1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-01 12:15:35 +00:00

saving progress

This commit is contained in:
Marek Kochanowicz 2014-07-30 17:07:11 +02:00
parent 6a9c7c9f86
commit 13ee469b70
6 changed files with 148 additions and 11 deletions

View file

@ -2,6 +2,7 @@
#include <cassert>
#include <fstream>
#include <iostream>
#include <boost/filesystem.hpp>
@ -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))
{

View file

@ -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;

View file

@ -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.

View file

@ -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());
}

View file

@ -13,6 +13,9 @@
#include <components/esm/loadcont.hpp>
#include <components/esm/defs.hpp>
#include <components/esm/loadnpc.hpp>
#include <components/esm/loadspel.hpp>
#include <components/esm/effectlist.hpp>
#include <components/esm/loadmgef.hpp>
#include <QVariant>
@ -174,6 +177,129 @@ namespace CSMWorld
};
/*
template <typename ESXRecordT>
class MagicEffectsHelper : public CastableHelper<ESXRecordT>
{
public:
MagicEffectsHelper(CSMWorld::UniversalId::Type type)
: CastableHelper<ESXRecordT>(type) {}
virtual void setNestedTable(RefIdData& data,
int index,
const NestedTableWrapperBase& nestedTable)
{
CastableHelper<ESXRecordT>::getRecord(data, index).get().mEffects =
(static_cast<const NestedTableWrapper<ESM::EffectList>&>(nestedTable)).mNestedTable;
}
virtual NestedTableWrapperBase* nestedTable(const RefIdData& data,
int index) const
{
return new NestedTableWrapper<ESM::EffectList>(CastableHelper<ESXRecordT>::getRecord(data, index).get().mEffects);
}
virtual QVariant getNestedData(const CSMWorld::RefIdData& data,
int index,
int subRowIndex,
int subColIndex) const
{
const ESM::EffectList& content = CastableHelper<ESXRecordT>::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<ESXRecordT>::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<ESXRecordT>::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<ESM::NPC::Dest>& list = CastableHelper<ESXRecordT>::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<ESXRecordT>::getRecord(data, index).get().mTransport.size();
}
};
*/
template <typename ESXRecordT>
class DestinationsHelper : public CastableHelper<ESXRecordT>
{
@ -316,7 +442,7 @@ namespace CSMWorld
}
};
template <typename ESXRecordT>
class InventoryHelper : public CastableHelper<ESXRecordT>
{

View file

@ -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,