mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 14:44:34 +00:00
Expose internal file selector failure state.
This commit is contained in:
parent
fbfd7e5186
commit
11cafbff1d
@ -11,6 +11,8 @@
|
||||
namespace tracy::Fileselector
|
||||
{
|
||||
|
||||
static bool s_hasFailed = false;
|
||||
|
||||
void Init()
|
||||
{
|
||||
#if !defined TRACY_NO_FILESELECTOR && !defined __EMSCRIPTEN__
|
||||
@ -25,6 +27,19 @@ void Shutdown()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool HasFailed()
|
||||
{
|
||||
if( s_hasFailed )
|
||||
{
|
||||
s_hasFailed = false;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
static std::function<void(const char*)> s_openFileCallback;
|
||||
|
||||
@ -35,7 +50,7 @@ extern "C" int nativeOpenFile()
|
||||
}
|
||||
#endif
|
||||
|
||||
bool OpenFile( const char* ext, const char* desc, std::function<void(const char*)> callback )
|
||||
static bool OpenFileImpl( const char* ext, const char* desc, std::function<void(const char*)> callback )
|
||||
{
|
||||
#ifndef TRACY_NO_FILESELECTOR
|
||||
# ifdef __EMSCRIPTEN__
|
||||
@ -73,7 +88,7 @@ bool OpenFile( const char* ext, const char* desc, std::function<void(const char*
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SaveFile( const char* ext, const char* desc, std::function<void(const char*)> callback )
|
||||
static bool SaveFileImpl( const char* ext, const char* desc, std::function<void(const char*)> callback )
|
||||
{
|
||||
#if !defined TRACY_NO_FILESELECTOR && !defined __EMSCRIPTEN__
|
||||
nfdu8filteritem_t filter = { desc, ext };
|
||||
@ -88,4 +103,14 @@ bool SaveFile( const char* ext, const char* desc, std::function<void(const char*
|
||||
return false;
|
||||
}
|
||||
|
||||
void OpenFile( const char* ext, const char* desc, std::function<void(const char*)> callback )
|
||||
{
|
||||
if( !OpenFileImpl( ext, desc, callback ) ) s_hasFailed = true;
|
||||
}
|
||||
|
||||
void SaveFile( const char* ext, const char* desc, std::function<void(const char*)> callback )
|
||||
{
|
||||
if( !SaveFileImpl( ext, desc, callback ) ) s_hasFailed = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,10 +8,10 @@ namespace tracy::Fileselector
|
||||
|
||||
void Init();
|
||||
void Shutdown();
|
||||
bool HasFailed();
|
||||
|
||||
// Will return false if file selector cannot be presented to the user.
|
||||
bool OpenFile( const char* ext, const char* desc, std::function<void(const char*)> callback );
|
||||
bool SaveFile( const char* ext, const char* desc, std::function<void(const char*)> callback );
|
||||
void OpenFile( const char* ext, const char* desc, std::function<void(const char*)> callback );
|
||||
void SaveFile( const char* ext, const char* desc, std::function<void(const char*)> callback );
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user