added faction table

pull/16/head
Marc Zinnschlag 12 years ago
parent 26db983599
commit c71edb613d

@ -57,10 +57,15 @@ CSMWorld::Data::Data()
mClasses.addColumn (new PlayableColumn<ESM::Class>);
mClasses.addColumn (new DescriptionColumn<ESM::Class>);
mFactions.addColumn (new StringIdColumn<ESM::Faction>);
mFactions.addColumn (new RecordStateColumn<ESM::Faction>);
mFactions.addColumn (new NameColumn<ESM::Faction>);
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);
addModel (new IdTable (&mClasses), UniversalId::Type_Classes, UniversalId::Type_Class);
addModel (new IdTable (&mFactions), UniversalId::Type_Factions, UniversalId::Type_Faction);
}
CSMWorld::Data::~Data()
@ -99,6 +104,16 @@ CSMWorld::IdCollection<ESM::Skill>& CSMWorld::Data::getSkills()
return mSkills;
}
const CSMWorld::IdCollection<ESM::Faction>& CSMWorld::Data::getFactions() const
{
return mFactions;
}
CSMWorld::IdCollection<ESM::Faction>& CSMWorld::Data::getFactions()
{
return mFactions;
}
QAbstractItemModel *CSMWorld::Data::getTableModel (const UniversalId& id)
{
std::map<UniversalId::Type, QAbstractItemModel *>::iterator iter = mModelIndex.find (id.getType());
@ -137,6 +152,7 @@ void CSMWorld::Data::loadFile (const boost::filesystem::path& path, bool base)
case ESM::REC_GMST: mGmsts.load (reader, base); break;
case ESM::REC_SKIL: mSkills.load (reader, base); break;
case ESM::REC_CLAS: mClasses.load (reader, base); break;
case ESM::REC_FACT: mFactions.load (reader, base); break;
default:

@ -10,6 +10,7 @@
#include <components/esm/loadgmst.hpp>
#include <components/esm/loadskil.hpp>
#include <components/esm/loadclas.hpp>
#include <components/esm/loadfact.hpp>
#include "idcollection.hpp"
#include "universalid.hpp"
@ -24,6 +25,7 @@ namespace CSMWorld
IdCollection<ESM::GameSetting> mGmsts;
IdCollection<ESM::Skill> mSkills;
IdCollection<ESM::Class> mClasses;
IdCollection<ESM::Faction> mFactions;
std::vector<QAbstractItemModel *> mModels;
std::map<UniversalId::Type, QAbstractItemModel *> mModelIndex;
@ -52,6 +54,10 @@ namespace CSMWorld
IdCollection<ESM::Skill>& getSkills();
const IdCollection<ESM::Faction>& getFactions() const;
IdCollection<ESM::Faction>& getFactions();
QAbstractItemModel *getTableModel (const UniversalId& id);
///< If no table model is available for \a id, an exception is thrown.
///

@ -21,6 +21,7 @@ namespace
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Gmsts, "Game Settings" },
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Skills, "Skills" },
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Classes, "Classes" },
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Factions, "Factions" },
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
};
@ -31,6 +32,7 @@ namespace
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Gmst, "Game Setting" },
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Skill, "Skill" },
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Class, "Class" },
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Faction, "Faction" },
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
};

@ -41,7 +41,9 @@ namespace CSMWorld
Type_Skills,
Type_Skill,
Type_Classes,
Type_Class
Type_Class,
Type_Factions,
Type_Faction
};
private:

@ -94,6 +94,10 @@ void CSVDoc::View::setupWorldMenu()
connect (classes, SIGNAL (triggered()), this, SLOT (addClassesSubView()));
world->addAction (classes);
QAction *factions = new QAction (tr ("Factions"), this);
connect (factions, SIGNAL (triggered()), this, SLOT (addFactionsSubView()));
world->addAction (factions);
mVerify = new QAction (tr ("&Verify"), this);
connect (mVerify, SIGNAL (triggered()), this, SLOT (verify()));
world->addAction (mVerify);
@ -262,6 +266,11 @@ void CSVDoc::View::addClassesSubView()
addSubView (CSMWorld::UniversalId::Type_Classes);
}
void CSVDoc::View::addFactionsSubView()
{
addSubView (CSMWorld::UniversalId::Type_Factions);
}
void CSVDoc::View::abortOperation (int type)
{
mDocument->abortOperation (type);

@ -119,6 +119,8 @@ namespace CSVDoc
void addSkillsSubView();
void addClassesSubView();
void addFactionsSubView();
};
}

@ -20,6 +20,9 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
manager.add (CSMWorld::UniversalId::Type_Classes,
new CSVDoc::SubViewFactoryWithCreateFlag<TableSubView> (true));
manager.add (CSMWorld::UniversalId::Type_Factions,
new CSVDoc::SubViewFactoryWithCreateFlag<TableSubView> (true));
// manager.add (CSMWorld::UniversalId::Type_Global,
// new CSVDoc::SubViewFactoryWithCreateFlag<DialogueSubView> (true));
}

@ -33,7 +33,7 @@ void Faction::load(ESMReader &esm)
void Faction::save(ESMWriter &esm)
{
esm.writeHNCString("FNAM", mName);
for (int i = 0; i < 10; i++)
{
if (mRanks[i].empty())
@ -43,7 +43,7 @@ void Faction::save(ESMWriter &esm)
}
esm.writeHNT("FADT", mData, 240);
for (std::vector<Reaction>::iterator it = mReactions.begin(); it != mReactions.end(); ++it)
{
esm.writeHNString("ANAM", it->mFaction);
@ -51,4 +51,25 @@ void Faction::save(ESMWriter &esm)
}
}
void Faction::blank()
{
mName.clear();
mData.mAttribute1 = mData.mAttribute2 = 0;
mData.mUnknown = -1;
mData.mIsHidden = 0;
for (int i=0; i<10; ++i)
{
mData.mRankData[i].mAttribute1 = mData.mRankData[i].mAttribute2 = 0;
mData.mRankData[i].mSkill1 = mData.mRankData[i].mSkill2 = 0;
mData.mRankData[i].mFactReaction = 0;
mRanks[i].clear();
}
for (int i=0; i<6; ++i)
mData.mSkillID[i] = 0;
mReactions.clear();
}
}

@ -58,6 +58,9 @@ struct Faction
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