Skip to content

Commit

Permalink
CommonClient: allow worlds to change title of run_gui without rewriti…
Browse files Browse the repository at this point in the history
…ng it (ArchipelagoMW#3297)

* moves the title name in CommonContext.run_gui into a parameter defaulted to the normal default so others using it don't have to rewrite everything

* Change to using a GameManager attribute instead of a default param

* Update CommonClient.py

treble suggestion 1

Co-authored-by: Aaron Wagener <[email protected]>

* Update CommonClient.py

treble suggestion 2

Co-authored-by: Aaron Wagener <[email protected]>

* Update CommonClient.py

treble suggestion 3

Co-authored-by: Doug Hoskisson <[email protected]>

* Use make_gui() instead of a property to push kivy importing back to lazy loading regardless of gui_enabled status

* cleanup

* almost forgot to type it

* change make_gui to be a class so clients can subclass it

* clean up code readability

---------

Co-authored-by: Aaron Wagener <[email protected]>
Co-authored-by: Doug Hoskisson <[email protected]>
Co-authored-by: NewSoupVi <[email protected]>
  • Loading branch information
4 people authored Sep 8, 2024
1 parent 430b71a commit b8c2e14
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions CommonClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,17 +662,19 @@ def handle_connection_loss(self, msg: str) -> None:
logger.exception(msg, exc_info=exc_info, extra={'compact_gui': True})
self._messagebox_connection_loss = self.gui_error(msg, exc_info[1])

def run_gui(self):
"""Import kivy UI system and start running it as self.ui_task."""
def make_gui(self) -> type:
"""To return the Kivy App class needed for run_gui so it can be overridden before being built"""
from kvui import GameManager

class TextManager(GameManager):
logging_pairs = [
("Client", "Archipelago")
]
base_title = "Archipelago Text Client"

self.ui = TextManager(self)
return TextManager

def run_gui(self):
"""Import kivy UI system from make_gui() and start running it as self.ui_task."""
ui_class = self.make_gui()
self.ui = ui_class(self)
self.ui_task = asyncio.create_task(self.ui.async_run(), name="UI")

def run_cli(self):
Expand Down

0 comments on commit b8c2e14

Please sign in to comment.