forked from mrkite/TerraFirma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
glmap.h
103 lines (85 loc) · 2.42 KB
/
glmap.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
/** @Copyright 2015 seancode */
#ifndef GLMAP_H_
#define GLMAP_H_
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QOpenGLBuffer>
#include <QOpenGLVertexArrayObject>
#include <QMatrix4x4>
#include "./render.h"
#include "./world.h"
#include "./chestview.h"
#include "./signview.h"
QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram)
class GLMap : public QOpenGLWidget, public QOpenGLFunctions {
Q_OBJECT
public:
explicit GLMap(QWidget *parent = 0);
~GLMap();
QSize minimumSizeHint() const Q_DECL_OVERRIDE;
QSize sizeHint() const Q_DECL_OVERRIDE;
void setTexturePath(QString path);
void setWorld(QSharedPointer<World> world);
void load(QString filename);
signals:
void status(QString text);
void texturesUsed(bool use);
void hilighting(bool use);
void texturesAvailable(bool avail);
void loaded(bool loaded);
void error(QString text);
public slots:
void fogOfWar(bool use);
void useTextures(bool use);
void showHouses(bool show);
void showWires(bool show);
void resetValues(bool loaded);
void jumpToSpawn();
void jumpToDungeon();
void jumpToLocation(QPointF);
void startHilighting();
void stopHilighting();
void refresh();
protected:
void initializeGL() Q_DECL_OVERRIDE;
void paintGL() Q_DECL_OVERRIDE;
void resizeGL(int w, int h) Q_DECL_OVERRIDE;
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
private:
void calcBounds();
void drawBackground();
void drawWalls();
void drawTiles();
void drawNPCs();
void drawWires();
void drawLiquids();
void drawFog();
void drawFlat();
int getTreeVariant(int offset);
int findTreeStyle(int x, int y);
int findBranchStyle(int x, int y);
int findPillarStyle(int offset);
QSharedPointer<World>world;
double centerX, centerY, scale, zoom;
bool useTexture, hilite, fogOfWarEnabled;
bool houses, wires;
bool fullReset;
QPoint lastMouse;
bool dragging;
ChestView *chestView;
SignView *signView;
Render render;
QOpenGLShaderProgram *program, *waterProgram, *fogProgram, *flatProgram;
QMatrix4x4 projection;
double aspect;
int width, height;
int startX, startY, endX, endY;
int flatW, flatH;
QOpenGLTexture *flat;
quint8 *flatData;
};
#endif // GLMAP_H_