aboutsummaryrefslogtreecommitdiff
path: root/game/src/Autoload
diff options
context:
space:
mode:
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
commitc0d8a4ac3723021c95da9674c3bc0eea511ee3a0 (patch)
tree4ca4a0835cb833fbba1983f0e8de5fa66227b86e /game/src/Autoload
parent537938683b748dbf5fcd78276aa823f168f715f1 (diff)
parent3798205c740e7e2faf2594866cb497260012508c (diff)
Merge pull request #7 from Spartan322/feature/usable-ui
Diffstat (limited to 'game/src/Autoload')
-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())