Skip to content

Commit

Permalink
Attempt to fix UI scaling issue #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Toldoven committed Oct 10, 2023
1 parent cb5e361 commit f8503ec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
25 changes: 17 additions & 8 deletions jigsaw-game/global/config/config.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ extends Node
# Used in the editor
export var test_url: String

export var default_ui_scaling: int = 1

onready var base_url = "http://%s" % test_url
onready var base_ws_url = "ws://%s" % test_url

Expand All @@ -13,10 +11,21 @@ func _ready():
var host = JavaScript.eval("window.location.host")
base_url = "https://%s" % host
base_ws_url = "wss://%s" % host

print(OS.get_screen_dpi())

var viewport: Viewport = get_tree().get_root()

# get_viewport().size_override_stretch()

var dpi = OS.get_screen_dpi()

var ui_scale

if dpi < 240:
ui_scale = 1
elif dpi < 480:
ui_scale = 2
else:
ui_scale = 3

get_tree().set_screen_stretch(
SceneTree.STRETCH_MODE_DISABLED,
SceneTree.STRETCH_ASPECT_EXPAND,
Vector2.ZERO,
ui_scale
)
1 change: 0 additions & 1 deletion jigsaw-game/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ window/size/width=1440
window/size/height=920
window/dpi/allow_hidpi=true
window/handheld/orientation="portrait"
window/stretch/mode="2d"
window/stretch/aspect="expand"
window/stretch/shrink=2.0

Expand Down

0 comments on commit f8503ec

Please sign in to comment.