diff --git a/assets/src/ba_data/python/ba/__init__.py b/assets/src/ba_data/python/ba/__init__.py index d09583a6..9a6fb03f 100644 --- a/assets/src/ba_data/python/ba/__init__.py +++ b/assets/src/ba_data/python/ba/__init__.py @@ -81,8 +81,7 @@ from ba._messages import (OutOfBoundsMessage, DieMessage, StandMessage, from ba._music import setmusic, MusicPlayer, MusicType, MusicPlayMode from ba._powerup import PowerupMessage, PowerupAcceptMessage from ba._teambasesession import TeamBaseSession -from ba.ui import (Window, UILocation, UILocationWindow, UIController, - uicleanupcheck) +from ba.ui import Window, UIController, uicleanupcheck app: App diff --git a/assets/src/ba_data/python/ba/_app.py b/assets/src/ba_data/python/ba/_app.py index c27d0221..a8c87f2a 100644 --- a/assets/src/ba_data/python/ba/_app.py +++ b/assets/src/ba_data/python/ba/_app.py @@ -451,7 +451,7 @@ class App: # pylint: disable=cyclic-import from ba import _apputils from ba import _appconfig - from ba import ui as bsui + from ba.ui import UIController, ui_upkeep from ba import _achievement from ba import _map from ba import _meta @@ -466,7 +466,7 @@ class App: self.delegate = appdelegate.AppDelegate() - self.uicontroller = bsui.UIController() + self.uicontroller = UIController() _achievement.init_achievements() spazappearance.register_appearances() _campaign.init_campaigns() @@ -499,34 +499,30 @@ class App: # Kick off our periodic UI upkeep. # FIXME: Can probably kill this if we do immediate UI death checks. self.uiupkeeptimer = _ba.Timer(2.6543, - bsui.upkeep, + ui_upkeep, timetype=TimeType.REAL, repeat=True) - # pylint: disable=using-constant-test - # noinspection PyUnreachableCode - if 0: # force-test small UI + if bool(False): # force-test small UI self.small_ui = True self.med_ui = False with _ba.Context('ui'): _ba.pushcall(lambda: _ba.screenmessage( 'FORCING SMALL UI FOR TESTING', color=(1, 0, 1), log=True)) - # noinspection PyUnreachableCode - if 0: # force-test medium UI + + if bool(False): # force-test medium UI self.small_ui = False self.med_ui = True with _ba.Context('ui'): _ba.pushcall(lambda: _ba.screenmessage( 'FORCING MEDIUM UI FOR TESTING', color=(1, 0, 1 ), log=True)) - # noinspection PyUnreachableCode - if 0: # force-test large UI + if bool(False): # force-test large UI self.small_ui = False self.med_ui = False with _ba.Context('ui'): _ba.pushcall(lambda: _ba.screenmessage( 'FORCING LARGE UI FOR TESTING', color=(1, 0, 1), log=True)) - # pylint: enable=using-constant-test # If there's a leftover log file, attempt to upload # it to the server and/or get rid of it. @@ -669,6 +665,7 @@ class App: to resume. """ from ba import _gameutils + # FIXME: Shouldn't be touching scene stuff here; # should just pass the request on to the host-session. activity = _ba.get_foreground_host_activity() diff --git a/assets/src/ba_data/python/ba/ui/__init__.py b/assets/src/ba_data/python/ba/ui/__init__.py index 8eea9fcb..d1745291 100644 --- a/assets/src/ba_data/python/ba/ui/__init__.py +++ b/assets/src/ba_data/python/ba/ui/__init__.py @@ -206,7 +206,7 @@ def uicleanupcheck(obj: Any, widget: ba.Widget) -> None: widget_death_time=None)) -def upkeep() -> None: +def ui_upkeep() -> None: """Run UI cleanup checks, etc. should be called periodically.""" app = _ba.app remainingchecks = [] diff --git a/assets/src/ba_data/python/bastd/mainmenu.py b/assets/src/ba_data/python/bastd/mainmenu.py index 7811f69a..22679277 100644 --- a/assets/src/ba_data/python/bastd/mainmenu.py +++ b/assets/src/ba_data/python/bastd/mainmenu.py @@ -403,44 +403,56 @@ class MainMenuActivity(ba.Activity): # Bring up the last place we were, or start at the main menu otherwise. with ba.Context('ui'): from bastd.ui import specialoffer - if True: # pylint: disable=using-constant-test + if bool(False): uicontroller = ba.app.uicontroller assert uicontroller is not None uicontroller.show_main_menu() else: + main_window = ba.app.main_window - # main_window = ba.app.main_window - - # # when coming back from a kiosk-mode game, jump to - # # the kiosk start screen.. - # if ba.app.kiosk_mode: - # ba.app.main_menu_window = ( - # bs_ui.KioskWindow().get_root_widget()) - # # ..or in normal cases go back to the main menu - # else: - # if main_window == 'Gather': - # ba.app.main_menu_window = (bs_ui.GatherWindow( - # transition=None).get_root_widget()) - # elif main_window == 'Watch': - # ba.app.main_menu_window = (bs_ui.WatchWindow( - # transition=None).get_root_widget()) - # elif main_window == 'Team Game Select': - # ba.app.main_menu_window = - # (bs_ui.PlaylistBrowserWindow( - # sessiontype=ba.TeamsSession, - # transition=None).get_root_widget()) - # elif main_window == 'Free-for-All Game Select': - # ba.app.main_menu_window = - # (bs_ui.PlaylistBrowserWindow( - # sessiontype=ba.FreeForAllSession, - # transition=None).get_root_widget()) - # elif main_window == 'Coop Select': - # ba.app.main_menu_window = (bs_ui.CoopWindow( - # transition=None).get_root_widget()) - # else: - # ba.app.main_menu_window = ( - # bs_ui.MainMenuWindow( - # transition=None).get_root_widget()) + # When coming back from a kiosk-mode game, jump to + # the kiosk start screen. + if ba.app.kiosk_mode: + # pylint: disable=cyclic-import + from bastd.ui.kiosk import KioskWindow + ba.app.main_menu_window = KioskWindow().get_root_widget() + # ..or in normal cases go back to the main menu + else: + main_window = ba.app.main_window + if main_window == 'Gather': + # pylint: disable=cyclic-import + from bastd.ui.gather import GatherWindow + ba.app.main_menu_window = (GatherWindow( + transition=None).get_root_widget()) + elif main_window == 'Watch': + # pylint: disable=cyclic-import + from bastd.ui.watch import WatchWindow + ba.app.main_menu_window = WatchWindow( + transition=None).get_root_widget() + elif main_window == 'Team Game Select': + # pylint: disable=cyclic-import + from bastd.ui.playlist.browser import ( + PlaylistBrowserWindow) + ba.app.main_menu_window = PlaylistBrowserWindow( + sessiontype=ba.TeamsSession, + transition=None).get_root_widget() + elif main_window == 'Free-for-All Game Select': + # pylint: disable=cyclic-import + from bastd.ui.playlist.browser import ( + PlaylistBrowserWindow) + ba.app.main_menu_window = PlaylistBrowserWindow( + sessiontype=ba.FreeForAllSession, + transition=None).get_root_widget() + elif main_window == 'Coop Select': + # pylint: disable=cyclic-import + from bastd.ui.coop.browser import CoopBrowserWindow + ba.app.main_menu_window = CoopBrowserWindow( + transition=None).get_root_widget() + else: + # pylint: disable=cyclic-import + from bastd.ui.mainmenu import MainMenuWindow + ba.app.main_menu_window = MainMenuWindow( + transition=None).get_root_widget() # attempt to show any pending offers immediately. # If that doesn't work, try again in a few seconds @@ -449,14 +461,14 @@ class MainMenuActivity(ba.Activity): # until the next opportunity. if not specialoffer.show_offer(): - def try_again(): + def try_again() -> None: if not specialoffer.show_offer(): - # try one last time.. + # Try one last time.. ba.timer(2.0, specialoffer.show_offer, - timetype='real') + timetype=ba.TimeType.REAL) - ba.timer(2.0, try_again, timetype='real') + ba.timer(2.0, try_again, timetype=ba.TimeType.REAL) ba.app.main_menu_did_initial_transition = True def _update(self) -> None: diff --git a/assets/src/ba_data/python/bastd/maps.py b/assets/src/ba_data/python/bastd/maps.py index fb156ee5..4f74678a 100644 --- a/assets/src/ba_data/python/bastd/maps.py +++ b/assets/src/ba_data/python/bastd/maps.py @@ -26,7 +26,7 @@ from __future__ import annotations from typing import TYPE_CHECKING import ba -from bastd import stdmap +# from bastd import stdmap if TYPE_CHECKING: from typing import Any, List, Dict @@ -181,7 +181,7 @@ class FootballStadium(ba.Map): return xpos < -0.5 or xpos > 0.5 or zpos < -0.5 or zpos > 0.5 -class Bridgit(stdmap.StdMap): +class Bridgit(ba.Map): """Map with a narrow bridge in the middle.""" # noinspection PyUnresolvedReferences from bastd.mapdata import bridgit as defs @@ -192,7 +192,7 @@ class Bridgit(stdmap.StdMap): @classmethod def get_play_types(cls) -> List[str]: """Return valid play types for this map.""" - print('getting playtypes', cls._getdata()['play_types']) + # print('getting playtypes', cls._getdata()['play_types']) return ['melee', 'team_flag', 'keep_away'] @classmethod diff --git a/assets/src/ba_data/python/bastd/ui/coop/browser.py b/assets/src/ba_data/python/bastd/ui/coop/browser.py index faaeba05..491bc6c4 100644 --- a/assets/src/ba_data/python/bastd/ui/coop/browser.py +++ b/assets/src/ba_data/python/bastd/ui/coop/browser.py @@ -49,7 +49,7 @@ class CoopBrowserWindow(ba.Window): self._height - 85 - (4 if ba.app.small_ui else 0))) def __init__(self, - transition: str = 'in_right', + transition: Optional[str] = 'in_right', origin_widget: ba.Widget = None): # pylint: disable=cyclic-import # pylint: disable=too-many-statements diff --git a/assets/src/ba_data/python/bastd/ui/gather.py b/assets/src/ba_data/python/bastd/ui/gather.py index 41897f3e..03dd96fd 100644 --- a/assets/src/ba_data/python/bastd/ui/gather.py +++ b/assets/src/ba_data/python/bastd/ui/gather.py @@ -41,7 +41,7 @@ class GatherWindow(ba.Window): _ba.set_party_icon_always_visible(False) def __init__(self, - transition: str = 'in_right', + transition: Optional[str] = 'in_right', origin_widget: ba.Widget = None): # pylint: disable=too-many-statements # pylint: disable=too-many-locals diff --git a/assets/src/ba_data/python/bastd/ui/league/rankbutton.py b/assets/src/ba_data/python/bastd/ui/league/rankbutton.py index 0d21cc9e..7d964274 100644 --- a/assets/src/ba_data/python/bastd/ui/league/rankbutton.py +++ b/assets/src/ba_data/python/bastd/ui/league/rankbutton.py @@ -112,7 +112,7 @@ class LeagueRankButton: self._smooth_update_timer: Optional[ba.Timer] = None - # take note of our account state; we'll refresh later if this changes + # Take note of our account state; we'll refresh later if this changes. self._account_state_num = _ba.get_account_state_num() self._last_power_ranking_query_time: Optional[float] = None self._doing_power_ranking_query = False @@ -124,7 +124,7 @@ class LeagueRankButton: repeat=True) self._update() - # if we've got cached power-ranking data already, apply it.. + # If we've got cached power-ranking data already, apply it. data = get_cached_league_rank_data() if data is not None: self._update_for_league_rank_data(data) @@ -309,8 +309,7 @@ class LeagueRankButton: timetype=ba.TimeType.REAL, timeformat=ba.TimeFormat.MILLISECONDS) - assert self._smooth_percent is not None - if (self._percent is not None + if (self._percent is not None and self._smooth_percent is not None and int(self._smooth_percent) != self._percent): self._improvement_text = str( (int(self._percent) - int(self._smooth_percent))) @@ -354,7 +353,8 @@ class LeagueRankButton: account_state_num = _ba.get_account_state_num() if account_state_num != self._account_state_num: self._account_state_num = account_state_num - # and power ranking too... + + # And power ranking too... if not self._doing_power_ranking_query: self._last_power_ranking_query_time = None diff --git a/assets/src/ba_data/python/bastd/ui/mainmenu.py b/assets/src/ba_data/python/bastd/ui/mainmenu.py index b0e12e50..242e5b1b 100644 --- a/assets/src/ba_data/python/bastd/ui/mainmenu.py +++ b/assets/src/ba_data/python/bastd/ui/mainmenu.py @@ -25,17 +25,18 @@ from __future__ import annotations from typing import TYPE_CHECKING -import _ba import ba +import _ba if TYPE_CHECKING: from typing import Any, Callable, List, Dict, Tuple, Optional, Union class MainMenuWindow(ba.Window): - """The main menu window, both in-game and in the main menu.""" + """The main menu window, both in-game and in the main menu session.""" - def __init__(self, transition: str = 'in_right'): + def __init__(self, transition: Optional[str] = 'in_right'): + # pylint: disable=cyclic-import from bastd import mainmenu self._in_game = not isinstance(_ba.get_foreground_host_session(), mainmenu.MainMenuSession) @@ -614,6 +615,7 @@ class MainMenuWindow(ba.Window): self._tdelay += self._t_delay_inc else: self._gc_button = None + # How-to-play button. h, v, scale = positions[self._p_index] self._p_index += 1 @@ -627,6 +629,7 @@ class MainMenuWindow(ba.Window): transition_delay=self._tdelay, on_activate_call=self._howtoplay) self._how_to_play_button = btn + # Scattered eggs on easter. if _ba.get_account_misc_read_val('easter', False) and not self._in_game: diff --git a/assets/src/ba_data/python/bastd/ui/playlist/browser.py b/assets/src/ba_data/python/bastd/ui/playlist/browser.py index 0b383f8d..97ac5f8b 100644 --- a/assets/src/ba_data/python/bastd/ui/playlist/browser.py +++ b/assets/src/ba_data/python/bastd/ui/playlist/browser.py @@ -38,7 +38,7 @@ class PlaylistBrowserWindow(ba.Window): def __init__(self, sessiontype: Type[ba.Session], - transition: str = 'in_right', + transition: Optional[str] = 'in_right', origin_widget: ba.Widget = None): # pylint: disable=too-many-statements # pylint: disable=cyclic-import diff --git a/assets/src/ba_data/python/bastd/ui/watch.py b/assets/src/ba_data/python/bastd/ui/watch.py index 993ec87a..5632f477 100644 --- a/assets/src/ba_data/python/bastd/ui/watch.py +++ b/assets/src/ba_data/python/bastd/ui/watch.py @@ -36,7 +36,7 @@ class WatchWindow(ba.Window): """Window for watching replays.""" def __init__(self, - transition: str = 'in_right', + transition: Optional[str] = 'in_right', origin_widget: ba.Widget = None): # pylint: disable=too-many-locals # pylint: disable=too-many-statements diff --git a/docs/ba_module.md b/docs/ba_module.md index a3a1ac68..2bfec979 100644 --- a/docs/ba_module.md +++ b/docs/ba_module.md @@ -139,10 +139,6 @@

User Interface Classes

@@ -4714,65 +4710,6 @@ self.t = ba.Timer(0.3, say_it, repeat=True)

Show the main menu, clearing other UIs from location stacks.

- - -
-

ba.UILocation

-

<top level class> -

-

Defines a specific 'place' in the UI the user can navigate to.

- -

Category: User Interface Classes -

- -

Methods:

-
<constructor>, push_location(), restore_state(), save_state()
-
-

<constructor>

-

ba.UILocation()

- -
-

push_location()

-

push_location(self, location: str) -> None

- -

Push a new location to the stack and transition to it.

- -
-

restore_state()

-

restore_state(self) -> None

- -

Restore this instance's state from a dict.

- -
-

save_state()

-

save_state(self) -> None

- -

Serialize this instance's state to a dict.

- -
-
-
-

ba.UILocationWindow

-

inherits from: ba.UILocation

-

A UILocation consisting of a single root window widget.

- -

Category: User Interface Classes -

- -

Methods Inherited:

-
push_location(), restore_state(), save_state()
-

Methods Defined or Overridden:

-
<constructor>, get_root_widget()
-
-

<constructor>

-

ba.UILocationWindow()

- -
-

get_root_widget()

-

get_root_widget(self) -> ba.Widget

- -

Return the root widget for this window.

-