From 826425f4f7e4806d733e7b431adb7961a7504b31 Mon Sep 17 00:00:00 2001 From: Rekku Date: Tue, 17 Sep 2024 17:30:36 +0100 Subject: [PATCH] State != null --- tools/configurator/main.tscn | 27 +++++++ tools/configurator/scripts/TabGlobals.gd | 21 ++++-- tools/configurator/scripts/class_functions.gd | 19 +++-- tools/configurator/scripts/main.gd | 73 ++++++++++++------- 4 files changed, 101 insertions(+), 39 deletions(-) diff --git a/tools/configurator/main.tscn b/tools/configurator/main.tscn index 402b8fd1..7e60d7cc 100644 --- a/tools/configurator/main.tscn +++ b/tools/configurator/main.tscn @@ -329,6 +329,7 @@ show_percentage = false [node name="mods_button" type="CheckButton" parent="Background/SplitContainer/MarginContainer/TabContainer/GLOBALS/ScrollContainer/VBoxContainer/globals_gridcontainer"] custom_minimum_size = Vector2(375, 125) layout_mode = 2 +disabled = true text = "MODS" icon = ExtResource("5_vehlp") alignment = 1 @@ -349,6 +350,7 @@ vertical_icon_alignment = 0 expand_icon = true [node name="quick_rewind_button" type="CheckButton" parent="Background/SplitContainer/MarginContainer/TabContainer/GLOBALS/ScrollContainer/VBoxContainer/globals_gridcontainer"] +unique_name_in_owner = true custom_minimum_size = Vector2(375, 125) layout_mode = 2 text = "QUICK REWIND" @@ -358,6 +360,18 @@ icon_alignment = 1 vertical_icon_alignment = 0 expand_icon = true +[node name="quick_rewind_progress" type="ProgressBar" parent="Background/SplitContainer/MarginContainer/TabContainer/GLOBALS/ScrollContainer/VBoxContainer/globals_gridcontainer/quick_rewind_button"] +unique_name_in_owner = true +visible = false +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_styles/fill = SubResource("StyleBoxFlat_1161k") +show_percentage = false + [node name="tate_mode_button" type="CheckButton" parent="Background/SplitContainer/MarginContainer/TabContainer/GLOBALS/ScrollContainer/VBoxContainer/globals_gridcontainer"] custom_minimum_size = Vector2(375, 125) layout_mode = 2 @@ -373,6 +387,7 @@ expand_icon = true [node name="shaders_button" type="CheckButton" parent="Background/SplitContainer/MarginContainer/TabContainer/GLOBALS/ScrollContainer/VBoxContainer/globals_gridcontainer"] custom_minimum_size = Vector2(375, 125) layout_mode = 2 +disabled = true text = "SHADERS" icon = ExtResource("4_q6hd2") alignment = 1 @@ -391,6 +406,18 @@ icon_alignment = 1 vertical_icon_alignment = 0 expand_icon = true +[node name="widescreen_progress" type="ProgressBar" parent="Background/SplitContainer/MarginContainer/TabContainer/GLOBALS/ScrollContainer/VBoxContainer/globals_gridcontainer/widescreen_button"] +unique_name_in_owner = true +visible = false +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_styles/fill = SubResource("StyleBoxFlat_1161k") +show_percentage = false + [node name="reset_retrodeck_button" type="CheckButton" parent="Background/SplitContainer/MarginContainer/TabContainer/GLOBALS/ScrollContainer/VBoxContainer/globals_gridcontainer"] custom_minimum_size = Vector2(375, 125) layout_mode = 2 diff --git a/tools/configurator/scripts/TabGlobals.gd b/tools/configurator/scripts/TabGlobals.gd index b7c8e801..0b7cacfd 100644 --- a/tools/configurator/scripts/TabGlobals.gd +++ b/tools/configurator/scripts/TabGlobals.gd @@ -11,7 +11,9 @@ func _process(delta: float) -> void: update_progress(delta, %button_swap_progress, %button_swap_button, class_functions.abxy_state) update_progress(delta, %ask_to_exit_progress, %ask_to_exit_button, class_functions.ask_to_exit_state) update_progress(delta, %border_progress, %border_button, class_functions.border_state) - + update_progress(delta, %widescreen_progress, %widescreen_button, class_functions.widescreen_state) + update_progress(delta, %quick_rewind_progress, %quick_rewind_button, class_functions.quick_rewind_state) + func update_progress(delta: float, progress: ProgressBar, button: Button, state: String) -> void: if is_state_pressed and state == "mixed": press_time += delta @@ -24,7 +26,6 @@ func update_progress(delta: float, progress: ProgressBar, button: Button, state: func _connect_signals(): %quick_resume_button.pressed.connect(class_functions.run_function.bind(%quick_resume_button, "quick_resume")) - %widescreen_button.pressed.connect(class_functions.run_function.bind(%widescreen_button, "widescreen")) %button_swap_button.button_down.connect(_do_action.bind(%button_swap_button, %button_swap_progress)) %button_swap_button.button_up.connect(_on_button_released.bind(%button_swap_progress)) %button_swap_button.pressed.connect(class_functions.run_function.bind(%button_swap_button, "abxy_button_swap")) @@ -34,7 +35,13 @@ func _connect_signals(): %border_button.button_down.connect(_do_action.bind(%border_button, %border_progress)) %border_button.button_up.connect(_on_button_released.bind(%border_progress)) %border_button.pressed.connect(class_functions.run_function.bind(%border_button, "borders")) - + %widescreen_button.button_down.connect(_do_action.bind(%widescreen_button, %widescreen_progress)) + %widescreen_button.button_up.connect(_on_button_released.bind(%widescreen_progress)) + %widescreen_button.pressed.connect(class_functions.run_function.bind(%widescreen_button, "widescreen")) + %quick_rewind_button.button_down.connect(_do_action.bind(%quick_rewind_button, %quick_rewind_progress)) + %quick_rewind_button.button_up.connect(_on_button_released.bind(%quick_rewind_progress)) + %quick_rewind_button.pressed.connect(class_functions.run_function.bind(%quick_rewind_button, "rewind")) + func _on_button_released(progress: ProgressBar) -> void: is_state_pressed = false progress.visible = false @@ -42,8 +49,8 @@ func _on_button_released(progress: ProgressBar) -> void: progress.value = 0.0 func _do_action(button: Button, progress: ProgressBar) -> void: - match button.name: - "button_swap_button", "ask_to_exit_button", "border_button": + match class_functions.button_list: + class_functions.button_list: is_state_pressed = true progress.visible = true @@ -57,4 +64,8 @@ func _do_complete(button: Button) ->void: class_functions.ask_to_exit_state = "false" "border_button": class_functions.border_state = "false" + "widescreen_button": + class_functions.widescreen_state = "false" + "quick_rewind_button": + class_functions.widescreen_state = "false" button.toggle_mode = true diff --git a/tools/configurator/scripts/class_functions.gd b/tools/configurator/scripts/class_functions.gd index ea14cb5f..e76b4a1b 100644 --- a/tools/configurator/scripts/class_functions.gd +++ b/tools/configurator/scripts/class_functions.gd @@ -24,7 +24,11 @@ var update_check: bool var abxy_state: String var ask_to_exit_state: String var border_state: String +var widescreen_state: String +var quick_rewind_state: String var font_select: int +enum preset_list {abxy_button_swap, ask_to_exit, borders, widescreen, rewind} +var button_list: Array = ["button_swap_button", "ask_to_exit_button", "border_button", "widescreen_button", "quick_rewind_button"] signal update_global_signal func _ready(): @@ -48,6 +52,8 @@ func read_values_states() -> void: abxy_state = multi_state("abxy_button_swap", abxy_state) ask_to_exit_state = multi_state("ask_to_exit", ask_to_exit_state) border_state = multi_state("borders", border_state) + widescreen_state = multi_state("widescreen", widescreen_state) + quick_rewind_state = multi_state("rewind", quick_rewind_state) sound_effects = config["options"]["sound_effects"] volume_effects = int(config["options"]["volume_effects"]) font_select = int(config["options"]["font"]) @@ -247,10 +253,8 @@ func slider_function(value: float, slide: HSlider) -> void: func run_function(button: Button, preset: String) -> void: if button.button_pressed: - print (button.name) update_global(button, preset, true) else: - print ("ELSE:" + button.name) update_global(button, preset, false) func update_global(button: Button, preset: String, state: bool) -> void: @@ -281,17 +285,20 @@ func update_global(button: Button, preset: String, state: bool) -> void: result = data_handler.change_all_cfg_values(config_file_path, config_section, preset, str(state)) change_global(result, "build_preset_config", button, ask_to_exit_state) "border_button": - print (border_state) if border_state != "mixed": border_state = str(state) - print (border_state) result = data_handler.change_all_cfg_values(config_file_path, config_section, preset, str(state)) change_global(result, "build_preset_config", button, border_state) + "widescreen_button": + if widescreen_state != "mixed": + widescreen_state = str(state) + result = data_handler.change_all_cfg_values(config_file_path, config_section, preset, str(state)) + change_global(result, "build_preset_config", button, widescreen_state) func change_global(parameters: Array, preset: String, button: Button, state: String) -> void: - #print (parameters) + print (parameters) match parameters[1]: - "abxy_button_swap", "ask_to_exit", "borders": + preset_list: for system in parameters[0].keys(): var command_parameter: Array = [preset, system, parameters[1]] logger("d", "Change Global: %s System: %s Preset %s " % command_parameter) diff --git a/tools/configurator/scripts/main.gd b/tools/configurator/scripts/main.gd index ec94af14..d5a86ef1 100644 --- a/tools/configurator/scripts/main.gd +++ b/tools/configurator/scripts/main.gd @@ -187,34 +187,51 @@ func _set_up_globals(state: Array) -> void: %retroarch_quick_resume_button.button_pressed = class_functions.quick_resume_status %sound_button.button_pressed = class_functions.sound_effects %volume_effects_slider.visible = class_functions.sound_effects - match class_functions.abxy_state: - "true": - %button_swap_button.button_pressed = true - %button_swap_button.add_theme_stylebox_override("normal", style_box_original) - "false": - %button_swap_button.button_pressed = false - %button_swap_button.add_theme_stylebox_override("normal", style_box_original) - "mixed": - mixed_status(%button_swap_button) - match class_functions.ask_to_exit_state: - "true": - %ask_to_exit_button.button_pressed = true - %ask_to_exit_button.add_theme_stylebox_override("normal", style_box_original) - "false": - %ask_to_exit_button.button_pressed = false - %ask_to_exit_button.add_theme_stylebox_override("normal", style_box_original) - "mixed": - mixed_status(%ask_to_exit_button) - match class_functions.border_state: - "true": - %border_button.button_pressed = true - %border_button.add_theme_stylebox_override("normal", style_box_original) - "false": - %border_button.button_pressed = false - %border_button.add_theme_stylebox_override("normal", style_box_original) - "mixed": - mixed_status(%border_button) - + mixed_mode(%button_swap_button, class_functions.abxy_state) + mixed_mode(%ask_to_exit_button, class_functions.ask_to_exit_state) + mixed_mode(%border_button, class_functions.border_state) + mixed_mode(%widescreen_button, class_functions.widescreen_state) + #match class_functions.ask_to_exit_state: + #"true": + #%ask_to_exit_button.button_pressed = true + #%ask_to_exit_button.add_theme_stylebox_override("normal", style_box_original) + #"false": + #%ask_to_exit_button.button_pressed = false + #%ask_to_exit_button.add_theme_stylebox_override("normal", style_box_original) + #"mixed": + #mixed_status(%ask_to_exit_button) + #match class_functions.border_state: + #"true": + #%border_button.button_pressed = true + #%border_button.add_theme_stylebox_override("normal", style_box_original) + #"false": + #%border_button.button_pressed = false + #%border_button.add_theme_stylebox_override("normal", style_box_original) + #"mixed": + #mixed_status(%border_button) + #match class_functions.widescreen_state: + #"true": + #%widescreen_button.button_pressed = true + #%widescreen_button.add_theme_stylebox_override("normal", style_box_original) + #"false": + #%widescreen_button.button_pressed = false + #%widescreen_button.add_theme_stylebox_override("normal", style_box_original) + #"mixed": + #mixed_status(%widescreen_button) + +func mixed_mode (button: Button, state: String) -> void: + + match [class_functions.button_list]: + [class_functions.button_list]: + if state == "true": + button.button_pressed = true + button.add_theme_stylebox_override("normal", style_box_original) + elif state == "false": + button.button_pressed = false + button.add_theme_stylebox_override("normal", style_box_original) + elif state == "mixed": + mixed_status(button) + func mixed_status (button: Button) -> void: button.button_pressed = false button.toggle_mode = false