Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleClick GUI improvements #379

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open
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
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 @@ -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
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