mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-02-05 15:03:33 +08:00
Merge pull request #42 from Dliwk/pr42
Exceptions cleanup and fix FFA spawn
This commit is contained in:
commit
354ba3e997
@ -83,7 +83,7 @@ def get_league_rank_points(data: Optional[Dict[str, Any]],
|
|||||||
assert isinstance(trophies_total, int)
|
assert isinstance(trophies_total, int)
|
||||||
return trophies_total
|
return trophies_total
|
||||||
if subset is not None:
|
if subset is not None:
|
||||||
raise Exception('invalid subset value: ' + str(subset))
|
raise ValueError('invalid subset value: ' + str(subset))
|
||||||
|
|
||||||
if data['p']:
|
if data['p']:
|
||||||
pro_mult = 1.0 + float(
|
pro_mult = 1.0 + float(
|
||||||
|
|||||||
@ -140,7 +140,7 @@ def get_achievement(name: str) -> Achievement:
|
|||||||
achs = [a for a in _ba.app.achievements if a.name == name]
|
achs = [a for a in _ba.app.achievements if a.name == name]
|
||||||
assert len(achs) < 2
|
assert len(achs) < 2
|
||||||
if not achs:
|
if not achs:
|
||||||
raise Exception("Invalid achievement name: '" + name + "'")
|
raise ValueError("Invalid achievement name: '" + name + "'")
|
||||||
return achs[0]
|
return achs[0]
|
||||||
|
|
||||||
|
|
||||||
@ -396,7 +396,7 @@ class Achievement:
|
|||||||
v_attach = Text.VAttach.TOP
|
v_attach = Text.VAttach.TOP
|
||||||
attach = Image.Attach.TOP_CENTER
|
attach = Image.Attach.TOP_CENTER
|
||||||
else:
|
else:
|
||||||
raise Exception('invalid style "' + style + '"')
|
raise ValueError('invalid style "' + style + '"')
|
||||||
|
|
||||||
# Attempt to determine what campaign we're in
|
# Attempt to determine what campaign we're in
|
||||||
# (so we know whether to show "hard mode only").
|
# (so we know whether to show "hard mode only").
|
||||||
|
|||||||
@ -166,14 +166,14 @@ class Activity(DependencyComponent, Generic[PlayerType, TeamType]):
|
|||||||
|
|
||||||
session = _ba.getsession()
|
session = _ba.getsession()
|
||||||
if session is None:
|
if session is None:
|
||||||
raise Exception('No current session')
|
raise RuntimeError('No current session')
|
||||||
self._session = weakref.ref(session)
|
self._session = weakref.ref(session)
|
||||||
|
|
||||||
# Preloaded data for actors, maps, etc; indexed by type.
|
# Preloaded data for actors, maps, etc; indexed by type.
|
||||||
self.preloads: Dict[Type, Any] = {}
|
self.preloads: Dict[Type, Any] = {}
|
||||||
|
|
||||||
if not isinstance(settings, dict):
|
if not isinstance(settings, dict):
|
||||||
raise Exception('expected dict for settings')
|
raise TypeError('expected dict for settings')
|
||||||
if _ba.getactivity(doraise=False) is not self:
|
if _ba.getactivity(doraise=False) is not self:
|
||||||
raise Exception('invalid context state')
|
raise Exception('invalid context state')
|
||||||
|
|
||||||
@ -292,8 +292,8 @@ class Activity(DependencyComponent, Generic[PlayerType, TeamType]):
|
|||||||
(internal)
|
(internal)
|
||||||
"""
|
"""
|
||||||
if self.has_begun():
|
if self.has_begun():
|
||||||
raise Exception('This should only be called for Activities'
|
raise RuntimeError('This should only be called for Activities'
|
||||||
'that have not yet begun.')
|
'that have not yet begun.')
|
||||||
if not self._should_end_immediately or force:
|
if not self._should_end_immediately or force:
|
||||||
self._should_end_immediately = True
|
self._should_end_immediately = True
|
||||||
self._should_end_immediately_results = results
|
self._should_end_immediately_results = results
|
||||||
@ -340,7 +340,7 @@ class Activity(DependencyComponent, Generic[PlayerType, TeamType]):
|
|||||||
"""
|
"""
|
||||||
from ba import _actor as bsactor
|
from ba import _actor as bsactor
|
||||||
if not isinstance(actor, bsactor.Actor):
|
if not isinstance(actor, bsactor.Actor):
|
||||||
raise Exception('non-actor passed to _retain_actor')
|
raise TypeError('non-actor passed to retain_actor')
|
||||||
if (self.has_transitioned_in()
|
if (self.has_transitioned_in()
|
||||||
and _ba.time() - self._last_prune_dead_actors_time > 10.0):
|
and _ba.time() - self._last_prune_dead_actors_time > 10.0):
|
||||||
print_error('it looks like nodes/actors are not'
|
print_error('it looks like nodes/actors are not'
|
||||||
@ -356,7 +356,7 @@ class Activity(DependencyComponent, Generic[PlayerType, TeamType]):
|
|||||||
"""
|
"""
|
||||||
from ba import _actor as bsactor
|
from ba import _actor as bsactor
|
||||||
if not isinstance(actor, bsactor.Actor):
|
if not isinstance(actor, bsactor.Actor):
|
||||||
raise Exception('non-actor passed to _add_actor_weak_ref')
|
raise TypeError('non-actor passed to add_actor_weak_ref')
|
||||||
if (self.has_transitioned_in()
|
if (self.has_transitioned_in()
|
||||||
and _ba.time() - self._last_prune_dead_actors_time > 10.0):
|
and _ba.time() - self._last_prune_dead_actors_time > 10.0):
|
||||||
print_error('it looks like nodes/actors are '
|
print_error('it looks like nodes/actors are '
|
||||||
|
|||||||
@ -729,7 +729,7 @@ class App:
|
|||||||
if args is None:
|
if args is None:
|
||||||
args = {}
|
args = {}
|
||||||
if game == '':
|
if game == '':
|
||||||
raise Exception('empty game name')
|
raise ValueError('empty game name')
|
||||||
campaignname, levelname = game.split(':')
|
campaignname, levelname = game.split(':')
|
||||||
campaign = get_campaign(campaignname)
|
campaign = get_campaign(campaignname)
|
||||||
levels = campaign.get_levels()
|
levels = campaign.get_levels()
|
||||||
|
|||||||
@ -64,7 +64,7 @@ class Campaign:
|
|||||||
def add_level(self, level: ba.Level) -> None:
|
def add_level(self, level: ba.Level) -> None:
|
||||||
"""Adds a ba.Level to the Campaign."""
|
"""Adds a ba.Level to the Campaign."""
|
||||||
if level.get_campaign() is not None:
|
if level.get_campaign() is not None:
|
||||||
raise Exception('level already belongs to a campaign')
|
raise RuntimeError('level already belongs to a campaign')
|
||||||
level.set_campaign(self, len(self._levels))
|
level.set_campaign(self, len(self._levels))
|
||||||
self._levels.append(level)
|
self._levels.append(level)
|
||||||
|
|
||||||
@ -74,11 +74,13 @@ class Campaign:
|
|||||||
|
|
||||||
def get_level(self, name: str) -> ba.Level:
|
def get_level(self, name: str) -> ba.Level:
|
||||||
"""Return a contained ba.Level by name."""
|
"""Return a contained ba.Level by name."""
|
||||||
|
from ba import _error
|
||||||
for level in self._levels:
|
for level in self._levels:
|
||||||
if level.name == name:
|
if level.name == name:
|
||||||
return level
|
return level
|
||||||
raise Exception("Level '" + name + "' not found in campaign '" +
|
raise _error.NotFoundError("Level '" + name +
|
||||||
self.name + "'")
|
"' not found in campaign '" + self.name +
|
||||||
|
"'")
|
||||||
|
|
||||||
def reset(self) -> None:
|
def reset(self) -> None:
|
||||||
"""Reset state for the Campaign."""
|
"""Reset state for the Campaign."""
|
||||||
|
|||||||
@ -292,7 +292,7 @@ class CoopSession(Session):
|
|||||||
and self.campaign_state['level'] == 'Onslaught Training'
|
and self.campaign_state['level'] == 'Onslaught Training'
|
||||||
and not app.kiosk_mode):
|
and not app.kiosk_mode):
|
||||||
if self._tutorial_activity is None:
|
if self._tutorial_activity is None:
|
||||||
raise Exception('tutorial not preloaded properly')
|
raise RuntimeError('tutorial not preloaded properly')
|
||||||
self.set_activity(self._tutorial_activity)
|
self.set_activity(self._tutorial_activity)
|
||||||
self._tutorial_activity = None
|
self._tutorial_activity = None
|
||||||
self._ran_tutorial_activity = True
|
self._ran_tutorial_activity = True
|
||||||
|
|||||||
@ -283,7 +283,7 @@ class DependencySet(Generic[T]):
|
|||||||
|
|
||||||
# Watch for wacky infinite dep loops.
|
# Watch for wacky infinite dep loops.
|
||||||
if recursion > 10:
|
if recursion > 10:
|
||||||
raise Exception('Max recursion reached')
|
raise RecursionError('Max recursion reached')
|
||||||
|
|
||||||
hashval = dep.get_hash()
|
hashval = dep.get_hash()
|
||||||
|
|
||||||
|
|||||||
@ -140,7 +140,7 @@ def print_exception(*args: Any, **keywds: Any) -> None:
|
|||||||
if keywds:
|
if keywds:
|
||||||
allowed_keywds = ['once']
|
allowed_keywds = ['once']
|
||||||
if any(keywd not in allowed_keywds for keywd in keywds):
|
if any(keywd not in allowed_keywds for keywd in keywds):
|
||||||
raise Exception('invalid keyword(s)')
|
raise TypeError('invalid keyword(s)')
|
||||||
try:
|
try:
|
||||||
# If we're only printing once and already have, bail.
|
# If we're only printing once and already have, bail.
|
||||||
if keywds.get('once', False):
|
if keywds.get('once', False):
|
||||||
|
|||||||
@ -693,7 +693,7 @@ class GameActivity(Activity[PlayerType, TeamType]):
|
|||||||
else:
|
else:
|
||||||
sb_desc_l = sb_desc_in
|
sb_desc_l = sb_desc_in
|
||||||
if not isinstance(sb_desc_l[0], str):
|
if not isinstance(sb_desc_l[0], str):
|
||||||
raise Exception('Invalid format for instance description')
|
raise TypeError('Invalid format for instance description')
|
||||||
|
|
||||||
is_empty = (sb_desc_l[0] == '')
|
is_empty = (sb_desc_l[0] == '')
|
||||||
subs = []
|
subs = []
|
||||||
@ -781,7 +781,7 @@ class GameActivity(Activity[PlayerType, TeamType]):
|
|||||||
else:
|
else:
|
||||||
desc_l = desc_in
|
desc_l = desc_in
|
||||||
if not isinstance(desc_l[0], str):
|
if not isinstance(desc_l[0], str):
|
||||||
raise Exception('Invalid format for instance description')
|
raise TypeError('Invalid format for instance description')
|
||||||
subs = []
|
subs = []
|
||||||
for i in range(len(desc_l) - 1):
|
for i in range(len(desc_l) - 1):
|
||||||
subs.append(('${ARG' + str(i + 1) + '}', str(desc_l[i + 1])))
|
subs.append(('${ARG' + str(i + 1) + '}', str(desc_l[i + 1])))
|
||||||
@ -965,7 +965,7 @@ class GameActivity(Activity[PlayerType, TeamType]):
|
|||||||
The default implementation simply calls spawn_player_spaz().
|
The default implementation simply calls spawn_player_spaz().
|
||||||
"""
|
"""
|
||||||
if not player:
|
if not player:
|
||||||
raise Exception('spawn_player() called for nonexistent player')
|
raise TypeError('spawn_player() called for nonexistent player')
|
||||||
|
|
||||||
return self.spawn_player_spaz(player)
|
return self.spawn_player_spaz(player)
|
||||||
|
|
||||||
|
|||||||
@ -137,7 +137,7 @@ def sharedobj(name: str) -> Any:
|
|||||||
True), ('modify_part_collision',
|
True), ('modify_part_collision',
|
||||||
'friction', 0.0)))
|
'friction', 0.0)))
|
||||||
else:
|
else:
|
||||||
raise Exception(
|
raise ValueError(
|
||||||
"unrecognized shared object (activity context): '" + name +
|
"unrecognized shared object (activity context): '" + name +
|
||||||
"'")
|
"'")
|
||||||
else:
|
else:
|
||||||
@ -156,10 +156,10 @@ def sharedobj(name: str) -> Any:
|
|||||||
if name == 'globals':
|
if name == 'globals':
|
||||||
obj = _ba.newnode('sessionglobals')
|
obj = _ba.newnode('sessionglobals')
|
||||||
else:
|
else:
|
||||||
raise Exception('unrecognized shared object '
|
raise ValueError('unrecognized shared object '
|
||||||
"(session context): '" + name + "'")
|
"(session context): '" + name + "'")
|
||||||
else:
|
else:
|
||||||
raise Exception('no current activity or session context')
|
raise RuntimeError('no current activity or session context')
|
||||||
|
|
||||||
# Ok, got a shiny new shared obj; store it for quick access next time.
|
# Ok, got a shiny new shared obj; store it for quick access next time.
|
||||||
sharedobjs[name] = obj
|
sharedobjs[name] = obj
|
||||||
@ -208,7 +208,7 @@ def animate(node: ba.Node,
|
|||||||
elif timeformat is TimeFormat.MILLISECONDS:
|
elif timeformat is TimeFormat.MILLISECONDS:
|
||||||
mult = 1
|
mult = 1
|
||||||
else:
|
else:
|
||||||
raise Exception(f'invalid timeformat value: {timeformat}')
|
raise ValueError(f'invalid timeformat value: {timeformat}')
|
||||||
|
|
||||||
curve.times = [int(mult * time) for time, val in items]
|
curve.times = [int(mult * time) for time, val in items]
|
||||||
curve.offset = _ba.time(timeformat=TimeFormat.MILLISECONDS) + int(
|
curve.offset = _ba.time(timeformat=TimeFormat.MILLISECONDS) + int(
|
||||||
@ -269,7 +269,7 @@ def animate_array(node: ba.Node,
|
|||||||
elif timeformat is TimeFormat.MILLISECONDS:
|
elif timeformat is TimeFormat.MILLISECONDS:
|
||||||
mult = 1
|
mult = 1
|
||||||
else:
|
else:
|
||||||
raise Exception('invalid timeformat value: "' + str(timeformat) + '"')
|
raise ValueError('invalid timeformat value: "' + str(timeformat) + '"')
|
||||||
|
|
||||||
for i in range(size):
|
for i in range(size):
|
||||||
curve = _ba.newnode('animcurve',
|
curve = _ba.newnode('animcurve',
|
||||||
@ -390,7 +390,7 @@ def timestring(timeval: float,
|
|||||||
elif timeformat is TimeFormat.MILLISECONDS:
|
elif timeformat is TimeFormat.MILLISECONDS:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise Exception(f'invalid timeformat: {timeformat}')
|
raise ValueError(f'invalid timeformat: {timeformat}')
|
||||||
if not isinstance(timeval, int):
|
if not isinstance(timeval, int):
|
||||||
timeval = int(timeval)
|
timeval = int(timeval)
|
||||||
bits = []
|
bits = []
|
||||||
|
|||||||
@ -111,7 +111,7 @@ class Lstr:
|
|||||||
"""
|
"""
|
||||||
# pylint: disable=too-many-branches
|
# pylint: disable=too-many-branches
|
||||||
if args:
|
if args:
|
||||||
raise Exception('Lstr accepts only keyword arguments')
|
raise TypeError('Lstr accepts only keyword arguments')
|
||||||
|
|
||||||
# Basically just store the exact args they passed.
|
# Basically just store the exact args they passed.
|
||||||
# However if they passed any Lstr values for subs,
|
# However if they passed any Lstr values for subs,
|
||||||
@ -120,7 +120,7 @@ class Lstr:
|
|||||||
our_type = type(self)
|
our_type = type(self)
|
||||||
|
|
||||||
if isinstance(self.args.get('value'), our_type):
|
if isinstance(self.args.get('value'), our_type):
|
||||||
raise Exception("'value' must be a regular string; not an Lstr")
|
raise TypeError("'value' must be a regular string; not an Lstr")
|
||||||
|
|
||||||
if 'subs' in self.args:
|
if 'subs' in self.args:
|
||||||
subs_new = []
|
subs_new = []
|
||||||
@ -301,7 +301,7 @@ def _add_to_attr_dict(dst: AttrDict, src: Dict) -> None:
|
|||||||
_add_to_attr_dict(dst_dict, value)
|
_add_to_attr_dict(dst_dict, value)
|
||||||
else:
|
else:
|
||||||
if not isinstance(value, (float, int, bool, str, str, type(None))):
|
if not isinstance(value, (float, int, bool, str, str, type(None))):
|
||||||
raise Exception("invalid value type for res '" + key + "': " +
|
raise TypeError("invalid value type for res '" + key + "': " +
|
||||||
str(type(value)))
|
str(type(value)))
|
||||||
dst[key] = value
|
dst[key] = value
|
||||||
|
|
||||||
@ -401,9 +401,10 @@ def get_resource(resource: str,
|
|||||||
# Ok, looks like we couldn't find our main or fallback resource
|
# Ok, looks like we couldn't find our main or fallback resource
|
||||||
# anywhere. Now if we've been given a fallback value, return it;
|
# anywhere. Now if we've been given a fallback value, return it;
|
||||||
# otherwise fail.
|
# otherwise fail.
|
||||||
|
from ba import _error
|
||||||
if fallback_value is not None:
|
if fallback_value is not None:
|
||||||
return fallback_value
|
return fallback_value
|
||||||
raise Exception("resource not found: '" + resource + "'")
|
raise _error.NotFoundError("resource not found: '" + resource + "'")
|
||||||
|
|
||||||
|
|
||||||
def translate(category: str,
|
def translate(category: str,
|
||||||
@ -466,5 +467,5 @@ def is_custom_unicode_char(char: str) -> bool:
|
|||||||
"""Return whether a char is in the custom unicode range we use."""
|
"""Return whether a char is in the custom unicode range we use."""
|
||||||
assert isinstance(char, str)
|
assert isinstance(char, str)
|
||||||
if len(char) != 1:
|
if len(char) != 1:
|
||||||
raise Exception('Invalid Input; must be length 1')
|
raise ValueError('Invalid Input; must be length 1')
|
||||||
return 0xE000 <= ord(char) <= 0xF8FF
|
return 0xE000 <= ord(char) <= 0xF8FF
|
||||||
|
|||||||
@ -169,7 +169,7 @@ class Level:
|
|||||||
can be modified in place."""
|
can be modified in place."""
|
||||||
campaign = self.get_campaign()
|
campaign = self.get_campaign()
|
||||||
if campaign is None:
|
if campaign is None:
|
||||||
raise Exception('level is not in a campaign')
|
raise TypeError('level is not in a campaign')
|
||||||
campaign_config = campaign.get_config_dict()
|
campaign_config = campaign.get_config_dict()
|
||||||
val: Dict[str,
|
val: Dict[str,
|
||||||
Any] = campaign_config.setdefault(self._name, {
|
Any] = campaign_config.setdefault(self._name, {
|
||||||
|
|||||||
@ -353,7 +353,8 @@ class Chooser:
|
|||||||
"""The chooser's ba.Lobby."""
|
"""The chooser's ba.Lobby."""
|
||||||
lobby = self._lobby()
|
lobby = self._lobby()
|
||||||
if lobby is None:
|
if lobby is None:
|
||||||
raise Exception('Lobby does not exist.')
|
from ba import _error
|
||||||
|
raise _error.NotFoundError('Lobby does not exist.')
|
||||||
return lobby
|
return lobby
|
||||||
|
|
||||||
def get_lobby(self) -> Optional[ba.Lobby]:
|
def get_lobby(self) -> Optional[ba.Lobby]:
|
||||||
|
|||||||
@ -144,7 +144,8 @@ def get_map_class(name: str) -> Type[ba.Map]:
|
|||||||
try:
|
try:
|
||||||
return _ba.app.maps[name]
|
return _ba.app.maps[name]
|
||||||
except Exception:
|
except Exception:
|
||||||
raise Exception("Map not found: '" + name + "'")
|
from ba import _error
|
||||||
|
raise _error.NotFoundError("Map not found: '" + name + "'")
|
||||||
|
|
||||||
|
|
||||||
class Map(Actor):
|
class Map(Actor):
|
||||||
@ -218,9 +219,11 @@ class Map(Actor):
|
|||||||
try:
|
try:
|
||||||
self.preloaddata = _ba.getactivity().preloads[type(self)]
|
self.preloaddata = _ba.getactivity().preloads[type(self)]
|
||||||
except Exception:
|
except Exception:
|
||||||
raise Exception('Preload data not found for ' + str(type(self)) +
|
from ba import _error
|
||||||
'; make sure to call the type\'s preload()'
|
raise _error.NotFoundError(
|
||||||
' staticmethod in the activity constructor')
|
'Preload data not found for ' + str(type(self)) +
|
||||||
|
'; make sure to call the type\'s preload()'
|
||||||
|
' staticmethod in the activity constructor')
|
||||||
|
|
||||||
# Set various globals.
|
# Set various globals.
|
||||||
gnode = _gameutils.sharedobj('globals')
|
gnode = _gameutils.sharedobj('globals')
|
||||||
@ -339,7 +342,7 @@ class Map(Actor):
|
|||||||
point_list.append(pts)
|
point_list.append(pts)
|
||||||
else:
|
else:
|
||||||
if len(pts) != 3:
|
if len(pts) != 3:
|
||||||
raise Exception('invalid point')
|
raise ValueError('invalid point')
|
||||||
point_list.append(pts + (0, 0, 0))
|
point_list.append(pts + (0, 0, 0))
|
||||||
i += 1
|
i += 1
|
||||||
return point_list
|
return point_list
|
||||||
@ -365,11 +368,12 @@ class Map(Actor):
|
|||||||
player_pts = []
|
player_pts = []
|
||||||
for player in players:
|
for player in players:
|
||||||
try:
|
try:
|
||||||
if player.node:
|
if player and player.node:
|
||||||
pnt = _ba.Vec3(player.node.position)
|
pnt = _ba.Vec3(player.node.position)
|
||||||
player_pts.append(pnt)
|
player_pts.append(pnt)
|
||||||
except Exception as exc:
|
except Exception:
|
||||||
print('EXC in get_ffa_start_position:', exc)
|
from ba import _error
|
||||||
|
_error.print_exception()
|
||||||
|
|
||||||
def _getpt() -> Sequence[float]:
|
def _getpt() -> Sequence[float]:
|
||||||
point = self.ffa_spawn_points[self._next_ffa_start_index]
|
point = self.ffa_spawn_points[self._next_ffa_start_index]
|
||||||
@ -427,5 +431,5 @@ class Map(Actor):
|
|||||||
def register_map(maptype: Type[Map]) -> None:
|
def register_map(maptype: Type[Map]) -> None:
|
||||||
"""Register a map class with the game."""
|
"""Register a map class with the game."""
|
||||||
if maptype.name in _ba.app.maps:
|
if maptype.name in _ba.app.maps:
|
||||||
raise Exception('map "' + maptype.name + '" already registered')
|
raise RuntimeError('map "' + maptype.name + '" already registered')
|
||||||
_ba.app.maps[maptype.name] = maptype
|
_ba.app.maps[maptype.name] = maptype
|
||||||
|
|||||||
@ -326,7 +326,8 @@ def get_scan_results() -> ScanResults:
|
|||||||
while app.metascan is None:
|
while app.metascan is None:
|
||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
if time.time() - starttime > 10.0:
|
if time.time() - starttime > 10.0:
|
||||||
raise Exception('timeout waiting for meta scan to complete.')
|
raise TimeoutError(
|
||||||
|
'timeout waiting for meta scan to complete.')
|
||||||
return app.metascan
|
return app.metascan
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -191,7 +191,7 @@ class MusicController:
|
|||||||
"""Returns the system music player, instantiating if necessary."""
|
"""Returns the system music player, instantiating if necessary."""
|
||||||
if self._music_player is None:
|
if self._music_player is None:
|
||||||
if self._music_player_type is None:
|
if self._music_player_type is None:
|
||||||
raise Exception('no music player type set')
|
raise TypeError('no music player type set')
|
||||||
self._music_player = self._music_player_type()
|
self._music_player = self._music_player_type()
|
||||||
return self._music_player
|
return self._music_player
|
||||||
|
|
||||||
@ -248,20 +248,21 @@ class MusicController:
|
|||||||
and isinstance(entry['name'], str)):
|
and isinstance(entry['name'], str)):
|
||||||
entry_type = entry['type']
|
entry_type = entry['type']
|
||||||
else:
|
else:
|
||||||
raise Exception('invalid soundtrack entry: ' + str(entry) +
|
raise TypeError('invalid soundtrack entry: ' + str(entry) +
|
||||||
' (type ' + str(type(entry)) + ')')
|
' (type ' + str(type(entry)) + ')')
|
||||||
if self.supports_soundtrack_entry_type(entry_type):
|
if self.supports_soundtrack_entry_type(entry_type):
|
||||||
return entry_type
|
return entry_type
|
||||||
raise Exception('invalid soundtrack entry:' + str(entry))
|
raise ValueError('invalid soundtrack entry:' + str(entry))
|
||||||
except Exception as exc:
|
except Exception:
|
||||||
print('EXC on get_soundtrack_entry_type', exc)
|
from ba import _error
|
||||||
|
_error.print_exception()
|
||||||
return 'default'
|
return 'default'
|
||||||
|
|
||||||
def get_soundtrack_entry_name(self, entry: Any) -> str:
|
def get_soundtrack_entry_name(self, entry: Any) -> str:
|
||||||
"""Given a soundtrack entry, returns its name."""
|
"""Given a soundtrack entry, returns its name."""
|
||||||
try:
|
try:
|
||||||
if entry is None:
|
if entry is None:
|
||||||
raise Exception('entry is None')
|
raise TypeError('entry is None')
|
||||||
|
|
||||||
# Simple string denotes an iTunesPlaylist name (legacy entry).
|
# Simple string denotes an iTunesPlaylist name (legacy entry).
|
||||||
if isinstance(entry, str):
|
if isinstance(entry, str):
|
||||||
@ -272,7 +273,7 @@ class MusicController:
|
|||||||
and isinstance(entry['type'], str) and 'name' in entry
|
and isinstance(entry['type'], str) and 'name' in entry
|
||||||
and isinstance(entry['name'], str)):
|
and isinstance(entry['name'], str)):
|
||||||
return entry['name']
|
return entry['name']
|
||||||
raise Exception('invalid soundtrack entry:' + str(entry))
|
raise ValueError('invalid soundtrack entry:' + str(entry))
|
||||||
except Exception:
|
except Exception:
|
||||||
from ba import _error
|
from ba import _error
|
||||||
_error.print_exception()
|
_error.print_exception()
|
||||||
|
|||||||
@ -56,7 +56,7 @@ def get_ip_address_type(addr: str) -> socket.AddressFamily:
|
|||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
if socket_type is None:
|
if socket_type is None:
|
||||||
raise Exception('addr seems to be neither v4 or v6: ' + str(addr))
|
raise ValueError('addr seems to be neither v4 or v6: ' + str(addr))
|
||||||
return socket_type
|
return socket_type
|
||||||
|
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ class ServerCallThread(threading.Thread):
|
|||||||
self._request = request
|
self._request = request
|
||||||
self._request_type = request_type
|
self._request_type = request_type
|
||||||
if not isinstance(response_type, ServerResponseType):
|
if not isinstance(response_type, ServerResponseType):
|
||||||
raise Exception(f'Invalid response type: {response_type}')
|
raise TypeError(f'Invalid response type: {response_type}')
|
||||||
self._response_type = response_type
|
self._response_type = response_type
|
||||||
self._data = {} if data is None else copy.deepcopy(data)
|
self._data = {} if data is None else copy.deepcopy(data)
|
||||||
self._callback: Optional[ServerCallbackType] = callback
|
self._callback: Optional[ServerCallbackType] = callback
|
||||||
@ -128,7 +128,7 @@ class ServerCallThread(threading.Thread):
|
|||||||
parse.urlencode(self._data).encode(),
|
parse.urlencode(self._data).encode(),
|
||||||
{'User-Agent': _ba.app.user_agent_string}))
|
{'User-Agent': _ba.app.user_agent_string}))
|
||||||
else:
|
else:
|
||||||
raise Exception('Invalid request_type: ' + self._request_type)
|
raise TypeError('Invalid request_type: ' + self._request_type)
|
||||||
|
|
||||||
# If html request failed.
|
# If html request failed.
|
||||||
if response.getcode() != 200:
|
if response.getcode() != 200:
|
||||||
@ -144,7 +144,7 @@ class ServerCallThread(threading.Thread):
|
|||||||
raw_data_s = raw_data.decode()
|
raw_data_s = raw_data.decode()
|
||||||
response_data = json.loads(raw_data_s)
|
response_data = json.loads(raw_data_s)
|
||||||
else:
|
else:
|
||||||
raise Exception(f'invalid responsetype: {self._response_type}')
|
raise TypeError(f'invalid responsetype: {self._response_type}')
|
||||||
except (urllib.error.URLError, ConnectionError):
|
except (urllib.error.URLError, ConnectionError):
|
||||||
# Server rejected us, broken pipe, etc. It happens. Ignoring.
|
# Server rejected us, broken pipe, etc. It happens. Ignoring.
|
||||||
response_data = None
|
response_data = None
|
||||||
|
|||||||
@ -181,7 +181,7 @@ class Player(Generic[TeamType]):
|
|||||||
self._sessionplayer.reset_input()
|
self._sessionplayer.reset_input()
|
||||||
|
|
||||||
def __bool__(self) -> bool:
|
def __bool__(self) -> bool:
|
||||||
return self._sessionplayer.exists()
|
return self.exists()
|
||||||
|
|
||||||
|
|
||||||
def playercast(totype: Type[PlayerType], player: ba.Player) -> PlayerType:
|
def playercast(totype: Type[PlayerType], player: ba.Player) -> PlayerType:
|
||||||
|
|||||||
@ -80,7 +80,7 @@ def filter_playlist(playlist: PlaylistType,
|
|||||||
# the actual game class. add successful ones to our initial list
|
# the actual game class. add successful ones to our initial list
|
||||||
# to present to the user.
|
# to present to the user.
|
||||||
if not isinstance(entry['type'], str):
|
if not isinstance(entry['type'], str):
|
||||||
raise Exception('invalid entry format')
|
raise TypeError('invalid entry format')
|
||||||
try:
|
try:
|
||||||
# Do some type filters for backwards compat.
|
# Do some type filters for backwards compat.
|
||||||
if entry['type'] in ('Assault.AssaultGame',
|
if entry['type'] in ('Assault.AssaultGame',
|
||||||
|
|||||||
@ -56,7 +56,7 @@ def get_store_item_name_translated(item_name: str) -> ba.Lstr:
|
|||||||
return gametype.get_display_string()
|
return gametype.get_display_string()
|
||||||
if item_name.startswith('icons.'):
|
if item_name.startswith('icons.'):
|
||||||
return _lang.Lstr(resource='editProfileWindow.iconText')
|
return _lang.Lstr(resource='editProfileWindow.iconText')
|
||||||
raise Exception('unrecognized item: ' + item_name)
|
raise ValueError('unrecognized item: ' + item_name)
|
||||||
|
|
||||||
|
|
||||||
def get_store_item_display_size(item_name: str) -> Tuple[float, float]:
|
def get_store_item_display_size(item_name: str) -> Tuple[float, float]:
|
||||||
|
|||||||
@ -127,7 +127,7 @@ class UIEntry:
|
|||||||
if self._name == 'mainmenu':
|
if self._name == 'mainmenu':
|
||||||
from bastd.ui import mainmenu
|
from bastd.ui import mainmenu
|
||||||
return cast(Type[UILocation], mainmenu.MainMenuWindow)
|
return cast(Type[UILocation], mainmenu.MainMenuWindow)
|
||||||
raise Exception('unknown ui class ' + str(self._name))
|
raise ValueError('unknown ui class ' + str(self._name))
|
||||||
|
|
||||||
|
|
||||||
class UIController:
|
class UIController:
|
||||||
@ -192,7 +192,7 @@ def uicleanupcheck(obj: Any, widget: ba.Widget) -> None:
|
|||||||
if DEBUG_UI_CLEANUP_CHECKS:
|
if DEBUG_UI_CLEANUP_CHECKS:
|
||||||
print(f'adding uicleanup to {obj}')
|
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 TypeError('widget arg is not a ba.Widget')
|
||||||
|
|
||||||
def foobar() -> None:
|
def foobar() -> None:
|
||||||
"""Just testing."""
|
"""Just testing."""
|
||||||
|
|||||||
@ -149,8 +149,8 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
|
|||||||
self._score_order: str
|
self._score_order: str
|
||||||
if 'score_order' in settings:
|
if 'score_order' in settings:
|
||||||
if not settings['score_order'] in ['increasing', 'decreasing']:
|
if not settings['score_order'] in ['increasing', 'decreasing']:
|
||||||
raise Exception('Invalid score order: ' +
|
raise ValueError('Invalid score order: ' +
|
||||||
settings['score_order'])
|
settings['score_order'])
|
||||||
self._score_order = settings['score_order']
|
self._score_order = settings['score_order']
|
||||||
else:
|
else:
|
||||||
self._score_order = 'increasing'
|
self._score_order = 'increasing'
|
||||||
@ -159,8 +159,8 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
|
|||||||
self._score_type: str
|
self._score_type: str
|
||||||
if 'score_type' in settings:
|
if 'score_type' in settings:
|
||||||
if not settings['score_type'] in ['points', 'time']:
|
if not settings['score_type'] in ['points', 'time']:
|
||||||
raise Exception('Invalid score type: ' +
|
raise ValueError('Invalid score type: ' +
|
||||||
settings['score_type'])
|
settings['score_type'])
|
||||||
self._score_type = settings['score_type']
|
self._score_type = settings['score_type']
|
||||||
else:
|
else:
|
||||||
self._score_type = 'points'
|
self._score_type = 'points'
|
||||||
|
|||||||
@ -665,7 +665,7 @@ class Bomb(ba.Actor):
|
|||||||
|
|
||||||
if bomb_type not in ('ice', 'impact', 'land_mine', 'normal', 'sticky',
|
if bomb_type not in ('ice', 'impact', 'land_mine', 'normal', 'sticky',
|
||||||
'tnt'):
|
'tnt'):
|
||||||
raise Exception('invalid bomb type: ' + bomb_type)
|
raise ValueError('invalid bomb type: ' + bomb_type)
|
||||||
self.bomb_type = bomb_type
|
self.bomb_type = bomb_type
|
||||||
|
|
||||||
self._exploded = False
|
self._exploded = False
|
||||||
|
|||||||
@ -95,7 +95,7 @@ class OnScreenTimer(ba.Actor):
|
|||||||
assert isinstance(endtime, int)
|
assert isinstance(endtime, int)
|
||||||
endtime_ms = endtime
|
endtime_ms = endtime
|
||||||
else:
|
else:
|
||||||
raise Exception(f'invalid timeformat: {timeformat}')
|
raise ValueError(f'invalid timeformat: {timeformat}')
|
||||||
|
|
||||||
self.inputnode.timemax = endtime_ms - self._starttime
|
self.inputnode.timemax = endtime_ms - self._starttime
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ class OnScreenTimer(ba.Actor):
|
|||||||
return 0.001 * val_ms
|
return 0.001 * val_ms
|
||||||
if timeformat is ba.TimeFormat.MILLISECONDS:
|
if timeformat is ba.TimeFormat.MILLISECONDS:
|
||||||
return val_ms
|
return val_ms
|
||||||
raise Exception(f'invalid timeformat: {timeformat}')
|
raise ValueError(f'invalid timeformat: {timeformat}')
|
||||||
|
|
||||||
def handlemessage(self, msg: Any) -> Any:
|
def handlemessage(self, msg: Any) -> Any:
|
||||||
# if we're asked to die, just kill our node/timer
|
# if we're asked to die, just kill our node/timer
|
||||||
|
|||||||
@ -187,7 +187,7 @@ def get_factory() -> PowerupBoxFactory:
|
|||||||
"""Return a shared ba.PowerupBoxFactory object, creating if necessary."""
|
"""Return a shared ba.PowerupBoxFactory object, creating if necessary."""
|
||||||
activity = ba.getactivity()
|
activity = ba.getactivity()
|
||||||
if activity is None:
|
if activity is None:
|
||||||
raise Exception('no current activity')
|
raise RuntimeError('no current activity')
|
||||||
try:
|
try:
|
||||||
# FIXME: et better way to store stuff with activity
|
# FIXME: et better way to store stuff with activity
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
@ -252,10 +252,10 @@ class PowerupBox(ba.Actor):
|
|||||||
elif poweruptype == 'curse':
|
elif poweruptype == 'curse':
|
||||||
tex = factory.tex_curse
|
tex = factory.tex_curse
|
||||||
else:
|
else:
|
||||||
raise Exception('invalid poweruptype: ' + str(poweruptype))
|
raise ValueError('invalid poweruptype: ' + str(poweruptype))
|
||||||
|
|
||||||
if len(position) != 3:
|
if len(position) != 3:
|
||||||
raise Exception('expected 3 floats for position')
|
raise ValueError('expected 3 floats for position')
|
||||||
|
|
||||||
self.node = ba.newnode(
|
self.node = ba.newnode(
|
||||||
'prop',
|
'prop',
|
||||||
|
|||||||
@ -1384,7 +1384,7 @@ class Spaz(ba.Actor):
|
|||||||
return bomb_factory.tex_ice_bombs
|
return bomb_factory.tex_ice_bombs
|
||||||
if self.bomb_type == 'impact':
|
if self.bomb_type == 'impact':
|
||||||
return bomb_factory.tex_impact_bombs
|
return bomb_factory.tex_impact_bombs
|
||||||
raise Exception()
|
raise ValueError('invalid bomb type')
|
||||||
|
|
||||||
def _flash_billboard(self, tex: ba.Texture) -> None:
|
def _flash_billboard(self, tex: ba.Texture) -> None:
|
||||||
assert self.node
|
assert self.node
|
||||||
|
|||||||
@ -224,7 +224,7 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]):
|
|||||||
]},
|
]},
|
||||||
{'entries': [
|
{'entries': [
|
||||||
{'type': spazbot.ChargerBotProShielded if hard
|
{'type': spazbot.ChargerBotProShielded if hard
|
||||||
else spazbot.ChargerBot, 'path': 1},
|
else spazbot.ChargerBot, 'path': 1},
|
||||||
{'type': spazbot.BrawlerBot, 'path': 2} if hard else None,
|
{'type': spazbot.BrawlerBot, 'path': 2} if hard else None,
|
||||||
{'type': spazbot.BrawlerBot, 'path': 2},
|
{'type': spazbot.BrawlerBot, 'path': 2},
|
||||||
{'type': spazbot.BrawlerBot, 'path': 2},
|
{'type': spazbot.BrawlerBot, 'path': 2},
|
||||||
@ -273,7 +273,7 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]):
|
|||||||
{'type': spazbot.TriggerBot, 'path': 2},
|
{'type': spazbot.TriggerBot, 'path': 2},
|
||||||
{'type': spazbot.TriggerBot, 'path': 3},
|
{'type': spazbot.TriggerBot, 'path': 3},
|
||||||
{'type': spazbot.BrawlerBotPro if hard
|
{'type': spazbot.BrawlerBotPro if hard
|
||||||
else spazbot.BrawlerBot, 'point': 'bottom_left'},
|
else spazbot.BrawlerBot, 'point': 'bottom_left'},
|
||||||
{'type': spazbot.BrawlerBotPro, 'point': 'bottom_right'}
|
{'type': spazbot.BrawlerBotPro, 'point': 'bottom_right'}
|
||||||
if player_count > 2 else None,
|
if player_count > 2 else None,
|
||||||
]},
|
]},
|
||||||
@ -312,7 +312,7 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]):
|
|||||||
]},
|
]},
|
||||||
{'entries': [
|
{'entries': [
|
||||||
{'type': spazbot.TriggerBotProShielded if hard
|
{'type': spazbot.TriggerBotProShielded if hard
|
||||||
else spazbot.TriggerBotPro, 'point': 'bottom_left'},
|
else spazbot.TriggerBotPro, 'point': 'bottom_left'},
|
||||||
{'type': spazbot.TriggerBotProShielded,
|
{'type': spazbot.TriggerBotProShielded,
|
||||||
'point': 'bottom_right'}
|
'point': 'bottom_right'}
|
||||||
if hard else None,
|
if hard else None,
|
||||||
@ -1110,7 +1110,6 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]):
|
|||||||
if ((ba.is_point_in_box(pos, boxes['b8'])
|
if ((ba.is_point_in_box(pos, boxes['b8'])
|
||||||
and not ba.is_point_in_box(pos, boxes['b9']))
|
and not ba.is_point_in_box(pos, boxes['b9']))
|
||||||
or pos == (0.0, 0.0, 0.0)):
|
or pos == (0.0, 0.0, 0.0)):
|
||||||
|
|
||||||
# Default to walking right if we're still in the walking area.
|
# Default to walking right if we're still in the walking area.
|
||||||
bot.node.move_left_right = speed
|
bot.node.move_left_right = speed
|
||||||
bot.node.move_up_down = 0
|
bot.node.move_up_down = 0
|
||||||
@ -1177,7 +1176,7 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]):
|
|||||||
def _get_bot_speed(self, bot_type: Type[spazbot.SpazBot]) -> float:
|
def _get_bot_speed(self, bot_type: Type[spazbot.SpazBot]) -> float:
|
||||||
speed = self._bot_speed_map.get(bot_type)
|
speed = self._bot_speed_map.get(bot_type)
|
||||||
if speed is None:
|
if speed is None:
|
||||||
raise Exception('Invalid bot type to _get_bot_speed(): ' +
|
raise TypeError('Invalid bot type to _get_bot_speed(): ' +
|
||||||
str(bot_type))
|
str(bot_type))
|
||||||
return speed
|
return speed
|
||||||
|
|
||||||
|
|||||||
@ -627,8 +627,8 @@ class AccountSettingsWindow(ba.Window):
|
|||||||
elif account_type == 'Game Circle':
|
elif account_type == 'Game Circle':
|
||||||
account_type_name = ba.Lstr(resource='gameCircleText')
|
account_type_name = ba.Lstr(resource='gameCircleText')
|
||||||
else:
|
else:
|
||||||
raise Exception("unknown account type: '" + str(account_type) +
|
raise ValueError("unknown account type: '" +
|
||||||
"'")
|
str(account_type) + "'")
|
||||||
self._game_service_button = btn = ba.buttonwidget(
|
self._game_service_button = btn = ba.buttonwidget(
|
||||||
parent=self._subcontainer,
|
parent=self._subcontainer,
|
||||||
position=((self._sub_width - button_width) * 0.5, v),
|
position=((self._sub_width - button_width) * 0.5, v),
|
||||||
@ -1105,7 +1105,7 @@ class AccountSettingsWindow(ba.Window):
|
|||||||
elif sel == self._scrollwidget:
|
elif sel == self._scrollwidget:
|
||||||
sel_name = 'Scroll'
|
sel_name = 'Scroll'
|
||||||
else:
|
else:
|
||||||
raise Exception('unrecognized selection')
|
raise ValueError('unrecognized selection')
|
||||||
ba.app.window_states[self.__class__.__name__] = sel_name
|
ba.app.window_states[self.__class__.__name__] = sel_name
|
||||||
except Exception:
|
except Exception:
|
||||||
ba.print_exception('exception saving state for', self.__class__)
|
ba.print_exception('exception saving state for', self.__class__)
|
||||||
|
|||||||
@ -50,7 +50,7 @@ class ColorPicker(popup.PopupWindow):
|
|||||||
|
|
||||||
c_raw = get_player_colors()
|
c_raw = get_player_colors()
|
||||||
if len(c_raw) != 16:
|
if len(c_raw) != 16:
|
||||||
raise Exception('expected 16 player colors')
|
raise ValueError('expected 16 player colors')
|
||||||
self.colors = [c_raw[0:4], c_raw[4:8], c_raw[8:12], c_raw[12:16]]
|
self.colors = [c_raw[0:4], c_raw[4:8], c_raw[8:12], c_raw[12:16]]
|
||||||
|
|
||||||
if scale is None:
|
if scale is None:
|
||||||
@ -189,7 +189,7 @@ class ColorPickerExact(popup.PopupWindow):
|
|||||||
from ba.internal import get_player_colors
|
from ba.internal import get_player_colors
|
||||||
c_raw = get_player_colors()
|
c_raw = get_player_colors()
|
||||||
if len(c_raw) != 16:
|
if len(c_raw) != 16:
|
||||||
raise Exception('expected 16 player colors')
|
raise ValueError('expected 16 player colors')
|
||||||
self.colors = [c_raw[0:4], c_raw[4:8], c_raw[8:12], c_raw[12:16]]
|
self.colors = [c_raw[0:4], c_raw[4:8], c_raw[8:12], c_raw[12:16]]
|
||||||
|
|
||||||
if scale is None:
|
if scale is None:
|
||||||
|
|||||||
@ -1555,7 +1555,7 @@ class CoopBrowserWindow(ba.Window):
|
|||||||
elif sel == self._scrollwidget:
|
elif sel == self._scrollwidget:
|
||||||
sel_name = 'Scroll'
|
sel_name = 'Scroll'
|
||||||
else:
|
else:
|
||||||
raise Exception('unrecognized selection')
|
raise ValueError('unrecognized selection')
|
||||||
ba.app.window_states[self.__class__.__name__] = {
|
ba.app.window_states[self.__class__.__name__] = {
|
||||||
'sel_name': sel_name
|
'sel_name': sel_name
|
||||||
}
|
}
|
||||||
|
|||||||
@ -807,11 +807,8 @@ class GatherWindow(ba.Window):
|
|||||||
color=(1, 0, 0))
|
color=(1, 0, 0))
|
||||||
ba.playsound(ba.getsound('error'))
|
ba.playsound(ba.getsound('error'))
|
||||||
return
|
return
|
||||||
try:
|
port = int(cast(str, ba.textwidget(query=port_textwidget)))
|
||||||
port = int(cast(str, ba.textwidget(query=port_textwidget)))
|
if port > 65535 or port < 0:
|
||||||
if port > 65535 or port < 0:
|
|
||||||
raise Exception()
|
|
||||||
except Exception:
|
|
||||||
ba.screenmessage(
|
ba.screenmessage(
|
||||||
ba.Lstr(resource='internal.invalidPortErrorText'),
|
ba.Lstr(resource='internal.invalidPortErrorText'),
|
||||||
color=(1, 0, 0))
|
color=(1, 0, 0))
|
||||||
@ -1958,7 +1955,7 @@ class GatherWindow(ba.Window):
|
|||||||
elif sel == self._tab_container:
|
elif sel == self._tab_container:
|
||||||
sel_name = 'TabContainer'
|
sel_name = 'TabContainer'
|
||||||
else:
|
else:
|
||||||
raise Exception('unrecognized selection: ' + str(sel))
|
raise ValueError(f'unrecognized selection: \'{sel}\'')
|
||||||
ba.app.window_states[self.__class__.__name__] = {
|
ba.app.window_states[self.__class__.__name__] = {
|
||||||
'sel_name': sel_name,
|
'sel_name': sel_name,
|
||||||
'tab': self._current_tab,
|
'tab': self._current_tab,
|
||||||
|
|||||||
@ -673,8 +673,8 @@ class MainMenuWindow(ba.Window):
|
|||||||
if (not isinstance(cme, dict) or 'label' not in cme
|
if (not isinstance(cme, dict) or 'label' not in cme
|
||||||
or not isinstance(cme['label'], (str, ba.Lstr))
|
or not isinstance(cme['label'], (str, ba.Lstr))
|
||||||
or 'call' not in cme or not callable(cme['call'])):
|
or 'call' not in cme or not callable(cme['call'])):
|
||||||
raise Exception('invalid custom menu entry: ' +
|
raise ValueError('invalid custom menu entry: ' +
|
||||||
str(cme))
|
str(cme))
|
||||||
except Exception:
|
except Exception:
|
||||||
custom_menu_entries = []
|
custom_menu_entries = []
|
||||||
ba.print_exception('exception getting custom menu entries for',
|
ba.print_exception('exception getting custom menu entries for',
|
||||||
|
|||||||
@ -538,7 +538,7 @@ class PlayWindow(ba.Window):
|
|||||||
elif sel == self._back_button:
|
elif sel == self._back_button:
|
||||||
sel_name = 'Back'
|
sel_name = 'Back'
|
||||||
else:
|
else:
|
||||||
raise Exception('unrecognized selected widget')
|
raise ValueError(f'unrecognized selection {sel}')
|
||||||
ba.app.window_states[self.__class__.__name__] = sel_name
|
ba.app.window_states[self.__class__.__name__] = sel_name
|
||||||
except Exception:
|
except Exception:
|
||||||
ba.print_exception('error saving state for', self.__class__)
|
ba.print_exception('error saving state for', self.__class__)
|
||||||
|
|||||||
@ -58,7 +58,7 @@ class PlaylistTypeVars:
|
|||||||
fallback_resource='freeForAllText')
|
fallback_resource='freeForAllText')
|
||||||
self.sessiontype = ba.FreeForAllSession
|
self.sessiontype = ba.FreeForAllSession
|
||||||
else:
|
else:
|
||||||
raise Exception('playlist type vars undefined for session type: ' +
|
raise TypeError('playlist type vars undefined for session type: ' +
|
||||||
str(sessiontype))
|
str(sessiontype))
|
||||||
self.default_list_name = ba.Lstr(resource='defaultGameListNameText',
|
self.default_list_name = ba.Lstr(resource='defaultGameListNameText',
|
||||||
subs=[('${PLAYMODE}', play_mode_name)
|
subs=[('${PLAYMODE}', play_mode_name)
|
||||||
|
|||||||
@ -62,7 +62,7 @@ class PlaylistBrowserWindow(ba.Window):
|
|||||||
ba.app.main_window = 'Free-for-All Game Select'
|
ba.app.main_window = 'Free-for-All Game Select'
|
||||||
ba.set_analytics_screen('FreeForAll Window')
|
ba.set_analytics_screen('FreeForAll Window')
|
||||||
else:
|
else:
|
||||||
raise Exception(f'invalid sessiontype: {sessiontype}')
|
raise TypeError(f'invalid sessiontype: {sessiontype}')
|
||||||
self._pvars = playlist.PlaylistTypeVars(sessiontype)
|
self._pvars = playlist.PlaylistTypeVars(sessiontype)
|
||||||
|
|
||||||
self._sessiontype = sessiontype
|
self._sessiontype = sessiontype
|
||||||
|
|||||||
@ -264,19 +264,19 @@ class PlaylistEditGameWindow(ba.Window):
|
|||||||
if 'choices' in setting:
|
if 'choices' in setting:
|
||||||
for choice in setting['choices']:
|
for choice in setting['choices']:
|
||||||
if len(choice) != 2:
|
if len(choice) != 2:
|
||||||
raise Exception(
|
raise ValueError(
|
||||||
"Expected 2-member tuples for 'choices'; got: " +
|
"Expected 2-member tuples for 'choices'; got: " +
|
||||||
repr(choice))
|
repr(choice))
|
||||||
if not isinstance(choice[0], str):
|
if not isinstance(choice[0], str):
|
||||||
raise Exception(
|
raise TypeError(
|
||||||
'First value for choice tuple must be a str; got: '
|
'First value for choice tuple must be a str; got: '
|
||||||
+ repr(choice))
|
+ repr(choice))
|
||||||
if not isinstance(choice[1], value_type):
|
if not isinstance(choice[1], value_type):
|
||||||
raise Exception(
|
raise TypeError(
|
||||||
'Choice type does not match default value; choice:'
|
'Choice type does not match default value; choice:'
|
||||||
+ repr(choice) + '; setting:' + repr(setting))
|
+ repr(choice) + '; setting:' + repr(setting))
|
||||||
if value_type not in (int, float):
|
if value_type not in (int, float):
|
||||||
raise Exception(
|
raise TypeError(
|
||||||
'Choice type setting must have int or float default; '
|
'Choice type setting must have int or float default; '
|
||||||
'got: ' + repr(setting))
|
'got: ' + repr(setting))
|
||||||
|
|
||||||
@ -509,5 +509,5 @@ class PlaylistEditGameWindow(ba.Window):
|
|||||||
elif setting_type == int:
|
elif setting_type == int:
|
||||||
ba.textwidget(edit=ctrl, text=str(int(val)))
|
ba.textwidget(edit=ctrl, text=str(int(val)))
|
||||||
else:
|
else:
|
||||||
raise Exception('invalid vartype: ' + str(setting_type))
|
raise TypeError('invalid vartype: ' + str(setting_type))
|
||||||
self._settings[setting_name] = val
|
self._settings[setting_name] = val
|
||||||
|
|||||||
@ -93,7 +93,7 @@ class PlayOptionsWindow(popup.PopupWindow):
|
|||||||
elif self._sessiontype is ba.DualTeamSession:
|
elif self._sessiontype is ba.DualTeamSession:
|
||||||
plst = get_default_teams_playlist()
|
plst = get_default_teams_playlist()
|
||||||
else:
|
else:
|
||||||
raise Exception('unrecognized session-type: ' +
|
raise TypeError('unrecognized session-type: ' +
|
||||||
str(self._sessiontype))
|
str(self._sessiontype))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -153,7 +153,7 @@ class PopupMenuWindow(PopupWindow):
|
|||||||
self._choices_disabled = list(choices_disabled)
|
self._choices_disabled = list(choices_disabled)
|
||||||
self._done_building = False
|
self._done_building = False
|
||||||
if not choices:
|
if not choices:
|
||||||
raise Exception('Must pass at least one choice')
|
raise TypeError('Must pass at least one choice')
|
||||||
self._width = width
|
self._width = width
|
||||||
self._scale = scale
|
self._scale = scale
|
||||||
if len(choices) > 8:
|
if len(choices) > 8:
|
||||||
@ -302,7 +302,7 @@ class PopupMenu:
|
|||||||
current_choice = None
|
current_choice = None
|
||||||
self._choices = list(choices)
|
self._choices = list(choices)
|
||||||
if not choices:
|
if not choices:
|
||||||
raise Exception('no choices given')
|
raise TypeError('no choices given')
|
||||||
self._choices_display = list(choices_display)
|
self._choices_display = list(choices_display)
|
||||||
self._choices_disabled = list(choices_disabled)
|
self._choices_disabled = list(choices_disabled)
|
||||||
self._width = width
|
self._width = width
|
||||||
@ -313,7 +313,7 @@ class PopupMenu:
|
|||||||
self._position = position
|
self._position = position
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
if not choices:
|
if not choices:
|
||||||
raise Exception('Must pass at least one choice')
|
raise TypeError('Must pass at least one choice')
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
self._button_size = button_size
|
self._button_size = button_size
|
||||||
|
|
||||||
|
|||||||
@ -546,7 +546,7 @@ class EditProfileWindow(ba.Window):
|
|||||||
elif picker_type == 'highlight':
|
elif picker_type == 'highlight':
|
||||||
initial_color = self._highlight
|
initial_color = self._highlight
|
||||||
else:
|
else:
|
||||||
raise Exception('invalid picker_type: ' + picker_type)
|
raise ValueError('invalid picker_type: ' + picker_type)
|
||||||
colorpicker.ColorPicker(
|
colorpicker.ColorPicker(
|
||||||
parent=self._root_widget,
|
parent=self._root_widget,
|
||||||
position=origin,
|
position=origin,
|
||||||
|
|||||||
@ -44,7 +44,7 @@ class PurchaseWindow(ba.Window):
|
|||||||
header_text = ba.Lstr(resource='unlockThisText',
|
header_text = ba.Lstr(resource='unlockThisText',
|
||||||
fallback_resource='unlockThisInTheStoreText')
|
fallback_resource='unlockThisInTheStoreText')
|
||||||
if len(items) != 1:
|
if len(items) != 1:
|
||||||
raise Exception('expected exactly 1 item')
|
raise ValueError('expected exactly 1 item')
|
||||||
self._items = list(items)
|
self._items = list(items)
|
||||||
self._width = 580
|
self._width = 580
|
||||||
self._height = 520
|
self._height = 520
|
||||||
|
|||||||
@ -596,11 +596,11 @@ class AdvancedSettingsWindow(ba.Window):
|
|||||||
elif sel == self._language_inform_checkbox:
|
elif sel == self._language_inform_checkbox:
|
||||||
sel_name = 'LangInform'
|
sel_name = 'LangInform'
|
||||||
else:
|
else:
|
||||||
raise Exception('unrecognized selection')
|
raise ValueError(f'unrecognized selection \'{sel}\'')
|
||||||
elif sel == self._back_button:
|
elif sel == self._back_button:
|
||||||
sel_name = 'Back'
|
sel_name = 'Back'
|
||||||
else:
|
else:
|
||||||
raise Exception('unrecognized selection')
|
raise ValueError(f'unrecognized selection \'{sel}\'')
|
||||||
ba.app.window_states[self.__class__.__name__] = {
|
ba.app.window_states[self.__class__.__name__] = {
|
||||||
'sel_name': sel_name
|
'sel_name': sel_name
|
||||||
}
|
}
|
||||||
|
|||||||
@ -252,7 +252,7 @@ class AllSettingsWindow(ba.Window):
|
|||||||
elif sel == self._back_button:
|
elif sel == self._back_button:
|
||||||
sel_name = 'Back'
|
sel_name = 'Back'
|
||||||
else:
|
else:
|
||||||
raise Exception('unrecognized selection')
|
raise ValueError(f'unrecognized selection \'{sel}\'')
|
||||||
ba.app.window_states[self.__class__.__name__] = {
|
ba.app.window_states[self.__class__.__name__] = {
|
||||||
'sel_name': sel_name
|
'sel_name': sel_name
|
||||||
}
|
}
|
||||||
|
|||||||
@ -266,7 +266,7 @@ class AudioSettingsWindow(ba.Window):
|
|||||||
elif sel == self._vr_head_relative_audio_button:
|
elif sel == self._vr_head_relative_audio_button:
|
||||||
sel_name = 'VRHeadRelative'
|
sel_name = 'VRHeadRelative'
|
||||||
else:
|
else:
|
||||||
raise Exception('unrecognized selected widget')
|
raise ValueError(f'unrecognized selection \'{sel}\'')
|
||||||
ba.app.window_states[self.__class__.__name__] = sel_name
|
ba.app.window_states[self.__class__.__name__] = sel_name
|
||||||
except Exception:
|
except Exception:
|
||||||
ba.print_exception('error saving state for', self.__class__)
|
ba.print_exception('error saving state for', self.__class__)
|
||||||
|
|||||||
@ -167,7 +167,7 @@ class TestingWindow(ba.Window):
|
|||||||
for entry in self._entries:
|
for entry in self._entries:
|
||||||
if entry['name'] == name:
|
if entry['name'] == name:
|
||||||
return entry
|
return entry
|
||||||
raise Exception(f'Entry not found: {name}')
|
raise ba.NotFoundError(f'Entry not found: {name}')
|
||||||
|
|
||||||
def _on_reset_press(self) -> None:
|
def _on_reset_press(self) -> None:
|
||||||
for entry in self._entries:
|
for entry in self._entries:
|
||||||
|
|||||||
@ -485,7 +485,7 @@ class SoundtrackBrowserWindow(ba.Window):
|
|||||||
elif sel == self._back_button:
|
elif sel == self._back_button:
|
||||||
sel_name = 'Back'
|
sel_name = 'Back'
|
||||||
else:
|
else:
|
||||||
raise Exception('unrecognized selection')
|
raise ValueError(f'unrecognized selection \'{sel}\'')
|
||||||
ba.app.window_states[self.__class__.__name__] = sel_name
|
ba.app.window_states[self.__class__.__name__] = sel_name
|
||||||
except Exception:
|
except Exception:
|
||||||
ba.print_exception('error saving state for', self.__class__)
|
ba.print_exception('error saving state for', self.__class__)
|
||||||
|
|||||||
@ -1002,7 +1002,7 @@ class StoreBrowserWindow(ba.Window):
|
|||||||
sel_name = 'Tab:' + list(self._tab_buttons.keys())[list(
|
sel_name = 'Tab:' + list(self._tab_buttons.keys())[list(
|
||||||
self._tab_buttons.values()).index(sel)]
|
self._tab_buttons.values()).index(sel)]
|
||||||
else:
|
else:
|
||||||
raise Exception('unrecognized selection')
|
raise ValueError(f'unrecognized selection \'{sel}\'')
|
||||||
ba.app.window_states[self.__class__.__name__] = {
|
ba.app.window_states[self.__class__.__name__] = {
|
||||||
'sel_name': sel_name,
|
'sel_name': sel_name,
|
||||||
'tab': self._current_tab
|
'tab': self._current_tab
|
||||||
|
|||||||
@ -69,7 +69,7 @@ class TournamentEntryWindow(popup.PopupWindow):
|
|||||||
self._purchase_price_name = 'price.tournament_entry_1'
|
self._purchase_price_name = 'price.tournament_entry_1'
|
||||||
else:
|
else:
|
||||||
if self._fee != 0:
|
if self._fee != 0:
|
||||||
raise Exception('invalid fee: ' + str(self._fee))
|
raise ValueError('invalid fee: ' + str(self._fee))
|
||||||
self._purchase_name = 'tournament_entry_0'
|
self._purchase_name = 'tournament_entry_0'
|
||||||
self._purchase_price_name = 'price.tournament_entry_0'
|
self._purchase_price_name = 'price.tournament_entry_0'
|
||||||
|
|
||||||
|
|||||||
@ -482,7 +482,7 @@ class WatchWindow(ba.Window):
|
|||||||
elif sel == self._tab_container:
|
elif sel == self._tab_container:
|
||||||
sel_name = 'TabContainer'
|
sel_name = 'TabContainer'
|
||||||
else:
|
else:
|
||||||
raise Exception('unrecognized selection')
|
raise ValueError(f'unrecognized selection {sel}')
|
||||||
ba.app.window_states[self.__class__.__name__] = {
|
ba.app.window_states[self.__class__.__name__] = {
|
||||||
'sel_name': sel_name,
|
'sel_name': sel_name,
|
||||||
'tab': self._current_tab
|
'tab': self._current_tab
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user