2024-09-11 18:23:05 +00:00
|
|
|
extends MarginContainer
|
|
|
|
|
2024-09-16 15:38:41 +00:00
|
|
|
var press_time: float = 0.0
|
2024-09-16 18:07:58 +00:00
|
|
|
var is_state_pressed: bool = false
|
2024-09-16 15:38:41 +00:00
|
|
|
var PRESS_DURATION: float = 3.0
|
2024-09-17 20:05:57 +00:00
|
|
|
var current_button: Button = null
|
|
|
|
var current_progress: ProgressBar = null
|
|
|
|
var current_state: String = ""
|
2024-09-11 18:23:05 +00:00
|
|
|
|
|
|
|
func _ready():
|
|
|
|
_connect_signals()
|
|
|
|
|
2024-09-16 15:38:41 +00:00
|
|
|
func _process(delta: float) -> void:
|
2024-09-17 20:05:57 +00:00
|
|
|
if current_button != null:
|
|
|
|
update_progress(delta, current_progress)
|
2024-09-17 16:30:36 +00:00
|
|
|
|
2024-09-17 20:05:57 +00:00
|
|
|
func update_progress(delta: float, progress: ProgressBar) -> void:
|
2024-09-16 15:38:41 +00:00
|
|
|
if press_time >= PRESS_DURATION:
|
2024-09-17 20:05:57 +00:00
|
|
|
_do_complete(current_button)
|
2024-09-17 20:29:01 +00:00
|
|
|
#print ("Progress Bar: %s Button: %s" % [progress.name, current_button.name])
|
2024-09-17 20:05:57 +00:00
|
|
|
elif is_state_pressed and current_state == "mixed":
|
2024-09-17 18:27:51 +00:00
|
|
|
press_time += delta
|
|
|
|
progress.value = press_time / PRESS_DURATION * 100.0
|
2024-09-16 15:38:41 +00:00
|
|
|
|
2024-09-11 18:23:05 +00:00
|
|
|
func _connect_signals():
|
2024-09-17 11:19:48 +00:00
|
|
|
%quick_resume_button.pressed.connect(class_functions.run_function.bind(%quick_resume_button, "quick_resume"))
|
2024-09-17 20:29:01 +00:00
|
|
|
%button_swap_button.button_down.connect(_do_action.bind(%button_swap_progress, %button_swap_button, class_functions.abxy_state))
|
2024-09-16 18:07:58 +00:00
|
|
|
%button_swap_button.button_up.connect(_on_button_released.bind(%button_swap_progress))
|
2024-09-17 11:19:48 +00:00
|
|
|
%button_swap_button.pressed.connect(class_functions.run_function.bind(%button_swap_button, "abxy_button_swap"))
|
2024-09-17 20:29:01 +00:00
|
|
|
%ask_to_exit_button.button_down.connect(_do_action.bind(%ask_to_exit_progress, %ask_to_exit_button, class_functions.ask_to_exit_state))
|
2024-09-16 18:07:58 +00:00
|
|
|
%ask_to_exit_button.button_up.connect(_on_button_released.bind(%ask_to_exit_progress))
|
2024-09-17 11:19:48 +00:00
|
|
|
%ask_to_exit_button.pressed.connect(class_functions.run_function.bind(%ask_to_exit_button, "ask_to_exit"))
|
2024-09-17 20:29:01 +00:00
|
|
|
%border_button.button_down.connect(_do_action.bind(%border_progress, %border_button, class_functions.border_state))
|
2024-09-17 11:19:48 +00:00
|
|
|
%border_button.button_up.connect(_on_button_released.bind(%border_progress))
|
|
|
|
%border_button.pressed.connect(class_functions.run_function.bind(%border_button, "borders"))
|
2024-09-17 20:29:01 +00:00
|
|
|
%widescreen_button.button_down.connect(_do_action.bind(%widescreen_progress, %widescreen_button, class_functions.widescreen_state))
|
2024-09-17 16:30:36 +00:00
|
|
|
%widescreen_button.button_up.connect(_on_button_released.bind(%widescreen_progress))
|
|
|
|
%widescreen_button.pressed.connect(class_functions.run_function.bind(%widescreen_button, "widescreen"))
|
2024-09-17 20:29:01 +00:00
|
|
|
%quick_rewind_button.button_down.connect(_do_action.bind(%quick_rewind_progress, %quick_rewind_button, class_functions.quick_rewind_state))
|
2024-09-17 16:30:36 +00:00
|
|
|
%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"))
|
2024-09-18 19:07:14 +00:00
|
|
|
%reset_retrodeck_button.pressed.connect(class_functions.run_function.bind(%reset_retrodeck_button, "reset"))
|
|
|
|
|
2024-09-17 16:30:36 +00:00
|
|
|
|
2024-09-16 18:07:58 +00:00
|
|
|
func _on_button_released(progress: ProgressBar) -> void:
|
|
|
|
is_state_pressed = false
|
|
|
|
progress.visible = false
|
2024-09-16 15:38:41 +00:00
|
|
|
press_time = 0.0
|
|
|
|
progress.value = 0.0
|
2024-09-17 20:05:57 +00:00
|
|
|
current_button = null
|
|
|
|
current_progress = null
|
|
|
|
current_state == null
|
2024-09-16 15:38:41 +00:00
|
|
|
|
2024-09-17 20:29:01 +00:00
|
|
|
func _do_action(progress: ProgressBar, button: Button, state: String) -> void:
|
|
|
|
match [class_functions.button_list]:
|
|
|
|
[class_functions.button_list]:
|
|
|
|
current_state = state
|
2024-09-17 20:05:57 +00:00
|
|
|
current_button = button
|
|
|
|
current_progress = progress
|
|
|
|
current_progress.visible = true
|
|
|
|
is_state_pressed = true
|
|
|
|
|
2024-09-16 18:07:58 +00:00
|
|
|
func _do_complete(button: Button) ->void:
|
2024-09-17 11:19:48 +00:00
|
|
|
#TODO use object for state
|
2024-09-17 20:05:57 +00:00
|
|
|
if is_state_pressed and button == current_button:
|
2024-09-16 18:07:58 +00:00
|
|
|
match button.name:
|
|
|
|
"button_swap_button":
|
|
|
|
class_functions.abxy_state = "false"
|
|
|
|
"ask_to_exit_button":
|
|
|
|
class_functions.ask_to_exit_state = "false"
|
2024-09-17 11:19:48 +00:00
|
|
|
"border_button":
|
|
|
|
class_functions.border_state = "false"
|
2024-09-17 16:30:36 +00:00
|
|
|
"widescreen_button":
|
|
|
|
class_functions.widescreen_state = "false"
|
|
|
|
"quick_rewind_button":
|
2024-09-17 18:27:51 +00:00
|
|
|
class_functions.quick_rewind_state = "false"
|
2024-09-16 18:07:58 +00:00
|
|
|
button.toggle_mode = true
|