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.
This commit is contained in:
parent
80128684ae
commit
01511757a0
28
src/ui/Ui.py
28
src/ui/Ui.py
@ -64,24 +64,20 @@ class Ui():
|
|||||||
|
|
||||||
def updateBasedOnPlayerStats(self, statistics: Statistics):
|
def updateBasedOnPlayerStats(self, statistics: Statistics):
|
||||||
consoleLines = []
|
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.healthBar.updateFill(statistics.hp)
|
||||||
self.hungerBar.updateFill(statistics.hunger)
|
consoleLines.append("Health: " + str(statistics.hp))
|
||||||
consoleLines.append(self.timer.getPrettyTime() + " - Hunger: " + str(statistics.hunger))
|
|
||||||
|
|
||||||
if self.staminaBar.value != statistics.stamina:
|
self.hungerBar.updateFill(statistics.hunger)
|
||||||
self.staminaBar.updateFill(statistics.stamina)
|
consoleLines.append("Hunger: " + str(statistics.hunger))
|
||||||
consoleLines.append(self.timer.getPrettyTime() + " - Stamina: " + str(statistics.stamina))
|
|
||||||
|
|
||||||
if self.thirstBar.value != statistics.thirst:
|
self.staminaBar.updateFill(statistics.stamina)
|
||||||
self.thirstBar.updateFill(statistics.thirst)
|
consoleLines.append("Stamina: " + str(statistics.stamina))
|
||||||
consoleLines.append(self.timer.getPrettyTime() + " - Thirst: " + str(statistics.thirst))
|
|
||||||
|
|
||||||
if len(consoleLines) > 0:
|
self.thirstBar.updateFill(statistics.thirst)
|
||||||
self.console.addLinesToConsoleAndScrollToDisplayThem(consoleLines)
|
consoleLines.append("Thirst: " + str(statistics.thirst))
|
||||||
|
|
||||||
|
self.console.addLinesToConsoleAndScrollToDisplayThem(consoleLines)
|
||||||
|
|
||||||
def updateBasedOnPygameEvent(self, event: pygame.event):
|
def updateBasedOnPygameEvent(self, event: pygame.event):
|
||||||
if event.type == pygame.MOUSEBUTTONDOWN:
|
if event.type == pygame.MOUSEBUTTONDOWN:
|
||||||
@ -91,6 +87,10 @@ class Ui():
|
|||||||
elif event.button == 5:
|
elif event.button == 5:
|
||||||
console.writeConsoleLines(console.topWrittenLineInd - 1)
|
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):
|
def updateTime(self):
|
||||||
self.timerTextView.changeText(self.timer.getPrettyTime())
|
self.timerTextView.changeText(self.timer.getPrettyTime())
|
||||||
if self.timer.isItDay():
|
if self.timer.isItDay():
|
||||||
|
Loading…
Reference in New Issue
Block a user