Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
Mod Class Reference

#include <Mod.h>

Classes

struct  ModData
 Parsed mod.json data for C++ usage. More...
 

Public Member Functions

const std::vector< CStr > & GetEnabledMods () const
 
const std::vector< CStr > & GetIncompatibleMods () const
 
const std::vector< ModData > & GetAvailableMods () const
 
void UpdateAvailableMods (const ScriptInterface &scriptInterface)
 Fetches available mods and stores some metadata about them. More...
 
bool EnableMods (const std::vector< CStr > &mods, const bool addPublic)
 Enables specified mods (& mods required by the engine). More...
 
const ModDataGetModData (const CStr &mod) const
 Get data for the given mod. More...
 
const std::vector< const Mod::ModData * > GetEnabledModsData () const
 Get a list of the enabled mod's data (intended for compatibility checks). More...
 

Static Public Member Functions

static ModInstance ()
 
static bool AreModsPlayCompatible (const std::vector< const Mod::ModData * > &modsA, const std::vector< const Mod::ModData * > &modsB)
 

Private Member Functions

std::vector< CStr > CheckForIncompatibleMods (const std::vector< CStr > &mods) const
 Checks a list of mods and returns the incompatible mods, if any. More...
 
bool CompareVersionStrings (const CStr &required, const CStr &op, const CStr &version) const
 

Private Attributes

std::vector< CStr > m_EnabledMods
 
std::vector< CStr > m_IncompatibleMods
 
std::vector< ModDatam_AvailableMods
 

Friends

class TestMod
 

Member Function Documentation

◆ AreModsPlayCompatible()

bool Mod::AreModsPlayCompatible ( const std::vector< const Mod::ModData * > &  modsA,
const std::vector< const Mod::ModData * > &  modsB 
)
static
Returns
whether the two lists are compatible for replaying / MP play.

◆ CheckForIncompatibleMods()

std::vector< CStr > Mod::CheckForIncompatibleMods ( const std::vector< CStr > &  mods) const
private

Checks a list of mods and returns the incompatible mods, if any.

◆ CompareVersionStrings()

bool Mod::CompareVersionStrings ( const CStr &  required,
const CStr &  op,
const CStr &  version 
) const
private

◆ EnableMods()

bool Mod::EnableMods ( const std::vector< CStr > &  mods,
const bool  addPublic 
)

Enables specified mods (& mods required by the engine).

Parameters
addPublic- if true, enable the public mod.
Returns
whether the mods were enabled successfully. This can fail if e.g. mods are incompatible. If true, GetEnabledMods() should be non-empty, GetIncompatibleMods() empty. Otherwise, GetIncompatibleMods() is non-empty.

◆ GetAvailableMods()

const std::vector< Mod::ModData > & Mod::GetAvailableMods ( ) const

◆ GetEnabledMods()

const std::vector< CStr > & Mod::GetEnabledMods ( ) const

◆ GetEnabledModsData()

const std::vector< const Mod::ModData * > Mod::GetEnabledModsData ( ) const

Get a list of the enabled mod's data (intended for compatibility checks).

"user" mod and "mod" mod are ignored as they are irrelevant for compatibility checks.

◆ GetIncompatibleMods()

const std::vector< CStr > & Mod::GetIncompatibleMods ( ) const

◆ GetModData()

const Mod::ModData * Mod::GetModData ( const CStr &  mod) const

Get data for the given mod.

Parameters
themod path name (e.g. 'public')
Returns
the mod data or nullptr if unavailable. TODO: switch to std::optional or something related.

◆ Instance()

Mod & Mod::Instance ( )
static

◆ UpdateAvailableMods()

void Mod::UpdateAvailableMods ( const ScriptInterface scriptInterface)

Fetches available mods and stores some metadata about them.

This may open the zipped mod archives, depending on the situation, and/or try to write files to the user mod folder, which can be quite slow, so should be run rarely. TODO: if this did not need the scriptInterface to parse JSON, we could run it in different contexts and possibly cleaner.

Friends And Related Function Documentation

◆ TestMod

friend class TestMod
friend

Member Data Documentation

◆ m_AvailableMods

std::vector<ModData> Mod::m_AvailableMods
private

◆ m_EnabledMods

std::vector<CStr> Mod::m_EnabledMods
private

◆ m_IncompatibleMods

std::vector<CStr> Mod::m_IncompatibleMods
private

The documentation for this class was generated from the following files: