Remove infinite resize timer loop
This commit is contained in:
parent
16f7dd80ec
commit
01390b7bb4
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue