generated from krampus/template-godot4
38 lines
937 B
GDScript
38 lines
937 B
GDScript
class_name BuildingSelector extends PanelContainer
|
|
|
|
signal select_building(building: Building)
|
|
|
|
var style_box: StyleBoxFlat
|
|
|
|
|
|
func _ready() -> void:
|
|
style_box = get_theme_stylebox("panel")
|
|
|
|
|
|
func _on_mouse_entered() -> void:
|
|
style_box.border_width_bottom = 5
|
|
style_box.border_width_top = 5
|
|
style_box.border_width_left = 5
|
|
style_box.border_width_right = 5
|
|
|
|
|
|
func _on_mouse_exited() -> void:
|
|
style_box.border_width_bottom = 0
|
|
style_box.border_width_top = 0
|
|
style_box.border_width_left = 0
|
|
style_box.border_width_right = 0
|
|
|
|
|
|
func _on_gui_input(event: InputEvent) -> void:
|
|
if event.is_action_pressed("select"):
|
|
select_building.emit(get_child(0))
|
|
|
|
|
|
func _on_child_entered_tree(node: Node) -> void:
|
|
if node is Building:
|
|
await node.ready
|
|
if is_instance_valid(node.size_node):
|
|
custom_minimum_size = node.size_node.size + Vector2(10, 10)
|
|
node.position = position - node.size_node.position
|
|
node.position += Vector2(5, 5)
|