From 8c726d4033cd4f71923c223da02b69ff559a1849 Mon Sep 17 00:00:00 2001 From: Nordup Date: Sun, 24 Mar 2024 20:51:50 +0400 Subject: [PATCH] fix WorldCanvas scale animation --- project/scenes/menu_body/world.tscn | 3 +-- project/scripts/ui/world/world_canvas.gd | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/project/scenes/menu_body/world.tscn b/project/scenes/menu_body/world.tscn index bff515f..4d3d8e2 100644 --- a/project/scenes/menu_body/world.tscn +++ b/project/scenes/menu_body/world.tscn @@ -300,12 +300,11 @@ grow_horizontal = 2 grow_vertical = 2 theme_override_constants/separation = 0 -[node name="WorldCanvas" type="Control" parent="HBoxContainer" node_paths=PackedStringArray("render_result")] +[node name="WorldCanvas" type="Control" parent="HBoxContainer"] custom_minimum_size = Vector2(1300, 0) layout_mode = 2 size_flags_horizontal = 0 script = ExtResource("9_ncfxj") -render_result = NodePath("RenderResult") [node name="RenderResult" type="TextureRect" parent="HBoxContainer/WorldCanvas"] layout_mode = 1 diff --git a/project/scripts/ui/world/world_canvas.gd b/project/scripts/ui/world/world_canvas.gd index f2cd9a1..78143b1 100644 --- a/project/scripts/ui/world/world_canvas.gd +++ b/project/scripts/ui/world/world_canvas.gd @@ -1,20 +1,19 @@ extends Control -@export var render_result: RenderResult @export var interpolate: float: set(value): interpolate = value animate(value) -var initial: int = 1300 -var full_screen: int = 1920 +var initial: int +var full_screen: int func _ready() -> void: var viewport_width = ProjectSettings.get_setting("display/window/size/viewport_width", 1152) var scale_width = float(custom_minimum_size.x) / viewport_width - full_screen = render_result.width + full_screen = int(get_parent_control().size.x) initial = int(full_screen * scale_width) custom_minimum_size.x = initial Debug.logclr("WorldCanvas initial: %d full_screen: %d" % [initial, full_screen], Color.DIM_GRAY)