Skip to content

Commit c8dba24

Browse files
committed
Show as minimap.
Show only the tile minimap colors. Shortcut Shift+E
1 parent 5e1e363 commit c8dba24

File tree

9 files changed

+108
-62
lines changed

9 files changed

+108
-62
lines changed

data/menubar.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
<item name="Show creatures" hotkey="F" action="SHOW_CREATURES" help="Show creatures on the map."/>
109109
<item name="Show spawns" hotkey="S" action="SHOW_SPAWNS" help="Show spawns on the map."/>
110110
<item name="Sho$w special" hotkey="E" action="SHOW_SPECIAL" help="Show special tiles on the map, like PZ."/>
111+
<item name="Show as minimap" hotkey="Shift+E" action="SHOW_AS_MINIMAP" help="Show only the tile minimap colors."/>
111112
<item name="Only show $colors" hotkey="Ctrl+E" action="SHOW_ONLY_COLORS" help="Show only the special tiles on the map."/>
112113
<item name="Only show $modified" hotkey="Ctrl+M" action="SHOW_ONLY_MODIFIED" help="Show only the tiles that have been modified since the map was opened."/>
113114
<item name="Show $houses" hotkey="Ctrl+H" action="SHOW_HOUSES" help="Show houses on the map."/>

source/main_menubar.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ MainMenuBar::MainMenuBar(MainFrame *frame) : frame(frame)
139139
MAKE_ACTION(SHOW_CREATURES, wxITEM_CHECK, OnChangeViewSettings);
140140
MAKE_ACTION(SHOW_SPAWNS, wxITEM_CHECK, OnChangeViewSettings);
141141
MAKE_ACTION(SHOW_SPECIAL, wxITEM_CHECK, OnChangeViewSettings);
142+
MAKE_ACTION(SHOW_AS_MINIMAP, wxITEM_CHECK, OnChangeViewSettings);
142143
MAKE_ACTION(SHOW_ONLY_COLORS, wxITEM_CHECK, OnChangeViewSettings);
143144
MAKE_ACTION(SHOW_ONLY_MODIFIED, wxITEM_CHECK, OnChangeViewSettings);
144145
MAKE_ACTION(SHOW_HOUSES, wxITEM_CHECK, OnChangeViewSettings);
@@ -401,6 +402,7 @@ void MainMenuBar::LoadValues()
401402
CheckItem(SHOW_CREATURES, g_settings.getBoolean(Config::SHOW_CREATURES));
402403
CheckItem(SHOW_SPAWNS, g_settings.getBoolean(Config::SHOW_SPAWNS));
403404
CheckItem(SHOW_SPECIAL, g_settings.getBoolean(Config::SHOW_SPECIAL_TILES));
405+
CheckItem(SHOW_AS_MINIMAP, g_settings.getBoolean(Config::SHOW_AS_MINIMAP));
404406
CheckItem(SHOW_ONLY_COLORS, g_settings.getBoolean(Config::SHOW_ONLY_TILEFLAGS));
405407
CheckItem(SHOW_ONLY_MODIFIED, g_settings.getBoolean(Config::SHOW_ONLY_MODIFIED_TILES));
406408
CheckItem(SHOW_HOUSES, g_settings.getBoolean(Config::SHOW_HOUSES));
@@ -474,7 +476,7 @@ bool MainMenuBar::Load(const FileName& path, wxArrayString& warnings, wxString&
474476
}
475477

