feat: Overhaul of the Game Over UI, custom texture integrations, and fixing visual artifacts.
This commit is contained in:
@@ -19,7 +19,10 @@ signal rematch_pressed
|
||||
@onready var player_score_label := %PlayerScoreLabel as Label
|
||||
@onready var completion_value := %CompletionValue as Label
|
||||
@onready var score_value := %ScoreValue as Label
|
||||
@onready var rank_value := %RankValue as Label
|
||||
@onready var rank_value := %RankValue as Panel
|
||||
|
||||
# Content Panel
|
||||
@onready var content_panel := %ContentPanel as PanelContainer
|
||||
|
||||
# Rank List tab
|
||||
@onready var rank_list_content := %RankListContent as VBoxContainer
|
||||
@@ -87,7 +90,48 @@ func _ready() -> void:
|
||||
func _switch_tab(show_race_result: bool) -> void:
|
||||
race_result_content.visible = show_race_result
|
||||
rank_list_content.visible = not show_race_result
|
||||
tab_title_label.text = "RACE RESULT" if show_race_result else "RANK LIST"
|
||||
if tab_title_label:
|
||||
tab_title_label.text = "RACE RESULT" if show_race_result else "RANK LIST"
|
||||
|
||||
# Tab button styles
|
||||
var tex_avail_normal = preload("res://assets/graphics/gui/game_over_panel/Button_avail.png")
|
||||
var tex_avail_click = preload("res://assets/graphics/gui/game_over_panel/Button_avail_click.png")
|
||||
var tex_avail_hover = preload("res://assets/graphics/gui/game_over_panel/Button_avail_expand.png")
|
||||
var tex_unavail_normal = preload("res://assets/graphics/gui/game_over_panel/Button_unavail.png")
|
||||
var tex_unavail_click = preload("res://assets/graphics/gui/game_over_panel/Button_unavail_click.png")
|
||||
|
||||
if show_race_result:
|
||||
race_result_tab_btn.add_theme_stylebox_override("normal", _get_stylebox(tex_avail_normal))
|
||||
race_result_tab_btn.add_theme_stylebox_override("pressed", _get_stylebox(tex_avail_click))
|
||||
race_result_tab_btn.add_theme_stylebox_override("hover", _get_stylebox(tex_avail_hover))
|
||||
|
||||
rank_list_tab_btn.add_theme_stylebox_override("normal", _get_stylebox(tex_unavail_normal))
|
||||
rank_list_tab_btn.add_theme_stylebox_override("pressed", _get_stylebox(tex_unavail_click))
|
||||
rank_list_tab_btn.add_theme_stylebox_override("hover", _get_stylebox(tex_unavail_normal))
|
||||
else:
|
||||
race_result_tab_btn.add_theme_stylebox_override("normal", _get_stylebox(tex_unavail_normal))
|
||||
race_result_tab_btn.add_theme_stylebox_override("pressed", _get_stylebox(tex_unavail_click))
|
||||
race_result_tab_btn.add_theme_stylebox_override("hover", _get_stylebox(tex_unavail_normal))
|
||||
|
||||
rank_list_tab_btn.add_theme_stylebox_override("normal", _get_stylebox(tex_avail_normal))
|
||||
rank_list_tab_btn.add_theme_stylebox_override("pressed", _get_stylebox(tex_avail_click))
|
||||
rank_list_tab_btn.add_theme_stylebox_override("hover", _get_stylebox(tex_avail_hover))
|
||||
|
||||
# Content Panel Background
|
||||
var bg_tex = preload("res://assets/graphics/gui/game_over_panel/raceresult.png") if show_race_result else preload("res://assets/graphics/gui/game_over_panel/ranklist.png")
|
||||
var bg_style = StyleBoxTexture.new()
|
||||
bg_style.texture = bg_tex
|
||||
# Must match margins from tscn: left 50, top 180, right 80, bottom 20
|
||||
bg_style.content_margin_left = 50
|
||||
bg_style.content_margin_top = 180
|
||||
bg_style.content_margin_right = 80
|
||||
bg_style.content_margin_bottom = 20
|
||||
content_panel.add_theme_stylebox_override("panel", bg_style)
|
||||
|
||||
func _get_stylebox(tex: Texture2D) -> StyleBoxTexture:
|
||||
var sb = StyleBoxTexture.new()
|
||||
sb.texture = tex
|
||||
return sb
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Data Population (called by main.gd)
|
||||
@@ -119,14 +163,21 @@ func setup(player_scores: Array, local_peer_id: int) -> void:
|
||||
player_score_label.text = str(local_score)
|
||||
completion_value.text = "%dx" % local_goal_count
|
||||
score_value.text = str(local_score)
|
||||
rank_value.text = _get_ordinal(local_rank + 1)
|
||||
|
||||
# Update RankValue Panel texture based on rank
|
||||
var rank_str = _get_ordinal(local_rank + 1)
|
||||
var rank_tex_path = "res://assets/graphics/gui/game_over_panel/%s.png" % rank_str
|
||||
if ResourceLoader.exists(rank_tex_path):
|
||||
var rank_tex = load(rank_tex_path)
|
||||
var rank_style = StyleBoxTexture.new()
|
||||
rank_style.texture = rank_tex
|
||||
rank_value.add_theme_stylebox_override("panel", rank_style)
|
||||
|
||||
# Rank color
|
||||
var rank_color := Color(0.95, 0.75, 0.1) # Gold
|
||||
if local_rank == 1: rank_color = Color(0.75, 0.75, 0.75) # Silver
|
||||
elif local_rank == 2: rank_color = Color(0.8, 0.5, 0.2) # Bronze
|
||||
elif local_rank > 2: rank_color = Color(0.6, 0.6, 0.6)
|
||||
rank_value.add_theme_color_override("font_color", rank_color)
|
||||
player_rank_label.add_theme_color_override("font_color", rank_color)
|
||||
|
||||
# --- Rank List tab ---
|
||||
@@ -199,6 +250,13 @@ func _setup_3d_preview() -> void:
|
||||
if not character_root:
|
||||
return
|
||||
_anim_player = character_root.get_node_or_null("AnimationPlayer")
|
||||
_set_layers_recursive(character_root, 512)
|
||||
|
||||
func _set_layers_recursive(node: Node, layer_mask: int) -> void:
|
||||
if node is VisualInstance3D:
|
||||
node.layers = layer_mask
|
||||
for child in node.get_children():
|
||||
_set_layers_recursive(child, layer_mask)
|
||||
|
||||
func _update_3d_preview(character_name: String) -> void:
|
||||
if not character_root:
|
||||
|
||||
Reference in New Issue
Block a user