Show and hide info menu

This commit is contained in:
Ategon 2024-09-13 20:20:51 -04:00
parent c30cc68db8
commit ffcb7de8c5
4 changed files with 19 additions and 5 deletions

View file

@ -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")

View file

@ -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")]

View file

@ -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)

View file

@ -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: