#include "../ta-utils.h" #include "imgui.h" #include #include "../pch.h" #if defined(_WIN32) || defined(_WIN64) || defined(__APPLE__) #ifndef SUPPORT_XP #define USE_NFD #endif #endif #ifdef USE_NFD #include #include #ifdef __APPLE__ #define NFD_NON_THREADED #endif #elif defined(ANDROID) #include #else namespace pfd { class open_file; class save_file; class select_folder; } #endif typedef std::function FileDialogSelectCallback; class FurnaceGUIFileDialog { bool sysDialog; bool opened; unsigned char dialogType; bool hasError; char noSysFilter[4096]; String curPath; std::vector fileName; #ifdef USE_NFD std::thread* dialogO; std::thread* dialogS; std::thread* dialogF; std::atomic dialogOK; std::vector nfdResult; #elif defined(ANDROID) JNIEnv* jniEnv; void* dialogO; void* dialogS; void* dialogF; #else pfd::open_file* dialogO; pfd::save_file* dialogS; pfd::select_folder* dialogF; #endif void convertFilterList(std::vector& filter); public: bool mobileUI; bool openLoad(String header, std::vector filter, String path, double dpiScale, FileDialogSelectCallback clickCallback=NULL, bool allowMultiple=false, String hint=""); bool openSave(String header, std::vector filter, String path, double dpiScale, String hint=""); bool openSelectDir(String header, String path, double dpiScale, String hint=""); bool accepted(); void close(); bool render(const ImVec2& min, const ImVec2& max); bool isOpen(); bool isError(); String getPath(); std::vector& getFileName(); explicit FurnaceGUIFileDialog(bool system): sysDialog(system), opened(false), dialogType(0), hasError(false), #ifdef ANDROID jniEnv(NULL), #endif dialogO(NULL), dialogS(NULL), mobileUI(false) {} };