More work reverting UI code to 1.4 state for now

This commit is contained in:
Eric Froemling 2020-04-05 16:44:54 -07:00
parent 21f2d50408
commit 2caa45284f
12 changed files with 77 additions and 129 deletions

View File

@ -81,8 +81,7 @@ from ba._messages import (OutOfBoundsMessage, DieMessage, StandMessage,
from ba._music import setmusic, MusicPlayer, MusicType, MusicPlayMode from ba._music import setmusic, MusicPlayer, MusicType, MusicPlayMode
from ba._powerup import PowerupMessage, PowerupAcceptMessage from ba._powerup import PowerupMessage, PowerupAcceptMessage
from ba._teambasesession import TeamBaseSession from ba._teambasesession import TeamBaseSession
from ba.ui import (Window, UILocation, UILocationWindow, UIController, from ba.ui import Window, UIController, uicleanupcheck
uicleanupcheck)
app: App app: App

View File

@ -451,7 +451,7 @@ class App:
# pylint: disable=cyclic-import # pylint: disable=cyclic-import
from ba import _apputils from ba import _apputils
from ba import _appconfig from ba import _appconfig
from ba import ui as bsui from ba.ui import UIController, ui_upkeep
from ba import _achievement from ba import _achievement
from ba import _map from ba import _map
from ba import _meta from ba import _meta
@ -466,7 +466,7 @@ class App:
self.delegate = appdelegate.AppDelegate() self.delegate = appdelegate.AppDelegate()
self.uicontroller = bsui.UIController() self.uicontroller = UIController()
_achievement.init_achievements() _achievement.init_achievements()
spazappearance.register_appearances() spazappearance.register_appearances()
_campaign.init_campaigns() _campaign.init_campaigns()
@ -499,34 +499,30 @@ class App:
# Kick off our periodic UI upkeep. # Kick off our periodic UI upkeep.
# FIXME: Can probably kill this if we do immediate UI death checks. # FIXME: Can probably kill this if we do immediate UI death checks.
self.uiupkeeptimer = _ba.Timer(2.6543, self.uiupkeeptimer = _ba.Timer(2.6543,
bsui.upkeep, ui_upkeep,
timetype=TimeType.REAL, timetype=TimeType.REAL,
repeat=True) repeat=True)
# pylint: disable=using-constant-test if bool(False): # force-test small UI
# noinspection PyUnreachableCode
if 0: # force-test small UI
self.small_ui = True self.small_ui = True
self.med_ui = False self.med_ui = False
with _ba.Context('ui'): with _ba.Context('ui'):
_ba.pushcall(lambda: _ba.screenmessage( _ba.pushcall(lambda: _ba.screenmessage(
'FORCING SMALL UI FOR TESTING', color=(1, 0, 1), log=True)) '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.small_ui = False
self.med_ui = True self.med_ui = True
with _ba.Context('ui'): with _ba.Context('ui'):
_ba.pushcall(lambda: _ba.screenmessage( _ba.pushcall(lambda: _ba.screenmessage(
'FORCING MEDIUM UI FOR TESTING', color=(1, 0, 1 'FORCING MEDIUM UI FOR TESTING', color=(1, 0, 1
), log=True)) ), log=True))
# noinspection PyUnreachableCode if bool(False): # force-test large UI
if 0: # force-test large UI
self.small_ui = False self.small_ui = False
self.med_ui = False self.med_ui = False
with _ba.Context('ui'): with _ba.Context('ui'):
_ba.pushcall(lambda: _ba.screenmessage( _ba.pushcall(lambda: _ba.screenmessage(
'FORCING LARGE UI FOR TESTING', color=(1, 0, 1), log=True)) '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 # If there's a leftover log file, attempt to upload
# it to the server and/or get rid of it. # it to the server and/or get rid of it.
@ -669,6 +665,7 @@ class App:
to resume. to resume.
""" """
from ba import _gameutils from ba import _gameutils
# FIXME: Shouldn't be touching scene stuff here; # FIXME: Shouldn't be touching scene stuff here;
# should just pass the request on to the host-session. # should just pass the request on to the host-session.
activity = _ba.get_foreground_host_activity() activity = _ba.get_foreground_host_activity()

View File

@ -206,7 +206,7 @@ def uicleanupcheck(obj: Any, widget: ba.Widget) -> None:
widget_death_time=None)) widget_death_time=None))
def upkeep() -> None: def ui_upkeep() -> None:
"""Run UI cleanup checks, etc. should be called periodically.""" """Run UI cleanup checks, etc. should be called periodically."""
app = _ba.app app = _ba.app
remainingchecks = [] remainingchecks = []

View File

@ -403,44 +403,56 @@ class MainMenuActivity(ba.Activity):
# Bring up the last place we were, or start at the main menu otherwise. # Bring up the last place we were, or start at the main menu otherwise.
with ba.Context('ui'): with ba.Context('ui'):
from bastd.ui import specialoffer from bastd.ui import specialoffer
if True: # pylint: disable=using-constant-test if bool(False):
uicontroller = ba.app.uicontroller uicontroller = ba.app.uicontroller
assert uicontroller is not None assert uicontroller is not None
uicontroller.show_main_menu() uicontroller.show_main_menu()
else: 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.
# # when coming back from a kiosk-mode game, jump to if ba.app.kiosk_mode:
# # the kiosk start screen.. # pylint: disable=cyclic-import
# if ba.app.kiosk_mode: from bastd.ui.kiosk import KioskWindow
# ba.app.main_menu_window = ( ba.app.main_menu_window = KioskWindow().get_root_widget()
# bs_ui.KioskWindow().get_root_widget()) # ..or in normal cases go back to the main menu
# # ..or in normal cases go back to the main menu else:
# else: main_window = ba.app.main_window
# if main_window == 'Gather': if main_window == 'Gather':
# ba.app.main_menu_window = (bs_ui.GatherWindow( # pylint: disable=cyclic-import
# transition=None).get_root_widget()) from bastd.ui.gather import GatherWindow
# elif main_window == 'Watch': ba.app.main_menu_window = (GatherWindow(
# ba.app.main_menu_window = (bs_ui.WatchWindow( transition=None).get_root_widget())
# transition=None).get_root_widget()) elif main_window == 'Watch':
# elif main_window == 'Team Game Select': # pylint: disable=cyclic-import
# ba.app.main_menu_window = from bastd.ui.watch import WatchWindow
# (bs_ui.PlaylistBrowserWindow( ba.app.main_menu_window = WatchWindow(
# sessiontype=ba.TeamsSession, transition=None).get_root_widget()
# transition=None).get_root_widget()) elif main_window == 'Team Game Select':
# elif main_window == 'Free-for-All Game Select': # pylint: disable=cyclic-import
# ba.app.main_menu_window = from bastd.ui.playlist.browser import (
# (bs_ui.PlaylistBrowserWindow( PlaylistBrowserWindow)
# sessiontype=ba.FreeForAllSession, ba.app.main_menu_window = PlaylistBrowserWindow(
# transition=None).get_root_widget()) sessiontype=ba.TeamsSession,
# elif main_window == 'Coop Select': transition=None).get_root_widget()
# ba.app.main_menu_window = (bs_ui.CoopWindow( elif main_window == 'Free-for-All Game Select':
# transition=None).get_root_widget()) # pylint: disable=cyclic-import
# else: from bastd.ui.playlist.browser import (
# ba.app.main_menu_window = ( PlaylistBrowserWindow)
# bs_ui.MainMenuWindow( ba.app.main_menu_window = PlaylistBrowserWindow(
# transition=None).get_root_widget()) 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. # attempt to show any pending offers immediately.
# If that doesn't work, try again in a few seconds # If that doesn't work, try again in a few seconds
@ -449,14 +461,14 @@ class MainMenuActivity(ba.Activity):
# until the next opportunity. # until the next opportunity.
if not specialoffer.show_offer(): if not specialoffer.show_offer():
def try_again(): def try_again() -> None:
if not specialoffer.show_offer(): if not specialoffer.show_offer():
# try one last time.. # Try one last time..
ba.timer(2.0, ba.timer(2.0,
specialoffer.show_offer, 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 ba.app.main_menu_did_initial_transition = True
def _update(self) -> None: def _update(self) -> None:

View File

@ -26,7 +26,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import ba import ba
from bastd import stdmap # from bastd import stdmap
if TYPE_CHECKING: if TYPE_CHECKING:
from typing import Any, List, Dict 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 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.""" """Map with a narrow bridge in the middle."""
# noinspection PyUnresolvedReferences # noinspection PyUnresolvedReferences
from bastd.mapdata import bridgit as defs from bastd.mapdata import bridgit as defs
@ -192,7 +192,7 @@ class Bridgit(stdmap.StdMap):
@classmethod @classmethod
def get_play_types(cls) -> List[str]: def get_play_types(cls) -> List[str]:
"""Return valid play types for this map.""" """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'] return ['melee', 'team_flag', 'keep_away']
@classmethod @classmethod

View File

@ -49,7 +49,7 @@ class CoopBrowserWindow(ba.Window):
self._height - 85 - (4 if ba.app.small_ui else 0))) self._height - 85 - (4 if ba.app.small_ui else 0)))
def __init__(self, def __init__(self,
transition: str = 'in_right', transition: Optional[str] = 'in_right',
origin_widget: ba.Widget = None): origin_widget: ba.Widget = None):
# pylint: disable=cyclic-import # pylint: disable=cyclic-import
# pylint: disable=too-many-statements # pylint: disable=too-many-statements

View File

@ -41,7 +41,7 @@ class GatherWindow(ba.Window):
_ba.set_party_icon_always_visible(False) _ba.set_party_icon_always_visible(False)
def __init__(self, def __init__(self,
transition: str = 'in_right', transition: Optional[str] = 'in_right',
origin_widget: ba.Widget = None): origin_widget: ba.Widget = None):
# pylint: disable=too-many-statements # pylint: disable=too-many-statements
# pylint: disable=too-many-locals # pylint: disable=too-many-locals

View File

@ -112,7 +112,7 @@ class LeagueRankButton:
self._smooth_update_timer: Optional[ba.Timer] = None 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._account_state_num = _ba.get_account_state_num()
self._last_power_ranking_query_time: Optional[float] = None self._last_power_ranking_query_time: Optional[float] = None
self._doing_power_ranking_query = False self._doing_power_ranking_query = False
@ -124,7 +124,7 @@ class LeagueRankButton:
repeat=True) repeat=True)
self._update() 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() data = get_cached_league_rank_data()
if data is not None: if data is not None:
self._update_for_league_rank_data(data) self._update_for_league_rank_data(data)
@ -309,8 +309,7 @@ class LeagueRankButton:
timetype=ba.TimeType.REAL, timetype=ba.TimeType.REAL,
timeformat=ba.TimeFormat.MILLISECONDS) timeformat=ba.TimeFormat.MILLISECONDS)
assert self._smooth_percent is not None if (self._percent is not None and self._smooth_percent is not None
if (self._percent is not None
and int(self._smooth_percent) != self._percent): and int(self._smooth_percent) != self._percent):
self._improvement_text = str( self._improvement_text = str(
(int(self._percent) - int(self._smooth_percent))) (int(self._percent) - int(self._smooth_percent)))
@ -354,7 +353,8 @@ class LeagueRankButton:
account_state_num = _ba.get_account_state_num() account_state_num = _ba.get_account_state_num()
if account_state_num != self._account_state_num: if account_state_num != self._account_state_num:
self._account_state_num = 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: if not self._doing_power_ranking_query:
self._last_power_ranking_query_time = None self._last_power_ranking_query_time = None

View File

@ -25,17 +25,18 @@ from __future__ import annotations
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import _ba
import ba import ba
import _ba
if TYPE_CHECKING: if TYPE_CHECKING:
from typing import Any, Callable, List, Dict, Tuple, Optional, Union from typing import Any, Callable, List, Dict, Tuple, Optional, Union
class MainMenuWindow(ba.Window): 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 from bastd import mainmenu
self._in_game = not isinstance(_ba.get_foreground_host_session(), self._in_game = not isinstance(_ba.get_foreground_host_session(),
mainmenu.MainMenuSession) mainmenu.MainMenuSession)
@ -614,6 +615,7 @@ class MainMenuWindow(ba.Window):
self._tdelay += self._t_delay_inc self._tdelay += self._t_delay_inc
else: else:
self._gc_button = None self._gc_button = None
# How-to-play button. # How-to-play button.
h, v, scale = positions[self._p_index] h, v, scale = positions[self._p_index]
self._p_index += 1 self._p_index += 1
@ -627,6 +629,7 @@ class MainMenuWindow(ba.Window):
transition_delay=self._tdelay, transition_delay=self._tdelay,
on_activate_call=self._howtoplay) on_activate_call=self._howtoplay)
self._how_to_play_button = btn self._how_to_play_button = btn
# Scattered eggs on easter. # Scattered eggs on easter.
if _ba.get_account_misc_read_val('easter', if _ba.get_account_misc_read_val('easter',
False) and not self._in_game: False) and not self._in_game:

View File

@ -38,7 +38,7 @@ class PlaylistBrowserWindow(ba.Window):
def __init__(self, def __init__(self,
sessiontype: Type[ba.Session], sessiontype: Type[ba.Session],
transition: str = 'in_right', transition: Optional[str] = 'in_right',
origin_widget: ba.Widget = None): origin_widget: ba.Widget = None):
# pylint: disable=too-many-statements # pylint: disable=too-many-statements
# pylint: disable=cyclic-import # pylint: disable=cyclic-import

View File

@ -36,7 +36,7 @@ class WatchWindow(ba.Window):
"""Window for watching replays.""" """Window for watching replays."""
def __init__(self, def __init__(self,
transition: str = 'in_right', transition: Optional[str] = 'in_right',
origin_widget: ba.Widget = None): origin_widget: ba.Widget = None):
# pylint: disable=too-many-locals # pylint: disable=too-many-locals
# pylint: disable=too-many-statements # pylint: disable=too-many-statements

View File

@ -139,10 +139,6 @@
<h4><a name="class_category_User_Interface_Classes">User Interface Classes</a></h4> <h4><a name="class_category_User_Interface_Classes">User Interface Classes</a></h4>
<ul> <ul>
<li><a href="#class_ba_UIController">ba.UIController</a></li> <li><a href="#class_ba_UIController">ba.UIController</a></li>
<li><a href="#class_ba_UILocation">ba.UILocation</a></li>
<ul>
<li><a href="#class_ba_UILocationWindow">ba.UILocationWindow</a></li>
</ul>
<li><a href="#class_ba_Widget">ba.Widget</a></li> <li><a href="#class_ba_Widget">ba.Widget</a></li>
<li><a href="#class_ba_Window">ba.Window</a></li> <li><a href="#class_ba_Window">ba.Window</a></li>
</ul> </ul>
@ -4714,65 +4710,6 @@ self.t = <a href="#class_ba_Timer">ba.Timer</a>(0.3, say_it, repeat=True)
<p>Show the main menu, clearing other UIs from location stacks.</p> <p>Show the main menu, clearing other UIs from location stacks.</p>
</dd>
</dl>
<hr>
<h2><strong><a name="class_ba_UILocation">ba.UILocation</a></strong></h3>
<p><em>&lt;top level class&gt;</em>
</p>
<p>Defines a specific 'place' in the UI the user can navigate to.</p>
<p>Category: <a href="#class_category_User_Interface_Classes">User Interface Classes</a>
</p>
<h3>Methods:</h3>
<h5><a href="#method_ba_UILocation____init__">&lt;constructor&gt;</a>, <a href="#method_ba_UILocation__push_location">push_location()</a>, <a href="#method_ba_UILocation__restore_state">restore_state()</a>, <a href="#method_ba_UILocation__save_state">save_state()</a></h5>
<dl>
<dt><h4><a name="method_ba_UILocation____init__">&lt;constructor&gt;</a></dt></h4><dd>
<p><span>ba.UILocation()</span></p>
</dd>
<dt><h4><a name="method_ba_UILocation__push_location">push_location()</a></dt></h4><dd>
<p><span>push_location(self, location: str) -&gt; None</span></p>
<p>Push a new location to the stack and transition to it.</p>
</dd>
<dt><h4><a name="method_ba_UILocation__restore_state">restore_state()</a></dt></h4><dd>
<p><span>restore_state(self) -&gt; None</span></p>
<p>Restore this instance's state from a dict.</p>
</dd>
<dt><h4><a name="method_ba_UILocation__save_state">save_state()</a></dt></h4><dd>
<p><span>save_state(self) -&gt; None</span></p>
<p>Serialize this instance's state to a dict.</p>
</dd>
</dl>
<hr>
<h2><strong><a name="class_ba_UILocationWindow">ba.UILocationWindow</a></strong></h3>
<p>inherits from: <a href="#class_ba_UILocation">ba.UILocation</a></p>
<p>A UILocation consisting of a single root window widget.</p>
<p>Category: <a href="#class_category_User_Interface_Classes">User Interface Classes</a>
</p>
<h3>Methods Inherited:</h3>
<h5><a href="#method_ba_UILocation__push_location">push_location()</a>, <a href="#method_ba_UILocation__restore_state">restore_state()</a>, <a href="#method_ba_UILocation__save_state">save_state()</a></h5>
<h3>Methods Defined or Overridden:</h3>
<h5><a href="#method_ba_UILocationWindow____init__">&lt;constructor&gt;</a>, <a href="#method_ba_UILocationWindow__get_root_widget">get_root_widget()</a></h5>
<dl>
<dt><h4><a name="method_ba_UILocationWindow____init__">&lt;constructor&gt;</a></dt></h4><dd>
<p><span>ba.UILocationWindow()</span></p>
</dd>
<dt><h4><a name="method_ba_UILocationWindow__get_root_widget">get_root_widget()</a></dt></h4><dd>
<p><span>get_root_widget(self) -&gt; <a href="#class_ba_Widget">ba.Widget</a></span></p>
<p>Return the root widget for this window.</p>
</dd> </dd>
</dl> </dl>
<hr> <hr>