Merge remote-tracking branch 'aesylwinn/landrecords'
commit
dd17f70068
@ -1,28 +1,341 @@
|
||||
#include "columnimp.hpp"
|
||||
|
||||
CSMWorld::BodyPartRaceColumn::BodyPartRaceColumn(const MeshTypeColumn<ESM::BodyPart> *meshType)
|
||||
: mMeshType(meshType)
|
||||
{}
|
||||
#include <stdexcept>
|
||||
#include <QVector>
|
||||
|
||||
QVariant CSMWorld::BodyPartRaceColumn::get(const Record<ESM::BodyPart> &record) const
|
||||
namespace CSMWorld
|
||||
{
|
||||
if (mMeshType != NULL && mMeshType->get(record) == ESM::BodyPart::MT_Skin)
|
||||
/* LandTextureNicknameColumn */
|
||||
LandTextureNicknameColumn::LandTextureNicknameColumn()
|
||||
: Column<LandTexture>(Columns::ColumnId_TextureNickname, ColumnBase::Display_String)
|
||||
{
|
||||
return QString::fromUtf8(record.get().mRace.c_str());
|
||||
}
|
||||
return QVariant(QVariant::UserType);
|
||||
}
|
||||
|
||||
void CSMWorld::BodyPartRaceColumn::set(Record<ESM::BodyPart> &record, const QVariant &data)
|
||||
{
|
||||
ESM::BodyPart record2 = record.get();
|
||||
QVariant LandTextureNicknameColumn::get(const Record<LandTexture>& record) const
|
||||
{
|
||||
return QString::fromUtf8(record.get().mId.c_str());
|
||||
}
|
||||
|
||||
record2.mRace = data.toString().toUtf8().constData();
|
||||
void LandTextureNicknameColumn::set(Record<LandTexture>& record, const QVariant& data)
|
||||
{
|
||||
LandTexture copy = record.get();
|
||||
copy.mId = data.toString().toUtf8().constData();
|
||||
record.setModified(copy);
|
||||
}
|
||||
|
||||
record.setModified(record2);
|
||||
}
|
||||
bool LandTextureNicknameColumn::isEditable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSMWorld::BodyPartRaceColumn::isEditable() const
|
||||
{
|
||||
return true;
|
||||
/* LandTextureIndexColumn */
|
||||
LandTextureIndexColumn::LandTextureIndexColumn()
|
||||
: Column<LandTexture>(Columns::ColumnId_TextureIndex, ColumnBase::Display_Integer)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant LandTextureIndexColumn::get(const Record<LandTexture>& record) const
|
||||
{
|
||||
return record.get().mIndex;
|
||||
}
|
||||
|
||||
bool LandTextureIndexColumn::isEditable() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* LandPluginIndexColumn */
|
||||
LandPluginIndexColumn::LandPluginIndexColumn()
|
||||
: Column<Land>(Columns::ColumnId_PluginIndex, ColumnBase::Display_Integer, 0)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant LandPluginIndexColumn::get(const Record<Land>& record) const
|
||||
{
|
||||
return record.get().mPlugin;
|
||||
}
|
||||
|
||||
bool LandPluginIndexColumn::isEditable() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* LandTexturePluginIndexColumn */
|
||||
LandTexturePluginIndexColumn::LandTexturePluginIndexColumn()
|
||||
: Column<LandTexture>(Columns::ColumnId_PluginIndex, ColumnBase::Display_Integer, 0)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant LandTexturePluginIndexColumn::get(const Record<LandTexture>& record) const
|
||||
{
|
||||
return record.get().mPluginIndex;
|
||||
}
|
||||
|
||||
bool LandTexturePluginIndexColumn::isEditable() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* LandMapLodColumn */
|
||||
LandMapLodColumn::LandMapLodColumn()
|
||||
: Column<Land>(Columns::ColumnId_LandMapLodIndex, ColumnBase::Display_String, 0)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant LandMapLodColumn::get(const Record<Land>& record) const
|
||||
{
|
||||
const int Size = Land::LAND_GLOBAL_MAP_LOD_SIZE;
|
||||
const Land& land = record.get();
|
||||
|
||||
DataType values(Size, 0);
|
||||
|
||||
if (land.isDataLoaded(Land::DATA_WNAM))
|
||||
{
|
||||
for (int i = 0; i < Size; ++i)
|
||||
values[i] = land.mWnam[i];
|
||||
}
|
||||
|
||||
QVariant variant;
|
||||
variant.setValue(values);
|
||||
return variant;
|
||||
}
|
||||
|
||||
void LandMapLodColumn::set(Record<Land>& record, const QVariant& data)
|
||||
{
|
||||
DataType values = data.value<DataType>();
|
||||
|
||||
if (values.size() != Land::LAND_GLOBAL_MAP_LOD_SIZE)
|
||||
throw std::runtime_error("invalid land map LOD data");
|
||||
|
||||
Land copy = record.get();
|
||||
copy.setDataLoaded(Land::DATA_WNAM);
|
||||
|
||||
for (int i = 0; i < values.size(); ++i)
|
||||
{
|
||||
copy.mWnam[i] = values[i];
|
||||
}
|
||||
|
||||
record.setModified(copy);
|
||||
}
|
||||
|
||||
bool LandMapLodColumn::isEditable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* LandNormalsColumn */
|
||||
LandNormalsColumn::LandNormalsColumn()
|
||||
: Column<Land>(Columns::ColumnId_LandNormalsIndex, ColumnBase::Display_String, 0)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant LandNormalsColumn::get(const Record<Land>& record) const
|
||||
{
|
||||
const int Size = Land::LAND_NUM_VERTS * 3;
|
||||
const Land& land = record.get();
|
||||
|
||||
DataType values(Size, 0);
|
||||
|
||||
if (land.isDataLoaded(Land::DATA_VNML))
|
||||
{
|
||||
for (int i = 0; i < Size; ++i)
|
||||
values[i] = land.getLandData()->mNormals[i];
|
||||
}
|
||||
|
||||
QVariant variant;
|
||||
variant.setValue(values);
|
||||
return variant;
|
||||
}
|
||||
|
||||
void LandNormalsColumn::set(Record<Land>& record, const QVariant& data)
|
||||
{
|
||||
DataType values = data.value<DataType>();
|
||||
|
||||
if (values.size() != Land::LAND_NUM_VERTS * 3)
|
||||
throw std::runtime_error("invalid land normals data");
|
||||
|
||||
Land copy = record.get();
|
||||
copy.setDataLoaded(Land::DATA_VNML);
|
||||
|
||||
for (int i = 0; i < values.size(); ++i)
|
||||
{
|
||||
copy.getLandData()->mNormals[i] = values[i];
|
||||
}
|
||||
|
||||
record.setModified(copy);
|
||||
}
|
||||
|
||||
bool LandNormalsColumn::isEditable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* LandHeightsColumn */
|
||||
LandHeightsColumn::LandHeightsColumn()
|
||||
: Column<Land>(Columns::ColumnId_LandHeightsIndex, ColumnBase::Display_String, 0)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant LandHeightsColumn::get(const Record<Land>& record) const
|
||||
{
|
||||
const int Size = Land::LAND_NUM_VERTS;
|
||||
const Land& land = record.get();
|
||||
|
||||
DataType values(Size, 0);
|
||||
|
||||
if (land.isDataLoaded(Land::DATA_VHGT))
|
||||
{
|
||||
for (int i = 0; i < Size; ++i)
|
||||
values[i] = land.getLandData()->mHeights[i];
|
||||
}
|
||||
|
||||
QVariant variant;
|
||||
variant.setValue(values);
|
||||
return variant;
|
||||
}
|
||||
|
||||
void LandHeightsColumn::set(Record<Land>& record, const QVariant& data)
|
||||
{
|
||||
DataType values = data.value<DataType>();
|
||||
|
||||
if (values.size() != Land::LAND_NUM_VERTS)
|
||||
throw std::runtime_error("invalid land heights data");
|
||||
|
||||
Land copy = record.get();
|
||||
copy.setDataLoaded(Land::DATA_VHGT);
|
||||
|
||||
for (int i = 0; i < values.size(); ++i)
|
||||
{
|
||||
copy.getLandData()->mHeights[i] = values[i];
|
||||
}
|
||||
|
||||
record.setModified(copy);
|
||||
}
|
||||
|
||||
bool LandHeightsColumn::isEditable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* LandColoursColumn */
|
||||
LandColoursColumn::LandColoursColumn()
|
||||
: Column<Land>(Columns::ColumnId_LandColoursIndex, ColumnBase::Display_String, 0)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant LandColoursColumn::get(const Record<Land>& record) const
|
||||
{
|
||||
const int Size = Land::LAND_NUM_VERTS * 3;
|
||||
const Land& land = record.get();
|
||||
|
||||
DataType values(Size, 0);
|
||||
|
||||
if (land.isDataLoaded(Land::DATA_VCLR))
|
||||
{
|
||||
for (int i = 0; i < Size; ++i)
|
||||
values[i] = land.getLandData()->mColours[i];
|
||||
}
|
||||
|
||||
QVariant variant;
|
||||
variant.setValue(values);
|
||||
return variant;
|
||||
}
|
||||
|
||||
void LandColoursColumn::set(Record<Land>& record, const QVariant& data)
|
||||
{
|
||||
DataType values = data.value<DataType>();
|
||||
|
||||
if (values.size() != Land::LAND_NUM_VERTS * 3)
|
||||
throw std::runtime_error("invalid land colours data");
|
||||
|
||||
Land copy = record.get();
|
||||
copy.setDataLoaded(Land::DATA_VCLR);
|
||||
|
||||
for (int i = 0; i < values.size(); ++i)
|
||||
{
|
||||
copy.getLandData()->mColours[i] = values[i];
|
||||
}
|
||||
|
||||
record.setModified(copy);
|
||||
}
|
||||
|
||||
bool LandColoursColumn::isEditable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* LandTexturesColumn */
|
||||
LandTexturesColumn::LandTexturesColumn()
|
||||
: Column<Land>(Columns::ColumnId_LandTexturesIndex, ColumnBase::Display_String, 0)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant LandTexturesColumn::get(const Record<Land>& record) const
|
||||
{
|
||||
const int Size = Land::LAND_NUM_TEXTURES;
|
||||
const Land& land = record.get();
|
||||
|
||||
DataType values(Size, 0);
|
||||
|
||||
if (land.isDataLoaded(Land::DATA_VTEX))
|
||||
{
|
||||
for (int i = 0; i < Size; ++i)
|
||||
values[i] = land.getLandData()->mTextures[i];
|
||||
}
|
||||
|
||||
QVariant variant;
|
||||
variant.setValue(values);
|
||||
return variant;
|
||||
}
|
||||
|
||||
void LandTexturesColumn::set(Record<Land>& record, const QVariant& data)
|
||||
{
|
||||
DataType values = data.value<DataType>();
|
||||
|
||||
if (values.size() != Land::LAND_NUM_TEXTURES)
|
||||
throw std::runtime_error("invalid land textures data");
|
||||
|
||||
Land copy = record.get();
|
||||
copy.setDataLoaded(Land::DATA_VTEX);
|
||||
|
||||
for (int i = 0; i < values.size(); ++i)
|
||||
{
|
||||
copy.getLandData()->mTextures[i] = values[i];
|
||||
}
|
||||
|
||||
record.setModified(copy);
|
||||
}
|
||||
|
||||
bool LandTexturesColumn::isEditable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* BodyPartRaceColumn */
|
||||
BodyPartRaceColumn::BodyPartRaceColumn(const MeshTypeColumn<ESM::BodyPart> *meshType)
|
||||
: mMeshType(meshType)
|
||||
{}
|
||||
|
||||
QVariant BodyPartRaceColumn::get(const Record<ESM::BodyPart> &record) const
|
||||
{
|
||||
if (mMeshType != NULL && mMeshType->get(record) == ESM::BodyPart::MT_Skin)
|
||||
{
|
||||
return QString::fromUtf8(record.get().mRace.c_str());
|
||||
}
|
||||
return QVariant(QVariant::UserType);
|
||||
}
|
||||
|
||||
void BodyPartRaceColumn::set(Record<ESM::BodyPart> &record, const QVariant &data)
|
||||
{
|
||||
ESM::BodyPart record2 = record.get();
|
||||
|
||||
record2.mRace = data.toString().toUtf8().constData();
|
||||
|
||||
record.setModified(record2);
|
||||
}
|
||||
|
||||
bool BodyPartRaceColumn::isEditable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,30 @@
|
||||
#include "land.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
void Land::load(ESM::ESMReader &esm, bool &isDeleted)
|
||||
{
|
||||
ESM::Land::load(esm, isDeleted);
|
||||
}
|
||||
|
||||
std::string Land::createUniqueRecordId(int x, int y)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "#" << mX << " " << mY;
|
||||
mId = stream.str();
|
||||
stream << "#" << x << " " << y;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
void Land::parseUniqueRecordId(const std::string& id, int& x, int& y)
|
||||
{
|
||||
size_t mid = id.find(' ');
|
||||
|
||||
if (mid == std::string::npos || id[0] != '#')
|
||||
throw std::runtime_error("Invalid Land ID");
|
||||
|
||||
x = std::stoi(id.substr(1, mid - 1));
|
||||
y = std::stoi(id.substr(mid + 1));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
#include "landtexturetableproxymodel.hpp"
|
||||
|
||||
#include "idtable.hpp"
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
LandTextureTableProxyModel::LandTextureTableProxyModel(QObject* parent)
|
||||
: IdTableProxyModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool LandTextureTableProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const
|
||||
{
|
||||
int columnIndex = mSourceModel->findColumnIndex(Columns::ColumnId_Modification);
|
||||
QModelIndex index = mSourceModel->index(sourceRow, columnIndex);
|
||||
if (mSourceModel->data(index).toInt() != RecordBase::State_ModifiedOnly)
|
||||
return false;
|
||||
|
||||
return IdTableProxyModel::filterAcceptsRow(sourceRow, sourceParent);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
#ifndef CSM_WORLD_LANDTEXTURETABLEPROXYMODEL_H
|
||||
#define CSM_WORLD_LANDTEXTURETABLEPROXYMODEL_H
|
||||
|
||||
#include "idtableproxymodel.hpp"
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
/// \brief Removes base records from filtered results.
|
||||
class LandTextureTableProxyModel : public IdTableProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
LandTextureTableProxyModel(QObject* parent = nullptr);
|
||||
|
||||
protected:
|
||||
|
||||
bool filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,120 @@
|
||||
#include "landcreator.hpp"
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QSpinBox>
|
||||
|
||||
#include "../../model/world/commands.hpp"
|
||||
#include "../../model/world/idtable.hpp"
|
||||
#include "../../model/world/land.hpp"
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
LandCreator::LandCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id)
|
||||
: GenericCreator(data, undoStack, id)
|
||||
, mXLabel(nullptr)
|
||||
, mYLabel(nullptr)
|
||||
, mX(nullptr)
|
||||
, mY(nullptr)
|
||||
{
|
||||
const int MaxInt = std::numeric_limits<int>::max();
|
||||
const int MinInt = std::numeric_limits<int>::min();
|
||||
|
||||
setManualEditing(false);
|
||||
|
||||
mXLabel = new QLabel("X: ");
|
||||
mX = new QSpinBox();
|
||||
mX->setMinimum(MinInt);
|
||||
mX->setMaximum(MaxInt);
|
||||
insertBeforeButtons(mXLabel, false);
|
||||
insertBeforeButtons(mX, true);
|
||||
|
||||
mYLabel = new QLabel("Y: ");
|
||||
mY = new QSpinBox();
|
||||
mY->setMinimum(MinInt);
|
||||
mY->setMaximum(MaxInt);
|
||||
insertBeforeButtons(mYLabel, false);
|
||||
insertBeforeButtons(mY, true);
|
||||
|
||||
connect (mX, SIGNAL(valueChanged(int)), this, SLOT(coordChanged(int)));
|
||||
connect (mY, SIGNAL(valueChanged(int)), this, SLOT(coordChanged(int)));
|
||||
}
|
||||
|
||||
void LandCreator::cloneMode(const std::string& originId, const CSMWorld::UniversalId::Type type)
|
||||
{
|
||||
GenericCreator::cloneMode(originId, type);
|
||||
|
||||
int x = 0, y = 0;
|
||||
CSMWorld::Land::parseUniqueRecordId(originId, x, y);
|
||||
|
||||
mX->setValue(x);
|
||||
mY->setValue(y);
|
||||
}
|
||||
|
||||
void LandCreator::touch(const std::vector<CSMWorld::UniversalId>& ids)
|
||||
{
|
||||
// Combine multiple touch commands into one "macro" command
|
||||
getUndoStack().beginMacro("Touch records");
|
||||
|
||||
CSMWorld::IdTable& lands = dynamic_cast<CSMWorld::IdTable&>(*getData().getTableModel(CSMWorld::UniversalId::Type_Lands));
|
||||
CSMWorld::IdTable& ltexs = dynamic_cast<CSMWorld::IdTable&>(*getData().getTableModel(CSMWorld::UniversalId::Type_LandTextures));
|
||||
for (const CSMWorld::UniversalId& uid : ids)
|
||||
{
|
||||
CSMWorld::TouchLandCommand* touchCmd = new CSMWorld::TouchLandCommand(lands, ltexs, uid.getId());
|
||||
getUndoStack().push(touchCmd);
|
||||
}
|
||||
|
||||
// Execute
|
||||
getUndoStack().endMacro();
|
||||
}
|
||||
|
||||
void LandCreator::focus()
|
||||
{
|
||||
mX->setFocus();
|
||||
}
|
||||
|
||||
void LandCreator::reset()
|
||||
{
|
||||
GenericCreator::reset();
|
||||
mX->setValue(0);
|
||||
mY->setValue(0);
|
||||
}
|
||||
|
||||
std::string LandCreator::getErrors() const
|
||||
{
|
||||
if (getData().getLand().searchId(getId()) >= 0)
|
||||
return "A land with that name already exists.";
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string LandCreator::getId() const
|
||||
{
|
||||
return CSMWorld::Land::createUniqueRecordId(mX->value(), mY->value());
|
||||
}
|
||||
|
||||
void LandCreator::pushCommand(std::unique_ptr<CSMWorld::CreateCommand> command, const std::string& id)
|
||||
{
|
||||
if (mCloneMode)
|
||||
{
|
||||
CSMWorld::IdTable& lands = dynamic_cast<CSMWorld::IdTable&>(*getData().getTableModel(CSMWorld::UniversalId::Type_Lands));
|
||||
CSMWorld::IdTable& ltexs = dynamic_cast<CSMWorld::IdTable&>(*getData().getTableModel(CSMWorld::UniversalId::Type_LandTextures));
|
||||
|
||||
getUndoStack().beginMacro(("Clone " + id).c_str());
|
||||
getUndoStack().push(command.release());
|
||||
|
||||
CSMWorld::CopyLandTexturesCommand* ltexCopy = new CSMWorld::CopyLandTexturesCommand(lands, ltexs, getClonedId(), getId());
|
||||
getUndoStack().push(ltexCopy);
|
||||
|
||||
getUndoStack().endMacro();
|
||||
}
|
||||
else
|
||||
getUndoStack().push (command.release());
|
||||
}
|
||||
|
||||
void LandCreator::coordChanged(int value)
|
||||
{
|
||||
update();
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
#ifndef CSV_WORLD_LANDCREATOR_H
|
||||
#define CSV_WORLD_LANDCREATOR_H
|
||||
|
||||
#include "genericcreator.hpp"
|
||||
|
||||
class QLabel;
|
||||
class QSpinBox;
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class LandCreator : public GenericCreator
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QLabel* mXLabel;
|
||||
QLabel* mYLabel;
|
||||
QSpinBox* mX;
|
||||
QSpinBox* mY;
|
||||
|
||||
public:
|
||||
|
||||
LandCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id);
|
||||
|
||||
void cloneMode(const std::string& originId, const CSMWorld::UniversalId::Type type) override;
|
||||
|
||||
void touch(const std::vector<CSMWorld::UniversalId>& ids) override;
|
||||
|
||||
void focus() override;
|
||||
|
||||
void reset() override;
|
||||
|
||||
std::string getErrors() const override;
|
||||
|
||||
protected:
|
||||
|
||||
std::string getId() const override;
|
||||
|
||||
void pushCommand(std::unique_ptr<CSMWorld::CreateCommand> command,
|
||||
const std::string& id) override;
|
||||
|
||||
private slots:
|
||||
|
||||
void coordChanged(int value);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,101 @@
|
||||
#include "landtexturecreator.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QSpinBox>
|
||||
|
||||
#include "../../model/world/commands.hpp"
|
||||
#include "../../model/world/idtable.hpp"
|
||||
#include "../../model/world/landtexture.hpp"
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
LandTextureCreator::LandTextureCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id)
|
||||
: GenericCreator(data, undoStack, id)
|
||||
{
|
||||
// One index is reserved for a default texture
|
||||
const size_t MaxIndex = std::numeric_limits<uint16_t>::max() - 1;
|
||||
|
||||
setManualEditing(false);
|
||||
|
||||
QLabel* nameLabel = new QLabel("Name");
|
||||
insertBeforeButtons(nameLabel, false);
|
||||
|
||||
mNameEdit = new QLineEdit(this);
|
||||
insertBeforeButtons(mNameEdit, true);
|
||||
|
||||
QLabel* indexLabel = new QLabel("Index");
|
||||
insertBeforeButtons(indexLabel, false);
|
||||
|
||||
mIndexBox = new QSpinBox(this);
|
||||
mIndexBox->setMinimum(0);
|
||||
mIndexBox->setMaximum(MaxIndex);
|
||||
insertBeforeButtons(mIndexBox, true);
|
||||
|
||||
connect(mNameEdit, SIGNAL(textChanged(const QString&)), this, SLOT(nameChanged(const QString&)));
|
||||
connect(mIndexBox, SIGNAL(valueChanged(int)), this, SLOT(indexChanged(int)));
|
||||
}
|
||||
|
||||
void LandTextureCreator::cloneMode(const std::string& originId, const CSMWorld::UniversalId::Type type)
|
||||
{
|
||||
GenericCreator::cloneMode(originId, type);
|
||||
|
||||
CSMWorld::IdTable& table = dynamic_cast<CSMWorld::IdTable&>(*getData().getTableModel(getCollectionId()));
|
||||
|
||||
int column = table.findColumnIndex(CSMWorld::Columns::ColumnId_TextureNickname);
|
||||
mNameEdit->setText((table.data(table.getModelIndex(originId, column)).toString()));
|
||||
|
||||
column = table.findColumnIndex(CSMWorld::Columns::ColumnId_TextureIndex);
|
||||
mIndexBox->setValue((table.data(table.getModelIndex(originId, column)).toInt()));
|
||||
}
|
||||
|
||||
void LandTextureCreator::focus()
|
||||
{
|
||||
mIndexBox->setFocus();
|
||||
}
|
||||
|
||||
void LandTextureCreator::reset()
|
||||
{
|
||||
GenericCreator::reset();
|
||||
mNameEdit->setText("");
|
||||
mIndexBox->setValue(0);
|
||||
}
|
||||
|
||||
std::string LandTextureCreator::getErrors() const
|
||||
{
|
||||
if (getData().getLandTextures().searchId(getId()) >= 0)
|
||||
{
|
||||
return "Index is already in use";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void LandTextureCreator::configureCreateCommand(CSMWorld::CreateCommand& command) const
|
||||
{
|
||||
GenericCreator::configureCreateCommand(command);
|
||||
|
||||
CSMWorld::IdTable& table = dynamic_cast<CSMWorld::IdTable&>(*getData().getTableModel(getCollectionId()));
|
||||
int column = table.findColumnIndex(CSMWorld::Columns::ColumnId_TextureNickname);
|
||||
command.addValue(column, mName.c_str());
|
||||
}
|
||||
|
||||
std::string LandTextureCreator::getId() const
|
||||
{
|
||||
return CSMWorld::LandTexture::createUniqueRecordId(0, mIndexBox->value());
|
||||
}
|
||||
|
||||
void LandTextureCreator::nameChanged(const QString& value)
|
||||
{
|
||||
mName = value.toUtf8().constData();
|
||||
update();
|
||||
}
|
||||
|
||||
void LandTextureCreator::indexChanged(int value)
|
||||
{
|
||||
update();
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
#ifndef CSV_WORLD_LANDTEXTURECREATOR_H
|
||||
#define CSV_WORLD_LANDTEXTURECREATOR_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "genericcreator.hpp"
|
||||
|
||||
class QLineEdit;
|
||||
class QSpinBox;
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class LandTextureCreator : public GenericCreator
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
LandTextureCreator(CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id);
|
||||
|
||||
void cloneMode(const std::string& originId, const CSMWorld::UniversalId::Type type) override;
|
||||
|
||||
void focus() override;
|
||||
|
||||
void reset() override;
|
||||
|
||||
std::string getErrors() const override;
|
||||
|
||||
protected:
|
||||
|
||||
void configureCreateCommand(CSMWorld::CreateCommand& command) const override;
|
||||
|
||||
std::string getId() const override;
|
||||
|
||||
private slots:
|
||||
|
||||
void nameChanged(const QString& val);
|
||||
void indexChanged(int val);
|
||||
|
||||
private:
|
||||
|
||||
QLineEdit* mNameEdit;
|
||||
QSpinBox* mIndexBox;
|
||||
|
||||
std::string mName;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue