1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-18 17:40:48 +02:00
vcmi/mapeditor/mapview.h

134 lines
2.4 KiB
C
Raw Normal View History

2022-08-31 20:05:57 +02:00
#ifndef MAPVIEW_H
#define MAPVIEW_H
#include <QGraphicsScene>
#include <QGraphicsView>
2022-09-05 02:19:21 +02:00
#include "scenelayer.h"
2022-09-01 03:51:29 +02:00
#include "../lib/int3.h"
2022-08-31 20:05:57 +02:00
2022-09-05 02:19:21 +02:00
2022-09-01 13:54:39 +02:00
class CGObjectInstance;
2022-08-31 20:05:57 +02:00
class MainWindow;
2022-09-05 02:19:21 +02:00
class MapController;
2022-08-31 20:05:57 +02:00
2022-09-05 12:10:39 +02:00
class MapSceneBase : public QGraphicsScene
2022-08-31 20:05:57 +02:00
{
Q_OBJECT;
2022-08-31 20:05:57 +02:00
public:
2022-09-05 12:10:39 +02:00
MapSceneBase(int lvl);
2022-09-05 02:19:21 +02:00
2022-09-05 12:10:39 +02:00
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;
2022-09-05 14:28:47 +02:00
MinimapViewLayer viewport;
2022-09-05 12:10:39 +02:00
protected:
virtual std::list<AbstractLayer *> getAbstractLayers();
};
class MapScene : public MapSceneBase
{
Q_OBJECT
2022-09-05 12:10:39 +02:00
public:
MapScene(int lvl);
void updateViews() override;
2022-09-05 02:19:21 +02:00
GridLayer gridView;
PassabilityLayer passabilityView;
SelectionTerrainLayer selectionTerrainView;
TerrainLayer terrainView;
ObjectsLayer objectsView;
SelectionObjectsLayer selectionObjectsView;
signals:
void selected(bool anything);
public slots:
void terrainSelected(bool anything);
void objectSelected(bool anything);
2022-09-05 02:19:21 +02:00
2022-09-05 12:10:39 +02:00
protected:
std::list<AbstractLayer *> getAbstractLayers() override;
bool isTerrainSelected;
bool isObjectSelected;
2022-08-31 20:05:57 +02:00
};
class MapView : public QGraphicsView
{
2022-09-05 02:19:21 +02:00
Q_OBJECT
2022-09-01 03:51:29 +02:00
public:
enum class SelectionTool
{
None, Brush, Brush2, Brush4, Area, Lasso
};
2022-08-31 20:05:57 +02:00
public:
2022-09-05 02:19:21 +02:00
MapView(QWidget * parent);
void setController(MapController *);
2022-08-31 20:05:57 +02:00
2022-09-01 03:51:29 +02:00
SelectionTool selectionTool;
2022-08-31 20:05:57 +02:00
public slots:
void mouseMoveEvent(QMouseEvent * mouseEvent) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
2022-09-05 02:19:21 +02:00
2022-09-05 14:28:47 +02:00
void cameraChanged(const QPointF & pos);
2022-09-05 02:19:21 +02:00
signals:
void openObjectProperties(CGObjectInstance *);
2022-09-05 14:28:47 +02:00
//void viewportChanged(const QRectF & rect);
2022-08-31 20:05:57 +02:00
2022-09-05 14:28:47 +02:00
protected:
bool viewportEvent(QEvent *event) override;
2022-08-31 20:05:57 +02:00
private:
2022-09-05 02:19:21 +02:00
MapController * controller = nullptr;
2022-09-01 03:51:29 +02:00
QPointF mouseStart;
int3 tileStart;
int3 tilePrev;
bool pressedOnSelected;
2022-08-31 20:05:57 +02:00
};
2022-09-05 12:10:39 +02:00
class MinimapView : public QGraphicsView
{
Q_OBJECT
public:
MinimapView(QWidget * parent);
void setController(MapController *);
void dimensions();
public slots:
2022-09-05 14:28:47 +02:00
void mouseMoveEvent(QMouseEvent * mouseEvent) override;
void mousePressEvent(QMouseEvent* event) override;
2022-09-05 12:10:39 +02:00
signals:
2022-09-05 14:28:47 +02:00
void cameraPositionChanged(const QPointF & newPosition);
2022-09-05 12:10:39 +02:00
private:
MapController * controller = nullptr;
int displayWidth = 192;
int displayHeight = 192;
};
2022-08-31 20:05:57 +02:00
#endif // MAPVIEW_H