forked from mrkite/minutor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapview.h
108 lines (89 loc) · 2.75 KB
/
mapview.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/** Copyright (c) 2013, Sean Kasun */
#ifndef MAPVIEW_H_
#define MAPVIEW_H_
#include <QtWidgets/QWidget>
#include <QSharedPointer>
#include "./chunkcache.h"
class DefinitionManager;
class BiomeIdentifier;
class BlockIdentifier;
class OverlayItem;
class MapView : public QWidget {
Q_OBJECT
public:
/// Values for the individual flags
enum {
flgLighting = 1,
flgMobSpawn = 2,
flgCaveMode = 4,
flgDepthShading = 8,
flgShowEntities = 16,
flgBiomeColors = 64
};
typedef struct {
float x, y, z;
int scale;
} BlockLocation;
explicit MapView(QWidget *parent = 0);
QSize minimumSizeHint() const;
QSize sizeHint() const;
void attach(DefinitionManager *dm);
void setLocation(double x, double z);
void setLocation(double x, int y, double z, bool ignoreScale, bool useHeight);
BlockLocation *getLocation();
void setDimension(QString path, int scale);
void setFlags(int flags);
int getFlags() const;
int getDepth() const;
void addOverlayItem(QSharedPointer<OverlayItem> item);
void clearOverlayItems();
void setVisibleOverlayItemTypes(const QSet<QString>& itemTypes);
// public for saving the png
QString getWorldPath();
public slots:
void setDepth(int depth);
void chunkUpdated(int x, int z);
void redraw();
// Clears the cache and redraws, causing all chunks to be re-loaded;
// but keeps the viewport
void clearCache();
signals:
void hoverTextChanged(QString text);
void demandDepthChange(int value);
void demandDepthValue(int value);
void showProperties(QVariant properties);
void addOverlayItemType(QString type, QColor color);
void coordinatesChanged(int x, int y, int z);
protected:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
void keyPressEvent(QKeyEvent *event);
void resizeEvent(QResizeEvent *event);
void paintEvent(QPaintEvent *event);
private slots:
void addStructureFromChunk(QSharedPointer<GeneratedStructure> structure);
private:
void drawChunk(int x, int z);
void getToolTip(int x, int z);
int getY(int x, int z);
QList<QSharedPointer<OverlayItem>> getItems(int x, int y, int z);
static const int CAVE_DEPTH = 16; // maximum depth caves are searched in cave mode
float caveshade[CAVE_DEPTH];
int depth;
double x, z;
int scale;
double zoom;
int flags;
ChunkCache &cache;
QImage imageChunks;
QImage imageOverlays;
DefinitionManager *dm;
uchar placeholder[16 * 16 * 4]; // no chunk found placeholder
QSet<QString> overlayItemTypes;
QMap<QString, QList<QSharedPointer<OverlayItem>>> overlayItems;
BlockLocation currentLocation;
};
#endif // MAPVIEW_H_