asset directories, part 9

This commit is contained in:
tildearrow 2023-05-16 04:29:26 -05:00
parent 92cf966a36
commit b1e2d76ce6
2 changed files with 19 additions and 3 deletions

View File

@ -523,9 +523,6 @@ class DivEngine {
// remove an asset
void removeAsset(std::vector<DivAssetDir>& dir, int entry);
// check whether an asset directory is complete
void checkAssetDir(std::vector<DivAssetDir>& dir, size_t entries);
// read/write asset dir
void putAssetDirData(SafeWriter* w, std::vector<DivAssetDir>& dir);
DivDataErrors readAssetDirData(SafeReader& reader, std::vector<DivAssetDir>& 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<DivAssetDir>& dir, size_t entries);
// benchmark (returns time in seconds)
double benchmarkPlayback();

View File

@ -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()?"<uncategorized>":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++) {