1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-28 23:06:24 +02:00
vcmi/mapeditor/mapview.h

153 lines
3.0 KiB
C++
Raw Normal View History

2022-10-12 23:51:55 +02:00
/*
* mapview.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
2022-09-24 22:55:05 +02:00
#pragma once
2022-09-18 01:23:17 +02:00
#include <QGraphicsScene>
#include <QGraphicsView>
#include "scenelayer.h"
#include "../lib/int3.h"
VCMI_LIB_NAMESPACE_BEGIN
2022-09-18 01:23:17 +02:00
class CGObjectInstance;
VCMI_LIB_NAMESPACE_END
2022-09-18 01:23:17 +02:00
class MainWindow;
class MapController;
class MapSceneBase : public QGraphicsScene
{
Q_OBJECT;
public:
MapSceneBase(int lvl);
const int level;
virtual void updateViews();
virtual void initialize(MapController &);
protected:
virtual std::list<AbstractLayer *> getAbstractLayers() = 0;
};
class MinimapScene : public MapSceneBase
{
public:
MinimapScene(int lvl);
void updateViews() override;
MinimapLayer minimapView;
MinimapViewLayer viewport;
protected:
std::list<AbstractLayer *> getAbstractLayers() override;
};
class MapScene : public MapSceneBase
{
Q_OBJECT
public:
MapScene(int lvl);
void updateViews() override;
GridLayer gridView;
PassabilityLayer passabilityView;
SelectionTerrainLayer selectionTerrainView;
TerrainLayer terrainView;
ObjectsLayer objectsView;
SelectionObjectsLayer selectionObjectsView;
2023-09-11 18:01:53 +02:00
ObjectPickerLayer objectPickerView;
2022-09-18 01:23:17 +02:00
signals:
void selected(bool anything);
public slots:
void terrainSelected(bool anything);
void objectSelected(bool anything);
protected:
std::list<AbstractLayer *> getAbstractLayers() override;
bool isTerrainSelected;
bool isObjectSelected;
};
class MapView : public QGraphicsView
{
Q_OBJECT
public:
enum class SelectionTool
{
2023-10-14 02:58:13 +02:00
None, Brush, Brush2, Brush4, Area, Lasso, Line, Fill
2022-09-18 01:23:17 +02:00
};
public:
MapView(QWidget * parent);
void setController(MapController *);
SelectionTool selectionTool;
public slots:
void mouseMoveEvent(QMouseEvent * mouseEvent) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
2022-12-04 04:45:39 +02:00
void dragEnterEvent(QDragEnterEvent * event) override;
void dragMoveEvent(QDragMoveEvent *event) override;
void dragLeaveEvent(QDragLeaveEvent *event) override;
void dropEvent(QDropEvent * event) override;
2022-09-18 01:23:17 +02:00
void cameraChanged(const QPointF & pos);
signals:
void openObjectProperties(CGObjectInstance *, bool switchTab);
2023-10-08 20:25:59 +02:00
void currentCoordinates(int, int);
2022-09-18 01:23:17 +02:00
//void viewportChanged(const QRectF & rect);
protected:
bool viewportEvent(QEvent *event) override;
private:
MapController * controller = nullptr;
2022-12-04 12:51:01 +02:00
QRubberBand * rubberBand = nullptr;
2022-09-18 01:23:17 +02:00
QPointF mouseStart;
int3 tileStart;
int3 tilePrev;
bool pressedOnSelected;
2023-10-14 02:58:13 +02:00
std::set<int3> temporaryTiles;
2022-09-18 01:23:17 +02:00
};
class MinimapView : public QGraphicsView
{
Q_OBJECT
public:
MinimapView(QWidget * parent);
void setController(MapController *);
void dimensions();
public slots:
void mouseMoveEvent(QMouseEvent * mouseEvent) override;
2022-12-04 04:45:39 +02:00
void mousePressEvent(QMouseEvent * event) override;
2022-09-18 01:23:17 +02:00
signals:
void cameraPositionChanged(const QPointF & newPosition);
private:
MapController * controller = nullptr;
int displayWidth = 192;
int displayHeight = 192;
};