mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
The KeyValues class belongs here. Also reimplemented most loading methods for KeyValues, and adjusted the VPK building code to account for it. Pointers to the engine's implementation of KeyValues have been moved to a separate header ('keyvalues_iface.h'), as this allows external tools code to utilize the standalone KeyValues class implementation. Playlist utilities are completely separated from the KeyValues header; these have nothing to do with KeyValues other than manipulating a global KeyValues object for the playlists, and thus have been named as such and moved to rtech/playlists.
80 lines
2.0 KiB
C++
80 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include "tier1/keyvalues.h"
|
|
#include "vpc/rson.h"
|
|
#include "filesystem/filesystem.h"
|
|
#include "public/vscript/ivscript.h"
|
|
|
|
#define MOD_STATUS_LIST_FILE "mods.vdf"
|
|
#define MOD_SETTINGS_FILE "mod.vdf"
|
|
#define MOD_BASE_DIRECTORY "mods"
|
|
|
|
class CModAppSystemGroup;
|
|
|
|
class CModSystem
|
|
{
|
|
public:
|
|
enum eModState : int8_t
|
|
{
|
|
UNLOADED = -1, // loading was unsuccessful (error occurred)
|
|
LOADING, // if mod is being loaded
|
|
LOADED, // if a mod has been loaded
|
|
DISABLED, // if disabled by user
|
|
ENABLED, // if enabled by user and loaded properly
|
|
};
|
|
|
|
struct ModInstance_t
|
|
{
|
|
ModInstance_t(const CUtlString& basePath);
|
|
~ModInstance_t();
|
|
|
|
bool ParseSettings();
|
|
void ParseConVars();
|
|
void ParseLocalizationFiles();
|
|
|
|
inline void SetState(eModState state) { m_iState = state; };
|
|
|
|
inline bool IsLoaded() const { return m_iState == eModState::LOADED; };
|
|
inline bool IsEnabled() const { return m_iState == eModState::ENABLED; };
|
|
|
|
inline const CUtlString& GetBasePath() const { return m_BasePath; };
|
|
inline CUtlString GetScriptCompileListPath() const { return m_BasePath + GAME_SCRIPT_COMPILELIST; };
|
|
|
|
KeyValues* GetRequiredSettingsKey(const char* settingsPath, const char* key) const;
|
|
|
|
inline RSON::Node_t* LoadScriptCompileList() const
|
|
{
|
|
return RSON::LoadFromFile(GetScriptCompileListPath().Get(), "PLATFORM");
|
|
};
|
|
|
|
KeyValues* m_SettingsKV;
|
|
eModState m_iState = eModState::UNLOADED;
|
|
bool m_bHasScriptCompileList; // if this mod has a scripts.rson file that exists
|
|
|
|
CUtlVector<CUtlString> m_LocalizationFiles;
|
|
|
|
CUtlString m_Name;
|
|
CUtlString m_ModID;
|
|
CUtlString m_Description;
|
|
CUtlString m_Version;
|
|
|
|
CUtlString m_BasePath;
|
|
};
|
|
|
|
~CModSystem();
|
|
|
|
void Init();
|
|
|
|
// load mod enabled/disabled status from file on disk
|
|
void UpdateModStatusList();
|
|
void LoadModStatusList(CUtlMap<CUtlString, bool>& enabledList);
|
|
void WriteModStatusList();
|
|
|
|
const inline CUtlVector<ModInstance_t*>& GetModList() { return m_ModList; };
|
|
|
|
private:
|
|
CUtlVector<ModInstance_t*> m_ModList;
|
|
};
|
|
|
|
extern CModSystem* g_pModSystem;
|