tibia-rme/source/editor.cpp

2093 lines
59 KiB
C++
Raw Permalink Normal View History

//////////////////////////////////////////////////////////////////////
// This file is part of Remere's Map Editor
//////////////////////////////////////////////////////////////////////
2020-07-30 11:42:28 -03:00
// 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/>.
//////////////////////////////////////////////////////////////////////
#include "main.h"
#include "editor.h"
#include "materials.h"
#include "map.h"
#include "complexitem.h"
#include "settings.h"
#include "gui.h"
#include "map_display.h"
#include "brush.h"
#include "ground_brush.h"
#include "wall_brush.h"
#include "table_brush.h"
#include "carpet_brush.h"
#include "waypoint_brush.h"
#include "house_exit_brush.h"
#include "doodad_brush.h"
#include "monster_brush.h"
#include "npc_brush.h"
#include "spawn_monster_brush.h"
#include "spawn_npc_brush.h"
#include "live_server.h"
#include "live_client.h"
#include "live_action.h"
2023-10-09 19:12:16 -07:00
Editor::Editor(CopyBuffer &copybuffer) :
live_server(nullptr),
live_client(nullptr),
actionQueue(newd ActionQueue(*this)),
selection(*this),
copybuffer(copybuffer),
2023-10-09 19:12:16 -07:00
replace_brush(nullptr) {
wxString error;
wxArrayString warnings;
bool ok = true;
ClientVersionID defaultVersion = ClientVersionID(g_settings.getInteger(Config::DEFAULT_CLIENT_VERSION));
2023-10-09 19:12:16 -07:00
if (defaultVersion == CLIENT_VERSION_NONE) {
defaultVersion = ClientVersion::getLatestVersion()->getID();
2023-10-09 19:12:16 -07:00
}
2015-12-06 11:42:37 -03:00
2023-10-09 19:12:16 -07:00
if (g_gui.GetCurrentVersionID() != defaultVersion) {
if (g_gui.CloseAllEditors()) {
ok = g_gui.LoadVersion(defaultVersion, error, warnings);
2016-11-05 15:28:14 +01:00
g_gui.PopupDialog("Error", error, wxOK);
g_gui.ListDialog("Warnings", warnings);
} else {
throw std::runtime_error("All maps of different versions were not closed.");
}
}
2023-10-09 19:12:16 -07:00
if (!ok) {
throw std::runtime_error("Couldn't load client version");
2023-10-09 19:12:16 -07:00
}
MapVersion version;
version.otbm = g_gui.GetCurrentVersion().getPrefferedMapVersionID();
version.client = g_gui.GetCurrentVersionID();
map.convert(version);
map.height = 2048;
map.width = 2048;
static int unnamed_counter = 0;
std::string sname = "Untitled-" + i2s(++unnamed_counter);
map.name = sname + ".otbm";
map.spawnmonsterfile = sname + "-monster.xml";
map.spawnnpcfile = sname + "-npc.xml";
map.housefile = sname + "-house.xml";
2023-11-08 17:04:13 -08:00
map.zonefile = sname + "-zones.xml";
map.description = "No map description available.";
map.unnamed = true;
map.doChange();
}
2023-10-09 19:12:16 -07:00
Editor::Editor(CopyBuffer &copybuffer, const FileName &fn) :
live_server(nullptr),
live_client(nullptr),
actionQueue(newd ActionQueue(*this)),
selection(*this),
copybuffer(copybuffer),
2023-10-09 19:12:16 -07:00
replace_brush(nullptr) {
MapVersion ver;
2023-10-09 19:12:16 -07:00
if (!IOMapOTBM::getVersionInfo(fn, ver)) {
2016-11-05 15:28:14 +01:00
// g_gui.PopupDialog("Error", "Could not open file \"" + fn.GetFullPath() + "\".", wxOK);
2012-07-04 17:05:30 +02:00
throw std::runtime_error("Could not open file \"" + nstr(fn.GetFullPath()) + "\".\nThis is not a valid OTBM file or it does not exist.");
}
/*
if(ver < CLIENT_VERSION_760) {
2016-11-05 15:28:14 +01:00
long b = g_gui.PopupDialog("Error", "Unsupported Client Version (pre 7.6), do you want to try to load the map anyways?", wxYES | wxNO);
if(b == wxID_NO) {
valid_state = false;
return;
}
}
*/
bool success = true;
2023-10-09 19:12:16 -07:00
if (g_gui.GetCurrentVersionID() != ver.client) {
wxString error;
wxArrayString warnings;
2023-10-09 19:12:16 -07:00
if (g_gui.CloseAllEditors()) {
success = g_gui.LoadVersion(ver.client, error, warnings);
2023-10-09 19:12:16 -07:00
if (!success) {
2016-11-05 15:28:14 +01:00
g_gui.PopupDialog("Error", error, wxOK);
2023-10-09 19:12:16 -07:00
} else {
2016-11-05 15:28:14 +01:00
g_gui.ListDialog("Warnings", warnings);
2023-10-09 19:12:16 -07:00
}
} else {
throw std::runtime_error("All maps of different versions were not closed.");
}
}
2023-10-09 19:12:16 -07:00
if (success) {
2012-07-04 17:00:14 +02:00
ScopedLoadingBar LoadingBar("Loading OTBM map...");
success = map.open(nstr(fn.GetFullPath()));
2012-07-01 19:06:30 +02:00
/* TODO
2015-12-06 11:42:37 -03:00
if(success && ver.client == CLIENT_VERSION_854_BAD) {
2016-11-05 15:28:14 +01:00
int ok = g_gui.PopupDialog("Incorrect OTB", "This map has been saved with an incorrect OTB version, do you want to convert it to the new OTB version?\n\nIf you are not sure, click Yes.", wxYES | wxNO);
2016-09-29 19:24:45 -03:00
if(ok == wxID_YES){
ver.client = CLIENT_VERSION_854;
map.convert(ver);
}
}
*/
}
}
2023-10-09 19:12:16 -07:00
Editor::Editor(CopyBuffer &copybuffer, LiveClient* client) :
live_server(nullptr),
live_client(client),
actionQueue(newd NetworkedActionQueue(*this)),
selection(*this),
copybuffer(copybuffer),
2023-10-09 19:12:16 -07:00
replace_brush(nullptr) {
;
}
2023-10-09 19:12:16 -07:00
Editor::~Editor() {
if (IsLive()) {
CloseLiveServer();
}
UnnamedRenderingLock();
selection.clear();
delete actionQueue;
}
2023-10-09 19:12:16 -07:00
Action* Editor::createAction(ActionIdentifier type) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return actionQueue->createAction(type);
}
2023-10-09 19:12:16 -07:00
Action* Editor::createAction(BatchAction* parent) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return actionQueue->createAction(parent);
}
2023-10-09 19:12:16 -07:00
BatchAction* Editor::createBatch(ActionIdentifier type) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return actionQueue->createBatch(type);
}
2023-10-09 19:12:16 -07:00
void Editor::addBatch(BatchAction* action, int stacking_delay) {
actionQueue->addBatch(action, stacking_delay);
}
2023-10-09 19:12:16 -07:00
void Editor::addAction(Action* action, int stacking_delay) {
actionQueue->addAction(action, stacking_delay);
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
}
2023-10-09 19:12:16 -07:00
bool Editor::canUndo() const {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return actionQueue->canUndo();
}
2023-10-09 19:12:16 -07:00
bool Editor::canRedo() const {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return actionQueue->canRedo();
}
2023-10-09 19:12:16 -07:00
void Editor::undo(int indexes) {
if (indexes <= 0 || !actionQueue->canUndo()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return;
2023-10-09 19:12:16 -07:00
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
2023-10-09 19:12:16 -07:00
while (indexes > 0) {
if (!actionQueue->undo()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
break;
2023-10-09 19:12:16 -07:00
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
indexes--;
}
g_gui.UpdateActions();
g_gui.RefreshView();
}
2023-10-09 19:12:16 -07:00
void Editor::redo(int indexes) {
if (indexes <= 0 || !actionQueue->canRedo()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return;
2023-10-09 19:12:16 -07:00
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
2023-10-09 19:12:16 -07:00
while (indexes > 0) {
if (!actionQueue->redo()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
break;
2023-10-09 19:12:16 -07:00
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
indexes--;
}
g_gui.UpdateActions();
g_gui.RefreshView();
}
2023-10-09 19:12:16 -07:00
void Editor::updateActions() {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
actionQueue->generateLabels();
g_gui.UpdateMenus();
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
g_gui.UpdateActions();
}
2023-10-09 19:12:16 -07:00
void Editor::resetActionsTimer() {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
actionQueue->resetTimer();
}
2023-10-09 19:12:16 -07:00
void Editor::clearActions() {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
actionQueue->clear();
g_gui.UpdateActions();
}
2023-10-09 19:12:16 -07:00
bool Editor::hasChanges() const {
if (map.hasChanged()) {
if (map.getTileCount() == 0) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return actionQueue->hasChanges();
}
return true;
}
return false;
}
2023-10-09 19:12:16 -07:00
void Editor::clearChanges() {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
map.clearChanges();
}
2023-10-09 19:12:16 -07:00
void Editor::saveMap(FileName filename, bool showdialog) {
std::string savefile = filename.GetFullPath().mb_str(wxConvUTF8).data();
2012-07-04 21:51:12 +02:00
bool save_as = false;
bool save_otgz = false;
2023-10-09 19:12:16 -07:00
if (savefile.empty()) {
savefile = map.filename;
2016-09-29 19:24:45 -03:00
2012-07-04 21:51:12 +02:00
FileName c1(wxstr(savefile));
FileName c2(wxstr(map.filename));
save_as = c1 != c2;
}
2012-07-04 21:51:12 +02:00
// If not named yet, propagate the file name to the auxilliary files
2023-10-09 19:12:16 -07:00
if (map.unnamed) {
FileName _name(filename);
2016-11-05 15:28:14 +01:00
_name.SetExt("xml");
_name.SetName(filename.GetName() + "-monster");
map.spawnmonsterfile = nstr(_name.GetFullName());
_name.SetName(filename.GetName() + "-npc");
map.spawnnpcfile = nstr(_name.GetFullName());
2016-11-05 15:28:14 +01:00
_name.SetName(filename.GetName() + "-house");
map.housefile = nstr(_name.GetFullName());
2023-11-08 17:04:13 -08:00
_name.SetName(filename.GetName() + "-zones");
map.zonefile = nstr(_name.GetFullName());
2012-07-04 21:51:12 +02:00
map.unnamed = false;
}
2016-09-29 19:24:45 -03:00
// File object to convert between local paths etc.
FileName converter;
converter.Assign(wxstr(savefile));
std::string map_path = nstr(converter.GetPath(wxPATH_GET_SEPARATOR | wxPATH_GET_VOLUME));
// Make temporary backups
2023-10-09 19:12:16 -07:00
// converter.Assign(wxstr(savefile));
2023-11-08 17:04:13 -08:00
std::string backup_otbm, backup_house, backup_spawn, backup_spawn_npc, backup_zones;
2023-10-09 19:12:16 -07:00
if (converter.GetExt() == "otgz") {
2012-07-04 21:51:12 +02:00
save_otgz = true;
2023-10-09 19:12:16 -07:00
if (converter.FileExists()) {
2012-07-04 21:51:12 +02:00
backup_otbm = map_path + nstr(converter.GetName()) + ".otgz~";
std::remove(backup_otbm.c_str());
std::rename(savefile.c_str(), backup_otbm.c_str());
}
2015-12-06 11:42:37 -03:00
} else {
2023-10-09 19:12:16 -07:00
if (converter.FileExists()) {
2012-07-04 21:51:12 +02:00
backup_otbm = map_path + nstr(converter.GetName()) + ".otbm~";
std::remove(backup_otbm.c_str());
std::rename(savefile.c_str(), backup_otbm.c_str());
}
2012-07-04 21:51:12 +02:00
converter.SetFullName(wxstr(map.housefile));
2023-10-09 19:12:16 -07:00
if (converter.FileExists()) {
2012-07-04 21:51:12 +02:00
backup_house = map_path + nstr(converter.GetName()) + ".xml~";
std::remove(backup_house.c_str());
std::rename((map_path + map.housefile).c_str(), backup_house.c_str());
}
converter.SetFullName(wxstr(map.spawnmonsterfile));
2023-10-09 19:12:16 -07:00
if (converter.FileExists()) {
2012-07-04 21:51:12 +02:00
backup_spawn = map_path + nstr(converter.GetName()) + ".xml~";
std::remove(backup_spawn.c_str());
std::rename((map_path + map.spawnmonsterfile).c_str(), backup_spawn.c_str());
}
converter.SetFullName(wxstr(map.spawnnpcfile));
2023-10-09 19:12:16 -07:00
if (converter.FileExists()) {
backup_spawn_npc = map_path + nstr(converter.GetName()) + ".xml~";
std::remove(backup_spawn_npc.c_str());
std::rename((map_path + map.spawnnpcfile).c_str(), backup_spawn_npc.c_str());
2012-07-04 21:51:12 +02:00
}
2023-11-08 17:04:13 -08:00
converter.SetFullName(wxstr(map.zonefile));
if (converter.FileExists()) {
backup_zones = map_path + nstr(converter.GetName()) + ".xml~";
std::remove(backup_zones.c_str());
std::rename((map_path + map.zonefile).c_str(), backup_zones.c_str());
}
}
// Save the map
{
std::string n = nstr(g_gui.GetLocalDataDirectory()) + ".saving.txt";
std::ofstream f(n.c_str(), std::ios::trunc | std::ios::out);
2023-10-09 19:12:16 -07:00
f << backup_otbm << std::endl
<< backup_house << std::endl
<< backup_spawn << std::endl
<< backup_spawn_npc << std::endl;
}
{
2012-07-04 21:51:12 +02:00
// Set up the Map paths
wxFileName fn = wxstr(savefile);
map.filename = fn.GetFullPath().mb_str(wxConvUTF8);
map.name = fn.GetFullName().mb_str(wxConvUTF8);
2023-10-09 19:12:16 -07:00
if (showdialog) {
g_gui.CreateLoadBar("Saving OTBM map...");
2023-10-09 19:12:16 -07:00
}
2016-09-29 19:24:45 -03:00
2012-07-04 21:51:12 +02:00
// Perform the actual save
IOMapOTBM mapsaver(map.getVersion());
bool success = mapsaver.saveMap(map, fn);
2012-07-04 21:51:12 +02:00
2023-10-09 19:12:16 -07:00
if (showdialog) {
g_gui.DestroyLoadBar();
2023-10-09 19:12:16 -07:00
}
2012-07-04 21:51:12 +02:00
// Check for errors...
2023-10-09 19:12:16 -07:00
if (!success) {
2012-07-04 21:51:12 +02:00
// Rename the temporary backup files back to their previous names
2023-10-09 19:12:16 -07:00
if (!backup_otbm.empty()) {
converter.SetFullName(wxstr(savefile));
std::string otbm_filename = map_path + nstr(converter.GetName());
2012-07-04 21:51:12 +02:00
std::rename(backup_otbm.c_str(), std::string(otbm_filename + (save_otgz ? ".otgz" : ".otbm")).c_str());
}
2023-10-09 19:12:16 -07:00
if (!backup_house.empty()) {
converter.SetFullName(wxstr(map.housefile));
std::string house_filename = map_path + nstr(converter.GetName());
std::rename(backup_house.c_str(), std::string(house_filename + ".xml").c_str());
}
2023-10-09 19:12:16 -07:00
if (!backup_spawn.empty()) {
converter.SetFullName(wxstr(map.spawnmonsterfile));
std::string spawn_filename = map_path + nstr(converter.GetName());
std::rename(backup_spawn.c_str(), std::string(spawn_filename + ".xml").c_str());
}
2012-07-04 21:51:12 +02:00
2023-10-09 19:12:16 -07:00
if (!backup_spawn_npc.empty()) {
converter.SetFullName(wxstr(map.spawnnpcfile));
std::string spawnnpc_filename = map_path + nstr(converter.GetName());
std::rename(backup_spawn_npc.c_str(), std::string(spawnnpc_filename + ".xml").c_str());
}
2023-11-08 17:04:13 -08:00
if (!backup_zones.empty()) {
converter.SetFullName(wxstr(map.zonefile));
std::string zones_filename = map_path + nstr(converter.GetName());
std::rename(backup_zones.c_str(), std::string(zones_filename + ".xml").c_str());
}
2012-07-04 21:51:12 +02:00
// Display the error
2016-11-05 15:28:14 +01:00
g_gui.PopupDialog("Error", "Could not save, unable to open target for writing.", wxOK);
}
2016-09-29 19:24:45 -03:00
// Remove temporary save runfile
{
std::string n = nstr(g_gui.GetLocalDataDirectory()) + ".saving.txt";
std::remove(n.c_str());
}
// If failure, don't run the rest of the function
2023-10-09 19:12:16 -07:00
if (!success) {
return;
2023-10-09 19:12:16 -07:00
}
}
2016-09-29 19:24:45 -03:00
// Move to permanent backup
2023-10-09 19:12:16 -07:00
if (!save_as && g_settings.getInteger(Config::ALWAYS_MAKE_BACKUP)) {
std::string backup_path = map_path + "backups/";
ensureBackupDirectoryExists(backup_path);
// Move temporary backups to their proper files
time_t t = time(nullptr);
tm* current_time = localtime(&t);
ASSERT(current_time);
std::ostringstream date;
date << (1900 + current_time->tm_year);
2023-10-09 19:12:16 -07:00
if (current_time->tm_mon < 9) {
date << "-"
<< "0" << current_time->tm_mon + 1;
} else {
date << "-" << current_time->tm_mon + 1;
}
date << "-" << current_time->tm_mday;
date << "-" << current_time->tm_hour;
date << "-" << current_time->tm_min;
date << "-" << current_time->tm_sec;
2023-10-09 19:12:16 -07:00
if (!backup_otbm.empty()) {
converter.SetFullName(wxstr(savefile));
std::string otbm_filename = backup_path + nstr(converter.GetName());
2012-07-04 21:51:12 +02:00
std::rename(backup_otbm.c_str(), std::string(otbm_filename + "." + date.str() + (save_otgz ? ".otgz" : ".otbm")).c_str());
}
2023-10-09 19:12:16 -07:00
if (!backup_house.empty()) {
converter.SetFullName(wxstr(map.housefile));
std::string house_filename = backup_path + nstr(converter.GetName());
std::rename(backup_house.c_str(), std::string(house_filename + "." + date.str() + ".xml").c_str());
}
2023-10-09 19:12:16 -07:00
if (!backup_spawn.empty()) {
converter.SetFullName(wxstr(map.spawnmonsterfile));
std::string spawn_filename = backup_path + nstr(converter.GetName());
std::rename(backup_spawn.c_str(), std::string(spawn_filename + "." + date.str() + ".xml").c_str());
}
2023-10-09 19:12:16 -07:00
if (!backup_spawn_npc.empty()) {
converter.SetFullName(wxstr(map.spawnnpcfile));
std::string spawnnpc_filename = backup_path + nstr(converter.GetName());
std::rename(backup_spawn_npc.c_str(), std::string(spawnnpc_filename + "." + date.str() + ".xml").c_str());
}
2023-11-08 17:04:13 -08:00
if (!backup_zones.empty()) {
converter.SetFullName(wxstr(map.zonefile));
std::string zones_filename = backup_path + nstr(converter.GetName());
2023-11-08 17:04:13 -08:00
std::rename(backup_zones.c_str(), std::string(zones_filename + "." + date.str() + ".xml").c_str());
}
2015-12-06 11:42:37 -03:00
} else {
// Delete the temporary files
std::remove(backup_otbm.c_str());
std::remove(backup_house.c_str());
std::remove(backup_spawn.c_str());
std::remove(backup_spawn_npc.c_str());
2023-11-08 17:04:13 -08:00
std::remove(backup_zones.c_str());
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
clearChanges();
}
2023-10-09 19:12:16 -07:00
bool Editor::importMiniMap(FileName filename, int import, int import_x_offset, int import_y_offset, int import_z_offset) {
return false;
}
2023-10-09 19:12:16 -07:00
bool Editor::importMap(FileName filename, int import_x_offset, int import_y_offset, int import_z_offset, ImportType house_import_type, ImportType spawn_import_type, ImportType spawn_npc_import_type) {
2012-07-04 21:51:12 +02:00
selection.clear();
actionQueue->clear();
Map imported_map;
bool loaded = imported_map.open(nstr(filename.GetFullPath()));
2023-10-09 19:12:16 -07:00
if (!loaded) {
2016-11-05 15:28:14 +01:00
g_gui.PopupDialog("Error", "Error loading map!\n" + imported_map.getError(), wxOK | wxICON_INFORMATION);
return false;
}
2016-11-05 15:28:14 +01:00
g_gui.ListDialog("Warning", imported_map.getWarnings());
Position offset(import_x_offset, import_y_offset, import_z_offset);
bool resizemap = false;
bool resize_asked = false;
int newsize_x = map.getWidth(), newsize_y = map.getHeight();
int discarded_tiles = 0;
2016-11-05 15:28:14 +01:00
g_gui.CreateLoadBar("Merging maps...");
std::map<uint32_t, uint32_t> town_id_map;
std::map<uint32_t, uint32_t> house_id_map;
2023-10-09 19:12:16 -07:00
if (house_import_type != IMPORT_DONT) {
for (TownMap::iterator tit = imported_map.towns.begin(); tit != imported_map.towns.end();) {
Town* imported_town = tit->second;
Town* current_town = map.towns.getTown(imported_town->getID());
Position oldexit = imported_town->getTemplePosition();
Position newexit = oldexit + offset;
2023-10-09 19:12:16 -07:00
if (newexit.isValid()) {
imported_town->setTemplePosition(newexit);
}
2023-10-09 19:12:16 -07:00
switch (house_import_type) {
case IMPORT_MERGE: {
town_id_map[imported_town->getID()] = imported_town->getID();
2023-10-09 19:12:16 -07:00
if (current_town) {
++tit;
continue;
}
2015-12-06 11:42:37 -03:00
break;
}
case IMPORT_SMART_MERGE: {
2023-10-09 19:12:16 -07:00
if (current_town) {
// Compare and insert/merge depending on parameters
2023-10-09 19:12:16 -07:00
if (current_town->getName() == imported_town->getName() && current_town->getID() == imported_town->getID()) {
// Just add to map
town_id_map[imported_town->getID()] = current_town->getID();
++tit;
continue;
} else {
// Conflict! Find a newd id and replace old
uint32_t new_id = map.towns.getEmptyID();
imported_town->setID(new_id);
town_id_map[imported_town->getID()] = new_id;
}
} else {
town_id_map[imported_town->getID()] = imported_town->getID();
}
2015-12-06 11:42:37 -03:00
break;
}
case IMPORT_INSERT: {
// Find a newd id and replace old
uint32_t new_id = map.towns.getEmptyID();
imported_town->setID(new_id);
town_id_map[imported_town->getID()] = new_id;
2015-12-06 11:42:37 -03:00
break;
}
case IMPORT_DONT: {
++tit;
continue; // Should never happend..?
2015-12-06 11:42:37 -03:00
break; // Continue or break ?
}
}
map.towns.addTown(imported_town);
#ifdef __VISUALC__ // C++0x compliance to some degree :)
tit = imported_map.towns.erase(tit);
#else // Bulky, slow way
TownMap::iterator tmp_iter = tit;
++tmp_iter;
uint32_t next_key = 0;
2023-10-09 19:12:16 -07:00
if (tmp_iter != imported_map.towns.end()) {
next_key = tmp_iter->first;
}
imported_map.towns.erase(tit);
2023-10-09 19:12:16 -07:00
if (next_key != 0) {
tit = imported_map.towns.find(next_key);
} else {
tit = imported_map.towns.end();
}
#endif
}
2015-12-06 11:42:37 -03:00
2023-10-09 19:12:16 -07:00
for (HouseMap::iterator hit = imported_map.houses.begin(); hit != imported_map.houses.end();) {
House* imported_house = hit->second;
House* current_house = map.houses.getHouse(imported_house->id);
imported_house->townid = town_id_map[imported_house->townid];
2023-10-09 19:12:16 -07:00
const Position &oldexit = imported_house->getExit();
imported_house->setExit(nullptr, Position()); // Reset it
2023-10-09 19:12:16 -07:00
switch (house_import_type) {
case IMPORT_MERGE: {
house_id_map[imported_house->id] = imported_house->id;
2023-10-09 19:12:16 -07:00
if (current_house) {
++hit;
Position newexit = oldexit + offset;
2023-10-09 19:12:16 -07:00
if (newexit.isValid()) {
current_house->setExit(&map, newexit);
}
continue;
}
2015-12-06 11:42:37 -03:00
break;
}
case IMPORT_SMART_MERGE: {
2023-10-09 19:12:16 -07:00
if (current_house) {
// Compare and insert/merge depending on parameters
2023-10-09 19:12:16 -07:00
if (current_house->name == imported_house->name && current_house->townid == imported_house->townid) {
// Just add to map
house_id_map[imported_house->id] = current_house->id;
++hit;
Position newexit = oldexit + offset;
2023-10-09 19:12:16 -07:00
if (newexit.isValid()) {
imported_house->setExit(&map, newexit);
}
continue;
} else {
// Conflict! Find a newd id and replace old
uint32_t new_id = map.houses.getEmptyID();
house_id_map[imported_house->id] = new_id;
imported_house->id = new_id;
}
} else {
house_id_map[imported_house->id] = imported_house->id;
}
2015-12-06 11:42:37 -03:00
break;
}
case IMPORT_INSERT: {
// Find a newd id and replace old
uint32_t new_id = map.houses.getEmptyID();
house_id_map[imported_house->id] = new_id;
imported_house->id = new_id;
2015-12-06 11:42:37 -03:00
break;
}
case IMPORT_DONT: {
++hit;
Position newexit = oldexit + offset;
2023-10-09 19:12:16 -07:00
if (newexit.isValid()) {
imported_house->setExit(&map, newexit);
}
continue; // Should never happend..?
2015-12-06 11:42:37 -03:00
break;
}
}
Position newexit = oldexit + offset;
2023-10-09 19:12:16 -07:00
if (newexit.isValid()) {
imported_house->setExit(&map, newexit);
}
map.houses.addHouse(imported_house);
#ifdef __VISUALC__ // C++0x compliance to some degree :)
hit = imported_map.houses.erase(hit);
#else // Bulky, slow way
HouseMap::iterator tmp_iter = hit;
++tmp_iter;
uint32_t next_key = 0;
2023-10-09 19:12:16 -07:00
if (tmp_iter != imported_map.houses.end()) {
next_key = tmp_iter->first;
}
imported_map.houses.erase(hit);
2023-10-09 19:12:16 -07:00
if (next_key != 0) {
hit = imported_map.houses.find(next_key);
} else {
hit = imported_map.houses.end();
}
#endif
}
}
// Monster spawn import
std::map<Position, SpawnMonster*> spawn_monster_map;
2023-10-09 19:12:16 -07:00
if (spawn_import_type != IMPORT_DONT) {
for (SpawnNpcPositionList::iterator siter = imported_map.spawnsMonster.begin(); siter != imported_map.spawnsMonster.end();) {
Position oldSpawnMonsterPos = *siter;
Position newSpawnMonsterPos = *siter + offset;
2023-10-09 19:12:16 -07:00
switch (spawn_import_type) {
case IMPORT_SMART_MERGE:
case IMPORT_INSERT:
2015-12-06 11:42:37 -03:00
case IMPORT_MERGE: {
Tile* imported_tile = imported_map.getTile(oldSpawnMonsterPos);
2023-10-09 19:12:16 -07:00
if (imported_tile) {
ASSERT(imported_tile->spawnMonster);
spawn_monster_map[newSpawnMonsterPos] = imported_tile->spawnMonster;
SpawnNpcPositionList::iterator next = siter;
bool cont = true;
Position next_spawn_monster;
++next;
2023-10-09 19:12:16 -07:00
if (next == imported_map.spawnsMonster.end()) {
cont = false;
2023-10-09 19:12:16 -07:00
} else {
next_spawn_monster = *next;
2023-10-09 19:12:16 -07:00
}
imported_map.spawnsMonster.erase(siter);
2023-10-09 19:12:16 -07:00
if (cont) {
siter = imported_map.spawnsMonster.find(next_spawn_monster);
2023-10-09 19:12:16 -07:00
} else {
siter = imported_map.spawnsMonster.end();
2023-10-09 19:12:16 -07:00
}
}
break;
}
case IMPORT_DONT: {
++siter;
break;
}
}
}
}
// Npc spawn import
std::map<Position, SpawnNpc*> spawn_npc_map;
2023-10-09 19:12:16 -07:00
if (spawn_npc_import_type != IMPORT_DONT) {
for (SpawnNpcPositionList::iterator siter = imported_map.spawnsNpc.begin(); siter != imported_map.spawnsNpc.end();) {
Position oldSpawnNpcPos = *siter;
Position newSpawnNpcPos = *siter + offset;
2023-10-09 19:12:16 -07:00
switch (spawn_npc_import_type) {
case IMPORT_SMART_MERGE:
case IMPORT_INSERT:
case IMPORT_MERGE: {
Tile* importedTile = imported_map.getTile(oldSpawnNpcPos);
2023-10-09 19:12:16 -07:00
if (importedTile) {
ASSERT(importedTile->spawnNpc);
spawn_npc_map[newSpawnNpcPos] = importedTile->spawnNpc;
SpawnNpcPositionList::iterator next = siter;
bool cont = true;
Position next_spawn_npc;
++next;
2023-10-09 19:12:16 -07:00
if (next == imported_map.spawnsNpc.end()) {
cont = false;
2023-10-09 19:12:16 -07:00
} else {
next_spawn_npc = *next;
2023-10-09 19:12:16 -07:00
}
imported_map.spawnsNpc.erase(siter);
2023-10-09 19:12:16 -07:00
if (cont) {
siter = imported_map.spawnsNpc.find(next_spawn_npc);
2023-10-09 19:12:16 -07:00
} else {
siter = imported_map.spawnsNpc.end();
2023-10-09 19:12:16 -07:00
}
}
2015-12-06 11:42:37 -03:00
break;
}
case IMPORT_DONT: {
++siter;
2015-12-06 11:42:37 -03:00
break;
}
}
}
}
// Plain merge of waypoints, very simple! :)
2023-10-09 19:12:16 -07:00
for (WaypointMap::iterator iter = imported_map.waypoints.begin(); iter != imported_map.waypoints.end(); ++iter) {
iter->second->pos += offset;
}
map.waypoints.waypoints.insert(imported_map.waypoints.begin(), imported_map.waypoints.end());
imported_map.waypoints.waypoints.clear();
uint64_t tiles_merged = 0;
uint64_t tiles_to_import = imported_map.tilecount;
2023-10-09 19:12:16 -07:00
for (MapIterator mit = imported_map.begin(); mit != imported_map.end(); ++mit) {
if (tiles_merged % 8092 == 0) {
g_gui.SetLoadDone(int(100.0 * tiles_merged / tiles_to_import));
}
++tiles_merged;
Tile* import_tile = (*mit)->get();
Position new_pos = import_tile->getPosition() + offset;
2023-10-09 19:12:16 -07:00
if (!new_pos.isValid()) {
++discarded_tiles;
continue;
}
2023-10-09 19:12:16 -07:00
if (!resizemap && (new_pos.x > map.getWidth() || new_pos.y > map.getHeight())) {
if (resize_asked) {
++discarded_tiles;
continue;
} else {
resize_asked = true;
2016-11-05 15:28:14 +01:00
int ret = g_gui.PopupDialog("Collision", "The imported tiles are outside the current map scope. Do you want to resize the map? (Else additional tiles will be removed)", wxYES | wxNO);
2023-10-09 19:12:16 -07:00
if (ret == wxID_YES) {
// ...
resizemap = true;
} else {
++discarded_tiles;
continue;
}
}
}
2023-10-09 19:12:16 -07:00
if (new_pos.x > newsize_x) {
newsize_x = new_pos.x;
}
2023-10-09 19:12:16 -07:00
if (new_pos.y > newsize_y) {
newsize_y = new_pos.y;
}
imported_map.setTile(import_tile->getPosition(), nullptr);
TileLocation* location = map.createTileL(new_pos);
// Check if we should update any houses
int new_houseid = house_id_map[import_tile->getHouseID()];
House* house = map.houses.getHouse(new_houseid);
2023-10-09 19:12:16 -07:00
if (import_tile->isHouseTile() && house_import_type != IMPORT_DONT && house) {
// We need to notify houses of the tile moving
house->removeTile(import_tile);
import_tile->setLocation(location);
house->addTile(import_tile);
} else {
import_tile->setLocation(location);
}
2023-10-09 19:12:16 -07:00
if (offset != Position(0, 0, 0)) {
for (ItemVector::iterator iter = import_tile->items.begin(); iter != import_tile->items.end(); ++iter) {
Item* item = *iter;
2023-10-09 19:12:16 -07:00
if (Teleport* teleport = dynamic_cast<Teleport*>(item)) {
teleport->setDestination(teleport->getDestination() + offset);
}
}
}
Tile* old_tile = map.getTile(new_pos);
2023-10-09 19:12:16 -07:00
if (old_tile) {
map.removeSpawnMonster(old_tile);
}
import_tile->spawnMonster = nullptr;
map.setTile(new_pos, import_tile, true);
}
2023-10-09 19:12:16 -07:00
for (std::map<Position, SpawnMonster*>::iterator spawn_monster_iter = spawn_monster_map.begin(); spawn_monster_iter != spawn_monster_map.end(); ++spawn_monster_iter) {
Position pos = spawn_monster_iter->first;
TileLocation* location = map.createTileL(pos);
Tile* tile = location->get();
2023-10-09 19:12:16 -07:00
if (!tile) {
tile = map.allocator(location);
map.setTile(pos, tile);
2023-10-09 19:12:16 -07:00
} else if (tile->spawnMonster) {
map.removeSpawnMonsterInternal(tile);
delete tile->spawnMonster;
}
tile->spawnMonster = spawn_monster_iter->second;
map.addSpawnMonster(tile);
}
2023-10-09 19:12:16 -07:00
for (std::map<Position, SpawnNpc*>::iterator spawn_npc_iter = spawn_npc_map.begin(); spawn_npc_iter != spawn_npc_map.end(); ++spawn_npc_iter) {
Position pos = spawn_npc_iter->first;
TileLocation* location = map.createTileL(pos);
Tile* tile = location->get();
2023-10-09 19:12:16 -07:00
if (!tile) {
tile = map.allocator(location);
map.setTile(pos, tile);
2023-10-09 19:12:16 -07:00
} else if (tile->spawnNpc) {
map.removeSpawnNpcInternal(tile);
delete tile->spawnNpc;
}
tile->spawnNpc = spawn_npc_iter->second;
map.addSpawnNpc(tile);
}
g_gui.DestroyLoadBar();
map.setWidth(newsize_x);
map.setHeight(newsize_y);
2016-11-05 15:28:14 +01:00
g_gui.PopupDialog("Success", "Map imported successfully, " + i2ws(discarded_tiles) + " tiles were discarded as invalid.", wxOK);
2016-09-29 19:24:45 -03:00
g_gui.RefreshPalettes();
g_gui.FitViewToMap();
return true;
}
2023-10-09 19:12:16 -07:00
void Editor::borderizeSelection() {
if (selection.empty()) {
2016-11-05 15:28:14 +01:00
g_gui.SetStatusText("No items selected. Can't borderize.");
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return;
}
Action* action = actionQueue->createAction(ACTION_BORDERIZE);
2023-10-09 19:12:16 -07:00
for (const Tile* tile : selection) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
Tile* new_tile = tile->deepCopy(map);
new_tile->borderize(&map);
new_tile->select();
action->addChange(new Change(new_tile));
}
addAction(action);
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
updateActions();
}
2023-10-09 19:12:16 -07:00
void Editor::borderizeMap(bool showdialog) {
if (showdialog) {
2016-11-05 15:28:14 +01:00
g_gui.CreateLoadBar("Borderizing map...");
}
uint64_t tiles_done = 0;
2023-10-09 19:12:16 -07:00
for (TileLocation* tileLocation : map) {
if (showdialog && tiles_done % 4096 == 0) {
g_gui.SetLoadDone(static_cast<int32_t>(tiles_done / double(map.tilecount) * 100.0));
}
2014-03-02 22:08:22 +01:00
Tile* tile = tileLocation->get();
ASSERT(tile);
2014-03-02 22:08:22 +01:00
tile->borderize(&map);
2014-03-02 22:08:22 +01:00
++tiles_done;
}
2023-10-09 19:12:16 -07:00
if (showdialog) {
g_gui.DestroyLoadBar();
}
}
2023-10-09 19:12:16 -07:00
void Editor::randomizeSelection() {
if (selection.empty()) {
2016-11-05 15:28:14 +01:00
g_gui.SetStatusText("No items selected. Can't randomize.");
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return;
}
Action* action = actionQueue->createAction(ACTION_RANDOMIZE);
2023-10-09 19:12:16 -07:00
for (const Tile* tile : selection) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
Tile* new_tile = tile->deepCopy(map);
GroundBrush* brush = new_tile->getGroundBrush();
2023-10-09 19:12:16 -07:00
if (brush && brush->isReRandomizable()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
brush->draw(&map, new_tile, nullptr);
Item* old_ground = tile->ground;
Item* new_ground = new_tile->ground;
2023-10-09 19:12:16 -07:00
if (old_ground && new_ground) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
new_ground->setActionID(old_ground->getActionID());
new_ground->setUniqueID(old_ground->getUniqueID());
}
2014-03-02 22:08:22 +01:00
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
new_tile->select();
action->addChange(new Change(new_tile));
}
}
addAction(action);
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
updateActions();
}
2023-10-09 19:12:16 -07:00
void Editor::randomizeMap(bool showdialog) {
if (showdialog) {
2016-11-05 15:28:14 +01:00
g_gui.CreateLoadBar("Randomizing map...");
}
uint64_t tiles_done = 0;
2023-10-09 19:12:16 -07:00
for (TileLocation* tileLocation : map) {
if (showdialog && tiles_done % 4096 == 0) {
g_gui.SetLoadDone(static_cast<int32_t>(tiles_done / double(map.tilecount) * 100.0));
}
2014-03-02 22:08:22 +01:00
Tile* tile = tileLocation->get();
ASSERT(tile);
2014-03-02 22:08:22 +01:00
GroundBrush* groundBrush = tile->getGroundBrush();
2023-10-09 19:12:16 -07:00
if (groundBrush) {
2014-03-02 22:08:22 +01:00
Item* oldGround = tile->ground;
uint16_t actionId, uniqueId;
2023-10-09 19:12:16 -07:00
if (oldGround) {
2014-03-02 22:08:22 +01:00
actionId = oldGround->getActionID();
uniqueId = oldGround->getUniqueID();
} else {
actionId = 0;
uniqueId = 0;
}
groundBrush->draw(&map, tile, nullptr);
Item* newGround = tile->ground;
2023-10-09 19:12:16 -07:00
if (newGround) {
2014-03-02 22:08:22 +01:00
newGround->setActionID(actionId);
newGround->setUniqueID(uniqueId);
}
tile->update();
}
2014-03-02 22:08:22 +01:00
++tiles_done;
}
2023-10-09 19:12:16 -07:00
if (showdialog) {
g_gui.DestroyLoadBar();
}
}
2023-10-09 19:12:16 -07:00
void Editor::clearInvalidHouseTiles(bool showdialog) {
if (showdialog) {
2016-11-05 15:28:14 +01:00
g_gui.CreateLoadBar("Clearing invalid house tiles...");
}
2023-10-09 19:12:16 -07:00
Houses &houses = map.houses;
HouseMap::iterator iter = houses.begin();
2023-10-09 19:12:16 -07:00
while (iter != houses.end()) {
House* h = iter->second;
2023-10-09 19:12:16 -07:00
if (map.towns.getTown(h->townid) == nullptr) {
#ifdef __VISUALC__ // C++0x compliance to some degree :)
iter = houses.erase(iter);
#else // Bulky, slow way
HouseMap::iterator tmp_iter = iter;
++tmp_iter;
uint32_t next_key = 0;
2023-10-09 19:12:16 -07:00
if (tmp_iter != houses.end()) {
next_key = tmp_iter->first;
}
houses.erase(iter);
2023-10-09 19:12:16 -07:00
if (next_key != 0) {
iter = houses.find(next_key);
} else {
iter = houses.end();
}
#endif
} else {
++iter;
}
}
uint64_t tiles_done = 0;
2023-10-09 19:12:16 -07:00
for (MapIterator map_iter = map.begin(); map_iter != map.end(); ++map_iter) {
if (showdialog && tiles_done % 4096 == 0) {
g_gui.SetLoadDone(int(tiles_done / double(map.tilecount) * 100.0));
}
Tile* tile = (*map_iter)->get();
ASSERT(tile);
2023-10-09 19:12:16 -07:00
if (tile->isHouseTile()) {
if (houses.getHouse(tile->getHouseID()) == nullptr) {
tile->setHouse(nullptr);
}
}
++tiles_done;
}
2023-10-09 19:12:16 -07:00
if (showdialog) {
g_gui.DestroyLoadBar();
}
}
2023-10-09 19:12:16 -07:00
void Editor::clearModifiedTileState(bool showdialog) {
if (showdialog) {
2016-11-05 15:28:14 +01:00
g_gui.CreateLoadBar("Clearing modified state from all tiles...");
}
2016-09-29 19:24:45 -03:00
uint64_t tiles_done = 0;
2023-10-09 19:12:16 -07:00
for (MapIterator map_iter = map.begin(); map_iter != map.end(); ++map_iter) {
if (showdialog && tiles_done % 4096 == 0) {
g_gui.SetLoadDone(int(tiles_done / double(map.tilecount) * 100.0));
}
Tile* tile = (*map_iter)->get();
ASSERT(tile);
tile->unmodify();
++tiles_done;
}
2023-10-09 19:12:16 -07:00
if (showdialog) {
g_gui.DestroyLoadBar();
}
}
2023-10-09 19:12:16 -07:00
void Editor::moveSelection(const Position &offset) {
if (!CanEdit() || !hasSelection()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return;
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
bool borderize = false;
int drag_threshold = g_settings.getInteger(Config::BORDERIZE_DRAG_THRESHOLD);
bool create_borders = g_settings.getInteger(Config::USE_AUTOMAGIC)
&& g_settings.getInteger(Config::BORDERIZE_DRAG);
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
TileSet storage;
BatchAction* batch_action = actionQueue->createBatch(ACTION_MOVE);
Action* action = actionQueue->createAction(batch_action);
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
// Update the tiles with the new positions
2023-10-09 19:12:16 -07:00
for (Tile* tile : selection) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
Tile* new_tile = tile->deepCopy(map);
Tile* storage_tile = map.allocator(tile->getLocation());
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
ItemVector selected_items = new_tile->popSelectedItems();
2023-10-09 19:12:16 -07:00
for (Item* item : selected_items) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
storage_tile->addItem(item);
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
// Move monster spawns
2023-10-09 19:12:16 -07:00
if (new_tile->spawnMonster && new_tile->spawnMonster->isSelected()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
storage_tile->spawnMonster = new_tile->spawnMonster;
new_tile->spawnMonster = nullptr;
}
// Move monster
2023-10-09 19:12:16 -07:00
if (new_tile->monster && new_tile->monster->isSelected()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
storage_tile->monster = new_tile->monster;
new_tile->monster = nullptr;
}
// Move npc
2023-10-09 19:12:16 -07:00
if (new_tile->npc && new_tile->npc->isSelected()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
storage_tile->npc = new_tile->npc;
new_tile->npc = nullptr;
}
// Move npc spawns
2023-10-09 19:12:16 -07:00
if (new_tile->spawnNpc && new_tile->spawnNpc->isSelected()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
storage_tile->spawnNpc = new_tile->spawnNpc;
new_tile->spawnNpc = nullptr;
}
2023-10-09 19:12:16 -07:00
if (storage_tile->ground) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
storage_tile->house_id = new_tile->house_id;
new_tile->house_id = 0;
storage_tile->setMapFlags(new_tile->getMapFlags());
new_tile->setMapFlags(TILESTATE_NONE);
borderize = true;
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
storage.insert(storage_tile);
action->addChange(new Change(new_tile));
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
batch_action->addAndCommitAction(action);
// Remove old borders (and create some new?)
2023-10-09 19:12:16 -07:00
if (create_borders && selection.size() < static_cast<size_t>(drag_threshold)) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
action = actionQueue->createAction(batch_action);
TileList borderize_tiles;
// Go through all modified (selected) tiles (might be slow)
2023-10-09 19:12:16 -07:00
for (const Tile* tile : storage) {
const Position &pos = tile->getPosition();
// Go through all neighbours
Tile* t;
2023-10-09 19:12:16 -07:00
t = map.getTile(pos.x, pos.y, pos.z);
if (t && !t->isSelected()) {
borderize_tiles.push_back(t);
}
t = map.getTile(pos.x - 1, pos.y - 1, pos.z);
if (t && !t->isSelected()) {
borderize_tiles.push_back(t);
}
t = map.getTile(pos.x, pos.y - 1, pos.z);
if (t && !t->isSelected()) {
borderize_tiles.push_back(t);
}
t = map.getTile(pos.x + 1, pos.y - 1, pos.z);
if (t && !t->isSelected()) {
borderize_tiles.push_back(t);
}
t = map.getTile(pos.x - 1, pos.y, pos.z);
if (t && !t->isSelected()) {
borderize_tiles.push_back(t);
}
t = map.getTile(pos.x + 1, pos.y, pos.z);
if (t && !t->isSelected()) {
borderize_tiles.push_back(t);
}
t = map.getTile(pos.x - 1, pos.y + 1, pos.z);
if (t && !t->isSelected()) {
borderize_tiles.push_back(t);
}
t = map.getTile(pos.x, pos.y + 1, pos.z);
if (t && !t->isSelected()) {
borderize_tiles.push_back(t);
}
t = map.getTile(pos.x + 1, pos.y + 1, pos.z);
if (t && !t->isSelected()) {
borderize_tiles.push_back(t);
}
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
// Remove duplicates
borderize_tiles.sort();
borderize_tiles.unique();
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
// Create borders
2023-10-09 19:12:16 -07:00
for (const Tile* tile : borderize_tiles) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
Tile* new_tile = tile->deepCopy(map);
2023-10-09 19:12:16 -07:00
if (borderize) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
new_tile->borderize(&map);
}
new_tile->wallize(&map);
new_tile->tableize(&map);
new_tile->carpetize(&map);
2023-10-09 19:12:16 -07:00
if (tile->ground && tile->ground->isSelected()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
new_tile->selectGround();
}
action->addChange(new Change(new_tile));
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
batch_action->addAndCommitAction(action);
}
// New action for adding the destination tiles
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
action = actionQueue->createAction(batch_action);
2023-10-09 19:12:16 -07:00
for (Tile* tile : storage) {
const Position &old_pos = tile->getPosition();
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
Position new_pos = old_pos - offset;
2023-10-09 19:12:16 -07:00
if (new_pos.z < rme::MapMinLayer && new_pos.z > rme::MapMaxLayer) {
delete tile;
continue;
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
TileLocation* location = map.createTileL(new_pos);
Tile* old_dest_tile = location->get();
Tile* new_dest_tile = nullptr;
2023-10-09 19:12:16 -07:00
if (!tile->ground || g_settings.getInteger(Config::MERGE_MOVE)) {
// Move items
2023-10-09 19:12:16 -07:00
if (old_dest_tile) {
new_dest_tile = old_dest_tile->deepCopy(map);
} else {
new_dest_tile = map.allocator(location);
}
new_dest_tile->merge(tile);
delete tile;
} else {
// Replace tile instead of just merge
tile->setLocation(location);
new_dest_tile = tile;
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
action->addChange(new Change(new_dest_tile));
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
batch_action->addAndCommitAction(action);
2023-10-09 19:12:16 -07:00
if (create_borders && selection.size() < static_cast<size_t>(drag_threshold)) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
action = actionQueue->createAction(batch_action);
TileList borderize_tiles;
// Go through all modified (selected) tiles (might be slow)
2023-10-09 19:12:16 -07:00
for (Tile* tile : selection) {
bool add_me = false; // If this tile is touched
2023-10-09 19:12:16 -07:00
const Position &pos = tile->getPosition();
// Go through all neighbours
Tile* t;
2023-10-09 19:12:16 -07:00
t = map.getTile(pos.x - 1, pos.y - 1, pos.z);
if (t && !t->isSelected()) {
borderize_tiles.push_back(t);
add_me = true;
}
t = map.getTile(pos.x - 1, pos.y - 1, pos.z);
if (t && !t->isSelected()) {
borderize_tiles.push_back(t);
add_me = true;
}
t = map.getTile(pos.x, pos.y - 1, pos.z);
if (t && !t->isSelected()) {
borderize_tiles.push_back(t);
add_me = true;
}
t = map.getTile(pos.x + 1, pos.y - 1, pos.z);
if (t && !t->isSelected()) {
borderize_tiles.push_back(t);
add_me = true;
}
t = map.getTile(pos.x - 1, pos.y, pos.z);
if (t && !t->isSelected()) {
borderize_tiles.push_back(t);
add_me = true;
}
t = map.getTile(pos.x + 1, pos.y, pos.z);
if (t && !t->isSelected()) {
borderize_tiles.push_back(t);
add_me = true;
}
t = map.getTile(pos.x - 1, pos.y + 1, pos.z);
if (t && !t->isSelected()) {
borderize_tiles.push_back(t);
add_me = true;
}
t = map.getTile(pos.x, pos.y + 1, pos.z);
if (t && !t->isSelected()) {
borderize_tiles.push_back(t);
add_me = true;
}
t = map.getTile(pos.x + 1, pos.y + 1, pos.z);
if (t && !t->isSelected()) {
borderize_tiles.push_back(t);
add_me = true;
}
if (add_me) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
borderize_tiles.push_back(tile);
}
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
// Remove duplicates
borderize_tiles.sort();
borderize_tiles.unique();
2016-09-29 19:24:45 -03:00
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
// Create borders
2023-10-09 19:12:16 -07:00
for (const Tile* tile : borderize_tiles) {
if (!tile || !tile->ground) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
continue;
}
2023-10-09 19:12:16 -07:00
if (tile->ground->getGroundBrush()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
Tile* new_tile = tile->deepCopy(map);
2023-10-09 19:12:16 -07:00
if (borderize) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
new_tile->borderize(&map);
}
new_tile->wallize(&map);
new_tile->tableize(&map);
new_tile->carpetize(&map);
2023-10-09 19:12:16 -07:00
if (tile->ground->isSelected()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
new_tile->selectGround();
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
action->addChange(new Change(new_tile));
}
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
batch_action->addAndCommitAction(action);
}
// Store the action for undo
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
addBatch(batch_action);
updateActions();
selection.updateSelectionCount();
}
2023-10-09 19:12:16 -07:00
void Editor::destroySelection() {
if (selection.size() == 0) {
2016-11-05 15:28:14 +01:00
g_gui.SetStatusText("No selected items to delete.");
} else {
int tile_count = 0;
int item_count = 0;
PositionList tilestoborder;
BatchAction* batch = actionQueue->createBatch(ACTION_DELETE_TILES);
Action* action = actionQueue->createAction(batch);
2023-10-09 19:12:16 -07:00
for (TileSet::iterator it = selection.begin(); it != selection.end(); ++it) {
tile_count++;
Tile* tile = *it;
Tile* newtile = tile->deepCopy(map);
ItemVector tile_selection = newtile->popSelectedItems();
2023-10-09 19:12:16 -07:00
for (ItemVector::iterator iit = tile_selection.begin(); iit != tile_selection.end(); ++iit) {
++item_count;
// Delete the items from the tile
delete *iit;
}
// Monster
2023-10-09 19:12:16 -07:00
if (newtile->monster && newtile->monster->isSelected()) {
delete newtile->monster;
newtile->monster = nullptr;
}
2023-10-09 19:12:16 -07:00
if (newtile->spawnMonster && newtile->spawnMonster->isSelected()) {
delete newtile->spawnMonster;
newtile->spawnMonster = nullptr;
}
// Npc
2023-10-09 19:12:16 -07:00
if (newtile->npc && newtile->npc->isSelected()) {
delete newtile->npc;
newtile->npc = nullptr;
}
2023-10-09 19:12:16 -07:00
if (newtile->spawnNpc && newtile->spawnNpc->isSelected()) {
delete newtile->spawnNpc;
newtile->spawnNpc = nullptr;
}
2023-10-09 19:12:16 -07:00
if (g_settings.getInteger(Config::USE_AUTOMAGIC)) {
for (int y = -1; y <= 1; y++) {
for (int x = -1; x <= 1; x++) {
const Position &position = tile->getPosition();
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
tilestoborder.push_back(Position(position.x + x, position.y + y, position.z));
}
}
}
action->addChange(newd Change(newtile));
}
batch->addAndCommitAction(action);
2023-10-09 19:12:16 -07:00
if (g_settings.getInteger(Config::USE_AUTOMAGIC)) {
// Remove duplicates
tilestoborder.sort();
tilestoborder.unique();
action = actionQueue->createAction(batch);
2023-10-09 19:12:16 -07:00
for (PositionList::iterator it = tilestoborder.begin(); it != tilestoborder.end(); ++it) {
TileLocation* location = map.createTileL(*it);
Tile* tile = location->get();
2023-10-09 19:12:16 -07:00
if (tile) {
Tile* new_tile = tile->deepCopy(map);
new_tile->borderize(&map);
new_tile->wallize(&map);
new_tile->tableize(&map);
new_tile->carpetize(&map);
action->addChange(newd Change(new_tile));
} else {
Tile* new_tile = map.allocator(location);
new_tile->borderize(&map);
2023-10-09 19:12:16 -07:00
if (new_tile->size()) {
action->addChange(newd Change(new_tile));
} else {
delete new_tile;
}
}
}
batch->addAndCommitAction(action);
}
addBatch(batch);
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
updateActions();
wxString ss;
2023-10-09 19:12:16 -07:00
ss << "Deleted " << tile_count << " tile" << (tile_count > 1 ? "s" : "") << " (" << item_count << " item" << (item_count > 1 ? "s" : "") << ")";
g_gui.SetStatusText(ss);
}
}
2023-10-09 19:12:16 -07:00
// Macro to avoid useless code repetition
void doSurroundingBorders(DoodadBrush* doodad_brush, PositionList &tilestoborder, Tile* buffer_tile, Tile* new_tile) {
if (doodad_brush->doNewBorders() && g_settings.getInteger(Config::USE_AUTOMAGIC)) {
const Position &position = new_tile->getPosition();
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
tilestoborder.push_back(Position(position));
2023-10-09 19:12:16 -07:00
if (buffer_tile->hasGround()) {
for (int y = -1; y <= 1; y++) {
for (int x = -1; x <= 1; x++) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
tilestoborder.push_back(Position(position.x + x, position.y + y, position.z));
}
}
2023-10-09 19:12:16 -07:00
} else if (buffer_tile->hasWall()) {
tilestoborder.push_back(Position(position.x, position.y - 1, position.z));
tilestoborder.push_back(Position(position.x - 1, position.y, position.z));
tilestoborder.push_back(Position(position.x + 1, position.y, position.z));
tilestoborder.push_back(Position(position.x, position.y + 1, position.z));
}
}
}
2023-10-09 19:12:16 -07:00
void removeDuplicateWalls(Tile* buffer, Tile* tile) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
if (!buffer || buffer->items.empty() || !tile || tile->items.empty()) {
return;
}
2023-10-09 19:12:16 -07:00
for (const Item* item : buffer->items) {
if (item) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
WallBrush* brush = item->getWallBrush();
2023-10-09 19:12:16 -07:00
if (brush) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
tile->cleanWalls(brush);
}
}
}
}
2023-10-09 19:12:16 -07:00
void Editor::drawInternal(Position offset, bool alt, bool dodraw) {
if (!CanEdit()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return;
}
Brush* brush = g_gui.GetCurrentBrush();
2023-10-09 19:12:16 -07:00
if (!brush) {
2016-11-12 10:30:06 -03:00
return;
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
}
2023-10-09 19:12:16 -07:00
if (brush->isDoodad()) {
2016-11-12 10:30:06 -03:00
BatchAction* batch = actionQueue->createBatch(ACTION_DRAW);
Action* action = actionQueue->createAction(batch);
2024-06-17 00:17:16 -03:00
BaseMap* buffer_map = g_gui.doodadBufferMap;
Position delta_pos = offset - Position(0x8000, 0x8000, 0x8);
PositionList tilestoborder;
2023-10-09 19:12:16 -07:00
for (MapIterator it = buffer_map->begin(); it != buffer_map->end(); ++it) {
2016-11-12 10:30:06 -03:00
Tile* buffer_tile = (*it)->get();
Position pos = buffer_tile->getPosition() + delta_pos;
2023-10-09 19:12:16 -07:00
if (!pos.isValid()) {
continue;
}
2016-09-29 19:24:45 -03:00
TileLocation* location = map.createTileL(pos);
Tile* tile = location->get();
2016-11-12 10:30:06 -03:00
DoodadBrush* doodad_brush = brush->asDoodad();
2023-10-09 19:12:16 -07:00
if (doodad_brush->placeOnBlocking() || alt) {
if (tile) {
bool place = true;
2023-10-09 19:12:16 -07:00
if (!doodad_brush->placeOnDuplicate() && !alt) {
for (ItemVector::const_iterator iter = tile->items.begin(); iter != tile->items.end(); ++iter) {
if (doodad_brush->ownsItem(*iter)) {
place = false;
break;
}
}
}
2023-10-09 19:12:16 -07:00
if (place) {
Tile* new_tile = tile->deepCopy(map);
removeDuplicateWalls(buffer_tile, new_tile);
doSurroundingBorders(doodad_brush, tilestoborder, buffer_tile, new_tile);
new_tile->merge(buffer_tile);
action->addChange(newd Change(new_tile));
}
} else {
Tile* new_tile = map.allocator(location);
removeDuplicateWalls(buffer_tile, new_tile);
doSurroundingBorders(doodad_brush, tilestoborder, buffer_tile, new_tile);
new_tile->merge(buffer_tile);
action->addChange(newd Change(new_tile));
}
} else {
2023-10-09 19:12:16 -07:00
if (tile && !tile->isBlocking()) {
bool place = true;
2023-10-09 19:12:16 -07:00
if (!doodad_brush->placeOnDuplicate() && !alt) {
for (ItemVector::const_iterator iter = tile->items.begin(); iter != tile->items.end(); ++iter) {
if (doodad_brush->ownsItem(*iter)) {
place = false;
break;
}
}
}
2023-10-09 19:12:16 -07:00
if (place) {
Tile* new_tile = tile->deepCopy(map);
removeDuplicateWalls(buffer_tile, new_tile);
doSurroundingBorders(doodad_brush, tilestoborder, buffer_tile, new_tile);
new_tile->merge(buffer_tile);
action->addChange(newd Change(new_tile));
}
}
}
}
batch->addAndCommitAction(action);
2023-10-09 19:12:16 -07:00
if (tilestoborder.size() > 0) {
Action* action = actionQueue->createAction(batch);
// Remove duplicates
tilestoborder.sort();
tilestoborder.unique();
2023-10-09 19:12:16 -07:00
for (PositionList::const_iterator it = tilestoborder.begin(); it != tilestoborder.end(); ++it) {
2016-11-12 10:30:06 -03:00
Tile* tile = map.getTile(*it);
2023-10-09 19:12:16 -07:00
if (tile) {
2016-11-12 10:30:06 -03:00
Tile* new_tile = tile->deepCopy(map);
new_tile->borderize(&map);
new_tile->wallize(&map);
action->addChange(newd Change(new_tile));
}
}
batch->addAndCommitAction(action);
}
2016-11-12 10:30:06 -03:00
addBatch(batch, 2);
2023-10-09 19:12:16 -07:00
} else if (brush->isHouseExit()) {
2016-11-12 10:30:06 -03:00
HouseExitBrush* house_exit_brush = brush->asHouseExit();
2023-10-09 19:12:16 -07:00
if (!house_exit_brush->canDraw(&map, offset)) {
2016-11-12 10:30:06 -03:00
return;
2023-10-09 19:12:16 -07:00
}
2016-11-12 10:30:06 -03:00
House* house = map.houses.getHouse(house_exit_brush->getHouseID());
2023-10-09 19:12:16 -07:00
if (!house) {
return;
2023-10-09 19:12:16 -07:00
}
2016-11-12 10:30:06 -03:00
BatchAction* batch = actionQueue->createBatch(ACTION_DRAW);
Action* action = actionQueue->createAction(batch);
2016-11-12 10:30:06 -03:00
action->addChange(Change::Create(house, offset));
batch->addAndCommitAction(action);
addBatch(batch, 2);
2023-10-09 19:12:16 -07:00
} else if (brush->isWaypoint()) {
2016-11-12 10:30:06 -03:00
WaypointBrush* waypoint_brush = brush->asWaypoint();
2023-10-09 19:12:16 -07:00
if (!waypoint_brush->canDraw(&map, offset)) {
return;
2023-10-09 19:12:16 -07:00
}
2016-11-12 10:30:06 -03:00
Waypoint* waypoint = map.waypoints.getWaypoint(waypoint_brush->getWaypoint());
2023-10-09 19:12:16 -07:00
if (!waypoint || waypoint->pos == offset) {
2016-11-12 10:30:06 -03:00
return;
2023-10-09 19:12:16 -07:00
}
2016-11-12 10:30:06 -03:00
BatchAction* batch = actionQueue->createBatch(ACTION_DRAW);
Action* action = actionQueue->createAction(batch);
action->addChange(Change::Create(waypoint, offset));
batch->addAndCommitAction(action);
2016-11-12 10:30:06 -03:00
addBatch(batch, 2);
2023-10-09 19:12:16 -07:00
} else if (brush->isWall()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
BatchAction* batch = actionQueue->createBatch(dodraw ? ACTION_DRAW : ACTION_ERASE);
Action* action = actionQueue->createAction(batch);
// This will only occur with a size 0, when clicking on a tile (not drawing)
2016-11-12 10:30:06 -03:00
Tile* tile = map.getTile(offset);
Tile* new_tile = nullptr;
2023-10-09 19:12:16 -07:00
if (tile) {
2016-11-12 10:30:06 -03:00
new_tile = tile->deepCopy(map);
} else {
new_tile = map.allocator(map.createTileL(offset));
}
2016-11-12 10:30:06 -03:00
2023-10-09 19:12:16 -07:00
if (dodraw) {
bool b = true;
2016-11-12 10:30:06 -03:00
brush->asWall()->draw(&map, new_tile, &b);
} else {
2016-11-12 10:30:06 -03:00
brush->asWall()->undraw(&map, new_tile);
}
action->addChange(newd Change(new_tile));
batch->addAndCommitAction(action);
2016-11-12 10:30:06 -03:00
addBatch(batch, 2);
2023-10-09 19:12:16 -07:00
} else if (brush->isSpawnMonster() || brush->isMonster()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
BatchAction* batch = actionQueue->createBatch(dodraw ? ACTION_DRAW : ACTION_ERASE);
Action* action = actionQueue->createAction(batch);
Tile* tile = map.getTile(offset);
Tile* new_tile = nullptr;
2023-10-09 19:12:16 -07:00
if (tile) {
new_tile = tile->deepCopy(map);
} else {
new_tile = map.allocator(map.createTileL(offset));
}
int param;
2023-10-09 19:12:16 -07:00
if (brush->isMonster()) {
param = g_gui.GetSpawnMonsterTime();
} else {
param = g_gui.GetBrushSize();
}
2023-10-09 19:12:16 -07:00
if (dodraw) {
brush->draw(&map, new_tile, &param);
} else {
brush->undraw(&map, new_tile);
}
action->addChange(newd Change(new_tile));
batch->addAndCommitAction(action);
addBatch(batch, 2);
2023-10-09 19:12:16 -07:00
} else if (brush->isSpawnNpc() || brush->isNpc()) {
2016-11-12 10:30:06 -03:00
BatchAction* batch = actionQueue->createBatch(ACTION_DRAW);
Action* action = actionQueue->createAction(batch);
2016-11-12 10:30:06 -03:00
Tile* tile = map.getTile(offset);
Tile* new_tile = nullptr;
2023-10-09 19:12:16 -07:00
if (tile) {
2016-11-12 10:30:06 -03:00
new_tile = tile->deepCopy(map);
} else {
new_tile = map.allocator(map.createTileL(offset));
}
int param;
2023-10-09 19:12:16 -07:00
if (brush->isNpc()) {
param = g_gui.GetSpawnNpcTime();
} else {
param = g_gui.GetBrushSize();
}
2023-10-09 19:12:16 -07:00
if (dodraw) {
brush->draw(&map, new_tile, &param);
} else {
brush->undraw(&map, new_tile);
}
action->addChange(newd Change(new_tile));
batch->addAndCommitAction(action);
2016-11-12 10:30:06 -03:00
addBatch(batch, 2);
}
}
2023-10-09 19:12:16 -07:00
void Editor::drawInternal(const PositionVector &tilestodraw, bool alt, bool dodraw) {
if (!CanEdit()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return;
}
Brush* brush = g_gui.GetCurrentBrush();
2023-10-09 19:12:16 -07:00
if (!brush) {
2016-11-12 10:30:06 -03:00
return;
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
}
2016-11-12 10:30:06 -03:00
#ifdef __DEBUG__
2023-10-09 19:12:16 -07:00
if (brush->isGround() || brush->isWall()) {
// Wrong function, end call
return;
}
#endif
2016-11-12 10:30:06 -03:00
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
Action* action = actionQueue->createAction(dodraw ? ACTION_DRAW : ACTION_ERASE);
2023-10-09 19:12:16 -07:00
if (brush->isOptionalBorder()) {
// We actually need to do borders, but on the same tiles we draw to
2023-10-09 19:12:16 -07:00
for (PositionVector::const_iterator it = tilestodraw.begin(); it != tilestodraw.end(); ++it) {
2016-11-12 10:30:06 -03:00
TileLocation* location = map.createTileL(*it);
Tile* tile = location->get();
2023-10-09 19:12:16 -07:00
if (tile) {
if (dodraw) {
Tile* new_tile = tile->deepCopy(map);
brush->draw(&map, new_tile);
new_tile->borderize(&map);
action->addChange(newd Change(new_tile));
2023-10-09 19:12:16 -07:00
} else if (!dodraw && tile->hasOptionalBorder()) {
Tile* new_tile = tile->deepCopy(map);
brush->undraw(&map, new_tile);
new_tile->borderize(&map);
action->addChange(newd Change(new_tile));
}
2023-10-09 19:12:16 -07:00
} else if (dodraw) {
Tile* new_tile = map.allocator(location);
brush->draw(&map, new_tile);
new_tile->borderize(&map);
2023-10-09 19:12:16 -07:00
if (new_tile->size() == 0) {
delete new_tile;
continue;
}
action->addChange(newd Change(new_tile));
}
}
} else {
2020-07-30 11:42:28 -03:00
2023-10-09 19:12:16 -07:00
for (PositionVector::const_iterator it = tilestodraw.begin(); it != tilestodraw.end(); ++it) {
2016-11-12 10:30:06 -03:00
TileLocation* location = map.createTileL(*it);
Tile* tile = location->get();
2023-10-09 19:12:16 -07:00
if (tile) {
Tile* new_tile = tile->deepCopy(map);
2023-10-09 19:12:16 -07:00
if (dodraw) {
brush->draw(&map, new_tile, &alt);
} else {
brush->undraw(&map, new_tile);
}
action->addChange(newd Change(new_tile));
2023-10-09 19:12:16 -07:00
} else if (dodraw) {
Tile* new_tile = map.allocator(location);
brush->draw(&map, new_tile, &alt);
action->addChange(newd Change(new_tile));
}
}
}
addAction(action, 2);
}
2023-10-09 19:12:16 -07:00
void Editor::drawInternal(const PositionVector &tilestodraw, PositionVector &tilestoborder, bool alt, bool dodraw) {
if (!CanEdit()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return;
}
Brush* brush = g_gui.GetCurrentBrush();
2023-10-09 19:12:16 -07:00
if (!brush) {
2016-11-12 10:30:06 -03:00
return;
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
}
2016-11-12 10:30:06 -03:00
2023-10-09 19:12:16 -07:00
if (brush->isGround() || brush->isEraser()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
ActionIdentifier identifier = (dodraw && !brush->isEraser()) ? ACTION_DRAW : ACTION_ERASE;
BatchAction* batch = actionQueue->createBatch(identifier);
Action* action = actionQueue->createAction(batch);
2023-10-09 19:12:16 -07:00
for (PositionVector::const_iterator it = tilestodraw.begin(); it != tilestodraw.end(); ++it) {
2016-11-12 10:30:06 -03:00
TileLocation* location = map.createTileL(*it);
Tile* tile = location->get();
2023-10-09 19:12:16 -07:00
if (tile) {
Tile* new_tile = tile->deepCopy(map);
2023-10-09 19:12:16 -07:00
if (g_settings.getInteger(Config::USE_AUTOMAGIC)) {
new_tile->cleanBorders();
}
2023-10-09 19:12:16 -07:00
if (dodraw) {
if (brush->isGround() && alt) {
std::pair<bool, GroundBrush*> param;
2023-10-09 19:12:16 -07:00
if (replace_brush) {
param.first = false;
param.second = replace_brush;
} else {
param.first = true;
param.second = nullptr;
}
g_gui.GetCurrentBrush()->draw(&map, new_tile, &param);
} else {
g_gui.GetCurrentBrush()->draw(&map, new_tile, nullptr);
}
2023-10-09 19:12:16 -07:00
} else {
g_gui.GetCurrentBrush()->undraw(&map, new_tile);
2016-11-12 10:30:06 -03:00
tilestoborder.push_back(*it);
}
action->addChange(newd Change(new_tile));
2023-10-09 19:12:16 -07:00
} else if (dodraw) {
Tile* new_tile = map.allocator(location);
2023-10-09 19:12:16 -07:00
if (brush->isGround() && alt) {
std::pair<bool, GroundBrush*> param;
2023-10-09 19:12:16 -07:00
if (replace_brush) {
param.first = false;
param.second = replace_brush;
} else {
param.first = true;
param.second = nullptr;
}
g_gui.GetCurrentBrush()->draw(&map, new_tile, &param);
} else {
g_gui.GetCurrentBrush()->draw(&map, new_tile, nullptr);
}
action->addChange(newd Change(new_tile));
}
}
// Commit changes to map
batch->addAndCommitAction(action);
2023-10-09 19:12:16 -07:00
if (g_settings.getInteger(Config::USE_AUTOMAGIC)) {
// Do borders!
action = actionQueue->createAction(batch);
2023-10-09 19:12:16 -07:00
for (PositionVector::const_iterator it = tilestoborder.begin(); it != tilestoborder.end(); ++it) {
2016-11-12 10:30:06 -03:00
TileLocation* location = map.createTileL(*it);
Tile* tile = location->get();
2023-10-09 19:12:16 -07:00
if (tile) {
Tile* new_tile = tile->deepCopy(map);
2023-10-09 19:12:16 -07:00
if (brush->isEraser()) {
new_tile->wallize(&map);
new_tile->tableize(&map);
new_tile->carpetize(&map);
}
new_tile->borderize(&map);
action->addChange(newd Change(new_tile));
} else {
Tile* new_tile = map.allocator(location);
2023-10-09 19:12:16 -07:00
if (brush->isEraser()) {
// There are no carpets/tables/walls on empty tiles...
2023-10-09 19:12:16 -07:00
// new_tile->wallize(map);
// new_tile->tableize(map);
// new_tile->carpetize(map);
}
new_tile->borderize(&map);
2023-10-09 19:12:16 -07:00
if (new_tile->size() > 0) {
action->addChange(newd Change(new_tile));
} else {
delete new_tile;
}
}
}
batch->addAndCommitAction(action);
}
addBatch(batch, 2);
2023-10-09 19:12:16 -07:00
} else if (brush->isTable() || brush->isCarpet()) {
BatchAction* batch = actionQueue->createBatch(ACTION_DRAW);
Action* action = actionQueue->createAction(batch);
2023-10-09 19:12:16 -07:00
for (PositionVector::const_iterator it = tilestodraw.begin(); it != tilestodraw.end(); ++it) {
2016-11-12 10:30:06 -03:00
TileLocation* location = map.createTileL(*it);
Tile* tile = location->get();
2023-10-09 19:12:16 -07:00
if (tile) {
Tile* new_tile = tile->deepCopy(map);
2023-10-09 19:12:16 -07:00
if (dodraw) {
g_gui.GetCurrentBrush()->draw(&map, new_tile, nullptr);
2023-10-09 19:12:16 -07:00
} else {
g_gui.GetCurrentBrush()->undraw(&map, new_tile);
2023-10-09 19:12:16 -07:00
}
action->addChange(newd Change(new_tile));
2023-10-09 19:12:16 -07:00
} else if (dodraw) {
Tile* new_tile = map.allocator(location);
g_gui.GetCurrentBrush()->draw(&map, new_tile, nullptr);
action->addChange(newd Change(new_tile));
}
}
// Commit changes to map
batch->addAndCommitAction(action);
// Do borders!
action = actionQueue->createAction(batch);
2023-10-09 19:12:16 -07:00
for (PositionVector::const_iterator it = tilestoborder.begin(); it != tilestoborder.end(); ++it) {
2016-11-12 10:30:06 -03:00
Tile* tile = map.getTile(*it);
2023-10-09 19:12:16 -07:00
if (brush->isTable()) {
if (tile && tile->hasTable()) {
Tile* new_tile = tile->deepCopy(map);
new_tile->tableize(&map);
action->addChange(newd Change(new_tile));
}
2023-10-09 19:12:16 -07:00
} else if (brush->isCarpet()) {
if (tile && tile->hasCarpet()) {
Tile* new_tile = tile->deepCopy(map);
new_tile->carpetize(&map);
action->addChange(newd Change(new_tile));
}
}
}
batch->addAndCommitAction(action);
addBatch(batch, 2);
2023-10-09 19:12:16 -07:00
} else if (brush->isWall()) {
BatchAction* batch = actionQueue->createBatch(ACTION_DRAW);
Action* action = actionQueue->createAction(batch);
2023-10-09 19:12:16 -07:00
if (alt && dodraw) {
// This is exempt from USE_AUTOMAGIC
2024-06-17 00:17:16 -03:00
g_gui.doodadBufferMap->clear();
BaseMap* draw_map = g_gui.doodadBufferMap;
2023-10-09 19:12:16 -07:00
for (PositionVector::const_iterator it = tilestodraw.begin(); it != tilestodraw.end(); ++it) {
2016-11-12 10:30:06 -03:00
TileLocation* location = map.createTileL(*it);
Tile* tile = location->get();
2023-10-09 19:12:16 -07:00
if (tile) {
Tile* new_tile = tile->deepCopy(map);
2016-11-12 10:30:06 -03:00
new_tile->cleanWalls(brush->isWall());
g_gui.GetCurrentBrush()->draw(draw_map, new_tile);
2016-11-12 10:30:06 -03:00
draw_map->setTile(*it, new_tile, true);
2023-10-09 19:12:16 -07:00
} else if (dodraw) {
Tile* new_tile = map.allocator(location);
g_gui.GetCurrentBrush()->draw(draw_map, new_tile);
2016-11-12 10:30:06 -03:00
draw_map->setTile(*it, new_tile, true);
}
}
2023-10-09 19:12:16 -07:00
for (PositionVector::const_iterator it = tilestodraw.begin(); it != tilestodraw.end(); ++it) {
// Get the correct tiles from the draw map instead of the editor map
2016-11-12 10:30:06 -03:00
Tile* tile = draw_map->getTile(*it);
2023-10-09 19:12:16 -07:00
if (tile) {
tile->wallize(draw_map);
action->addChange(newd Change(tile));
}
}
draw_map->clear(false);
// Commit
batch->addAndCommitAction(action);
} else {
2023-10-09 19:12:16 -07:00
for (PositionVector::const_iterator it = tilestodraw.begin(); it != tilestodraw.end(); ++it) {
2016-11-12 10:30:06 -03:00
TileLocation* location = map.createTileL(*it);
Tile* tile = location->get();
2023-10-09 19:12:16 -07:00
if (tile) {
Tile* new_tile = tile->deepCopy(map);
// Wall cleaning is exempt from automagic
2016-11-12 10:30:06 -03:00
new_tile->cleanWalls(brush->isWall());
2023-10-09 19:12:16 -07:00
if (dodraw) {
g_gui.GetCurrentBrush()->draw(&map, new_tile);
2023-10-09 19:12:16 -07:00
} else {
g_gui.GetCurrentBrush()->undraw(&map, new_tile);
2023-10-09 19:12:16 -07:00
}
action->addChange(newd Change(new_tile));
2023-10-09 19:12:16 -07:00
} else if (dodraw) {
Tile* new_tile = map.allocator(location);
g_gui.GetCurrentBrush()->draw(&map, new_tile);
action->addChange(newd Change(new_tile));
}
}
// Commit changes to map
batch->addAndCommitAction(action);
2023-10-09 19:12:16 -07:00
if (g_settings.getInteger(Config::USE_AUTOMAGIC)) {
// Do borders!
action = actionQueue->createAction(batch);
2023-10-09 19:12:16 -07:00
for (PositionVector::const_iterator it = tilestoborder.begin(); it != tilestoborder.end(); ++it) {
2016-11-12 10:30:06 -03:00
Tile* tile = map.getTile(*it);
2023-10-09 19:12:16 -07:00
if (tile) {
Tile* new_tile = tile->deepCopy(map);
new_tile->wallize(&map);
2023-10-09 19:12:16 -07:00
// if(*tile == *new_tile) delete new_tile;
action->addChange(newd Change(new_tile));
}
}
batch->addAndCommitAction(action);
}
}
actionQueue->addBatch(batch, 2);
2023-10-09 19:12:16 -07:00
} else if (brush->isDoor()) {
BatchAction* batch = actionQueue->createBatch(ACTION_DRAW);
Action* action = actionQueue->createAction(batch);
2016-11-12 10:30:06 -03:00
DoorBrush* door_brush = brush->asDoor();
// Loop is kind of redundant since there will only ever be one index.
2023-10-09 19:12:16 -07:00
for (PositionVector::const_iterator it = tilestodraw.begin(); it != tilestodraw.end(); ++it) {
2016-11-12 10:30:06 -03:00
TileLocation* location = map.createTileL(*it);
Tile* tile = location->get();
2023-10-09 19:12:16 -07:00
if (tile) {
Tile* new_tile = tile->deepCopy(map);
// Wall cleaning is exempt from automagic
2023-10-09 19:12:16 -07:00
if (brush->isWall()) {
2016-12-02 22:01:48 -03:00
new_tile->cleanWalls(brush->asWall());
2023-10-09 19:12:16 -07:00
}
if (dodraw) {
door_brush->draw(&map, new_tile, &alt);
2023-10-09 19:12:16 -07:00
} else {
door_brush->undraw(&map, new_tile);
2023-10-09 19:12:16 -07:00
}
action->addChange(newd Change(new_tile));
2023-10-09 19:12:16 -07:00
} else if (dodraw) {
Tile* new_tile = map.allocator(location);
door_brush->draw(&map, new_tile, &alt);
action->addChange(newd Change(new_tile));
}
}
// Commit changes to map
batch->addAndCommitAction(action);
2023-10-09 19:12:16 -07:00
if (g_settings.getInteger(Config::USE_AUTOMAGIC)) {
// Do borders!
action = actionQueue->createAction(batch);
2023-10-09 19:12:16 -07:00
for (PositionVector::const_iterator it = tilestoborder.begin(); it != tilestoborder.end(); ++it) {
2016-11-12 10:30:06 -03:00
Tile* tile = map.getTile(*it);
2023-10-09 19:12:16 -07:00
if (tile) {
Tile* new_tile = tile->deepCopy(map);
new_tile->wallize(&map);
2023-10-09 19:12:16 -07:00
// if(*tile == *new_tile) delete new_tile;
action->addChange(newd Change(new_tile));
}
}
batch->addAndCommitAction(action);
}
addBatch(batch, 2);
} else {
Action* action = actionQueue->createAction(ACTION_DRAW);
2023-10-09 19:12:16 -07:00
for (PositionVector::const_iterator it = tilestodraw.begin(); it != tilestodraw.end(); ++it) {
2016-11-12 10:30:06 -03:00
TileLocation* location = map.createTileL(*it);
Tile* tile = location->get();
2023-10-09 19:12:16 -07:00
if (tile) {
Tile* new_tile = tile->deepCopy(map);
2023-10-09 19:12:16 -07:00
if (dodraw) {
g_gui.GetCurrentBrush()->draw(&map, new_tile);
2023-10-09 19:12:16 -07:00
} else {
g_gui.GetCurrentBrush()->undraw(&map, new_tile);
2023-10-09 19:12:16 -07:00
}
action->addChange(newd Change(new_tile));
2023-10-09 19:12:16 -07:00
} else if (dodraw) {
Tile* new_tile = map.allocator(location);
g_gui.GetCurrentBrush()->draw(&map, new_tile);
action->addChange(newd Change(new_tile));
}
}
addAction(action, 2);
}
}
///////////////////////////////////////////////////////////////////////////////
// Live!
2023-10-09 19:12:16 -07:00
bool Editor::IsLiveClient() const {
return live_client != nullptr;
}
2023-10-09 19:12:16 -07:00
bool Editor::IsLiveServer() const {
return live_server != nullptr;
}
2023-10-09 19:12:16 -07:00
bool Editor::IsLive() const {
return IsLiveClient() || IsLiveServer();
}
2023-10-09 19:12:16 -07:00
bool Editor::IsLocal() const {
return !IsLive();
}
2023-10-09 19:12:16 -07:00
LiveClient* Editor::GetLiveClient() const {
return live_client;
}
2023-10-09 19:12:16 -07:00
LiveServer* Editor::GetLiveServer() const {
return live_server;
}
2023-10-09 19:12:16 -07:00
LiveSocket &Editor::GetLive() const {
if (live_server) {
return *live_server;
2023-10-09 19:12:16 -07:00
}
return *live_client;
}
2023-10-09 19:12:16 -07:00
LiveServer* Editor::StartLiveServer() {
2016-09-29 19:24:45 -03:00
ASSERT(IsLocal());
live_server = newd LiveServer(*this);
delete actionQueue;
actionQueue = newd NetworkedActionQueue(*this);
return live_server;
}
2023-10-09 19:12:16 -07:00
void Editor::BroadcastNodes(DirtyList &dirtyList) {
if (IsLiveClient()) {
live_client->sendChanges(dirtyList);
} else {
live_server->broadcastNodes(dirtyList);
}
}
2023-10-09 19:12:16 -07:00
void Editor::CloseLiveServer() {
ASSERT(IsLive());
2023-10-09 19:12:16 -07:00
if (live_client) {
live_client->close();
delete live_client;
live_client = nullptr;
}
2016-09-29 19:24:45 -03:00
2023-10-09 19:12:16 -07:00
if (live_server) {
live_server->close();
delete live_server;
live_server = nullptr;
delete actionQueue;
actionQueue = newd ActionQueue(*this);
}
2023-10-09 19:12:16 -07:00
NetworkConnection &connection = NetworkConnection::getInstance();
connection.stop();
}
2023-10-09 19:12:16 -07:00
void Editor::QueryNode(int ndx, int ndy, bool underground) {
ASSERT(live_client);
live_client->queryNode(ndx, ndy, underground);
}
2023-10-09 19:12:16 -07:00
void Editor::SendNodeRequests() {
if (live_client) {
live_client->sendNodeRequests();
}
}