Return to repo list

heart-of-gold

Tactical RPG written in python, using pygame.
Return to HMagellan.com

commit dcd06905570f57ed09ff5fd74e161aa40b9470c4
parent 48468d775d2ea6733da8f819f0340f64a70f06ef
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Wed, 12 May 2021 16:19:09 -0500

pause ui elements for base mode

Diffstat:
Msrc/base.py | 22++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/base.py b/src/base.py @@ -32,18 +32,33 @@ class BaseManager(manager.Manager): self.base_entities = pygame.sprite.LayeredDirty() self.tile_cursor = None + # Buttons and other UI elements + # For pause screen + self.pause_save_button = None + self.pause_load_button = None + # Event stages self.current_event_stage = 0 def load_base(self, basename): """ - Load the base from a given definition JSON. + Setup base and load from a given definition JSON. """ + # Pre-load setup + sheets = self.bus.fetch("sheet_manager", "sheets") + + # First, establish the UI + self.pause_save_button = BasePauseSaveButton(self, sheets["mainmenu_buttons_1"], (0, 0)) + self.pause_save_button.set_position(200, 200) + self.pause_load_button = BasePauseLoadButton(self, sheets["mainmenu_buttons_1"], (0, 1)) + self.pause_load_button.set_position(200, 500) + + # Then, load the actual base elements with open(os.path.join("data", "board", basename, basename + ".json")) as f: definition = json.load(f) for e in definition: work = copy.deepcopy(definition[e]) if work["type"] == "Normal": - n_sheet = self.bus.fetch("sheet_manager", "sheets")[work["sheet"]] + n_sheet = sheets[work["sheet"]] n_sprite = tuple(work["sprite"]) n_anim = n_sheet.animations[work["animation"]] n_animated = work["animated"] @@ -118,6 +133,9 @@ class BaseManager(manager.Manager): if surface != None: if self.game.control_mode == CTRL_MODES.Base_Normal: self.tile_cursor.update(surface) + elif self.game.control_mode in PAUSE_MODES: + self.pause_save_button.update(surface) + self.pause_load_button.update(surface) self.base_entities.update(surface, self.game.control_mode not in PAUSE_MODES) ###################################################