mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2025-04-05 09:00:51 +00:00
added file dialog pk3 filtering and kb navigation
This commit is contained in:
parent
2c8026e0c1
commit
5e6b190223
1 changed files with 42 additions and 5 deletions
|
@ -180,24 +180,37 @@ static bool DoFileDialog(FileDialog& dialog)
|
|||
bool success = false;
|
||||
if(ImGui::BeginPopupModal(dialog.dialogName, NULL, ImGuiWindowFlags_AlwaysAutoResize))
|
||||
{
|
||||
static bool showFilesInPaks = false;
|
||||
if(!dialog.folderMode)
|
||||
{
|
||||
ImGui::Checkbox("Show files in PK3s", &showFilesInPaks);
|
||||
}
|
||||
|
||||
if(BeginTable(dialog.folderMode ? "Folders" : "Files", 1))
|
||||
{
|
||||
for(int i = 0; i < dialog.fileCount; i++)
|
||||
{
|
||||
const char* const filePath = dialog.filePaths[i];
|
||||
if(dialog.folderMode &&
|
||||
(Q_stricmp(dialog.filePaths[i], ".") == 0 ||
|
||||
Q_stricmp(dialog.filePaths[i], "..") == 0))
|
||||
(Q_stricmp(filePath, ".") == 0 || Q_stricmp(filePath, "..") == 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!dialog.folderMode &&
|
||||
!showFilesInPaks &&
|
||||
FS_FileIsInPAK(va("%s/%s", dialog.folder, filePath), NULL, NULL))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
if(ImGui::Selectable(dialog.filePaths[i], i == dialog.selectedFileIndex,
|
||||
if(ImGui::Selectable(filePath, i == dialog.selectedFileIndex,
|
||||
ImGuiSelectableFlags_DontClosePopups))
|
||||
{
|
||||
dialog.selectedFileIndex = i;
|
||||
Q_strncpyz(dialog.fileName, dialog.filePaths[i], sizeof(dialog.fileName));
|
||||
Q_strncpyz(dialog.fileName, filePath, sizeof(dialog.fileName));
|
||||
}
|
||||
}
|
||||
ImGui::EndTable();
|
||||
|
@ -205,12 +218,26 @@ static bool DoFileDialog(FileDialog& dialog)
|
|||
|
||||
if(dialog.saveMode)
|
||||
{
|
||||
if(ImGui::IsWindowAppearing())
|
||||
{
|
||||
ImGui::SetKeyboardFocusHere();
|
||||
}
|
||||
if(ImGui::InputText(dialog.folderMode ? "Folder path" : "File path", dialog.fileName, sizeof(dialog.fileName)))
|
||||
{
|
||||
dialog.selectedFileIndex = -1;
|
||||
}
|
||||
|
||||
if(ImGui::Button("Save") &&
|
||||
bool save = false;
|
||||
if(ImGui::IsItemFocused() && ImGui::IsKeyPressed(ImGuiKey_Enter))
|
||||
{
|
||||
save = true;
|
||||
}
|
||||
if(ImGui::Button("Save"))
|
||||
{
|
||||
save = true;
|
||||
}
|
||||
|
||||
if(save &&
|
||||
dialog.fileName[0] != '\0' &&
|
||||
dialog.fileName[0] != '.')
|
||||
{
|
||||
|
@ -246,8 +273,18 @@ static bool DoFileDialog(FileDialog& dialog)
|
|||
}
|
||||
}
|
||||
|
||||
bool cancel = false;
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button("Cancel"))
|
||||
{
|
||||
cancel = true;
|
||||
}
|
||||
if(ImGui::IsKeyPressed(ImGuiKey_Escape, false))
|
||||
{
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(cancel)
|
||||
{
|
||||
FS_FreeFileList(dialog.filePaths);
|
||||
dialog.filePaths = NULL;
|
||||
|
|
Loading…
Reference in a new issue