From 93c6b207c11fdaba484410eb53fc11b35fbbb3bd Mon Sep 17 00:00:00 2001 From: Hop311 Date: Sun, 26 Feb 2023 16:12:07 +0000 Subject: Add Setting Sanatization (#21) --- game/src/OptionMenu/ScreenModeSelector.gd | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'game/src/OptionMenu/ScreenModeSelector.gd') diff --git a/game/src/OptionMenu/ScreenModeSelector.gd b/game/src/OptionMenu/ScreenModeSelector.gd index 92c5d60..b4fc5ab 100644 --- a/game/src/OptionMenu/ScreenModeSelector.gd +++ b/game/src/OptionMenu/ScreenModeSelector.gd @@ -29,7 +29,11 @@ func _setup_button(): selected = default_selected func _on_item_selected(index : int): - var window := get_viewport().get_window() - var current_resolution := Resolution.get_current_resolution() - window.mode = get_window_mode_from_screen_mode(index) - Resolution.set_resolution(current_resolution) + if _valid_index(index): + var window := get_viewport().get_window() + var current_resolution := Resolution.get_current_resolution() + window.mode = get_window_mode_from_screen_mode(index) + Resolution.set_resolution(current_resolution) + else: + push_error("Invalid ScreenModeSelector index: %d" % index) + reset_setting() -- cgit v1.2.3-56-ga3b1