Fix writing console lines when line ind is too small or too big
This commit is contained in:
parent
bf166232f3
commit
65c9171428
@ -21,6 +21,7 @@ class UiConsole(UiElement):
|
|||||||
|
|
||||||
self.consoleLines = []
|
self.consoleLines = []
|
||||||
self.linesCount = 0
|
self.linesCount = 0
|
||||||
|
self.topWrittenLineInd = 0
|
||||||
|
|
||||||
self.linesImages = []
|
self.linesImages = []
|
||||||
self.lineHeight = font.render("sampleText", False, textColor) .get_height()
|
self.lineHeight = font.render("sampleText", False, textColor) .get_height()
|
||||||
@ -32,6 +33,11 @@ class UiConsole(UiElement):
|
|||||||
|
|
||||||
def writeConsoleLines(self, startingLineInd=0):
|
def writeConsoleLines(self, startingLineInd=0):
|
||||||
self.image.fill(self.bgColor)
|
self.image.fill(self.bgColor)
|
||||||
|
if startingLineInd < 0:
|
||||||
|
startingLineInd = 0
|
||||||
|
elif startingLineInd > self.linesImagesCount:
|
||||||
|
startingLineInd = self.linesImagesCount
|
||||||
|
self.topWrittenLineInd = startingLineInd
|
||||||
writtenLines = 0
|
writtenLines = 0
|
||||||
for i in range(startingLineInd, min(self.maxLines + startingLineInd, self.linesImagesCount)):
|
for i in range(startingLineInd, min(self.maxLines + startingLineInd, self.linesImagesCount)):
|
||||||
self.image.blit(self.linesImages[i], (0, writtenLines * self.lineHeight))
|
self.image.blit(self.linesImages[i], (0, writtenLines * self.lineHeight))
|
||||||
|
Loading…
Reference in New Issue
Block a user