aboutsummaryrefslogtreecommitdiff
path: root/game/src/Autoload/Resolution.gd
diff options
context:
space:
mode:
author Spartan322 <Megacake1234@gmail.com>2023-02-10 10:18:46 +0100
committer Spartan322 <Megacake1234@gmail.com>2023-02-10 10:31:28 +0100
commit3798205c740e7e2faf2594866cb497260012508c (patch)
tree4ca4a0835cb833fbba1983f0e8de5fa66227b86e /game/src/Autoload/Resolution.gd
parent6525b89a37a31eaf88182b11410bd46b6658e297 (diff)
Implement a usable settings UI, should fulfill:
SS-58, SS-61, SS-6, SS-9, SS-10, SS-11, SS-13 UI-11, UI-12, UI-19, UI-44, UI-47, UI-22
Diffstat (limited to 'game/src/Autoload/Resolution.gd')
-rw-r--r--game/src/Autoload/Resolution.gd43
1 files changed, 43 insertions, 0 deletions
diff --git a/game/src/Autoload/Resolution.gd b/game/src/Autoload/Resolution.gd
new file mode 100644
index 0000000..cde46f5
--- /dev/null
+++ b/game/src/Autoload/Resolution.gd
@@ -0,0 +1,43 @@
+extends Node
+
+const _resolutions := {
+ &"3840x2160": Vector2i(3840,2160),
+ &"2560x1440": Vector2i(2560,1080),
+ &"1920x1080": Vector2i(1920,1080),
+ &"1366x768": Vector2i(1366,768),
+ &"1536x864": Vector2i(1536,864),
+ &"1280x720": Vector2i(1280,720),
+ &"1440x900": Vector2i(1440,900),
+ &"1600x900": Vector2i(1600,900),
+ &"1024x600": Vector2i(1024,600),
+ &"800x600": Vector2i(800,600)
+}
+
+func has_resolution(resolution_name : StringName) -> bool:
+ return resolution_name in _resolutions
+
+func get_resolution(resolution_name : StringName, default : Vector2i = Vector2i(1920, 1080)) -> Vector2i:
+ return _resolutions.get(resolution_name, default)
+
+func get_resolution_name_list() -> Array:
+ return _resolutions.keys()
+
+func get_current_resolution() -> Vector2:
+ var window := get_viewport().get_window()
+ match window.mode:
+ Window.MODE_EXCLUSIVE_FULLSCREEN, Window.MODE_FULLSCREEN:
+ return window.content_scale_size
+ _:
+ return window.size
+
+func set_resolution(resolution : Vector2) -> void:
+ var window := get_viewport().get_window()
+ match window.mode:
+ Window.MODE_EXCLUSIVE_FULLSCREEN, Window.MODE_FULLSCREEN:
+ window.content_scale_size = resolution
+ _:
+ window.size = resolution
+ window.content_scale_size = Vector2i(0,0)
+
+func reset_resolution() -> void:
+ set_resolution(get_current_resolution())