mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
basic gmst support
This commit is contained in:
parent
dd2b7d5c63
commit
d5dd0640c7
9 changed files with 58 additions and 7 deletions
|
@ -28,7 +28,13 @@ CSMWorld::Data::Data()
|
|||
mGlobals.addColumn (new FixedRecordTypeColumn<ESM::Global> (UniversalId::Type_Global));
|
||||
mGlobals.addColumn (new FloatValueColumn<ESM::Global>);
|
||||
|
||||
mGmsts.addColumn (new StringIdColumn<ESM::GameSetting>);
|
||||
mGmsts.addColumn (new RecordStateColumn<ESM::GameSetting>);
|
||||
mGmsts.addColumn (new FixedRecordTypeColumn<ESM::GameSetting> (UniversalId::Type_Gmst));
|
||||
///< \todo add type and value
|
||||
|
||||
addModel (new IdTable (&mGlobals), UniversalId::Type_Globals, UniversalId::Type_Global);
|
||||
addModel (new IdTable (&mGmsts), UniversalId::Type_Gmsts, UniversalId::Type_Gmst);
|
||||
}
|
||||
|
||||
CSMWorld::Data::~Data()
|
||||
|
@ -78,6 +84,7 @@ void CSMWorld::Data::loadFile (const boost::filesystem::path& path, bool base)
|
|||
switch (n.val)
|
||||
{
|
||||
case ESM::REC_GLOB: mGlobals.load (reader, base); break;
|
||||
case ESM::REC_GMST: mGmsts.load (reader, base); break;
|
||||
|
||||
|
||||
default:
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <components/esm/loadglob.hpp>
|
||||
#include <components/esm/loadgmst.hpp>
|
||||
|
||||
#include "idcollection.hpp"
|
||||
#include "universalid.hpp"
|
||||
|
@ -18,6 +19,7 @@ namespace CSMWorld
|
|||
class Data
|
||||
{
|
||||
IdCollection<ESM::Global> mGlobals;
|
||||
IdCollection<ESM::GameSetting> mGmsts;
|
||||
std::vector<QAbstractTableModel *> mModels;
|
||||
std::map<UniversalId::Type, QAbstractTableModel *> mModelIndex;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace
|
|||
{
|
||||
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, "empty" },
|
||||
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Globals, "Global Variables" },
|
||||
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Gmsts, "Game Settings" },
|
||||
|
||||
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
|
||||
};
|
||||
|
@ -25,6 +26,7 @@ namespace
|
|||
static const TypeData sIdArg[] =
|
||||
{
|
||||
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Global, "Global Variable" },
|
||||
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Gmst, "Game Setting" },
|
||||
|
||||
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
|
||||
};
|
||||
|
|
|
@ -33,12 +33,12 @@ namespace CSMWorld
|
|||
enum Type
|
||||
{
|
||||
Type_None,
|
||||
|
||||
Type_Globals,
|
||||
|
||||
Type_Global,
|
||||
Type_VerificationResults,
|
||||
Type_Gmsts,
|
||||
Type_Gmst
|
||||
|
||||
Type_VerificationResults
|
||||
};
|
||||
|
||||
private:
|
||||
|
|
|
@ -71,6 +71,10 @@ void CSVDoc::View::setupWorldMenu()
|
|||
connect (globals, SIGNAL (triggered()), this, SLOT (addGlobalsSubView()));
|
||||
world->addAction (globals);
|
||||
|
||||
QAction *gmsts = new QAction (tr ("Game settings"), this);
|
||||
connect (gmsts, SIGNAL (triggered()), this, SLOT (addGmstsSubView()));
|
||||
world->addAction (gmsts);
|
||||
|
||||
mVerify = new QAction (tr ("&Verify"), this);
|
||||
connect (mVerify, SIGNAL (triggered()), this, SLOT (verify()));
|
||||
world->addAction (mVerify);
|
||||
|
@ -217,4 +221,9 @@ void CSVDoc::View::verify()
|
|||
void CSVDoc::View::addGlobalsSubView()
|
||||
{
|
||||
addSubView (CSMWorld::UniversalId::Type_Globals);
|
||||
}
|
||||
|
||||
void CSVDoc::View::addGmstsSubView()
|
||||
{
|
||||
addSubView (CSMWorld::UniversalId::Type_Gmsts);
|
||||
}
|
|
@ -99,6 +99,8 @@ namespace CSVDoc
|
|||
void verify();
|
||||
|
||||
void addGlobalsSubView();
|
||||
|
||||
void addGmstsSubView();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
|
|||
manager.add (CSMWorld::UniversalId::Type_Globals,
|
||||
new CSVDoc::SubViewFactoryWithCreateFlag<TableSubView> (true));
|
||||
|
||||
manager.add (CSMWorld::UniversalId::Type_Gmsts,
|
||||
new CSVDoc::SubViewFactoryWithCreateFlag<TableSubView> (false));
|
||||
|
||||
manager.add (CSMWorld::UniversalId::Type_Global,
|
||||
new CSVDoc::SubViewFactoryWithCreateFlag<DialogueSubView> (true));
|
||||
}
|
|
@ -76,8 +76,29 @@ std::string GameSetting::getString() const
|
|||
{
|
||||
if (mType==VT_String)
|
||||
return mStr;
|
||||
|
||||
|
||||
throw std::runtime_error ("GMST " + mId + " is not a string");
|
||||
}
|
||||
|
||||
void GameSetting::blank()
|
||||
{
|
||||
mStr.clear();
|
||||
mI = 0;
|
||||
mF = 0;
|
||||
mType = VT_Float;
|
||||
}
|
||||
|
||||
bool operator== (const GameSetting& left, const GameSetting& right)
|
||||
{
|
||||
if (left.mType!=right.mType)
|
||||
return false;
|
||||
|
||||
switch (left.mType)
|
||||
{
|
||||
case VT_Float: return left.mF==right.mF;
|
||||
case VT_Int: return left.mI==right.mI;
|
||||
case VT_String: return left.mStr==right.mStr;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,17 +26,22 @@ struct GameSetting
|
|||
VarType mType;
|
||||
|
||||
void load(ESMReader &esm);
|
||||
|
||||
|
||||
int getInt() const;
|
||||
///< Throws an exception if GMST is not of type int or float.
|
||||
|
||||
|
||||
float getFloat() const;
|
||||
///< Throws an exception if GMST is not of type int or float.
|
||||
|
||||
|
||||
std::string getString() const;
|
||||
///< Throwns an exception if GMST is not of type string.
|
||||
|
||||
void save(ESMWriter &esm);
|
||||
|
||||
void blank();
|
||||
///< Set record to default state (does not touch the ID).
|
||||
};
|
||||
|
||||
bool operator== (const GameSetting& left, const GameSetting& right);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue