Jazz2::LevelPacks::LevelPackLibrary class

Installed level packs.

The original files of all packs are stored once in Files of ContentResolver::GetLevelPacksPath(), named <name>~<hash>.<extension> by their content, so a file that more packs have is there only once. A file that's the same as the one of the original game isn't stored at all. A stored file is deleted once no pack has it anymore. The levels are converted into ContentResolver::GetLevelPacksCachePath(), they're named +<id>/<level>, or +<id>_<episode>/<level> for a level of an episode of the pack, and they're converted again whenever the cache is rebuilt.

Installing, removing and converting may run on a thread of its own, one at a time.

Public static functions

static auto Get() -> LevelPackLibrary&
Returns the library.
static auto GetPackId(StringView name) -> StringView
Returns the identifier of the pack from a level or an episode name of the form +<id>....
static auto GetResultDescription(LevelPackResult result) -> StringView
Returns a description of a result for messages.

Constructors, destructors, conversion operators

LevelPackLibrary(const LevelPackLibrary&) deleted

Public functions

auto operator=(const LevelPackLibrary&) -> LevelPackLibrary& deleted
void Refresh()
Reads the records of the installed packs again.
auto GetPacks() -> SmallVector<std::shared_ptr<const LevelPackManifest>, 0>
Returns the installed packs, sorted by title.
auto FindPack(StringView id) -> std::shared_ptr<const LevelPackManifest>
Returns an installed pack by its identifier.
auto FindPackOfLevel(StringView levelName) -> std::shared_ptr<const LevelPackManifest>
Returns the installed pack a level of the form +<id>/<level> belongs to.
auto Install(StringView archivePath, const LevelPackInfo& info, Compatibility::ConversionProgress progress = {}, const std::atomic<bool>* cancel = nullptr, String* installedId = nullptr) -> LevelPackResult
Installs a pack from a ZIP archive, or installs it again if it's installed already.
auto Remove(StringView id) -> LevelPackResult
Removes a pack and every file only it had, on the main thread, it changes the preferences.
auto ReconvertStale(Compatibility::ConversionProgress progress = {}) -> std::int32_t
Converts packs whose levels were converted by another version of the converter or are gone, returns how many.
void CleanUp()
Removes what an interrupted operation left behind and files no pack has.
auto FindOriginalFile(StringView levelName, StringView fileName) -> String
Returns the full path of an original file of the pack a level belongs to.
auto FindTileSet(StringView levelName, StringView tileSetName) -> String
Returns the name a tile set of the pack a level belongs to was converted to.

Function documentation

LevelPackResult Jazz2::LevelPacks::LevelPackLibrary::Install(StringView archivePath, const LevelPackInfo& info, Compatibility::ConversionProgress progress = {}, const std::atomic<bool>* cancel = nullptr, String* installedId = nullptr)

Installs a pack from a ZIP archive, or installs it again if it's installed already.

Parameters
archivePath The archive
info What is known about the pack
progress Reports how far it has got
cancel Cancels it once set, can be nullptr
installedId Receives the identifier of the pack, can be nullptr

String Jazz2::LevelPacks::LevelPackLibrary::FindOriginalFile(StringView levelName, StringView fileName)

Returns the full path of an original file of the pack a level belongs to.

For scripts of a pack, which load files by their original name. Returns an empty string if the level isn't of a pack, or the pack has no such file.

String Jazz2::LevelPacks::LevelPackLibrary::FindTileSet(StringView levelName, StringView tileSetName)

Returns the name a tile set of the pack a level belongs to was converted to.

For scripts of a pack, which name tile sets by their original name. Returns an empty string if the level isn't of a pack, or the pack has no such tile set.