-
Notifications
You must be signed in to change notification settings - Fork 224
/
map_drawer.h
199 lines (168 loc) · 5.88 KB
/
map_drawer.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
//////////////////////////////////////////////////////////////////////
// This file is part of Remere's Map Editor
//////////////////////////////////////////////////////////////////////
// Remere's Map Editor 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 3 of the License, or
// (at your option) any later version.
//
// Remere's Map Editor 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, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////////
#ifndef RME_MAP_DRAWER_H_
#define RME_MAP_DRAWER_H_
class GameSprite;
struct MapTooltip
{
enum TextLength {
MAX_CHARS_PER_LINE = 40,
MAX_CHARS = 255,
};
MapTooltip(int x, int y, std::string text, uint8_t r, uint8_t g, uint8_t b) :
x(x), y(y), text(text), r(r), g(g), b(b) {
ellipsis = (text.length() - 3) > MAX_CHARS;
}
void checkLineEnding() {
if(text.at(text.size() - 1) == '\n')
text.resize(text.size() - 1);
}
int x, y;
std::string text;
uint8_t r, g, b;
bool ellipsis;
};
// Storage during drawing, for option caching
class DrawingOptions
{
public:
DrawingOptions();
void SetIngame();
void SetDefault();
bool isOnlyColors() const noexcept;
bool isTileIndicators() const noexcept;
bool isTooltips() const noexcept;
bool isDrawLight() const noexcept;
bool transparent_floors;
bool transparent_items;
bool show_ingame_box;
bool show_lights;
bool ingame;
bool dragging;
int show_grid;
bool show_all_floors;
bool show_creatures;
bool show_spawns;
bool show_houses;
bool show_shade;
bool show_special_tiles;
bool show_items;
bool highlight_items;
bool show_blocking;
bool show_tooltips;
bool show_as_minimap;
bool show_only_colors;
bool show_only_modified;
bool show_preview;
bool show_hooks;
bool show_pickupables;
bool show_moveables;
bool hide_items_when_zoomed;
};
class MapCanvas;
class LightDrawer;
class MapDrawer
{
MapCanvas* canvas;
Editor& editor;
DrawingOptions options;
std::shared_ptr<LightDrawer> light_drawer;
float zoom;
uint32_t current_house_id;
int mouse_map_x, mouse_map_y;
int start_x, start_y, start_z;
int end_x, end_y, end_z, superend_z;
int view_scroll_x, view_scroll_y;
int screensize_x, screensize_y;
int tile_size;
int floor;
protected:
std::vector<MapTooltip*> tooltips;
std::ostringstream tooltip;
wxStopWatch pos_indicator_timer;
Position pos_indicator;
public:
MapDrawer(MapCanvas* canvas);
~MapDrawer();
bool dragging;
bool dragging_draw;
void SetupVars();
void SetupGL();
void Release();
void Draw();
void DrawBackground();
void DrawShade(int mapz);
void DrawMap();
void DrawSecondaryMap(int mapz);
void DrawDraggingShadow();
void DrawHigherFloors();
void DrawSelectionBox();
void DrawLiveCursors();
void DrawBrush();
void DrawIngameBox();
void DrawGrid();
void DrawTooltips();
void TakeScreenshot(uint8_t* screenshot_buffer);
void ShowPositionIndicator(const Position& position);
long GetPositionIndicatorTime() const {
const long time = pos_indicator_timer.Time();
if(time < rme::PositionIndicatorDuration) {
return time;
}
return 0;
}
DrawingOptions& getOptions() noexcept { return options; }
protected:
void BlitItem(int& screenx, int& screeny, const Tile* tile, const Item* item, bool ephemeral = false, int red = 255, int green = 255, int blue = 255, int alpha = 255);
void BlitItem(int& screenx, int& screeny, const Position& pos, const Item* item, bool ephemeral = false, int red = 255, int green = 255, int blue = 255, int alpha = 255);
void BlitSpriteType(int screenx, int screeny, uint32_t spriteid, int red = 255, int green = 255, int blue = 255, int alpha = 255);
void BlitSpriteType(int screenx, int screeny, GameSprite* spr, int red = 255, int green = 255, int blue = 255, int alpha = 255);
void BlitCreature(int screenx, int screeny, const Creature* c, int red = 255, int green = 255, int blue = 255, int alpha = 255);
void BlitCreature(int screenx, int screeny, const Outfit& outfit, Direction dir, int red = 255, int green = 255, int blue = 255, int alpha = 255);
void DrawTile(TileLocation* tile);
void DrawBrushIndicator(int x, int y, Brush* brush, uint8_t r, uint8_t g, uint8_t b);
void DrawHookIndicator(int x, int y, const ItemType& type);
void DrawTileIndicators(TileLocation* location);
void DrawIndicator(int x, int y, int indicator, uint8_t r = 255, uint8_t g = 255, uint8_t b = 255, uint8_t a = 255);
void DrawPositionIndicator(int z);
void WriteTooltip(const Item* item, std::ostringstream& stream);
void WriteTooltip(const Waypoint* item, std::ostringstream& stream);
void MakeTooltip(int screenx, int screeny, const std::string& text, uint8_t r = 255, uint8_t g = 255, uint8_t b = 255);
void AddLight(TileLocation* location);
enum BrushColor {
COLOR_BRUSH,
COLOR_HOUSE_BRUSH,
COLOR_FLAG_BRUSH,
COLOR_SPAWN_BRUSH,
COLOR_ERASER,
COLOR_VALID,
COLOR_INVALID,
COLOR_BLANK,
};
void getColor(Brush* brush, const Position& position, uint8_t &r, uint8_t &g, uint8_t &b);
void glBlitTexture(int x, int y, int textureId, int red, int green, int blue, int alpha, bool adjustZoom = false);
void glBlitSquare(int x, int y, int red, int green, int blue, int alpha);
void glBlitSquare(int x, int y, const wxColor& color);
void glColor(const wxColor& color);
void glColor(BrushColor color);
void glColorCheck(Brush* brush, const Position& pos);
void drawRect(int x, int y, int w, int h, const wxColor& color, int width = 1);
void drawFilledRect(int x, int y, int w, int h, const wxColor& color);
private:
void getDrawPosition(const Position& position, int &x, int &y);
};
#endif