476478
#ifdef __LINUX__
477-
const int count = 40;
479+
const int count = 41;
478480
wxAcceleratorEntry entries[count];
479481
// Edit
480482
entries[0].Set(wxACCEL_CTRL, (int)'Z', MAIN_FRAME_MENU + MenuBar::UNDO);
@@ -503,23 +505,24 @@ bool MainMenuBar::Load(const FileName& path, wxArrayString& warnings, wxString&
503505
entries[22].Set(wxACCEL_NORMAL, (int)'F', MAIN_FRAME_MENU + MenuBar::SHOW_CREATURES);
504506
entries[23].Set(wxACCEL_NORMAL, (int)'S', MAIN_FRAME_MENU + MenuBar::SHOW_SPAWNS);
505507
entries[24].Set(wxACCEL_NORMAL, (int)'E', MAIN_FRAME_MENU + MenuBar::SHOW_SPECIAL);
506-
entries[25].Set(wxACCEL_CTRL, (int)'E', MAIN_FRAME_MENU + MenuBar::SHOW_ONLY_COLORS);
507-
entries[26].Set(wxACCEL_CTRL, (int)'M', MAIN_FRAME_MENU + MenuBar::SHOW_ONLY_MODIFIED);
508-
entries[27].Set(wxACCEL_CTRL, (int)'H', MAIN_FRAME_MENU + MenuBar::SHOW_HOUSES);
509-
entries[28].Set(wxACCEL_NORMAL, (int)'O', MAIN_FRAME_MENU + MenuBar::SHOW_PATHING);
510-
entries[29].Set(wxACCEL_NORMAL, (int)'Y', MAIN_FRAME_MENU + MenuBar::SHOW_TOOLTIPS);
511-
entries[30].Set(wxACCEL_NORMAL, (int)'L', MAIN_FRAME_MENU + MenuBar::SHOW_PREVIEW);
512-
entries[31].Set(wxACCEL_NORMAL, (int)'K', MAIN_FRAME_MENU + MenuBar::SHOW_WALL_HOOKS);
508+
entries[25].Set(wxACCEL_SHIFT, (int)'E', MAIN_FRAME_MENU + MenuBar::SHOW_AS_MINIMAP);
509+
entries[26].Set(wxACCEL_CTRL, (int)'E', MAIN_FRAME_MENU + MenuBar::SHOW_ONLY_COLORS);
510+
entries[27].Set(wxACCEL_CTRL, (int)'M', MAIN_FRAME_MENU + MenuBar::SHOW_ONLY_MODIFIED);
511+
entries[28].Set(wxACCEL_CTRL, (int)'H', MAIN_FRAME_MENU + MenuBar::SHOW_HOUSES);
512+
entries[29].Set(wxACCEL_NORMAL, (int)'O', MAIN_FRAME_MENU + MenuBar::SHOW_PATHING);
513+
entries[30].Set(wxACCEL_NORMAL, (int)'Y', MAIN_FRAME_MENU + MenuBar::SHOW_TOOLTIPS);
514+
entries[31].Set(wxACCEL_NORMAL, (int)'L', MAIN_FRAME_MENU + MenuBar::SHOW_PREVIEW);
515+
entries[32].Set(wxACCEL_NORMAL, (int)'K', MAIN_FRAME_MENU + MenuBar::SHOW_WALL_HOOKS);
513516

514517
// Window
515-
entries[32].Set(wxACCEL_NORMAL, (int)'M', MAIN_FRAME_MENU + MenuBar::WIN_MINIMAP);
516-
entries[33].Set(wxACCEL_NORMAL, (int)'T', MAIN_FRAME_MENU + MenuBar::SELECT_TERRAIN);
517-
entries[34].Set(wxACCEL_NORMAL, (int)'D', MAIN_FRAME_MENU + MenuBar::SELECT_DOODAD);
518-
entries[35].Set(wxACCEL_NORMAL, (int)'I', MAIN_FRAME_MENU + MenuBar::SELECT_ITEM);
519-
entries[36].Set(wxACCEL_NORMAL, (int)'H', MAIN_FRAME_MENU + MenuBar::SELECT_HOUSE);
520-
entries[37].Set(wxACCEL_NORMAL, (int)'C', MAIN_FRAME_MENU + MenuBar::SELECT_CREATURE);
521-
entries[38].Set(wxACCEL_NORMAL, (int)'W', MAIN_FRAME_MENU + MenuBar::SELECT_WAYPOINT);
522-
entries[39].Set(wxACCEL_NORMAL, (int)'R', MAIN_FRAME_MENU + MenuBar::SELECT_RAW);
518+
entries[33].Set(wxACCEL_NORMAL, (int)'M', MAIN_FRAME_MENU + MenuBar::WIN_MINIMAP);
519+
entries[34].Set(wxACCEL_NORMAL, (int)'T', MAIN_FRAME_MENU + MenuBar::SELECT_TERRAIN);
520+
entries[35].Set(wxACCEL_NORMAL, (int)'D', MAIN_FRAME_MENU + MenuBar::SELECT_DOODAD);
521+
entries[36].Set(wxACCEL_NORMAL, (int)'I', MAIN_FRAME_MENU + MenuBar::SELECT_ITEM);
522+
entries[37].Set(wxACCEL_NORMAL, (int)'H', MAIN_FRAME_MENU + MenuBar::SELECT_HOUSE);
523+
entries[38].Set(wxACCEL_NORMAL, (int)'C', MAIN_FRAME_MENU + MenuBar::SELECT_CREATURE);
524+
entries[39].Set(wxACCEL_NORMAL, (int)'W', MAIN_FRAME_MENU + MenuBar::SELECT_WAYPOINT);
525+
entries[40].Set(wxACCEL_NORMAL, (int)'R', MAIN_FRAME_MENU + MenuBar::SELECT_RAW);
523526

524527
wxAcceleratorTable accelerator(count, entries);
525528
frame->SetAcceleratorTable(accelerator);
@@ -1728,6 +1731,7 @@ void MainMenuBar::OnChangeViewSettings(wxCommandEvent& event)
17281731

17291732
g_settings.setInteger(Config::SHOW_SHADE, IsItemChecked(MenuBar::SHOW_SHADE));
17301733
g_settings.setInteger(Config::SHOW_SPECIAL_TILES, IsItemChecked(MenuBar::SHOW_SPECIAL));
1734+
g_settings.setInteger(Config::SHOW_AS_MINIMAP, IsItemChecked(MenuBar::SHOW_AS_MINIMAP));
17311735
g_settings.setInteger(Config::SHOW_ONLY_TILEFLAGS, IsItemChecked(MenuBar::SHOW_ONLY_COLORS));
17321736
g_settings.setInteger(Config::SHOW_ONLY_MODIFIED_TILES, IsItemChecked(MenuBar::SHOW_ONLY_MODIFIED));
17331737
g_settings.setInteger(Config::SHOW_CREATURES, IsItemChecked(MenuBar::SHOW_CREATURES));

source/main_menubar.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ namespace MenuBar
100100
SHOW_CREATURES,
101101
SHOW_SPAWNS,
102102
SHOW_SPECIAL,
103+
SHOW_AS_MINIMAP,
103104
SHOW_ONLY_COLORS,
104105
SHOW_ONLY_MODIFIED,
105106
SHOW_HOUSES,

source/map_display.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ void MapCanvas::OnPaint(wxPaintEvent& event)
195195
options.highlight_items = g_settings.getBoolean(Config::HIGHLIGHT_ITEMS);
196196
options.show_blocking = g_settings.getBoolean(Config::SHOW_BLOCKING);
197197
options.show_tooltips = g_settings.getBoolean(Config::SHOW_TOOLTIPS);
198+
options.show_as_minimap = g_settings.getBoolean(Config::SHOW_AS_MINIMAP);
198199
options.show_only_colors = g_settings.getBoolean(Config::SHOW_ONLY_TILEFLAGS);
199200
options.show_only_modified = g_settings.getBoolean(Config::SHOW_ONLY_MODIFIED_TILES);
200201
options.show_preview = g_settings.getBoolean(Config::SHOW_PREVIEW);

source/map_drawer.cpp

Lines changed: 61 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ void DrawingOptions::SetDefault()
5151
highlight_items = false;
5252
show_blocking = false;
5353
show_tooltips = false;
54+
show_as_minimap = false;
5455
show_only_colors = false;
5556
show_only_modified = false;
5657
show_preview = false;
@@ -78,6 +79,7 @@ void DrawingOptions::SetIngame()
7879
highlight_items = false;
7980
show_blocking = false;
8081
show_tooltips = false;
82+
show_as_minimap = false;
8183
show_only_colors = false;
8284
show_only_modified = false;
8385
show_preview = false;
@@ -221,14 +223,16 @@ void MapDrawer::DrawMap()
221223
current_house_id = brush->asHouseExit()->getHouseID();
222224
}
223225

