Skip to content

Commit

Permalink
refs #373: Make buttons and other components usable.
Browse files Browse the repository at this point in the history
Players can now open the save, load, history and quit popups. They can
also change volumes, the text continue mode and the text speed.
  • Loading branch information
mapedorr committed Jan 5, 2025
1 parent 9a519fe commit ab85e7a
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func set_title(value: String) -> void:
#endregion

#region Private ####################################################################################
## Checks if the overlay area of the popup was clicked in order to close it.
# Checks if the overlay area of the popup was clicked in order to close it.
func _check_click(event: InputEvent) -> void:
if (
PopochiuUtils.get_click_or_touch_index(event) == MOUSE_BUTTON_LEFT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ signal slot_selected
const SELECTION_COLOR := Color("edf171")
const OVERWRITE_COLOR := Color("c46c71")

## The [code]script_name[/code] used to open the Save popup when the
## [signal PopochiuIGraphicInterface.popup_requested] signal is triggered.
@export var save_popup_script_name := &"SavePopup"
## The [code]script_name[/code] used to open the Load popup when the
## [signal PopochiuIGraphicInterface.popup_requested] signal is triggered.
@export var load_popup_script_name := &"LoadPopup"

var _current_slot: Button = null
var _slot_name := ""
var _prev_text := ""
Expand Down Expand Up @@ -68,7 +75,8 @@ func _on_ok() -> void:
if _slot_name:
_prev_text = _current_slot.text
_current_slot.set_meta("has_save", true)



#endregion

#region Public #####################################################################################
Expand All @@ -83,6 +91,15 @@ func open_load() -> void:
#endregion

#region Private ####################################################################################
func _on_popup_requested(popup_script_name: StringName) -> void:
if popup_script_name == save_popup_script_name:
_show_save()
elif popup_script_name == load_popup_script_name:
_show_load()
else:
super(popup_script_name)


func _show_save(slot_text := "") -> void:
lbl_title.text = "Choose a slot to save the game"
_slot_name = slot_text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func _ready() -> void:
dialog_style.selected = PopochiuUtils.e.settings.dialog_style
continue_mode.button_pressed = PopochiuUtils.e.settings.auto_continue_text

# Connect to child signals
# Connect to children signals
text_speed.value_changed.connect(_on_text_speed_changed)
dialog_style.item_selected.connect(_on_dialog_style_selected)
continue_mode.toggled.connect(_on_continue_mode_toggled)
Expand Down
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 @@ -89,7 +89,6 @@ func _input(event: InputEvent) -> void:
#region Private ####################################################################################
func _on_settings_pressed() -> void:
PopochiuUtils.g.popup_requested.emit("SimpleClickSettings")
#PopochiuUtils.g.gui.settings_requested.emit()


func _open() -> void:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
@tool
extends PopochiuPopup

@onready var save: Button = %Save
@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


#region Godot ######################################################################################
func _ready() -> void:
super()

if Engine.is_editor_hint(): return

# 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

# 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)


#endregion

#region Private ####################################################################################
func _on_save_pressed() -> void:
PopochiuUtils.g.popup_requested.emit("SavePopup")


func _on_load_pressed() -> void:
PopochiuUtils.g.popup_requested.emit("LoadPopup")


func _on_history_pressed() -> void:
PopochiuUtils.g.popup_requested.emit("HistoryPopup")


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


#endregion
Original file line number Diff line number Diff line change
@@ -1,46 +1,165 @@
[gd_scene load_steps=3 format=3 uid="uid://bmpxoiebdf67g"]
[gd_scene load_steps=17 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://bexxkrmqdiemq" path="res://addons/popochiu/engine/objects/gui/components/settings_bar/images/btn_save.png" id="3_iyxhd"]
[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="Texture2D" uid="uid://bns33w6nl2qkb" path="res://addons/popochiu/engine/objects/gui/components/settings_bar/images/btn_load.png" id="4_cxw13"]
[ext_resource type="Texture2D" uid="uid://bg1txcy1ofatq" path="res://addons/popochiu/engine/objects/gui/components/settings_bar/images/btn_dialog_history.png" id="5_8pumv"]
[ext_resource type="Texture2D" uid="uid://cxpcw7xvcjcfy" path="res://addons/popochiu/engine/objects/gui/components/settings_bar/images/btn_quit.png" id="6_o5sh3"]
[ext_resource type="Texture2D" uid="uid://cyvd8h2ouw8rg" path="res://addons/popochiu/engine/objects/gui/components/settings_bar/images/btn_audio.png" id="7_p3unk"]
[ext_resource type="Texture2D" uid="uid://hjol4hvanbt5" path="res://addons/popochiu/engine/objects/gui/components/settings_bar/images/btn_text.png" id="8_hh105"]

[sub_resource type="AtlasTexture" id="AtlasTexture_n1wdd"]
atlas = ExtResource("3_iyxhd")
region = Rect2(0, 0, 16, 16)

[sub_resource type="AtlasTexture" id="AtlasTexture_2g267"]
atlas = ExtResource("4_cxw13")
region = Rect2(0, 0, 16, 16)

[sub_resource type="AtlasTexture" id="AtlasTexture_wplse"]
atlas = ExtResource("5_8pumv")
region = Rect2(0, 0, 16, 16)

[sub_resource type="AtlasTexture" id="AtlasTexture_p5j1e"]
atlas = ExtResource("6_o5sh3")
region = Rect2(0, 0, 16, 16)

[sub_resource type="AtlasTexture" id="AtlasTexture_ktudv"]
atlas = ExtResource("7_p3unk")
region = Rect2(0, 0, 16, 16)

[sub_resource type="AtlasTexture" id="AtlasTexture_ocfjj"]
atlas = ExtResource("8_hh105")
region = Rect2(0, 0, 16, 16)

[sub_resource type="AtlasTexture" id="AtlasTexture_1jlhx"]
atlas = ExtResource("8_hh105")
region = Rect2(0, 0, 16, 16)

[node name="SimpleClickSettingsPopup" instance=ExtResource("1_l0ff4")]
texture_filter = 1
script = ExtResource("2_y4ddu")
script_name = &"SimpleClickSettings"

[node name="Overlay" parent="." index="0"]
self_modulate = Color(1, 1, 1, 0)

[node name="HeaderContainer" parent="Overlay/PanelContainer/VBoxContainer" index="0"]
visible = false

[node name="BodyContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer" index="1"]
layout_mode = 2

[node name="VBoxContainer" type="VBoxContainer" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer" index="0"]
[node name="LeftContainer" type="VBoxContainer" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer" index="0"]
layout_mode = 2

[node name="Save" type="Button" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/VBoxContainer" index="0"]
[node name="Save" type="Button" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/LeftContainer" index="0"]
unique_name_in_owner = true
layout_mode = 2
text = "Save"
icon = SubResource("AtlasTexture_n1wdd")
alignment = 0

[node name="Load" type="Button" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/VBoxContainer" index="1"]
[node name="Load" type="Button" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/LeftContainer" index="1"]
unique_name_in_owner = true
layout_mode = 2
text = "Load"
icon = SubResource("AtlasTexture_2g267")
alignment = 0

[node name="History" type="Button" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/VBoxContainer" index="2"]
[node name="History" type="Button" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/LeftContainer" index="2"]
unique_name_in_owner = true
layout_mode = 2
text = "History"
icon = SubResource("AtlasTexture_wplse")
alignment = 0

[node name="Quit" type="Button" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/VBoxContainer" index="3"]
[node name="Quit" type="Button" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/LeftContainer" index="3"]
unique_name_in_owner = true
layout_mode = 2
text = "Quit game"
size_flags_vertical = 10
text = "Quit"
icon = SubResource("AtlasTexture_p5j1e")
alignment = 0

[node name="VSeparator" type="VSeparator" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer" index="1"]
layout_mode = 2

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

[node name="VolumeContainer" type="VBoxContainer" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/RightContainer" index="0"]
layout_mode = 2

[node name="Label" type="Label" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/RightContainer/VolumeContainer" index="0"]
layout_mode = 2
text = "Volume"

[node name="HBoxContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/RightContainer/VolumeContainer" index="1"]
layout_mode = 2

[node name="Icon" type="TextureRect" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/RightContainer/VolumeContainer/HBoxContainer" index="0"]
layout_mode = 2
size_flags_vertical = 4
texture = SubResource("AtlasTexture_ktudv")

[node name="SoundVolumes" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/RightContainer/VolumeContainer/HBoxContainer" index="1" instance=ExtResource("3_w0ss4")]
layout_mode = 2

[node name="ContinueContainer" type="VBoxContainer" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/RightContainer" index="1"]
layout_mode = 2

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

[node name="HBoxContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/RightContainer/ContinueContainer" index="1"]
layout_mode = 2

[node name="Icon" type="TextureRect" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/RightContainer/ContinueContainer/HBoxContainer" index="0"]
layout_mode = 2
texture = SubResource("AtlasTexture_ocfjj")

[node name="ContinueMode" type="OptionButton" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/RightContainer/ContinueContainer/HBoxContainer" index="1"]
unique_name_in_owner = true
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

[node name="Label" type="Label" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/RightContainer/DialogueSpeedContainer" index="0"]
layout_mode = 2
text = "Dialogue Speed"

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

[node name="Icon" type="TextureRect" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/RightContainer/DialogueSpeedContainer/HBoxContainer" index="0"]
layout_mode = 2
texture = SubResource("AtlasTexture_1jlhx")

[node name="TextSpeed" type="HSlider" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/RightContainer/DialogueSpeedContainer/HBoxContainer" index="1"]
unique_name_in_owner = true
texture_filter = 1
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 4
max_value = 0.1
step = 0.01

[node name="TextSpeedLabel" type="Label" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/RightContainer/DialogueSpeedContainer/HBoxContainer" index="2"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 1
text = "0x"
vertical_alignment = 2

[node name="FooterContainer" parent="Overlay/PanelContainer/VBoxContainer" index="2"]
visible = false
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ extends PopochiuGraphicInterface
## inventory bar is in the top left corner of the screen, and the settings bar is in the top right
## corner of the screen.

signal settings_requested

@onready var settings_bar: Control = %SettingsBar
@onready var save_and_load_popup: Control = %SaveAndLoadPopup
@onready var text_settings_popup: Control = %TextSettingsPopup
Expand Down

0 comments on commit ab85e7a

Please sign in to comment.