/* Edit3D::changeThingZ * Changes the Z height of selected 3d mode things by [amount] *******************************************************************/ void Edit3D::changeThingZ(int amount) const { // Ignore for doom format if (context_.map().currentFormat() == MAP_DOOM) return; // Go through 3d selection auto& selection_3d = context_.selection(); for (unsigned a = 0; a < selection_3d.size(); a++) { // Check if thing if (selection_3d[a].type == ItemType::Thing) { MapThing* thing = context_.map().getThing(selection_3d[a].index); if (thing) { // Change z height context_.recordPropertyChangeUndoStep(thing); double z = thing->intProperty("height"); z += amount; thing->setIntProperty("height", z); } } } }
/* MapEditContext::paste3d * Pastes previously copied wall/flat/thing info to selection *******************************************************************/ void Edit3D::paste(CopyType type) { // Begin undo step string ptype = "Paste Properties"; if (type == CopyType::TexType) ptype = "Paste Texture/Type"; undo_manager_->beginRecord(ptype); // Go through items auto& selection = context_.selection(); for (auto& item : selection.selectionOrHilight()) { // Wall if (MapEditor::baseItemType(item.type) == ItemType::Side) { MapSide* side = context_.map().getSide(item.index); undo_manager_->recordUndoStep(new MapEditor::PropertyChangeUS(side)); // Upper wall if (item.type == ItemType::WallTop) { // Texture if (type == CopyType::TexType) side->setStringProperty("texturetop", copy_texture_); } // Middle wall else if (item.type == ItemType::WallMiddle) { // Texture if (type == CopyType::TexType) side->setStringProperty("texturemiddle", copy_texture_); } // Lower wall else if (item.type == ItemType::WallBottom) { // Texture if (type == CopyType::TexType) side->setStringProperty("texturebottom", copy_texture_); } } // Flat else if (item.type == ItemType::Floor || item.type == ItemType::Ceiling) { MapSector* sector = context_.map().getSector(item.index); undo_manager_->recordUndoStep(new MapEditor::PropertyChangeUS(sector)); // Floor if (item.type == ItemType::Floor) { // Texture if (type == CopyType::TexType) sector->setStringProperty("texturefloor", copy_texture_); } // Ceiling if (item.type == ItemType::Ceiling) { // Texture if (type == CopyType::TexType) sector->setStringProperty("textureceiling", copy_texture_); } } // Thing else if (item.type == ItemType::Thing) { MapThing* thing = context_.map().getThing(item.index); undo_manager_->recordUndoStep(new MapEditor::PropertyChangeUS(thing)); // Type if (type == CopyType::TexType) thing->setIntProperty("type", copy_thing_.getType()); } } // Editor message if (type == CopyType::TexType) { if (selection.hilight().type == ItemType::Thing) context_.addEditorMessage("Pasted Thing Type"); else context_.addEditorMessage("Pasted Texture"); } undo_manager_->endRecord(true); }
/* Edit3D::changeHeight * Changes the height of objects, depending on type: * Things: Z height * Flat: height * Wall: vertical offset *******************************************************************/ void Edit3D::changeHeight(int amount) const { // Get items to process vector<MapEditor::Item> items; auto& selection_3d = context_.selection(); auto hilight_3d = context_.hilightItem(); auto& map = context_.map(); if (selection_3d.empty() && hilight_3d.index >= 0) { if (hilight_3d.type != ItemType::Thing || map.currentFormat() != MAP_DOOM) items.push_back(hilight_3d); } else for (unsigned a = 0; a < selection_3d.size(); a++) { if (selection_3d[a].type != ItemType::Thing || map.currentFormat() != MAP_DOOM) items.push_back(selection_3d[a]); } if (items.empty()) return; // Begin undo level context_.beginUndoRecordLocked("Change Height", true, false, false); // Go through items for (unsigned a = 0; a < items.size(); a++) { auto type = items[a].type; // Thing if (type == ItemType::Thing) { MapThing* thing = map.getThing(items[a].index); if (thing) { double z = thing->intProperty("height"); z += amount; thing->setIntProperty("height", z); } } // Wall if (type == ItemType::WallBottom || type == ItemType::WallMiddle || type == ItemType::WallTop) { auto side = map.getSide(items[a].index); if (side) { string ofs = "offsety"; // If offsets are linked, just change the whole side offset if (link_offset_) { int offset = side->intProperty(ofs); side->setIntProperty(ofs, offset + amount); continue; } // Unlinked offsets, build string (offsety_[top/mid/bottom]) else if (items[a].type == ItemType::WallBottom) ofs += "_bottom"; else if (items[a].type == ItemType::WallTop) ofs += "_top"; else ofs += "_mid"; // Change the offset float offset = side->floatProperty(ofs); side->setFloatProperty(ofs, offset + amount); } } // Floor else if (type == ItemType::Floor) { // Get sector auto sector = map.getSector(items[a].index); // Change height if (sector) sector->setFloorHeight(sector->getFloorHeight() + amount); } // Ceiling else if (type == ItemType::Ceiling) { // Get sector auto sector = map.getSector(items[a].index); // Change height if (sector) sector->setCeilingHeight(sector->getCeilingHeight() + amount); } } // End undo level context_.endUndoRecord(); // Editor message if (items.size() > 0) { if (amount > 0) context_.addEditorMessage(S_FMT("Height increased by %d", amount)); else context_.addEditorMessage(S_FMT("Height decreased by %d", -amount)); } }