From ea1ed1fa17a168223fbb2d4cf554769836c826a3 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Sun, 19 Sep 2021 19:07:13 +0930 Subject: [PATCH] Fix viewport size not updating correctly in many cases for subsampling --- RadialGame.tscn | 1 - scripts/NoteViewport.gd | 23 ++++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/RadialGame.tscn b/RadialGame.tscn index 01f5413..e207413 100644 --- a/RadialGame.tscn +++ b/RadialGame.tscn @@ -206,7 +206,6 @@ __meta__ = { "_edit_use_anchors_": false } -[connection signal="item_rect_changed" from="Square" to="Square/NoteHandler/Viewport" method="_on_Square_item_rect_changed"] [connection signal="combo_changed" from="Square/NoteHandler" to="Square/NoteHandler/lbl_combo" method="_on_NoteHandler_combo_changed"] [connection signal="finished_song" from="Square/NoteHandler" to="Square/NoteHandler/lbl_combo" method="_on_NoteHandler_finished_song"] [connection signal="column_pressed" from="Square/InputHandler" to="Square/NoteHandler" method="_on_InputHandler_column_pressed"] diff --git a/scripts/NoteViewport.gd b/scripts/NoteViewport.gd index 583bf92..51caa29 100644 --- a/scripts/NoteViewport.gd +++ b/scripts/NoteViewport.gd @@ -1,5 +1,8 @@ extends Viewport +export var SquarePath := @'../../' +onready var Square := get_node(SquarePath) +onready var Root := $'/root' onready var base_height = 1080.0 var container_size := Vector2(1080, 1080) @@ -10,17 +13,15 @@ func set_render_scale(scale: Vector2): $Center.position = size * 0.5 $Center.scale = size/base_height -# Called when the node enters the scene tree for the first time. -func _ready(): - Settings.connect('subsampling_changed', self, 'set_render_scale') - set_render_scale(Settings.subsampling) - _on_Square_item_rect_changed() - - -onready var Square := $'../../' -onready var Root := $'/root' -onready var Main := $'/root/main' -func _on_Square_item_rect_changed() -> void: +func update_size() -> void: var winscale = min(Root.size.x, Root.size.y)/base_height container_size = Square.rect_size * winscale set_render_scale(scale) + +# Called when the node enters the scene tree for the first time. +func _ready(): + Settings.connect('subsampling_changed', self, 'set_render_scale') + Square.connect('item_rect_changed', self, 'update_size') + Root.connect('size_changed', self, 'update_size') + scale = Settings.subsampling + update_size()