1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00
Files
vcmi/mapeditor/mapview.h

153 lines
3.3 KiB
C++
Raw Normal View History

2022-10-13 01:51:55 +04: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-25 00:55:05 +04:00
#pragma once
2022-09-18 03:23:17 +04:00
#include <QGraphicsScene>
#include <QGraphicsView>
2025-04-13 17:18:13 +02:00
#include <QRubberBand>
2022-09-18 03:23:17 +04:00
#include "scenelayer.h"
#include "../lib/int3.h"
VCMI_LIB_NAMESPACE_BEGIN
2022-09-18 03:23:17 +04:00
class CGObjectInstance;
VCMI_LIB_NAMESPACE_END
2022-09-18 03:23:17 +04:00
class MainWindow;
class MapController;
class MapSceneBase : public QGraphicsScene
{
Q_OBJECT;
public:
MapSceneBase(int lvl);
const int level;
2025-10-06 20:33:09 +02:00
virtual void createMap();
virtual void updateMap();
2022-09-18 03:23:17 +04:00
virtual void initialize(MapController &);
2025-10-06 20:33:09 +02:00
virtual std::list<AbstractFixedLayer *> getStaticLayers() = 0;
virtual std::list<AbstractViewportLayer *> getDynamicLayers() = 0;
2022-09-18 03:23:17 +04:00
};
class MinimapScene : public MapSceneBase
{
public:
MinimapScene(int lvl);
2025-10-06 20:33:09 +02:00
void createMap() override;
2022-09-18 03:23:17 +04:00
MinimapLayer minimapView;
MinimapViewLayer viewport;
2025-10-06 20:33:09 +02:00
std::list<AbstractFixedLayer *> getStaticLayers() override;
std::list<AbstractViewportLayer *> getDynamicLayers() override;
2022-09-18 03:23:17 +04:00
};
class MapScene : public MapSceneBase
{
Q_OBJECT
public:
MapScene(int lvl);
2025-10-06 20:33:09 +02:00
void createMap() override;
std::list<AbstractFixedLayer *> getStaticLayers() override;
std::list<AbstractViewportLayer *> getDynamicLayers() override;
2022-09-18 03:23:17 +04:00
2025-10-06 20:33:09 +02:00
EmptyLayer emptyLayer;
2022-09-18 03:23:17 +04:00
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 03:23:17 +04:00
signals:
void selected(bool anything);
public slots:
void terrainSelected(bool anything);
void objectSelected(bool anything);
2025-10-06 20:33:09 +02:00
protected:
2022-09-18 03:23:17 +04:00
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 03:23:17 +04:00
};
public:
MapView(QWidget * parent);
void setController(MapController *);
SelectionTool selectionTool;
public slots:
2025-10-06 20:33:09 +02:00
void resizeEvent (QResizeEvent * event) override;
2022-09-18 03:23:17 +04:00
void mouseMoveEvent(QMouseEvent * mouseEvent) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
2022-12-04 06:45:39 +04:00
void dragEnterEvent(QDragEnterEvent * event) override;
void dragMoveEvent(QDragMoveEvent *event) override;
void dragLeaveEvent(QDragLeaveEvent *event) override;
void dropEvent(QDropEvent * event) override;
2022-09-18 03:23:17 +04:00
void cameraChanged(const QPointF & pos);
2025-10-06 20:33:09 +02:00
void setViewports();
2022-09-18 03:23:17 +04:00
signals:
void openObjectProperties(CGObjectInstance *, bool switchTab);
2023-10-08 20:25:59 +02:00
void currentCoordinates(int, int);
2022-09-18 03:23:17 +04:00
//void viewportChanged(const QRectF & rect);
protected:
private:
MapController * controller = nullptr;
2022-12-04 14:51:01 +04:00
QRubberBand * rubberBand = nullptr;
2022-09-18 03:23:17 +04:00
QPointF mouseStart;
int3 tileStart;
int3 tilePrev;
bool pressedOnSelected;
2023-10-14 02:58:13 +02:00
std::set<int3> temporaryTiles;
2022-09-18 03:23:17 +04: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 06:45:39 +04:00
void mousePressEvent(QMouseEvent * event) override;
2022-09-18 03:23:17 +04:00
signals:
void cameraPositionChanged(const QPointF & newPosition);
private:
MapController * controller = nullptr;
int displayWidth = 192;
int displayHeight = 192;
};