added basic region table

pull/16/head
Marc Zinnschlag 12 years ago
parent ff1d908af4
commit e25f5c6dfe

@ -87,6 +87,10 @@ CSMWorld::Data::Data()
mScripts.addColumn (new StringIdColumn<ESM::Script>);
mScripts.addColumn (new RecordStateColumn<ESM::Script>);
mRegions.addColumn (new StringIdColumn<ESM::Region>);
mRegions.addColumn (new RecordStateColumn<ESM::Region>);
mRegions.addColumn (new NameColumn<ESM::Region>);
addModel (new IdTable (&mGlobals), UniversalId::Type_Globals, UniversalId::Type_Global);
addModel (new IdTable (&mGmsts), UniversalId::Type_Gmsts, UniversalId::Type_Gmst);
addModel (new IdTable (&mSkills), UniversalId::Type_Skills, UniversalId::Type_Skill);
@ -95,6 +99,7 @@ CSMWorld::Data::Data()
addModel (new IdTable (&mRaces), UniversalId::Type_Races, UniversalId::Type_Race);
addModel (new IdTable (&mSounds), UniversalId::Type_Sounds, UniversalId::Type_Sound);
addModel (new IdTable (&mScripts), UniversalId::Type_Scripts, UniversalId::Type_Script);
addModel (new IdTable (&mRegions), UniversalId::Type_Regions, UniversalId::Type_Region);
}
CSMWorld::Data::~Data()
@ -183,6 +188,16 @@ CSMWorld::IdCollection<ESM::Script>& CSMWorld::Data::getScripts()
return mScripts;
}
const CSMWorld::IdCollection<ESM::Region>& CSMWorld::Data::getRegions() const
{
return mRegions;
}
CSMWorld::IdCollection<ESM::Region>& CSMWorld::Data::getRegions()
{
return mRegions;
}
QAbstractItemModel *CSMWorld::Data::getTableModel (const UniversalId& id)
{
std::map<UniversalId::Type, QAbstractItemModel *>::iterator iter = mModelIndex.find (id.getType());
@ -225,6 +240,7 @@ void CSMWorld::Data::loadFile (const boost::filesystem::path& path, bool base)
case ESM::REC_RACE: mRaces.load (reader, base); break;
case ESM::REC_SOUN: mSounds.load (reader, base); break;
case ESM::REC_SCPT: mScripts.load (reader, base); break;
case ESM::REC_REGN: mRegions.load (reader, base); break;
default:

@ -14,6 +14,7 @@
#include <components/esm/loadrace.hpp>
#include <components/esm/loadsoun.hpp>
#include <components/esm/loadscpt.hpp>
#include <components/esm/loadregn.hpp>
#include "idcollection.hpp"
#include "universalid.hpp"
@ -32,6 +33,7 @@ namespace CSMWorld
IdCollection<ESM::Race> mRaces;
IdCollection<ESM::Sound> mSounds;
IdCollection<ESM::Script> mScripts;
IdCollection<ESM::Region> mRegions;
std::vector<QAbstractItemModel *> mModels;
std::map<UniversalId::Type, QAbstractItemModel *> mModelIndex;
@ -80,6 +82,10 @@ namespace CSMWorld
IdCollection<ESM::Script>& getScripts();
const IdCollection<ESM::Region>& getRegions() const;
IdCollection<ESM::Region>& getRegions();
QAbstractItemModel *getTableModel (const UniversalId& id);
///< If no table model is available for \a id, an exception is thrown.
///

@ -25,6 +25,7 @@ namespace
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Races, "Races" },
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Sounds, "Sounds" },
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Scripts, "Scripts" },
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Regions, "Regions" },
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
};
@ -39,6 +40,7 @@ namespace
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Race, "Race" },
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Sound, "Sound" },
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Script, "Script" },
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Region, "Region" },
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
};

@ -49,7 +49,9 @@ namespace CSMWorld
Type_Sounds,
Type_Sound,
Type_Scripts,
Type_Script
Type_Script,
Type_Regions,
Type_Region
};
private:

@ -113,6 +113,10 @@ void CSVDoc::View::setupWorldMenu()
QAction *scripts = new QAction (tr ("Scripts"), this);
connect (scripts, SIGNAL (triggered()), this, SLOT (addScriptsSubView()));
world->addAction (scripts);
QAction *regions = new QAction (tr ("Regions"), this);
connect (regions, SIGNAL (triggered()), this, SLOT (addRegionsSubView()));
world->addAction (regions);
}
void CSVDoc::View::setupUi()
@ -298,6 +302,11 @@ void CSVDoc::View::addScriptsSubView()
addSubView (CSMWorld::UniversalId::Type_Scripts);
}
void CSVDoc::View::addRegionsSubView()
{
addSubView (CSMWorld::UniversalId::Type_Regions);
}
void CSVDoc::View::abortOperation (int type)
{
mDocument->abortOperation (type);

@ -127,6 +127,8 @@ namespace CSVDoc
void addSoundsSubView();
void addScriptsSubView();
void addRegionsSubView();
};
}

@ -22,6 +22,7 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
CSMWorld::UniversalId::Type_Races,
CSMWorld::UniversalId::Type_Sounds,
CSMWorld::UniversalId::Type_Scripts,
CSMWorld::UniversalId::Type_Regions,
CSMWorld::UniversalId::Type_None // end marker
};

@ -31,14 +31,14 @@ void Region::load(ESMReader &esm)
void Region::save(ESMWriter &esm)
{
esm.writeHNCString("FNAM", mName);
if (esm.getVersion() == VER_12)
esm.writeHNT("WEAT", mData, sizeof(mData) - 2);
else
esm.writeHNT("WEAT", mData);
esm.writeHNOCString("BNAM", mSleepList);
esm.writeHNT("CNAM", mMapColor);
for (std::vector<SoundRef>::iterator it = mSoundList.begin(); it != mSoundList.end(); ++it)
{
@ -46,4 +46,17 @@ void Region::save(ESMWriter &esm)
}
}
void Region::blank()
{
mName.clear();
mData.mClear = mData.mCloudy = mData.mFoggy = mData.mOvercast = mData.mRain =
mData.mThunder = mData.mAsh, mData.mBlight = mData.mA = mData.mB = 0;
mMapColor = 0;
mName.clear();
mSleepList.clear();
mSoundList.clear();
}
}

@ -48,6 +48,9 @@ struct Region
void load(ESMReader &esm);
void save(ESMWriter &esm);
void blank();
///< Set record to default state (does not touch the ID/index).
};
}
#endif

Loading…
Cancel
Save