Skip to content

Commit bba3394

Browse files
authored
Merge pull request #239 from hjnilsson/make_spawns_visible
Make spawns visible when placing a new spawn.
2 parents db48aa6 + 8227054 commit bba3394

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

source/gui.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,11 @@ void GUI::DestroyLoadBar()
11171117
}
11181118
}
11191119

1120+
void GUI::UpdateMenubar()
1121+
{
1122+
root->UpdateMenubar();
1123+
}
1124+
11201125
void GUI::SetScreenCenterPosition(Position position)
11211126
{
11221127
MapTab* mapTab = GetCurrentMapTab();

source/gui.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ class GUI
151151
*/
152152
void DestroyLoadBar();
153153

154+
void UpdateMenubar();
155+
154156
bool IsRenderingEnabled() const {return disabled_counter == 0;}
155157

156158
void EnableHotkeys();

source/main_menubar.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@ void MainMenuBar::Update()
344344
EnableItem(ZOOM_OUT, has_map);
345345
EnableItem(ZOOM_NORMAL, has_map);
346346

347+
if(has_map)
348+
CheckItem(SHOW_SPAWNS, g_settings.getBoolean(Config::SHOW_SPAWNS));
349+
347350
EnableItem(WIN_MINIMAP, loaded);
348351
EnableItem(NEW_PALETTE, loaded);
349352
EnableItem(SELECT_TERRAIN, loaded);

source/map_display.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,25 @@ void MapCanvas::OnMouseActionClick(wxMouseEvent& event)
799799
editor.undraw(Position(mouse_map_x, mouse_map_y, floor), event.ShiftDown() || event.AltDown());
800800
}
801801
} else {
802+
bool will_show_spawn = false;
803+
if(brush->isSpawn() || brush->isCreature()) {
804+
if(!g_settings.getBoolean(Config::SHOW_SPAWNS)) {
805+
Tile* tile = editor.map.getTile(mouse_map_x, mouse_map_y, floor);
806+
if(!tile || !tile->spawn) {
807+
will_show_spawn = true;
808+
}
809+
}
810+
}
811+
802812
editor.draw(Position(mouse_map_x, mouse_map_y, floor), event.ShiftDown() || event.AltDown());
813+
814+
if(will_show_spawn) {
815+
Tile* tile = editor.map.getTile(mouse_map_x, mouse_map_y, floor);
816+
if(tile && tile->spawn) {
817+
g_settings.setInteger(Config::SHOW_SPAWNS, true);
818+
g_gui.UpdateMenubar();
819+
}
820+
}
803821
}
804822
} else {
805823
if(brush->isGround() && event.AltDown()) {

0 commit comments

Comments
 (0)