Remove layout from menuboard, change highscore cycle behaviour
parent
d010995a42
commit
984a540d72
|
@ -165,19 +165,17 @@ class MenuBoard(BoxBoard):
|
|||
def __init__(self, width, height, parent=None):
|
||||
super().__init__(width, height, parent)
|
||||
|
||||
self.layout = QGraphicsLinearLayout(Qt.Horizontal)
|
||||
self.layout.setMinimumWidth(width)
|
||||
self.layout.setMinimumWidth(height)
|
||||
|
||||
self.diff_display = menu_grap.DifficultyDisplayer(parent=self)
|
||||
self.layout.addItem(self.diff_display)
|
||||
self.diff_display.setX(5)
|
||||
self.diff_display.setY(self.geometry().height()/2-self.diff_display.height/2)
|
||||
self.timer_display = menu_grap.TimerDisplayer(parent=self)
|
||||
self.layout.addItem(self.timer_display)
|
||||
self.layout.setItemSpacing(0, 50)
|
||||
self.layout.setItemSpacing(1, 0)
|
||||
self.layout.setContentsMargins(20,15,20,15)
|
||||
self.timer_display.setParent(self)
|
||||
self.timer_display.setX(self.geometry().width()/2)
|
||||
self.timer_display.setY(self.geometry().height()/2-self.timer_display.height/2)
|
||||
self.score_display = menu_grap.HighScoreDisplayer(parent=self)
|
||||
self.score_display.setX(self.geometry().width()-5)
|
||||
self.score_display.setY(self.geometry().height()/2)
|
||||
|
||||
self.setLayout(self.layout)
|
||||
|
||||
self.show_children(False)
|
||||
self.toggle_anim(True)
|
||||
|
@ -187,8 +185,8 @@ class MenuBoard(BoxBoard):
|
|||
self.diff_display.update()
|
||||
|
||||
def show_children(self, state):
|
||||
for chd in self.children():
|
||||
chd.setVisible(state)
|
||||
self.timer_display.setVisible(state)
|
||||
self.diff_display.setVisible(state)
|
||||
self.timer_display.reset_time()
|
||||
|
||||
def set_difficulty_text(self, string):
|
||||
|
|
|
@ -25,8 +25,8 @@ DIFFICULTIES = ['Very Easy', 'Easy', 'Normal', 'Hard', 'Insane']
|
|||
class TimerDisplayer(QGraphicsWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__()
|
||||
self.setParent(parent)
|
||||
super().__init__(parent=parent)
|
||||
#self.setParent(parent)
|
||||
self.width = 100
|
||||
self.height = 50
|
||||
|
||||
|
@ -72,8 +72,8 @@ class DifficultyDisplayer(QGraphicsWidget):
|
|||
difficultySelected = pyqtSignal(str)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__()
|
||||
self.setParent(parent)
|
||||
super().__init__(parent=parent)
|
||||
#self.setParent(parent)
|
||||
|
||||
self.width = 100
|
||||
self.height = 50
|
||||
|
|
|
@ -12,8 +12,8 @@ if not __name__ == "__main__":
|
|||
|
||||
from general import highscore as hs
|
||||
|
||||
BACKWARD = -1
|
||||
FORWARD = 1
|
||||
BACKWARD = 1
|
||||
FORWARD = -1
|
||||
|
||||
class HighScoreBoard(QWidget):
|
||||
|
||||
|
@ -54,6 +54,7 @@ class HighScoreBoard(QWidget):
|
|||
def set_score(self, name):
|
||||
self.score_grid.set_highscore(self.current_difficulty, name, self.final_time)
|
||||
|
||||
|
||||
class DifficultySwitch(QHBoxLayout):
|
||||
difficultySelected = pyqtSignal(str)
|
||||
|
||||
|
@ -64,7 +65,7 @@ class DifficultySwitch(QHBoxLayout):
|
|||
circular_text.insert(0, hs.DIFFICULTIES[-1])
|
||||
circular_text.append(hs.DIFFICULTIES[0])
|
||||
self.max_length = max(len(diff) for diff in hs.DIFFICULTIES)
|
||||
self.full_text = ''.join(d.center(self.max_length) for d in circular_text)
|
||||
self.full_text = ''.join(d.center(self.max_length) for d in circular_text[::-1])
|
||||
left_btn = QPushButton('<')
|
||||
self.difficulty_display = QLabel('Normal')
|
||||
self.difficulty_display.setAlignment(Qt.AlignCenter)
|
||||
|
@ -75,8 +76,8 @@ class DifficultySwitch(QHBoxLayout):
|
|||
self.addWidget(right_btn)
|
||||
|
||||
self.shift_direction = FORWARD
|
||||
self.show_pos = self.max_length
|
||||
self.next_pos = self.max_length
|
||||
self.show_pos = self.max_length * len(hs.DIFFICULTIES)
|
||||
self.next_pos = self.max_length * len(hs.DIFFICULTIES)
|
||||
self.timer = QTimer(self)
|
||||
self.timer.setInterval(20)
|
||||
self.timer.timeout.connect(self.shift_pos)
|
||||
|
|
Loading…
Reference in New Issue