Fix scoreboard behaviour
parent
f5a3757368
commit
05acc17262
|
@ -6,4 +6,4 @@
|
||||||
8,9,1,2,3,4,5,6,7
|
8,9,1,2,3,4,5,6,7
|
||||||
3,4,5,6,7,8,9,1,2
|
3,4,5,6,7,8,9,1,2
|
||||||
6,7,8,9,1,2,3,4,5
|
6,7,8,9,1,2,3,4,5
|
||||||
9,1,2,3,4,5,6,7,
|
9,1,2,3,4,5,6,7,0
|
|
@ -42,10 +42,10 @@ def write_highscore_file(file, data):
|
||||||
|
|
||||||
|
|
||||||
def replace_placing(data, difficulty, name, time):
|
def replace_placing(data, difficulty, name, time):
|
||||||
for info in data[difficulty]:
|
for i, info in enumerate(data[difficulty]):
|
||||||
if time < info['time']:
|
if time < info['time']:
|
||||||
info['name'] = name
|
data[difficulty].insert(i, {'name': name, 'time': time})
|
||||||
info['time'] = time
|
data[difficulty].pop(-1)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -190,6 +190,7 @@ class ScoreGrid(QGridLayout):
|
||||||
|
|
||||||
def set_highscore(self, difficulty, name, time):
|
def set_highscore(self, difficulty, name, time):
|
||||||
hs.replace_placing(self.highscore_list, difficulty, name, time)
|
hs.replace_placing(self.highscore_list, difficulty, name, time)
|
||||||
|
hs.write_highscore_file(hs_file, self.highscore_list)
|
||||||
self.replace_scores(difficulty)
|
self.replace_scores(difficulty)
|
||||||
self.scoreUpdate.emit(difficulty)
|
self.scoreUpdate.emit(difficulty)
|
||||||
|
|
||||||
|
@ -209,6 +210,7 @@ class NameInput(QWidget):
|
||||||
self.layout.addWidget(self.rank_label)
|
self.layout.addWidget(self.rank_label)
|
||||||
|
|
||||||
self.name_input = QLineEdit(self)
|
self.name_input = QLineEdit(self)
|
||||||
|
self.name_input.setMaxLength(13)
|
||||||
self.layout.addWidget(self.name_input)
|
self.layout.addWidget(self.name_input)
|
||||||
|
|
||||||
self.time_display = QLabel('-:-:-')
|
self.time_display = QLabel('-:-:-')
|
||||||
|
@ -216,7 +218,7 @@ class NameInput(QWidget):
|
||||||
self.name_input.returnPressed.connect(self.receive_name_input)
|
self.name_input.returnPressed.connect(self.receive_name_input)
|
||||||
|
|
||||||
self.name_input.setStyleSheet("""
|
self.name_input.setStyleSheet("""
|
||||||
border: 2px solid gray;
|
border-top: 1px solid white;
|
||||||
""")
|
""")
|
||||||
|
|
||||||
def receive_name_input(self):
|
def receive_name_input(self):
|
||||||
|
|
Loading…
Reference in New Issue