1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 18:53:52 +00:00
openmw/apps/opencs/view/render/terraintexturemode.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

153 lines
4.4 KiB
C++
Raw Normal View History

2018-04-15 11:47:31 +00:00
#ifndef CSV_RENDER_TERRAINTEXTUREMODE_H
#define CSV_RENDER_TERRAINTEXTUREMODE_H
#include "editmode.hpp"
#include <memory>
2018-04-15 11:47:31 +00:00
#include <string>
2022-10-19 17:02:00 +00:00
#include <utility>
#include <vector>
2018-04-15 11:47:31 +00:00
#include <QWidget>
#ifndef Q_MOC_RUN
2022-08-19 17:19:42 +00:00
#include "../../model/world/columnimp.hpp"
#include "../widget/brushshapes.hpp"
#include "brushdraw.hpp"
#endif
2018-04-19 15:00:47 +00:00
2022-10-19 17:02:00 +00:00
#include <components/esm3/loadland.hpp>
class QDragMoveEvent;
class QDropEvent;
class QMouseEvent;
class QObject;
class QPoint;
class QWidget;
2019-04-07 20:11:13 +00:00
namespace osg
{
class Group;
}
2022-10-19 17:02:00 +00:00
namespace CSMDoc
{
class Document;
}
namespace CSMWorld
{
class IdTable;
}
2018-04-15 11:47:31 +00:00
namespace CSVWidget
{
class SceneToolTextureBrush;
2022-10-19 17:02:00 +00:00
class SceneToolbar;
2018-04-15 11:47:31 +00:00
}
namespace CSVRender
{
2022-10-19 17:02:00 +00:00
class TerrainSelection;
class WorldspaceWidget;
struct WorldspaceHitResult;
2018-04-15 11:47:31 +00:00
class TerrainTextureMode : public EditMode
{
Q_OBJECT
public:
enum InteractionType
2022-09-22 18:26:05 +00:00
{
InteractionType_PrimaryEdit,
InteractionType_PrimarySelect,
InteractionType_SecondaryEdit,
InteractionType_SecondarySelect,
InteractionType_None
2022-09-22 18:26:05 +00:00
};
2018-04-15 11:47:31 +00:00
/// \brief Editmode for terrain texture grid
TerrainTextureMode(WorldspaceWidget*, osg::Group* parentNode, QWidget* parent = nullptr);
void primaryOpenPressed(const WorldspaceHitResult& hit) override;
2018-04-15 11:47:31 +00:00
/// \brief Create single command for one-click texture editing
void primaryEditPressed(const WorldspaceHitResult& hit) override;
/// \brief Open brush settings window
void primarySelectPressed(const WorldspaceHitResult&) override;
2018-04-15 15:49:33 +00:00
void secondarySelectPressed(const WorldspaceHitResult&) override;
void activate(CSVWidget::SceneToolbar*) override;
void deactivate(CSVWidget::SceneToolbar*) override;
2018-04-15 11:47:31 +00:00
/// \brief Start texture editing command macro
bool primaryEditStartDrag(const QPoint& pos) override;
2018-04-15 11:47:31 +00:00
bool secondaryEditStartDrag(const QPoint& pos) override;
bool primarySelectStartDrag(const QPoint& pos) override;
bool secondarySelectStartDrag(const QPoint& pos) override;
/// \brief Handle texture edit behavior during dragging
void drag(const QPoint& pos, int diffX, int diffY, double speedFactor) override;
/// \brief End texture editing command macro
void dragCompleted(const QPoint& pos) override;
void dragAborted() override;
void dragWheel(int diff, double speedFactor) override;
void dragMoveEvent(QDragMoveEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
2018-04-15 11:47:31 +00:00
std::shared_ptr<TerrainSelection> getTerrainSelection();
2022-09-22 18:26:05 +00:00
private:
/// \brief Handle brush mechanics, maths regarding worldspace hit etc.
void editTerrainTextureGrid(const WorldspaceHitResult& hit);
/// \brief Check if global selection coordinate belongs to cell in view
2018-04-17 17:48:58 +00:00
bool isInCellSelection(int globalSelectionX, int globalSelectionY);
2019-05-06 09:56:04 +00:00
/// \brief Handle brush mechanics for texture selection
void selectTerrainTextures(const std::pair<int, int>& texCoords, unsigned char selectMode);
2019-05-06 09:56:04 +00:00
/// \brief Push texture edits to command macro
void pushEditToCommand(CSMWorld::LandTexturesColumn::DataType& newLandGrid, CSMDoc::Document& document,
CSMWorld::IdTable& landTable, std::string cellId);
/// \brief Create new land texture record from texture asset
2018-04-19 15:00:47 +00:00
void createTexture(std::string textureFileName);
2018-04-17 17:48:58 +00:00
/// \brief Create new cell and land if needed
bool allowLandTextureEditing(std::string textureFileName);
std::string mCellId;
std::string mBrushTexture;
int mBrushSize;
CSVWidget::BrushShape mBrushShape;
std::unique_ptr<BrushDraw> mBrushDraw;
std::vector<std::pair<int, int>> mCustomBrushShape;
CSVWidget::SceneToolTextureBrush* mTextureBrushScenetool;
int mDragMode;
osg::Group* mParentNode;
bool mIsEditing;
std::shared_ptr<TerrainSelection> mTerrainTextureSelection;
const int cellSize{ ESM::Land::REAL_SIZE };
const int landTextureSize{ ESM::Land::LAND_TEXTURE_SIZE };
2018-04-15 11:47:31 +00:00
2018-04-15 15:49:33 +00:00
signals:
void passBrushTexture(std::string brushTexture);
2018-04-15 11:47:31 +00:00
public slots:
void handleDropEvent(QDropEvent* event);
2018-04-15 15:49:33 +00:00
void setBrushSize(int brushSize);
void setBrushShape(CSVWidget::BrushShape brushShape);
2018-05-10 18:58:36 +00:00
void setBrushTexture(std::string brushShape);
2018-04-15 11:47:31 +00:00
};
}
#endif