From 3bf63f1615868cb4a8625356a49eff4aed36879c Mon Sep 17 00:00:00 2001 From: Spartan322 Date: Sat, 20 May 2023 04:39:37 -0400 Subject: Add revert dialog functionality to ScreenModeSelector Fix recursion bug caused by invalid default value in `reset_setting` Add `option_selected` signal to SettingOptionButton Allows discerning between user option selection and system option selection Add `no_emit` bool defaulted to false for `SettingOptionButton.reset_setting` Add push_error for failing to generate option as well Generalize ResolutionRevertDialog functionality Using the `dialog_reverted` signal enables custom revert functionality instead Disables process function while not visible Displayed time is more correct Add Resolution `resolution_added`, `resolution_changed`, and `window_mode_changed` signals Add `get_resolution_name` to Resolution Change ResolutionSelector `_sync_resolutions` to use `Resolution.resolution_added` signal Reduces unnecessary resolution option list rebuilds Move Resolution display_name functionality to ResolutionSelector Makes it easier to denote default functionality an inline fashion Add SettingRevertButton to automatically handle revert setting behavior Rename VideoTab VBoxContainer/GridContainer to VideoSettingGrid Rename VideoTab VBoxContainer to VideoSettingList Remove `horizontal_alignment` from AutosaveIntervalLabel --- game/src/Autoload/Resolution.gd | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'game/src/Autoload') diff --git a/game/src/Autoload/Resolution.gd b/game/src/Autoload/Resolution.gd index 56aa4a5..c973ba9 100644 --- a/game/src/Autoload/Resolution.gd +++ b/game/src/Autoload/Resolution.gd @@ -1,5 +1,9 @@ extends Node +signal resolution_added(value : Vector2i, name : StringName, display_name : StringName) +signal resolution_changed(value : Vector2i) +signal window_mode_changed(value : Window.Mode) + const error_resolution : Vector2i = Vector2i(-1,-1) @export @@ -39,7 +43,7 @@ func has_resolution(resolution_value : Vector2i) -> bool: func add_resolution(resolution_value : Vector2i, resolution_name : StringName = &"") -> bool: if has_resolution(resolution_value): return true - var res_dict := { value = resolution_value } + var res_dict := { value = resolution_value, name = &"" } var display_name := "%sx%s" % [resolution_value.x, resolution_value.y] if not resolution_name.is_empty(): res_dict.name = resolution_name @@ -48,6 +52,7 @@ func add_resolution(resolution_value : Vector2i, resolution_name : StringName = if resolution_value.x < minimum_resolution.x or resolution_value.y < minimum_resolution.y: push_error("Resolution %s is smaller than minimum (%sx%s)" % [res_dict.display_name, minimum_resolution.x, minimum_resolution.y]) return false + resolution_added.emit(resolution_value, resolution_name, display_name) _resolutions[resolution_value] = res_dict return true @@ -56,6 +61,9 @@ func get_resolution_value_list() -> Array: list.sort_custom(func(a, b): return a > b) return list +func get_resolution_name(resolution_value : Vector2i) -> StringName: + return _resolutions.get(resolution_value, { name = &"unknown resolution" }).name + func get_resolution_display_name(resolution_value : Vector2i) -> StringName: return _resolutions.get(resolution_value, { display_name = &"unknown resolution" }).display_name @@ -80,6 +88,8 @@ func set_resolution(resolution : Vector2i) -> void: if not has_resolution(resolution): push_warning("Setting resolution to non-standard value %sx%s" % [resolution.x, resolution.y]) var window := get_viewport().get_window() + if get_current_resolution() != resolution: + resolution_changed.emit(resolution) match window.mode: Window.MODE_EXCLUSIVE_FULLSCREEN, Window.MODE_FULLSCREEN: window.content_scale_size = resolution -- cgit v1.2.3-56-ga3b1