diff --git a/src/noggit/MapChunk.cpp b/src/noggit/MapChunk.cpp index d29a6efd..b585e98e 100755 --- a/src/noggit/MapChunk.cpp +++ b/src/noggit/MapChunk.cpp @@ -1259,6 +1259,17 @@ void MapChunk::eraseTextures() texture_set->eraseTextures(); } +void MapChunk::eraseTexture(scoped_blp_texture_reference const& tex) +{ + + int textureindex = texture_set->get_texture_index_or_add(tex, 0); + + if (textureindex != -1) + { + texture_set->eraseTexture(textureindex); + } +} + void MapChunk::change_texture_flag(scoped_blp_texture_reference const& tex, std::size_t flag, bool add) { texture_set->change_texture_flag(tex, flag, add); diff --git a/src/noggit/MapChunk.h b/src/noggit/MapChunk.h index 656c8c8b..03f62e10 100755 --- a/src/noggit/MapChunk.h +++ b/src/noggit/MapChunk.h @@ -162,6 +162,7 @@ public: int addTexture(scoped_blp_texture_reference texture); void switchTexture(scoped_blp_texture_reference const& oldTexture, scoped_blp_texture_reference newTexture); void eraseTextures(); + void eraseTexture(scoped_blp_texture_reference const& tex); void change_texture_flag(scoped_blp_texture_reference const& tex, std::size_t flag, bool add); void clear_shadows(); diff --git a/src/noggit/World.cpp b/src/noggit/World.cpp index af901bb4..6a47b568 100755 --- a/src/noggit/World.cpp +++ b/src/noggit/World.cpp @@ -2031,6 +2031,21 @@ void World::swapTexture(glm::vec3 const& pos, scoped_blp_texture_reference tex) } } +void World::removeTexture(glm::vec3 const& pos, scoped_blp_texture_reference tex) +{ + ZoneScoped; + if (!!Noggit::Ui::selected_texture::get()) + { + for_all_chunks_on_tile(pos, [&](MapChunk* chunk) + { + NOGGIT_CUR_ACTION->registerChunkTextureChange(chunk); + // chunk->switchTexture(tex, *Noggit::Ui::selected_texture::get()); + chunk->eraseTexture(tex); + }); + } +} + + void World::removeTexDuplicateOnADT(glm::vec3 const& pos) { ZoneScoped; diff --git a/src/noggit/World.h b/src/noggit/World.h index eec45727..bbc0b01c 100755 --- a/src/noggit/World.h +++ b/src/noggit/World.h @@ -216,6 +216,7 @@ public: void clear_shadows(glm::vec3 const& pos); void clearTextures(glm::vec3 const& pos); void swapTexture(glm::vec3 const& pos, scoped_blp_texture_reference tex); + void removeTexture(glm::vec3 const& pos, scoped_blp_texture_reference tex); void removeTexDuplicateOnADT(glm::vec3 const& pos); void change_texture_flag(glm::vec3 const& pos, scoped_blp_texture_reference const& tex, std::size_t flag, bool add); diff --git a/src/noggit/ui/texture_swapper.cpp b/src/noggit/ui/texture_swapper.cpp index b890b96f..7b4b2718 100755 --- a/src/noggit/ui/texture_swapper.cpp +++ b/src/noggit/ui/texture_swapper.cpp @@ -36,11 +36,13 @@ namespace Noggit QPushButton* select = new QPushButton("Select", this); QPushButton* swap_adt = new QPushButton("Swap ADT", this); + QPushButton* remove_text_adt = new QPushButton(tr("Remove this texture from ADT"), this); layout->addRow(new QLabel("Texture to swap")); layout->addRow(_texture_to_swap_display); layout->addRow(select); layout->addRow(swap_adt); + layout->addRow(remove_text_adt); _brush_mode_group = new QGroupBox("Brush mode", this); _brush_mode_group->setCheckable(true); @@ -87,6 +89,15 @@ namespace Noggit } }); + connect(remove_text_adt, &QPushButton::clicked, [this, camera_pos, map_view]() { + if (_texture_to_swap) + { + ActionManager::instance()->beginAction(map_view, ActionFlags::eCHUNKS_TEXTURE); + _world->removeTexture(*camera_pos, _texture_to_swap.value()); + ActionManager::instance()->endAction(); + } + }); + connect ( _radius_spin, qOverload (&QDoubleSpinBox::valueChanged) , [&](double v) {