WIP: enhancing setting focus handling

This commit is contained in:
betalars 2024-10-07 11:16:18 +02:00
parent f64bb5a71c
commit 9566606bdc
7 changed files with 50 additions and 6 deletions

View File

@ -0,0 +1,9 @@
class_name SettingsPopup extends PanelContainer
func show_settings(id: int = 0):
$AnimationPlayer.play("reveal")
$TabContainer.current_tab = id
State.pass_stage_to($TabContainer)
func vanish():
$AnimationPlayer.play("vanish")

View File

@ -1,12 +1,16 @@
extends VBoxContainer
signal changed
signal leave_stage
var has_stage:bool = false:
set(stage):
has_stage = stage
visible = has_stage
%MusicPreview.playing = has_stage
if is_node_ready():
%MusicPreview.playing = has_stage
if has_stage:
music_mute_switch.grab_focus()
var current_music_decay:float = 0
@ -67,5 +71,6 @@ func update_ui_from_state():
sum_slider.value = State.main_volume
func _on_exit_button_pressed() -> void:
leave_stage.emit()
State.save_settings()
State.leave_stage(self)

View File

@ -1,11 +1,13 @@
extends VBoxContainer
signal changed
signal leave_stage
var has_stage:bool = false:
set(stage):
has_stage = stage
visible = has_stage
if is_node_ready() and has_stage:
%ExpandButton.grab_focus()
@export var is_in_beginning: bool = false
var current_music_decay:float = 0
@ -37,5 +39,6 @@ func update_ui_from_state():
allow_skip_button.button_pressed = State.allow_skipping
func _on_exit_button_pressed() -> void:
leave_stage.emit()
State.save_settings()
State.leave_stage(self)

View File

@ -127,6 +127,7 @@ layout_mode = 2
[node name="Button" type="Button" parent="ScrollContainer/Content Notes/VBoxContainer1"]
layout_mode = 2
focus_neighbor_bottom = NodePath("../../../../SaveButton")
toggle_mode = true
button_group = SubResource("ButtonGroup_v7ly6")
text = "Is this game for or about me?"

View File

@ -1,11 +1,13 @@
extends VBoxContainer
signal changed
signal leave_stage
var has_stage:bool = false:
set(stage):
has_stage = stage
visible = has_stage
if is_node_ready() and has_stage:
y_switch.grab_focus()
var current_music_decay:float = 0
@ -28,5 +30,6 @@ func update_ui_from_state():
stream_overlay_picker.select(State.stream_overlay_position)
func _on_exit_button_pressed() -> void:
leave_stage.emit()
State.save_settings()
State.leave_stage(self)

View File

@ -1,11 +1,11 @@
extends VBoxContainer
signal changed
signal leave_stage
var has_stage:bool = false:
set(stage):
has_stage = stage
visible = has_stage
preset_selected = preset_selected
@export_file(".json") var settings_path = "user://video_settings.json"
@ -48,7 +48,6 @@ var fps_enabled: bool:
fps_enabled = value
@onready var fps_selector: SpinBox = %MaxFps
@onready var fps_placeholder:PanelContainer = %FPSPlaceholder
@export_enum("low", "medium", "high", "ultra") var lighting_quality: int = 3:
set(value):
@ -111,6 +110,7 @@ func _ready() -> void:
preset_selected = preset_selected
%ExitButton.pressed.connect(_on_exit_button_pressed)
%ConfirmExit.pressed.connect(_on_exit_confirmed)
%ConfirmSave.pressed.connect(_on_confirm_button_pressed)
%ConfirmAbort.pressed.connect($Popup.hide)
@ -161,12 +161,14 @@ func save_settings():
has_changed = false
func _on_exit_confirmed() -> void:
leave_stage.emit()
State.leave_stage(self)
func _on_exit_button_pressed() -> void:
if has_changed:
$Popup.show()
else:
leave_stage.emit()
State.leave_stage(self)
func _on_confirm_button_pressed() -> void:

21
src/tab_container.gd Normal file
View File

@ -0,0 +1,21 @@
extends TabContainer
var pass_to_actor
func _ready() -> void:
for child in get_children():
if "leave_stage" in child:
child.leave_stage.connect(get_parent().vanish)
tab_changed.connect(_on_tab_changed)
pass_to_actor = get_child(current_tab)
func _on_tab_changed(tab_id: int):
var child_has_stage:bool = false
for child in get_children():
if "has_stage" in child:
if child.has_stage:
child_has_stage = true
if child_has_stage:
State.pass_stage_to(get_child(tab_id))
pass_to_actor = get_child(tab_id)