1
1
from __future__ import annotations
2
2
import time
3
+ import sys
3
4
from typing import Any
4
5
import typing
5
6
from worlds import AutoWorldRegister , network_data_package
@@ -80,7 +81,8 @@ class ManualContext(SuperContext):
80
81
'category_in_logic' : [2 / 255 , 82 / 255 , 2 / 255 , 1 ],
81
82
'deathlink_received' : [1 , 0 , 0 , 1 ],
82
83
'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 ],
84
86
}
85
87
86
88
def __init__ (self , server_address , password , game , player_name ) -> None :
@@ -211,21 +213,20 @@ def on_tracker_events(self, events: list[str]):
211
213
if events :
212
214
self .ui .update_tracker_and_locations_table (update_highlights = True )
213
215
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
217
218
218
219
from kivy .metrics import dp
219
220
from kivy .uix .button import Button
220
- from kivy .uix .label import Label
221
- from kivy .uix .layout import Layout
222
221
from kivy .uix .boxlayout import BoxLayout
222
+ from kivy .uix .dropdown import DropDown
223
223
from kivy .uix .gridlayout import GridLayout
224
+ from kivy .uix .label import Label
225
+ from kivy .uix .layout import Layout
224
226
from kivy .uix .scrollview import ScrollView
227
+ from kivy .uix .spinner import Spinner , SpinnerOption
225
228
from kivy .uix .textinput import TextInput
226
- from kivy .uix .tabbedpanel import TabbedPanelItem
227
229
from kivy .uix .treeview import TreeView , TreeViewNode , TreeViewLabel
228
- from kivy .clock import Clock
229
230
from kivy .core .window import Window
230
231
231
232
class TrackerAndLocationsLayout (GridLayout ):
@@ -244,7 +245,14 @@ class TreeViewButton(Button, TreeViewNode):
244
245
class TreeViewScrollView (ScrollView , TreeViewNode ):
245
246
pass
246
247
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 ):
248
256
logging_pairs = [
249
257
("Client" , "Archipelago" ),
250
258
("Manual" , "Manual" ),
@@ -269,9 +277,11 @@ def build(self) -> Layout:
269
277
self .manual_game_layout = BoxLayout (orientation = "horizontal" , size_hint_y = None , height = dp (30 ))
270
278
271
279
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
272
282
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 )
275
285
self .manual_game_layout .add_widget (self .game_bar_text )
276
286
277
287
self .grid .add_widget (self .manual_game_layout , 3 )
@@ -284,9 +294,6 @@ def build(self) -> Layout:
284
294
285
295
self .build_tracker_and_locations_table ()
286
296
287
- if tracker_loaded :
288
- self .ctx .build_gui (self )
289
-
290
297
return self .container
291
298
292
299
def clear_lists (self ):
@@ -660,12 +667,7 @@ def victory_button_callback(self, button):
660
667
self .ctx .items_received .append ("__Victory__" )
661
668
self .ctx .syncing = True
662
669
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
669
671
670
672
async def game_watcher_manual (ctx : ManualContext ):
671
673
while not ctx .exit_event .is_set ():
@@ -736,7 +738,10 @@ def launch() -> None:
736
738
parser .add_argument ('apmanual_file' , default = "" , type = str , nargs = "?" ,
737
739
help = 'Path to an APMANUAL file' )
738
740
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 )
740
745
colorama .init ()
741
746
asyncio .run (main (args ))
742
747
colorama .deinit ()
0 commit comments