forked from ennorehling/csmapfx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.h
207 lines (159 loc) · 5.79 KB
/
map.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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#ifndef _CSMAP_MAP
#define _CSMAP_MAP
#include <fx.h>
#include <vector>
#include <list>
#include <boost/function.hpp>
#include "datafile.h"
#include "mapcanvas.h"
#include "linked_ptr.h"
//#include "scout.h"
class FXCSMap : public FXScrollArea
{
FXDECLARE(FXCSMap)
public:
FXCSMap(FXComposite* p, FXObject* tgt=NULL,FXSelector sel=0, FXuint opts=(FRAME_SUNKEN|FRAME_THICK), FXbool minimap=false, FXint x=0,FXint y=0,FXint w=0,FXint h=0);
void create();
virtual ~FXCSMap();
void paintMapLines(FXDrawable* buffer, FXint ystart);
virtual void moveContents(FXint x,FXint y);
FXbool paintMap(FXDrawable* buffer /*, FXRectangle& rect*/);
void mapfiles(std::list<datafile> *f);
void connectMap(FXCSMap* map);
void scrollTo(FXint x, FXint y);
void registerImages(); // create connection b/w image data and images
void scaleChange(FXfloat sc); // scales font and images
FXfloat getScale();
void setShowNames(bool show);
void setShowKoords(bool show);
void setShowIslands(bool show);
FXival getVisiblePlane() const { return visiblePlane; }
void calculateContentSize();
void terraform(FXint x, FXint y, FXint plane, FXint terrain);
FXint sendRouteCmds(const FXString& str, int which);
FXint getContentWidth();
FXint getContentHeight();
public:
long onMotion(FXObject*,FXSelector,void*);
long onLeftButtonPress(FXObject*,FXSelector,void*);
long onLeftButtonRelease(FXObject*,FXSelector,void*);
long onRightButtonPress(FXObject*,FXSelector,void*);
long onRightButtonRelease(FXObject*,FXSelector,void*);
long onWheel(FXObject*,FXSelector,void*);
long onPaint(FXObject*,FXSelector,void*);
long onMapChange(FXObject*,FXSelector,void*);
long onQueryHelp(FXObject*,FXSelector,void*);
long onKeyPress(FXObject*,FXSelector,void*);
long onPopup(FXObject*,FXSelector,void*);
long onPopupClicked(FXObject*,FXSelector,void*);
long onToggleStreets(FXObject*,FXSelector,void*);
long onUpdateStreets(FXObject*,FXSelector,void*);
long onToggleVisibility(FXObject*,FXSelector,void*);
long onUpdateVisibility(FXObject*,FXSelector,void*);
long onToggleShipTravel(FXObject*,FXSelector,void*);
long onUpdateShipTravel(FXObject*,FXSelector,void*);
long onToggleShadowRegions(FXObject*,FXSelector,void*);
long onUpdateShadowRegions(FXObject*,FXSelector,void*);
long onToggleIslands(FXObject*,FXSelector,void*);
long onUpdateIslands(FXObject*,FXSelector,void*);
long onSetModus(FXObject*,FXSelector,void*);
long onUpdSetModus(FXObject*,FXSelector,void*);
long onSetVisiblePlane(FXObject*,FXSelector,void*);
long onUpdVisiblePlane(FXObject*,FXSelector,void*);
public:
enum
{
ID_MAP = FXScrollArea::ID_LAST,
ID_TOGGLESTREETS,
ID_TOGGLEVISIBILITYSYMBOL,
ID_TOGGLESHIPTRAVEL,
ID_TOGGLESHADOWREGIONS,
ID_TOGGLEISLANDS,
ID_SETMODUS,
ID_SETVISIBLEPLANE,
ID_POPUP_CLICKED,
ID_LAST
};
enum
{
MODUS_NORMAL, // left-click marks region
MODUS_SELECT, // left-click selects/deselects regions
MODUS_SETTERRAIN, // MODUS_SETTERRAIN+x: left-click converts regions to terrain
/*MODUS_SETTERRAIN+1,
MODUS_SETTERRAIN+...,*/
};
protected:
//Scout scout;
FXival visiblePlane;
FXint cursor_x, cursor_y; // coordinates of cursor grap for moving map view
FXint offset_x, offset_y; // used to center map on screen
FXint image_w, image_h; // width and height of the whole map
datafile::SelectionState selection;
FXint sel_x, sel_y, sel_plane; // selected region koordinates
FXint popup_x, popup_y; // which region is popup selected
FXfloat scale; // paint map in this scale
FXival modus; // mouse button modus
FXint mouse_select; // select_set==1: select regions on mouse-over, select_set==2: unselect them
FXbool minimap; // is this map a minimap?
FXCSMap *main_map; // pointer to the normal map
FXCanvas *map; // the bitmap where the image data will be written to
linked_ptr<FXImage> backbuffer, imagebuffer;
linked_ptr<FXFont> font, islandfont; // font used for region names, " for island names
FXButton *button;
FXIcon *terrain[datablock::TERRAIN_LAST];
FXIcon *terrainShadow[datablock::TERRAIN_LAST];
FXIcon *terrainIcons[datablock::TERRAIN_LAST];
FXIcon *activeRegion, *selectedRegion;
FXIcon *troopsunknown, *troopally, *troopenemy;
FXIcon *guardown, *guardally, *guardenemy, *guardmixed;
FXIcon *ship, *castle, *shiptravel, *lighthouse, *travel;
FXIcon *castleown, *castleally, *castleenemy, *castlecoins;
FXIcon *monster, *seasnake, *dragon;
FXIcon *wormhole;
FXIcon *street[6], *street_undone[6];
FXIcon *redarrows[6], *greenarrows[6], *bluearrows[6], *greyarrows[6];
std::vector< std::vector<FXIcon*> > overlays; // terrain color overlays
std::vector< FXColor > overlayColors;
// records icon <-> image data link
struct IconRecord {
typedef boost::function<FXColor(FXColor)> transform_t;
FXIcon** icon;
const unsigned char* data;
int width, height;
bool scaleable;
transform_t transform;
};
std::vector< IconRecord > iconRecords;
// what text is shown
FXbool show_koords, show_names, show_islands;
// what symbols are shown
FXbool show_streets, show_visibility_symbol, show_ship_travel, show_shadow_regions;
struct arrow
{
int x, y; // coordinates of arrow origin
int dir; // direction of arrow
enum // color of array
{
ARROW_RED,
ARROW_GREEN,
ARROW_BLUE,
ARROW_GREY
} color;
};
std::vector<arrow> arrows;
std::vector<arrow> routeArrows[2]; // saved
std::list<datafile> *files;
// Return default width / height
virtual FXint getDefaultWidth();
virtual FXint getDefaultHeight();
// Recalculate layout
void layout();
FXint GetHexFromScreenY(FXint scrx, FXint scry);
FXint GetHexFromScreenX(FXint scrx, FXint scry);
FXint GetScreenFromHexY(FXint x, FXint y);
FXint GetScreenFromHexX(FXint x, FXint y);
protected:
FXCSMap(){}
FXCSMap(const FXCSMap&) {}
};
#endif //_CSMAP_MAP