mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-01-23 15:33:26 +08:00
Added ui module preloading to prevent hitches
This commit is contained in:
parent
13937d4777
commit
fe8b030b21
@ -4135,16 +4135,16 @@
|
||||
"assets/build/windows/x64/vc_redist.x64.exe": "https://files.ballistica.net/cache/ba1/ea/19/8b8787d81abcdce158ba608cd24f",
|
||||
"assets/build/windows/x64/vcruntime140_1d.dll": "https://files.ballistica.net/cache/ba1/11/d8/ff6344b429b00c24d9a1930d4338",
|
||||
"assets/build/windows/x64/vcruntime140d.dll": "https://files.ballistica.net/cache/ba1/20/33/0825e11e6518f87ece3009309933",
|
||||
"build/prefab/linux-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/48/94/a726a87b0601df96b34e457f406f",
|
||||
"build/prefab/linux-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/93/f4/1de7a2a7b25e9797cdeb8fbdbd4a",
|
||||
"build/prefab/linux/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/ed/6f/8d356c4b4aacb83ef227498a0c5c",
|
||||
"build/prefab/linux/release/ballisticacore": "https://files.ballistica.net/cache/ba1/a8/76/4bf599bdab77331350d0da8a5714",
|
||||
"build/prefab/mac-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/3a/36/ebcc874f5b681e4fc22b0512f31b",
|
||||
"build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/b3/5f/c2b1ff67661b855f93a201fe78fd",
|
||||
"build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/d6/ea/bc68af318e0100d2d4cde351591b",
|
||||
"build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/da/08/6913f20d7c0a6f77369f3ade467a",
|
||||
"build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/36/af/73e96b1008e2a34b43a482534c04",
|
||||
"build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/19/3b/ee02640ca173b63aa1805fe3b82b",
|
||||
"build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/15/d1/c79915d092932b4019ad086d93dc",
|
||||
"build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/83/c1/73811083cdfbd86f7365001a0ccb"
|
||||
"build/prefab/linux-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/0d/10/8b0acfe18403ed5f7648cbd16304",
|
||||
"build/prefab/linux-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/60/d6/78971bf24839db03eb52df3d66fa",
|
||||
"build/prefab/linux/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/6f/17/265584b464b9ed0dd32f5138513c",
|
||||
"build/prefab/linux/release/ballisticacore": "https://files.ballistica.net/cache/ba1/47/42/4b10abcb0acd20c7a36d80283046",
|
||||
"build/prefab/mac-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ec/7c/0456f8a0371de22d65dfc50389b4",
|
||||
"build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/34/c8/d7c9071a85ddc33e395960af86e0",
|
||||
"build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/41/b6/aa543cfed5ef05b6b1aae26c33f0",
|
||||
"build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/50/dd/4be23bf45b013537a3970e457976",
|
||||
"build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/32/4c/aff483fae256674f9833946cd5f2",
|
||||
"build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/93/ff/d898d07ebebebfd225d6bb437488",
|
||||
"build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/f1/c5/d56a83b4e32c1a2e566054cf58ad",
|
||||
"build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/44/9a/5cef4f8e575e210baac8857e265b"
|
||||
}
|
||||
@ -1,3 +1,6 @@
|
||||
### 1.5.9 (20081)
|
||||
- Reduced some hitches when clicking on certain buttons in the UI
|
||||
|
||||
### 1.5.8 (20079)
|
||||
- Fixed an issue where touch controls or sound settings values could look like 0.8999999999. Please holler if you see this anywhere else.
|
||||
- Fixed a potential crash when tapping the screen before the game is fully inited.
|
||||
|
||||
@ -29,6 +29,8 @@ from typing import TYPE_CHECKING
|
||||
|
||||
import _ba
|
||||
import ba
|
||||
from bastd.ui.store.button import StoreButton
|
||||
from bastd.ui.league.rankbutton import LeagueRankButton
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Any, Optional, Tuple, Dict, List, Union
|
||||
@ -54,8 +56,12 @@ class CoopBrowserWindow(ba.Window):
|
||||
# pylint: disable=cyclic-import
|
||||
# pylint: disable=too-many-statements
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui.store.button import StoreButton
|
||||
from bastd.ui.league.rankbutton import LeagueRankButton
|
||||
import threading
|
||||
|
||||
# Preload some modules we use in a background thread so we won't
|
||||
# have a visual hitch when the user taps them.
|
||||
threading.Thread(target=self._preload_modules).start()
|
||||
|
||||
ba.set_analytics_screen('Coop Window')
|
||||
|
||||
app = ba.app
|
||||
@ -271,6 +277,20 @@ class CoopBrowserWindow(ba.Window):
|
||||
repeat=True)
|
||||
self._update()
|
||||
|
||||
@staticmethod
|
||||
def _preload_modules() -> None:
|
||||
"""For preloading modules we use in a bg thread to prevent hitches."""
|
||||
import bastd.ui.purchase as _unused1
|
||||
import bastd.ui.coop.gamebutton as _unused2
|
||||
import bastd.ui.confirm as _unused3
|
||||
import bastd.ui.account as _unused4
|
||||
import bastd.ui.league.rankwindow as _unused5
|
||||
import bastd.ui.store.browser as _unused6
|
||||
import bastd.ui.account.viewer as _unused7
|
||||
import bastd.ui.tournamentscores as _unused8
|
||||
import bastd.ui.tournamententry as _unused9
|
||||
import bastd.ui.play as _unused10
|
||||
|
||||
def _update(self) -> None:
|
||||
cur_time = ba.time(ba.TimeType.REAL)
|
||||
|
||||
@ -739,13 +759,13 @@ class CoopBrowserWindow(ba.Window):
|
||||
|
||||
def _on_tournament_info_press(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui import confirm
|
||||
from bastd.ui.confirm import ConfirmWindow
|
||||
txt = ba.Lstr(resource=self._r + '.tournamentInfoText')
|
||||
confirm.ConfirmWindow(txt,
|
||||
cancel_button=False,
|
||||
width=550,
|
||||
height=260,
|
||||
origin_widget=self._tournament_info_button)
|
||||
ConfirmWindow(txt,
|
||||
cancel_button=False,
|
||||
width=550,
|
||||
height=260,
|
||||
origin_widget=self._tournament_info_button)
|
||||
|
||||
def _refresh(self) -> None:
|
||||
# pylint: disable=too-many-statements
|
||||
@ -1335,10 +1355,10 @@ class CoopBrowserWindow(ba.Window):
|
||||
|
||||
def _switch_to_league_rankings(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui import account
|
||||
from bastd.ui.account import show_sign_in_prompt
|
||||
from bastd.ui.league.rankwindow import LeagueRankWindow
|
||||
if _ba.get_account_state() != 'signed_in':
|
||||
account.show_sign_in_prompt()
|
||||
show_sign_in_prompt()
|
||||
return
|
||||
self._save_state()
|
||||
ba.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
@ -1349,22 +1369,22 @@ class CoopBrowserWindow(ba.Window):
|
||||
|
||||
def _switch_to_score(self, show_tab: Optional[str] = 'extras') -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui import account
|
||||
from bastd.ui.store import browser
|
||||
from bastd.ui.account import show_sign_in_prompt
|
||||
from bastd.ui.store.browser import StoreBrowserWindow
|
||||
if _ba.get_account_state() != 'signed_in':
|
||||
account.show_sign_in_prompt()
|
||||
show_sign_in_prompt()
|
||||
return
|
||||
self._save_state()
|
||||
ba.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
assert self._store_button is not None
|
||||
ba.app.main_menu_window = (browser.StoreBrowserWindow(
|
||||
ba.app.main_menu_window = (StoreBrowserWindow(
|
||||
origin_widget=self._store_button.get_button(),
|
||||
show_tab=show_tab,
|
||||
back_location='CoopBrowserWindow').get_root_widget())
|
||||
|
||||
def _show_leader(self, tournament_button: Dict[str, Any]) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui.account import viewer
|
||||
from bastd.ui.account.viewer import AccountViewerWindow
|
||||
tournament_id = tournament_button['tournament_id']
|
||||
|
||||
# FIXME: This assumes a single player entry in leader; should expand
|
||||
@ -1374,7 +1394,7 @@ class CoopBrowserWindow(ba.Window):
|
||||
ba.playsound(ba.getsound('error'))
|
||||
return
|
||||
ba.playsound(ba.getsound('swish'))
|
||||
viewer.AccountViewerWindow(
|
||||
AccountViewerWindow(
|
||||
account_id=tournament_button['leader'][2][0].get('a', None),
|
||||
profile_id=tournament_button['leader'][2][0].get('p', None),
|
||||
position=tournament_button['current_leader_name_text'].
|
||||
@ -1382,13 +1402,13 @@ class CoopBrowserWindow(ba.Window):
|
||||
|
||||
def _show_scores(self, tournament_button: Dict[str, Any]) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui import tournamentscores
|
||||
from bastd.ui.tournamentscores import TournamentScoresWindow
|
||||
tournament_id = tournament_button['tournament_id']
|
||||
if tournament_id is None:
|
||||
ba.playsound(ba.getsound('error'))
|
||||
return
|
||||
|
||||
tournamentscores.TournamentScoresWindow(
|
||||
TournamentScoresWindow(
|
||||
tournament_id=tournament_id,
|
||||
position=tournament_button['more_scores_button'].
|
||||
get_screen_space_center())
|
||||
@ -1406,8 +1426,8 @@ class CoopBrowserWindow(ba.Window):
|
||||
# pylint: disable=too-many-return-statements
|
||||
# pylint: disable=cyclic-import
|
||||
from ba.internal import have_pro
|
||||
from bastd.ui import confirm
|
||||
from bastd.ui import tournamententry
|
||||
from bastd.ui.confirm import ConfirmWindow
|
||||
from bastd.ui.tournamententry import TournamentEntryWindow
|
||||
from bastd.ui.purchase import PurchaseWindow
|
||||
from bastd.ui.account import show_sign_in_prompt
|
||||
args: Dict[str, Any] = {}
|
||||
@ -1457,12 +1477,11 @@ class CoopBrowserWindow(ba.Window):
|
||||
tournament_button['tournament_id']]['game']
|
||||
|
||||
if tournament_button is None and game == 'Easy:The Last Stand':
|
||||
confirm.ConfirmWindow(ba.Lstr(
|
||||
resource='difficultyHardUnlockOnlyText',
|
||||
fallback_resource='difficultyHardOnlyText'),
|
||||
cancel_button=False,
|
||||
width=460,
|
||||
height=130)
|
||||
ConfirmWindow(ba.Lstr(resource='difficultyHardUnlockOnlyText',
|
||||
fallback_resource='difficultyHardOnlyText'),
|
||||
cancel_button=False,
|
||||
width=460,
|
||||
height=130)
|
||||
return
|
||||
|
||||
# Infinite onslaught/runaround require pro; bring up a store link if
|
||||
@ -1506,7 +1525,7 @@ class CoopBrowserWindow(ba.Window):
|
||||
|
||||
# For tournaments, we pop up the entry window.
|
||||
if tournament_button is not None:
|
||||
tournamententry.TournamentEntryWindow(
|
||||
TournamentEntryWindow(
|
||||
tournament_id=tournament_button['tournament_id'],
|
||||
position=tournament_button['button'].get_screen_space_center())
|
||||
else:
|
||||
|
||||
@ -374,8 +374,9 @@ class LeagueRankButton:
|
||||
callback=ba.WeakCall(self._on_power_ranking_query_response))
|
||||
|
||||
def _default_on_activate_call(self) -> None:
|
||||
from bastd.ui.league import rankwindow
|
||||
rankwindow.LeagueRankWindow(modal=True, origin_widget=self._button)
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui.league.rankwindow import LeagueRankWindow
|
||||
LeagueRankWindow(modal=True, origin_widget=self._button)
|
||||
|
||||
def set_position(self, position: Tuple[float, float]) -> None:
|
||||
"""Set the button's position."""
|
||||
|
||||
@ -37,12 +37,17 @@ class MainMenuWindow(ba.Window):
|
||||
|
||||
def __init__(self, transition: Optional[str] = 'in_right'):
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd import mainmenu
|
||||
import threading
|
||||
from bastd.mainmenu import MainMenuSession
|
||||
self._in_game = not isinstance(_ba.get_foreground_host_session(),
|
||||
mainmenu.MainMenuSession)
|
||||
MainMenuSession)
|
||||
|
||||
# Preload some modules we use in a background thread so we won't
|
||||
# have a visual hitch when the user taps them.
|
||||
threading.Thread(target=self._preload_modules).start()
|
||||
|
||||
if not self._in_game:
|
||||
ba.set_analytics_screen('Main Menu')
|
||||
|
||||
self._show_remote_app_info_on_first_launch()
|
||||
|
||||
# Make a vanilla container; we'll modify it to our needs in refresh.
|
||||
@ -84,6 +89,22 @@ class MainMenuWindow(ba.Window):
|
||||
repeat=True,
|
||||
timetype=ba.TimeType.REAL)
|
||||
|
||||
@staticmethod
|
||||
def _preload_modules() -> None:
|
||||
"""For preloading modules we use in a bg thread to prevent hitches."""
|
||||
import bastd.ui.getremote as _unused
|
||||
import bastd.ui.confirm as _unused2
|
||||
import bastd.ui.store.button as _unused3
|
||||
import bastd.ui.kiosk as _unused4
|
||||
import bastd.ui.account.settings as _unused5
|
||||
import bastd.ui.store.browser as _unused6
|
||||
import bastd.ui.creditslist as _unused7
|
||||
import bastd.ui.helpui as _unused8
|
||||
import bastd.ui.settings.allsettings as _unused9
|
||||
import bastd.ui.gather as _unused10
|
||||
import bastd.ui.watch as _unused11
|
||||
import bastd.ui.play as _unused12
|
||||
|
||||
def _show_remote_app_info_on_first_launch(self) -> None:
|
||||
# The first time the non-in-game menu pops up, we might wanna show
|
||||
# a 'get-remote-app' dialog in front of it.
|
||||
@ -99,12 +120,12 @@ class MainMenuWindow(ba.Window):
|
||||
|
||||
def _check_show_bs_remote_window() -> None:
|
||||
try:
|
||||
from bastd.ui import getremote
|
||||
from bastd.ui.getremote import GetBSRemoteWindow
|
||||
ba.playsound(ba.getsound('swish'))
|
||||
getremote.GetBSRemoteWindow()
|
||||
GetBSRemoteWindow()
|
||||
except Exception:
|
||||
ba.print_exception(
|
||||
'error showing ba-remote window')
|
||||
'Error showing get-remote window.')
|
||||
|
||||
ba.timer(2.5,
|
||||
_check_show_bs_remote_window,
|
||||
@ -149,7 +170,7 @@ class MainMenuWindow(ba.Window):
|
||||
# pylint: disable=too-many-branches
|
||||
# pylint: disable=too-many-locals
|
||||
# pylint: disable=too-many-statements
|
||||
from bastd.ui import confirm
|
||||
from bastd.ui.confirm import QuitWindow
|
||||
from bastd.ui.store.button import StoreButton
|
||||
|
||||
# Clear everything that was there.
|
||||
@ -323,7 +344,7 @@ class MainMenuWindow(ba.Window):
|
||||
and ba.app.platform == 'android'):
|
||||
|
||||
def _do_quit() -> None:
|
||||
confirm.QuitWindow(swish=True, back=True)
|
||||
QuitWindow(swish=True, back=True)
|
||||
|
||||
ba.containerwidget(edit=self._root_widget,
|
||||
on_cancel_call=_do_quit)
|
||||
@ -804,68 +825,67 @@ class MainMenuWindow(ba.Window):
|
||||
|
||||
def _quit(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui import confirm
|
||||
confirm.QuitWindow(origin_widget=self._quit_button)
|
||||
from bastd.ui.confirm import QuitWindow
|
||||
QuitWindow(origin_widget=self._quit_button)
|
||||
|
||||
def _demo_menu_press(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui import kiosk
|
||||
from bastd.ui.kiosk import KioskWindow
|
||||
self._save_state()
|
||||
ba.containerwidget(edit=self._root_widget, transition='out_right')
|
||||
ba.app.main_menu_window = (kiosk.KioskWindow(
|
||||
ba.app.main_menu_window = (KioskWindow(
|
||||
transition='in_left').get_root_widget())
|
||||
|
||||
def _show_account_window(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui.account import settings
|
||||
from bastd.ui.account.settings import AccountSettingsWindow
|
||||
self._save_state()
|
||||
ba.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
ba.app.main_menu_window = (settings.AccountSettingsWindow(
|
||||
ba.app.main_menu_window = (AccountSettingsWindow(
|
||||
origin_widget=self._gc_button).get_root_widget())
|
||||
|
||||
def _on_store_pressed(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui.store import browser
|
||||
from bastd.ui import account
|
||||
from bastd.ui.store.browser import StoreBrowserWindow
|
||||
from bastd.ui.account import show_sign_in_prompt
|
||||
if _ba.get_account_state() != 'signed_in':
|
||||
account.show_sign_in_prompt()
|
||||
show_sign_in_prompt()
|
||||
return
|
||||
self._save_state()
|
||||
ba.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
ba.app.main_menu_window = (browser.StoreBrowserWindow(
|
||||
ba.app.main_menu_window = (StoreBrowserWindow(
|
||||
origin_widget=self._store_button).get_root_widget())
|
||||
|
||||
def _confirm_end_game(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui import confirm
|
||||
from bastd.ui.confirm import ConfirmWindow
|
||||
# FIXME: Currently we crash calling this on client-sessions.
|
||||
|
||||
# Select cancel by default; this occasionally gets called by accident
|
||||
# in a fit of button mashing and this will help reduce damage.
|
||||
confirm.ConfirmWindow(ba.Lstr(resource=self._r + '.exitToMenuText'),
|
||||
self._end_game,
|
||||
cancel_is_selected=True)
|
||||
ConfirmWindow(ba.Lstr(resource=self._r + '.exitToMenuText'),
|
||||
self._end_game,
|
||||
cancel_is_selected=True)
|
||||
|
||||
def _confirm_end_replay(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui import confirm
|
||||
from bastd.ui.confirm import ConfirmWindow
|
||||
|
||||
# Select cancel by default; this occasionally gets called by accident
|
||||
# in a fit of button mashing and this will help reduce damage.
|
||||
confirm.ConfirmWindow(ba.Lstr(resource=self._r + '.exitToMenuText'),
|
||||
self._end_game,
|
||||
cancel_is_selected=True)
|
||||
ConfirmWindow(ba.Lstr(resource=self._r + '.exitToMenuText'),
|
||||
self._end_game,
|
||||
cancel_is_selected=True)
|
||||
|
||||
def _confirm_leave_party(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui import confirm
|
||||
from bastd.ui.confirm import ConfirmWindow
|
||||
|
||||
# Select cancel by default; this occasionally gets called by accident
|
||||
# in a fit of button mashing and this will help reduce damage.
|
||||
confirm.ConfirmWindow(ba.Lstr(resource=self._r +
|
||||
'.leavePartyConfirmText'),
|
||||
self._leave_party,
|
||||
cancel_is_selected=True)
|
||||
ConfirmWindow(ba.Lstr(resource=self._r + '.leavePartyConfirmText'),
|
||||
self._leave_party,
|
||||
cancel_is_selected=True)
|
||||
|
||||
def _leave_party(self) -> None:
|
||||
_ba.disconnect_from_host()
|
||||
@ -886,27 +906,27 @@ class MainMenuWindow(ba.Window):
|
||||
|
||||
def _credits(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui import creditslist
|
||||
from bastd.ui.creditslist import CreditsListWindow
|
||||
self._save_state()
|
||||
ba.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
ba.app.main_menu_window = (creditslist.CreditsListWindow(
|
||||
ba.app.main_menu_window = (CreditsListWindow(
|
||||
origin_widget=self._credits_button).get_root_widget())
|
||||
|
||||
def _howtoplay(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui import helpui
|
||||
from bastd.ui.helpui import HelpWindow
|
||||
self._save_state()
|
||||
ba.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
ba.app.main_menu_window = (helpui.HelpWindow(
|
||||
ba.app.main_menu_window = (HelpWindow(
|
||||
main_menu=True,
|
||||
origin_widget=self._how_to_play_button).get_root_widget())
|
||||
|
||||
def _settings(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui.settings import allsettings
|
||||
from bastd.ui.settings.allsettings import AllSettingsWindow
|
||||
self._save_state()
|
||||
ba.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
ba.app.main_menu_window = (allsettings.AllSettingsWindow(
|
||||
ba.app.main_menu_window = (AllSettingsWindow(
|
||||
origin_widget=self._settings_button).get_root_widget())
|
||||
|
||||
def _resume_and_call(self, call: Callable[[], Any]) -> None:
|
||||
|
||||
@ -39,6 +39,12 @@ class PlayWindow(ba.Window):
|
||||
origin_widget: ba.Widget = None):
|
||||
# pylint: disable=too-many-statements
|
||||
# pylint: disable=too-many-locals
|
||||
import threading
|
||||
|
||||
# Preload some modules we use in a background thread so we won't
|
||||
# have a visual hitch when the user taps them.
|
||||
threading.Thread(target=self._preload_modules).start()
|
||||
|
||||
new_style = True
|
||||
width = 1000 if ba.app.small_ui else 800
|
||||
x_offs = 100 if ba.app.small_ui else 0
|
||||
@ -410,42 +416,50 @@ class PlayWindow(ba.Window):
|
||||
|
||||
self._restore_state()
|
||||
|
||||
@staticmethod
|
||||
def _preload_modules() -> None:
|
||||
"""For preloading modules we use in a bg thread to prevent hitches."""
|
||||
import bastd.ui.mainmenu as _unused1
|
||||
import bastd.ui.account as _unused2
|
||||
import bastd.ui.coop.browser as _unused3
|
||||
import bastd.ui.playlist.browser as _unused4
|
||||
|
||||
def _back(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui import mainmenu
|
||||
from bastd.ui.mainmenu import MainMenuWindow
|
||||
self._save_state()
|
||||
ba.app.main_menu_window = (mainmenu.MainMenuWindow(
|
||||
ba.app.main_menu_window = (MainMenuWindow(
|
||||
transition='in_left').get_root_widget())
|
||||
ba.containerwidget(edit=self._root_widget,
|
||||
transition=self._transition_out)
|
||||
|
||||
def _coop(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui import account
|
||||
from bastd.ui.coop import browser
|
||||
from bastd.ui.account import show_sign_in_prompt
|
||||
from bastd.ui.coop.browser import CoopBrowserWindow
|
||||
if _ba.get_account_state() != 'signed_in':
|
||||
account.show_sign_in_prompt()
|
||||
show_sign_in_prompt()
|
||||
return
|
||||
self._save_state()
|
||||
ba.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
ba.app.main_menu_window = (browser.CoopBrowserWindow(
|
||||
ba.app.main_menu_window = (CoopBrowserWindow(
|
||||
origin_widget=self._coop_button).get_root_widget())
|
||||
|
||||
def _team_tourney(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui.playlist import browser
|
||||
from bastd.ui.playlist.browser import PlaylistBrowserWindow
|
||||
self._save_state()
|
||||
ba.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
ba.app.main_menu_window = (browser.PlaylistBrowserWindow(
|
||||
ba.app.main_menu_window = (PlaylistBrowserWindow(
|
||||
origin_widget=self._teams_button,
|
||||
sessiontype=ba.DualTeamSession).get_root_widget())
|
||||
|
||||
def _free_for_all(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui.playlist import browser
|
||||
from bastd.ui.playlist.browser import PlaylistBrowserWindow
|
||||
self._save_state()
|
||||
ba.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
ba.app.main_menu_window = (browser.PlaylistBrowserWindow(
|
||||
ba.app.main_menu_window = (PlaylistBrowserWindow(
|
||||
origin_widget=self._free_for_all_button,
|
||||
sessiontype=ba.FreeForAllSession).get_root_widget())
|
||||
|
||||
|
||||
@ -39,6 +39,12 @@ class AllSettingsWindow(ba.Window):
|
||||
origin_widget: ba.Widget = None):
|
||||
# pylint: disable=too-many-statements
|
||||
# pylint: disable=too-many-locals
|
||||
import threading
|
||||
|
||||
# Preload some modules we use in a background thread so we won't
|
||||
# have a visual hitch when the user taps them.
|
||||
threading.Thread(target=self._preload_modules).start()
|
||||
|
||||
ba.set_analytics_screen('Settings Window')
|
||||
scale_origin: Optional[Tuple[float, float]]
|
||||
if origin_widget is not None:
|
||||
@ -197,45 +203,54 @@ class AllSettingsWindow(ba.Window):
|
||||
texture=ba.gettexture('advancedIcon'),
|
||||
draw_controller=avb)
|
||||
|
||||
@staticmethod
|
||||
def _preload_modules() -> None:
|
||||
"""For preloading modules we use in a bg thread to prevent hitches."""
|
||||
import bastd.ui.mainmenu as _unused1
|
||||
import bastd.ui.settings.controls as _unused2
|
||||
import bastd.ui.settings.graphics as _unused3
|
||||
import bastd.ui.settings.audio as _unused4
|
||||
import bastd.ui.settings.advanced as _unused5
|
||||
|
||||
def _do_back(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui import mainmenu
|
||||
from bastd.ui.mainmenu import MainMenuWindow
|
||||
self._save_state()
|
||||
ba.containerwidget(edit=self._root_widget,
|
||||
transition=self._transition_out)
|
||||
ba.app.main_menu_window = (mainmenu.MainMenuWindow(
|
||||
ba.app.main_menu_window = (MainMenuWindow(
|
||||
transition='in_left').get_root_widget())
|
||||
|
||||
def _do_controllers(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui.settings import controls
|
||||
from bastd.ui.settings.controls import ControlsSettingsWindow
|
||||
self._save_state()
|
||||
ba.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
ba.app.main_menu_window = (controls.ControlsSettingsWindow(
|
||||
ba.app.main_menu_window = (ControlsSettingsWindow(
|
||||
origin_widget=self._controllers_button).get_root_widget())
|
||||
|
||||
def _do_graphics(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui.settings import graphics
|
||||
from bastd.ui.settings.graphics import GraphicsSettingsWindow
|
||||
self._save_state()
|
||||
ba.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
ba.app.main_menu_window = (graphics.GraphicsSettingsWindow(
|
||||
ba.app.main_menu_window = (GraphicsSettingsWindow(
|
||||
origin_widget=self._graphics_button).get_root_widget())
|
||||
|
||||
def _do_audio(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui.settings import audio
|
||||
from bastd.ui.settings.audio import AudioSettingsWindow
|
||||
self._save_state()
|
||||
ba.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
ba.app.main_menu_window = (audio.AudioSettingsWindow(
|
||||
ba.app.main_menu_window = (AudioSettingsWindow(
|
||||
origin_widget=self._audio_button).get_root_widget())
|
||||
|
||||
def _do_advanced(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui.settings import advanced
|
||||
from bastd.ui.settings.advanced import AdvancedSettingsWindow
|
||||
self._save_state()
|
||||
ba.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
ba.app.main_menu_window = (advanced.AdvancedSettingsWindow(
|
||||
ba.app.main_menu_window = (AdvancedSettingsWindow(
|
||||
origin_widget=self._advanced_button).get_root_widget())
|
||||
|
||||
def _save_state(self) -> None:
|
||||
|
||||
@ -212,12 +212,13 @@ class StoreButton:
|
||||
self._sale_circle_rad * 0.3))
|
||||
|
||||
def _default_on_activate_call(self) -> None:
|
||||
from bastd.ui import account
|
||||
from bastd.ui.store import browser
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.ui.account import show_sign_in_prompt
|
||||
from bastd.ui.store.browser import StoreBrowserWindow
|
||||
if _ba.get_account_state() != 'signed_in':
|
||||
account.show_sign_in_prompt()
|
||||
show_sign_in_prompt()
|
||||
return
|
||||
browser.StoreBrowserWindow(modal=True, origin_widget=self._button)
|
||||
StoreBrowserWindow(modal=True, origin_widget=self._button)
|
||||
|
||||
def get_button(self) -> ba.Widget:
|
||||
"""Return the underlying button widget."""
|
||||
@ -225,6 +226,7 @@ class StoreButton:
|
||||
|
||||
def _update(self) -> None:
|
||||
# pylint: disable=too-many-branches
|
||||
# pylint: disable=cyclic-import
|
||||
from ba import SpecialChar, TimeFormat
|
||||
from ba.internal import (get_available_sale_time,
|
||||
get_available_purchase_count)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user