mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-01-29 10:43:21 +08:00
added ba.app.add_coop_practice_level()
This commit is contained in:
parent
e5e54a64e6
commit
2039d44a03
@ -1,6 +1,8 @@
|
||||
### 1.7.4 (20638, 2022-07-07)
|
||||
- Fixed the trophies list showing an incorrect total (Thanks itsre3!)
|
||||
- ba.app.meta.metascan is now ba.app.meta.scanresults
|
||||
- Cleaned up co-op ui code a bit
|
||||
- Added a utility function to add custom co-op games in the practice section: `ba.app.add_coop_practice_level`. Also added new workspace template script which uses it to define a new co-op game type.
|
||||
|
||||
### 1.7.3 (20634, 2022-07-06)
|
||||
- Fixed an issue with King of the Hill flag regions not working when players entered them (Thanks itsre3!)
|
||||
|
||||
@ -29,6 +29,7 @@ if TYPE_CHECKING:
|
||||
from ba._cloud import CloudSubsystem
|
||||
from bastd.actor import spazappearance
|
||||
from ba._accountv2 import AccountV2Subsystem
|
||||
from ba._level import Level
|
||||
|
||||
|
||||
class App:
|
||||
@ -274,6 +275,7 @@ class App:
|
||||
|
||||
# Co-op Campaigns.
|
||||
self.campaigns: dict[str, ba.Campaign] = {}
|
||||
self.custom_coop_practice_games: list[str] = []
|
||||
|
||||
# Server Mode.
|
||||
self.server: ba.ServerController | None = None
|
||||
@ -527,6 +529,15 @@ class App:
|
||||
# FIXME: This should not be an actor attr.
|
||||
activity.paused_text = None
|
||||
|
||||
def add_coop_practice_level(self, level: Level) -> None:
|
||||
"""Adds an individual level to the 'practice' section in Co-op."""
|
||||
|
||||
# Assign this level to our catch-all campaign.
|
||||
self.campaigns['Challenges'].addlevel(level)
|
||||
|
||||
# Make note to add it to our challenges UI.
|
||||
self.custom_coop_practice_games.append(f'Challenges:{level.name}')
|
||||
|
||||
def return_to_main_menu_session_gracefully(self,
|
||||
reset_ui: bool = True) -> None:
|
||||
"""Attempt to cleanly get back to the main menu."""
|
||||
|
||||
@ -49,12 +49,12 @@ class Campaign:
|
||||
"""Whether this Campaign's levels must be played in sequence."""
|
||||
return self._sequential
|
||||
|
||||
def addlevel(self, level: ba.Level) -> None:
|
||||
def addlevel(self, level: ba.Level, index: int = -1) -> None:
|
||||
"""Adds a ba.Level to the Campaign."""
|
||||
if level.campaign is not None:
|
||||
raise RuntimeError('Level already belongs to a campaign.')
|
||||
level.set_campaign(self, len(self._levels))
|
||||
self._levels.append(level)
|
||||
self._levels.insert(index, level)
|
||||
|
||||
@property
|
||||
def levels(self) -> list[ba.Level]:
|
||||
|
||||
@ -720,7 +720,7 @@ class CoopBrowserWindow(ba.Window):
|
||||
self.run_tournament)))
|
||||
v -= 200
|
||||
|
||||
# Custom Games.
|
||||
# Custom Games. (called 'Practice' in UI these days).
|
||||
v -= 50
|
||||
ba.textwidget(parent=w_parent,
|
||||
position=(h_base + 27, v + 30 + 198),
|
||||
@ -751,11 +751,9 @@ class CoopBrowserWindow(ba.Window):
|
||||
'Challenges:Pro Easter Egg Hunt',
|
||||
] + items
|
||||
|
||||
# add all custom user levels here..
|
||||
# items += [
|
||||
# 'User:' + l.getname()
|
||||
# for l in getcampaign('User').getlevels()
|
||||
# ]
|
||||
# If we've defined custom games, put them at the beginning.
|
||||
if ba.app.custom_coop_practice_games:
|
||||
items = ba.app.custom_coop_practice_games + items
|
||||
|
||||
self._custom_h_scroll = custom_h_scroll = h_scroll = ba.hscrollwidget(
|
||||
parent=w_parent,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user