first attempt at an info record collection

actorid
Marc Zinnschlag 11 years ago
parent 45f5a66bcc
commit ba88c94d58

@ -24,7 +24,7 @@ opencs_units (model/world
opencs_units_noqt (model/world
universalid record commands columnbase scriptcontext cell refidcollection
refidadapter refiddata refidadapterimp ref collectionbase refcollection columns
refidadapter refiddata refidadapterimp ref collectionbase refcollection columns infocollection
)
opencs_hdrs_noqt (model/world

@ -149,6 +149,12 @@ CSMWorld::Data::Data() : mRefs (mCells)
mJournals.addColumn (new RecordStateColumn<ESM::Dialogue>);
mJournals.addColumn (new DialogueTypeColumn<ESM::Dialogue> (true));
mTopicInfos.addColumn (new StringIdColumn<ESM::DialInfo>);
mTopicInfos.addColumn (new RecordStateColumn<ESM::DialInfo>);
mJournalInfos.addColumn (new StringIdColumn<ESM::DialInfo>);
mJournalInfos.addColumn (new RecordStateColumn<ESM::DialInfo>);
mCells.addColumn (new StringIdColumn<Cell>);
mCells.addColumn (new RecordStateColumn<Cell>);
mCells.addColumn (new FixedRecordTypeColumn<Cell> (UniversalId::Type_Cell));
@ -206,6 +212,8 @@ CSMWorld::Data::Data() : mRefs (mCells)
addModel (new IdTable (&mSpells), UniversalId::Type_Spells, UniversalId::Type_Spell);
addModel (new IdTable (&mTopics), UniversalId::Type_Topics, UniversalId::Type_Topic);
addModel (new IdTable (&mJournals), UniversalId::Type_Journals, UniversalId::Type_Journal);
addModel (new IdTable (&mTopicInfos), UniversalId::Type_TopicInfos, UniversalId::Type_TopicInfo);
addModel (new IdTable (&mJournalInfos), UniversalId::Type_JournalInfos, UniversalId::Type_JournalInfo);
addModel (new IdTable (&mCells), UniversalId::Type_Cells, UniversalId::Type_Cell);
addModel (new IdTable (&mReferenceables), UniversalId::Type_Referenceables,
UniversalId::Type_Referenceable);
@ -350,6 +358,25 @@ CSMWorld::IdCollection<ESM::Dialogue>& CSMWorld::Data::getJournals()
return mJournals;
}
const CSMWorld::InfoCollection& CSMWorld::Data::getTopicInfos() const
{
return mTopicInfos;
}
CSMWorld::InfoCollection& CSMWorld::Data::getTopicInfos()
{
return mTopicInfos;
}
const CSMWorld::InfoCollection& CSMWorld::Data::getJournalInfos() const
{
return mJournalInfos;
}
CSMWorld::InfoCollection& CSMWorld::Data::getJournalInfos()
{
return mJournalInfos;
}
const CSMWorld::IdCollection<CSMWorld::Cell>& CSMWorld::Data::getCells() const
{
@ -514,6 +541,13 @@ void CSMWorld::Data::loadFile (const boost::filesystem::path& path, bool base)
break;
}
case ESM::REC_INFO:
{
/// \todo associate info record with last loaded dialogue record
mJournalInfos.load (reader, base);
break;
}
default:
/// \todo throw an exception instead, once all records are implemented

@ -29,6 +29,7 @@
#include "cell.hpp"
#include "refidcollection.hpp"
#include "refcollection.hpp"
#include "infocollection.hpp"
class QAbstractItemModel;
@ -51,6 +52,8 @@ namespace CSMWorld
IdCollection<ESM::Spell> mSpells;
IdCollection<ESM::Dialogue> mTopics;
IdCollection<ESM::Dialogue> mJournals;
InfoCollection mTopicInfos;
InfoCollection mJournalInfos;
IdCollection<Cell> mCells;
RefIdCollection mReferenceables;
RefCollection mRefs;
@ -127,6 +130,14 @@ namespace CSMWorld
IdCollection<ESM::Dialogue>& getJournals();
const InfoCollection& getTopicInfos() const;
InfoCollection& getTopicInfos();
const InfoCollection& getJournalInfos() const;
InfoCollection& getJournalInfos();
const IdCollection<Cell>& getCells() const;
IdCollection<Cell>& getCells();

@ -0,0 +1,72 @@
#include "infocollection.hpp"
#include <components/esm/esmreader.hpp>
void CSMWorld::InfoCollection::load (const ESM::DialInfo& record, bool base)
{
int index = searchId (record.mId);
if (index==-1)
{
// new record
Record<ESM::DialInfo> record2;
record2.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
(base ? record2.mBase : record2.mModified) = record;
appendRecord (record2);
}
else
{
// old record
Record<ESM::DialInfo> record2 = getRecord (index);
if (base)
record2.mBase = record;
else
record2.setModified (record);
setRecord (index, record2);
}
}
void CSMWorld::InfoCollection::load (ESM::ESMReader& reader, bool base)
{
/// \todo put records into proper order
/// \todo adjust ID
std::string id = reader.getHNOString ("NAME");
if (reader.isNextSub ("DELE"))
{
int index = searchId (id);
reader.skipRecord();
if (index==-1)
{
// deleting a record that does not exist
// ignore it for now
/// \todo report the problem to the user
}
else if (base)
{
removeRows (index, 1);
}
else
{
Record<ESM::DialInfo> record = getRecord (index);
record.mState = RecordBase::State_Deleted;
setRecord (index, record);
}
}
else
{
ESM::DialInfo record;
record.mId = id;
record.load (reader);
load (record, base);
}
}

@ -0,0 +1,20 @@
#ifndef CSM_WOLRD_INFOCOLLECTION_H
#define CSM_WOLRD_INFOCOLLECTION_H
#include <components/esm/loadinfo.hpp>
#include "collection.hpp"
namespace CSMWorld
{
class InfoCollection : public Collection<ESM::DialInfo, IdAccessor<ESM::DialInfo> >
{
void load (const ESM::DialInfo& record, bool base);
public:
void load (ESM::ESMReader& reader, bool base);
};
}
#endif

@ -31,6 +31,8 @@ namespace
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Spells, "Spells", 0 },
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Topics, "Topics", 0 },
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Journals, "Journals", 0 },
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_TopicInfos, "Topic Infos", 0 },
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_JournalInfos, "Journal Infos", 0 },
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Cells, "Cells", 0 },
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Referenceables,
"Referenceables", 0 },
@ -58,6 +60,8 @@ namespace
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Spell, "Spell", ":./spell.png" },
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Topic, "Topic", 0 },
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Journal, "Journal", 0 },
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_TopicInfo, "TopicInfo", 0 },
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_JournalInfo, "JournalInfo", 0 },
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Cell, "Cell", ":./cell.png" },
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Referenceable, "Referenceables", 0 },
{ CSMWorld::UniversalId::Class_RefRecord, CSMWorld::UniversalId::Type_Activator, "Activator", ":./activator.png" },

@ -91,6 +91,10 @@ namespace CSMWorld
Type_Topic,
Type_Journals,
Type_Journal,
Type_TopicInfos,
Type_TopicInfo,
Type_JournalInfos,
Type_JournalInfo,
Type_Scene
};

@ -176,6 +176,14 @@ void CSVDoc::View::setupCharacterMenu()
QAction *journals = new QAction (tr ("Journals"), this);
connect (journals, SIGNAL (triggered()), this, SLOT (addJournalsSubView()));
characters->addAction (journals);
QAction *topicInfos = new QAction (tr ("Topic Infos"), this);
connect (topicInfos, SIGNAL (triggered()), this, SLOT (addTopicInfosSubView()));
characters->addAction (topicInfos);
QAction *journalInfos = new QAction (tr ("Journal Infos"), this);
connect (journalInfos, SIGNAL (triggered()), this, SLOT (addJournalInfosSubView()));
characters->addAction (journalInfos);
}
void CSVDoc::View::setupAssetsMenu()
@ -436,6 +444,16 @@ void CSVDoc::View::addJournalsSubView()
addSubView (CSMWorld::UniversalId::Type_Journals);
}
void CSVDoc::View::addTopicInfosSubView()
{
addSubView (CSMWorld::UniversalId::Type_TopicInfos);
}
void CSVDoc::View::addJournalInfosSubView()
{
addSubView (CSMWorld::UniversalId::Type_JournalInfos);
}
void CSVDoc::View::abortOperation (int type)
{
mDocument->abortOperation (type);

@ -172,6 +172,10 @@ namespace CSVDoc
void addJournalsSubView();
void addTopicInfosSubView();
void addJournalInfosSubView();
void toggleShowStatusBar (bool show);
};
}

@ -37,6 +37,8 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
CSMWorld::UniversalId::Type_Regions,
CSMWorld::UniversalId::Type_Birthsigns,
CSMWorld::UniversalId::Type_Spells,
CSMWorld::UniversalId::Type_TopicInfos,
CSMWorld::UniversalId::Type_JournalInfos,
CSMWorld::UniversalId::Type_None // end marker
};

@ -153,4 +153,28 @@ void DialInfo::save(ESMWriter &esm)
}
}
void DialInfo::blank()
{
mData.mUnknown1 = 0;
mData.mDisposition = 0;
mData.mRank = 0;
mData.mGender = 0;
mData.mPCrank = 0;
mData.mUnknown2 = 0;
mSelects.clear();
mPrev.clear();
mNext.clear();
mActor.clear();
mRace.clear();
mClass.clear();
mNpcFaction.clear();
mPcFaction.clear();
mCell.clear();
mSound.clear();
mResponse.clear();
mResultScript.clear();
mFactionLess = false;
mQuestStatus = QS_None;
}
}

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

Loading…
Cancel
Save