forked from mirror/openmw-tes3mp
Handle invalid texture id's
This commit is contained in:
parent
c2cddc91e4
commit
21e8d08e69
2 changed files with 97 additions and 38 deletions
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
CSVRender::TerrainTextureMode::TerrainTextureMode (WorldspaceWidget *worldspaceWidget, QWidget *parent)
|
CSVRender::TerrainTextureMode::TerrainTextureMode (WorldspaceWidget *worldspaceWidget, QWidget *parent)
|
||||||
: EditMode (worldspaceWidget, QIcon {":scenetoolbar/editing-terrain-texture"}, Mask_Terrain | Mask_Reference, "Terrain texture editing", parent),
|
: EditMode (worldspaceWidget, QIcon {":scenetoolbar/editing-terrain-texture"}, Mask_Terrain | Mask_Reference, "Terrain texture editing", parent),
|
||||||
mBrushTexture("#0"),
|
mBrushTexture("L0#0"),
|
||||||
mBrushSize(0),
|
mBrushSize(0),
|
||||||
mBrushShape(0),
|
mBrushShape(0),
|
||||||
mTextureBrushScenetool(0)
|
mTextureBrushScenetool(0)
|
||||||
|
@ -87,13 +87,19 @@ void CSVRender::TerrainTextureMode::primaryEditPressed(const WorldspaceHitResult
|
||||||
mCellId = getWorldspaceWidget().getCellId (hit.worldPos);
|
mCellId = getWorldspaceWidget().getCellId (hit.worldPos);
|
||||||
|
|
||||||
QUndoStack& undoStack = document.getUndoStack();
|
QUndoStack& undoStack = document.getUndoStack();
|
||||||
undoStack.beginMacro ("Edit texture records");
|
CSMWorld::IdCollection<CSMWorld::LandTexture>& landtexturesCollection = document.getData().getLandTextures();
|
||||||
if(allowLandTextureEditing(mCellId)==true)
|
int index = landtexturesCollection.searchId(mBrushTexture);
|
||||||
|
|
||||||
|
if (index != -1 && !landtexturesCollection.getRecord(index).isDeleted())
|
||||||
{
|
{
|
||||||
undoStack.push (new CSMWorld::TouchLandCommand(landTable, ltexTable, mCellId));
|
undoStack.beginMacro ("Edit texture records");
|
||||||
editTerrainTextureGrid(hit);
|
if(allowLandTextureEditing(mCellId)==true)
|
||||||
|
{
|
||||||
|
undoStack.push (new CSMWorld::TouchLandCommand(landTable, ltexTable, mCellId));
|
||||||
|
editTerrainTextureGrid(hit);
|
||||||
|
}
|
||||||
|
undoStack.endMacro();
|
||||||
}
|
}
|
||||||
undoStack.endMacro();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::TerrainTextureMode::primarySelectPressed(const WorldspaceHitResult& hit)
|
void CSVRender::TerrainTextureMode::primarySelectPressed(const WorldspaceHitResult& hit)
|
||||||
|
@ -117,11 +123,18 @@ bool CSVRender::TerrainTextureMode::primaryEditStartDrag (const QPoint& pos)
|
||||||
mCellId = getWorldspaceWidget().getCellId (hit.worldPos);
|
mCellId = getWorldspaceWidget().getCellId (hit.worldPos);
|
||||||
|
|
||||||
QUndoStack& undoStack = document.getUndoStack();
|
QUndoStack& undoStack = document.getUndoStack();
|
||||||
undoStack.beginMacro ("Edit texture records");
|
|
||||||
if(allowLandTextureEditing(mCellId)==true)
|
CSMWorld::IdCollection<CSMWorld::LandTexture>& landtexturesCollection = document.getData().getLandTextures();
|
||||||
|
int index = landtexturesCollection.searchId(mBrushTexture);
|
||||||
|
|
||||||
|
if (index != -1 && !landtexturesCollection.getRecord(index).isDeleted())
|
||||||
{
|
{
|
||||||
undoStack.push (new CSMWorld::TouchLandCommand(landTable, ltexTable, mCellId));
|
undoStack.beginMacro ("Edit texture records");
|
||||||
editTerrainTextureGrid(hit);
|
if(allowLandTextureEditing(mCellId)==true)
|
||||||
|
{
|
||||||
|
undoStack.push (new CSMWorld::TouchLandCommand(landTable, ltexTable, mCellId));
|
||||||
|
editTerrainTextureGrid(hit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -145,13 +158,28 @@ bool CSVRender::TerrainTextureMode::secondarySelectStartDrag (const QPoint& pos)
|
||||||
void CSVRender::TerrainTextureMode::drag (const QPoint& pos, int diffX, int diffY, double speedFactor)
|
void CSVRender::TerrainTextureMode::drag (const QPoint& pos, int diffX, int diffY, double speedFactor)
|
||||||
{
|
{
|
||||||
WorldspaceHitResult hit = getWorldspaceWidget().mousePick (pos, getWorldspaceWidget().getInteractionMask());
|
WorldspaceHitResult hit = getWorldspaceWidget().mousePick (pos, getWorldspaceWidget().getInteractionMask());
|
||||||
editTerrainTextureGrid(hit);
|
CSMDoc::Document& document = getWorldspaceWidget().getDocument();
|
||||||
|
|
||||||
|
CSMWorld::IdCollection<CSMWorld::LandTexture>& landtexturesCollection = document.getData().getLandTextures();
|
||||||
|
int index = landtexturesCollection.searchId(mBrushTexture);
|
||||||
|
|
||||||
|
if (index != -1 && !landtexturesCollection.getRecord(index).isDeleted())
|
||||||
|
{
|
||||||
|
editTerrainTextureGrid(hit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::TerrainTextureMode::dragCompleted(const QPoint& pos) {
|
void CSVRender::TerrainTextureMode::dragCompleted(const QPoint& pos) {
|
||||||
CSMDoc::Document& document = getWorldspaceWidget().getDocument();
|
CSMDoc::Document& document = getWorldspaceWidget().getDocument();
|
||||||
QUndoStack& undoStack = document.getUndoStack();
|
QUndoStack& undoStack = document.getUndoStack();
|
||||||
undoStack.endMacro();
|
|
||||||
|
CSMWorld::IdCollection<CSMWorld::LandTexture>& landtexturesCollection = document.getData().getLandTextures();
|
||||||
|
int index = landtexturesCollection.searchId(mBrushTexture);
|
||||||
|
|
||||||
|
if (index != -1 && !landtexturesCollection.getRecord(index).isDeleted())
|
||||||
|
{
|
||||||
|
undoStack.endMacro();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::TerrainTextureMode::dragAborted() {
|
void CSVRender::TerrainTextureMode::dragAborted() {
|
||||||
|
|
|
@ -25,8 +25,10 @@
|
||||||
#include "../../model/doc/document.hpp"
|
#include "../../model/doc/document.hpp"
|
||||||
#include "../../model/prefs/state.hpp"
|
#include "../../model/prefs/state.hpp"
|
||||||
#include "../../model/world/data.hpp"
|
#include "../../model/world/data.hpp"
|
||||||
|
#include "../../model/world/idcollection.hpp"
|
||||||
#include "../../model/world/idtable.hpp"
|
#include "../../model/world/idtable.hpp"
|
||||||
#include "../../model/world/landtexture.hpp"
|
#include "../../model/world/landtexture.hpp"
|
||||||
|
#include "../../model/world/universalid.hpp"
|
||||||
|
|
||||||
|
|
||||||
CSVWidget::BrushSizeControls::BrushSizeControls(const QString &title, QWidget *parent)
|
CSVWidget::BrushSizeControls::BrushSizeControls(const QString &title, QWidget *parent)
|
||||||
|
@ -59,14 +61,21 @@ CSVWidget::TextureBrushWindow::TextureBrushWindow(CSMDoc::Document& document, QW
|
||||||
mBrushTexture("L0#0"),
|
mBrushTexture("L0#0"),
|
||||||
mDocument(document)
|
mDocument(document)
|
||||||
{
|
{
|
||||||
CSMWorld::IdTable& ltexTable = dynamic_cast<CSMWorld::IdTable&> (
|
|
||||||
*mDocument.getData().getTableModel (CSMWorld::UniversalId::Type_LandTextures));
|
|
||||||
|
|
||||||
int landTextureFilename = ltexTable.findColumnIndex(CSMWorld::Columns::ColumnId_Texture);
|
|
||||||
|
|
||||||
QModelIndex index = ltexTable.getModelIndex (mBrushTexture, landTextureFilename);
|
|
||||||
mBrushTextureLabel = "Selected texture: " + mBrushTexture + " ";
|
mBrushTextureLabel = "Selected texture: " + mBrushTexture + " ";
|
||||||
mSelectedBrush = new QLabel(QString::fromStdString(mBrushTextureLabel) + ltexTable.data(index).value<QString>());
|
|
||||||
|
CSMWorld::IdCollection<CSMWorld::LandTexture>& landtexturesCollection = mDocument.getData().getLandTextures();
|
||||||
|
|
||||||
|
int landTextureFilename = landtexturesCollection.findColumnIndex(CSMWorld::Columns::ColumnId_Texture);
|
||||||
|
int index = landtexturesCollection.searchId(mBrushTexture);
|
||||||
|
|
||||||
|
if (index != -1 && !landtexturesCollection.getRecord(index).isDeleted())
|
||||||
|
{
|
||||||
|
mSelectedBrush = new QLabel(QString::fromStdString(mBrushTextureLabel) + landtexturesCollection.getData(index, landTextureFilename).value<QString>());
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
mBrushTextureLabel = "No selected texture or invalid texture";
|
||||||
|
mSelectedBrush = new QLabel(QString::fromStdString(mBrushTextureLabel));
|
||||||
|
}
|
||||||
|
|
||||||
QVBoxLayout *layoutMain = new QVBoxLayout;
|
QVBoxLayout *layoutMain = new QVBoxLayout;
|
||||||
layoutMain->setSpacing(0);
|
layoutMain->setSpacing(0);
|
||||||
|
@ -125,16 +134,22 @@ void CSVWidget::TextureBrushWindow::configureButtonInitialSettings(QPushButton *
|
||||||
|
|
||||||
void CSVWidget::TextureBrushWindow::setBrushTexture(std::string brushTexture)
|
void CSVWidget::TextureBrushWindow::setBrushTexture(std::string brushTexture)
|
||||||
{
|
{
|
||||||
CSMWorld::IdTable& ltexTable = dynamic_cast<CSMWorld::IdTable&> (
|
CSMWorld::IdCollection<CSMWorld::LandTexture>& landtexturesCollection = mDocument.getData().getLandTextures();
|
||||||
*mDocument.getData().getTableModel (CSMWorld::UniversalId::Type_LandTextures));
|
|
||||||
int landTextureFilename = ltexTable.findColumnIndex(CSMWorld::Columns::ColumnId_Texture);
|
|
||||||
|
|
||||||
|
int landTextureFilename = landtexturesCollection.findColumnIndex(CSMWorld::Columns::ColumnId_Texture);
|
||||||
|
int index = landtexturesCollection.searchId(mBrushTexture);
|
||||||
mBrushTexture = brushTexture;
|
mBrushTexture = brushTexture;
|
||||||
mBrushTextureLabel = "Selected texture: " + mBrushTexture + " ";
|
|
||||||
QModelIndex index = ltexTable.getModelIndex (mBrushTexture, landTextureFilename);
|
|
||||||
mSelectedBrush->setText(QString::fromStdString(mBrushTextureLabel) + ltexTable.data(index).value<QString>());
|
|
||||||
emit passBrushShape(mBrushShape); // update icon
|
|
||||||
|
|
||||||
|
if (index != -1 && !landtexturesCollection.getRecord(index).isDeleted())
|
||||||
|
{
|
||||||
|
mSelectedBrush = new QLabel(QString::fromStdString(mBrushTextureLabel) + landtexturesCollection.getData(index, landTextureFilename).value<QString>());
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
mBrushTextureLabel = "No selected texture or invalid texture";
|
||||||
|
mSelectedBrush = new QLabel(QString::fromStdString(mBrushTextureLabel));
|
||||||
|
}
|
||||||
|
|
||||||
|
emit passBrushShape(mBrushShape); // update icon
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWidget::TextureBrushWindow::setBrushSize(int brushSize)
|
void CSVWidget::TextureBrushWindow::setBrushSize(int brushSize)
|
||||||
|
@ -219,13 +234,22 @@ void CSVWidget::SceneToolTextureBrush::setButtonIcon (int brushShape)
|
||||||
setIcon (QIcon (QPixmap (":scenetoolbar/brush-custom")));
|
setIcon (QIcon (QPixmap (":scenetoolbar/brush-custom")));
|
||||||
tooltip += dynamic_cast<QString&> (mTextureBrushWindow->toolTipCustom);
|
tooltip += dynamic_cast<QString&> (mTextureBrushWindow->toolTipCustom);
|
||||||
}
|
}
|
||||||
tooltip += "<p>Selected texture: " + QString::fromStdString(mTextureBrushWindow->mBrushTexture) + " ";
|
|
||||||
|
|
||||||
CSMWorld::IdTable& ltexTable = dynamic_cast<CSMWorld::IdTable&> (
|
CSMWorld::IdCollection<CSMWorld::LandTexture>& landtexturesCollection = mDocument.getData().getLandTextures();
|
||||||
*mDocument.getData().getTableModel (CSMWorld::UniversalId::Type_LandTextures));
|
|
||||||
int landTextureFilename = ltexTable.findColumnIndex(CSMWorld::Columns::ColumnId_Texture);
|
int landTextureFilename = landtexturesCollection.findColumnIndex(CSMWorld::Columns::ColumnId_Texture);
|
||||||
QModelIndex index = ltexTable.getModelIndex (mTextureBrushWindow->mBrushTexture, landTextureFilename);
|
int index = landtexturesCollection.searchId(mTextureBrushWindow->mBrushTexture);
|
||||||
tooltip += ltexTable.data(index).value<QString>();
|
|
||||||
|
if (index != -1 && !landtexturesCollection.getRecord(index).isDeleted())
|
||||||
|
{
|
||||||
|
//QModelIndex qIndex = landtexturesCollection.getModelIndex (mBrushTexture, landTextureFilename);
|
||||||
|
tooltip += "<p>Selected texture: " + QString::fromStdString(mTextureBrushWindow->mBrushTexture) + " ";
|
||||||
|
|
||||||
|
tooltip += landtexturesCollection.getData(index, landTextureFilename).value<QString>();
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
tooltip += "No selected texture or invalid texture";
|
||||||
|
}
|
||||||
|
|
||||||
tooltip += "<br>(drop texture here to change)";
|
tooltip += "<br>(drop texture here to change)";
|
||||||
setToolTip (tooltip);
|
setToolTip (tooltip);
|
||||||
|
@ -244,12 +268,19 @@ void CSVWidget::SceneToolTextureBrush::updatePanel()
|
||||||
|
|
||||||
for (int i = mBrushHistory.size()-1; i >= 0; --i)
|
for (int i = mBrushHistory.size()-1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
CSMWorld::IdTable& ltexTable = dynamic_cast<CSMWorld::IdTable&> (
|
CSMWorld::IdCollection<CSMWorld::LandTexture>& landtexturesCollection = mDocument.getData().getLandTextures();
|
||||||
*mDocument.getData().getTableModel (CSMWorld::UniversalId::Type_LandTextures));
|
int landTextureFilename = landtexturesCollection.findColumnIndex(CSMWorld::Columns::ColumnId_Texture);
|
||||||
int landTextureFilename = ltexTable.findColumnIndex(CSMWorld::Columns::ColumnId_Texture);
|
int index = landtexturesCollection.searchId(mBrushHistory[i]);
|
||||||
QModelIndex index = ltexTable.getModelIndex (mBrushHistory[i], landTextureFilename);
|
|
||||||
mTable->setItem (i, 1, new QTableWidgetItem (ltexTable.data(index).value<QString>()));
|
if (index != -1 && !landtexturesCollection.getRecord(index).isDeleted())
|
||||||
mTable->setItem (i, 0, new QTableWidgetItem (QString::fromStdString(mBrushHistory[i])));
|
{
|
||||||
|
mTable->setItem (i, 1, new QTableWidgetItem (landtexturesCollection.getData(index, landTextureFilename).value<QString>()));
|
||||||
|
mTable->setItem (i, 0, new QTableWidgetItem (QString::fromStdString(mBrushHistory[i])));
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
mTable->setItem (i, 1, new QTableWidgetItem ("Invalid/deleted texture"));
|
||||||
|
mTable->setItem (i, 0, new QTableWidgetItem (QString::fromStdString(mBrushHistory[i])));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue