added add-on global variables in the same way add-on GMSTs were added

pull/16/head
Marc Zinnschlag 12 years ago
parent 6f5a772d02
commit 868916a9a2

@ -20,6 +20,7 @@ void CSMDoc::Document::load (const std::vector<boost::filesystem::path>::const_i
getData().loadFile (*end2, false);
addOptionalGmsts();
addOptionalGlobals();
}
void CSMDoc::Document::addOptionalGmsts()
@ -139,6 +140,26 @@ void CSMDoc::Document::addOptionalGmsts()
}
}
void CSMDoc::Document::addOptionalGlobals()
{
static const char *sGlobals[] =
{
"dayspassed",
"pcwerewolf",
"pcyear",
0
};
for (int i=0; sGlobals[i]; ++i)
{
ESM::Global global;
global.mId = sGlobals[i];
global.mType = ESM::VT_Int;
global.mValue = 0;
addOptionalGlobal (global);
}
}
void CSMDoc::Document::addOptionalGmst (const ESM::GameSetting& gmst)
{
if (getData().getGmsts().searchId (gmst.mId)==-1)
@ -150,6 +171,17 @@ void CSMDoc::Document::addOptionalGmst (const ESM::GameSetting& gmst)
}
}
void CSMDoc::Document::addOptionalGlobal (const ESM::Global& global)
{
if (getData().getGlobals().searchId (global.mId)==-1)
{
CSMWorld::Record<ESM::Global> record;
record.mBase = global;
record.mState = CSMWorld::RecordBase::State_BaseOnly;
getData().getGlobals().appendRecord (record);
}
}
void CSMDoc::Document::createBase()
{
static const char *sGlobals[] =

@ -20,6 +20,7 @@ class QAbstractItemModel;
namespace ESM
{
struct GameSetting;
struct Global;
}
namespace CSMDoc
@ -53,8 +54,12 @@ namespace CSMDoc
void addOptionalGmsts();
void addOptionalGlobals();
void addOptionalGmst (const ESM::GameSetting& gmst);
void addOptionalGlobal (const ESM::Global& global);
public:
Document (const std::vector<boost::filesystem::path>& files, bool new_);

Loading…
Cancel
Save