Show a graph of the game on the Winner popup
The Winner popup now shows every player's score after each song as a step line, with the winning score marked, and three facts under it: the longest streak, the longest standstill and the song most players scored on. The data comes from the points each song already records, through the new ScoreHistory. The popup grows to 1600x920 with the graph across the full width, so a 60-song game with five players stays readable. Reset points now starts a new game: it clears the points on the songs and the graph starts after the song that was playing. Songs already on the server at startup count as an earlier game. The screenshot tour has a long five-player game, and only the Winner popup differs from before.
This commit is contained in:
1 parent
b40b160fde
commit
e1e05f3904
21 files changed
+2461
-182
No files matched your search
+36
-6
@@ -1,11 +1,20 @@
|
||||
class_name WinnerPopup
|
||||
extends BasePopup
|
||||
## Shows who won, with their character, and where the other players placed.
|
||||
## Shows who won, with their character, where the other players placed, and how the game
|
||||
## went: a graph of everyone's score after each song and a few facts about it.
|
||||
|
||||
## Size of the coloured square in front of each name in the legend.
|
||||
const LEGEND_SQUARE_SIZE: Vector2 = Vector2(14, 14)
|
||||
|
||||
@onready var winner_panel: Panel = %WinnerPanel
|
||||
@onready var winner_picture: TextureRect = %WinnerPicture
|
||||
@onready var winner_label: Label = %WinnerLabel
|
||||
@onready var players_list: VBoxContainer = %PlayersList
|
||||
@onready var legend: HBoxContainer = %Legend
|
||||
@onready var score_graph: ScoreGraph = %ScoreGraph
|
||||
@onready var streak_label: Label = %StreakLabel
|
||||
@onready var standstill_label: Label = %StandstillLabel
|
||||
@onready var shared_label: Label = %SharedLabel
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -14,7 +23,6 @@ func _ready() -> void:
|
||||
|
||||
func show_winner(winner: PlayerObject) -> void:
|
||||
visible = true
|
||||
# Set winner info
|
||||
winner_label.text = winner.player_name + " won with " + str(winner.player_score) + \
|
||||
" points!!"
|
||||
winner_picture.texture = winner.character
|
||||
@@ -23,9 +31,6 @@ func show_winner(winner: PlayerObject) -> void:
|
||||
winner_picture.texture_filter = CanvasItem.TEXTURE_FILTER_NEAREST
|
||||
else:
|
||||
winner_picture.texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR
|
||||
winner_picture.custom_minimum_size = Vector2(480, 200)
|
||||
winner_picture.expand_mode = TextureRect.EXPAND_FIT_WIDTH_PROPORTIONAL
|
||||
winner_picture.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
|
||||
# Clear previous player list entries
|
||||
for child: Node in players_list.get_children():
|
||||
@@ -45,6 +50,31 @@ func show_winner(winner: PlayerObject) -> void:
|
||||
var label: Label = Label.new()
|
||||
label.text = str(placing) + ". " + player.player_name + " - " + \
|
||||
str(player.player_score) + " points"
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
players_list.add_child(label)
|
||||
placing += 1
|
||||
|
||||
show_history(ScoreHistory.from_playlist(Settings.player_array))
|
||||
|
||||
|
||||
## Shows how the game went: the score graph, its legend and the summary boxes.
|
||||
func show_history(history: ScoreHistory) -> void:
|
||||
score_graph.show_history(history, Settings.winning_score)
|
||||
streak_label.text = history.longest_streak_text()
|
||||
standstill_label.text = history.longest_standstill_text()
|
||||
shared_label.text = history.most_shared_text()
|
||||
|
||||
for child: Node in legend.get_children():
|
||||
legend.remove_child(child)
|
||||
child.queue_free()
|
||||
for index: int in history.players.size():
|
||||
var player: PlayerObject = history.players[index]
|
||||
var entry: HBoxContainer = HBoxContainer.new()
|
||||
var square: ColorRect = ColorRect.new()
|
||||
square.custom_minimum_size = LEGEND_SQUARE_SIZE
|
||||
square.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
square.color = score_graph.player_color(index)
|
||||
entry.add_child(square)
|
||||
var name_label: Label = Label.new()
|
||||
name_label.text = "%s %d" % [player.player_name, history.final_score(player.id)]
|
||||
entry.add_child(name_label)
|
||||
legend.add_child(entry)
|
||||
Reference in new issue
Block a user