made rails delete themselves if they don't have any waypoints to avoid crashes when trying to add rail points to an empty rail
This commit is contained in:
parent
7850871955
commit
18f5c9d025
1 changed files with 17 additions and 4 deletions
|
|
@ -159,10 +159,23 @@ void ImGuiDrawElem(Element* elem,std::string Id = ""){
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ImGui::Button((ICON_FA_PLUS "##" + Id).c_str())) {
|
|
||||||
RailPoint rp = RailPoint(rail->Points.back());
|
if(rail->Points.size() != 1) {
|
||||||
rp.runtimeID = rand();
|
if (ImGui::Button((ICON_FA_PLUS "##" + Id).c_str())) {
|
||||||
rail->Points.push_back(rp);
|
RailPoint rp = RailPoint(rail->Points.back());
|
||||||
|
rp.runtimeID = rand();
|
||||||
|
rail->Points.push_back(rp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rail->Points.empty()){
|
||||||
|
auto& map = GetMainWindow()->loadedMap;
|
||||||
|
|
||||||
|
std::erase_if(map.Rails,[&](const Rail& rail1){
|
||||||
|
return rail1.runtimeID == rail->runtimeID;
|
||||||
|
});
|
||||||
|
|
||||||
|
GetMainWindow()->selectedElem = nullptr;
|
||||||
}
|
}
|
||||||
ImGui::Unindent();
|
ImGui::Unindent();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue