Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion addons/dialogue_manager/dialogue_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ signal bridge_get_line_completed(call_index: int, line: DialogueLine)
## Used internally
signal bridge_mutated(call_index: int)

const BALLOON_VARIANTS := {
"top": "res://scenes/ui_elements/dialogue/balloon_top.tscn",
"right": "res://scenes/ui_elements/dialogue/balloon_right.tscn",
"bottom": "res://scenes/ui_elements/dialogue/balloon_bottom.tscn",
"left": "res://scenes/ui_elements/dialogue/balloon_left.tscn",
}

const BALLOON_SIMPLE_VARIANTS := {
"top": "res://scenes/ui_elements/dialogue/balloon_top_simple.tscn",
"right": "res://scenes/ui_elements/dialogue/balloon_right_simple.tscn",
"bottom": "res://scenes/ui_elements/dialogue/balloon_bottom_simple.tscn",
"left": "res://scenes/ui_elements/dialogue/balloon_left_simple.tscn",
}
Comment thread
wjt marked this conversation as resolved.

## The list of globals that dialogue can query
var game_states: Array = []
Expand Down Expand Up @@ -515,7 +528,15 @@ func show_example_dialogue_balloon(resource: DialogueResource, title: String = "

## Show the configured dialogue balloon
func show_dialogue_balloon(resource: DialogueResource, title: String = "", extra_game_states: Array = []) -> Node:
var balloon_path: String = DMSettings.get_setting(DMSettings.BALLOON_PATH, _get_example_balloon_path())
var is_player_at_bottom := true
var player: Node2D = get_tree().get_first_node_in_group("player")
if player:
var viewport := player.get_viewport()
var screen_pos: Vector2 = viewport.get_canvas_transform() * player.global_position
var viewport_size: Vector2 = viewport.get_visible_rect().size
is_player_at_bottom = screen_pos.y > viewport_size.y / 2.0
var balloon_path: String = BALLOON_SIMPLE_VARIANTS["top"] if is_player_at_bottom else BALLOON_SIMPLE_VARIANTS["bottom"]
# var balloon_path: String = DMSettings.get_setting(DMSettings.BALLOON_PATH, _get_example_balloon_path())
if not ResourceLoader.exists(balloon_path):
balloon_path = _get_example_balloon_path()
return show_dialogue_balloon_scene(balloon_path, resource, title, extra_game_states)
Expand Down
94 changes: 94 additions & 0 deletions scenes/ui_elements/dialogue/balloon_bottom.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
[gd_scene format=3 uid="uid://3vqiyiuqusa6"]

[ext_resource type="Script" uid="uid://n1guv6m28qbw" path="res://scenes/ui_elements/dialogue/components/balloon.gd" id="1_iren2"]
[ext_resource type="Theme" uid="uid://cvitou84ni7qe" path="res://scenes/ui_elements/components/theme.tres" id="2_hfoq0"]
[ext_resource type="PackedScene" uid="uid://ckvgyvclnwggo" path="res://addons/dialogue_manager/dialogue_label.tscn" id="3_x03ja"]
[ext_resource type="Texture2D" uid="uid://ctvutcaoqvftf" path="res://assets/first_party/icons/right_arrow.png" id="4_robwq"]
[ext_resource type="Script" uid="uid://bb52rsfwhkxbn" path="res://addons/dialogue_manager/dialogue_responses_menu.gd" id="5_yvslu"]
[ext_resource type="AudioStream" uid="uid://cs1bx2odpj6vm" path="res://scenes/ui_elements/dialogue/components/sounds/pencil.ogg" id="6_nlt11"]

[node name="DialogueBalloon" type="CanvasLayer" unique_id=308207015]
layer = 100
script = ExtResource("1_iren2")

[node name="Balloon" type="Control" parent="." unique_id=2032365240]
unique_name_in_owner = true
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("2_hfoq0")

[node name="PanelContainer" type="PanelContainer" parent="Balloon" unique_id=58550594]
layout_mode = 1
anchors_preset = -1
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -416.0
offset_top = 4096.0
offset_right = 416.0
grow_horizontal = 2
grow_vertical = 0

[node name="VBoxContainer" type="VBoxContainer" parent="Balloon/PanelContainer" unique_id=412895659]
custom_minimum_size = Vector2(704, 0)
layout_mode = 2
size_flags_vertical = 8
theme_override_constants/separation = 3

[node name="CharacterPanel" type="PanelContainer" parent="Balloon/PanelContainer/VBoxContainer" unique_id=383126775]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 64)
layout_mode = 2
size_flags_horizontal = 0
theme_type_variation = &"NPCRibbon"

[node name="CharacterLabel" type="Label" parent="Balloon/PanelContainer/VBoxContainer/CharacterPanel" unique_id=172265592]
unique_name_in_owner = true
layout_mode = 2
mouse_filter = 1
text = "Musician"
horizontal_alignment = 1

[node name="DialogueLabel" parent="Balloon/PanelContainer/VBoxContainer" unique_id=728821532 instance=ExtResource("3_x03ja")]
unique_name_in_owner = true
layout_mode = 2
text = "¡Ah! ¿Another wanderer? It’s been a while siñce aňyone çame löõkiŋ for instead of «treaßure»."
skip_action = &"dialogue_skip"

[node name="NextButton" type="Button" parent="Balloon/PanelContainer/VBoxContainer" unique_id=110419078]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 8
theme_type_variation = &"FlatNextButton"
text = "next"
icon = ExtResource("4_robwq")
icon_alignment = 2

[node name="ResponsesMenu" type="VBoxContainer" parent="Balloon/PanelContainer/VBoxContainer" unique_id=938619174 node_paths=PackedStringArray("response_template")]
unique_name_in_owner = true
visible = false
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 8
theme_override_constants/separation = 2
script = ExtResource("5_yvslu")
response_template = NodePath("ResponseExample")

[node name="ResponseExample" type="Button" parent="Balloon/PanelContainer/VBoxContainer/ResponsesMenu" unique_id=957333658]
layout_mode = 2
theme_type_variation = &"FlatButton"
text = "Response example"

[node name="TalkSoundPlayer" type="AudioStreamPlayer" parent="." unique_id=1778551533]
stream = ExtResource("6_nlt11")
volume_db = 2.0
bus = &"SFX"
parameters/looping = true

[connection signal="gui_input" from="Balloon" to="." method="_on_balloon_gui_input"]
[connection signal="response_selected" from="Balloon/PanelContainer/VBoxContainer/ResponsesMenu" to="." method="_on_responses_menu_response_selected"]
110 changes: 110 additions & 0 deletions scenes/ui_elements/dialogue/balloon_bottom_simple.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
[gd_scene format=3 uid="uid://cklb5tsenn428"]

[ext_resource type="Script" uid="uid://n1guv6m28qbw" path="res://scenes/ui_elements/dialogue/components/balloon.gd" id="1_a72yx"]
[ext_resource type="Theme" uid="uid://cvitou84ni7qe" path="res://scenes/ui_elements/components/theme.tres" id="2_qgnmu"]
[ext_resource type="Texture2D" uid="uid://dh4tixu06hfwt" path="res://assets/third_party/tiny-swords/UI/Banners/Carved_9Slides.png" id="3_qgnmu"]
[ext_resource type="PackedScene" uid="uid://ckvgyvclnwggo" path="res://addons/dialogue_manager/dialogue_label.tscn" id="3_v4opp"]
[ext_resource type="Texture2D" uid="uid://ctvutcaoqvftf" path="res://assets/first_party/icons/right_arrow.png" id="4_g5sha"]
[ext_resource type="Script" uid="uid://bb52rsfwhkxbn" path="res://addons/dialogue_manager/dialogue_responses_menu.gd" id="5_ror8n"]
[ext_resource type="AudioStream" uid="uid://cs1bx2odpj6vm" path="res://scenes/ui_elements/dialogue/components/sounds/pencil.ogg" id="6_rrpqg"]

