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