fix highscores
This commit is contained in:
parent
ab5d2441a2
commit
34f4533b9f
4 changed files with 16 additions and 12 deletions
|
@ -319,10 +319,10 @@ anchor_left = 0.5
|
|||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -64.5
|
||||
offset_top = -57.0
|
||||
offset_right = 64.5
|
||||
offset_bottom = 57.0
|
||||
offset_left = -483.861
|
||||
offset_top = -287.132
|
||||
offset_right = -354.861
|
||||
offset_bottom = -173.132
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = SubResource("Theme_lsv84")
|
||||
|
|
|
@ -216,7 +216,7 @@ func _on_countdown_timeout() -> void:
|
|||
|
||||
|
||||
func _on_car_finished(playerid,finalTime) -> void:
|
||||
times_container.addFinishedPlayer(playerid,finalTime)
|
||||
times_container.addFinishedPlayer(playerid,finalTime,Gamestate.getPlayers().size())
|
||||
|
||||
if times_container.getPlayersFinished() == Gamestate.getPlayers().size(): #all players have finish times
|
||||
finishGame()# Game finished
|
||||
|
@ -244,14 +244,14 @@ func finishGame():
|
|||
i+=1
|
||||
|
||||
|
||||
if Gamestate.getPlayers().size()==1: #was played in singleplayer
|
||||
if Gamestate.getPlayers().size()==1: #was played in singleplayer
|
||||
var timediff=HighscoreHandler.updateHighscore(Gamestate.getSelectedMapName(),"normal",str(Gamestate.getRounds()),getfinalTimeByPlayer(Gamestate.getPlayers()[0]))
|
||||
print("Timediff="+str(timediff))
|
||||
timediff=round(timediff*1000)/1000
|
||||
highscore_label.visible=true
|
||||
|
||||
if timediff==0: #same time or first entry
|
||||
highscore_label.text=str(timediff)
|
||||
highscore_label.text=="+"+str(timediff)
|
||||
highscore_label.modulate=Color(200,200,0)
|
||||
elif timediff<0: #new highscore
|
||||
highscore_label.text=str(timediff)
|
||||
|
|
|
@ -34,9 +34,9 @@ func loadHighscore(mapname:String,preset:String,rounds:String):
|
|||
if highscores[mapname].has(preset):
|
||||
if highscores[mapname][preset].has(rounds):
|
||||
if highscores[mapname][preset][rounds].size()>0:
|
||||
return highscores[mapname][preset][rounds][highscores[mapname].size()-1]["time"] #return last entry
|
||||
else:
|
||||
return null
|
||||
return highscores[mapname][preset][rounds][highscores[mapname][preset][rounds].size()-1]["time"] #return last entry
|
||||
|
||||
return null
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -10,13 +10,17 @@ func _ready() -> void:
|
|||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func addFinishedPlayer(playerid,finalTime):
|
||||
func addFinishedPlayer(playerid,finalTime,playercount):
|
||||
print("Finished "+str(playerid)+" final time="+str(finalTime))
|
||||
var place=get_child_count()+1
|
||||
|
||||
var newlabel= Label.new()
|
||||
add_child(newlabel)
|
||||
#newlabel.set("theme_override_font_sizes/font_size",40)
|
||||
newlabel.text=str(place)+": "+str(round(finalTime*1000)/1000.0)+"s"
|
||||
newlabel.text=""
|
||||
if playercount>1: #singleplayer
|
||||
newlabel.text+=str(place)+": "
|
||||
newlabel.text+=str(round(finalTime*1000)/1000.0)+"s"
|
||||
newlabel.set("theme_override_colors/font_color",Gamestate.getPlayers()[playerid].color)
|
||||
|
||||
func getPlayersFinished():
|
||||
|
|
Loading…
Reference in a new issue