Fix scoreboard behaviour

master
En Yi 2018-07-20 14:02:16 +08:00
parent f5a3757368
commit 05acc17262
3 changed files with 7 additions and 5 deletions

View File

@ -6,4 +6,4 @@
8,9,1,2,3,4,5,6,7
3,4,5,6,7,8,9,1,2
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

View File

@ -42,10 +42,10 @@ def write_highscore_file(file, data):
def replace_placing(data, difficulty, name, time):
for info in data[difficulty]:
for i, info in enumerate(data[difficulty]):
if time < info['time']:
info['name'] = name
info['time'] = time
data[difficulty].insert(i, {'name': name, 'time': time})
data[difficulty].pop(-1)
break

View File

@ -190,6 +190,7 @@ class ScoreGrid(QGridLayout):
def set_highscore(self, 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.scoreUpdate.emit(difficulty)
@ -209,6 +210,7 @@ class NameInput(QWidget):
self.layout.addWidget(self.rank_label)
self.name_input = QLineEdit(self)
self.name_input.setMaxLength(13)
self.layout.addWidget(self.name_input)
self.time_display = QLabel('-:-:-')
@ -216,7 +218,7 @@ class NameInput(QWidget):
self.name_input.returnPressed.connect(self.receive_name_input)
self.name_input.setStyleSheet("""
border: 2px solid gray;
border-top: 1px solid white;
""")
def receive_name_input(self):