Files
settled-reach/client/ui/hud.gd
T
jpmschweitzerandClaude Opus 4.6 283518d332 refactor(ui): convert HUD status + interaction prompt to implant (#786, #788)
HUD: merge TimeDisplay into ImplantPanel (time/health/perception in one
panel), remove dead tscn nodes, move HUD to InsertOverlay for D-051 bloom.
Interaction prompt: convert from PanelContainer+StyleBoxFlat to Control
with ImplantPanel+ImplantDataRow, fix panel height for 42px minimum.
Tests updated for new scene structure and public API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 12:51:58 +02:00

66 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.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)
print("HUD: Initialized")
func update_from_hud_data(data: Dictionary) -> void:
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:
_health_row.text = UIStrings.get_text("hud.health") + ": " + str(health)
func update_from_state() -> void:
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 "--:--"