Tracks¶
Opening tracks from a plugin: the game's own, in the circuit's order, and workshop tracks found by a search. They open the way the game opens them. Everything here needs host 0.14.0.
Official¶
array<string>@ Tracks::Official()
The game's own tracks by level name, grouped as its playlists group them: each circuit season in order, then the collabs, then the trials (The Tower and The Tower CPs). Empty away from the main menu, where the game doesn't have them loaded.
Example
array<string>@ levels = Tracks::Official();
Title¶
string Tracks::Title(const string &in)
A track's name as the game shows it, or "" when it only has its level name.
Example
string title = Tracks::Title(levels[0]);
Group¶
string Tracks::Group(const string &in)
Which playlist one of the game's tracks is in: "season 1", "season 2", ..., "collabs" or "trials".
Example
string group = Tracks::Group(levels[0]);
Image¶
string Tracks::Image(const string &in)
A game track's preview picture, as a game texture path that Window.AddImage takes, or "" if it has none.
Example
string image = Tracks::Image(levels[0]);
if (image != "")
window.AddImage(image, 160, 90);
Open¶
bool Tracks::Open(const string &in)
Opens one of the game's tracks by its level name, as the game's own play button does. False if it didn't start.
Example
Tracks::Open(levels[0]);
Search¶
void Tracks::Search(const string &in)
Searches the workshop for tracks by name. Results arrive a moment later: see SearchState.
Example
Tracks::Search("chaos");
SearchState¶
string Tracks::SearchState()
"idle", "searching", "done" or "error: ...".
Example
if (Tracks::SearchState() == "done")
Log::Info(Tracks::ResultCount() + " tracks found");
ResultCount¶
int Tracks::ResultCount()
How many results the last search returned (the first page).
Example
int found = Tracks::ResultCount();
Total¶
int Tracks::Total()
How many workshop items matched the last search in all.
Example
Log::Info(Tracks::ResultCount() + " of " + Tracks::Total());
ResultTitle¶
string Tracks::ResultTitle(int)
A search result's title.
Example
button.label = Tracks::ResultTitle(0);
ResultId¶
string Tracks::ResultId(int)
A search result's workshop id, as text (for OpenWorkshop).
Example
string id = Tracks::ResultId(0);
ResultImage¶
string Tracks::ResultImage(int)
A search result's preview picture as a file on this computer (for Window.AddImage), or "" until there is one:
asking for it starts the download, so ask again a moment later.
Example
string image = Tracks::ResultImage(0);
OpenWorkshop¶
bool Tracks::OpenWorkshop(const string &in)
Opens a workshop track by its id. If it isn't on this computer yet, Steam downloads it first, as the game's own track
browser does. False if it can't start; OpenState tells how it goes.
Example
Tracks::OpenWorkshop(Tracks::ResultId(0));
OpenState¶
string Tracks::OpenState()
"idle", "downloading", "opening", "open" or "error: ...".
Example
if (Tracks::OpenState().findFirst("error") == 0)
statusText.text = Tracks::OpenState();
OpenLocal¶
bool Tracks::OpenLocal(const string &in)
Races one of the player's own saved maps (a file name in the game's maps folder, Tracks::LocalFolder) as a normal
race, the way the game races a workshop map: the pre-race menu, countdown, timer, checkpoints, the finish screen and
improve, not the editor's test run. A map that was never published has no leaderboard, and its runs never go to one.
Only a map whose file says it was never published (levelPublishedFileId -1 or 0); a published map, or a file that
doesn't say, is refused.
False if it can't start; OpenState says why. Requires host 0.26.0.
Example
Tracks::OpenLocal("Map_LevelEditorMain&My Map_AnythingGoes.balledit");
InstallLocalMap¶
int Tracks::InstallLocalMap(const string &in)
Puts a map file that ships in your plugin's folder into the player's own maps folder, where the game opens local maps
from (Tracks::OpenLocal). It copies when the map isn't there yet or your copy is newer; a copy the player edited since
(newer than yours) is kept. Only an editor map file ("Map_LevelEditorMain&"levelPublishedFileId": -1; a file that doesn't say is refused). 1 when copied, 0 when
already there, -1 when not done: OpenState says why (the game may still be starting:
try again a moment later). Requires host 0.26.0.
Example
if (Tracks::InstallLocalMap("maps/Map_LevelEditorMain&My Map_AnythingGoes.balledit") >= 0)
Tracks::OpenLocal("Map_LevelEditorMain&My Map_AnythingGoes.balledit");
InstallLocalMapAs¶
int Tracks::InstallLocalMapAs(const string &in file, const string &in target)
InstallLocalMap for a map file with any name ending in .balledit, installed into the maps folder as target: an
editor map file name ("Map_LevelEditorMain&-, _ and ., so they can't be the map's own file name. The same
answers and rules as InstallLocalMap. Requires host 0.26.1.
Example
if (Tracks::InstallLocalMapAs("maps/my_map.balledit", "Map_LevelEditorMain&My Map_AnythingGoes.balledit") >= 0)
Tracks::OpenLocal("Map_LevelEditorMain&My Map_AnythingGoes.balledit");
LocalFolder¶
string Tracks::LocalFolder()
The game's folder of the player's own saved maps, or "" when the game doesn't have it yet. Requires host 0.26.0.
Example
Log::Info("maps are in " + Tracks::LocalFolder());
OpenLocalList¶
bool Tracks::OpenLocalList(const array<string>@, int)
Races map index of a list of the player's own saved maps, as OpenLocal does, with the list as the game's active
playlist while they are raced, so the game's own "next track" goes on to the next map. The game's own playlist is
active again once the main menu is back. Requires host 0.26.0.
Example
array<string> maps = {"Map_LevelEditorMain&Course 1_AnythingGoes.balledit", "Map_LevelEditorMain&Course 2_AnythingGoes.balledit"};
Tracks::OpenLocalList(maps, 0);