aboutsummaryrefslogtreecommitdiff
path: root/game/src/OptionMenu/MonitorDisplaySelector.gd
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-02-26 17:12:07 +0100
committer GitHub <noreply@github.com>2023-02-26 17:12:07 +0100
commit93c6b207c11fdaba484410eb53fc11b35fbbb3bd (patch)
tree911753c663adb3955ab15cc8b5ac37498c2fda6e /game/src/OptionMenu/MonitorDisplaySelector.gd
parenta37c5085c3b7ee515789d681c8c18d71071fb771 (diff)
Add Setting Sanatization (#21)
Diffstat (limited to 'game/src/OptionMenu/MonitorDisplaySelector.gd')
-rw-r--r--game/src/OptionMenu/MonitorDisplaySelector.gd18
1 files changed, 11 insertions, 7 deletions
diff --git a/game/src/OptionMenu/MonitorDisplaySelector.gd b/game/src/OptionMenu/MonitorDisplaySelector.gd
index f2f0dc8..b665658 100644
--- a/game/src/OptionMenu/MonitorDisplaySelector.gd
+++ b/game/src/OptionMenu/MonitorDisplaySelector.gd
@@ -2,13 +2,17 @@ extends SettingOptionButton
func _setup_button():
clear()
- for screen_index in range(DisplayServer.get_screen_count()):
+ for screen_index in DisplayServer.get_screen_count():
add_item("Monitor %d" % (screen_index + 1))
default_selected = get_viewport().get_window().current_screen
-func _on_item_selected(index):
- var window := get_viewport().get_window()
- var mode := window.mode
- window.mode = Window.MODE_WINDOWED
- get_viewport().get_window().set_current_screen(index)
- window.mode = mode
+func _on_item_selected(index : int):
+ if _valid_index(index):
+ var window := get_viewport().get_window()
+ var mode := window.mode
+ window.mode = Window.MODE_WINDOWED
+ get_viewport().get_window().set_current_screen(index)
+ window.mode = mode
+ else:
+ push_error("Invalid MonitorDisplaySelector index: %d" % index)
+ reset_setting()