diff options
author | George L. Albany <Megacake1234@gmail.com> | 2023-02-12 16:09:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-12 16:09:17 +0100 |
commit | c0d8a4ac3723021c95da9674c3bc0eea511ee3a0 (patch) | |
tree | 4ca4a0835cb833fbba1983f0e8de5fa66227b86e /game/src/OptionMenu/ScreenModeSelector.gd | |
parent | 537938683b748dbf5fcd78276aa823f168f715f1 (diff) | |
parent | 3798205c740e7e2faf2594866cb497260012508c (diff) |
Merge pull request #7 from Spartan322/feature/usable-ui
Diffstat (limited to 'game/src/OptionMenu/ScreenModeSelector.gd')
-rw-r--r-- | game/src/OptionMenu/ScreenModeSelector.gd | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/game/src/OptionMenu/ScreenModeSelector.gd b/game/src/OptionMenu/ScreenModeSelector.gd new file mode 100644 index 0000000..fae0771 --- /dev/null +++ b/game/src/OptionMenu/ScreenModeSelector.gd @@ -0,0 +1,33 @@ +extends SettingOptionButton + +enum ScreenMode { Unknown = -1, Fullscreen, Borderless, Windowed } + +func get_screen_mode_from_window_mode(window_mode : int) -> ScreenMode: + match window_mode: + Window.MODE_EXCLUSIVE_FULLSCREEN: + return ScreenMode.Fullscreen + Window.MODE_FULLSCREEN: + return ScreenMode.Borderless + Window.MODE_WINDOWED: + return ScreenMode.Windowed + _: + return ScreenMode.Unknown + +func get_window_mode_from_screen_mode(screen_mode : int) -> Window.Mode: + match screen_mode: + ScreenMode.Fullscreen: + return Window.MODE_EXCLUSIVE_FULLSCREEN + ScreenMode.Borderless: + return Window.MODE_FULLSCREEN + ScreenMode.Windowed: + return Window.MODE_WINDOWED + _: + return Window.MODE_EXCLUSIVE_FULLSCREEN + +func _on_item_selected(index : int): + print("Selected index: %d" % 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) |