mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add ModMetadata API (#5131)
* mod can create a ModMetadata object where store its values and retrieve it. * Modmetadata object can only be fetched at mod loading * Save when modified using same time as map interval or at server stop * add helper function to get mod storage path * ModMetadata has exactly same calls than all every other Metadata
This commit is contained in:
parent
0680c47d6c
commit
ef6feca501
12 changed files with 384 additions and 12 deletions
21
src/mods.h
21
src/mods.h
|
@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include <map>
|
||||
#include <json/json.h>
|
||||
#include "config.h"
|
||||
#include "metadata.h"
|
||||
|
||||
#define MODNAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyz0123456789_"
|
||||
|
||||
|
@ -205,4 +206,24 @@ struct ModStoreModDetails {
|
|||
bool valid;
|
||||
};
|
||||
|
||||
class ModMetadata: public Metadata
|
||||
{
|
||||
public:
|
||||
ModMetadata(const std::string &mod_name);
|
||||
~ModMetadata() {}
|
||||
|
||||
virtual void clear();
|
||||
|
||||
bool save(const std::string &root_path);
|
||||
bool load(const std::string &root_path);
|
||||
|
||||
bool isModified() const { return m_modified; }
|
||||
const std::string &getModName() const { return m_mod_name; }
|
||||
|
||||
virtual bool setString(const std::string &name, const std::string &var);
|
||||
private:
|
||||
std::string m_mod_name;
|
||||
bool m_modified;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue