Skip to content

CommonClient: allow worlds to change title of run_gui without rewriting it #3297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Sep 8, 2024
19 changes: 10 additions & 9 deletions CommonClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class CommonContext:
starting_reconnect_delay: int = 5
current_reconnect_delay: int = starting_reconnect_delay
command_processor: typing.Type[CommandProcessor] = ClientCommandProcessor
ui_manager: typing.Optional["type[kvui.GameManager]"] = None
ui = None
ui_task: typing.Optional["asyncio.Task[None]"] = None
input_task: typing.Optional["asyncio.Task[None]"] = None
Expand Down Expand Up @@ -278,6 +279,14 @@ def __init__(self, server_address: typing.Optional[str], password: typing.Option
# execution
self.keep_alive_task = asyncio.create_task(keep_alive(self), name="Bouncy")

if gui_enabled and self.ui_manager is None:
from kvui import GameManager

class TextManager(GameManager):
base_title = "Archipelago Text Client"

self.ui_manager = TextManager

@property
def suggested_address(self) -> str:
if self.server_address:
Expand Down Expand Up @@ -587,15 +596,7 @@ def handle_connection_loss(self, msg: str) -> None:

def run_gui(self):
"""Import kivy UI system and start running it as self.ui_task."""
from kvui import GameManager

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

self.ui = TextManager(self)
self.ui = self.ui_manager(self)
self.ui_task = asyncio.create_task(self.ui.async_run(), name="UI")

def run_cli(self):
Expand Down