Skip to content

Commit

Permalink
refs #373: Create DialogueAdvancement component with better feedback.
Browse files Browse the repository at this point in the history
This component uses a CheckButton with two labels so players can have
a better understanding of the current dialogue advancement mode.
  • Loading branch information
mapedorr committed Jan 17, 2025
1 parent 301dd3d commit 41de770
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
extends Control

@onready var input_button: LinkButton = $InputButton
@onready var manual: Label = %Manual
@onready var continue_mode: CheckButton = %ContinueMode
@onready var auto: Label = %Auto


#region Godot ######################################################################################
func _ready() -> void:
# Set default values
input_button.button_pressed = PopochiuUtils.e.settings.auto_continue_text
continue_mode.button_pressed = PopochiuUtils.e.settings.auto_continue_text
_update_labels()

# Connect to children signals
input_button.toggled.connect(_on_toggled)


#endregion

#region Private ####################################################################################
func _update_labels() -> void:
if input_button.button_pressed:
manual.modulate.a = 0.5
auto.modulate.a = 1.0
else:
manual.modulate.a = 1.0
auto.modulate.a = 0.5


func _on_toggled(toggled_on: bool) -> void:
PopochiuUtils.e.settings.auto_continue_text = toggled_on
continue_mode.button_pressed = toggled_on
_update_labels()


#endregion
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[gd_scene load_steps=6 format=3 uid="uid://clhnbnew4ydpc"]

[ext_resource type="Texture2D" uid="uid://cm5ik18o3ragq" path="res://addons/popochiu/engine/objects/gui/components/dialogue_advancement/images/dialogue_advancement_check_button.png" id="1_pbw0k"]
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_woi6t"]
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/dialogue_advancement/dialogue_advancement.gd" id="2_ju60a"]

[sub_resource type="AtlasTexture" id="AtlasTexture_eca4m"]
atlas = ExtResource("1_pbw0k")
region = Rect2(26, 0, 26, 13)

[sub_resource type="AtlasTexture" id="AtlasTexture_1ivvq"]
atlas = ExtResource("1_pbw0k")
region = Rect2(0, 0, 26, 13)

[node name="DialogueAdvancement" type="Control" groups=["popochiu_gui_component"]]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_woi6t")
script = ExtResource("2_ju60a")

[node name="InputButton" type="LinkButton" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
toggle_mode = true

[node name="HBoxContainer" type="HBoxContainer" parent="InputButton"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

[node name="Manual" type="Label" parent="InputButton/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Manual"

[node name="ContinueMode" type="CheckButton" parent="InputButton/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
mouse_filter = 2
theme_override_icons/checked = SubResource("AtlasTexture_eca4m")
theme_override_icons/unchecked = SubResource("AtlasTexture_1ivvq")

[node name="Auto" type="Label" parent="InputButton/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Auto"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ extends PopochiuPopup
@onready var load: Button = %Load
@onready var history: Button = %History
@onready var quit: Button = %Quit
@onready var continue_mode: OptionButton = %ContinueMode
@onready var text_speed: HSlider = %TextSpeed
@onready var text_speed_label: Label = %TextSpeedLabel

Expand All @@ -18,17 +17,13 @@ func _ready() -> void:

# Set default values
text_speed.value = 0.1 - PopochiuUtils.e.text_speed
continue_mode.selected = 0 if PopochiuUtils.e.settings.auto_continue_text else 1
text_speed_label.text = "%.2fx" % PopochiuUtils.e.text_speed
continue_mode.get_popup().canvas_item_default_texture_filter =\
Viewport.DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST

# Connect to children signals
save.pressed.connect(_on_save_pressed)
load.pressed.connect(_on_load_pressed)
history.pressed.connect(_on_history_pressed)
quit.pressed.connect(_on_quit_pressed)
continue_mode.item_selected.connect(_on_continue_mode_selected)
text_speed.value_changed.connect(_on_text_speed_changed)


Expand All @@ -51,10 +46,6 @@ func _on_quit_pressed() -> void:
PopochiuUtils.g.popup_requested.emit("QuitPopup")


func _on_continue_mode_selected(idx: int) -> void:
PopochiuUtils.e.settings.auto_continue_text = idx == 0


func _on_text_speed_changed(value: float) -> void:
PopochiuUtils.e.text_speed = 0.1 - value
text_speed_label.text = "%.2fx" % PopochiuUtils.e.text_speed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[gd_scene load_steps=19 format=3 uid="uid://bmpxoiebdf67g"]
[gd_scene load_steps=20 format=3 uid="uid://bmpxoiebdf67g"]

[ext_resource type="PackedScene" uid="uid://c51xplyeuk787" path="res://addons/popochiu/engine/objects/gui/components/popups/popochiu_popup.tscn" id="1_l0ff4"]
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/templates/simple_click/components/simple_click_settings_popup/simple_click_settings_popup.gd" id="2_y4ddu"]
[ext_resource type="Texture2D" uid="uid://0b0qq0lccphh" path="res://addons/popochiu/engine/objects/gui/templates/simple_click/components/simple_click_settings_popup/images/simple_click_settings_popup_icons.png" id="3_fhu7w"]
[ext_resource type="PackedScene" uid="uid://drx0r8w00ivck" path="res://addons/popochiu/engine/objects/gui/components/sound_volumes/sound_volumes.tscn" id="3_w0ss4"]
[ext_resource type="PackedScene" uid="uid://clhnbnew4ydpc" path="res://addons/popochiu/engine/objects/gui/components/dialogue_advancement/dialogue_advancement.tscn" id="5_chydt"]

[sub_resource type="AtlasTexture" id="AtlasTexture_n1wdd"]
atlas = ExtResource("3_fhu7w")
Expand Down Expand Up @@ -132,7 +133,7 @@ layout_mode = 2

[node name="Label" type="Label" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/RightContainer/ContinueContainer" index="0"]
layout_mode = 2
text = "Continue Mode"
text = "Dialogue Advancement"

[node name="HBoxContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/RightContainer/ContinueContainer" index="1"]
layout_mode = 2
Expand All @@ -141,14 +142,9 @@ layout_mode = 2
layout_mode = 2
texture = SubResource("AtlasTexture_gnvye")

[node name="ContinueMode" type="OptionButton" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/RightContainer/ContinueContainer/HBoxContainer" index="1"]
unique_name_in_owner = true
[node name="DialogueAdvancement" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/RightContainer/ContinueContainer/HBoxContainer" index="1" instance=ExtResource("5_chydt")]
layout_mode = 2
size_flags_horizontal = 3
item_count = 2
popup/item_0/text = "Auto"
popup/item_1/text = "Manual"
popup/item_1/id = 1

[node name="DialogueSpeedContainer" type="VBoxContainer" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/RightContainer" index="2"]
layout_mode = 2
Expand Down

0 comments on commit 41de770

Please sign in to comment.