From b8c2e14e8b0b1f7837b7cefc1aaeb94ce87bf93f Mon Sep 17 00:00:00 2001 From: qwint Date: Sun, 8 Sep 2024 07:17:20 -0500 Subject: [PATCH] CommonClient: allow worlds to change title of run_gui without rewriting it (#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 * Update CommonClient.py treble suggestion 2 Co-authored-by: Aaron Wagener * Update CommonClient.py treble suggestion 3 Co-authored-by: Doug Hoskisson * 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 Co-authored-by: Doug Hoskisson Co-authored-by: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com> --- CommonClient.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/CommonClient.py b/CommonClient.py index fe9df38d..7f91172a 100644 --- a/CommonClient.py +++ b/CommonClient.py @@ -662,17 +662,19 @@ class CommonContext: 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):