From 01511757a0fe0bdebb4ac0cc33d3d5accf5022b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Czeka=C5=84ski?= Date: Mon, 6 Apr 2020 13:13:28 +0200 Subject: [PATCH] Change console updates Added updateOnPlayerPickup method and modified updateBasedOnPlayerStats so that is used in former method. Now info is written only on player pickup so that there is no spam. --- src/ui/Ui.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/ui/Ui.py b/src/ui/Ui.py index dcdfd31..7d9f6dd 100644 --- a/src/ui/Ui.py +++ b/src/ui/Ui.py @@ -64,24 +64,20 @@ class Ui(): def updateBasedOnPlayerStats(self, statistics: Statistics): consoleLines = [] - if self.healthBar.value != statistics.hp: - self.healthBar.updateFill(statistics.hp) - consoleLines.append(self.timer.getPrettyTime() + " - Health: " + str(statistics.hp)) - if self.hungerBar.value != statistics.hunger: - self.hungerBar.updateFill(statistics.hunger) - consoleLines.append(self.timer.getPrettyTime() + " - Hunger: " + str(statistics.hunger)) + self.healthBar.updateFill(statistics.hp) + consoleLines.append("Health: " + str(statistics.hp)) - if self.staminaBar.value != statistics.stamina: - self.staminaBar.updateFill(statistics.stamina) - consoleLines.append(self.timer.getPrettyTime() + " - Stamina: " + str(statistics.stamina)) + self.hungerBar.updateFill(statistics.hunger) + consoleLines.append("Hunger: " + str(statistics.hunger)) - if self.thirstBar.value != statistics.thirst: - self.thirstBar.updateFill(statistics.thirst) - consoleLines.append(self.timer.getPrettyTime() + " - Thirst: " + str(statistics.thirst)) + self.staminaBar.updateFill(statistics.stamina) + consoleLines.append("Stamina: " + str(statistics.stamina)) - if len(consoleLines) > 0: - self.console.addLinesToConsoleAndScrollToDisplayThem(consoleLines) + self.thirstBar.updateFill(statistics.thirst) + consoleLines.append("Thirst: " + str(statistics.thirst)) + + self.console.addLinesToConsoleAndScrollToDisplayThem(consoleLines) def updateBasedOnPygameEvent(self, event: pygame.event): if event.type == pygame.MOUSEBUTTONDOWN: @@ -91,6 +87,10 @@ class Ui(): elif event.button == 5: console.writeConsoleLines(console.topWrittenLineInd - 1) + def updateOnPlayerPickup(self, playerStats, pickedObject): + self.console.addLinesToConsoleAndScrollToDisplayThem([self.timer.getPrettyTime() + " - Picked object " + str(pickedObject.id) + ":"]) + self.updateBasedOnPlayerStats(playerStats) + def updateTime(self): self.timerTextView.changeText(self.timer.getPrettyTime()) if self.timer.isItDay():