This commit is contained in:
Auric Vente 2024-07-25 09:56:44 -06:00
parent 1c0d9c5dfc
commit fc63064441
2 changed files with 23 additions and 1 deletions

View File

@ -561,3 +561,11 @@ class Game:
]
Window.alert("\n\n".join(lines))
@staticmethod
def slowdown() -> None:
Game.change_speed("slow")
@staticmethod
def change_speed(speed: str) -> None:
Window.speed.setCurrentText(speed.capitalize())

View File

@ -46,6 +46,19 @@ class SpecialButton(QPushButton): # type: ignore
super().mousePressEvent(e)
class SpecialComboBox(QComboBox): # type: ignore
middleClicked = Signal()
def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
def mousePressEvent(self, e: QMouseEvent) -> None:
if e.button() == Qt.MiddleButton:
self.middleClicked.emit()
else:
super().mousePressEvent(e)
class FilterLineEdit(QLineEdit): # type: ignore
def keyPressEvent(self, e: QKeyEvent) -> None:
if e.key() == Qt.Key_Escape:
@ -249,7 +262,7 @@ class Window:
btn_menu.clicked.connect(Game.menu)
btn_menu.middleClicked.connect(Game.force_update)
Window.speed = QComboBox()
Window.speed = SpecialComboBox()
tooltip = "The speed of the updates\n"
tooltip += f"Fast: {Utils.get_seconds(Config.loop_delay_fast)}\n"
tooltip += f"Normal: {Utils.get_seconds(Config.loop_delay_normal)}\n"
@ -258,6 +271,7 @@ class Window:
Window.speed.addItems(["Fast", "Normal", "Slow", "Paused"])
Window.speed.setCurrentIndex(1)
Window.speed.currentIndexChanged.connect(Game.update_speed)
Window.speed.middleClicked.connect(Game.slowdown)
Window.filter = FilterLineEdit()
Window.filter.setPlaceholderText("Filter")