1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-25 17:53:47 +00:00
Aquaria/Aquaria/Mod.h
fgenesis 3b759294df Add support for mod script compatibility layers
This uses a new <Compatibility script="..." /> tag in a mod's XML file.
A compatbility layer is a script that runs before mod-init.lua is loaded,
and before any mod scripts are loaded when resuming a saved game.

This is a better solution than shipping a fragile wrapper
with every mod, that tends to break and then needs to be updated.
Now this wrapper is centralized, easy to use, and easy to update.

Closes #31.
2017-01-21 02:06:44 +01:00

82 lines
1.2 KiB
C++

#ifndef AQUARIA_MOD_H
#define AQUARIA_MOD_H
#include "GameEnums.h"
#include "Precacher.h"
namespace tinyxml2
{
class XMLDocument;
class XMLElement;
}
enum ModType
{
MODTYPE_MOD,
MODTYPE_PATCH
};
struct ModEntry
{
unsigned int id; // index in vector
ModType type;
std::string path;
};
class ModSelectorScreen;
class Mod
{
public:
Mod();
~Mod();
void clear();
void setActive(bool v);
void start();
void stop();
void load(const std::string &path);
bool loadSavedGame(const std::string& path);
void update(float dt);
void recache();
const std::string& getBaseModPath() const;
bool isActive();
bool isDebugMenu();
bool hasWorldMap();
bool isEditorBlocked();
const std::string& getPath() const;
const std::string& getName() const;
void shutdown();
bool isShuttingDown();
static bool loadModXML(tinyxml2::XMLDocument *d, std::string modName);
static ModType getTypeFromXML(tinyxml2::XMLElement *xml);
WorldMapRevealMethod mapRevealMethod;
protected:
bool loadCompatScript();
bool shuttingDown;
bool active;
bool hasMap;
bool blockEditor;
int doRecache;
int debugMenu;
int enqueueModStart;
void applyStart();
std::string name;
std::string path;
Precacher modcache;
std::string compatScript;
};
#endif