First commit 🎉

This commit is contained in:
Tony Bark 2025-07-17 01:49:18 -04:00
commit 43ea213f9b
728 changed files with 37080 additions and 0 deletions

View file

@ -0,0 +1,139 @@
@tool
class_name GUIPopup
extends Control
## The base popup node used by Popochiu GUIs.
@export var closes_by_clicking_out := true
@export var script_name: StringName = ""
@export var title := "" : set = set_title
@onready var lbl_title: Label = %Title
@onready var btn_ok: Button = %Ok
@onready var btn_cancel: Button = %Cancel
@onready var btn_close: TextureButton = %Close
#region Godot ######################################################################################
func _ready() -> void:
if not title.is_empty():
lbl_title.text = title
if Engine.is_editor_hint(): return
# Connect to own signals
$Overlay.gui_input.connect(_check_click)
# Connect to child signals
btn_ok.pressed.connect(on_ok_pressed)
btn_cancel.pressed.connect(on_cancel_pressed)
btn_close.pressed.connect(on_cancel_pressed)
# Connect to singleton signals
PopochiuUtils.g.popup_requested.connect(_on_popup_requested)
close()
#endregion
#region Virtual ####################################################################################
## Called when the popup is opened. At this point it is not visible yet.
func _open() -> void:
pass
## Called when the popup is closed. The node hides after calling this method.
func _close() -> void:
pass
## Called when OK is pressed.
func _on_ok() -> void:
pass
## Called when CANCEL or X (top-right corner) are pressed.
func _on_cancel() -> void:
pass
#endregion
#region Public #####################################################################################
## Shows the popup scaling it and blocking interactions with the graphic interface.
func open() -> void:
_open()
PopochiuUtils.g.block()
PopochiuUtils.cursor.show_cursor("gui", true)
# Never open a popup on top of another
if not PopochiuUtils.e.gui.popups_stack.is_empty():
PopochiuUtils.e.gui.popups_stack.back().hide()
PopochiuUtils.e.gui.popups_stack.append(self)
show()
## Closes the popup unlocking interactions with the graphic interface.
func close() -> void:
PopochiuUtils.e.gui.popups_stack.erase(self)
hide()
if PopochiuUtils.e.gui.popups_stack.is_empty():
PopochiuUtils.g.unblock()
PopochiuUtils.cursor.unblock()
else:
# Idempotent call, no need to check the mode
PopochiuUtils.e.gui.popups_stack.back().show()
_close()
## Called when the OK button is pressed. It closes the popup afterwards.
func on_ok_pressed() -> void:
_on_ok()
close()
## Called when the CANCEL button is pressed. It closes the popup afterwards.
func on_cancel_pressed() -> void:
_on_cancel()
close()
## Called when the X (top-right corner) button is pressed. It closes the popup
## afterwards.
func on_close_pressed() -> void:
_on_cancel()
close()
#endregion
#region SetGet #####################################################################################
func set_title(value: String) -> void:
title = value
if is_instance_valid(lbl_title):
lbl_title.text = title
#endregion
#region Private ####################################################################################
## 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
and closes_by_clicking_out
):
_on_cancel()
close()
func _on_popup_requested(popup_script_name: StringName) -> void:
if popup_script_name == script_name:
open()
#endregion

View file

@ -0,0 +1 @@
uid://dkhut4ro2glfh

View file

@ -0,0 +1,2 @@
@tool
extends "popochiu_popup.gd"

View file

@ -0,0 +1 @@
uid://deajt0yn7u242

View file

@ -0,0 +1,12 @@
[gd_resource type="StyleBoxFlat" format=3 uid="uid://ue48aimeiar7"]
[resource]
content_margin_left = 4.0
content_margin_top = 2.0
content_margin_right = 4.0
content_margin_bottom = 2.0
bg_color = Color(0, 0, 0, 0.705882)
expand_margin_left = 2.0
expand_margin_top = 2.0
expand_margin_right = 2.0
expand_margin_bottom = 2.0

View file

@ -0,0 +1,26 @@
@tool
extends PopochiuPopup
#region Virtual ####################################################################################
## Called when the popup is opened. At this point it is not visible yet.
func _open() -> void:
pass
## Called when the popup is closed. The node hides after calling this method.
func _close() -> void:
pass
## Called when OK is pressed.
func _on_ok() -> void:
get_tree().quit()
## Called when CANCEL or X (top-right corner) are pressed.
func _on_cancel() -> void:
pass
#endregion

View file

@ -0,0 +1 @@
uid://tmuymrue3vd2

View file

