mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 10:23:56 +00:00
Cleanup. Also modify ltex index generation.
This commit is contained in:
parent
97d0fd756a
commit
99e90ef808
12 changed files with 42 additions and 35 deletions
|
@ -278,6 +278,7 @@ void CSMPrefs::State::declare()
|
||||||
declareShortcut ("table-edit", "Edit Record", QKeySequence());
|
declareShortcut ("table-edit", "Edit Record", QKeySequence());
|
||||||
declareShortcut ("table-add", "Add Row/Record", QKeySequence(Qt::ShiftModifier | Qt::Key_A));
|
declareShortcut ("table-add", "Add Row/Record", QKeySequence(Qt::ShiftModifier | Qt::Key_A));
|
||||||
declareShortcut ("table-clone", "Clone Record", QKeySequence(Qt::ShiftModifier | Qt::Key_D));
|
declareShortcut ("table-clone", "Clone Record", QKeySequence(Qt::ShiftModifier | Qt::Key_D));
|
||||||
|
declareShortcut ("touch-record", "Touch Record", QKeySequence());
|
||||||
declareShortcut ("table-revert", "Revert Record", QKeySequence());
|
declareShortcut ("table-revert", "Revert Record", QKeySequence());
|
||||||
declareShortcut ("table-remove", "Remove Row/Record", QKeySequence(Qt::Key_Delete));
|
declareShortcut ("table-remove", "Remove Row/Record", QKeySequence(Qt::Key_Delete));
|
||||||
declareShortcut ("table-moveup", "Move Record Up", QKeySequence());
|
declareShortcut ("table-moveup", "Move Record Up", QKeySequence());
|
||||||
|
|
|
@ -48,8 +48,6 @@ namespace CSMWorld
|
||||||
Land::parseUniqueRecordId(id, x, y);
|
Land::parseUniqueRecordId(id, x, y);
|
||||||
record.mX = x;
|
record.mX = x;
|
||||||
record.mY = y;
|
record.mY = y;
|
||||||
// TODO check for uses of mId and remove them
|
|
||||||
record.mId = id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
|
@ -63,6 +63,13 @@ namespace CSMWorld
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline QVariant StringIdColumn<Land>::get(const Record<Land>& record) const
|
||||||
|
{
|
||||||
|
const Land& land = record.get();
|
||||||
|
return QString(Land::createUniqueRecordId(land.mX, land.mY).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline QVariant StringIdColumn<LandTexture>::get(const Record<LandTexture>& record) const
|
inline QVariant StringIdColumn<LandTexture>::get(const Record<LandTexture>& record) const
|
||||||
{
|
{
|
||||||
|
@ -2483,7 +2490,7 @@ namespace CSMWorld
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isEditable() const override
|
bool isEditable() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -333,6 +333,11 @@ namespace CSMWorld
|
||||||
{ ColumnId_TextureHandle, "Texture Handle" },
|
{ ColumnId_TextureHandle, "Texture Handle" },
|
||||||
{ ColumnId_PluginIndex, "Plugin Index" },
|
{ ColumnId_PluginIndex, "Plugin Index" },
|
||||||
{ ColumnId_TextureIndex, "Texture Index" },
|
{ ColumnId_TextureIndex, "Texture Index" },
|
||||||
|
{ ColumnId_LandMapLodIndex, "Land map height LOD" },
|
||||||
|
{ ColumnId_LandNormalsIndex, "Land normals" },
|
||||||
|
{ ColumnId_LandHeightsIndex, "Land heights" },
|
||||||
|
{ ColumnId_LandColoursIndex, "Land colors" },
|
||||||
|
{ ColumnId_LandTexturesIndex, "Land textures" },
|
||||||
|
|
||||||
{ ColumnId_UseValue1, "Use value 1" },
|
{ ColumnId_UseValue1, "Use value 1" },
|
||||||
{ ColumnId_UseValue2, "Use value 2" },
|
{ ColumnId_UseValue2, "Use value 2" },
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "idtable.hpp"
|
#include "idtable.hpp"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
@ -379,11 +380,10 @@ CSMWorld::LandTextureIdTable::ImportResults CSMWorld::LandTextureIdTable::import
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine next index. Spread out the indices to reduce conflicts.
|
// Determine next index. Spread out the indices to reduce conflicts.
|
||||||
size_t MaxIndex = std::numeric_limits<uint16_t>::max();
|
size_t MaxIndex = std::numeric_limits<uint16_t>::max() - 1;
|
||||||
size_t Prime = (1 << 19) - 1; // A mersenne prime
|
size_t Prime = (1 << 13) - 1; // A mersenne prime
|
||||||
size_t K = 2154;
|
|
||||||
|
|
||||||
index = ((K * index) % Prime) % MaxIndex;
|
index = (index + Prime) % MaxIndex;
|
||||||
} while (true);
|
} while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,6 @@ namespace CSMWorld
|
||||||
void Land::load(ESM::ESMReader &esm, bool &isDeleted)
|
void Land::load(ESM::ESMReader &esm, bool &isDeleted)
|
||||||
{
|
{
|
||||||
ESM::Land::load(esm, isDeleted);
|
ESM::Land::load(esm, isDeleted);
|
||||||
|
|
||||||
mId = createUniqueRecordId(mX, mY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Land::createUniqueRecordId(int x, int y)
|
std::string Land::createUniqueRecordId(int x, int y)
|
||||||
|
|
|
@ -12,8 +12,6 @@ namespace CSMWorld
|
||||||
/// \todo Add worldspace support to the Land record.
|
/// \todo Add worldspace support to the Land record.
|
||||||
struct Land : public ESM::Land
|
struct Land : public ESM::Land
|
||||||
{
|
{
|
||||||
std::string mId;
|
|
||||||
|
|
||||||
/// Loads the metadata and ID
|
/// Loads the metadata and ID
|
||||||
void load (ESM::ESMReader &esm, bool &isDeleted);
|
void load (ESM::ESMReader &esm, bool &isDeleted);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "landtexture.hpp"
|
#include "landtexture.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <components/esm/esmreader.hpp>
|
#include <components/esm/esmreader.hpp>
|
||||||
|
@ -16,7 +16,9 @@ namespace CSMWorld
|
||||||
|
|
||||||
std::string LandTexture::createUniqueRecordId(int plugin, int index)
|
std::string LandTexture::createUniqueRecordId(int plugin, int index)
|
||||||
{
|
{
|
||||||
return 'L' + std::to_string(plugin) + '#' + std::to_string(index);
|
std::stringstream ss;
|
||||||
|
ss << 'L' << plugin << '#' << index;
|
||||||
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandTexture::parseUniqueRecordId(const std::string& id, int& plugin, int& index)
|
void LandTexture::parseUniqueRecordId(const std::string& id, int& plugin, int& index)
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QSpinBox>
|
||||||
|
|
||||||
#include "../../model/world/commands.hpp"
|
#include "../../model/world/commands.hpp"
|
||||||
#include "../../model/world/idtable.hpp"
|
#include "../../model/world/idtable.hpp"
|
||||||
#include "../../model/world/land.hpp"
|
#include "../../model/world/land.hpp"
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#ifndef CSV_WORLD_LANDCREATOR_H
|
#ifndef CSV_WORLD_LANDCREATOR_H
|
||||||
#define CSV_WORLD_LANDCREATOR_H
|
#define CSV_WORLD_LANDCREATOR_H
|
||||||
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QSpinBox>
|
|
||||||
|
|
||||||
#include "genericcreator.hpp"
|
#include "genericcreator.hpp"
|
||||||
|
|
||||||
|
class QLabel;
|
||||||
|
class QSpinBox;
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
{
|
{
|
||||||
class LandCreator : public GenericCreator
|
class LandCreator : public GenericCreator
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include <QIntValidator>
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
#include <QSpinBox>
|
||||||
|
|
||||||
#include "../../model/world/commands.hpp"
|
#include "../../model/world/commands.hpp"
|
||||||
#include "../../model/world/idtable.hpp"
|
#include "../../model/world/idtable.hpp"
|
||||||
|
@ -30,14 +30,13 @@ namespace CSVWorld
|
||||||
QLabel* indexLabel = new QLabel("Index");
|
QLabel* indexLabel = new QLabel("Index");
|
||||||
insertBeforeButtons(indexLabel, false);
|
insertBeforeButtons(indexLabel, false);
|
||||||
|
|
||||||
QIntValidator* indexValidator = new QIntValidator(0, MaxIndex, this);
|
mIndexBox = new QSpinBox(this);
|
||||||
|
mIndexBox->setMinimum(0);
|
||||||
mIndexEdit = new QLineEdit(this);
|
mIndexBox->setMaximum(MaxIndex);
|
||||||
mIndexEdit->setValidator(indexValidator);
|
insertBeforeButtons(mIndexBox, true);
|
||||||
insertBeforeButtons(mIndexEdit, true);
|
|
||||||
|
|
||||||
connect(mNameEdit, SIGNAL(textChanged(const QString&)), this, SLOT(nameChanged(const QString&)));
|
connect(mNameEdit, SIGNAL(textChanged(const QString&)), this, SLOT(nameChanged(const QString&)));
|
||||||
connect(mIndexEdit, SIGNAL(textChanged(const QString&)), this, SLOT(indexChanged(const QString&)));
|
connect(mIndexBox, SIGNAL(valueChanged(int)), this, SLOT(indexChanged(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandTextureCreator::cloneMode(const std::string& originId, const CSMWorld::UniversalId::Type type)
|
void LandTextureCreator::cloneMode(const std::string& originId, const CSMWorld::UniversalId::Type type)
|
||||||
|
@ -50,26 +49,23 @@ namespace CSVWorld
|
||||||
mNameEdit->setText((table.data(table.getModelIndex(originId, column)).toString()));
|
mNameEdit->setText((table.data(table.getModelIndex(originId, column)).toString()));
|
||||||
|
|
||||||
column = table.findColumnIndex(CSMWorld::Columns::ColumnId_TextureIndex);
|
column = table.findColumnIndex(CSMWorld::Columns::ColumnId_TextureIndex);
|
||||||
mIndexEdit->setText((table.data(table.getModelIndex(originId, column)).toString()));
|
mIndexBox->setValue((table.data(table.getModelIndex(originId, column)).toInt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandTextureCreator::focus()
|
void LandTextureCreator::focus()
|
||||||
{
|
{
|
||||||
mIndexEdit->setFocus();
|
mIndexBox->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandTextureCreator::reset()
|
void LandTextureCreator::reset()
|
||||||
{
|
{
|
||||||
GenericCreator::reset();
|
GenericCreator::reset();
|
||||||
mNameEdit->setText("");
|
mNameEdit->setText("");
|
||||||
mIndexEdit->setText("");
|
mIndexBox->setValue(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string LandTextureCreator::getErrors() const
|
std::string LandTextureCreator::getErrors() const
|
||||||
{
|
{
|
||||||
std::string id = getId();
|
|
||||||
|
|
||||||
// TODO empty index edit?
|
|
||||||
if (getData().getLandTextures().searchId(getId()) >= 0)
|
if (getData().getLandTextures().searchId(getId()) >= 0)
|
||||||
{
|
{
|
||||||
return "Index is already in use";
|
return "Index is already in use";
|
||||||
|
@ -89,7 +85,7 @@ namespace CSVWorld
|
||||||
|
|
||||||
std::string LandTextureCreator::getId() const
|
std::string LandTextureCreator::getId() const
|
||||||
{
|
{
|
||||||
return CSMWorld::LandTexture::createUniqueRecordId(0, mIndex);
|
return CSMWorld::LandTexture::createUniqueRecordId(0, mIndexBox->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandTextureCreator::nameChanged(const QString& value)
|
void LandTextureCreator::nameChanged(const QString& value)
|
||||||
|
@ -98,9 +94,8 @@ namespace CSVWorld
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandTextureCreator::indexChanged(const QString& value)
|
void LandTextureCreator::indexChanged(int value)
|
||||||
{
|
{
|
||||||
mIndex = value.toInt();
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "genericcreator.hpp"
|
#include "genericcreator.hpp"
|
||||||
|
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
|
class QSpinBox;
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
{
|
{
|
||||||
|
@ -34,15 +35,14 @@ namespace CSVWorld
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void nameChanged(const QString& val);
|
void nameChanged(const QString& val);
|
||||||
void indexChanged(const QString& val);
|
void indexChanged(int val);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QLineEdit* mNameEdit;
|
QLineEdit* mNameEdit;
|
||||||
QLineEdit* mIndexEdit;
|
QSpinBox* mIndexBox;
|
||||||
|
|
||||||
std::string mName;
|
std::string mName;
|
||||||
int mIndex;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue