pequeños bugixes; debug facherito
This commit is contained in:
parent
af3af6bc4f
commit
b4ff0148ee
2 changed files with 66 additions and 71 deletions
137
main.cpp
137
main.cpp
|
|
@ -78,8 +78,6 @@ int listDirectory(std::string path, std::vector<char*> *directoryContents, std::
|
|||
hFind = FindFirstFile(path.c_str(), &ffd);
|
||||
if (INVALID_HANDLE_VALUE == hFind) return -2;
|
||||
do {
|
||||
|
||||
//TODO laberga k momento educativo
|
||||
if(!strcmp(ffd.cFileName, ".") || !strcmp(ffd.cFileName, "..")) continue;
|
||||
|
||||
//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];
|
||||
idx++;
|
||||
} while (ffd.cFileName[idx]);
|
||||
itemPath[idx] = '\0';
|
||||
|
||||
numFiles++;
|
||||
} while (FindNextFile(hFind, &ffd) != 0);
|
||||
|
|
@ -370,10 +369,10 @@ int main(int, char**)
|
|||
static char currentPath[MAX_PATH];
|
||||
static char* currentPathPtr = ¤tPath[0];
|
||||
|
||||
static int currentItemIdx = -1;
|
||||
//static int currentItemIdx = -1;
|
||||
//TODO David momento
|
||||
static std::vector<char*> displayContents;
|
||||
std::vector<char*> directoryContents;
|
||||
//static std::vector<char*> displayContents;
|
||||
static std::vector<char*> directoryContents;
|
||||
static int numFiles = 0;
|
||||
|
||||
if (debug) ImGui::Text("%s primir", currentPath);
|
||||
|
|
@ -391,82 +390,76 @@ int main(int, char**)
|
|||
numFiles = (listDirectory(std::string(currentPath), &directoryContents));//, &restrictToExe));
|
||||
//std::cout << numFiles;
|
||||
if (numFiles < 0) {
|
||||
ImGui::Text("Path not valid");
|
||||
//ImGui::Text("Path not valid");
|
||||
if (debug) std::cout << "pencaste 2 el repencazo";
|
||||
goto filepickerFailure;
|
||||
}
|
||||
if (numFiles == 0) {
|
||||
if (debug) std::cout << std::to_string (numFiles) << "<- NUM FILES" << std::endl;
|
||||
char empty[] = "Empty";
|
||||
numFiles++;
|
||||
directoryContents.push_back(empty);
|
||||
}
|
||||
displayContents = std::move(directoryContents);
|
||||
directoryContents.clear();
|
||||
|
||||
//displayContents = std::move(directoryContents);
|
||||
//directoryContents.clear();
|
||||
}
|
||||
|
||||
//It's renderin' time
|
||||
if(numFiles > 0){
|
||||
ImGui::Text("Select a file:");
|
||||
if (debug) ImGui::Text("%s %d", currentPath, currentItemIdx);
|
||||
|
||||
//Y a que los VOLUMENES pinta2 pa100pre
|
||||
//if (debug) std::cout << std::to_string(onPresentPaths.size()) + "<- numvols" << std::endl;
|
||||
if (numVolumes > 0) {
|
||||
for (int i = 0; i < onPresentPaths.size(); i++) {
|
||||
if (i > 0) ImGui::SameLine();
|
||||
// if (debug) std::cout << std::to_string(i) + "<- WE IN" << std::endl;
|
||||
// ImGui::PushID(i);
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(i / 7.0f, 0.6f, 0.6f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(i / 7.0f, 0.7f, 0.7f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(i / 7.0f, 0.8f, 0.8f));
|
||||
if(ImGui::Button(onPresentPaths.at(i))){
|
||||
moveDirectory(&onPresentPaths.at(i));
|
||||
isListDirectoriesAdequate = true;
|
||||
}
|
||||
ImGui::PopStyleColor(3);
|
||||
// ImGui::PopID();
|
||||
ImGui::Text("Select a file:");
|
||||
if (debug) ImGui::Text("%s ", currentPath);
|
||||
|
||||
//Y a que los VOLUMENES pinta2 pa100pre
|
||||
//if (debug) std::cout << std::to_string(onPresentPaths.size()) + "<- numvols" << std::endl;
|
||||
if (numVolumes > 0) {
|
||||
for (int i = 0; i < onPresentPaths.size(); i++) {
|
||||
if (i > 0) ImGui::SameLine();
|
||||
// if (debug) std::cout << std::to_string(i) + "<- WE IN" << std::endl;
|
||||
// ImGui::PushID(i);
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(i / 7.0f, 0.6f, 0.6f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(i / 7.0f, 0.7f, 0.7f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(i / 7.0f, 0.8f, 0.8f));
|
||||
if(ImGui::Button(onPresentPaths.at(i))){
|
||||
moveDirectory(&onPresentPaths.at(i));
|
||||
isListDirectoriesAdequate = true;
|
||||
}
|
||||
ImGui::PopStyleColor(3);
|
||||
// ImGui::PopID();
|
||||
}
|
||||
|
||||
|
||||
//Permanentes e increiblemente utilitarios botones en Cuatro K
|
||||
//c pervirtio con unicode std::wstring s(L"←→↑↓");
|
||||
static char moveUp[] = "..";
|
||||
static char* moveUpPtr = &moveUp[0];
|
||||
if(ImGui::Button("Move Up")){
|
||||
moveDirectory(&moveUpPtr);
|
||||
isListDirectoriesAdequate = true;
|
||||
}
|
||||
|
||||
|
||||
//DIRECTORIOS ENCONTRADOS bien pinta2
|
||||
if (ImGui::BeginListBox("fpLb", ImVec2(-FLT_MIN, 25 * ImGui::GetTextLineHeightWithSpacing()))){
|
||||
for (int i = 0; i < numFiles; i++) {
|
||||
|
||||
const bool isSelected = (currentItemIdx == i);
|
||||
if (ImGui::Selectable(displayContents.at(i), isSelected))
|
||||
currentItemIdx = i;
|
||||
|
||||
if (isSelected) {
|
||||
strcat(currentPath, "\\");
|
||||
strcat(currentPath, displayContents.at(i));
|
||||
moveDirectory(¤tPathPtr);
|
||||
currentItemIdx = -1;
|
||||
isListDirectoriesAdequate = true;
|
||||
}
|
||||
//ImGui::SetItemDefaultFocus();
|
||||
|
||||
}
|
||||
ImGui::EndListBox();
|
||||
}
|
||||
} else {
|
||||
ImGui::Text("cagaste");
|
||||
}
|
||||
//ImGui::TreePop();
|
||||
filepickerFailure:
|
||||
ImGui::End();
|
||||
|
||||
|
||||
|
||||
//Permanentes e increiblemente utilitarios botones en Cuatro K
|
||||
//c pervirtio con unicode std::wstring s(L"←→↑↓");
|
||||
static char moveUp[] = "..";
|
||||
static char* moveUpPtr = &moveUp[0];
|
||||
if(ImGui::Button("Move Up")){
|
||||
moveDirectory(&moveUpPtr);
|
||||
isListDirectoriesAdequate = true;
|
||||
}
|
||||
|
||||
|
||||
//DIRECTORIOS ENCONTRADOS bien pinta2
|
||||
if (ImGui::BeginListBox("fpLb", ImVec2(-FLT_MIN, 25 * ImGui::GetTextLineHeightWithSpacing()))){
|
||||
int idx = 0;
|
||||
for (; idx < numFiles; idx++) {
|
||||
|
||||
//const bool isSelected = (currentItemIdx == i);
|
||||
bool isSelected = false;
|
||||
if (ImGui::Selectable(directoryContents.at(idx), &isSelected)){
|
||||
//currentItemIdx = i;
|
||||
strcat(currentPath, "\\");
|
||||
strcat(currentPath, directoryContents.at(idx));
|
||||
moveDirectory(¤tPathPtr);
|
||||
//currentItemIdx = -1;
|
||||
isListDirectoriesAdequate = true;
|
||||
}
|
||||
|
||||
//ImGui::SetItemDefaultFocus();
|
||||
|
||||
}
|
||||
if (!idx) ImGui::Text("Folder is empty");
|
||||
ImGui::EndListBox();
|
||||
}
|
||||
|
||||
//ImGui::TreePop();
|
||||
filepickerFailure:
|
||||
ImGui::End();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue