mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-27 15:03:01 +00:00
Furnace has stopped.
• Diagnose later
This commit is contained in:
parent
e75d1ef411
commit
6a6ca22ebe
3 changed files with 60 additions and 2 deletions
|
@ -4,6 +4,8 @@
|
|||
|
||||
#ifdef USE_NFD
|
||||
#include <nfd.h>
|
||||
#elif defined(ANDROID)
|
||||
#include <SDL.h>
|
||||
#else
|
||||
#include "../../extern/pfd-fixed/portable-file-dialogs.h"
|
||||
#endif
|
||||
|
@ -87,6 +89,45 @@ bool FurnaceGUIFileDialog::openLoad(String header, std::vector<String> filter, c
|
|||
#else
|
||||
dialogO=new std::thread(_nfdThread,NFDState(false,header,filter,path,clickCallback,allowMultiple),&dialogOK,&nfdResult,&hasError);
|
||||
#endif
|
||||
#elif defined(ANDROID)
|
||||
hasError=false;
|
||||
if (jniEnv==NULL) {
|
||||
jniEnv=(JNIEnv*)SDL_AndroidGetJNIEnv();
|
||||
if (jniEnv==NULL) {
|
||||
hasError=true;
|
||||
logE("could not acquire JNI env!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
jobject activity=(jobject)SDL_AndroidGetActivity();
|
||||
if (activity==NULL) {
|
||||
hasError=true;
|
||||
logE("the Activity is NULL!");
|
||||
return false;
|
||||
}
|
||||
|
||||
jclass class_=jniEnv->GetObjectClass(activity);
|
||||
jmethodID showFileDialog=jniEnv->GetMethodID(class_,"showFileDialog","()B");
|
||||
|
||||
if (showFileDialog==NULL) {
|
||||
logE("method showFileDialog not found!");
|
||||
hasError=true;
|
||||
jniEnv->DeleteLocalRef(class_);
|
||||
jniEnv->DeleteLocalRef(activity);
|
||||
return false;
|
||||
}
|
||||
|
||||
jboolean mret=jniEnv->CallBooleanMethod(activity,showFileDialog);
|
||||
|
||||
if (!(bool)mret) {
|
||||
hasError=true;
|
||||
logW("could not open Android file picker...");
|
||||
}
|
||||
|
||||
jniEnv->DeleteLocalRef(class_);
|
||||
jniEnv->DeleteLocalRef(activity);
|
||||
return true;
|
||||
#else
|
||||
dialogO=new pfd::open_file(header,path,filter,allowMultiple?(pfd::opt::multiselect):(pfd::opt::none));
|
||||
hasError=!pfd::settings::available();
|
||||
|
@ -113,6 +154,8 @@ bool FurnaceGUIFileDialog::openSave(String header, std::vector<String> filter, c
|
|||
#else
|
||||
dialogS=new std::thread(_nfdThread,NFDState(true,header,filter,path,NULL,false),&dialogOK,&nfdResult,&hasError);
|
||||
#endif
|
||||
#elif defined(ANDROID)
|
||||
hasError=true; // TODO
|
||||
#else
|
||||
dialogS=new pfd::save_file(header,path,filter);
|
||||
hasError=!pfd::settings::available();
|
||||
|
@ -141,7 +184,9 @@ void FurnaceGUIFileDialog::close() {
|
|||
#ifdef USE_NFD
|
||||
dialogS->join();
|
||||
#endif
|
||||
#ifndef ANDROID
|
||||
delete dialogS;
|
||||
#endif
|
||||
dialogS=NULL;
|
||||
}
|
||||
} else {
|
||||
|
@ -149,7 +194,9 @@ void FurnaceGUIFileDialog::close() {
|
|||
#ifdef USE_NFD
|
||||
dialogO->join();
|
||||
#endif
|
||||
#ifndef ANDROID
|
||||
delete dialogO;
|
||||
#endif
|
||||
dialogO=NULL;
|
||||
}
|
||||
}
|
||||
|
@ -179,6 +226,9 @@ bool FurnaceGUIFileDialog::render(const ImVec2& min, const ImVec2& max) {
|
|||
return true;
|
||||
}
|
||||
return false;
|
||||
#elif defined(ANDROID)
|
||||
// TODO: detect when file picker is closed
|
||||
return false;
|
||||
#else
|
||||
if (saving) {
|
||||
if (dialogS!=NULL) {
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#define NFD_NON_THREADED
|
||||
#endif
|
||||
|
||||
#elif defined(ANDROID)
|
||||
#include <jni.h>
|
||||
#else
|
||||
namespace pfd {
|
||||
class open_file;
|
||||
|
@ -36,6 +38,10 @@ class FurnaceGUIFileDialog {
|
|||
std::thread* dialogS;
|
||||
std::atomic<bool> dialogOK;
|
||||
std::vector<String> nfdResult;
|
||||
#elif defined(ANDROID)
|
||||
JNIEnv* jniEnv;
|
||||
void* dialogO;
|
||||
void* dialogS;
|
||||
#else
|
||||
pfd::open_file* dialogO;
|
||||
pfd::save_file* dialogS;
|
||||
|
@ -55,6 +61,9 @@ class FurnaceGUIFileDialog {
|
|||
opened(false),
|
||||
saving(false),
|
||||
hasError(false),
|
||||
#ifdef ANDROID
|
||||
jniEnv(NULL),
|
||||
#endif
|
||||
dialogO(NULL),
|
||||
dialogS(NULL) {}
|
||||
};
|
||||
|
|
|
@ -40,9 +40,8 @@
|
|||
#define POWER_SAVE_DEFAULT 0
|
||||
#endif
|
||||
|
||||
#if defined(__HAIKU__) || defined(IS_MOBILE)
|
||||
#if defined(__HAIKU__)
|
||||
// NFD doesn't support Haiku
|
||||
// I still haven't implemented Android file picker
|
||||
#define SYS_FILE_DIALOG_DEFAULT 0
|
||||
#else
|
||||
#define SYS_FILE_DIALOG_DEFAULT 1
|
||||
|
|
Loading…
Reference in a new issue