2026-08-14 11:54:31 +02:00
|
|
|
class_name ResourceGlyph
|
|
|
|
|
extends Control
|
|
|
|
|
|
2026-08-14 20:32:58 +02:00
|
|
|
const RESOURCE_DEFINITIONS = preload("res://ResourceDefinitions.gd")
|
|
|
|
|
|
2026-08-14 11:54:31 +02:00
|
|
|
# A small, non-interactive resource mark shared by tables and transfer rows.
|
|
|
|
|
# Resource buttons used to borrow IconButton, which made decorative icons
|
|
|
|
|
# look tappable and encouraged each screen to invent its own version.
|
|
|
|
|
|
|
|
|
|
@export var resource_type: String = GameState.RESOURCE_ORE: set = set_resource_type
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func set_resource_type(value: String) -> void:
|
|
|
|
|
if resource_type == value:
|
|
|
|
|
return
|
|
|
|
|
resource_type = value
|
2026-08-14 20:32:58 +02:00
|
|
|
if is_node_ready():
|
|
|
|
|
_rebuild_visual()
|
2026-08-14 11:54:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
|
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
2026-08-14 20:32:58 +02:00
|
|
|
_rebuild_visual()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _rebuild_visual() -> void:
|
|
|
|
|
for child in get_children():
|
|
|
|
|
child.queue_free()
|
|
|
|
|
var definition: Resource = RESOURCE_DEFINITIONS.get_definition(resource_type)
|
|
|
|
|
if definition == null or definition.glyph_scene == null:
|
|
|
|
|
return
|
|
|
|
|
var visual: Control = definition.glyph_scene.instantiate()
|
|
|
|
|
visual.colour = definition.color
|
|
|
|
|
add_child(visual)
|