1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-29 07:45:31 +00:00

Resolve merge issues and change the getSpells() interface.

This commit is contained in:
cc9cii 2015-06-25 18:57:32 +10:00
parent 66877cbfe7
commit b1f07ba4fb
7 changed files with 21 additions and 29 deletions

View file

@ -33,7 +33,6 @@ namespace
const CSMWorld::IdCollection<ESM::Skill>& mSkillTable; const CSMWorld::IdCollection<ESM::Skill>& mSkillTable;
const CSMWorld::IdCollection<ESM::MagicEffect>& mMagicEffectTable; const CSMWorld::IdCollection<ESM::MagicEffect>& mMagicEffectTable;
const CSMWorld::NestedIdCollection<ESM::Spell>& mSpells; const CSMWorld::NestedIdCollection<ESM::Spell>& mSpells;
std::vector<ESM::Spell *> mLocal;
public: public:
@ -42,14 +41,8 @@ namespace
const CSMWorld::IdCollection<ESM::MagicEffect>& magicEffects, const CSMWorld::IdCollection<ESM::MagicEffect>& magicEffects,
const CSMWorld::NestedIdCollection<ESM::Spell>& spells) const CSMWorld::NestedIdCollection<ESM::Spell>& spells)
: mGmstTable(gmst), mSkillTable(skills), mMagicEffectTable(magicEffects), mSpells(spells) : mGmstTable(gmst), mSkillTable(skills), mMagicEffectTable(magicEffects), mSpells(spells)
{ { }
// prepare data in a format used by OpenMW store
for (int index = 0; index < mSpells.getSize(); ++index)
{
ESM::Spell *spell = const_cast<ESM::Spell *>(&mSpells.getRecord(index).get());
mLocal.push_back(spell);
}
}
~CSStore() {} ~CSStore() {}
virtual int findGmstInt(const std::string& name) const virtual int findGmstInt(const std::string& name) const
@ -74,9 +67,11 @@ namespace
return &mMagicEffectTable.getRecord(ESM::MagicEffect::indexToId((short)id)).get(); return &mMagicEffectTable.getRecord(ESM::MagicEffect::indexToId((short)id)).get();
} }
virtual const std::vector<ESM::Spell*>& getSpells() const virtual void getSpells(std::vector<ESM::Spell*>& spells)
{ {
return mLocal; // prepare data in a format used by OpenMW store
for (int index = 0; index < mSpells.getSize(); ++index)
spells.push_back(const_cast<ESM::Spell *>(&mSpells.getRecord(index).get()));
} }
}; };

View file

@ -16,6 +16,8 @@ CSVWorld::NestedTable::NestedTable(CSMDoc::Document& document,
QWidget* parent, QWidget* parent,
bool editable) bool editable)
: DragRecordTable(document, parent), : DragRecordTable(document, parent),
mAddNewRowAction(0),
mRemoveRowAction(0),
mModel(model) mModel(model)
{ {
setSelectionBehavior (QAbstractItemView::SelectRows); setSelectionBehavior (QAbstractItemView::SelectRows);
@ -50,8 +52,6 @@ CSVWorld::NestedTable::NestedTable(CSMDoc::Document& document,
setItemDelegateForColumn(i, delegate); setItemDelegateForColumn(i, delegate);
} }
setModel(model);
mAddNewRowAction = new QAction (tr ("Add new row"), this); mAddNewRowAction = new QAction (tr ("Add new row"), this);
connect(mAddNewRowAction, SIGNAL(triggered()), connect(mAddNewRowAction, SIGNAL(triggered()),
@ -90,15 +90,15 @@ void CSVWorld::NestedTable::contextMenuEvent (QContextMenuEvent *event)
void CSVWorld::NestedTable::removeRowActionTriggered() void CSVWorld::NestedTable::removeRowActionTriggered()
{ {
mDocument.getUndoStack().push(new CSMWorld::DeleteNestedCommand(*(mModel->model()), mDocument.getUndoStack().push(new CSMWorld::DeleteNestedCommand(*(mModel->model()),
mModel->getParentId(), mModel->getParentId(),
selectionModel()->selectedRows().begin()->row(), selectionModel()->selectedRows().begin()->row(),
mModel->getParentColumn())); mModel->getParentColumn()));
} }
void CSVWorld::NestedTable::addNewRowActionTriggered() void CSVWorld::NestedTable::addNewRowActionTriggered()
{ {
mDocument.getUndoStack().push(new CSMWorld::AddNestedCommand(*(mModel->model()), mDocument.getUndoStack().push(new CSMWorld::AddNestedCommand(*(mModel->model()),
mModel->getParentId(), mModel->getParentId(),
selectionModel()->selectedRows().size(), selectionModel()->selectedRows().size(),
mModel->getParentColumn())); mModel->getParentColumn()));
} }

View file

@ -29,8 +29,9 @@ namespace MWWorld
return MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(id); return MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(id);
} }
const std::vector<ESM::Spell*>& MWStore::getSpells() const void MWStore::getSpells(std::vector<ESM::Spell*>& spells)
{ {
return MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().getShared(); for (Store<ESM::Spell>::iterator iter = mSpells.begin(); iter != mSpells.end(); ++iter)
spells.push_back(const_cast<ESM::Spell*>(&*iter));
} }
} }

View file

@ -27,7 +27,7 @@ namespace MWWorld
virtual const ESM::MagicEffect* findMagicEffect(int id) const; virtual const ESM::MagicEffect* findMagicEffect(int id) const;
virtual const std::vector<ESM::Spell*>& getSpells() const; virtual void MWStore::getSpells(std::vector<ESM::Spell*>& spells);
}; };
} }

View file

@ -234,10 +234,6 @@ namespace MWWorld
return mShared.size(); return mShared.size();
} }
const std::vector<T *>& getShared() const {
return mShared;
}
int getDynamicSize() const int getDynamicSize() const
{ {
return static_cast<int> (mDynamic.size()); // truncated from unsigned __int64 if _MSC_VER && _WIN64 return static_cast<int> (mDynamic.size()); // truncated from unsigned __int64 if _MSC_VER && _WIN64

View file

@ -60,8 +60,8 @@ namespace AutoCalc
} }
std::vector<std::string> selectedSpells; std::vector<std::string> selectedSpells;
std::vector<ESM::Spell*> spells;
const std::vector<ESM::Spell*>& spells = store->getSpells(); store->getSpells(spells);
// Note: the algorithm heavily depends on the traversal order of the spells. For vanilla-compatible results the // Note: the algorithm heavily depends on the traversal order of the spells. For vanilla-compatible results the
// Store must preserve the record ordering as it was in the content files. // Store must preserve the record ordering as it was in the content files.

View file

@ -36,7 +36,7 @@ namespace AutoCalc
virtual const ESM::MagicEffect* findMagicEffect(int id) const = 0; virtual const ESM::MagicEffect* findMagicEffect(int id) const = 0;
virtual const std::vector<ESM::Spell*>& getSpells() const = 0; virtual void getSpells(std::vector<ESM::Spell*>& spells) = 0;
}; };
} }
#endif // COMPONENTS_AUTOCALC_STORE_H #endif // COMPONENTS_AUTOCALC_STORE_H