Skip to content
Snippets Groups Projects
Commit b3cf09aa authored by Martin Štourač's avatar Martin Štourač
Browse files

fix modules with same name

parent a3e2ae0e
No related branches found
No related tags found
No related merge requests found
...@@ -274,6 +274,8 @@ void Editor::enterPhaseOne() ...@@ -274,6 +274,8 @@ void Editor::enterPhaseOne()
scene->manageCameraAxes(false); scene->manageCameraAxes(false);
removeRofiWorldNodeTreeFromScene(rofiworld->getNodeTree()); removeRofiWorldNodeTreeFromScene(rofiworld->getNodeTree());
removeModuleFromScene(selected_module); removeModuleFromScene(selected_module);
removeModuleFromScene(selected_add_module);
selected_add_module = nullptr;
voxel_graph = nullptr; voxel_graph = nullptr;
} }
...@@ -1268,6 +1270,14 @@ void Editor::addToModules(std::string name, std::string type) ...@@ -1268,6 +1270,14 @@ void Editor::addToModules(std::string name, std::string type)
linkImportVoxelGraphToNodes(new_module->getParts()); linkImportVoxelGraphToNodes(new_module->getParts());
setModuleNodeHierarchy(new_module->getParts(), type); setModuleNodeHierarchy(new_module->getParts(), type);
setRoFIMesh(new_module->getParts()); setRoFIMesh(new_module->getParts());
if (const auto it = std::find_if(modules.begin(), modules.end(),
[&](const module_ptr module) { return module->getName() == name; } );
it != modules.end())
{
modules.erase(it);
}
modules.emplace_back(new_module); modules.emplace_back(new_module);
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <utils/math.hpp> #include <utils/math.hpp>
#include <iostream> #include <iostream>
#include <string>
void show_ui(const osi::Window &window, edit::UIData &data, const double &current_second) void show_ui(const osi::Window &window, edit::UIData &data, const double &current_second)
{ {
...@@ -524,7 +525,7 @@ void module_selection_ui(const osi::Window &window, edit::UIData &data) ...@@ -524,7 +525,7 @@ void module_selection_ui(const osi::Window &window, edit::UIData &data)
{ {
auto & [name, type] = names_types[n]; auto & [name, type] = names_types[n];
bool is_selected = (data.add_module_list_index == n); bool is_selected = (data.add_module_list_index == n);
const auto label_string = name + " (" + type + ")"; const auto label_string = name + " (" + type + ")" + "##ModuleSelectionItem" + std::to_string(n);
const char* label = label_string.c_str(); const char* label = label_string.c_str();
if (ImGui::Selectable(label, is_selected)) if (ImGui::Selectable(label, is_selected))
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment