Skip to content

Commit

Permalink
SimpleClick GUI improvements (#379)
Browse files Browse the repository at this point in the history
* refs #373: Create bar and settings popup for the SimpleClickGUI.

These components will replace the old InventoryBar and SettingsBar as
part of the update for the SimpleClickGUI as proposed be Papernoise.

* refs #373: Make buttons and other components usable.

Players can now open the save, load, history and quit popups. They can
also change volumes, the text continue mode and the text speed.

* refs #373: Update icons and add setup options to Sound Volumes component.

Now devs can set if the Sound Volumens component should show the Master
bus only and if it should show the label with the name for each bus.

- **upd** Add custom icons for radio buttons in PopupMenu for the
  base_gui_theme.tres.

* refs #373: Create DialogueAdvancement component with better feedback.

This component uses a CheckButton with two labels so players can have
a better understanding of the current dialogue advancement mode.

* refs #373: Remove non used components and popups in SimpleClick GUI.

This also updates the behavior of the cursor when hovering the settings
button (to be improved).

* refs #373: Progress on migration script to update the SimpleClick GUI.

The script is executed only if the project is using the SimpleClick
template, and it removes the InventoryBar, SettingsBar,
TextSettingsPopup and SoundSettingsPopup components.

* refs #373: Update migration script to add new components and update the SaveAndLoadPopup.

The new Simple Click GUI uses the SimpleClickBar and the
SimpleClickPopup components. Instead of adding a new migration step, the
SaveAndLoadPopup is also removed in the first step and then added in the
second one.

- **upd** Remove the `@onready` vars in the Simple Click GUI to access
  the SaveAndLoadPopup, HistoryPopup, and QuitPopup since it is no
  longer used to open those popups.

* refs #373: Update migration to avoid removing the SaveAndLoadPopup

Instead of this, the popup's main script is updated with the content
of the one in the addons folder.

* refs #373: Remove commented code and improve saving

* refs #373: Improve and homogenize icon sizing when items enter inventory.

- **fix**: Assign unique names to the **Up** and **Down** icons in the
  base **InventoryGrid** component.

* refs #373: Improve property value assignation based on review suggestion.

Co-authored-by: Paolo Pustorino <[email protected]>

* refs #373: Make improvements suggested by @stickgrinder on its PR review

- **upd** Reassign the texture used by the **AtlasTexture** of all the
  icons in the **SimpleClickSettingsPopup** to use the
  `simple_click_settings_popup_icons.png` instead of a
  CompressedTexture2D.

* refs #373: Update SimpleClickSettingsPopup icons based on PR feedback.

---------

Co-authored-by: Paolo Pustorino <[email protected]>
  • Loading branch information
mapedorr and stickgrinder authored Feb 14, 2025
1 parent b55a28d commit f19d252
Show file tree
Hide file tree
Showing 22 changed files with 827 additions and 61 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 = PopochiuGraphicInterface.UNSELECTED_ALPHA
auto.modulate.a = PopochiuGraphicInterface.SELECTED_ALPHA
else:
manual.modulate.a = PopochiuGraphicInterface.SELECTED_ALPHA
auto.modulate.a = PopochiuGraphicInterface.UNSELECTED_ALPHA


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 @@ -54,6 +54,7 @@ layout_mode = 2
theme_override_constants/separation = 0

[node name="Up" type="TextureButton" parent="ScrollButtons"]
unique_name_in_owner = true
texture_filter = 1
layout_mode = 2
size_flags_vertical = 3
Expand All @@ -64,6 +65,7 @@ texture_disabled = SubResource("AtlasTexture_73nr4")
stretch_mode = 3

[node name="Down" type="TextureButton" parent="ScrollButtons"]
unique_name_in_owner = true
texture_filter = 1
layout_mode = 2
size_flags_vertical = 3
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ extends GridContainer
const MIN_VOLUME := -30
const MUTE_VOLUME := -70

## Determines whether only the Master bus is displayed.
@export var show_master_only := false
## Specifies whether labels are displayed in front of each volume slider.
@export var show_labels := true

var dflt_volumes := {}


Expand Down Expand Up @@ -42,10 +47,15 @@ func _on_audio_manager_ready() -> void:
# Build sound settings UI
for bus_idx in range(AudioServer.get_bus_count()):
var bus_name := AudioServer.get_bus_name(bus_idx)
# Create the label for the slider
var label := Label.new()
label.text = bus_name
$ChannelsContainer.add_child(label)

if show_master_only and bus_idx > 0:
continue

if show_labels:
# Create the label for the slider
var label := Label.new()
label.text = bus_name
$ChannelsContainer.add_child(label)

# Create the node that will allow players to modify buses volumes
var slider = HSlider.new()
Expand Down
5 changes: 5 additions & 0 deletions addons/popochiu/engine/objects/gui/popochiu_gui.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ extends Control
## You can extend this class to create your own GUI, or use one of the built-in templates for:
## 2-click context-sensitive, 9 verbs and Sierra style.

## The alpha value ([code]modulate.a[/code]) to set to GUI components when they are not selected.
const UNSELECTED_ALPHA = 0.5
## The alpha value ([code]modulate.a[/code]) to set to GUI components when they are selected.
const SELECTED_ALPHA = 1.0

## Stack of opened popups.
var popups_stack := []
## Whether a dialog line is being displayed.
Expand Down
36 changes: 35 additions & 1 deletion addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[gd_resource type="Theme" load_steps=20 format=3 uid="uid://dpequqav4rjaf"]
[gd_resource type="Theme" load_steps=29 format=3 uid="uid://dpequqav4rjaf"]

[ext_resource type="Texture2D" uid="uid://pl1ch71kfj72" path="res://addons/popochiu/engine/objects/gui/resources/images/check_button_checked.png" id="2_ldprq"]
[ext_resource type="Texture2D" uid="uid://dukr75slqli45" path="res://addons/popochiu/engine/objects/gui/resources/images/check_button_unchecked.png" id="3_3rprc"]
[ext_resource type="Texture2D" uid="uid://cqxqfxobqltga" path="res://addons/popochiu/engine/objects/gui/resources/images/grabber.png" id="4_4x0ix"]
[ext_resource type="Texture2D" uid="uid://bbl1rk1aqbhp" path="res://addons/popochiu/engine/objects/gui/resources/images/radio_button.png" id="5_c6xq1"]
[ext_resource type="Texture2D" uid="uid://d1ywqbehmtuv" path="res://addons/popochiu/engine/objects/gui/resources/images/down_arrow.png" id="5_jwcnu"]
[ext_resource type="FontFile" uid="uid://dm6h44ck2nm2b" path="res://addons/popochiu/engine/objects/gui/fonts/minecraftia-regular.ttf" id="6_gx6k1"]

Expand Down Expand Up @@ -58,6 +59,34 @@ thickness = 4
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_d8gde"]
bg_color = Color(0, 0, 0, 0.705882)

[sub_resource type="AtlasTexture" id="AtlasTexture_dg7lp"]
atlas = ExtResource("5_c6xq1")
region = Rect2(0, 0, 12, 12)

[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_m15gs"]
load_path = "res://.godot/imported/radio_button.png-f5f800afce88f7818a95c83aac5f8cc2.ctex"

[sub_resource type="AtlasTexture" id="AtlasTexture_0o3te"]
atlas = SubResource("CompressedTexture2D_m15gs")
region = Rect2(12, 0, 12, 12)

[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_7ex1i"]
load_path = "res://.godot/imported/radio_button.png-f5f800afce88f7818a95c83aac5f8cc2.ctex"

[sub_resource type="AtlasTexture" id="AtlasTexture_r2o0l"]
atlas = SubResource("CompressedTexture2D_7ex1i")
region = Rect2(24, 0, 12, 12)

[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_siucv"]
load_path = "res://.godot/imported/radio_button.png-f5f800afce88f7818a95c83aac5f8cc2.ctex"

[sub_resource type="AtlasTexture" id="AtlasTexture_xd4wp"]
atlas = SubResource("CompressedTexture2D_siucv")
region = Rect2(36, 0, 12, 12)

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_effvh"]
bg_color = Color(0, 0, 0, 0.705882)

[resource]
default_font = ExtResource("6_gx6k1")
default_font_size = 8
Expand Down Expand Up @@ -86,3 +115,8 @@ HSlider/styles/grabber_area_highlight = SubResource("StyleBoxFlat_mp7ca")
HSlider/styles/slider = SubResource("StyleBoxLine_1vxxo")
OptionButton/icons/arrow = ExtResource("5_jwcnu")
PanelContainer/styles/panel = SubResource("StyleBoxFlat_d8gde")
PopupMenu/icons/radio_checked = SubResource("AtlasTexture_dg7lp")
PopupMenu/icons/radio_checked_disabled = SubResource("AtlasTexture_0o3te")
PopupMenu/icons/radio_unchecked = SubResource("AtlasTexture_r2o0l")
PopupMenu/icons/radio_unchecked_disabled = SubResource("AtlasTexture_xd4wp")
PopupMenu/styles/panel = SubResource("StyleBoxFlat_effvh")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f19d252

Please sign in to comment.