Progress on getting UI back to stable 1.4 state (disabling new location stuff for now)

This commit is contained in:
Eric Froemling 2020-04-05 01:53:28 -07:00
parent 1560a15ddd
commit d933200197
64 changed files with 168 additions and 148 deletions

View File

@ -1776,6 +1776,7 @@
<w>uber</w> <w>uber</w>
<w>ugrade</w> <w>ugrade</w>
<w>uibounds</w> <w>uibounds</w>
<w>uicleanup</w>
<w>uicleanupcheck</w> <w>uicleanupcheck</w>
<w>uicleanupchecks</w> <w>uicleanupchecks</w>
<w>uicontroller</w> <w>uicontroller</w>

View File

@ -81,7 +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 (OldWindow, UILocation, UILocationWindow, UIController, from ba.ui import (Window, UILocation, UILocationWindow, UIController,
uicleanupcheck) uicleanupcheck)
app: App app: App

View File

@ -29,6 +29,7 @@ import _ba
if TYPE_CHECKING: if TYPE_CHECKING:
import ba import ba
from ba import _lang, _meta from ba import _lang, _meta
from ba.ui import UICleanupCheck
from bastd.actor import spazappearance from bastd.actor import spazappearance
from typing import (Optional, Dict, Tuple, Set, Any, List, Type, Tuple, from typing import (Optional, Dict, Tuple, Set, Any, List, Type, Tuple,
Callable) Callable)
@ -429,7 +430,7 @@ class App:
self.title_color = (0.72, 0.7, 0.75) self.title_color = (0.72, 0.7, 0.75)
self.heading_color = (0.72, 0.7, 0.75) self.heading_color = (0.72, 0.7, 0.75)
self.infotextcolor = (0.7, 0.9, 0.7) self.infotextcolor = (0.7, 0.9, 0.7)
self.uicleanupchecks: List[dict] = [] self.uicleanupchecks: List[UICleanupCheck] = []
self.uiupkeeptimer: Optional[ba.Timer] = None self.uiupkeeptimer: Optional[ba.Timer] = None
self.delegate: Optional[ba.AppDelegate] = None self.delegate: Optional[ba.AppDelegate] = None

View File

@ -22,7 +22,9 @@
from __future__ import annotations from __future__ import annotations
import os
import weakref import weakref
from dataclasses import dataclass
from typing import TYPE_CHECKING, cast, Type from typing import TYPE_CHECKING, cast, Type
import _ba import _ba
@ -30,11 +32,17 @@ from ba._enums import TimeType
if TYPE_CHECKING: if TYPE_CHECKING:
from typing import Optional, List, Any from typing import Optional, List, Any
from weakref import ReferenceType
import ba import ba
# Set environment variable BA_DEBUG_UI_CLEANUP_CHECKS to 1
# to print detailed info about what is getting cleaned up when.
DEBUG_UI_CLEANUP_CHECKS = os.environ.get('BA_DEBUG_UI_CLEANUP_CHECKS') == '1'
class OldWindow:
"""Temp for transitioning windows over to UILocationWindows. class Window:
"""A basic window.
Category: User Interface Classes Category: User Interface Classes
""" """
@ -47,6 +55,14 @@ class OldWindow:
return self._root_widget return self._root_widget
@dataclass
class UICleanupCheck:
"""Holds info about a uicleanupcheck target."""
obj: ReferenceType
widget: ba.Widget
widget_death_time: Optional[float]
class UILocation: class UILocation:
"""Defines a specific 'place' in the UI the user can navigate to. """Defines a specific 'place' in the UI the user can navigate to.
@ -143,7 +159,7 @@ class UIController:
self._update_ui() self._update_ui()
def _update_ui(self) -> None: def _update_ui(self) -> None:
"""Instantiates the topmost ui in our stacks.""" """Instantiate the topmost ui in our stacks."""
# First tell any existing UIs to get outta here. # First tell any existing UIs to get outta here.
for stack in (self._dialog_stack, self._main_stack): for stack in (self._dialog_stack, self._main_stack):
@ -173,19 +189,21 @@ def uicleanupcheck(obj: Any, widget: ba.Widget) -> None:
strong referencing can lead to such objects never getting destroyed, strong referencing can lead to such objects never getting destroyed,
however, and this helps detect such cases to avoid memory leaks. however, and this helps detect such cases to avoid memory leaks.
""" """
if DEBUG_UI_CLEANUP_CHECKS:
print(f'adding uicleanup to {obj}')
if not isinstance(widget, _ba.Widget): if not isinstance(widget, _ba.Widget):
raise Exception('widget arg is not a ba.Widget') raise Exception('widget arg is not a ba.Widget')
def foobar() -> None: def foobar() -> None:
"""Just testing.""" """Just testing."""
print('uicleanupcheck widget dying...') if DEBUG_UI_CLEANUP_CHECKS:
print('uicleanupcheck widget dying...')
widget.add_delete_callback(foobar) widget.add_delete_callback(foobar)
_ba.app.uicleanupchecks.append({ _ba.app.uicleanupchecks.append(
'obj': weakref.ref(obj), UICleanupCheck(obj=weakref.ref(obj),
'widget': widget, widget=widget,
'widgetdeathtime': None widget_death_time=None))
})
def upkeep() -> None: def upkeep() -> None:
@ -194,20 +212,22 @@ def upkeep() -> None:
remainingchecks = [] remainingchecks = []
now = _ba.time(TimeType.REAL) now = _ba.time(TimeType.REAL)
for check in app.uicleanupchecks: for check in app.uicleanupchecks:
obj = check['obj']() obj = check.obj()
# If the object has died, ignore and don't re-add. # If the object has died, ignore and don't re-add.
if obj is None: if obj is None:
if DEBUG_UI_CLEANUP_CHECKS:
print('uicleanupcheck object is dead; hooray!')
continue continue
# If the widget hadn't died yet, note if it has. # If the widget hadn't died yet, note if it has.
if check['widgetdeathtime'] is None: if check.widget_death_time is None:
remainingchecks.append(check) remainingchecks.append(check)
if not check['widget']: if not check.widget:
check['widgetdeathtime'] = now check.widget_death_time = now
else: else:
# Widget was already dead; complain if its been too long. # Widget was already dead; complain if its been too long.
if now - check['widgetdeathtime'] > 5.0: if now - check.widget_death_time > 5.0:
print( print(
'WARNING:', obj, 'WARNING:', obj,
'is still alive 5 second after its widget died;' 'is still alive 5 second after its widget died;'

View File

@ -33,7 +33,7 @@ if TYPE_CHECKING:
from typing import Any, Tuple, Optional, Dict from typing import Any, Tuple, Optional, Dict
class AccountLinkWindow(ba.OldWindow): class AccountLinkWindow(ba.Window):
"""Window for linking accounts.""" """Window for linking accounts."""
def __init__(self, origin_widget: ba.Widget = None): def __init__(self, origin_widget: ba.Widget = None):
@ -125,7 +125,7 @@ class AccountLinkWindow(ba.OldWindow):
transition=self._transition_out) transition=self._transition_out)
class AccountLinkCodeWindow(ba.OldWindow): class AccountLinkCodeWindow(ba.Window):
"""Window showing code for account-linking.""" """Window showing code for account-linking."""
def __init__(self, data: Dict[str, Any]): def __init__(self, data: Dict[str, Any]):

