score board
This commit is contained in:
@@ -92,22 +92,24 @@ func start_score_saver(score: int)->void:
|
||||
get_tree().call_deferred("change_scene_to_file", "res://scene/score_saver.tscn")
|
||||
|
||||
|
||||
func get_scoreboard_singleplayer() -> String:
|
||||
return " 1 Player" + _get_scoreboard(score.score_singleplayer)
|
||||
func get_scoreboard_singleplayer(n_lignes: int = 0) -> String:
|
||||
return " 1 Player" + _get_scoreboard(score.score_singleplayer, n_lignes)
|
||||
|
||||
func get_scoreboard_multiplayer() -> String:
|
||||
return " 2 Player" + _get_scoreboard(score.score_multiplayer)
|
||||
func get_scoreboard_multiplayer(n_lignes: int = 0) -> String:
|
||||
return " 2 Player" + _get_scoreboard(score.score_multiplayer, n_lignes)
|
||||
|
||||
func _get_scoreboard(dict: Dictionary) -> String:
|
||||
func _get_scoreboard(dict: Dictionary, n_lignes: int) -> String:
|
||||
var text = ""
|
||||
var tableau_paires = []
|
||||
for key in dict:
|
||||
tableau_paires.append({"key": key, "value": dict[key]})
|
||||
tableau_paires.sort_custom(func(a, b): return a["value"] > b["value"])
|
||||
for i in range(clamp(5, 0, tableau_paires.size())):
|
||||
if n_lignes == 0:
|
||||
n_lignes = clamp( tableau_paires.size(), 5, 1000)
|
||||
for i in range(clamp(n_lignes, 0, tableau_paires.size())):
|
||||
text += "\n" + str(i+1) + ". " + tableau_paires[i]["key"] + " : " + display_score(tableau_paires[i]["value"])
|
||||
if tableau_paires.size() < 5:
|
||||
for i in range(5 - tableau_paires.size()):
|
||||
if tableau_paires.size() < n_lignes:
|
||||
for i in range(n_lignes - tableau_paires.size()):
|
||||
text += "\n" + str(tableau_paires.size()+ i+1) + ". " + "---- : ----"
|
||||
return text
|
||||
|
||||
|
||||
Reference in New Issue
Block a user