[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_beq22"]
content_margin_left = 16.0
content_margin_top = 16.0
content_margin_right = 16.0
content_margin_bottom = 16.0
texture = ExtResource("3_qgnmu")
texture_margin_left = 64.0
texture_margin_top = 64.0
texture_margin_right = 64.0
texture_margin_bottom = 64.0
axis_stretch_horizontal = 1
axis_stretch_vertical = 1
modulate_color = Color(1.3807716, 1.3807716, 1.3807716, 0.83137256)

[node name="DialogueBalloon" type="CanvasLayer" unique_id=308207015]
layer = 100
script = ExtResource("1_a72yx")

[node name="Balloon" type="Control" parent="." unique_id=2032365240]
unique_name_in_owner = true
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("2_qgnmu")

[node name="PanelContainer" type="PanelContainer" parent="Balloon" unique_id=58550594]
layout_mode = 1
anchors_preset = -1
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -416.0
offset_top = 4096.0
offset_right = 416.0
grow_horizontal = 2
grow_vertical = 0
theme_override_styles/panel = SubResource("StyleBoxTexture_beq22")

[node name="VBoxContainer" type="VBoxContainer" parent="Balloon/PanelContainer" unique_id=412895659]
custom_minimum_size = Vector2(704, 0)
layout_mode = 2
size_flags_vertical = 8
theme_override_constants/separation = 3

[node name="CharacterPanel" type="PanelContainer" parent="Balloon/PanelContainer/VBoxContainer" unique_id=383126775]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 64)
layout_mode = 2
size_flags_horizontal = 0
theme_type_variation = &"NPCRibbon"

[node name="CharacterLabel" type="Label" parent="Balloon/PanelContainer/VBoxContainer/CharacterPanel" unique_id=172265592]
unique_name_in_owner = true
layout_mode = 2
mouse_filter = 1
text = "Musician"
horizontal_alignment = 1

[node name="DialogueLabel" parent="Balloon/PanelContainer/VBoxContainer" unique_id=728821532 instance=ExtResource("3_v4opp")]
unique_name_in_owner = true
layout_mode = 2
text = "¡Ah! ¿Another wanderer? It’s been a while siñce aňyone çame löõkiŋ for instead of «treaßure»."
skip_action = &"dialogue_skip"

[node name="NextButton" type="Button" parent="Balloon/PanelContainer/VBoxContainer" unique_id=110419078]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 8
theme_type_variation = &"FlatNextButton"
text = "next"
icon = ExtResource("4_g5sha")
icon_alignment = 2

[node name="ResponsesMenu" type="VBoxContainer" parent="Balloon/PanelContainer/VBoxContainer" unique_id=938619174 node_paths=PackedStringArray("response_template")]
unique_name_in_owner = true
visible = false
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 8
theme_override_constants/separation = 2
script = ExtResource("5_ror8n")
response_template = NodePath("ResponseExample")

[node name="ResponseExample" type="Button" parent="Balloon/PanelContainer/VBoxContainer/ResponsesMenu" unique_id=957333658]
layout_mode = 2
theme_type_variation = &"FlatButton"
text = "Response example"

[node name="TalkSoundPlayer" type="AudioStreamPlayer" parent="." unique_id=1778551533]
stream = ExtResource("6_rrpqg")
volume_db = 2.0
bus = &"SFX"
parameters/looping = true

[connection signal="gui_input" from="Balloon" to="." method="_on_balloon_gui_input"]
[connection signal="response_selected" from="Balloon/PanelContainer/VBoxContainer/ResponsesMenu" to="." method="_on_responses_menu_response_selected"]
96 changes: 96 additions & 0 deletions scenes/ui_elements/dialogue/balloon_left_simple.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
[gd_scene format=3 uid="uid://byqupqcoaocxg"]

