From ffcb7de8c5203721e77f7cec1f32bf997a246ac4 Mon Sep 17 00:00:00 2001 From: Ategon Date: Fri, 13 Sep 2024 20:20:51 -0400 Subject: [PATCH] Show and hide info menu --- InfoWindow.tscn | 1 + Main.tscn | 3 +-- info_window.gd | 12 ++++++++++-- tile_map.gd | 8 +++++++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/InfoWindow.tscn b/InfoWindow.tscn index 216f8c5..86c770d 100644 --- a/InfoWindow.tscn +++ b/InfoWindow.tscn @@ -18,6 +18,7 @@ offset_right = -13.0 offset_bottom = 133.0 grow_horizontal = 0 grow_vertical = 2 +pivot_offset = Vector2(109, 129) theme = ExtResource("1_emusj") script = ExtResource("1_oy31s") diff --git a/Main.tscn b/Main.tscn index 12a18bf..728be01 100644 --- a/Main.tscn +++ b/Main.tscn @@ -78,8 +78,7 @@ offset = Vector2(50, 150) [node name="CanvasLayer" type="CanvasLayer" parent="."] [node name="InfoWindow" parent="CanvasLayer" instance=ExtResource("7_f4xfy")] -visible = false -pivot_offset = Vector2(170, 129) +pivot_offset = Vector2(114, 128) [node name="BuildingMenu" parent="CanvasLayer" instance=ExtResource("7_hnxcf")] diff --git a/info_window.gd b/info_window.gd index 80fc7b5..a90e68f 100644 --- a/info_window.gd +++ b/info_window.gd @@ -6,6 +6,7 @@ var window_tween func _ready() -> void: Triggerer.listen("show_info", _show_info_window) Triggerer.listen("hide_info", _hide_info_window) + scale = Vector2.ZERO func _show_info_window(data): @@ -17,7 +18,12 @@ func _show_info_window(data): window_tween = create_tween() window_tween.set_ease(Tween.EASE_OUT) window_tween.set_trans(Tween.TRANS_BACK) - window_tween.tween_property(self, "scale", Vector2.ONE, 1) + window_tween.tween_property(self, "scale", Vector2.ONE, 0.5) + + +func _process(delta: float) -> void: + if Input.is_action_just_pressed("rclick"): + _hide_info_window({}) func _hide_info_window(_data): @@ -25,4 +31,6 @@ func _hide_info_window(_data): window_tween.kill() window_tween = create_tween() - window_tween.tween_property(self, "scale", Vector2.ZERO, 1) + window_tween.set_ease(Tween.EASE_IN) + window_tween.set_trans(Tween.TRANS_QUAD) + window_tween.tween_property(self, "scale", Vector2.ZERO, 0.25) diff --git a/tile_map.gd b/tile_map.gd index c6afea3..0d4512e 100644 --- a/tile_map.gd +++ b/tile_map.gd @@ -92,11 +92,17 @@ func _process(delta): func _on_mouse_handler_clicked(): - print("TEST") if Building_Mode: place_building() + else: + show_info_building() +func show_info_building(): + var tile = local_to_map(get_global_mouse_position()) + if Dic[str(tile)]["Placed"]: + Triggerer.trigger("show_info", Dic[str(tile)]) + func select_building(data): Building_Mode = true for x in GridSize: