From: Simon Cross Date: Sat, 10 Sep 2016 16:47:43 +0000 (+0200) Subject: Change how infobar updates work. X-Git-Tag: tabakrolletjie-v1.0.0~75 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=a583e427c608fcae7e73e4fcd175e767fb3994be;p=tabakrolletjie.git Change how infobar updates work. --- diff --git a/tabakrolletjie/infobar.py b/tabakrolletjie/infobar.py index 5a4d3cc..58aa3b6 100644 --- a/tabakrolletjie/infobar.py +++ b/tabakrolletjie/infobar.py @@ -32,9 +32,8 @@ class InfoBar(object): self._text = None self._infobar = None - def render(self, surface): - if self._infobar is None: - self._update_infobar() + def render(self, surface, gamestate): + self._update(gamestate) surface.blit(self._infobar, self.pos, None) def _update_infobar(self): @@ -46,7 +45,7 @@ class InfoBar(object): self._infobar.fill((0, 0, 0, 64)) self._infobar.blit(text_img, (5, 3), None) - def update(self, gamestate): + def _update(self, gamestate): options = { "gamestate": gamestate, "battery": self.battery, "scene": self.scene, "time_of_day": self.time_of_day, @@ -54,4 +53,4 @@ class InfoBar(object): text = self.template.format(**options) if text != self._text: self._text = text - self._infobar = None + self._update_infobar() diff --git a/tabakrolletjie/scenes/day.py b/tabakrolletjie/scenes/day.py index 17506fd..4c3cbfe 100644 --- a/tabakrolletjie/scenes/day.py +++ b/tabakrolletjie/scenes/day.py @@ -44,7 +44,6 @@ class DayScene(BaseScene): # Tools self._light_toolbar = [] self._tools = self.create_tools(gamestate) - self._infobar.update(gamestate) # Background self._soil = loader.load_image( "textures", "soil.png", transform=self.BRIGHTNESS) @@ -150,7 +149,7 @@ class DayScene(BaseScene): self._lights.render_light(surface) self._obstacles.render(surface) self._lights.render_fittings(surface) - self._infobar.render(surface) + self._infobar.render(surface, gamestate) for tool in self._tools: tool.render(surface) for light_tool in self._light_toolbar: @@ -189,7 +188,6 @@ class DayScene(BaseScene): turnip = Turnip(age=0, pos=pos, space=self._space) self._turnips.append(turnip) gamestate.seeds -= 1 - self._infobar.update(gamestate) except TurnipInvalidPosition: # TODO: Add error sound or something pass @@ -219,7 +217,6 @@ class DayScene(BaseScene): if self._lights.nearest(pos, max_distance=25): return gamestate.seeds -= cost - self._infobar.update(gamestate) cfg["position"] = pos cfg["colours"] = colours gamestate.station["lights"].append(cfg)