[ext_resource type="Script" uid="uid://n1guv6m28qbw" path="res://scenes/ui_elements/dialogue/components/balloon.gd" id="1_e61yc"]
[ext_resource type="Theme" uid="uid://cvitou84ni7qe" path="res://scenes/ui_elements/components/theme.tres" id="2_g6ctl"]
[ext_resource type="Texture2D" uid="uid://dh4tixu06hfwt" path="res://assets/third_party/tiny-swords/UI/Banners/Carved_9Slides.png" id="3_g6ctl"]
[ext_resource type="PackedScene" uid="uid://ckvgyvclnwggo" path="res://addons/dialogue_manager/dialogue_label.tscn" id="3_x84yq"]
[ext_resource type="Texture2D" uid="uid://ctvutcaoqvftf" path="res://assets/first_party/icons/right_arrow.png" id="4_723pg"]
[ext_resource type="Script" uid="uid://bb52rsfwhkxbn" path="res://addons/dialogue_manager/dialogue_responses_menu.gd" id="5_7tvoj"]
[ext_resource type="AudioStream" uid="uid://cs1bx2odpj6vm" path="res://scenes/ui_elements/dialogue/components/sounds/pencil.ogg" id="6_bbwuq"]

[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_beq22"]
content_margin_left = 16.0
content_margin_top = 16.0
content_margin_right = 16.0
content_margin_bottom = 16.0
texture = ExtResource("3_g6ctl")
texture_margin_left = 64.0
texture_margin_top = 64.0
texture_margin_right = 64.0
texture_margin_bottom = 64.0
axis_stretch_horizontal = 1
axis_stretch_vertical = 1
modulate_color = Color(1.3807716, 1.3807716, 1.3807716, 0.83137256)

[node name="DialogueBalloon" type="CanvasLayer" unique_id=308207015]
layer = 100
script = ExtResource("1_e61yc")

[node name="Balloon" type="Control" parent="." unique_id=2032365240]
unique_name_in_owner = true
layout_mode = 3
anchors_preset = 0
theme = ExtResource("2_g6ctl")

[node name="PanelContainer" type="PanelContainer" parent="Balloon" unique_id=58550594]
layout_mode = 0
offset_right = 480.0
offset_bottom = 359.0
theme_override_styles/panel = SubResource("StyleBoxTexture_beq22")

[node name="VBoxContainer" type="VBoxContainer" parent="Balloon/PanelContainer" unique_id=412895659]
custom_minimum_size = Vector2(352, 128)
layout_mode = 2

[node name="CharacterPanel" type="PanelContainer" parent="Balloon/PanelContainer/VBoxContainer" unique_id=383126775]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 64)
layout_mode = 2
size_flags_horizontal = 0
theme_type_variation = &"NPCRibbon"

[node name="CharacterLabel" type="Label" parent="Balloon/PanelContainer/VBoxContainer/CharacterPanel" unique_id=172265592]
unique_name_in_owner = true
layout_mode = 2
mouse_filter = 1
text = "Musician"
horizontal_alignment = 1

[node name="DialogueLabel" parent="Balloon/PanelContainer/VBoxContainer" unique_id=728821532 instance=ExtResource("3_x84yq")]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
text = "¡Ah! ¿Another wanderer? It’s been a while siñce aňyone çame löõkiŋ for instead of «treaßure»."
skip_action = &"dialogue_skip"

[node name="NextButton" type="Button" parent="Balloon/PanelContainer/VBoxContainer" unique_id=110419078]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 8
theme_type_variation = &"FlatNextButton"
text = "next"
icon = ExtResource("4_723pg")
icon_alignment = 2

[node name="ResponsesMenu" type="VBoxContainer" parent="Balloon/PanelContainer/VBoxContainer" unique_id=938619174 node_paths=PackedStringArray("response_template")]
unique_name_in_owner = true
visible = false
layout_mode = 2
size_flags_vertical = 8
theme_override_constants/separation = 2
script = ExtResource("5_7tvoj")
response_template = NodePath("ResponseExample")

[node name="ResponseExample" type="Button" parent="Balloon/PanelContainer/VBoxContainer/ResponsesMenu" unique_id=957333658]
layout_mode = 2
theme_type_variation = &"FlatButton"
text = "Response example"

[node name="TalkSoundPlayer" type="AudioStreamPlayer" parent="." unique_id=1778551533]
stream = ExtResource("6_bbwuq")
volume_db = 2.0
bus = &"SFX"
parameters/looping = true

[connection signal="gui_input" from="Balloon" to="." method="_on_balloon_gui_input"]
[connection signal="response_selected" from="Balloon/PanelContainer/VBoxContainer/ResponsesMenu" to="." method="_on_responses_menu_response_selected"]
Loading