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 <mmmcheese158@gmail.com> * Update CommonClient.py treble suggestion 2 Co-authored-by: Aaron Wagener <mmmcheese158@gmail.com> * Update CommonClient.py treble suggestion 3 Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com> * 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 <mmmcheese158@gmail.com> Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com> Co-authored-by: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com>
This commit is contained in:
parent
430b71a092
commit
b8c2e14e8b
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue