1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 03:32:36 +00:00
OpenMW/apps/opencs/view/render/terraintexturemode.hpp

134 lines
4.2 KiB
C++
Raw Normal View History

2018-04-15 14:47:31 +03:00
#ifndef CSV_RENDER_TERRAINTEXTUREMODE_H
#define CSV_RENDER_TERRAINTEXTUREMODE_H
#include "editmode.hpp"
#include <string>
#include <QWidget>
#include <QLabel>
#include <QSpinBox>
#include <QGroupBox>
#include <QSlider>
#include <QIcon>
#include <QFrame>
#include <QEvent>
#include <QHBoxLayout>
#include <QPushButton>
2018-04-15 18:49:33 +03:00
#include "../../model/world/data.hpp"
#include "../../model/world/land.hpp"
2018-04-19 18:00:47 +03:00
#include "../../model/doc/document.hpp"
#include "../../model/world/commands.hpp"
#include "../../model/world/idtable.hpp"
#include "../../model/world/landtexture.hpp"
2018-04-15 14:47:31 +03:00
namespace CSVWidget
{
class SceneToolMode;
}
namespace CSVRender
{
class BrushSizeControls : public QGroupBox
{
Q_OBJECT
public:
BrushSizeControls(const QString &title, QWidget *parent);
2018-04-15 18:49:33 +03:00
QSlider *brushSizeSlider;
2018-04-15 14:47:31 +03:00
private:
QSpinBox *brushSizeSpinBox;
QHBoxLayout *layoutSliderSize;
};
class TextureBrushWindow : public QFrame
{
Q_OBJECT
public:
TextureBrushWindow(WorldspaceWidget *worldspaceWidget, QWidget *parent = 0);
void configureButtonInitialSettings(QPushButton *button);
2018-04-15 14:47:31 +03:00
QPushButton *buttonPoint = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-point")), "", this);
QPushButton *buttonSquare = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-square")), "", this);
QPushButton *buttonCircle = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-circle")), "", this);
QPushButton *buttonCustom = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-custom")), "", this);
2018-04-15 18:49:33 +03:00
2018-04-15 14:47:31 +03:00
private:
QLabel *selectedBrush;
QGroupBox *horizontalGroupBox;
WorldspaceWidget *mWorldspaceWidget;
2018-04-18 13:12:11 +03:00
int mBrushSize;
int mBrushShape;
2018-04-15 14:47:31 +03:00
std::string mBrushTexture;
std::string mBrushTextureLabel;
public slots:
2018-04-18 13:12:11 +03:00
void setBrushTexture(std::string brushTexture);
2018-04-15 18:49:33 +03:00
void setBrushShape();
void setBrushSize(int brushSize);
signals:
void passBrushSize (int brushSize);
void passBrushShape(int brushShape);
2018-04-15 14:47:31 +03:00
};
class TerrainTextureMode : public EditMode
{
Q_OBJECT
public:
TerrainTextureMode(WorldspaceWidget*, QWidget* parent = nullptr);
2018-04-15 18:49:33 +03:00
void primaryEditPressed (const WorldspaceHitResult& hit);
2018-04-15 14:47:31 +03:00
void primarySelectPressed(const WorldspaceHitResult&);
void secondarySelectPressed(const WorldspaceHitResult&);
void activate(CSVWidget::SceneToolbar*);
void deactivate(CSVWidget::SceneToolbar*);
virtual bool primaryEditStartDrag (const QPoint& pos);
virtual bool secondaryEditStartDrag (const QPoint& pos);
virtual bool primarySelectStartDrag (const QPoint& pos);
virtual bool secondarySelectStartDrag (const QPoint& pos);
virtual void drag (const QPoint& pos, int diffX, int diffY, double speedFactor);
virtual void dragCompleted(const QPoint& pos);
virtual void dragAborted();
virtual void dragWheel (int diff, double speedFactor);
virtual void dragMoveEvent (QDragMoveEvent *event);
2018-04-17 20:48:58 +03:00
void editTerrainTextureGrid (const WorldspaceHitResult& hit);
2018-04-19 18:00:47 +03:00
void pushEditToCommand (CSMWorld::LandTexturesColumn::DataType& newLandGrid, CSMDoc::Document& document,
CSMWorld::IdTable& landTable, std::string cellId);
2018-04-17 20:48:58 +03:00
2018-04-15 14:47:31 +03:00
private:
TextureBrushWindow *textureBrushWindow;
2018-04-17 20:48:58 +03:00
std::string mCellId;
2018-04-18 13:12:11 +03:00
std::string mBrushTexture;
int mBrushSize;
int mBrushShape;
2018-04-15 14:47:31 +03:00
2018-04-15 18:49:33 +03:00
const int cellSize {ESM::Land::REAL_SIZE};
const int landSize {ESM::Land::LAND_SIZE};
const int landTextureSize {ESM::Land::LAND_TEXTURE_SIZE};
2018-04-15 14:47:31 +03:00
2018-04-15 18:49:33 +03:00
signals:
2018-04-15 14:47:31 +03:00
void passBrushTexture(std::string brushTexture);
public slots:
void handleDragEnterEvent (QDragEnterEvent *event);
void handleDropEvent(QDropEvent *event);
2018-04-15 18:49:33 +03:00
void setBrushSize(int brushSize);
void setBrushShape(int brushShape);
2018-04-15 14:47:31 +03:00
};
}
#endif