diff --git a/src/ui/Ui.py b/src/ui/Ui.py index f232cce..19a2531 100644 --- a/src/ui/Ui.py +++ b/src/ui/Ui.py @@ -91,9 +91,9 @@ class Ui(): if event.type == pygame.MOUSEBUTTONDOWN: console = self.console if event.button == 4: - console.writeConsoleLines(console.topWrittenLineInd + 1) + console.scrollDown() elif event.button == 5: - console.writeConsoleLines(console.topWrittenLineInd - 1) + console.scrollUp() def updateOnPlayerPickup(self, playerStats, pickedObject): self.console.addLinesToConsoleAndScrollToDisplayThem([self.timer.getPrettyTime() + " - Picked object " + str(pickedObject.id) + ":"]) diff --git a/src/ui/UiConsole.py b/src/ui/UiConsole.py index f56d575..107e4d0 100644 --- a/src/ui/UiConsole.py +++ b/src/ui/UiConsole.py @@ -69,7 +69,7 @@ class UiConsole(UiElement): self.maxLines = int(self.image.get_height() / self.lineHeight) self.addLinesToConsole(["Hello from console!"]) - self.writeConsoleLines() + self.__writeConsoleLines__() def update(self, *args): """ @@ -89,7 +89,21 @@ class UiConsole(UiElement): """ self.addLinesToConsoleAndScrollToDisplayThem([inp]) - def writeConsoleLines(self, startingLineInd: int = 0): + def scrollUp(self): + """ + Scrolls one line up. + + """ + self.__writeConsoleLines__(self.topWrittenLineInd - 1) + + def scrollDown(self): + """ + Scrolls one line down. + + """ + self.__writeConsoleLines__(self.topWrittenLineInd + 1) + + def __writeConsoleLines__(self, startingLineInd: int = 0): """ Displays lines stored in console's list of lines, starting from line with given index. @@ -152,4 +166,4 @@ class UiConsole(UiElement): ind = 0 if self.linesImagesCount > self.maxLines: ind = self.linesImagesCount - self.maxLines - self.writeConsoleLines(ind) + self.__writeConsoleLines__(ind)