refactor(city): ♻️ Replace hardcoded colors in BuildingPanel, CityBuildableHelper, and CityScreen with theme-aware dynamic color resolution

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
autocommit 2026-06-04 20:30:32 -07:00
parent 164fed22ae
commit 11ad9e3d5d
3 changed files with 19 additions and 10 deletions

View file

@ -19,8 +19,6 @@ signal building_action_pressed(kind: String, building_id: String)
const ActionButtonScene: PackedScene = preload("res://engine/scenes/hud/action_button.tscn")
const DISABLED_OUTLINE_COLOR: Color = Color(0.95, 0.35, 0.35, 0.85)
const _KIND_TO_SIGNAL_BUILDING: Dictionary = {
"set_rally": "set_rally_pressed",
"clear_rally": "clear_rally_pressed",
@ -64,6 +62,15 @@ var _building_data: Dictionary = {}
@onready var _building_name: Label = %BuildingName
@onready var _status_label: Label = %StatusLabel
@onready var _button_row: HBoxContainer = %ButtonRow
## Disabled-action outline: semantic-negative token at 0.85 alpha. Resolved at
## @onready (token lookups are autoload calls, illegal in a const initializer).
@onready var _disabled_outline_color: Color = _make_disabled_outline_color()
func _make_disabled_outline_color() -> Color:
var c: Color = ThemeAssets.color("semantic.negative")
c.a = 0.85
return c
func _ready() -> void:
@ -143,7 +150,7 @@ func _refresh_action_buttons() -> void:
var tooltip_key: String = "tooltip_building_action_%s" % kind if enabled else reason
btn.tooltip_text = ThemeVocabulary.lookup(tooltip_key)
if not enabled:
btn.add_theme_color_override("font_outline_color", DISABLED_OUTLINE_COLOR)
btn.add_theme_color_override("font_outline_color", _disabled_outline_color)
btn.add_theme_constant_override("outline_size", 2)
var signal_name: String = _KIND_TO_SIGNAL_BUILDING.get(kind, "")
if signal_name != "":

View file

@ -57,7 +57,7 @@ static func populate_buildings_all(
list.add_item("[built] %s" % display)
var idx: int = list.item_count - 1
list.set_item_disabled(idx, true)
list.set_item_custom_fg_color(idx, Color(0.45, 0.72, 0.45, 1))
list.set_item_custom_fg_color(idx, ThemeAssets.color("semantic.positive"))
list.set_item_tooltip(idx, tooltip)
list.set_item_metadata(idx, {"type": "building", "id": bid, "owned": true})
elif can_build_now:
@ -69,7 +69,7 @@ static func populate_buildings_all(
list.add_item("[locked] %s" % display)
var idx: int = list.item_count - 1
list.set_item_disabled(idx, true)
list.set_item_custom_fg_color(idx, Color(0.45, 0.35, 0.35, 1))
list.set_item_custom_fg_color(idx, ThemeAssets.color("semantic.negative"))
list.set_item_tooltip(idx, "Not available: %s" % tooltip)
list.set_item_metadata(idx, {"type": "building", "id": bid, "owned": false})
@ -125,7 +125,9 @@ static func populate_citizen_tiles(
]
)
list.set_item_custom_fg_color(
idx, Color(0.85, 0.82, 0.55, 1) if is_worked else Color(0.55, 0.52, 0.42, 1)
idx,
ThemeAssets.color("text.title") if is_worked
else ThemeAssets.color("text.muted")
)
list.set_item_metadata(idx, {"pos": pos, "worked": is_worked})
@ -189,7 +191,7 @@ static func populate_units(
if not reasons.is_empty():
list.set_item_disabled(idx, true)
list.set_item_custom_fg_color(
idx, Color(0.55, 0.45, 0.45, 1)
idx, ThemeAssets.color("semantic.negative")
)
meta["reason"] = "\n".join(reasons)
list.set_item_tooltip(idx, meta["reason"])
@ -281,7 +283,7 @@ static func populate_items(
if not reasons.is_empty():
list.set_item_disabled(idx, true)
list.set_item_custom_fg_color(
idx, Color(0.55, 0.45, 0.45, 1)
idx, ThemeAssets.color("semantic.negative")
)
meta["reason"] = "\n".join(reasons)
list.set_item_tooltip(idx, meta["reason"])

View file

@ -235,8 +235,8 @@ func _refresh_focus_buttons() -> void:
_focus_auto_btn, _focus_food_btn, _focus_prod_btn,
_focus_science_btn, _focus_culture_btn, _focus_gold_btn,
]
var active_color: Color = Color(1.0, 0.82, 0.2, 1)
var inactive_color: Color = Color(0.55, 0.55, 0.5, 1)
var active_color: Color = ThemeAssets.color("accent.gold")
var inactive_color: Color = ThemeAssets.color("text.muted")
for i: int in range(modes.size()):
btns[i].add_theme_color_override(
"font_color",