From 8227054ef2cd97b8afe9ad7b979b2a772d9be0f7 Mon Sep 17 00:00:00 2001 From: Mignari Date: Fri, 24 Aug 2018 21:30:19 -0300 Subject: [PATCH] Make spawns visible when placing a new spawn. --- source/gui.cpp | 5 +++++ source/gui.h | 2 ++ source/main_menubar.cpp | 3 +++ source/map_display.cpp | 18 ++++++++++++++++++ 4 files changed, 28 insertions(+) diff --git a/source/gui.cpp b/source/gui.cpp index 00f1e3ee..c5264367 100644 --- a/source/gui.cpp +++ b/source/gui.cpp @@ -1117,6 +1117,11 @@ void GUI::DestroyLoadBar() } } +void GUI::UpdateMenubar() +{ + root->UpdateMenubar(); +} + void GUI::SetScreenCenterPosition(Position position) { MapTab* mapTab = GetCurrentMapTab(); diff --git a/source/gui.h b/source/gui.h index be00e2ba..0d5672af 100644 --- a/source/gui.h +++ b/source/gui.h @@ -151,6 +151,8 @@ class GUI */ void DestroyLoadBar(); + void UpdateMenubar(); + bool IsRenderingEnabled() const {return disabled_counter == 0;} void EnableHotkeys(); diff --git a/source/main_menubar.cpp b/source/main_menubar.cpp index 08b11925..22919b23 100644 --- a/source/main_menubar.cpp +++ b/source/main_menubar.cpp @@ -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); diff --git a/source/map_display.cpp b/source/map_display.cpp index 14ba10c1..ebc3e53a 100644 --- a/source/map_display.cpp +++ b/source/map_display.cpp @@ -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()) {