pequeños bugixes; debug facherito

This commit is contained in:
OugonNoHane 2022-10-31 15:33:42 +01:00
commit c52687450e
2 changed files with 66 additions and 71 deletions

2
.gitignore vendored
View file

@ -1,2 +1,4 @@
*.ini *.ini
*.exe *.exe
*.rdbg
*.pdb

View file

@ -78,8 +78,6 @@ int listDirectory(std::string path, std::vector<char*> *directoryContents, std::
hFind = FindFirstFile(path.c_str(), &ffd); hFind = FindFirstFile(path.c_str(), &ffd);
if (INVALID_HANDLE_VALUE == hFind) return -2; if (INVALID_HANDLE_VALUE == hFind) return -2;
do { do {
//TODO laberga k momento educativo
if(!strcmp(ffd.cFileName, ".") || !strcmp(ffd.cFileName, "..")) continue; if(!strcmp(ffd.cFileName, ".") || !strcmp(ffd.cFileName, "..")) continue;
//Codigo pa saltarse arxibus k no estiendan //Codigo pa saltarse arxibus k no estiendan
@ -127,6 +125,7 @@ int listDirectory(std::string path, std::vector<char*> *directoryContents, std::
itemPath[idx] = ffd.cFileName[idx]; itemPath[idx] = ffd.cFileName[idx];
idx++; idx++;
} while (ffd.cFileName[idx]); } while (ffd.cFileName[idx]);
itemPath[idx] = '\0';
numFiles++; numFiles++;
} while (FindNextFile(hFind, &ffd) != 0); } while (FindNextFile(hFind, &ffd) != 0);
@ -370,10 +369,10 @@ int main(int, char**)
static char currentPath[MAX_PATH]; static char currentPath[MAX_PATH];
static char* currentPathPtr = &currentPath[0]; static char* currentPathPtr = &currentPath[0];
static int currentItemIdx = -1; //static int currentItemIdx = -1;
//TODO David momento //TODO David momento
static std::vector<char*> displayContents; //static std::vector<char*> displayContents;
std::vector<char*> directoryContents; static std::vector<char*> directoryContents;
static int numFiles = 0; static int numFiles = 0;
if (debug) ImGui::Text("%s primir", currentPath); if (debug) ImGui::Text("%s primir", currentPath);
@ -391,24 +390,18 @@ int main(int, char**)
numFiles = (listDirectory(std::string(currentPath), &directoryContents));//, &restrictToExe)); numFiles = (listDirectory(std::string(currentPath), &directoryContents));//, &restrictToExe));
//std::cout << numFiles; //std::cout << numFiles;
if (numFiles < 0) { if (numFiles < 0) {
ImGui::Text("Path not valid"); //ImGui::Text("Path not valid");
if (debug) std::cout << "pencaste 2 el repencazo"; if (debug) std::cout << "pencaste 2 el repencazo";
goto filepickerFailure; goto filepickerFailure;
} }
if (numFiles == 0) {
if (debug) std::cout << std::to_string (numFiles) << "<- NUM FILES" << std::endl; //displayContents = std::move(directoryContents);
char empty[] = "Empty"; //directoryContents.clear();
numFiles++;
directoryContents.push_back(empty);
}
displayContents = std::move(directoryContents);
directoryContents.clear();
} }
//It's renderin' time //It's renderin' time
if(numFiles > 0){
ImGui::Text("Select a file:"); ImGui::Text("Select a file:");
if (debug) ImGui::Text("%s %d", currentPath, currentItemIdx); if (debug) ImGui::Text("%s ", currentPath);
//Y a que los VOLUMENES pinta2 pa100pre //Y a que los VOLUMENES pinta2 pa100pre
//if (debug) std::cout << std::to_string(onPresentPaths.size()) + "<- numvols" << std::endl; //if (debug) std::cout << std::to_string(onPresentPaths.size()) + "<- numvols" << std::endl;
@ -442,27 +435,27 @@ int main(int, char**)
//DIRECTORIOS ENCONTRADOS bien pinta2 //DIRECTORIOS ENCONTRADOS bien pinta2
if (ImGui::BeginListBox("fpLb", ImVec2(-FLT_MIN, 25 * ImGui::GetTextLineHeightWithSpacing()))){ if (ImGui::BeginListBox("fpLb", ImVec2(-FLT_MIN, 25 * ImGui::GetTextLineHeightWithSpacing()))){
for (int i = 0; i < numFiles; i++) { int idx = 0;
for (; idx < numFiles; idx++) {
const bool isSelected = (currentItemIdx == i); //const bool isSelected = (currentItemIdx == i);
if (ImGui::Selectable(displayContents.at(i), isSelected)) bool isSelected = false;
currentItemIdx = i; if (ImGui::Selectable(directoryContents.at(idx), &isSelected)){
//currentItemIdx = i;
if (isSelected) {
strcat(currentPath, "\\"); strcat(currentPath, "\\");
strcat(currentPath, displayContents.at(i)); strcat(currentPath, directoryContents.at(idx));
moveDirectory(&currentPathPtr); moveDirectory(&currentPathPtr);
currentItemIdx = -1; //currentItemIdx = -1;
isListDirectoriesAdequate = true; isListDirectoriesAdequate = true;
} }
//ImGui::SetItemDefaultFocus(); //ImGui::SetItemDefaultFocus();
} }
if (!idx) ImGui::Text("Folder is empty");
ImGui::EndListBox(); ImGui::EndListBox();
} }
} else {
ImGui::Text("cagaste");
}
//ImGui::TreePop(); //ImGui::TreePop();
filepickerFailure: filepickerFailure:
ImGui::End(); ImGui::End();