View File

@ -33,7 +33,7 @@ if TYPE_CHECKING:
from typing import Optional, Tuple, List, Union from typing import Optional, Tuple, List, Union
class AccountSettingsWindow(ba.OldWindow): class AccountSettingsWindow(ba.Window):
"""Window for account related functionality.""" """Window for account related functionality."""
def __init__(self, def __init__(self,

View File

@ -32,7 +32,7 @@ if TYPE_CHECKING:
from typing import Any, Optional, Tuple, Dict from typing import Any, Optional, Tuple, Dict
class AccountUnlinkWindow(ba.OldWindow): class AccountUnlinkWindow(ba.Window):
"""A window to kick off account unlinks.""" """A window to kick off account unlinks."""
def __init__(self, origin_widget: ba.Widget = None): def __init__(self, origin_widget: ba.Widget = None):

View File

@ -33,7 +33,7 @@ if TYPE_CHECKING:
from typing import Any, Optional, Dict, Union from typing import Any, Optional, Dict, Union
class AppInviteWindow(ba.OldWindow): class AppInviteWindow(ba.Window):
"""Window for showing different ways to invite people to try the game.""" """Window for showing different ways to invite people to try the game."""
def __init__(self) -> None: def __init__(self) -> None:
@ -164,7 +164,7 @@ class AppInviteWindow(ba.OldWindow):
ba.containerwidget(edit=self._root_widget, transition='out_scale') ba.containerwidget(edit=self._root_widget, transition='out_scale')
class ShowFriendCodeWindow(ba.OldWindow): class ShowFriendCodeWindow(ba.Window):
"""Window showing a code for sharing with friends.""" """Window showing a code for sharing with friends."""
def __init__(self, data: Dict[str, Any]): def __init__(self, data: Dict[str, Any]):

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
pass pass
class ConfigErrorWindow(ba.OldWindow): class ConfigErrorWindow(ba.Window):
"""Window for dealing with a broken config.""" """Window for dealing with a broken config."""
def __init__(self) -> None: def __init__(self) -> None:

View File

@ -32,7 +32,7 @@ if TYPE_CHECKING:
from typing import Any, Callable, Optional from typing import Any, Callable, Optional
class ContinuesWindow(ba.OldWindow): class ContinuesWindow(ba.Window):
"""A window to continue a game.""" """A window to continue a game."""
def __init__(self, activity: ba.Activity, cost: int, def __init__(self, activity: ba.Activity, cost: int,

View File

@ -34,7 +34,7 @@ if TYPE_CHECKING:
from typing import Any, Optional, Tuple, Dict, List, Union from typing import Any, Optional, Tuple, Dict, List, Union
class CoopBrowserWindow(ba.OldWindow): class CoopBrowserWindow(ba.Window):
"""Window for browsing co-op levels/games/etc.""" """Window for browsing co-op levels/games/etc."""
def _update_corner_button_positions(self) -> None: def _update_corner_button_positions(self) -> None:

View File

@ -25,7 +25,7 @@ from __future__ import annotations
import ba import ba
class CoopLevelLockedWindow(ba.OldWindow): class CoopLevelLockedWindow(ba.Window):
"""Window showing that a level is locked.""" """Window showing that a level is locked."""
def __init__(self, name: ba.Lstr, dep_name: ba.Lstr): def __init__(self, name: ba.Lstr, dep_name: ba.Lstr):

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
from typing import Tuple, Optional, Sequence from typing import Tuple, Optional, Sequence
class CreditsListWindow(ba.OldWindow): class CreditsListWindow(ba.Window):
"""Window for displaying game credits.""" """Window for displaying game credits."""
def __init__(self, origin_widget: ba.Widget = None): def __init__(self, origin_widget: ba.Widget = None):

View File

@ -30,7 +30,7 @@ if TYPE_CHECKING:
pass pass
class DebugWindow(ba.OldWindow): class DebugWindow(ba.Window):
"""Window for debugging internal values.""" """Window for debugging internal values."""
def __init__(self, transition: str = 'in_right'): def __init__(self, transition: str = 'in_right'):

View File

@ -34,7 +34,7 @@ if TYPE_CHECKING:
from typing import Any, Callable, Sequence, List, Optional from typing import Any, Callable, Sequence, List, Optional
class FileSelectorWindow(ba.OldWindow): class FileSelectorWindow(ba.Window):
"""Window for selecting files.""" """Window for selecting files."""
def __init__(self, def __init__(self,

View File

@ -34,7 +34,7 @@ if TYPE_CHECKING:
from typing import Any, Optional, Tuple, Dict, List, Union, Callable from typing import Any, Optional, Tuple, Dict, List, Union, Callable
class GatherWindow(ba.OldWindow): class GatherWindow(ba.Window):
"""Window for joining/inviting friends.""" """Window for joining/inviting friends."""
def __del__(self) -> None: def __del__(self) -> None:

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
from typing import Any, Optional, Tuple, Union, Dict from typing import Any, Optional, Tuple, Union, Dict
class GetCurrencyWindow(ba.OldWindow): class GetCurrencyWindow(ba.Window):
"""Window for purchasing/acquiring currency.""" """Window for purchasing/acquiring currency."""
def __init__(self, def __init__(self,

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
from typing import Optional, Tuple from typing import Optional, Tuple
class HelpWindow(ba.OldWindow): class HelpWindow(ba.Window):
"""A window providing help on how to play.""" """A window providing help on how to play."""
def __init__(self, def __init__(self,

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
from typing import Optional from typing import Optional
class KioskWindow(ba.OldWindow): class KioskWindow(ba.Window):
"""Kiosk mode window.""" """Kiosk mode window."""
def __init__(self, transition: str = 'in_right'): def __init__(self, transition: str = 'in_right'):

View File

@ -33,7 +33,7 @@ if TYPE_CHECKING:
from typing import Any, Optional, Tuple, List, Dict, Union from typing import Any, Optional, Tuple, List, Dict, Union
class LeagueRankWindow(ba.OldWindow): class LeagueRankWindow(ba.Window):
"""Window for showing league rank.""" """Window for showing league rank."""
def __init__(self, def __init__(self,

View File

@ -32,7 +32,7 @@ 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.OldWindow): 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."""
def __init__(self, transition: str = 'in_right'): def __init__(self, transition: str = 'in_right'):

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
from typing import List, Tuple, Optional from typing import List, Tuple, Optional
class OnScreenKeyboardWindow(ba.OldWindow): class OnScreenKeyboardWindow(ba.Window):
"""Simple built-in on-screen keyboard.""" """Simple built-in on-screen keyboard."""
def __init__(self, textwidget: ba.Widget, label: str, max_chars: int): def __init__(self, textwidget: ba.Widget, label: str, max_chars: int):

View File

@ -34,7 +34,7 @@ if TYPE_CHECKING:
from typing import List, Sequence, Optional, Dict, Any from typing import List, Sequence, Optional, Dict, Any
class PartyWindow(ba.OldWindow): class PartyWindow(ba.Window):
"""Party list/chat window.""" """Party list/chat window."""
def __del__(self) -> None: def __del__(self) -> None:

View File

@ -33,7 +33,7 @@ if TYPE_CHECKING:
from typing import Any, Optional, Sequence, List, Dict from typing import Any, Optional, Sequence, List, Dict
class PartyQueueWindow(ba.OldWindow): class PartyQueueWindow(ba.Window):
"""Window showing players waiting to join a server.""" """Window showing players waiting to join a server."""
# ewww this needs quite a bit of de-linting if/when i revisit it.. # ewww this needs quite a bit of de-linting if/when i revisit it..

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
from typing import Optional, Tuple from typing import Optional, Tuple
class PlayWindow(ba.OldWindow): class PlayWindow(ba.Window):
"""Window for selecting overall play type.""" """Window for selecting overall play type."""
def __init__(self, def __init__(self,

View File

@ -32,7 +32,7 @@ if TYPE_CHECKING:
from bastd.ui.playlist.editcontroller import PlaylistEditController from bastd.ui.playlist.editcontroller import PlaylistEditController
class PlaylistAddGameWindow(ba.OldWindow): class PlaylistAddGameWindow(ba.Window):
"""Window for selecting a game type to add to a playlist.""" """Window for selecting a game type to add to a playlist."""
def __init__(self, def __init__(self,

View File

@ -33,7 +33,7 @@ if TYPE_CHECKING:
from typing import Type, Optional, Tuple, Union from typing import Type, Optional, Tuple, Union
class PlaylistBrowserWindow(ba.OldWindow): class PlaylistBrowserWindow(ba.Window):
"""Window for starting teams games.""" """Window for starting teams games."""
def __init__(self, def __init__(self,

View File

@ -33,7 +33,7 @@ if TYPE_CHECKING:
from typing import Any, Type, Optional, Tuple, List from typing import Any, Type, Optional, Tuple, List
class PlaylistCustomizeBrowserWindow(ba.OldWindow): class PlaylistCustomizeBrowserWindow(ba.Window):
"""Window for viewing a playlist.""" """Window for viewing a playlist."""
def __init__(self, def __init__(self,

View File

@ -32,7 +32,7 @@ if TYPE_CHECKING:
from bastd.ui.playlist.editcontroller import PlaylistEditController from bastd.ui.playlist.editcontroller import PlaylistEditController
class PlaylistEditWindow(ba.OldWindow): class PlaylistEditWindow(ba.Window):
"""Window for editing an individual game playlist.""" """Window for editing an individual game playlist."""
def __init__(self, def __init__(self,

View File

@ -33,7 +33,7 @@ if TYPE_CHECKING:
from typing import Type, Any, Dict, Callable, Optional, Union from typing import Type, Any, Dict, Callable, Optional, Union
class PlaylistEditGameWindow(ba.OldWindow): class PlaylistEditGameWindow(ba.Window):
"""Window for editing a game in a playlist.""" """Window for editing a game in a playlist."""
def __init__(self, def __init__(self,

View File

@ -32,7 +32,7 @@ if TYPE_CHECKING:
from typing import Type, Any, Callable, Dict, List, Tuple, Optional from typing import Type, Any, Callable, Dict, List, Tuple, Optional
class PlaylistMapSelectWindow(ba.OldWindow): class PlaylistMapSelectWindow(ba.Window):
"""Window to select a map.""" """Window to select a map."""
def __init__(self, def __init__(self,

View File

@ -79,7 +79,7 @@ class SharePlaylistImportWindow(promocode.PromoCodeWindow):
ba.screenmessage(ba.Lstr(resource='importingText')) ba.screenmessage(ba.Lstr(resource='importingText'))
class SharePlaylistResultsWindow(ba.OldWindow): class SharePlaylistResultsWindow(ba.Window):
"""Window for sharing playlists.""" """Window for sharing playlists."""
def __init__(self, def __init__(self,

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
from typing import Any, Optional, Tuple, List, Dict from typing import Any, Optional, Tuple, List, Dict
class ProfileBrowserWindow(ba.OldWindow): class ProfileBrowserWindow(ba.Window):
"""Window for browsing player profiles.""" """Window for browsing player profiles."""
def __init__(self, def __init__(self,

View File

@ -33,7 +33,7 @@ if TYPE_CHECKING:
from bastd.ui.colorpicker import ColorPicker from bastd.ui.colorpicker import ColorPicker
class EditProfileWindow(ba.OldWindow): class EditProfileWindow(ba.Window):
"""Window for editing a player profile.""" """Window for editing a player profile."""
# FIXME: WILL NEED TO CHANGE THIS FOR UILOCATION. # FIXME: WILL NEED TO CHANGE THIS FOR UILOCATION.

View File

@ -34,7 +34,7 @@ if TYPE_CHECKING:
from bastd.ui.profile.edit import EditProfileWindow from bastd.ui.profile.edit import EditProfileWindow
class ProfileUpgradeWindow(ba.OldWindow): class ProfileUpgradeWindow(ba.Window):
"""Window for player profile upgrades to global.""" """Window for player profile upgrades to global."""
def __init__(self, def __init__(self,

View File

@ -32,7 +32,7 @@ if TYPE_CHECKING:
from typing import Optional, Tuple from typing import Optional, Tuple
class PromoCodeWindow(ba.OldWindow): class PromoCodeWindow(ba.Window):
"""Window for entering promo codes.""" """Window for entering promo codes."""
def __init__(self, modal: bool = False, origin_widget: ba.Widget = None): def __init__(self, modal: bool = False, origin_widget: ba.Widget = None):

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
from typing import Any, Dict, List, Optional from typing import Any, Dict, List, Optional
class PurchaseWindow(ba.OldWindow): class PurchaseWindow(ba.Window):
"""Window for purchasing one or more items.""" """Window for purchasing one or more items."""
def __init__(self, def __init__(self,

View File

@ -26,7 +26,7 @@ import _ba
import ba import ba
class ReportPlayerWindow(ba.OldWindow): class ReportPlayerWindow(ba.Window):
"""Player for reporting naughty players.""" """Player for reporting naughty players."""
def __init__(self, account_id: str, origin_widget: ba.Widget): def __init__(self, account_id: str, origin_widget: ba.Widget):

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
from typing import Any, Dict, Optional from typing import Any, Dict, Optional
class ServerDialogWindow(ba.OldWindow): class ServerDialogWindow(ba.Window):
"""A dialog window driven by the master-server.""" """A dialog window driven by the master-server."""
def __init__(self, data: Dict[str, Any]): def __init__(self, data: Dict[str, Any]):

View File

@ -32,7 +32,7 @@ if TYPE_CHECKING:
from typing import Tuple, Any, Optional, List, Dict from typing import Tuple, Any, Optional, List, Dict
class AdvancedSettingsWindow(ba.OldWindow): class AdvancedSettingsWindow(ba.Window):
"""Window for editing advanced game settings.""" """Window for editing advanced game settings."""
def __init__(self, def __init__(self,
@ -178,7 +178,7 @@ class AdvancedSettingsWindow(ba.OldWindow):
# pylint: disable=too-many-statements # pylint: disable=too-many-statements
# pylint: disable=too-many-branches # pylint: disable=too-many-branches
# pylint: disable=too-many-locals # pylint: disable=too-many-locals
from bastd.ui import config from bastd.ui.config import ConfigCheckBox
from ba.internal import show_user_scripts from ba.internal import show_user_scripts
# Don't rebuild if the menu is open or if our language and # Don't rebuild if the menu is open or if our language and
@ -348,7 +348,7 @@ class AdvancedSettingsWindow(ba.OldWindow):
v -= self._spacing * 3.0 v -= self._spacing * 3.0
self._kick_idle_players_check_box = config.ConfigCheckBox( self._kick_idle_players_check_box = ConfigCheckBox(
parent=self._subcontainer, parent=self._subcontainer,
position=(50, v), position=(50, v),
size=(self._sub_width - 100, 30), size=(self._sub_width - 100, 30),
@ -357,21 +357,19 @@ class AdvancedSettingsWindow(ba.OldWindow):
scale=1.0, scale=1.0,
maxwidth=430) maxwidth=430)
self._always_use_internal_keyboard_check_box: Optional[ self._always_use_internal_keyboard_check_box: Optional[ConfigCheckBox]
config.ConfigCheckBox]
if self._show_always_use_internal_keyboard: if self._show_always_use_internal_keyboard:
v -= 42 v -= 42
self._always_use_internal_keyboard_check_box = ( self._always_use_internal_keyboard_check_box = ConfigCheckBox(
config.ConfigCheckBox( parent=self._subcontainer,
parent=self._subcontainer, position=(50, v),
position=(50, v), size=(self._sub_width - 100, 30),
size=(self._sub_width - 100, 30), configkey="Always Use Internal Keyboard",
configkey="Always Use Internal Keyboard", autoselect=True,
autoselect=True, displayname=ba.Lstr(resource=self._r +
displayname=ba.Lstr(resource=self._r + '.alwaysUseInternalKeyboardText'),
'.alwaysUseInternalKeyboardText'), scale=1.0,
scale=1.0, maxwidth=430)
maxwidth=430))
ba.textwidget( ba.textwidget(
parent=self._subcontainer, parent=self._subcontainer,
position=(90, v - 10), position=(90, v - 10),
@ -427,18 +425,13 @@ class AdvancedSettingsWindow(ba.OldWindow):
v -= self._spacing * 1.8 v -= self._spacing * 1.8
def doit(val: Any) -> None: self._enable_package_mods_checkbox = ConfigCheckBox(
del val # Unused.
ba.screenmessage(ba.Lstr(resource=self._r + '.mustRestartText'),
color=(1, 1, 0))
self._enable_package_mods_checkbox = config.ConfigCheckBox(
parent=self._subcontainer, parent=self._subcontainer,
position=(80, v), position=(80, v),
size=(self._sub_width - 100, 30), size=(self._sub_width - 100, 30),
configkey="Enable Package Mods", configkey="Enable Package Mods",
autoselect=True, autoselect=True,
value_change_call=doit, value_change_call=ba.WeakCall(self._show_restart_needed),
displayname=ba.Lstr(resource=self._r + '.enablePackageModsText'), displayname=ba.Lstr(resource=self._r + '.enablePackageModsText'),
scale=1.0, scale=1.0,
maxwidth=400) maxwidth=400)
@ -515,6 +508,11 @@ class AdvancedSettingsWindow(ba.OldWindow):
self._restore_state() self._restore_state()
def _show_restart_needed(self, value: Any) -> None:
del value # Unused.
ba.screenmessage(ba.Lstr(resource=self._r + '.mustRestartText'),
color=(1, 1, 0))
def _on_lang_inform_value_change(self, val: bool) -> None: def _on_lang_inform_value_change(self, val: bool) -> None:
_ba.add_transaction({ _ba.add_transaction({
'type': 'SET_MISC_VAL', 'type': 'SET_MISC_VAL',

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
from typing import Tuple, Optional, Union from typing import Tuple, Optional, Union
class AllSettingsWindow(ba.OldWindow): class AllSettingsWindow(ba.Window):
"""Window for selecting a settings category.""" """Window for selecting a settings category."""
def __init__(self, def __init__(self,

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
from typing import Tuple, Optional from typing import Tuple, Optional
class AudioSettingsWindow(ba.OldWindow): class AudioSettingsWindow(ba.Window):
"""Window for editing audio settings.""" """Window for editing audio settings."""
def __init__(self, def __init__(self,

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
from typing import Tuple, Optional from typing import Tuple, Optional
class ControlsSettingsWindow(ba.OldWindow): class ControlsSettingsWindow(ba.Window):
"""Top level control settings window.""" """Top level control settings window."""
def __init__(self, def __init__(self,

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
from typing import Dict, Any, Optional, Union, Tuple, Callable from typing import Dict, Any, Optional, Union, Tuple, Callable
class GamepadSettingsWindow(ba.OldWindow): class GamepadSettingsWindow(ba.Window):
"""Window for configuring a gamepad.""" """Window for configuring a gamepad."""
def __init__(self, def __init__(self,
@ -765,7 +765,7 @@ class GamepadSettingsWindow(ba.OldWindow):
transition='in_left').get_root_widget()) transition='in_left').get_root_widget())
class AwaitGamepadInputWindow(ba.OldWindow): class AwaitGamepadInputWindow(ba.Window):
"""Window for capturing a gamepad button press.""" """Window for capturing a gamepad button press."""
def __init__( def __init__(

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
from bastd.ui.settings import gamepad as gpsui from bastd.ui.settings import gamepad as gpsui
class GamepadAdvancedSettingsWindow(ba.OldWindow): class GamepadAdvancedSettingsWindow(ba.Window):
"""Window for advanced gamepad configuration.""" """Window for advanced gamepad configuration."""
def __init__(self, parent_window: gpsui.GamepadSettingsWindow): def __init__(self, parent_window: gpsui.GamepadSettingsWindow):

View File

@ -84,7 +84,7 @@ def gamepad_configure_callback(event: Dict[str, Any]) -> None:
on_activate_call=_ok) on_activate_call=_ok)
class GamepadSelectWindow(ba.OldWindow): class GamepadSelectWindow(ba.Window):
"""Window for selecting a gamepad to configure.""" """Window for selecting a gamepad to configure."""
def __init__(self) -> None: def __init__(self) -> None:

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
from typing import Tuple, Optional from typing import Tuple, Optional
class GraphicsSettingsWindow(ba.OldWindow): class GraphicsSettingsWindow(ba.Window):
"""Window for graphics settings.""" """Window for graphics settings."""
def __init__(self, def __init__(self,
@ -41,7 +41,7 @@ class GraphicsSettingsWindow(ba.OldWindow):
# pylint: disable=too-many-branches # pylint: disable=too-many-branches
# pylint: disable=too-many-statements # pylint: disable=too-many-statements
from bastd.ui import popup from bastd.ui import popup
from bastd.ui import config as cfgui from bastd.ui.config import ConfigCheckBox, ConfigNumberEdit
# if they provided an origin-widget, scale up from that # if they provided an origin-widget, scale up from that
scale_origin: Optional[Tuple[float, float]] scale_origin: Optional[Tuple[float, float]]
if origin_widget is not None: if origin_widget is not None:
@ -123,7 +123,7 @@ class GraphicsSettingsWindow(ba.OldWindow):
self._fullscreen_checkbox: Optional[ba.Widget] self._fullscreen_checkbox: Optional[ba.Widget]
if self._show_fullscreen: if self._show_fullscreen:
v -= fullscreen_spacing_top v -= fullscreen_spacing_top
self._fullscreen_checkbox = cfgui.ConfigCheckBox( self._fullscreen_checkbox = ConfigCheckBox(
parent=self._root_widget, parent=self._root_widget,
position=(100, v), position=(100, v),
maxwidth=200, maxwidth=200,
@ -140,9 +140,9 @@ class GraphicsSettingsWindow(ba.OldWindow):
else: else:
self._fullscreen_checkbox = None self._fullscreen_checkbox = None
self._gamma_controls: Optional[cfgui.ConfigNumberEdit] self._gamma_controls: Optional[ConfigNumberEdit]
if show_gamma: if show_gamma:
self._gamma_controls = gmc = cfgui.ConfigNumberEdit( self._gamma_controls = gmc = ConfigNumberEdit(
parent=self._root_widget, parent=self._root_widget,
position=(90, v), position=(90, v),
configkey="Screen Gamma", configkey="Screen Gamma",
@ -325,25 +325,25 @@ class GraphicsSettingsWindow(ba.OldWindow):
on_value_change_call=self._set_vsync) on_value_change_call=self._set_vsync)
v -= 90 v -= 90
fpsc = cfgui.ConfigCheckBox(parent=self._root_widget, fpsc = ConfigCheckBox(parent=self._root_widget,
position=(69, v - 6), position=(69, v - 6),
size=(210, 30), size=(210, 30),
scale=0.86, scale=0.86,
configkey="Show FPS", configkey="Show FPS",
displayname=ba.Lstr(resource=self._r + displayname=ba.Lstr(resource=self._r +
'.showFPSText'), '.showFPSText'),
maxwidth=130) maxwidth=130)
# (tv mode doesnt apply to vr) # (tv mode doesnt apply to vr)
if not ba.app.vr_mode: if not ba.app.vr_mode:
tvc = cfgui.ConfigCheckBox(parent=self._root_widget, tvc = ConfigCheckBox(parent=self._root_widget,
position=(240, v - 6), position=(240, v - 6),
size=(210, 30), size=(210, 30),
scale=0.86, scale=0.86,
configkey="TV Border", configkey="TV Border",
displayname=ba.Lstr(resource=self._r + displayname=ba.Lstr(resource=self._r +
'.tvBorderText'), '.tvBorderText'),
maxwidth=130) maxwidth=130)
# grumble.. # grumble..
ba.widget(edit=fpsc.widget, right_widget=tvc.widget) ba.widget(edit=fpsc.widget, right_widget=tvc.widget)
try: try:

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
from typing import Dict, Tuple, Any, Optional from typing import Dict, Tuple, Any, Optional
class ConfigKeyboardWindow(ba.OldWindow): class ConfigKeyboardWindow(ba.Window):
"""Window for configuring keyboards.""" """Window for configuring keyboards."""
def __init__(self, c: ba.InputDevice, transition: str = 'in_right'): def __init__(self, c: ba.InputDevice, transition: str = 'in_right'):
@ -258,7 +258,7 @@ class ConfigKeyboardWindow(ba.OldWindow):
transition='in_left').get_root_widget()) transition='in_left').get_root_widget())
class AwaitKeyboardInputWindow(ba.OldWindow): class AwaitKeyboardInputWindow(ba.Window):
"""Window for capturing a keypress.""" """Window for capturing a keypress."""
def __init__(self, button: str, ui: ba.Widget, settings: Dict[str, Any]): def __init__(self, button: str, ui: ba.Widget, settings: Dict[str, Any]):

View File

@ -26,7 +26,7 @@ import _ba
import ba import ba
class PS3ControllerSettingsWindow(ba.OldWindow): class PS3ControllerSettingsWindow(ba.Window):
"""UI showing info about using PS3 controllers.""" """UI showing info about using PS3 controllers."""
def __init__(self) -> None: def __init__(self) -> None:

View File

@ -25,7 +25,7 @@ from __future__ import annotations
import ba import ba
class RemoteAppSettingsWindow(ba.OldWindow): class RemoteAppSettingsWindow(ba.Window):
"""Window showing info/settings related to the remote app.""" """Window showing info/settings related to the remote app."""
def __init__(self) -> None: def __init__(self) -> None:

View File

@ -32,7 +32,7 @@ if TYPE_CHECKING:
from typing import Any, Dict, List from typing import Any, Dict, List
class TestingWindow(ba.OldWindow): class TestingWindow(ba.Window):
"""Window for conveniently testing various settings.""" """Window for conveniently testing various settings."""
def __init__(self, def __init__(self,

View File

@ -25,7 +25,7 @@ import _ba
import ba import ba
class TouchscreenSettingsWindow(ba.OldWindow): class TouchscreenSettingsWindow(ba.Window):
"""Settings window for touchscreens.""" """Settings window for touchscreens."""
def __del__(self) -> None: def __del__(self) -> None:

View File

@ -25,7 +25,7 @@ import _ba
import ba import ba
class WiimoteSettingsWindow(ba.OldWindow): class WiimoteSettingsWindow(ba.Window):
"""Window for setting up Wiimotes.""" """Window for setting up Wiimotes."""
def __init__(self) -> None: def __init__(self) -> None:
@ -112,7 +112,7 @@ class WiimoteSettingsWindow(ba.OldWindow):
transition='in_left').get_root_widget()) transition='in_left').get_root_widget())
class WiimoteListenWindow(ba.OldWindow): class WiimoteListenWindow(ba.Window):
"""Window shown while listening for a wiimote connection.""" """Window shown while listening for a wiimote connection."""
def __init__(self) -> None: def __init__(self) -> None:
@ -181,7 +181,7 @@ class WiimoteListenWindow(ba.OldWindow):
_ba.stop_listening_for_wii_remotes() _ba.stop_listening_for_wii_remotes()
class WiimoteLicenseWindow(ba.OldWindow): class WiimoteLicenseWindow(ba.Window):
"""Window displaying the Darwiinremote software license.""" """Window displaying the Darwiinremote software license."""
def __init__(self) -> None: def __init__(self) -> None:

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
pass pass
class XBox360ControllerSettingsWindow(ba.OldWindow): class XBox360ControllerSettingsWindow(ba.Window):
"""UI showing info about xbox 360 controllers.""" """UI showing info about xbox 360 controllers."""
def __init__(self) -> None: def __init__(self) -> None:

View File

@ -32,7 +32,7 @@ if TYPE_CHECKING:
from typing import Any, Optional, List, Tuple, Dict from typing import Any, Optional, List, Tuple, Dict
class SoundtrackBrowserWindow(ba.OldWindow): class SoundtrackBrowserWindow(ba.Window):
"""Window for browsing soundtracks.""" """Window for browsing soundtracks."""
def __init__(self, def __init__(self,

View File

@ -32,7 +32,7 @@ if TYPE_CHECKING:
from typing import Any, Dict, Union, Optional from typing import Any, Dict, Union, Optional
class SoundtrackEditWindow(ba.OldWindow): class SoundtrackEditWindow(ba.Window):
"""Window for editing a soundtrack.""" """Window for editing a soundtrack."""
def __init__(self, def __init__(self,

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
from typing import Any, Callable, Optional from typing import Any, Callable, Optional
class SoundtrackEntryTypeSelectWindow(ba.OldWindow): class SoundtrackEntryTypeSelectWindow(ba.Window):
"""Window for selecting a soundtrack entry type.""" """Window for selecting a soundtrack entry type."""
def __init__(self, def __init__(self,

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
from typing import Any, List, Optional, Callable from typing import Any, List, Optional, Callable
class MacMusicAppPlaylistSelectWindow(ba.OldWindow): class MacMusicAppPlaylistSelectWindow(ba.Window):
"""Window for selecting an iTunes playlist.""" """Window for selecting an iTunes playlist."""
def __init__(self, callback: Callable[[Any], Any], def __init__(self, callback: Callable[[Any], Any],

View File

@ -32,7 +32,7 @@ if TYPE_CHECKING:
from typing import Any, Dict, Optional, Union from typing import Any, Dict, Optional, Union
class SpecialOfferWindow(ba.OldWindow): class SpecialOfferWindow(ba.Window):
"""Window for presenting sales/etc.""" """Window for presenting sales/etc."""
def __init__(self, offer: Dict[str, Any], transition: str = 'in_right'): def __init__(self, offer: Dict[str, Any], transition: str = 'in_right'):

View File

@ -34,7 +34,7 @@ if TYPE_CHECKING:
from typing import Any, Callable, Optional, Tuple, Dict, Union, Sequence from typing import Any, Callable, Optional, Tuple, Dict, Union, Sequence
class StoreBrowserWindow(ba.OldWindow): class StoreBrowserWindow(ba.Window):
"""Window for browsing the store.""" """Window for browsing the store."""
def _update_get_tickets_button_pos(self) -> None: def _update_get_tickets_button_pos(self) -> None:

View File

@ -26,7 +26,7 @@ import _ba
import ba import ba
class TelnetAccessRequestWindow(ba.OldWindow): class TelnetAccessRequestWindow(ba.Window):
"""Window asking the user whether to allow a telnet connection.""" """Window asking the user whether to allow a telnet connection."""
def __init__(self) -> None: def __init__(self) -> None:

View File

@ -26,7 +26,7 @@ import _ba
import ba import ba
class ShowURLWindow(ba.OldWindow): class ShowURLWindow(ba.Window):
"""A window presenting a URL to the user visually.""" """A window presenting a URL to the user visually."""
def __init__(self, address: str): def __init__(self, address: str):

View File

@ -32,7 +32,7 @@ if TYPE_CHECKING:
from typing import Any, Optional, Tuple, Dict from typing import Any, Optional, Tuple, Dict
class WatchWindow(ba.OldWindow): class WatchWindow(ba.Window):
"""Window for watching replays.""" """Window for watching replays."""
def __init__(self, def __init__(self,

View File

@ -1,5 +1,5 @@
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND --> <!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
<h4><em>last updated on 2020-04-04 for Ballistica version 1.5.0 build 20001</em></h4> <h4><em>last updated on 2020-04-05 for Ballistica version 1.5.0 build 20001</em></h4>
<p>This page documents the Python classes and functions in the 'ba' module, <p>This page documents the Python classes and functions in the 'ba' module,
which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p> which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p>
<hr> <hr>
@ -138,13 +138,13 @@
</ul> </ul>
<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_OldWindow">ba.OldWindow</a></li>
<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> <li><a href="#class_ba_UILocation">ba.UILocation</a></li>
<ul> <ul>
<li><a href="#class_ba_UILocationWindow">ba.UILocationWindow</a></li> <li><a href="#class_ba_UILocationWindow">ba.UILocationWindow</a></li>
</ul> </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>
</ul> </ul>
<h4><a name="function_category_User_Interface_Functions">User Interface Functions</a></h4> <h4><a name="function_category_User_Interface_Functions">User Interface Functions</a></h4>
<ul> <ul>
@ -3338,29 +3338,6 @@ acting as an alternative to setting node attributes.</p>
<h3>Methods:</h3> <h3>Methods:</h3>
<p>&lt;all methods inherited from <a href="#class_builtins_Exception">builtins.Exception</a>&gt;</p> <p>&lt;all methods inherited from <a href="#class_builtins_Exception">builtins.Exception</a>&gt;</p>
<hr> <hr>
<h2><strong><a name="class_ba_OldWindow">ba.OldWindow</a></strong></h3>
<p><em>&lt;top level class&gt;</em>
</p>
<p>Temp for transitioning windows over to UILocationWindows.</p>
<p>Category: <a href="#class_category_User_Interface_Classes">User Interface Classes</a>
</p>
<h3>Methods:</h3>
<h5><a href="#method_ba_OldWindow____init__">&lt;constructor&gt;</a>, <a href="#method_ba_OldWindow__get_root_widget">get_root_widget()</a></h5>
<dl>
<dt><h4><a name="method_ba_OldWindow____init__">&lt;constructor&gt;</a></dt></h4><dd>
<p><span>ba.OldWindow(root_widget: <a href="#class_ba_Widget">ba.Widget</a>)</span></p>
</dd>
<dt><h4><a name="method_ba_OldWindow__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.</p>
</dd>
</dl>
<hr>
<h2><strong><a name="class_ba_OutOfBoundsMessage">ba.OutOfBoundsMessage</a></strong></h3> <h2><strong><a name="class_ba_OutOfBoundsMessage">ba.OutOfBoundsMessage</a></strong></h3>
<p><em>&lt;top level class&gt;</em> <p><em>&lt;top level class&gt;</em>
</p> </p>
@ -4999,6 +4976,29 @@ widgets.</p>
<h3>Methods:</h3> <h3>Methods:</h3>
<p>&lt;all methods inherited from <a href="#class_ba_NotFoundError">ba.NotFoundError</a>&gt;</p> <p>&lt;all methods inherited from <a href="#class_ba_NotFoundError">ba.NotFoundError</a>&gt;</p>
<hr> <hr>
<h2><strong><a name="class_ba_Window">ba.Window</a></strong></h3>
<p><em>&lt;top level class&gt;</em>
</p>
<p>A basic window.</p>
<p>Category: <a href="#class_category_User_Interface_Classes">User Interface Classes</a>
</p>
<h3>Methods:</h3>
<h5><a href="#method_ba_Window____init__">&lt;constructor&gt;</a>, <a href="#method_ba_Window__get_root_widget">get_root_widget()</a></h5>
<dl>
<dt><h4><a name="method_ba_Window____init__">&lt;constructor&gt;</a></dt></h4><dd>
<p><span>ba.Window(root_widget: <a href="#class_ba_Widget">ba.Widget</a>)</span></p>
</dd>
<dt><h4><a name="method_ba_Window__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.</p>
</dd>
</dl>
<hr>
<h2><strong><a name="function_ba_animate">ba.animate()</a></strong></h3> <h2><strong><a name="function_ba_animate">ba.animate()</a></strong></h3>
<p><span>animate(node: <a href="#class_ba_Node">ba.Node</a>, attr: str, keys: Dict[float, float], loop: bool = False, offset: float = 0, timetype: <a href="#class_ba_TimeType">ba.TimeType</a> = &lt;TimeType.SIM: 0&gt;, timeformat: <a href="#class_ba_TimeFormat">ba.TimeFormat</a> = &lt;TimeFormat.SECONDS: 0&gt;, suppress_format_warning: bool = False) -&gt; <a href="#class_ba_Node">ba.Node</a></span></p> <p><span>animate(node: <a href="#class_ba_Node">ba.Node</a>, attr: str, keys: Dict[float, float], loop: bool = False, offset: float = 0, timetype: <a href="#class_ba_TimeType">ba.TimeType</a> = &lt;TimeType.SIM: 0&gt;, timeformat: <a href="#class_ba_TimeFormat">ba.TimeFormat</a> = &lt;TimeFormat.SECONDS: 0&gt;, suppress_format_warning: bool = False) -&gt; <a href="#class_ba_Node">ba.Node</a></span></p>