2010-07-04 10:43:34 +02:00
|
|
|
#ifndef GAME_SCRIPT_GLOBALSCRIPTS_H
|
|
|
|
#define GAME_SCRIPT_GLOBALSCRIPTS_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
|
2014-03-05 17:08:58 +01:00
|
|
|
#include <stdint.h>
|
2013-12-15 16:16:50 +01:00
|
|
|
|
2010-07-04 10:43:34 +02:00
|
|
|
#include "locals.hpp"
|
|
|
|
|
2013-12-15 16:16:50 +01:00
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
class ESMWriter;
|
|
|
|
class ESMReader;
|
|
|
|
}
|
|
|
|
|
2014-04-28 11:29:57 +02:00
|
|
|
namespace Loading
|
|
|
|
{
|
|
|
|
class Listener;
|
|
|
|
}
|
|
|
|
|
2013-12-12 13:15:38 +01:00
|
|
|
namespace MWWorld
|
2010-07-04 10:43:34 +02:00
|
|
|
{
|
|
|
|
struct ESMStore;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWScript
|
|
|
|
{
|
2014-07-15 12:59:02 +02:00
|
|
|
struct GlobalScriptDesc
|
|
|
|
{
|
|
|
|
bool mRunning;
|
|
|
|
Locals mLocals;
|
|
|
|
std::string mId; // ID used to start targeted script (empty if not a targeted script)
|
|
|
|
|
|
|
|
GlobalScriptDesc();
|
|
|
|
};
|
|
|
|
|
2010-07-04 10:43:34 +02:00
|
|
|
class GlobalScripts
|
|
|
|
{
|
2012-10-01 19:17:04 +04:00
|
|
|
const MWWorld::ESMStore& mStore;
|
2014-07-15 12:59:02 +02:00
|
|
|
std::map<std::string, GlobalScriptDesc> mScripts;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2010-07-04 10:43:34 +02:00
|
|
|
public:
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2012-10-01 19:17:04 +04:00
|
|
|
GlobalScripts (const MWWorld::ESMStore& store);
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2014-07-15 13:26:04 +02:00
|
|
|
void addScript (const std::string& name, const std::string& targetId = "");
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2010-07-04 16:00:32 +02:00
|
|
|
void removeScript (const std::string& name);
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2010-07-04 16:00:32 +02:00
|
|
|
bool isRunning (const std::string& name) const;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
|
|
|
void run();
|
2010-07-04 16:00:32 +02:00
|
|
|
///< run all active global scripts
|
2013-12-12 13:15:38 +01:00
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
void addStartup();
|
|
|
|
///< Add startup script
|
2013-12-15 16:16:50 +01:00
|
|
|
|
|
|
|
int countSavedGameRecords() const;
|
|
|
|
|
2014-04-28 11:29:57 +02:00
|
|
|
void write (ESM::ESMWriter& writer, Loading::Listener& progress) const;
|
2013-12-15 16:16:50 +01:00
|
|
|
|
|
|
|
bool readRecord (ESM::ESMReader& reader, int32_t type);
|
|
|
|
///< Records for variables that do not exist are dropped silently.
|
|
|
|
///
|
|
|
|
/// \return Known type?
|
2014-02-10 14:45:55 +01:00
|
|
|
|
|
|
|
Locals& getLocals (const std::string& name);
|
|
|
|
///< If the script \a name has not been added as a global script yet, it is added
|
|
|
|
/// automatically, but is not set to running state.
|
2010-07-04 10:43:34 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|