Show unit portraits in battle HUD

This commit is contained in:
2026-06-18 13:07:08 +09:00
parent 68342c1b0b
commit 7ad34697f9
9 changed files with 111 additions and 14 deletions

View File

@@ -469,6 +469,7 @@ func _prepare_unit(source_unit: Dictionary) -> Dictionary:
unit["min_range"] = clampi(int(unit.get("min_range", min(1, int(unit["range"])))), 1, int(unit["range"]))
unit["level"] = int(unit.get("level", 1))
unit["exp"] = int(unit.get("exp", 0))
unit["portrait"] = _portrait_for_unit(unit)
if not unit.has("growth") or typeof(unit["growth"]) != TYPE_DICTIONARY:
unit["growth"] = {}
if not unit.has("growth_bonus") or typeof(unit["growth_bonus"]) != TYPE_DICTIONARY:
@@ -513,6 +514,13 @@ func _apply_roster_overlay(unit: Dictionary, roster_overrides) -> void:
unit["loaded_from_roster"] = true
func _portrait_for_unit(unit: Dictionary) -> String:
var portrait := str(unit.get("portrait", ""))
if not portrait.is_empty():
return portrait
return data_catalog.get_portrait_for_officer(str(unit.get("officer_id", "")))
func _find_roster_overlay(unit: Dictionary, roster_overrides: Dictionary) -> Dictionary:
var unit_id := str(unit.get("id", ""))
if roster_overrides.has(unit_id) and typeof(roster_overrides[unit_id]) == TYPE_DICTIONARY: