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._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

View File

@ -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()

View File

@ -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 = []

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -139,10 +139,6 @@
<h4><a name="class_category_User_Interface_Classes">User Interface Classes</a></h4>
<ul>
<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_Window">ba.Window</a></li>
</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>
</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>
</dl>
<hr>