From 01390b7bb4d3344697a8506b0b5093fff7ecc629 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Wed, 2 Aug 2023 20:18:29 +0930 Subject: [PATCH] Remove infinite resize timer loop --- scripts/loaders/common.gd | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/loaders/common.gd b/scripts/loaders/common.gd index a397cc6..de8fabf 100644 --- a/scripts/loaders/common.gd +++ b/scripts/loaders/common.gd @@ -1,6 +1,6 @@ extends Node -const base_resolution := Vector2(640, 360) +var base_resolution: Vector2 = Vector2(ProjectSettings.get_setting('display/window/size/width'), ProjectSettings.get_setting('display/window/size/height')) # Vector2(640, 360) var shrink_timer := Timer.new() static func load_json(filename: String) -> Dictionary: @@ -45,7 +45,10 @@ func shrink_to_integer(): var scale_vec := size / base_resolution var scale_f := max(min(scale_vec.x, scale_vec.y), 1) var scale := int(scale_f) - OS.window_size = base_resolution*scale + var new_window_size := base_resolution*scale + if OS.get_window_size() != new_window_size: # avoid retriggering this event forever + OS.set_window_size(new_window_size) + print('resized to scale %d %s' % [scale, new_window_size]) func update_window_scale(): if OS.window_size < base_resolution*2: @@ -62,6 +65,7 @@ func update_window_scale(): func _ready(): shrink_timer.connect('timeout', self, 'shrink_to_integer') + shrink_timer.one_shot = true add_child(shrink_timer) get_tree().connect('screen_resized', self, 'update_window_scale') OS.set_min_window_size(base_resolution*2)