Formatting, fixes

pull/440/head
Nelsson Huotari 7 years ago
parent 1c113eca9c
commit 1ca2710a2a

@ -1,7 +1,7 @@
#include "terraintexturemode.hpp" #include "terraintexturemode.hpp"
#include "editmode.hpp"
#include <string> #include <string>
#include <sstream>
#include <QWidget> #include <QWidget>
#include <QIcon> #include <QIcon>
@ -16,14 +16,11 @@
#include <QDragEnterEvent> #include <QDragEnterEvent>
#include <QDrag> #include <QDrag>
#include <components/esm/loadland.hpp>
#include "../widget/modebutton.hpp" #include "../widget/modebutton.hpp"
#include "../widget/scenetoolbar.hpp" #include "../widget/scenetoolbar.hpp"
#include "pagedworldspacewidget.hpp"
#include "mask.hpp"
#include "object.hpp" // Something small needed regarding pointers from here ()
#include "worldspacewidget.hpp"
#include "../../model/doc/document.hpp" #include "../../model/doc/document.hpp"
#include "../../model/world/columnbase.hpp" #include "../../model/world/columnbase.hpp"
#include "../../model/world/commandmacro.hpp" #include "../../model/world/commandmacro.hpp"
@ -36,8 +33,11 @@
#include "../../model/world/tablemimedata.hpp" #include "../../model/world/tablemimedata.hpp"
#include "../../model/world/universalid.hpp" #include "../../model/world/universalid.hpp"
#include "editmode.hpp"
#include <components/esm/loadland.hpp> #include "pagedworldspacewidget.hpp"
#include "mask.hpp"
#include "object.hpp" // Something small needed regarding pointers from here ()
#include "worldspacewidget.hpp"
CSVRender::BrushSizeControls::BrushSizeControls(const QString &title, QWidget *parent) CSVRender::BrushSizeControls::BrushSizeControls(const QString &title, QWidget *parent)
@ -68,7 +68,10 @@ CSVRender::TextureBrushButton::TextureBrushButton (const QIcon & icon, const QSt
} }
CSVRender::TextureBrushWindow::TextureBrushWindow(WorldspaceWidget *worldspaceWidget, QWidget *parent) CSVRender::TextureBrushWindow::TextureBrushWindow(WorldspaceWidget *worldspaceWidget, QWidget *parent)
: QFrame(parent, Qt::Popup), mWorldspaceWidget (worldspaceWidget) : QFrame(parent, Qt::Popup),
mWorldspaceWidget (worldspaceWidget),
mBrushSize(0),
mBrushShape(0)
{ {
mBrushTextureLabel = "Brush: " + mBrushTexture; mBrushTextureLabel = "Brush: " + mBrushTexture;
selectedBrush = new QLabel(QString::fromUtf8(mBrushTextureLabel.c_str()), this); selectedBrush = new QLabel(QString::fromUtf8(mBrushTextureLabel.c_str()), this);
@ -116,7 +119,7 @@ CSVRender::TextureBrushWindow::TextureBrushWindow(WorldspaceWidget *worldspaceWi
connect(sizeSliders->brushSizeSlider, SIGNAL(valueChanged(int)), parent, SLOT(setBrushSize(int))); connect(sizeSliders->brushSizeSlider, SIGNAL(valueChanged(int)), parent, SLOT(setBrushSize(int)));
connect(parent, SIGNAL(passBrushTexture(std::string)), this, SLOT(getBrushTexture(std::string))); connect(parent, SIGNAL(passBrushTexture(std::string)), this, SLOT(setBrushTexture(std::string)));
} }
void CSVRender::TextureBrushWindow::configureButtonInitialSettings(TextureBrushButton *button) void CSVRender::TextureBrushWindow::configureButtonInitialSettings(TextureBrushButton *button)
@ -129,7 +132,7 @@ void CSVRender::TextureBrushWindow::configureButtonInitialSettings(TextureBrushB
button->setCheckable(true); button->setCheckable(true);
} }
void CSVRender::TextureBrushWindow::getBrushTexture(std::string brushTexture) void CSVRender::TextureBrushWindow::setBrushTexture(std::string brushTexture)
{ {
mBrushTexture = brushTexture; mBrushTexture = brushTexture;
mBrushTextureLabel = "Brush:" + mBrushTexture; mBrushTextureLabel = "Brush:" + mBrushTexture;
@ -152,8 +155,11 @@ void CSVRender::TextureBrushWindow::setBrushShape()
} }
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),
, textureBrushWindow(new TextureBrushWindow(worldspaceWidget, this)) textureBrushWindow(new TextureBrushWindow(worldspaceWidget, this)),
mBrushTexture("#0"),
mBrushSize(0),
mBrushShape(0)
{ {
connect(parent, SIGNAL(passEvent(QDragEnterEvent*)), this, SLOT(handleDragEnterEvent(QDragEnterEvent*))); connect(parent, SIGNAL(passEvent(QDragEnterEvent*)), this, SLOT(handleDragEnterEvent(QDragEnterEvent*)));
connect(parent, SIGNAL(passEvent(QDropEvent*)), this, SLOT(handleDropEvent(QDropEvent*))); connect(parent, SIGNAL(passEvent(QDropEvent*)), this, SLOT(handleDropEvent(QDropEvent*)));
@ -245,13 +251,12 @@ void CSVRender::TerrainTextureMode::handleDropEvent (QDropEvent *event) {
void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitResult& hit) void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitResult& hit)
{ {
mCellId = getWorldspaceWidget().getCellId (hit.worldPos); mCellId = getWorldspaceWidget().getCellId (hit.worldPos);
std::string hash = "#";
std::string space = " "; std::istringstream streamCoord (mCellId);
std::size_t hashlocation = mCellId.find(hash); char ignore;
std::size_t spacelocation = mCellId.find(space); int cellX = 0;
std::string slicedX = mCellId.substr (hashlocation+1, spacelocation-hashlocation); int cellY = 0;
std::string slicedY = mCellId.substr (spacelocation+1); streamCoord >> ignore >> cellX >> cellY;
CSMWorld::CellCoordinates mCoordinates(stoi(slicedX), stoi(slicedY));
CSMDoc::Document& document = getWorldspaceWidget().getDocument(); CSMDoc::Document& document = getWorldspaceWidget().getDocument();
CSMWorld::IdTable& landTable = dynamic_cast<CSMWorld::IdTable&> ( CSMWorld::IdTable& landTable = dynamic_cast<CSMWorld::IdTable&> (
@ -263,10 +268,10 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe
CSMWorld::LandTexturesColumn::DataType mPointer = landTable.data(landTable.getModelIndex(mCellId, textureColumn)).value<CSMWorld::LandTexturesColumn::DataType>(); CSMWorld::LandTexturesColumn::DataType mPointer = landTable.data(landTable.getModelIndex(mCellId, textureColumn)).value<CSMWorld::LandTexturesColumn::DataType>();
CSMWorld::LandTexturesColumn::DataType mNew(mPointer); CSMWorld::LandTexturesColumn::DataType mNew(mPointer);
int xInCell ((hit.worldPos.x() - (stoi(slicedX)* cellSize)) * landTextureSize / cellSize); int xInCell ((hit.worldPos.x() - (cellX* cellSize)) * landTextureSize / cellSize);
int yInCell ((hit.worldPos.y() - (stoi(slicedY)* cellSize)) * landTextureSize / cellSize); int yInCell ((hit.worldPos.y() - (cellY* cellSize)) * landTextureSize / cellSize);
hashlocation = mBrushTexture.find(hash); std::size_t hashlocation = mBrushTexture.find("#");
std::string mBrushTextureInt = mBrushTexture.substr (hashlocation+1); std::string mBrushTextureInt = mBrushTexture.substr (hashlocation+1);
int brushInt = stoi(mBrushTexture.substr (hashlocation+1))+1; // All indices are offset by +1 int brushInt = stoi(mBrushTexture.substr (hashlocation+1))+1; // All indices are offset by +1
@ -308,10 +313,8 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe
CSMWorld::CommandMacro macro (document.getUndoStack(), "Edit texture records"); CSMWorld::CommandMacro macro (document.getUndoStack(), "Edit texture records");
QModelIndex index(landTable.getModelIndex (mCellId, landTable.findColumnIndex (CSMWorld::Columns::ColumnId_LandTexturesIndex))); QModelIndex index(landTable.getModelIndex (mCellId, landTable.findColumnIndex (CSMWorld::Columns::ColumnId_LandTexturesIndex)));
CSMWorld::TouchLandCommand* ltexTouch = new CSMWorld::TouchLandCommand(landTable, ltexTable, mCellId); macro.push (new CSMWorld::TouchLandCommand(landTable, ltexTable, mCellId));
CSMWorld::ModifyCommand* ltexModify = new CSMWorld::ModifyCommand(landTable, index, changedLand); macro.push (new CSMWorld::ModifyCommand(landTable, index, changedLand));
macro.push (ltexTouch);
macro.push (ltexModify);
} }
void CSVRender::TerrainTextureMode::dragMoveEvent (QDragMoveEvent *event) { void CSVRender::TerrainTextureMode::dragMoveEvent (QDragMoveEvent *event) {

@ -64,16 +64,14 @@ namespace CSVRender
private: private:
QLabel *selectedBrush; QLabel *selectedBrush;
QGroupBox *horizontalGroupBox; QGroupBox *horizontalGroupBox;
int mButtonSize;
int mBrushSize = 0;
int mBrushShape = 0;
int mIconSize;
WorldspaceWidget *mWorldspaceWidget; WorldspaceWidget *mWorldspaceWidget;
int mBrushSize;
int mBrushShape;
std::string mBrushTexture; std::string mBrushTexture;
std::string mBrushTextureLabel; std::string mBrushTextureLabel;
public slots: public slots:
void getBrushTexture(std::string brushTexture); void setBrushTexture(std::string brushTexture);
void setBrushShape(); void setBrushShape();
void setBrushSize(int brushSize); void setBrushSize(int brushSize);
@ -113,9 +111,9 @@ namespace CSVRender
private: private:
TextureBrushWindow *textureBrushWindow; TextureBrushWindow *textureBrushWindow;
std::string mCellId; std::string mCellId;
std::string mBrushTexture = "#0"; std::string mBrushTexture;
int mBrushSize = 0; int mBrushSize;
int mBrushShape = 0; int mBrushShape;
const int cellSize {ESM::Land::REAL_SIZE}; const int cellSize {ESM::Land::REAL_SIZE};
const int landSize {ESM::Land::LAND_SIZE}; const int landSize {ESM::Land::LAND_SIZE};

Loading…
Cancel
Save