Files
settled-reach/client/ui/hud.gd
T
jpmschweitzerandClaude Opus 4.6 879ef6092f fix(ui): address PR #115 review — 8 items
- Fix stale test path UILayer/HUD → InsertOverlay/HUD
- Fix D-record citation D-051 → D-049 in main.tscn
- Add null guards to hud.gd update methods (pre-_ready safety)
- Minimap: dirty-flag queue_redraw instead of per-frame
- Remove redundant _panel.size.x, debug print
- Fix DebugOverlay/GauntletHUD positioning comments

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 15:45:47 +02:00

69 lines
2.0 KiB
GDScript

extends Control
## HUD — implant-styled status panel (D-169, D-170).
## Merged panel: Time, Health, Perception mode. Time row replaces standalone TimeDisplay (#786).
var _panel: ImplantPanel
var _time_row: ImplantDataRow
var _health_row: ImplantDataRow
var _perception_row: ImplantDataRow
func _ready() -> void:
# Remove the old raw MarginContainer/labels if present
var old := get_node_or_null("MarginContainer")
if old:
old.queue_free()
var theme_res := load("res://ui/implant/default_implant.tres") as ImplantTheme
_panel = ImplantPanel.new()
_panel.name = "StatusPanel"
_panel.theme_resource = theme_res
_panel.custom_minimum_size.x = 200.0
_panel.mouse_filter = Control.MOUSE_FILTER_IGNORE
_panel.position = Vector2(16, 16) # top-left; replaces standalone TimeDisplay
add_child(_panel)
_time_row = ImplantDataRow.new("--:--")
_health_row = ImplantDataRow.new("Health: 100")
_perception_row = ImplantDataRow.new("Mode: Baseline")
_panel.add_component(_time_row)
_panel.add_component(_health_row)
_panel.add_component(_perception_row)
func update_from_hud_data(data: Dictionary) -> void:
if not _perception_row:
return
if data.has("perception_mode"):
var prefix := UIStrings.get_text("hud.perception_mode_prefix")
if prefix.is_empty():
_perception_row.text = data.perception_mode.capitalize()
else:
_perception_row.text = prefix + ": " + data.perception_mode.capitalize()
func update_health(health: int) -> void:
if not _health_row:
return
_health_row.text = UIStrings.get_text("hud.health") + ": " + str(health)
func update_from_state() -> void:
if not _time_row:
return
var gt: Dictionary = GameState.game_time
if gt.is_empty():
return
var tod: int = int(gt.get("time_of_day", 0))
var day: int = int(gt.get("day", 0))
var phase: String = str(gt.get("day_phase", ""))
_time_row.text = "%s · %s · D%d" % [Constants.format_game_time(tod), phase, day + 1]
## Returns the time row text. Used by tests after standalone TimeDisplay was removed.
func get_time_text() -> String:
return _time_row.text if _time_row else "--:--"