Skip to content

Commit

Permalink
Change to using a GameManager attribute instead of a default param
Browse files Browse the repository at this point in the history
  • Loading branch information
qwint committed May 13, 2024
1 parent 04d9a87 commit e92b841
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 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["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,17 @@ 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:
from kvui import GameManager

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

self.ui_manager = TextManager

@property
def suggested_address(self) -> str:
if self.server_address:
Expand Down Expand Up @@ -585,17 +597,9 @@ 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, title="Archipelago Text Client"):
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 = title

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

0 comments on commit e92b841

Please sign in to comment.