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"
|
|
|
|
|
|
|
|
|
2022-12-05 22:28:01 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
2022-09-18 01:23:17 +02:00
|
|
|
class CGObjectInstance;
|
2022-12-05 22:28:01 +02:00
|
|
|
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;
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
None, Brush, Brush2, Brush4, Area, Lasso
|
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
|
|
|
//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;
|
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
};
|