@ -0,0 +1,84 @@
[gd_scene load_steps=7 format=3 uid="uid://cvuyvuwt3dh4r"]
[ext_resource type="Theme" uid="uid://djl1xk7jgyvpp" path="res://game/gui/resources/gui_theme.tres" id="1_80fb2"]
[ext_resource type="Script" uid="uid://b01j2is3thxla" path="res://game/gui/components/popups/quit_popup/quit_popup_custom.gd" id="2_6j1m7"]
[ext_resource type="StyleBox" uid="uid://ue48aimeiar7" path="res://game/gui/components/popups/popochiu_popup_panel_container.tres" id="3_ou8w6"]
[ext_resource type="Texture2D" uid="uid://d127ve13o2kpl" path="res://game/gui/resources/images/close.png" id="4_jwtna"]
[ext_resource type="Texture2D" uid="uid://b3q226w2e3giu" path="res://game/gui/resources/images/close_highlight.png" id="5_8umn4"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_il3mr"]
[node name="QuitPopup" type="Control" groups=["popochiu_gui_popup"]]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_80fb2")
script = ExtResource("2_6j1m7")
script_name = &"QuitPopup"
title = "Quit game"
[node name="Overlay" type="PanelContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_styles/panel = SubResource("StyleBoxEmpty_il3mr")
[node name="PanelContainer" type="PanelContainer" parent="Overlay"]
custom_minimum_size = Vector2(256, 0)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
theme_override_styles/panel = ExtResource("3_ou8w6")
[node name="VBoxContainer" type="VBoxContainer" parent="Overlay/PanelContainer"]
layout_mode = 2
[node name="HeaderContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="Title" type="Label" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
text = "Quit game"
horizontal_alignment = 1
vertical_alignment = 1
[node name="Close" type="TextureButton" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
unique_name_in_owner = true
texture_filter = 1
layout_mode = 2
size_flags_vertical = 4
texture_normal = ExtResource("4_jwtna")
texture_pressed = ExtResource("5_8umn4")
texture_hover = ExtResource("5_8umn4")
[node name="Question" type="Label" parent="Overlay/PanelContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
text = "Are you sure you want to quit?"
horizontal_alignment = 1
vertical_alignment = 1
autowrap_mode = 3
[node name="FooterContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 10
alignment = 1
[node name="Ok" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "OK"
[node name="Cancel" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Cancel
"

View file

@ -0,0 +1,2 @@
@tool
extends "quit_popup.gd"

View file

@ -0,0 +1 @@
uid://b01j2is3thxla

View file

@ -0,0 +1,134 @@
@tool
extends PopochiuPopup
signal slot_selected
const SELECTION_COLOR := Color("edf171")
const OVERWRITE_COLOR := Color("c46c71")
var _current_slot: Button = null
var _slot_name := ""
var _prev_text := ""
var _slot := 0
@onready var slots: VBoxContainer = %Slots
#region Godot ######################################################################################
func _ready() -> void:
super()
if Engine.is_editor_hint(): return
btn_ok.disabled = true
var saves: Dictionary = PopochiuUtils.e.get_saves_descriptions()
for btn: Button in slots.get_children():
btn.set_meta("has_save", false)
if saves.has(btn.get_index() + 1):
btn.text = saves[btn.get_index() + 1]
btn.set_meta("has_save", true)
else:
btn.disabled = true
btn.pressed.connect(_select_slot.bind(btn))
#endregion
#region Virtual ####################################################################################
func _open() -> void:
btn_ok.disabled = true
_slot = 0
if _current_slot:
_current_slot.text = _prev_text
_current_slot.button_pressed = false
_current_slot = null
_prev_text = ""
func _close() -> void:
if not _slot: return
slot_selected.emit()
if _slot_name:
PopochiuUtils.e.save_game(_slot, _slot_name)
else:
PopochiuUtils.e.load_game(_slot)
func _on_ok() -> void:
_slot = _current_slot.get_index() + 1
if _slot_name:
_prev_text = _current_slot.text
_current_slot.set_meta("has_save", true)
#endregion
#region Public #####################################################################################
func open_save() -> void:
_show_save()
func open_load() -> void:
_show_load()
#endregion
#region Private ####################################################################################
func _show_save(slot_text := "") -> void:
lbl_title.text = "Choose a slot to save the game"
_slot_name = slot_text
if _slot_name.is_empty():
_slot_name = _format_date(Time.get_datetime_dict_from_system())
for btn in slots.get_children():
btn.disabled = false
open()
func _show_load() -> void:
lbl_title.text = "Choose the slot to load"
_slot_name = ""
for btn in slots.get_children():
btn.disabled = !(btn as Button).get_meta("has_save")
open()
func _select_slot(btn: Button) -> void:
if _slot_name:
if _current_slot:
_current_slot.text = _prev_text
_current_slot.button_pressed = false
_current_slot = btn
_prev_text = _current_slot.text
_current_slot.text = _slot_name
else:
if _current_slot:
_current_slot.button_pressed = false
_current_slot = btn
_prev_text = _current_slot.text
btn_ok.disabled = false
func _format_date(date: Dictionary) -> String:
return "%d/%02d/%02d %02d:%02d:%02d" % [
date.year, date.month, date.day, date.hour, date.minute, date.second
]
#endregion

View file

@ -0,0 +1 @@
uid://5wnpp5td5dcx

View file

@ -0,0 +1,100 @@
[gd_scene load_steps=7 format=3 uid="uid://tgyca2usqnn1"]
[ext_resource type="Theme" uid="uid://djl1xk7jgyvpp" path="res://game/gui/resources/gui_theme.tres" id="1_vmhif"]
[ext_resource type="Script" uid="uid://c30sbvthxnrr0" path="res://game/gui/components/popups/save_and_load_popup/save_and_load_popup_custom.gd" id="2_mh08k"]
[ext_resource type="StyleBox" uid="uid://ue48aimeiar7" path="res://game/gui/components/popups/popochiu_popup_panel_container.tres" id="3_3nj74"]
[ext_resource type="Texture2D" uid="uid://d127ve13o2kpl" path="res://game/gui/resources/images/close.png" id="4_sf4bt"]
[ext_resource type="Texture2D" uid="uid://b3q226w2e3giu" path="res://game/gui/resources/images/close_highlight.png" id="5_xdowh"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_yg86r"]
[node name="SaveAndLoadPopup" type="Control" groups=["popochiu_gui_popup"]]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_vmhif")
script = ExtResource("2_mh08k")
script_name = &"SaveAndLoadPopup"
[node name="Overlay" type="PanelContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_styles/panel = SubResource("StyleBoxEmpty_yg86r")
[node name="PanelContainer" type="PanelContainer" parent="Overlay"]
custom_minimum_size = Vector2(192, 0)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
theme_override_styles/panel = ExtResource("3_3nj74")
[node name="VBoxContainer" type="VBoxContainer" parent="Overlay/PanelContainer"]
layout_mode = 2
[node name="HeaderContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="Title" type="Label" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
text = "Choose a slot to..."
horizontal_alignment = 1
vertical_alignment = 1
[node name="Close" type="TextureButton" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
unique_name_in_owner = true
texture_filter = 1
layout_mode = 2
size_flags_vertical = 4
texture_normal = ExtResource("4_sf4bt")
texture_pressed = ExtResource("5_xdowh")
texture_hover = ExtResource("5_xdowh")
[node name="Slots" type="VBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
alignment = 1
[node name="BtnSlot1" type="Button" parent="Overlay/PanelContainer/VBoxContainer/Slots"]
layout_mode = 2
toggle_mode = true
text = "slot 1"
[node name="BtnSlot2" type="Button" parent="Overlay/PanelContainer/VBoxContainer/Slots"]
layout_mode = 2
toggle_mode = true
text = "slot 2"
[node name="BtnSlot3" type="Button" parent="Overlay/PanelContainer/VBoxContainer/Slots"]
layout_mode = 2
toggle_mode = true
text = "slot 3"
[node name="BtnSlot4" type="Button" parent="Overlay/PanelContainer/VBoxContainer/Slots"]
layout_mode = 2
toggle_mode = true
text = "slot 4"
[node name="FooterContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 10
alignment = 1
[node name="Ok" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "OK"
[node name="Cancel" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Cancel"

View file

@ -0,0 +1,2 @@
@tool
extends "save_and_load_popup.gd"

View file

@ -0,0 +1 @@
uid://c30sbvthxnrr0

View file

@ -0,0 +1,40 @@
@tool
extends PopochiuPopup
@onready var text_speed: HSlider = %TextSpeed
@onready var dialog_style: OptionButton = %DialogStyle
@onready var continue_mode: CheckButton = %ContinueMode
#region Godot ######################################################################################
func _ready() -> void:
super()
if Engine.is_editor_hint(): return
text_speed.value = 0.1 - PopochiuUtils.e.text_speed
dialog_style.selected = PopochiuUtils.e.settings.dialog_style
continue_mode.button_pressed = PopochiuUtils.e.settings.auto_continue_text
# Connect to child 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)
#endregion
#region Private ####################################################################################
func _on_text_speed_changed(value: float) -> void:
PopochiuUtils.e.text_speed = 0.1 - value
func _on_dialog_style_selected(idx: int) -> void:
PopochiuUtils.e.current_dialog_style = dialog_style.get_item_id(idx)
func _on_continue_mode_toggled(toggled_on: bool) -> void:
PopochiuUtils.e.settings.auto_continue_text = toggled_on
#endregion

View file

@ -0,0 +1 @@
uid://dri5b2wiyrk2k

View file

@ -0,0 +1,151 @@
[gd_scene load_steps=13 format=3 uid="uid://b7eigjmiv4k0y"]
[ext_resource type="Theme" uid="uid://djl1xk7jgyvpp" path="res://game/gui/resources/gui_theme.tres" id="1_0bw1h"]
[ext_resource type="Script" uid="uid://bme4hhwe1ej25" path="res://game/gui/components/popups/text_settings_popup/text_settings_popup_custom.gd" id="2_t0dmb"]
[ext_resource type="StyleBox" uid="uid://ue48aimeiar7" path="res://game/gui/components/popups/popochiu_popup_panel_container.tres" id="3_1lm8y"]
[ext_resource type="Texture2D" uid="uid://d127ve13o2kpl" path="res://game/gui/resources/images/close.png" id="4_ml574"]
[ext_resource type="Texture2D" uid="uid://b3q226w2e3giu" path="res://game/gui/resources/images/close_highlight.png" id="5_8vsjw"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_bh5os"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_b5jxw"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_rinqp"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_vprmd"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_372y7"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_t5skw"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_5015x"]
[node name="TextSettingsPopup" type="Control" groups=["popochiu_gui_popup"]]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_0bw1h")
script = ExtResource("2_t0dmb")
script_name = &"SierraTextPopup"
title = "Text options"
[node name="Overlay" type="PanelContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_styles/panel = SubResource("StyleBoxEmpty_bh5os")
[node name="PanelContainer" type="PanelContainer" parent="Overlay"]
custom_minimum_size = Vector2(160, 140)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
theme_override_styles/panel = ExtResource("3_1lm8y")
[node name="VBoxContainer" type="VBoxContainer" parent="Overlay/PanelContainer"]
layout_mode = 2
[node name="HeaderContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="Title" type="Label" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
text = "Text options"
horizontal_alignment = 1
vertical_alignment = 1
[node name="Close" type="TextureButton" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
unique_name_in_owner = true
visible = false
texture_filter = 1
layout_mode = 2
size_flags_vertical = 4
texture_normal = ExtResource("4_ml574")
texture_pressed = ExtResource("5_8vsjw")
texture_hover = ExtResource("5_8vsjw")
[node name="BodyContainer" type="VBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="TextSpeedContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/TextSpeedContainer"]
layout_mode = 2
text = "Typing speed"
[node name="TextSpeed" type="HSlider" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/TextSpeedContainer"]
unique_name_in_owner = true
texture_filter = 1
layout_mode = 2
size_flags_horizontal = 3
max_value = 0.1
step = 0.01
[node name="DialogStyleContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer"]
visible = false
layout_mode = 2
[node name="Label" type="Label" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/DialogStyleContainer"]
layout_mode = 2
text = "Style"
horizontal_alignment = 1
[node name="DialogStyle" type="OptionButton" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/DialogStyleContainer"]
unique_name_in_owner = true
texture_filter = 1
layout_mode = 2
size_flags_horizontal = 3
selected = 0
item_count = 3
popup/item_0/text = "Above character"
popup/item_1/text = "Portrait"
popup/item_1/id = 1
popup/item_2/text = "Caption"
popup/item_2/id = 2
[node name="ContinueModeContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/ContinueModeContainer"]
layout_mode = 2
text = "Autoadvance"
horizontal_alignment = 1
[node name="ContinueMode" type="CheckButton" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/ContinueModeContainer"]
unique_name_in_owner = true
texture_filter = 1
layout_mode = 2
size_flags_horizontal = 10
size_flags_vertical = 0
theme_override_styles/focus = SubResource("StyleBoxEmpty_b5jxw")
theme_override_styles/disabled = SubResource("StyleBoxEmpty_rinqp")
theme_override_styles/hover_pressed = SubResource("StyleBoxEmpty_vprmd")
theme_override_styles/hover = SubResource("StyleBoxEmpty_372y7")
theme_override_styles/pressed = SubResource("StyleBoxEmpty_t5skw")
theme_override_styles/normal = SubResource("StyleBoxEmpty_5015x")
icon_alignment = 2
[node name="FooterContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 10
alignment = 1
[node name="Ok" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
text = "OK"
[node name="Cancel" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Back"

View file

@ -0,0 +1,2 @@
@tool
extends "text_settings_popup.gd"

View file

@ -0,0 +1 @@
uid://bme4hhwe1ej25