diff --git a/src/engine/engine.h b/src/engine/engine.h index 711e3591e..6dcf3eb5f 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -523,9 +523,6 @@ class DivEngine { // remove an asset void removeAsset(std::vector& dir, int entry); - // check whether an asset directory is complete - void checkAssetDir(std::vector& dir, size_t entries); - // read/write asset dir void putAssetDirData(SafeWriter* w, std::vector& dir); DivDataErrors readAssetDirData(SafeReader& reader, std::vector& dir); @@ -607,6 +604,8 @@ class DivEngine { // convert old flags static void convertOldFlags(unsigned int oldFlags, DivConfig& newFlags, DivSystem sys); + // check whether an asset directory is complete (UNSAFE) + void checkAssetDir(std::vector& dir, size_t entries); // benchmark (returns time in seconds) double benchmarkPlayback(); diff --git a/src/gui/dataList.cpp b/src/gui/dataList.cpp index 19fca6235..79a3a821c 100644 --- a/src/gui/dataList.cpp +++ b/src/gui/dataList.cpp @@ -591,11 +591,22 @@ void FurnaceGUI::drawInsList(bool asChild) { ImGui::TableNextColumn(); insListItem(-1,-1,-1); int dirIndex=0; + int dirToDelete=-1; for (DivAssetDir& i: e->song.insDir) { String nodeName=fmt::sprintf("%s %s##_AD%d",i.name.empty()?ICON_FA_FOLDER_O:ICON_FA_FOLDER,i.name.empty()?"":i.name,i.name.empty()?-1:dirIndex); + String popupID=fmt::sprintf("DirRightMenu%d",dirIndex); bool treeNode=ImGui::TreeNodeEx(nodeName.c_str(),ImGuiTreeNodeFlags_SpanAvailWidth|(i.name.empty()?ImGuiTreeNodeFlags_DefaultOpen:0)); DRAG_SOURCE(dirIndex,-1); DRAG_TARGET(dirIndex,-1,e->song.insDir); + if (ImGui::BeginPopupContextItem(popupID.c_str())) { + if (ImGui::MenuItem("rename...")) { + ImGui::OpenPopup("NewInsFolder"); + } + if (ImGui::MenuItem("delete")) { + dirToDelete=dirIndex; + } + ImGui::EndPopup(); + } if (treeNode) { int assetIndex=0; for (int j: i.entries) { @@ -606,6 +617,12 @@ void FurnaceGUI::drawInsList(bool asChild) { } dirIndex++; } + if (dirToDelete!=-1) { + e->lockEngine([this,dirToDelete]() { + e->song.insDir.erase(e->song.insDir.begin()+dirToDelete); + e->checkAssetDir(e->song.insDir,e->song.ins.size()); + }); + } } else { int curRow=0; for (int i=-1; i<(int)e->song.ins.size(); i++) {