From 00292d7ae88223c4f9d9a3d2913dc8747c56e25f Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Fri, 27 Dec 2019 22:10:44 +0100 Subject: [PATCH] Add basic hiDPI support This upscales the game by a factor of 2 on hiDPI displays. The end result will be pixelated, but this makes the game playable on such displays. --- src/Scenes/UI/Helpers.gd | 6 ++++++ src/project.godot | 1 + 2 files changed, 7 insertions(+) diff --git a/src/Scenes/UI/Helpers.gd b/src/Scenes/UI/Helpers.gd index 9968950..385af0b 100644 --- a/src/Scenes/UI/Helpers.gd +++ b/src/Scenes/UI/Helpers.gd @@ -1,5 +1,11 @@ extends Node +func _ready(): + # Upscale everything if the display requires it (crude hiDPI support). + # This prevents 2D elements from being too small on hiDPI displays. + if OS.get_screen_dpi() >= 192 and OS.get_screen_size().x >= 2048: + get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_DISABLED, SceneTree.STRETCH_ASPECT_IGNORE, Vector2(), 2) + func _get_scene(): return get_tree().current_scene diff --git a/src/project.godot b/src/project.godot index 48e2fcc..844c995 100644 --- a/src/project.godot +++ b/src/project.godot @@ -33,6 +33,7 @@ window/size/width=640 window/size/height=480 window/size/test_width=1366 window/size/test_height=750 +window/dpi/allow_hidpi=true window/stretch/aspect="expand" [importer_defaults]