Skip to content

Commit

Permalink
Merge pull request #239 from hjnilsson/make_spawns_visible
Browse files Browse the repository at this point in the history
Make spawns visible when placing a new spawn.
  • Loading branch information
Elime1 authored Sep 4, 2018
2 parents db48aa6 + 8227054 commit bba3394
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions source/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,11 @@ void GUI::DestroyLoadBar()
}
}

void GUI::UpdateMenubar()
{
root->UpdateMenubar();
}

void GUI::SetScreenCenterPosition(Position position)
{
MapTab* mapTab = GetCurrentMapTab();
Expand Down
2 changes: 2 additions & 0 deletions source/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ class GUI
*/
void DestroyLoadBar();

void UpdateMenubar();

bool IsRenderingEnabled() const {return disabled_counter == 0;}

void EnableHotkeys();
Expand Down
3 changes: 3 additions & 0 deletions source/main_menubar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ void MainMenuBar::Update()
EnableItem(ZOOM_OUT, has_map);
EnableItem(ZOOM_NORMAL, has_map);

if(has_map)
CheckItem(SHOW_SPAWNS, g_settings.getBoolean(Config::SHOW_SPAWNS));

EnableItem(WIN_MINIMAP, loaded);
EnableItem(NEW_PALETTE, loaded);
EnableItem(SELECT_TERRAIN, loaded);
Expand Down
18 changes: 18 additions & 0 deletions source/map_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,25 @@ void MapCanvas::OnMouseActionClick(wxMouseEvent& event)
editor.undraw(Position(mouse_map_x, mouse_map_y, floor), event.ShiftDown() || event.AltDown());
}
} else {
bool will_show_spawn = false;
if(brush->isSpawn() || brush->isCreature()) {
if(!g_settings.getBoolean(Config::SHOW_SPAWNS)) {
Tile* tile = editor.map.getTile(mouse_map_x, mouse_map_y, floor);
if(!tile || !tile->spawn) {
will_show_spawn = true;
}
}
}

editor.draw(Position(mouse_map_x, mouse_map_y, floor), event.ShiftDown() || event.AltDown());

if(will_show_spawn) {
Tile* tile = editor.map.getTile(mouse_map_x, mouse_map_y, floor);
if(tile && tile->spawn) {
g_settings.setInteger(Config::SHOW_SPAWNS, true);
g_gui.UpdateMenubar();
}
}
}
} else {
if(brush->isGround() && event.AltDown()) {
Expand Down

0 comments on commit bba3394

Please sign in to comment.