From cbb9508c1904d97239d0ef0978a466cb2afd02bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Czeka=C5=84ski?= Date: Sun, 5 Apr 2020 19:06:15 +0200 Subject: [PATCH] Add method addLinesToConsoleAndScrollToDisplayThem in UiConsole --- src/ui/UiConsole.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ui/UiConsole.py b/src/ui/UiConsole.py index 8ce5d89..1c57793 100644 --- a/src/ui/UiConsole.py +++ b/src/ui/UiConsole.py @@ -24,7 +24,7 @@ class UiConsole(UiElement): self.topWrittenLineInd = 0 self.linesImages = [] - self.lineHeight = font.render("sampleText", False, textColor) .get_height() + self.lineHeight = font.render("sampleText", False, textColor).get_height() self.maxLines = int(self.image.get_height() / self.lineHeight) @@ -65,8 +65,15 @@ class UiConsole(UiElement): row.fill(self.bgColor) howMuchRowIsFilled = 0 - row.blit(wordImage, (howMuchRowIsFilled, 0)) + row.blit(wordImage, (howMuchRowIsFilled, 0)) howMuchRowIsFilled += wordImage.get_width() self.linesImages.append(row) self.linesImagesCount += 1 + + def addLinesToConsoleAndScrollToDisplayThem(self, linesToAdd): + self.addLinesToConsole(linesToAdd) + ind = 0 + if self.linesImagesCount > self.maxLines: + ind = self.linesImagesCount - self.maxLines + self.writeConsoleLines(ind)