void CopyBuffer::copy(Editor& editor, int floor) { if(editor.selection.size() == 0) { gui.SetStatusText(wxT("No tiles to copy.")); return; } clear(); tiles = newd BaseMap(); int tile_count = 0; int item_count = 0; copyPos = Position(0xFFFF, 0xFFFF, floor); for(TileVector::iterator it = editor.selection.begin(); it != editor.selection.end(); ++it) { ++tile_count; Tile* tile = *it; TileLocation* newlocation = tiles->createTileL(tile->getPosition()); Tile* copied_tile = tiles->allocator(newlocation); if(tile->ground && tile->ground->isSelected()) { copied_tile->house_id = tile->house_id; copied_tile->setMapFlags(tile->getMapFlags()); } ItemVector tile_selection = tile->getSelectedItems(); for(ItemVector::iterator iit = tile_selection.begin(); iit != tile_selection.end(); ++iit) { ++item_count; // Copy items to copybuffer copied_tile->addItem((*iit)->deepCopy()); } if(tile->creature && tile->creature->isSelected()) { copied_tile->creature = tile->creature->deepCopy(); } if(tile->spawn && tile->spawn->isSelected()) { copied_tile->spawn = tile->spawn->deepCopy(); } tiles->setTile(copied_tile); if(copied_tile->getX() < copyPos.x) copyPos.x = copied_tile->getX(); if(copied_tile->getY() < copyPos.y) copyPos.y = copied_tile->getY(); } std::ostringstream ss; ss << "Copied " << tile_count << " tile" << (tile_count > 1 ? "s" : "") << " (" << item_count << " item" << (item_count > 1? "s" : "") << ")"; gui.SetStatusText(wxstr(ss.str())); }
// GUI class implementation GUI::GUI() : aui_manager(nullptr), root(nullptr), minimap(nullptr), gem(nullptr), search_result_window(nullptr), secondary_map(nullptr), doodad_buffer_map(nullptr), house_brush(nullptr), house_exit_brush(nullptr), waypoint_brush(nullptr), optional_brush(nullptr), eraser(nullptr), normal_door_brush(nullptr), locked_door_brush(nullptr), magic_door_brush(nullptr), quest_door_brush(nullptr), hatch_door_brush(nullptr), window_door_brush(nullptr), OGLContext(nullptr), loaded_version(CLIENT_VERSION_NONE), mode(SELECTION_MODE), pasting(false), hotkeys_enabled(true), current_brush(nullptr), previous_brush(nullptr), brush_shape(BRUSHSHAPE_SQUARE), brush_size(0), brush_variation(0), creature_spawntime(0), use_custom_thickness(false), custom_thickness_mod(0.0), progressBar(nullptr), disabled_counter(0) { doodad_buffer_map = newd BaseMap(); }
CopyBuffer::CopyBuffer() : tiles(newd BaseMap()) { ; }
void CopyBuffer::cut(Editor& editor, int floor) { if(editor.selection.size() == 0) { gui.SetStatusText(wxT("No tiles to cut.")); return; } clear(); tiles = newd BaseMap(); int tile_count = 0; int item_count = 0; copyPos = Position(0xFFFF, 0xFFFF, floor); BatchAction* batch = editor.actionQueue->createBatch(ACTION_CUT_TILES); Action* action = editor.actionQueue->createAction(batch); PositionList tilestoborder; for(TileVector::iterator it = editor.selection.begin(); it != editor.selection.end(); ++it) { tile_count++; Tile* tile = *it; Tile* newtile = tile->deepCopy(editor.map); Tile* copied_tile = tiles->allocator(tile->getLocation()); 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(); for(ItemVector::iterator iit = tile_selection.begin(); iit != tile_selection.end(); ++iit) { item_count++; // Add items to copybuffer copied_tile->addItem(*iit); } if(newtile->creature && newtile->creature->isSelected()) { copied_tile->creature = newtile->creature; newtile->creature = nullptr; } if(newtile->spawn && newtile->spawn->isSelected()) { copied_tile->spawn = newtile->spawn; newtile->spawn = nullptr; } tiles->setTile(copied_tile->getPosition(), copied_tile); if(copied_tile->getX() < copyPos.x) { copyPos.x = copied_tile->getX(); } if(copied_tile->getY() < copyPos.y) { copyPos.y = copied_tile->getY(); } if(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())); } action->addChange(newd Change(newtile)); } batch->addAndCommitAction(action); // Remove duplicates tilestoborder.sort(); tilestoborder.unique(); if(settings.getInteger(Config::USE_AUTOMAGIC)) { action = editor.actionQueue->createAction(batch); for(PositionList::iterator it = tilestoborder.begin(); it != tilestoborder.end(); ++it) { TileLocation* location = editor.map.createTileL(*it); if(location->get()) { Tile* new_tile = location->get()->deepCopy(editor.map); new_tile->borderize(&editor.map); new_tile->wallize(&editor.map); action->addChange(newd Change(new_tile)); } else { Tile* new_tile = editor.map.allocator(location); new_tile->borderize(&editor.map); if(new_tile->size()) { action->addChange(newd Change(new_tile)); } else { delete new_tile; } } } batch->addAndCommitAction(action); } editor.addBatch(batch); std::stringstream ss; ss << "Cut out " << tile_count << " tile" << (tile_count > 1 ? "s" : "") << " (" << item_count << " item" << (item_count > 1? "s" : "") << ")"; gui.SetStatusText(wxstr(ss.str())); }