Start to add building info
This commit is contained in:
parent
586b3f55dc
commit
4cada48a71
6 changed files with 58 additions and 5 deletions
|
@ -60,9 +60,9 @@ layout_mode = 1
|
|||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -93.5
|
||||
offset_left = -119.5
|
||||
offset_top = 53.0
|
||||
offset_right = 103.5
|
||||
offset_right = 120.5
|
||||
offset_bottom = 83.0
|
||||
grow_horizontal = 2
|
||||
theme_override_font_sizes/normal_font_size = 16
|
||||
|
|
|
@ -60,6 +60,10 @@ func _on_click():
|
|||
if current_node.modulate.a < 1:
|
||||
hidden = true
|
||||
break
|
||||
if "visible" in current_node:
|
||||
if not current_node.visible:
|
||||
hidden = true
|
||||
break
|
||||
current_node = current_node.get_parent()
|
||||
|
||||
if hidden:
|
||||
|
@ -83,6 +87,10 @@ func _on_rclick():
|
|||
if current_node.modulate.a < 1:
|
||||
hidden = true
|
||||
break
|
||||
if "visible" in current_node:
|
||||
if not current_node.visible:
|
||||
hidden = true
|
||||
break
|
||||
current_node = current_node.get_parent()
|
||||
|
||||
if hidden:
|
||||
|
@ -105,9 +113,29 @@ func _process(delta):
|
|||
|
||||
func _on_mouse_control_area_entered(area):
|
||||
if area.has_method("_on_hovered"):
|
||||
var current_node = area
|
||||
var hidden = false
|
||||
while current_node:
|
||||
if "visible" in current_node:
|
||||
if not current_node.visible:
|
||||
hidden = true
|
||||
break
|
||||
current_node = current_node.get_parent()
|
||||
|
||||
if not hidden:
|
||||
area._on_hovered()
|
||||
|
||||
|
||||
func _on_mouse_control_area_exited(area):
|
||||
if area.has_method("_on_unhovered"):
|
||||
var current_node = area
|
||||
var hidden = false
|
||||
while current_node:
|
||||
if "visible" in current_node:
|
||||
if not current_node.visible:
|
||||
hidden = true
|
||||
break
|
||||
current_node = current_node.get_parent()
|
||||
|
||||
if not hidden:
|
||||
area._on_unhovered()
|
||||
|
|
|
@ -2,6 +2,11 @@ extends Control
|
|||
|
||||
var window_tween
|
||||
|
||||
@onready var icon: TextureRect = $Icon
|
||||
@onready var title: RichTextLabel = $Title
|
||||
@onready var subtitle: RichTextLabel = $Subtitle
|
||||
@onready var description: RichTextLabel = $Description
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Triggerer.listen("show_info", _show_info_window)
|
||||
|
@ -12,10 +17,19 @@ func _ready() -> void:
|
|||
func _show_info_window(data):
|
||||
visible = true
|
||||
|
||||
var building_data = Data.data.buildings[data.Key]
|
||||
|
||||
|
||||
if window_tween:
|
||||
window_tween.kill()
|
||||
|
||||
window_tween = create_tween()
|
||||
window_tween.set_ease(Tween.EASE_IN)
|
||||
window_tween.set_trans(Tween.TRANS_QUAD)
|
||||
window_tween.tween_property(self, "scale", Vector2.ZERO, 0.25)
|
||||
window_tween.tween_callback(func():
|
||||
title.text = "[center]%s" % [building_data.name]
|
||||
)
|
||||
window_tween.set_ease(Tween.EASE_OUT)
|
||||
window_tween.set_trans(Tween.TRANS_BACK)
|
||||
window_tween.tween_property(self, "scale", Vector2.ONE, 0.5)
|
||||
|
|
|
@ -4,6 +4,7 @@ var GridSize = 33
|
|||
var Dic = {}
|
||||
var Building_Mode := false
|
||||
var Drag_Mode := false
|
||||
var building_key
|
||||
|
||||
func generate_percentage(percentages: Array):
|
||||
var array_length = 0
|
||||
|
@ -105,6 +106,7 @@ func show_info_building():
|
|||
|
||||
func select_building(data):
|
||||
Building_Mode = true
|
||||
building_key = data.key
|
||||
for x in GridSize:
|
||||
for y in GridSize:
|
||||
if !Dic[str(Vector2(x,y))].get("Placed"):
|
||||
|
@ -114,17 +116,20 @@ func select_building(data):
|
|||
func drag_building(data):
|
||||
Building_Mode = true
|
||||
Drag_Mode = true
|
||||
building_key = data.key
|
||||
|
||||
|
||||
func release_mouse():
|
||||
if Drag_Mode and Building_Mode:
|
||||
place_building()
|
||||
Building_Mode = false
|
||||
|
||||
|
||||
func place_building():
|
||||
var tile = local_to_map(get_global_mouse_position())
|
||||
if Dic.has(str(tile)):
|
||||
Building_Mode = false
|
||||
Dic[str(tile)]["Key"] = building_key
|
||||
Dic[str(tile)]["Placed"] = true
|
||||
|
||||
Drag_Mode = false
|
||||
|
|
|
@ -3,7 +3,6 @@ extends ColorRect
|
|||
var key
|
||||
var clicked = false
|
||||
|
||||
|
||||
@onready var texture_rect: TextureRect = $TextureRect
|
||||
|
||||
|
||||
|
@ -17,12 +16,17 @@ func _on_mouse_handler_hovered() -> void:
|
|||
|
||||
|
||||
func _on_mouse_handler_unhovered() -> void:
|
||||
print(key)
|
||||
print("DRAG 1")
|
||||
if clicked:
|
||||
print("DRAG")
|
||||
Triggerer.trigger("drag_building", { "key": key })
|
||||
clicked = false
|
||||
|
||||
|
||||
func _on_mouse_handler_released() -> void:
|
||||
print("SELECT 1")
|
||||
if clicked:
|
||||
print("SELECT")
|
||||
Triggerer.trigger("select_building", { "key": key })
|
||||
clicked = false
|
||||
|
|
|
@ -51,6 +51,8 @@ func swap_to_tab(index):
|
|||
if i > 0:
|
||||
spacers[i - 1].visible = false
|
||||
|
||||
print(icons.map(func(icon): return icon.key))
|
||||
|
||||
|
||||
func _on_building_tab_clicked() -> void:
|
||||
swap_to_tab(0)
|
||||
|
|
Loading…
Reference in a new issue