DEBUG macro momento
This commit is contained in:
parent
54bd3a914e
commit
0bccc31b37
1 changed files with 15 additions and 11 deletions
26
main.cpp
26
main.cpp
|
|
@ -11,6 +11,7 @@
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#define DEBUG true
|
||||||
|
|
||||||
// [Win32] Our example includes a copy of glfw3.lib pre-compiled with VS2010 to maximize ease of testing and compatibility with old VS compilers.
|
// [Win32] Our example includes a copy of glfw3.lib pre-compiled with VS2010 to maximize ease of testing and compatibility with old VS compilers.
|
||||||
// To link with VS2010-era libraries, VS2015+ requires linking with legacy_stdio_definitions.lib, which we do using this pragma.
|
// To link with VS2010-era libraries, VS2015+ requires linking with legacy_stdio_definitions.lib, which we do using this pragma.
|
||||||
|
|
@ -30,7 +31,6 @@ bool retrieveCurrentDirectory(char** currentPath){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool moveDirectory(char** currentPath){
|
bool moveDirectory(char** currentPath){
|
||||||
if(SetCurrentDirectory(*currentPath)) return true;
|
if(SetCurrentDirectory(*currentPath)) return true;
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -197,33 +197,38 @@ int main(int, char**)
|
||||||
{
|
{
|
||||||
ImGui::Begin("File Picker in 4K");
|
ImGui::Begin("File Picker in 4K");
|
||||||
|
|
||||||
|
static bool renderListbox = true;
|
||||||
//cursed C momento: necesario ptr en otra var para mandar a char** de firma
|
//cursed C momento: necesario ptr en otra var para mandar a char** de firma
|
||||||
static bool renderList = true;
|
|
||||||
static char currentPath[MAX_PATH];
|
static char currentPath[MAX_PATH];
|
||||||
static char* ptr = ¤tPath[0];
|
static char* ptr = ¤tPath[0];
|
||||||
|
|
||||||
static int currentItemIdx = -1;
|
static int currentItemIdx = -1;
|
||||||
static std::vector<char*> displayContents;
|
static std::vector<char*> displayContents;
|
||||||
std::vector<char*> directoryContents;
|
std::vector<char*> directoryContents;
|
||||||
ImGui::Text("%s primir", currentPath);
|
|
||||||
static int numFiles = 0;
|
static int numFiles = 0;
|
||||||
|
|
||||||
if(renderList) {
|
if (DEBUG) ImGui::Text("%s primir", currentPath);
|
||||||
renderList = false;
|
|
||||||
if(!retrieveCurrentDirectory(&ptr))
|
if(renderListbox) {
|
||||||
|
if (DEBUG) std::cout << "renderiso";
|
||||||
|
renderListbox = false;
|
||||||
|
if(!retrieveCurrentDirectory(&ptr)) {
|
||||||
|
if (DEBUG) std::cout << "pencaste";
|
||||||
goto filepickerFailure;
|
goto filepickerFailure;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
numFiles = (listDirectory(std::string(currentPath), &directoryContents));
|
numFiles = (listDirectory(std::string(currentPath), &directoryContents));
|
||||||
//std::cout << numFiles;
|
//std::cout << numFiles;
|
||||||
if (numFiles < 0)
|
if (numFiles < 0) {
|
||||||
|
if (DEBUG) std::cout << "pencaste 2 el repencazo";
|
||||||
goto filepickerFailure;
|
goto filepickerFailure;
|
||||||
|
}
|
||||||
displayContents = std::move(directoryContents);
|
displayContents = std::move(directoryContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(numFiles > 0){
|
if(numFiles > 0){
|
||||||
ImGui::Text("Select a file:");
|
ImGui::Text("Select a file:");
|
||||||
//TODO quitar
|
if (DEBUG) ImGui::Text("%s %d", currentPath, currentItemIdx);
|
||||||
ImGui::Text("%s %d", currentPath, currentItemIdx);
|
|
||||||
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++) {
|
for (int i = 0; i < numFiles; i++) {
|
||||||
// ImGui::Selectable(directoryContents.at(i), false);
|
// ImGui::Selectable(directoryContents.at(i), false);
|
||||||
|
|
@ -232,13 +237,12 @@ int main(int, char**)
|
||||||
if (ImGui::Selectable(displayContents.at(i), isSelected))
|
if (ImGui::Selectable(displayContents.at(i), isSelected))
|
||||||
currentItemIdx = i;
|
currentItemIdx = i;
|
||||||
|
|
||||||
//Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
|
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
strcat(currentPath, "\\");
|
strcat(currentPath, "\\");
|
||||||
strcat(currentPath, displayContents.at(i));
|
strcat(currentPath, displayContents.at(i));
|
||||||
moveDirectory(&ptr);
|
moveDirectory(&ptr);
|
||||||
currentItemIdx = -1;
|
currentItemIdx = -1;
|
||||||
renderList = true;
|
renderListbox = true;
|
||||||
}
|
}
|
||||||
//ImGui::SetItemDefaultFocus();
|
//ImGui::SetItemDefaultFocus();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue