2015-04-12 03:48:23 +00:00
|
|
|
#ifndef CSM_WOLRD_NESTEDCOLADAPTERIMP_H
|
|
|
|
#define CSM_WOLRD_NESTEDCOLADAPTERIMP_H
|
2015-04-09 09:29:03 +00:00
|
|
|
|
2022-10-19 17:02:00 +00:00
|
|
|
#include <QString>
|
2015-04-09 09:29:03 +00:00
|
|
|
#include <QVariant>
|
|
|
|
|
2022-10-19 17:02:00 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2022-01-22 14:58:41 +00:00
|
|
|
#include <components/esm3/effectlist.hpp>
|
|
|
|
#include <components/esm3/loadmgef.hpp> // for converting magic effect id to string & back
|
2015-04-09 09:29:03 +00:00
|
|
|
|
2015-04-12 03:48:23 +00:00
|
|
|
#include "nestedcolumnadapter.hpp"
|
2015-04-11 03:54:05 +00:00
|
|
|
#include "nestedtablewrapper.hpp"
|
2015-04-09 09:29:03 +00:00
|
|
|
|
2015-04-12 00:52:01 +00:00
|
|
|
namespace ESM
|
2015-04-09 09:29:03 +00:00
|
|
|
{
|
2015-04-12 00:52:01 +00:00
|
|
|
struct Faction;
|
|
|
|
struct Region;
|
2022-10-19 17:02:00 +00:00
|
|
|
struct Race;
|
2015-04-12 00:52:01 +00:00
|
|
|
}
|
2015-04-10 05:28:09 +00:00
|
|
|
|
2015-04-12 00:52:01 +00:00
|
|
|
namespace CSMWorld
|
|
|
|
{
|
|
|
|
struct Pathgrid;
|
2015-04-19 03:31:16 +00:00
|
|
|
struct Info;
|
2022-10-19 17:02:00 +00:00
|
|
|
struct Cell;
|
|
|
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
struct Record;
|
2015-04-09 09:29:03 +00:00
|
|
|
|
2015-04-12 03:48:23 +00:00
|
|
|
class PathgridPointListAdapter : public NestedColumnAdapter<Pathgrid>
|
2015-04-09 09:29:03 +00:00
|
|
|
{
|
2016-04-06 14:23:12 +00:00
|
|
|
public:
|
2022-09-22 18:26:05 +00:00
|
|
|
PathgridPointListAdapter();
|
2015-04-09 09:29:03 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void addRow(Record<Pathgrid>& record, int position) const override;
|
2015-04-09 09:29:03 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void removeRow(Record<Pathgrid>& record, int rowToRemove) const override;
|
2015-04-09 09:29:03 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setTable(Record<Pathgrid>& record, const NestedTableWrapperBase& nestedTable) const override;
|
2015-04-09 09:29:03 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
NestedTableWrapperBase* table(const Record<Pathgrid>& record) const override;
|
2015-04-09 09:29:03 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
QVariant getData(const Record<Pathgrid>& record, int subRowIndex, int subColIndex) const override;
|
2015-04-09 09:29:03 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setData(Record<Pathgrid>& record, const QVariant& value, int subRowIndex, int subColIndex) const override;
|
2015-04-09 09:29:03 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getColumnsCount(const Record<Pathgrid>& record) const override;
|
2015-04-09 09:29:03 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getRowsCount(const Record<Pathgrid>& record) const override;
|
2015-04-09 09:29:03 +00:00
|
|
|
};
|
2015-04-11 05:55:26 +00:00
|
|
|
|
2015-04-12 03:48:23 +00:00
|
|
|
class PathgridEdgeListAdapter : public NestedColumnAdapter<Pathgrid>
|
2015-04-11 07:51:30 +00:00
|
|
|
{
|
2016-04-06 14:23:12 +00:00
|
|
|
public:
|
2022-09-22 18:26:05 +00:00
|
|
|
PathgridEdgeListAdapter();
|
2015-04-11 07:51:30 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void addRow(Record<Pathgrid>& record, int position) const override;
|
2015-04-11 07:51:30 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void removeRow(Record<Pathgrid>& record, int rowToRemove) const override;
|
2015-04-11 07:51:30 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setTable(Record<Pathgrid>& record, const NestedTableWrapperBase& nestedTable) const override;
|
2015-04-11 07:51:30 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
NestedTableWrapperBase* table(const Record<Pathgrid>& record) const override;
|
2015-04-11 07:51:30 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
QVariant getData(const Record<Pathgrid>& record, int subRowIndex, int subColIndex) const override;
|
2015-04-11 07:51:30 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setData(Record<Pathgrid>& record, const QVariant& value, int subRowIndex, int subColIndex) const override;
|
2015-04-11 07:51:30 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getColumnsCount(const Record<Pathgrid>& record) const override;
|
2015-04-11 07:51:30 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getRowsCount(const Record<Pathgrid>& record) const override;
|
2015-04-11 07:51:30 +00:00
|
|
|
};
|
|
|
|
|
2015-04-12 03:48:23 +00:00
|
|
|
class FactionReactionsAdapter : public NestedColumnAdapter<ESM::Faction>
|
2015-04-11 05:55:26 +00:00
|
|
|
{
|
2016-04-06 14:23:12 +00:00
|
|
|
public:
|
2022-09-22 18:26:05 +00:00
|
|
|
FactionReactionsAdapter();
|
2015-04-11 05:55:26 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void addRow(Record<ESM::Faction>& record, int position) const override;
|
2015-04-11 05:55:26 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void removeRow(Record<ESM::Faction>& record, int rowToRemove) const override;
|
2015-04-11 05:55:26 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setTable(Record<ESM::Faction>& record, const NestedTableWrapperBase& nestedTable) const override;
|
2015-04-11 05:55:26 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
NestedTableWrapperBase* table(const Record<ESM::Faction>& record) const override;
|
2015-04-11 05:55:26 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
QVariant getData(const Record<ESM::Faction>& record, int subRowIndex, int subColIndex) const override;
|
2015-04-11 05:55:26 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setData(
|
|
|
|
Record<ESM::Faction>& record, const QVariant& value, int subRowIndex, int subColIndex) const override;
|
2015-04-11 05:55:26 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getColumnsCount(const Record<ESM::Faction>& record) const override;
|
2015-04-11 05:55:26 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getRowsCount(const Record<ESM::Faction>& record) const override;
|
2015-04-12 00:52:01 +00:00
|
|
|
};
|
2018-12-21 10:16:40 +00:00
|
|
|
|
|
|
|
class FactionRanksAdapter : public NestedColumnAdapter<ESM::Faction>
|
|
|
|
{
|
|
|
|
public:
|
2022-09-22 18:26:05 +00:00
|
|
|
FactionRanksAdapter();
|
2018-12-21 10:16:40 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void addRow(Record<ESM::Faction>& record, int position) const override;
|
2018-12-21 10:16:40 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void removeRow(Record<ESM::Faction>& record, int rowToRemove) const override;
|
2018-12-21 10:16:40 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setTable(Record<ESM::Faction>& record, const NestedTableWrapperBase& nestedTable) const override;
|
2018-12-21 10:16:40 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
NestedTableWrapperBase* table(const Record<ESM::Faction>& record) const override;
|
2018-12-21 10:16:40 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
QVariant getData(const Record<ESM::Faction>& record, int subRowIndex, int subColIndex) const override;
|
2018-12-21 10:16:40 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setData(
|
|
|
|
Record<ESM::Faction>& record, const QVariant& value, int subRowIndex, int subColIndex) const override;
|
2018-12-21 10:16:40 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getColumnsCount(const Record<ESM::Faction>& record) const override;
|
2018-12-21 10:16:40 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getRowsCount(const Record<ESM::Faction>& record) const override;
|
2018-12-21 10:16:40 +00:00
|
|
|
};
|
2015-04-11 07:51:30 +00:00
|
|
|
|
2015-04-12 03:48:23 +00:00
|
|
|
class RegionSoundListAdapter : public NestedColumnAdapter<ESM::Region>
|
2015-04-12 00:52:01 +00:00
|
|
|
{
|
2016-04-06 14:23:12 +00:00
|
|
|
public:
|
2022-09-22 18:26:05 +00:00
|
|
|
RegionSoundListAdapter();
|
2015-04-11 05:55:26 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void addRow(Record<ESM::Region>& record, int position) const override;
|
2015-04-11 07:51:30 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void removeRow(Record<ESM::Region>& record, int rowToRemove) const override;
|
2015-04-11 07:51:30 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setTable(Record<ESM::Region>& record, const NestedTableWrapperBase& nestedTable) const override;
|
2015-04-11 07:51:30 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
NestedTableWrapperBase* table(const Record<ESM::Region>& record) const override;
|
2015-04-11 05:55:26 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
QVariant getData(const Record<ESM::Region>& record, int subRowIndex, int subColIndex) const override;
|
2015-04-11 05:55:26 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setData(
|
|
|
|
Record<ESM::Region>& record, const QVariant& value, int subRowIndex, int subColIndex) const override;
|
2015-04-11 05:55:26 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getColumnsCount(const Record<ESM::Region>& record) const override;
|
2015-04-11 05:55:26 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getRowsCount(const Record<ESM::Region>& record) const override;
|
2015-04-11 05:55:26 +00:00
|
|
|
};
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
template <typename ESXRecordT>
|
2015-04-12 03:48:23 +00:00
|
|
|
class SpellListAdapter : public NestedColumnAdapter<ESXRecordT>
|
2015-04-11 09:05:03 +00:00
|
|
|
{
|
2016-04-06 14:23:12 +00:00
|
|
|
public:
|
2022-09-22 18:26:05 +00:00
|
|
|
SpellListAdapter() {}
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void addRow(Record<ESXRecordT>& record, int position) const override
|
2016-04-06 14:23:12 +00:00
|
|
|
{
|
|
|
|
ESXRecordT raceOrBthSgn = record.get();
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2022-10-06 17:39:46 +00:00
|
|
|
std::vector<ESM::RefId>& spells = raceOrBthSgn.mPowers.mList;
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2016-04-06 14:23:12 +00:00
|
|
|
// blank row
|
2022-10-06 17:39:46 +00:00
|
|
|
ESM::RefId spell;
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
spells.insert(spells.begin() + position, spell);
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
record.setModified(raceOrBthSgn);
|
2016-04-06 14:23:12 +00:00
|
|
|
}
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void removeRow(Record<ESXRecordT>& record, int rowToRemove) const override
|
2016-04-06 14:23:12 +00:00
|
|
|
{
|
|
|
|
ESXRecordT raceOrBthSgn = record.get();
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2022-10-06 17:39:46 +00:00
|
|
|
std::vector<ESM::RefId>& spells = raceOrBthSgn.mPowers.mList;
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
if (rowToRemove < 0 || rowToRemove >= static_cast<int>(spells.size()))
|
|
|
|
throw std::runtime_error("index out of range");
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
spells.erase(spells.begin() + rowToRemove);
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
record.setModified(raceOrBthSgn);
|
2016-04-06 14:23:12 +00:00
|
|
|
}
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void setTable(Record<ESXRecordT>& record, const NestedTableWrapperBase& nestedTable) const override
|
2016-04-06 14:23:12 +00:00
|
|
|
{
|
|
|
|
ESXRecordT raceOrBthSgn = record.get();
|
2015-04-12 10:03:55 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
raceOrBthSgn.mPowers.mList
|
2022-10-06 17:39:46 +00:00
|
|
|
= static_cast<const NestedTableWrapper<std::vector<ESM::RefId>>&>(nestedTable).mNestedTable;
|
2015-04-12 10:03:55 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
record.setModified(raceOrBthSgn);
|
2016-04-06 14:23:12 +00:00
|
|
|
}
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
NestedTableWrapperBase* table(const Record<ESXRecordT>& record) const override
|
2016-04-06 14:23:12 +00:00
|
|
|
{
|
|
|
|
// deleted by dtor of NestedTableStoring
|
2022-10-06 17:39:46 +00:00
|
|
|
return new NestedTableWrapper<std::vector<ESM::RefId>>(record.get().mPowers.mList);
|
2016-04-06 14:23:12 +00:00
|
|
|
}
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
QVariant getData(const Record<ESXRecordT>& record, int subRowIndex, int subColIndex) const override
|
2016-04-06 14:23:12 +00:00
|
|
|
{
|
|
|
|
ESXRecordT raceOrBthSgn = record.get();
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2022-10-06 17:39:46 +00:00
|
|
|
std::vector<ESM::RefId>& spells = raceOrBthSgn.mPowers.mList;
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
if (subRowIndex < 0 || subRowIndex >= static_cast<int>(spells.size()))
|
|
|
|
throw std::runtime_error("index out of range");
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2022-10-06 17:39:46 +00:00
|
|
|
ESM::RefId spell = spells[subRowIndex];
|
2016-04-06 14:23:12 +00:00
|
|
|
switch (subColIndex)
|
|
|
|
{
|
2022-09-22 18:26:05 +00:00
|
|
|
case 0:
|
2022-10-06 17:39:46 +00:00
|
|
|
return QString(spell.getRefIdString().c_str());
|
2022-09-22 18:26:05 +00:00
|
|
|
default:
|
|
|
|
throw std::runtime_error("Spells subcolumn index out of range");
|
2015-04-11 09:05:03 +00:00
|
|
|
}
|
2016-04-06 14:23:12 +00:00
|
|
|
}
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setData(Record<ESXRecordT>& record, const QVariant& value, int subRowIndex, int subColIndex) const override
|
2016-04-06 14:23:12 +00:00
|
|
|
{
|
|
|
|
ESXRecordT raceOrBthSgn = record.get();
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2022-10-06 17:39:46 +00:00
|
|
|
std::vector<ESM::RefId>& spells = raceOrBthSgn.mPowers.mList;
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
if (subRowIndex < 0 || subRowIndex >= static_cast<int>(spells.size()))
|
|
|
|
throw std::runtime_error("index out of range");
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2022-10-06 17:39:46 +00:00
|
|
|
ESM::RefId spell = spells[subRowIndex];
|
2016-04-06 14:23:12 +00:00
|
|
|
switch (subColIndex)
|
|
|
|
{
|
2022-09-22 18:26:05 +00:00
|
|
|
case 0:
|
2022-10-06 17:39:46 +00:00
|
|
|
spell = ESM::RefId::stringRefId(value.toString().toUtf8().constData());
|
2022-09-22 18:26:05 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw std::runtime_error("Spells subcolumn index out of range");
|
2016-04-06 14:23:12 +00:00
|
|
|
}
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2016-04-06 14:23:12 +00:00
|
|
|
raceOrBthSgn.mPowers.mList[subRowIndex] = spell;
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
record.setModified(raceOrBthSgn);
|
2016-04-06 14:23:12 +00:00
|
|
|
}
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
int getColumnsCount(const Record<ESXRecordT>& record) const override { return 1; }
|
2015-04-11 09:05:03 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getRowsCount(const Record<ESXRecordT>& record) const override
|
2016-04-06 14:23:12 +00:00
|
|
|
{
|
|
|
|
return static_cast<int>(record.get().mPowers.mList.size());
|
|
|
|
}
|
2015-04-11 09:05:03 +00:00
|
|
|
};
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
template <typename ESXRecordT>
|
2015-04-12 03:48:23 +00:00
|
|
|
class EffectsListAdapter : public NestedColumnAdapter<ESXRecordT>
|
2015-04-11 11:43:25 +00:00
|
|
|
{
|
2016-04-06 14:23:12 +00:00
|
|
|
public:
|
2022-09-22 18:26:05 +00:00
|
|
|
EffectsListAdapter() {}
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void addRow(Record<ESXRecordT>& record, int position) const override
|
2016-04-06 14:23:12 +00:00
|
|
|
{
|
|
|
|
ESXRecordT magic = record.get();
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2016-04-06 14:23:12 +00:00
|
|
|
std::vector<ESM::ENAMstruct>& effectsList = magic.mEffects.mList;
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2016-04-06 14:23:12 +00:00
|
|
|
// blank row
|
|
|
|
ESM::ENAMstruct effect;
|
|
|
|
effect.mEffectID = 0;
|
|
|
|
effect.mSkill = -1;
|
|
|
|
effect.mAttribute = -1;
|
|
|
|
effect.mRange = 0;
|
|
|
|
effect.mArea = 0;
|
|
|
|
effect.mDuration = 0;
|
|
|
|
effect.mMagnMin = 0;
|
|
|
|
effect.mMagnMax = 0;
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
effectsList.insert(effectsList.begin() + position, effect);
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
record.setModified(magic);
|
2016-04-06 14:23:12 +00:00
|
|
|
}
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void removeRow(Record<ESXRecordT>& record, int rowToRemove) const override
|
2016-04-06 14:23:12 +00:00
|
|
|
{
|
|
|
|
ESXRecordT magic = record.get();
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2016-04-06 14:23:12 +00:00
|
|
|
std::vector<ESM::ENAMstruct>& effectsList = magic.mEffects.mList;
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
if (rowToRemove < 0 || rowToRemove >= static_cast<int>(effectsList.size()))
|
|
|
|
throw std::runtime_error("index out of range");
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
effectsList.erase(effectsList.begin() + rowToRemove);
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
record.setModified(magic);
|
2016-04-06 14:23:12 +00:00
|
|
|
}
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void setTable(Record<ESXRecordT>& record, const NestedTableWrapperBase& nestedTable) const override
|
2016-04-06 14:23:12 +00:00
|
|
|
{
|
|
|
|
ESXRecordT magic = record.get();
|
2015-04-12 10:03:55 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
magic.mEffects.mList
|
|
|
|
= static_cast<const NestedTableWrapper<std::vector<ESM::ENAMstruct>>&>(nestedTable).mNestedTable;
|
2015-04-12 10:03:55 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
record.setModified(magic);
|
2016-04-06 14:23:12 +00:00
|
|
|
}
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
NestedTableWrapperBase* table(const Record<ESXRecordT>& record) const override
|
2016-04-06 14:23:12 +00:00
|
|
|
{
|
|
|
|
// deleted by dtor of NestedTableStoring
|
2022-09-22 18:26:05 +00:00
|
|
|
return new NestedTableWrapper<std::vector<ESM::ENAMstruct>>(record.get().mEffects.mList);
|
2016-04-06 14:23:12 +00:00
|
|
|
}
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
QVariant getData(const Record<ESXRecordT>& record, int subRowIndex, int subColIndex) const override
|
2016-04-06 14:23:12 +00:00
|
|
|
{
|
|
|
|
ESXRecordT magic = record.get();
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2016-04-06 14:23:12 +00:00
|
|
|
std::vector<ESM::ENAMstruct>& effectsList = magic.mEffects.mList;
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
if (subRowIndex < 0 || subRowIndex >= static_cast<int>(effectsList.size()))
|
|
|
|
throw std::runtime_error("index out of range");
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2016-04-06 14:23:12 +00:00
|
|
|
ESM::ENAMstruct effect = effectsList[subRowIndex];
|
|
|
|
switch (subColIndex)
|
|
|
|
{
|
|
|
|
case 0:
|
2015-04-11 21:46:32 +00:00
|
|
|
{
|
2022-09-22 18:26:05 +00:00
|
|
|
if (effect.mEffectID >= 0 && effect.mEffectID < ESM::MagicEffect::Length)
|
2016-04-06 14:23:12 +00:00
|
|
|
return effect.mEffectID;
|
|
|
|
else
|
|
|
|
throw std::runtime_error("Magic effects ID unexpected value");
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
switch (effect.mEffectID)
|
2016-04-06 06:39:33 +00:00
|
|
|
{
|
2016-04-06 14:23:12 +00:00
|
|
|
case ESM::MagicEffect::DrainSkill:
|
|
|
|
case ESM::MagicEffect::DamageSkill:
|
|
|
|
case ESM::MagicEffect::RestoreSkill:
|
|
|
|
case ESM::MagicEffect::FortifySkill:
|
|
|
|
case ESM::MagicEffect::AbsorbSkill:
|
2022-09-22 18:26:05 +00:00
|
|
|
return effect.mSkill;
|
2016-04-06 14:23:12 +00:00
|
|
|
default:
|
|
|
|
return QVariant();
|
2016-04-06 06:39:33 +00:00
|
|
|
}
|
2016-04-06 14:23:12 +00:00
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
switch (effect.mEffectID)
|
2016-04-06 06:39:33 +00:00
|
|
|
{
|
2016-04-06 14:23:12 +00:00
|
|
|
case ESM::MagicEffect::DrainAttribute:
|
|
|
|
case ESM::MagicEffect::DamageAttribute:
|
|
|
|
case ESM::MagicEffect::RestoreAttribute:
|
|
|
|
case ESM::MagicEffect::FortifyAttribute:
|
|
|
|
case ESM::MagicEffect::AbsorbAttribute:
|
2022-09-22 18:26:05 +00:00
|
|
|
return effect.mAttribute;
|
2016-04-06 14:23:12 +00:00
|
|
|
default:
|
|
|
|
return QVariant();
|
2016-04-06 06:39:33 +00:00
|
|
|
}
|
2015-10-28 00:30:36 +00:00
|
|
|
}
|
2016-04-06 14:23:12 +00:00
|
|
|
case 3:
|
|
|
|
{
|
2022-09-22 18:26:05 +00:00
|
|
|
if (effect.mRange >= 0 && effect.mRange <= 2)
|
2016-04-06 14:23:12 +00:00
|
|
|
return effect.mRange;
|
|
|
|
else
|
|
|
|
throw std::runtime_error("Magic effects range unexpected value");
|
|
|
|
}
|
2022-09-22 18:26:05 +00:00
|
|
|
case 4:
|
|
|
|
return effect.mArea;
|
|
|
|
case 5:
|
|
|
|
return effect.mDuration;
|
|
|
|
case 6:
|
|
|
|
return effect.mMagnMin;
|
|
|
|
case 7:
|
|
|
|
return effect.mMagnMax;
|
|
|
|
default:
|
|
|
|
throw std::runtime_error("Magic Effects subcolumn index out of range");
|
2015-04-11 11:43:25 +00:00
|
|
|
}
|
2016-04-06 14:23:12 +00:00
|
|
|
}
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setData(Record<ESXRecordT>& record, const QVariant& value, int subRowIndex, int subColIndex) const override
|
2016-04-06 14:23:12 +00:00
|
|
|
{
|
|
|
|
ESXRecordT magic = record.get();
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2016-04-06 14:23:12 +00:00
|
|
|
std::vector<ESM::ENAMstruct>& effectsList = magic.mEffects.mList;
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
if (subRowIndex < 0 || subRowIndex >= static_cast<int>(effectsList.size()))
|
|
|
|
throw std::runtime_error("index out of range");
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2016-04-06 14:23:12 +00:00
|
|
|
ESM::ENAMstruct effect = effectsList[subRowIndex];
|
|
|
|
switch (subColIndex)
|
|
|
|
{
|
|
|
|
case 0:
|
2015-04-11 21:46:32 +00:00
|
|
|
{
|
2016-04-06 14:23:12 +00:00
|
|
|
effect.mEffectID = static_cast<short>(value.toInt());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
effect.mSkill = static_cast<signed char>(value.toInt());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
effect.mAttribute = static_cast<signed char>(value.toInt());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
effect.mRange = value.toInt();
|
|
|
|
break;
|
2015-04-11 21:46:32 +00:00
|
|
|
}
|
2022-09-22 18:26:05 +00:00
|
|
|
case 4:
|
|
|
|
effect.mArea = value.toInt();
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
effect.mDuration = value.toInt();
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
effect.mMagnMin = value.toInt();
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
effect.mMagnMax = value.toInt();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw std::runtime_error("Magic Effects subcolumn index out of range");
|
2016-04-06 14:23:12 +00:00
|
|
|
}
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2016-04-06 14:23:12 +00:00
|
|
|
magic.mEffects.mList[subRowIndex] = effect;
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
record.setModified(magic);
|
2016-04-06 14:23:12 +00:00
|
|
|
}
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
int getColumnsCount(const Record<ESXRecordT>& record) const override { return 8; }
|
2015-04-11 11:43:25 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getRowsCount(const Record<ESXRecordT>& record) const override
|
2016-04-06 14:23:12 +00:00
|
|
|
{
|
|
|
|
return static_cast<int>(record.get().mEffects.mList.size());
|
|
|
|
}
|
2015-04-11 11:43:25 +00:00
|
|
|
};
|
2015-04-19 03:31:16 +00:00
|
|
|
|
|
|
|
class InfoListAdapter : public NestedColumnAdapter<Info>
|
|
|
|
{
|
2016-04-06 14:23:12 +00:00
|
|
|
public:
|
2022-09-22 18:26:05 +00:00
|
|
|
InfoListAdapter();
|
2015-04-19 03:31:16 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void addRow(Record<Info>& record, int position) const override;
|
2015-04-19 03:31:16 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void removeRow(Record<Info>& record, int rowToRemove) const override;
|
2015-04-19 03:31:16 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setTable(Record<Info>& record, const NestedTableWrapperBase& nestedTable) const override;
|
2015-04-19 03:31:16 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
NestedTableWrapperBase* table(const Record<Info>& record) const override;
|
2015-04-19 03:31:16 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
QVariant getData(const Record<Info>& record, int subRowIndex, int subColIndex) const override;
|
2015-04-19 03:31:16 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setData(Record<Info>& record, const QVariant& value, int subRowIndex, int subColIndex) const override;
|
2015-04-19 03:31:16 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getColumnsCount(const Record<Info>& record) const override;
|
2015-04-19 03:31:16 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getRowsCount(const Record<Info>& record) const override;
|
2015-04-19 03:31:16 +00:00
|
|
|
};
|
2015-05-09 11:21:16 +00:00
|
|
|
|
|
|
|
class InfoConditionAdapter : public NestedColumnAdapter<Info>
|
|
|
|
{
|
2016-04-06 14:23:12 +00:00
|
|
|
public:
|
2022-09-22 18:26:05 +00:00
|
|
|
InfoConditionAdapter();
|
2015-05-09 11:21:16 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void addRow(Record<Info>& record, int position) const override;
|
2015-05-09 11:21:16 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void removeRow(Record<Info>& record, int rowToRemove) const override;
|
2015-05-09 11:21:16 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setTable(Record<Info>& record, const NestedTableWrapperBase& nestedTable) const override;
|
2015-05-09 11:21:16 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
NestedTableWrapperBase* table(const Record<Info>& record) const override;
|
2015-05-09 11:21:16 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
QVariant getData(const Record<Info>& record, int subRowIndex, int subColIndex) const override;
|
2015-05-09 11:21:16 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setData(Record<Info>& record, const QVariant& value, int subRowIndex, int subColIndex) const override;
|
2015-05-09 11:21:16 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getColumnsCount(const Record<Info>& record) const override;
|
2015-05-09 11:21:16 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getRowsCount(const Record<Info>& record) const override;
|
2015-05-09 11:21:16 +00:00
|
|
|
};
|
2015-05-18 20:56:38 +00:00
|
|
|
|
|
|
|
class RaceAttributeAdapter : public NestedColumnAdapter<ESM::Race>
|
|
|
|
{
|
2016-04-06 14:23:12 +00:00
|
|
|
public:
|
2022-09-22 18:26:05 +00:00
|
|
|
RaceAttributeAdapter();
|
2015-05-18 20:56:38 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void addRow(Record<ESM::Race>& record, int position) const override;
|
2015-05-18 20:56:38 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void removeRow(Record<ESM::Race>& record, int rowToRemove) const override;
|
2015-05-18 20:56:38 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setTable(Record<ESM::Race>& record, const NestedTableWrapperBase& nestedTable) const override;
|
2015-05-18 20:56:38 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
NestedTableWrapperBase* table(const Record<ESM::Race>& record) const override;
|
2015-05-18 20:56:38 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
QVariant getData(const Record<ESM::Race>& record, int subRowIndex, int subColIndex) const override;
|
2015-05-18 20:56:38 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setData(Record<ESM::Race>& record, const QVariant& value, int subRowIndex, int subColIndex) const override;
|
2015-05-18 20:56:38 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getColumnsCount(const Record<ESM::Race>& record) const override;
|
2015-05-18 20:56:38 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getRowsCount(const Record<ESM::Race>& record) const override;
|
2015-05-18 20:56:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class RaceSkillsBonusAdapter : public NestedColumnAdapter<ESM::Race>
|
|
|
|
{
|
2016-04-06 14:23:12 +00:00
|
|
|
public:
|
2022-09-22 18:26:05 +00:00
|
|
|
RaceSkillsBonusAdapter();
|
2015-05-18 20:56:38 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void addRow(Record<ESM::Race>& record, int position) const override;
|
2015-05-18 20:56:38 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void removeRow(Record<ESM::Race>& record, int rowToRemove) const override;
|
2015-05-18 20:56:38 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setTable(Record<ESM::Race>& record, const NestedTableWrapperBase& nestedTable) const override;
|
2015-05-18 20:56:38 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
NestedTableWrapperBase* table(const Record<ESM::Race>& record) const override;
|
2015-05-18 20:56:38 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
QVariant getData(const Record<ESM::Race>& record, int subRowIndex, int subColIndex) const override;
|
2015-05-18 20:56:38 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setData(Record<ESM::Race>& record, const QVariant& value, int subRowIndex, int subColIndex) const override;
|
2015-05-18 20:56:38 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getColumnsCount(const Record<ESM::Race>& record) const override;
|
2015-05-18 20:56:38 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getRowsCount(const Record<ESM::Race>& record) const override;
|
2015-05-18 20:56:38 +00:00
|
|
|
};
|
2015-05-19 12:01:40 +00:00
|
|
|
|
|
|
|
class CellListAdapter : public NestedColumnAdapter<CSMWorld::Cell>
|
|
|
|
{
|
2016-04-06 14:23:12 +00:00
|
|
|
public:
|
2022-09-22 18:26:05 +00:00
|
|
|
CellListAdapter();
|
2015-05-19 12:01:40 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void addRow(Record<CSMWorld::Cell>& record, int position) const override;
|
2015-05-19 12:01:40 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void removeRow(Record<CSMWorld::Cell>& record, int rowToRemove) const override;
|
2015-05-19 12:01:40 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setTable(Record<CSMWorld::Cell>& record, const NestedTableWrapperBase& nestedTable) const override;
|
2015-05-19 12:01:40 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
NestedTableWrapperBase* table(const Record<CSMWorld::Cell>& record) const override;
|
2015-05-19 12:01:40 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
QVariant getData(const Record<CSMWorld::Cell>& record, int subRowIndex, int subColIndex) const override;
|
2015-05-19 12:01:40 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setData(
|
|
|
|
Record<CSMWorld::Cell>& record, const QVariant& value, int subRowIndex, int subColIndex) const override;
|
2015-05-19 12:01:40 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getColumnsCount(const Record<CSMWorld::Cell>& record) const override;
|
2015-05-19 12:01:40 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getRowsCount(const Record<CSMWorld::Cell>& record) const override;
|
2015-05-19 12:01:40 +00:00
|
|
|
};
|
2016-04-06 06:18:19 +00:00
|
|
|
|
|
|
|
class RegionWeatherAdapter : public NestedColumnAdapter<ESM::Region>
|
|
|
|
{
|
2016-04-06 14:23:12 +00:00
|
|
|
public:
|
2022-09-22 18:26:05 +00:00
|
|
|
RegionWeatherAdapter();
|
2016-04-06 06:18:19 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void addRow(Record<ESM::Region>& record, int position) const override;
|
2016-04-06 06:18:19 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void removeRow(Record<ESM::Region>& record, int rowToRemove) const override;
|
2016-04-06 06:18:19 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setTable(Record<ESM::Region>& record, const NestedTableWrapperBase& nestedTable) const override;
|
2016-04-06 06:18:19 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
NestedTableWrapperBase* table(const Record<ESM::Region>& record) const override;
|
2016-04-06 06:18:19 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
QVariant getData(const Record<ESM::Region>& record, int subRowIndex, int subColIndex) const override;
|
2016-04-06 06:18:19 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void setData(
|
|
|
|
Record<ESM::Region>& record, const QVariant& value, int subRowIndex, int subColIndex) const override;
|
2016-04-06 06:18:19 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getColumnsCount(const Record<ESM::Region>& record) const override;
|
2016-04-06 06:18:19 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getRowsCount(const Record<ESM::Region>& record) const override;
|
2016-04-06 06:18:19 +00:00
|
|
|
};
|
2015-04-09 09:29:03 +00:00
|
|
|
}
|
|
|
|
|
2015-04-12 03:48:23 +00:00
|
|
|
#endif // CSM_WOLRD_NESTEDCOLADAPTERIMP_H
|