diff options
author | George L. Albany <Megacake1234@gmail.com> | 2023-05-18 02:43:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-18 02:43:51 +0200 |
commit | 5b679386eb2241216402468a06469b31c263e300 (patch) | |
tree | 6e4a7424c75565ee938457b7a3f36e99e8d40cfd /game/src/OptionMenu/ResolutionSelector.gd | |
parent | 6c7a1a7c8f55d92882d9364c0ad36a61a3f5614f (diff) | |
parent | 56675b0401573f799271eff4716cd6788c98ce7b (diff) |
Merge pull request #113 from Nemrav/keep-video-settings-dialog
Diffstat (limited to 'game/src/OptionMenu/ResolutionSelector.gd')
-rw-r--r-- | game/src/OptionMenu/ResolutionSelector.gd | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/game/src/OptionMenu/ResolutionSelector.gd b/game/src/OptionMenu/ResolutionSelector.gd index 2fdcba2..fee6e31 100644 --- a/game/src/OptionMenu/ResolutionSelector.gd +++ b/game/src/OptionMenu/ResolutionSelector.gd @@ -3,10 +3,16 @@ extends SettingOptionButton # REQUIREMENTS # * UIFUN-21 # * UIFUN-28 +# * UIFUN-301 +# * UIFUN-302 @export var default_value : Vector2i = Resolution.error_resolution +var previous_resolution : Vector2i = Resolution.error_resolution +@export var revert_dialog : ConfirmationDialog +@export var timer : Timer + func _find_resolution_index_by_value(value : Vector2i) -> int: for item_index in item_count: if get_item_metadata(item_index) == value: @@ -63,7 +69,31 @@ func _set_value_from_file(load_value): func _on_item_selected(index : int): if _valid_index(index): + previous_resolution = Resolution.get_current_resolution() Resolution.set_resolution(get_item_metadata(index)) + var new_resolution = get_item_metadata(index) + + #has_focus() indicates the user is calling _on_item_selected, not some other function + if has_focus() and previous_resolution != new_resolution: + print("Start Revert Countdown!") + start_revert_countdown() else: push_error("Invalid ResolutionSelector index: %d" % index) reset_setting() + +func _process(_delta): + revert_dialog.dialog_text = tr("OPTIONS_VIDEO_RESOLUTION_DIALOG_TEXT").format({"time":round(timer.time_left)}) + +func start_revert_countdown() -> void: + timer.start() + revert_dialog.popup_centered(Vector2(1,1)) + +func _on_confirmed() -> void: + timer.stop() + +func _cancel_changes() -> void: + Resolution.set_resolution(previous_resolution) + _sync_resolutions() + print("Resolution reset to (%dx%d)" % [previous_resolution.x,previous_resolution.y]) + timer.stop() + revert_dialog.hide() |