From 13ee469b70ab0478658cce05c142b7b834430b80 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 30 Jul 2014 17:07:11 +0200 Subject: [PATCH] saving progress --- apps/opencs/model/doc/document.cpp | 4 +- apps/opencs/model/world/columns.cpp | 7 ++ apps/opencs/model/world/columns.hpp | 1 + apps/opencs/model/world/commands.cpp | 18 +-- apps/opencs/model/world/nestedadaptors.hpp | 128 ++++++++++++++++++++- apps/opencs/view/world/enumdelegate.cpp | 1 - 6 files changed, 148 insertions(+), 11 deletions(-) diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index 644d32e84..eb03be085 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -2,6 +2,7 @@ #include #include +#include #include @@ -2221,8 +2222,7 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration, boost::filesystem::path customFiltersPath (configuration.getUserDataPath()); customFiltersPath /= "defaultfilters"; - std::string destinationPath = mProjectPath.string() + "/defaultfilters"; - std::ofstream dst(destinationPath.c_str(), std::ios::binary); + std::ofstream dst(mProjectPath.c_str(), std::ios::binary); if (boost::filesystem::exists (customFiltersPath)) { diff --git a/apps/opencs/model/world/columns.cpp b/apps/opencs/model/world/columns.cpp index 212772450..0c44c2dcb 100644 --- a/apps/opencs/model/world/columns.cpp +++ b/apps/opencs/model/world/columns.cpp @@ -24,6 +24,7 @@ namespace CSMWorld { ColumnId_ValueType, "Value Type" }, { ColumnId_Description, "Description" }, { ColumnId_Specialisation, "Specialisation" }, + { ColumnId_Skill, "Skill" }, { ColumnId_Attribute, "Attribute" }, { ColumnId_Name, "Name" }, { ColumnId_Playable, "Playable" }, @@ -248,6 +249,11 @@ int CSMWorld::Columns::getId (const std::string& name) namespace { + static const char *sSkills[] = + { + "Long Blade" + }; + static const char *sSpecialisations[] = { "Combat", "Magic", "Stealth", 0 @@ -339,6 +345,7 @@ namespace switch (column) { case CSMWorld::Columns::ColumnId_Specialisation: return sSpecialisations; + case CSMWorld::Columns::ColumnId_Skill: return sSkills; case CSMWorld::Columns::ColumnId_Attribute: return sAttributes; case CSMWorld::Columns::ColumnId_SpellType: return sSpellTypes; case CSMWorld::Columns::ColumnId_ApparatusType: return sApparatusTypes; diff --git a/apps/opencs/model/world/columns.hpp b/apps/opencs/model/world/columns.hpp index 7efaf2bd0..b06018dd4 100644 --- a/apps/opencs/model/world/columns.hpp +++ b/apps/opencs/model/world/columns.hpp @@ -190,6 +190,7 @@ namespace CSMWorld ColumnId_RotY = 175, ColumnId_RotZ = 176, ColumnId_DestinationCell = 177, + ColumnId_Skill = 178, // Allocated to a separate value range, so we don't get a collision should we ever need // to extend the number of use values. diff --git a/apps/opencs/model/world/commands.cpp b/apps/opencs/model/world/commands.cpp index 0d9f6c773..30c4bb892 100644 --- a/apps/opencs/model/world/commands.cpp +++ b/apps/opencs/model/world/commands.cpp @@ -173,13 +173,17 @@ void CSMWorld::CloneCommand::undo() mModel.removeRow (mModel.getModelIndex (mIdDestination, 0).row()); } -CSMWorld::DeleteNestedCommand::DeleteNestedCommand (IdTable& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent) - : mId(id), - mModel(model), - mParentColumn(parentColumn), - QUndoCommand(parent), - mNestedRow(nestedRow), - NestedTableStoring(model, id, parentColumn) +CSMWorld::DeleteNestedCommand::DeleteNestedCommand (IdTable& model, + const std::string& id, + int nestedRow, + int parentColumn, + QUndoCommand* parent) : + mId(id), + mModel(model), + mParentColumn(parentColumn), + QUndoCommand(parent), + mNestedRow(nestedRow), + NestedTableStoring(model, id, parentColumn) { setText (("Delete nested row in " + mId).c_str()); } diff --git a/apps/opencs/model/world/nestedadaptors.hpp b/apps/opencs/model/world/nestedadaptors.hpp index 319fe1569..6e3d447b2 100644 --- a/apps/opencs/model/world/nestedadaptors.hpp +++ b/apps/opencs/model/world/nestedadaptors.hpp @@ -13,6 +13,9 @@ #include #include #include +#include +#include +#include #include @@ -174,6 +177,129 @@ namespace CSMWorld }; + /* + template + class MagicEffectsHelper : public CastableHelper + { + public: + + MagicEffectsHelper(CSMWorld::UniversalId::Type type) + : CastableHelper(type) {} + + virtual void setNestedTable(RefIdData& data, + int index, + const NestedTableWrapperBase& nestedTable) + { + CastableHelper::getRecord(data, index).get().mEffects = + (static_cast&>(nestedTable)).mNestedTable; + } + + virtual NestedTableWrapperBase* nestedTable(const RefIdData& data, + int index) const + { + return new NestedTableWrapper(CastableHelper::getRecord(data, index).get().mEffects); + } + + virtual QVariant getNestedData(const CSMWorld::RefIdData& data, + int index, + int subRowIndex, + int subColIndex) const + { + const ESM::EffectList& content = CastableHelper::getRecord(data, index).get().mEffects; + + switch (subColIndex) + { + case 0: + return content.at(subRowIndex).mEffectID; + + case 1: + return content.at(subRowIndex).mRange; + + case 2: + return content.at(subRowIndex).mDuration; + + case 3: + return content.at(subRowIndex).mArea; + + case 4: + return content.at(subRowIndex).mMagMin; + + case 5: + return content.at(subRowIndex).mMagMax; + + case 6: + return (int)content.at(rubRowIndex).mSkill; + + case 7: + return (int)content.at(subRowIndex).mAttribute; + + default: + throw std::logic_error("Trying to access non-existing column in the nested table!"); + } + } + + virtual void removeNestedRow (RefIdData& data, int index, int rowToRemove) const + { + ESM::EffectList& list = CastableHelper::getRecord(data, index).get().mEffects; + + list.erase (list.begin () + rowToRemove); + } + + void setNestedData (RefIdData& data, + int index, + const QVariant& value, + int subRowIndex, + int subColIndex) const + { + switch(subColIndex) + { + case 0: + CastableHelper::getRecord(data, index).get().mEffects.at(subRowIndex).mEffectID = value.toInt(); + break; + + default: + throw std::logic_error("Trying to access non-existing column in the nested table!"); + } + } + + virtual void addNestedRow (RefIdData& data, int index, int position) const + { + std::vector& list = CastableHelper::getRecord(data, index).get().mTransport; + + ESM::Position newPos; + for (unsigned i = 0; i < 3; ++i) + { + newPos.pos[i] = 0; + newPos.rot[i] = 0; + } + + ESM::NPC::Dest newRow; + newRow.mPos = newPos; + newRow.mCellName = ""; + + if (position >= (int)list.size()) + { + list.push_back(newRow); + return; + } + + list.insert(list.begin()+position, newRow); + } + + virtual int getNestedColumnsCount(const RefIdData& data) const + { + return 7; + } + + + virtual int getNestedRowsCount(const RefIdData& data, + int index) const + { + return CastableHelper::getRecord(data, index).get().mTransport.size(); + } + + }; + */ template class DestinationsHelper : public CastableHelper { @@ -316,7 +442,7 @@ namespace CSMWorld } }; - + template class InventoryHelper : public CastableHelper { diff --git a/apps/opencs/view/world/enumdelegate.cpp b/apps/opencs/view/world/enumdelegate.cpp index 377f479bf..16f38938d 100644 --- a/apps/opencs/view/world/enumdelegate.cpp +++ b/apps/opencs/view/world/enumdelegate.cpp @@ -46,7 +46,6 @@ QWidget *CSVWorld::EnumDelegate::createEditor(QWidget *parent, const QModelIndex& index) const { return createEditor(parent, option, index, CSMWorld::ColumnBase::Display_None); - //overloading virtual functions is HARD } QWidget *CSVWorld::EnumDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem& option,