Skip to content

Commit a5e12c9

Browse files
authored
Merge pull request #86 from ManualForArchipelago/more_client
Game Select dropdown
2 parents 002debd + 4a7521a commit a5e12c9

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

src/ManualClient.py

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22
import time
3+
import sys
34
from typing import Any
45
import typing
56
from worlds import AutoWorldRegister, network_data_package
@@ -80,7 +81,8 @@ class ManualContext(SuperContext):
8081
'category_in_logic': [2/255, 82/255, 2/255, 1],
8182
'deathlink_received': [1, 0, 0, 1],
8283
'deathlink_primed': [1, 1, 1, 1],
83-
'deathlink_sent': [0, 1, 0, 1]
84+
'deathlink_sent': [0, 1, 0, 1],
85+
'game_select_button': [200/255, 200/255, 200/255, 1],
8486
}
8587

8688
def __init__(self, server_address, password, game, player_name) -> None:
@@ -211,21 +213,20 @@ def on_tracker_events(self, events: list[str]):
211213
if events:
212214
self.ui.update_tracker_and_locations_table(update_highlights=True)
213215

214-
def run_gui(self):
215-
"""Import kivy UI system and start running it as self.ui_task."""
216-
from kvui import GameManager
216+
def make_gui(self) -> typing.Type["kvui.GameManager"]:
217+
ui = super().make_gui() # before the kivy imports so kvui gets loaded first
217218

218219
from kivy.metrics import dp
219220
from kivy.uix.button import Button
220-
from kivy.uix.label import Label
221-
from kivy.uix.layout import Layout
222221
from kivy.uix.boxlayout import BoxLayout
222+
from kivy.uix.dropdown import DropDown
223223
from kivy.uix.gridlayout import GridLayout
224+
from kivy.uix.label import Label
225+
from kivy.uix.layout import Layout
224226
from kivy.uix.scrollview import ScrollView
227+
from kivy.uix.spinner import Spinner, SpinnerOption
225228
from kivy.uix.textinput import TextInput
226-
from kivy.uix.tabbedpanel import TabbedPanelItem
227229
from kivy.uix.treeview import TreeView, TreeViewNode, TreeViewLabel
228-
from kivy.clock import Clock
229230
from kivy.core.window import Window
230231

231232
class TrackerAndLocationsLayout(GridLayout):
@@ -244,7 +245,14 @@ class TreeViewButton(Button, TreeViewNode):
244245
class TreeViewScrollView(ScrollView, TreeViewNode):
245246
pass
246247

247-
class ManualManager(GameManager):
248+
class GameSelectOption(SpinnerOption):
249+
background_color = self.colors['game_select_button']
250+
251+
class GameSelectDropDown(DropDown):
252+
# If someone can figure out how to give this a solid background, I'd be very happy.
253+
pass
254+
255+
class ManualManager(ui):
248256
logging_pairs = [
249257
("Client", "Archipelago"),
250258
("Manual", "Manual"),
@@ -269,9 +277,11 @@ def build(self) -> Layout:
269277
self.manual_game_layout = BoxLayout(orientation="horizontal", size_hint_y=None, height=dp(30))
270278

271279
game_bar_label = Label(text="Manual Game ID", size=(dp(150), dp(30)), size_hint_y=None, size_hint_x=None)
280+
manuals = [w for w in AutoWorldRegister.world_types.keys() if "Manual_" in w]
281+
manuals.sort() # Sort by alphabetical order, not load order
272282
self.manual_game_layout.add_widget(game_bar_label)
273-
self.game_bar_text = TextInput(text=self.ctx.suggested_game,
274-
size_hint_y=None, height=dp(30), multiline=False, write_tab=False)
283+
self.game_bar_text = Spinner(text=self.ctx.suggested_game, size_hint_y=None, height=dp(30), sync_height=True,
284+
values=manuals, option_cls=GameSelectOption, dropdown_cls=GameSelectDropDown)
275285
self.manual_game_layout.add_widget(self.game_bar_text)
276286

277287
self.grid.add_widget(self.manual_game_layout, 3)
@@ -284,9 +294,6 @@ def build(self) -> Layout:
284294

285295
self.build_tracker_and_locations_table()
286296

287-
if tracker_loaded:
288-
self.ctx.build_gui(self)
289-
290297
return self.container
291298

292299
def clear_lists(self):
@@ -660,12 +667,7 @@ def victory_button_callback(self, button):
660667
self.ctx.items_received.append("__Victory__")
661668
self.ctx.syncing = True
662669

663-
self.ui = ManualManager(self)
664-
665-
if tracker_loaded:
666-
self.load_kv()
667-
668-
self.ui_task = asyncio.create_task(self.ui.async_run(), name="UI")
670+
return ManualManager
669671

670672
async def game_watcher_manual(ctx: ManualContext):
671673
while not ctx.exit_event.is_set():
@@ -736,7 +738,10 @@ def launch() -> None:
736738
parser.add_argument('apmanual_file', default="", type=str, nargs="?",
737739
help='Path to an APMANUAL file')
738740

739-
args, rest = parser.parse_known_args()
741+
args = sys.argv[1:]
742+
if "Manual Client" in args:
743+
args.remove("Manual Client")
744+
args, rest = parser.parse_known_args(args=args)
740745
colorama.init()
741746
asyncio.run(main(args))
742747
colorama.deinit()

src/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,15 +339,15 @@ def write_spoiler(self, spoiler_handle):
339339

340340
def extend_hint_information(self, hint_data: dict[int, dict[int, str]]) -> None:
341341
before_extend_hint_information(hint_data, self, self.multiworld, self.player)
342-
342+
343343
for location in self.multiworld.get_locations(self.player):
344344
if not location.address:
345345
continue
346346
if "hint_entrance" in self.location_name_to_location[location.name]:
347347
if self.player not in hint_data:
348348
hint_data.update({self.player: {}})
349349
hint_data[self.player][location.address] = self.location_name_to_location[location.name]["hint_entrance"]
350-
350+
351351
after_extend_hint_information(hint_data, self, self.multiworld, self.player)
352352

353353
###
@@ -440,7 +440,7 @@ def __init__(self, display_name: str, script_name: Optional[str] = None, func: O
440440
self.version = version
441441

442442
def add_client_to_launcher() -> None:
443-
version = 2024_09_19 # YYYYMMDD
443+
version = 2024_09_29 # YYYYMMDD
444444
found = False
445445
for c in components:
446446
if c.display_name == "Manual Client":

0 commit comments

Comments
 (0)