aboutsummaryrefslogtreecommitdiff
path: root/game/src/Autoload/Resolution.gd
diff options
context:
space:
mode:
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())