Show display names everywhere accountId was shown in GameScreen
Server: - PlayerState: add DisplayName property (populated from identity DB) - PlayerStateDto: add DisplayName field (falls back to truncated ID) - GameEngine.ToDto: include DisplayName in player DTO - GameReadyHandler: resolve display names from identity DB after state initialization so every subsequent state push carries them Client: - Game.gd: add get_display_name(account_id) helper — reads displayName from player state, falls back to substr(0,8) - game_screen.gd: replace all 5 pid/eid/elim_id.substr(0,8) UI sites with Game.get_display_name() — HUD opp name, turn order strip, game-over outcome list, discard scope selector, elimination dialog - Turn order strip chips: use resolved display name; add mouse_filter STOP + tooltip_text showing SP/ST/Hand/Deck for opponent chips on hover Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -2934,7 +2934,7 @@ func _show_player_panel(scope: String, ownership: String) -> void:
|
||||
if show_enemy:
|
||||
for ep: Dictionary in Game.get_enemy_players():
|
||||
var eid : String = str(ep.get("accountId", ""))
|
||||
var ename : String = eid.substr(0, 8)
|
||||
var ename : String = Game.get_display_name(eid)
|
||||
_add_player_option(vbox, ename, eid, scope)
|
||||
|
||||
panel.add_child(vbox)
|
||||
@@ -3231,8 +3231,7 @@ func _update_hud(state: Dictionary) -> void:
|
||||
_st_lbl.text = "ST: %d" % int(my.get("currentSt", 0))
|
||||
_deck_lbl.text = "Deck: %d" % int(my.get("deckCount", 0))
|
||||
|
||||
_opp_name_lbl.text = Game.opponent_name if not Game.opponent_name.is_empty() \
|
||||
else str(opp.get("accountId", "Opponent")).substr(0, 8)
|
||||
_opp_name_lbl.text = Game.get_display_name(str(opp.get("accountId", "")))
|
||||
_opp_hand_lbl.text = "Hand: %d" % int(opp.get("handCount", 0))
|
||||
_opp_deck_lbl.text = "Deck: %d" % int(opp.get("deckCount", 0))
|
||||
|
||||
@@ -3291,10 +3290,12 @@ func _rebuild_turn_order_strip(state: Dictionary) -> void:
|
||||
var eliminated : bool = bool(p.get("isEliminated", false))
|
||||
var team_idx : int = int(p.get("teamIndex", -1))
|
||||
var hex_str : String = str(team_colors.get(str(team_idx), ""))
|
||||
var display : String = "You" if is_me else Game.get_display_name(pid)
|
||||
|
||||
var chip := PanelContainer.new()
|
||||
chip.custom_minimum_size = Vector2(72, 36)
|
||||
chip.self_modulate = Color(1, 1, 1, 0.3 if eliminated else (0.95 if is_active else 0.6))
|
||||
chip.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
|
||||
# Team-color left border via StyleBoxFlat.
|
||||
var style := StyleBoxFlat.new()
|
||||
@@ -3307,11 +3308,11 @@ func _rebuild_turn_order_strip(state: Dictionary) -> void:
|
||||
chip.add_theme_stylebox_override("panel", style)
|
||||
|
||||
var lbl := Label.new()
|
||||
var display : String = "You" if is_me else pid.substr(0, 8)
|
||||
lbl.text = ("★ " if is_active else "") + display + (" ✗" if eliminated else "")
|
||||
lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
lbl.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
lbl.add_theme_font_size_override("font_size", 10)
|
||||
lbl.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
if is_active:
|
||||
lbl.add_theme_color_override("font_color", Color(1.0, 0.9, 0.3))
|
||||
elif eliminated:
|
||||
@@ -3319,6 +3320,15 @@ func _rebuild_turn_order_strip(state: Dictionary) -> void:
|
||||
elif is_me:
|
||||
lbl.add_theme_color_override("font_color", Color(0.5, 1.0, 0.5))
|
||||
|
||||
# Hover tooltip showing player specs (opponents only).
|
||||
if not is_me:
|
||||
var sp : int = int(p.get("currentSp", 0))
|
||||
var st : int = int(p.get("currentSt", 0))
|
||||
var hand : int = int(p.get("handCount", 0))
|
||||
var deck : int = int(p.get("deckCount", 0))
|
||||
chip.tooltip_text = "%s\nSP: %d ST: %d\nHand: %d Deck: %d" % [
|
||||
display, sp, st, hand, deck]
|
||||
|
||||
chip.add_child(lbl)
|
||||
_turn_order_strip.add_child(chip)
|
||||
|
||||
@@ -3414,7 +3424,7 @@ func _on_game_over(winner_id: String, win_condition: String,
|
||||
var oc : String = str(po.get("outcome", "?"))
|
||||
var rd : int = int(po.get("rankDelta", 0))
|
||||
var sign : String = "+" if rd >= 0 else ""
|
||||
var label: String = "You" if pid == Auth.user_id else pid.substr(0, 8)
|
||||
var label: String = "You" if pid == Auth.user_id else Game.get_display_name(pid)
|
||||
outcome_lines.append("%s: %s (%s%d)" % [label, oc, sign, rd])
|
||||
_go_rank_lbl.text = "[%s]
|
||||
" % win_condition + "
|
||||
@@ -3495,7 +3505,7 @@ func _on_player_eliminated(session_id: String, elim_id: String, _seat_idx: int,
|
||||
"You have been eliminated!
|
||||
You can continue watching the game as a spectator."
|
||||
if is_me
|
||||
else "Player %s has been eliminated from the game!" % elim_id.substr(0, 8))
|
||||
else "Player %s has been eliminated from the game!" % Game.get_display_name(elim_id))
|
||||
var dlg := AcceptDialog.new()
|
||||
dlg.title = "Player Eliminated"
|
||||
dlg.dialog_text = msg
|
||||
|
||||
Reference in New Issue
Block a user