From e97fd35ae6d9d50e65866182dcd84cee91452570 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 30 Jun 2014 20:40:34 +0200 Subject: [PATCH] added enchantments table --- apps/opencs/model/doc/saving.cpp | 3 +++ apps/opencs/model/world/data.cpp | 22 ++++++++++++++++++++++ apps/opencs/model/world/data.hpp | 6 ++++++ apps/opencs/model/world/universalid.cpp | 3 ++- apps/opencs/model/world/universalid.hpp | 6 ++++-- apps/opencs/view/doc/view.cpp | 9 +++++++++ apps/opencs/view/doc/view.hpp | 2 ++ apps/opencs/view/world/subviews.cpp | 1 + components/esm/loadench.cpp | 9 +++++++++ components/esm/loadench.hpp | 3 +++ 10 files changed, 61 insertions(+), 3 deletions(-) diff --git a/apps/opencs/model/doc/saving.cpp b/apps/opencs/model/doc/saving.cpp index 45b53f4fe8..ef753bb4b6 100644 --- a/apps/opencs/model/doc/saving.cpp +++ b/apps/opencs/model/doc/saving.cpp @@ -59,6 +59,9 @@ CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& proje appendStage (new WriteCollectionStage > (mDocument.getData().getSpells(), mState)); + appendStage (new WriteCollectionStage > + (mDocument.getData().getEnchantments(), mState)); + appendStage (new WriteDialogueCollectionStage (mDocument, mState, false)); appendStage (new WriteDialogueCollectionStage (mDocument, mState, true)); diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index 0319d71acc..35b658ada7 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -198,6 +198,13 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding) mCells.addColumn (new FlagColumn (Columns::ColumnId_InteriorSky, ESM::Cell::QuasiEx)); mCells.addColumn (new RegionColumn); + mEnchantments.addColumn (new StringIdColumn); + mEnchantments.addColumn (new RecordStateColumn); + mEnchantments.addColumn (new FixedRecordTypeColumn (UniversalId::Type_Enchantment)); + + mEnchantments.addColumn (new CostColumn); + + mRefs.addColumn (new StringIdColumn (true)); mRefs.addColumn (new RecordStateColumn); mRefs.addColumn (new FixedRecordTypeColumn (UniversalId::Type_Reference)); @@ -252,6 +259,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding) addModel (new IdTable (&mTopicInfos, IdTable::Feature_ReorderWithinTopic), UniversalId::Type_TopicInfo); addModel (new IdTable (&mJournalInfos, IdTable::Feature_ReorderWithinTopic), UniversalId::Type_JournalInfo); addModel (new IdTable (&mCells, IdTable::Feature_ViewId), UniversalId::Type_Cell); + addModel (new IdTable (&mEnchantments), UniversalId::Type_Enchantment); addModel (new IdTable (&mReferenceables, IdTable::Feature_Preview), UniversalId::Type_Referenceable); addModel (new IdTable (&mRefs, IdTable::Feature_ViewCell | IdTable::Feature_Preview), UniversalId::Type_Reference); @@ -457,6 +465,16 @@ CSMWorld::IdCollection& CSMWorld::Data::getFilters() return mFilters; } +const CSMWorld::IdCollection& CSMWorld::Data::getEnchantments() const +{ + return mEnchantments; +} + +CSMWorld::IdCollection& CSMWorld::Data::getEnchantments() +{ + return mEnchantments; +} + QAbstractItemModel *CSMWorld::Data::getTableModel (const CSMWorld::UniversalId& id) { std::map::iterator iter = mModelIndex.find (id.getType()); @@ -534,6 +552,7 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Stage::Messages& messages) case ESM::REC_REGN: mRegions.load (*mReader, mBase); break; case ESM::REC_BSGN: mBirthsigns.load (*mReader, mBase); break; case ESM::REC_SPEL: mSpells.load (*mReader, mBase); break; + case ESM::REC_ENCH: mEnchantments.load (*mReader, mBase); break; case ESM::REC_CELL: { @@ -668,6 +687,7 @@ bool CSMWorld::Data::hasId (const std::string& id) const getTopics().searchId (id)!=-1 || getJournals().searchId (id)!=-1 || getCells().searchId (id)!=-1 || + getEnchantments().searchId (id)!=-1 || getReferenceables().searchId (id)!=-1; } @@ -686,6 +706,7 @@ int CSMWorld::Data::count (RecordBase::State state) const count (state, mBirthsigns) + count (state, mSpells) + count (state, mCells) + + count (state, mEnchantments) + count (state, mReferenceables); } @@ -726,6 +747,7 @@ std::vector CSMWorld::Data::getIds (bool listDeleted) const appendIds (ids, mTopics, listDeleted); appendIds (ids, mJournals, listDeleted); appendIds (ids, mCells, listDeleted); + appendIds (ids, mEnchantments, listDeleted); appendIds (ids, mReferenceables, listDeleted); std::sort (ids.begin(), ids.end()); diff --git a/apps/opencs/model/world/data.hpp b/apps/opencs/model/world/data.hpp index edca9fdbcf..758354450d 100644 --- a/apps/opencs/model/world/data.hpp +++ b/apps/opencs/model/world/data.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -63,6 +64,7 @@ namespace CSMWorld IdCollection mSpells; IdCollection mTopics; IdCollection mJournals; + IdCollection mEnchantments; InfoCollection mTopicInfos; InfoCollection mJournalInfos; IdCollection mCells; @@ -174,6 +176,10 @@ namespace CSMWorld IdCollection& getFilters(); + const IdCollection& getEnchantments() const; + + IdCollection& getEnchantments(); + QAbstractItemModel *getTableModel (const UniversalId& id); ///< If no table model is available for \a id, an exception is thrown. /// diff --git a/apps/opencs/model/world/universalid.cpp b/apps/opencs/model/world/universalid.cpp index 88e649ace4..79273a8311 100644 --- a/apps/opencs/model/world/universalid.cpp +++ b/apps/opencs/model/world/universalid.cpp @@ -35,6 +35,7 @@ namespace { 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_Enchantments, "Enchantments", 0 }, { CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Referenceables, "Referenceables", 0 }, { CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_References, @@ -92,8 +93,8 @@ namespace { CSMWorld::UniversalId::Class_SubRecord, CSMWorld::UniversalId::Type_Reference, "Reference", 0 }, { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Filter, "Filter", ":./filter.png" }, { CSMWorld::UniversalId::Class_Collection, CSMWorld::UniversalId::Type_Scene, "Scene", 0 }, - { CSMWorld::UniversalId::Class_Collection, CSMWorld::UniversalId::Type_Preview, "Preview", 0 }, + { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Enchantment, "Enchantment", 0 }, { CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0, 0 } // end marker }; diff --git a/apps/opencs/model/world/universalid.hpp b/apps/opencs/model/world/universalid.hpp index 3bef71c75f..f92ad0bcb7 100644 --- a/apps/opencs/model/world/universalid.hpp +++ b/apps/opencs/model/world/universalid.hpp @@ -100,10 +100,12 @@ namespace CSMWorld Type_JournalInfo, Type_Scene, Type_Preview, - Type_LoadErrorLog + Type_LoadErrorLog, + Type_Enchantments, + Type_Enchantment }; - enum { NumberOfTypes = Type_LoadErrorLog+1 }; + enum { NumberOfTypes = Type_Enchantment+1 }; private: diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index e71b8435ab..a356721f60 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -146,6 +146,10 @@ void CSVDoc::View::setupMechanicsMenu() QAction *spells = new QAction (tr ("Spells"), this); connect (spells, SIGNAL (triggered()), this, SLOT (addSpellsSubView())); mechanics->addAction (spells); + + QAction *enchantments = new QAction (tr ("Enchantments"), this); + connect (enchantments, SIGNAL (triggered()), this, SLOT (addEnchantmentsSubView())); + mechanics->addAction (enchantments); } void CSVDoc::View::setupCharacterMenu() @@ -469,6 +473,11 @@ void CSVDoc::View::addJournalInfosSubView() addSubView (CSMWorld::UniversalId::Type_JournalInfos); } +void CSVDoc::View::addEnchantmentsSubView() +{ + addSubView (CSMWorld::UniversalId::Type_Enchantments); +} + void CSVDoc::View::abortOperation (int type) { mDocument->abortOperation (type); diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index 686c001dc1..1ba73c56de 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -178,6 +178,8 @@ namespace CSVDoc void addJournalInfosSubView(); + void addEnchantmentsSubView(); + void toggleShowStatusBar (bool show); void loadErrorLog(); diff --git a/apps/opencs/view/world/subviews.cpp b/apps/opencs/view/world/subviews.cpp index 022d5d02e4..8d62466968 100644 --- a/apps/opencs/view/world/subviews.cpp +++ b/apps/opencs/view/world/subviews.cpp @@ -39,6 +39,7 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager) CSMWorld::UniversalId::Type_Regions, CSMWorld::UniversalId::Type_Birthsigns, CSMWorld::UniversalId::Type_Spells, + CSMWorld::UniversalId::Type_Enchantments, CSMWorld::UniversalId::Type_None // end marker }; diff --git a/components/esm/loadench.cpp b/components/esm/loadench.cpp index a1e885f23b..2438038337 100644 --- a/components/esm/loadench.cpp +++ b/components/esm/loadench.cpp @@ -20,4 +20,13 @@ void Enchantment::save(ESMWriter &esm) const mEffects.save(esm); } + void Enchantment::blank() + { + mData.mType = 0; + mData.mCost = 0; + mData.mCharge = 0; + mData.mAutocalc = 0; + + mEffects.mList.clear(); + } } diff --git a/components/esm/loadench.hpp b/components/esm/loadench.hpp index f6ba8c6ab3..3b7746812a 100644 --- a/components/esm/loadench.hpp +++ b/components/esm/loadench.hpp @@ -42,6 +42,9 @@ struct Enchantment void load(ESMReader &esm); void save(ESMWriter &esm) const; + + void blank(); + ///< Set record to default state (does not touch the ID). }; } #endif