tibia-rme/source/copybuffer.cpp

370 lines
10 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.
2016-09-29 19:24:45 -03:00
//
2020-07-30 11:42:28 -03:00
// Remere's Map Editor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
2020-07-30 11:42:28 -03:00
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
2016-09-29 19:24:45 -03:00
//
// You should have received a copy of the GNU General Public License
2020-07-30 11:42:28 -03:00
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////////
#include "main.h"
#include "copybuffer.h"
#include "editor.h"
#include "gui.h"
#include "monster.h"
#include "npc.h"
CopyBuffer::CopyBuffer() :
2023-10-09 19:12:16 -07:00
tiles(newd BaseMap()) {
;
}
2023-10-09 19:12:16 -07:00
size_t CopyBuffer::GetTileCount() {
return tiles ? (size_t)tiles->size() : 0;
}
2023-10-09 19:12:16 -07:00
BaseMap &CopyBuffer::getBufferMap() {
ASSERT(tiles);
return *tiles;
}
2023-10-09 19:12:16 -07:00
CopyBuffer::~CopyBuffer() {
clear();
}
2023-10-09 19:12:16 -07:00
Position CopyBuffer::getPosition() const {
ASSERT(tiles);
return copyPos;
}
2023-10-09 19:12:16 -07:00
void CopyBuffer::clear() {
delete tiles;
tiles = nullptr;
}
2023-10-09 19:12:16 -07:00
void CopyBuffer::copy(Editor &editor, int floor) {
if (!editor.hasSelection()) {
2016-11-05 15:28:14 +01:00
g_gui.SetStatusText("No tiles to copy.");
return;
}
clear();
tiles = newd BaseMap();
int tile_count = 0;
int item_count = 0;
copyPos = Position(0xFFFF, 0xFFFF, floor);
2023-10-09 19:12:16 -07:00
for (Tile* tile : editor.getSelection()) {
++tile_count;
TileLocation* newlocation = tiles->createTileL(tile->getPosition());
Tile* copied_tile = tiles->allocator(newlocation);
2023-10-09 19:12:16 -07:00
if (tile->ground && tile->ground->isSelected()) {
copied_tile->house_id = tile->house_id;
copied_tile->setMapFlags(tile->getMapFlags());
}
ItemVector tile_selection = tile->getSelectedItems();
2023-10-09 19:12:16 -07:00
for (ItemVector::iterator iit = tile_selection.begin(); iit != tile_selection.end(); ++iit) {
++item_count;
// Copy items to copybuffer
copied_tile->addItem((*iit)->deepCopy());
}
// Monster
2023-10-09 19:12:16 -07:00
if (tile->monster && tile->monster->isSelected()) {
copied_tile->monster = tile->monster->deepCopy();
}
2023-10-09 19:12:16 -07:00
if (tile->spawnMonster && tile->spawnMonster->isSelected()) {
copied_tile->spawnMonster = tile->spawnMonster->deepCopy();
}
// Npc
2023-10-09 19:12:16 -07:00
if (tile->npc && tile->npc->isSelected()) {
copied_tile->npc = tile->npc->deepCopy();
}
2023-10-09 19:12:16 -07:00
if (tile->spawnNpc && tile->spawnNpc->isSelected()) {
copied_tile->spawnNpc = tile->spawnNpc->deepCopy();
}
tiles->setTile(copied_tile);
2023-10-09 19:12:16 -07:00
if (copied_tile->getX() < copyPos.x) {
copyPos.x = copied_tile->getX();
2023-10-09 19:12:16 -07:00
}
2023-10-09 19:12:16 -07:00
if (copied_tile->getY() < copyPos.y) {
copyPos.y = copied_tile->getY();
2023-10-09 19:12:16 -07:00
}
}
std::ostringstream ss;
2023-10-09 19:12:16 -07:00
ss << "Copied " << tile_count << " tile" << (tile_count > 1 ? "s" : "") << " (" << item_count << " item" << (item_count > 1 ? "s" : "") << ")";
g_gui.SetStatusText(wxstr(ss.str()));
}
2023-10-09 19:12:16 -07:00
void CopyBuffer::cut(Editor &editor, int floor) {
if (!editor.hasSelection()) {
2016-11-05 15:28:14 +01:00
g_gui.SetStatusText("No tiles to cut.");
return;
}
clear();
tiles = newd BaseMap();
2023-10-09 19:12:16 -07:00
Map &map = editor.getMap();
int tile_count = 0;
int item_count = 0;
copyPos = Position(0xFFFF, 0xFFFF, floor);
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 = editor.createBatch(ACTION_CUT_TILES);
Action* action = editor.createAction(batch);
PositionList tilestoborder;
2023-10-09 19:12:16 -07:00
for (Tile* tile : editor.getSelection()) {
tile_count++;
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* newtile = tile->deepCopy(map);
Tile* copied_tile = tiles->allocator(tile->getLocation());
2023-10-09 19:12:16 -07:00
if (tile->ground && tile->ground->isSelected()) {
copied_tile->house_id = newtile->house_id;
newtile->house_id = 0;
copied_tile->setMapFlags(tile->getMapFlags());
newtile->setMapFlags(TILESTATE_NONE);
}
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++;
// Add items to copybuffer
copied_tile->addItem(*iit);
}
// Monster
2023-10-09 19:12:16 -07:00
if (newtile->monster && newtile->monster->isSelected()) {
copied_tile->monster = newtile->monster;
newtile->monster = nullptr;
}
2023-10-09 19:12:16 -07:00
if (newtile->spawnMonster && newtile->spawnMonster->isSelected()) {
copied_tile->spawnMonster = newtile->spawnMonster;
newtile->spawnMonster = nullptr;
}
// Npc
2023-10-09 19:12:16 -07:00
if (newtile->npc && newtile->npc->isSelected()) {
copied_tile->npc = newtile->npc;
newtile->npc = nullptr;
}
2023-10-09 19:12:16 -07:00
if (newtile->spawnNpc && newtile->spawnNpc->isSelected()) {
copied_tile->spawnNpc = newtile->spawnNpc;
newtile->spawnNpc = nullptr;
}
tiles->setTile(copied_tile->getPosition(), copied_tile);
2023-10-09 19:12:16 -07:00
if (copied_tile->getX() < copyPos.x) {
copyPos.x = copied_tile->getX();
}
2023-10-09 19:12:16 -07:00
if (copied_tile->getY() < copyPos.y) {
copyPos.y = copied_tile->getY();
}
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++) {
tilestoborder.push_back(Position(tile->getX() + x, tile->getY() + y, tile->getZ()));
2023-10-09 19:12:16 -07:00
}
}
}
action->addChange(newd Change(newtile));
}
batch->addAndCommitAction(action);
// Remove duplicates
tilestoborder.sort();
tilestoborder.unique();
2023-10-09 19:12:16 -07:00
if (g_settings.getInteger(Config::USE_AUTOMAGIC)) {
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 = editor.createAction(batch);
2023-10-09 19:12:16 -07:00
for (PositionList::iterator it = tilestoborder.begin(); it != tilestoborder.end(); ++it) {
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(*it);
2023-10-09 19:12:16 -07:00
if (location->get()) {
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 = location->get()->deepCopy(map);
new_tile->borderize(&map);
new_tile->wallize(&map);
action->addChange(newd Change(new_tile));
2015-12-06 11:42:37 -03:00
} else {
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 = 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));
2015-12-06 11:42:37 -03:00
} else {
delete new_tile;
}
}
}
batch->addAndCommitAction(action);
}
editor.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
editor.updateActions();
std::stringstream ss;
2023-10-09 19:12:16 -07:00
ss << "Cut out " << tile_count << " tile" << (tile_count > 1 ? "s" : "") << " (" << item_count << " item" << (item_count > 1 ? "s" : "") << ")";
g_gui.SetStatusText(wxstr(ss.str()));
}
2023-10-09 19:12:16 -07:00
void CopyBuffer::paste(Editor &editor, const Position &toPosition) {
if (!tiles) {
return;
2014-03-01 14:44:11 +01:00
}
2023-10-09 19:12:16 -07:00
Map &map = editor.getMap();
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* batchAction = editor.createBatch(ACTION_PASTE_TILES);
Action* action = editor.createAction(batchAction);
2023-10-09 19:12:16 -07:00
for (MapIterator it = tiles->begin(); it != tiles->end(); ++it) {
Tile* buffer_tile = (*it)->get();
2014-03-01 14:44:11 +01:00
Position pos = buffer_tile->getPosition() - copyPos + toPosition;
2023-10-09 19:12:16 -07:00
if (!pos.isValid()) {
continue;
2023-10-09 19:12:16 -07:00
}
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
TileLocation* location = map.createTileL(pos);
Tile* copy_tile = buffer_tile->deepCopy(map);
Tile* old_dest_tile = location->get();
Tile* new_dest_tile = nullptr;
copy_tile->setLocation(location);
2023-10-09 19:12:16 -07:00
if (g_settings.getInteger(Config::MERGE_PASTE) || !copy_tile->ground) {
if (old_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
new_dest_tile = old_dest_tile->deepCopy(map);
2023-10-09 19:12:16 -07:00
} else {
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_dest_tile = map.allocator(location);
2023-10-09 19:12:16 -07:00
}
new_dest_tile->merge(copy_tile);
delete copy_tile;
2015-12-06 11:42:37 -03:00
} else {
// If the copied tile has ground, replace target tile
new_dest_tile = copy_tile;
}
// Add all surrounding tiles to the map, so they get borders
2023-10-09 19:12:16 -07:00
map.createTile(pos.x - 1, pos.y - 1, pos.z);
map.createTile(pos.x, pos.y - 1, pos.z);
map.createTile(pos.x + 1, pos.y - 1, pos.z);
map.createTile(pos.x - 1, pos.y, pos.z);
map.createTile(pos.x + 1, pos.y, pos.z);
map.createTile(pos.x - 1, pos.y + 1, pos.z);
map.createTile(pos.x, pos.y + 1, pos.z);
map.createTile(pos.x + 1, pos.y + 1, pos.z);
action->addChange(newd Change(new_dest_tile));
}
batchAction->addAndCommitAction(action);
2023-10-09 19:12:16 -07:00
if (g_settings.getInteger(Config::USE_AUTOMAGIC) && g_settings.getInteger(Config::BORDERIZE_PASTE)) {
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 = editor.createAction(batchAction);
TileList borderize_tiles;
// Go through all modified (selected) tiles (might be slow)
2023-10-09 19:12:16 -07:00
for (MapIterator it = tiles->begin(); it != tiles->end(); ++it) {
bool add_me = false; // If this tile is touched
2014-03-01 14:44:11 +01:00
Position pos = (*it)->getPosition() - copyPos + toPosition;
2023-10-09 19:12:16 -07:00
if (pos.z < rme::MapMinLayer || pos.z > rme::MapMaxLayer) {
continue;
}
// 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, 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) {
borderize_tiles.push_back(map.getTile(pos));
}
}
// Remove duplicates
borderize_tiles.sort();
borderize_tiles.unique();
2023-10-09 19:12:16 -07:00
for (Tile* tile : borderize_tiles) {
if (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
Tile* newTile = tile->deepCopy(map);
2014-03-01 14:44:11 +01:00
newTile->borderize(&map);
2016-09-29 19:24:45 -03:00
2023-10-09 19:12:16 -07:00
if (tile->ground && tile->ground->isSelected()) {
2014-03-01 14:44:11 +01:00
newTile->selectGround();
}
newTile->wallize(&map);
action->addChange(newd Change(newTile));
}
}
2014-03-01 14:44:11 +01:00
// Commit changes to map
batchAction->addAndCommitAction(action);
}
editor.addBatch(batchAction);
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
editor.updateActions();
}
2023-10-09 19:12:16 -07:00
bool CopyBuffer::canPaste() const {
return tiles && tiles->size() != 0;
}