forked from Mudlet/Mudlet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTMap.h
More file actions
145 lines (131 loc) · 5.12 KB
/
TMap.h
File metadata and controls
145 lines (131 loc) · 5.12 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#ifndef MUDLET_TMAP_H
#define MUDLET_TMAP_H
/***************************************************************************
* Copyright (C) 2008-2013 by Heiko Koehn - KoehnHeiko@googlemail.com *
* Copyright (C) 2014 by Ahmed Charles - acharles@outlook.com *
* Copyright (C) 2014-2015 by Stephen Lyons - slysven@virginmedia.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "TAstar.h"
#include "pre_guard.h"
#include <QColor>
#include <QMap>
#include <QPixmap>
#include <QPointer>
#include <QSizeF>
#include <QVector3D>
#include "post_guard.h"
#include <stdlib.h>
class dlgMapper;
class Host;
class GLWidget;
class TArea;
class TRoom;
class TRoomDB;
class T2DMap;
class TMapLabel
{
public:
TMapLabel(){ hilite=false; showOnTop=false; noScaling=false; }
QVector3D pos;
QPointF pointer;
QSizeF size;
QSizeF clickSize;
QString text;
QColor fgColor;
QColor bgColor;
QPixmap pix;
bool hilite;
bool showOnTop;
bool noScaling;
};
class TMap
{
public:
TMap( Host *);
~TMap();
void mapClear();
int createMapLabelID( int area );
int createMapImageLabel(int area, QString filePath, float x, float y, float z, float width, float height, float zoom, bool showOnTop, bool noScaling );
int createMapLabel(int area, QString text, float x, float y, float z, QColor fg, QColor bg, bool showOnTop=true, bool noScaling=true, qreal zoom=15.0, int fontSize=15 );
void deleteMapLabel( int area, int labelID );
bool addRoom( int id=0 );
bool setRoomArea( int id, int area, bool isToDeferAreaRelatedRecalculations = false );
// void deleteRoom( int id );
void deleteArea( int id );
int createNewRoomID();
void logError(QString &msg);
void tidyMap( int area );
void getConnectedNodesGreaterThanX( int id, int x );
void getConnectedNodesSmallerThanX( int id, int x );
void getConnectedNodesGreaterThanY( int id, int x );
void getConnectedNodesSmallerThanY( int id, int x );
void astBreitenAnpassung( int id, int );
void astHoehenAnpassung( int id, int );
bool setExit( int from, int to, int dir );
bool setRoomCoordinates( int id, int x, int y, int z );
void init(Host*);
QList<int> detectRoomCollisions( int id );
void solveRoomCollision( int id, int creationDirection, bool PCheck=true );
void setRoom( int );
bool findPath( int from, int to );
bool gotoRoom( int );
bool gotoRoom( int, int );
void setView( float, float, float, float );
bool serialize( QDataStream & );
bool restore(QString location);
void initGraph();
void exportMapToDatabase();
void importMapFromDatabase();
void connectExitStub(int roomId, int dirType);
TRoomDB * mpRoomDB;
QMap<int, int> envColors;
QVector3D span;
QPointer<Host> mpHost;
int mRoomId;
bool m2DPanMode;
bool mLeftDown;
bool mRightDown;
float m2DPanXStart;
float m2DPanYStart;
int mViewArea;
int mTargetID;
QList<int> mPathList;
QList<QString> mDirList;
QList<int> mWeightList;
QMap<int, QColor> customEnvColors;
QMap<int, QVector3D> unitVectors;
QMap<int, int> reverseDirections; // contains complementary directions of dirs on TRoom.h
GLWidget * mpM;
dlgMapper * mpMapper;
QMap<int, int> roomidToIndex;
// QMap<int, int> indexToRoomid;
QMap<QString, int> pixNameTable;
QMap<int, QPixmap> pixTable;
typedef adjacency_list<listS, vecS, directedS, no_property, property<edge_weight_t, cost> > mygraph_t;
typedef property_map<mygraph_t, edge_weight_t>::type WeightMap;
typedef mygraph_t::vertex_descriptor vertex;
typedef mygraph_t::edge_descriptor edge_descriptor;
mygraph_t g;
QHash<QPair<unsigned int, unsigned int>, route> edgeHash; // For Mudlet to decode BGL edges
std::vector<location> locations;
bool mMapGraphNeedsUpdate;
bool mNewMove;
QMap<qint32, QMap<qint32, TMapLabel> > mapLabels;
int version; // map file format version
};
#endif // MUDLET_TMAP_H