226+
bool only_colors = options.show_as_minimap || options.show_only_colors;
227+
224228
// Enable texture mode
225-
if(!options.show_only_colors)
229+
if(!only_colors)
226230
glEnable(GL_TEXTURE_2D);
227231

228232
for(int map_z = start_z; map_z >= superend_z; map_z--) {
229233
if(map_z == end_z && start_z != end_z && options.show_shade) {
230234
// Draw shade
231-
if(!options.show_only_colors)
235+
if(!only_colors)
232236
glDisable(GL_TEXTURE_2D);
233237

234238
glColor4ub(0, 0, 0, 128);
@@ -239,7 +243,7 @@ void MapDrawer::DrawMap()
239243
glVertex2f(0,0);
240244
glEnd();
241245

242-
if(!options.show_only_colors)
246+
if(!only_colors)
243247
glEnable(GL_TEXTURE_2D);
244248
}
245249

@@ -288,7 +292,7 @@ void MapDrawer::DrawMap()
288292
}
289293
}
290294

291-
if(options.show_only_colors)
295+
if(only_colors)
292296
glEnable(GL_TEXTURE_2D);
293297

294298
// Draws the doodad preview or the paste preview (or import preview)
@@ -378,7 +382,7 @@ void MapDrawer::DrawMap()
378382
++end_y;
379383
}
380384

381-
if(!options.show_only_colors)
385+
if(!only_colors)
382386
glEnable(GL_TEXTURE_2D);
383387
}
384388

@@ -1356,7 +1360,8 @@ void MapDrawer::DrawTile(TileLocation* location)
13561360
WriteTooltip(waypoint, tooltip);
13571361
}
13581362

1359-
bool only_colors = options.show_only_colors;
1363+
bool as_minimap = options.show_as_minimap;
1364+
bool only_colors = as_minimap || options.show_only_colors;
13601365

13611366
int offset;
13621367
if (map_z <= GROUND_LAYER)
@@ -1369,57 +1374,69 @@ void MapDrawer::DrawTile(TileLocation* location)
13691374

13701375
uint8_t r = 255,g = 255,b = 255;
13711376
if(tile->ground || only_colors) {
1372-
bool showspecial = options.show_only_colors || options.show_special_tiles;
13731377

1374-
if(tile->isBlocking() && tile->size() > 0 && options.show_blocking) {
1375-
g = g/3*2;
1376-
b = b/3*2;
1377-
}
1378+
if(!as_minimap) {
1379+
bool showspecial = options.show_only_colors || options.show_special_tiles;
13781380

1379-
int item_count = tile->items.size();
1380-
if(options.highlight_items && item_count > 0 && !tile->items.back()->isBorder()) {
1381-
static const float factor[5] = {0.75f, 0.6f, 0.48f, 0.40f, 0.33f};
1382-
int idx = (item_count < 5 ? item_count : 5) - 1;
1383-
g = int(g * factor[idx]);
1384-
r = int(r * factor[idx]);
1385-
}
1381+
if(options.show_blocking && tile->isBlocking() && tile->size() > 0) {
1382+
g = g / 3 * 2;
1383+
b = b / 3 * 2;
1384+
}
13861385

1387-
if(location->getSpawnCount() > 0 && options.show_spawns) {
1388-
float f = 1.0f;
1389-
for(uint32_t i = 0; i < location->getSpawnCount(); ++i) {
1390-
f *= 0.7f;
1386+
int item_count = tile->items.size();
1387+
if(options.highlight_items && item_count > 0 && !tile->items.back()->isBorder()) {
1388+
static const float factor[5] = { 0.75f, 0.6f, 0.48f, 0.40f, 0.33f };
1389+
int idx = (item_count < 5 ? item_count : 5) - 1;
1390+
g = int(g * factor[idx]);
1391+
r = int(r * factor[idx]);
13911392
}
1392-
g = uint8_t(g * f);
1393-
b = uint8_t(b * f);
1394-
}
13951393

1396-
if(tile->isHouseTile() && options.show_houses) {
1397-
if((int)tile->getHouseID() == current_house_id) {
1398-
r /= 2;
1399-
} else {
1394+
if(options.show_spawns && location->getSpawnCount() > 0) {
1395+
float f = 1.0f;
1396+
for(uint32_t i = 0; i < location->getSpawnCount(); ++i) {
1397+
f *= 0.7f;
1398+
}
1399+
g = uint8_t(g * f);
1400+
b = uint8_t(b * f);
1401+
}
1402+
1403+
if(options.show_houses && tile->isHouseTile()) {
1404+
if((int)tile->getHouseID() == current_house_id) {
1405+
r /= 2;
1406+
}
1407+
else {
1408+
r /= 2;
1409+
g /= 2;
1410+
}
1411+
}
1412+
else if(showspecial && tile->isPZ()) {
14001413
r /= 2;
1401-
g /= 2;
1414+
b /= 2;
14021415
}
1403-
} else if(showspecial && tile->isPZ()) {
1404-
r /= 2;
1405-
b /= 2;
1406-
}
14071416

1408-
if(showspecial && tile->getMapFlags() & TILESTATE_PVPZONE) {
1409-
g = r/4;
1410-
b = b/3*2;
1411-
}
1417+
if(showspecial && tile->getMapFlags() & TILESTATE_PVPZONE) {
1418+
g = r / 4;
1419+
b = b / 3 * 2;
1420+
}
14121421

1413-
if(showspecial && tile->getMapFlags() & TILESTATE_NOLOGOUT) {
1414-
b /= 2;
1415-
}
1422+
if(showspecial && tile->getMapFlags() & TILESTATE_NOLOGOUT) {
1423+
b /= 2;
1424+
}
14161425

1417-
if(showspecial && tile->getMapFlags() & TILESTATE_NOPVP) {
1418-
g /= 2;
1426+
if(showspecial && tile->getMapFlags() & TILESTATE_NOPVP) {
1427+
g /= 2;
1428+
}
14191429
}
14201430

14211431
if(only_colors) {
1422-
if(r != 255 || g != 255 || b != 255) {
1432+
if(as_minimap) {
1433+
uint8_t color = tile->getMiniMapColor();
1434+
r = (uint8_t)(int(color / 36) % 6 * 51);
1435+
g = (uint8_t)(int(color / 6) % 6 * 51);
1436+
b = (uint8_t)(color % 6 * 51);
1437+
glBlitSquare(draw_x, draw_y, r, g, b, 255);
1438+
}
1439+
else if(r != 255 || g != 255 || b != 255) {
14231440
glBlitSquare(draw_x, draw_y, r, g, b, 128);
14241441
}
14251442
} else {

source/map_drawer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ struct DrawingOptions {
5252
bool highlight_items;
5353
bool show_blocking;
5454
bool show_tooltips;
55+
bool show_as_minimap;
5556
bool show_only_colors;
5657
bool show_only_modified;
5758
bool show_preview;

source/settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ namespace Config {
4545
SHOW_TOOLTIPS,
4646
SHOW_PREVIEW,
4747
SHOW_WALL_HOOKS,
48+
SHOW_AS_MINIMAP,
4849
SHOW_ONLY_TILEFLAGS,
4950
SHOW_ONLY_MODIFIED_TILES,
5051
HIDE_ITEMS_WHEN_ZOOMED,

source/tile.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ Tile::Tile(int x, int y, int z) :
3838
spawn(nullptr),
3939
house_id(0),
4040
mapflags(0),
41-
statflags(0)
41+
statflags(0),
42+
minimapColor(INVALID_MINIMAP_COLOR)
4243
{
4344
////
4445
}
@@ -50,7 +51,8 @@ Tile::Tile(TileLocation& loc) :
5051
spawn(nullptr),
5152
house_id(0),
5253
mapflags(0),
53-
statflags(0)
54+
statflags(0),
55+
minimapColor(INVALID_MINIMAP_COLOR)
5456
{
5557
////
5658
}
@@ -334,16 +336,21 @@ ItemVector Tile::getSelectedItems()
334336

335337
uint8_t Tile::getMiniMapColor() const
336338
{
339+
if(minimapColor != INVALID_MINIMAP_COLOR)
340+
return minimapColor;
341+
337342
for(ItemVector::const_reverse_iterator item_iter = items.rbegin(); item_iter != items.rend(); ++item_iter) {
338343
if((*item_iter)->getMiniMapColor()) {
339344
return (*item_iter)->getMiniMapColor();
340345
break;
341346
}
342347
}
348+
343349
// check ground too
344350
if(hasGround()) {
345351
return ground->getMiniMapColor();
346352
}
353+
347354
return 0;
348355
}
349356

@@ -394,6 +401,9 @@ void Tile::update()
394401
if(ground->getUniqueID() != 0) {
395402
statflags |= TILESTATE_UNIQUE;
396403
}
404+
if(ground->getMiniMapColor() != 0) {
405+
minimapColor = ground->getMiniMapColor();
406+
}
397407
}
398408

399409
ItemVector::const_iterator iter = items.begin();
@@ -405,6 +415,9 @@ void Tile::update()
405415
if(i->getUniqueID() != 0) {
406416
statflags |= TILESTATE_UNIQUE;
407417
}
418+
if(i->getMiniMapColor() != 0) {
419+
minimapColor = i->getMiniMapColor();
420+
}
408421

409422
ItemType& it = g_items[i->getID()];
410423
if(it.unpassable) {

source/tile.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ enum {
4242
TILESTATE_MODIFIED = 0x0040,
4343
};
4444

45+
enum : uint8_t {
46+
INVALID_MINIMAP_COLOR = 0xFF
47+
};
48+
4549
class Tile
4650
{
4751
public: // Members
@@ -207,7 +211,10 @@ class Tile
207211
};
208212
uint32_t flags;
209213
};
214+
210215
private:
216+
uint8_t minimapColor;
217+
211218
Tile(const Tile& tile); // No copy
212219
Tile& operator=(const Tile& i);// Can't copy
213220
Tile& operator==(const Tile& i);// Can't compare

0 commit comments

Comments
 (0)