1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Change file selector to work with callbacks.

This commit is contained in:
Bartosz Taudul
2022-10-06 17:35:07 +02:00
parent a4e39f3d5f
commit ec0757c03a
6 changed files with 82 additions and 94 deletions
+4 -8
View File
@@ -21,34 +21,30 @@ void Shutdown()
#endif
}
std::string OpenFile( const char* ext, const char* desc )
void OpenFile( const char* ext, const char* desc, std::function<void(const char*)> callback )
{
std::string ret;
#ifndef TRACY_NO_FILESELECTOR
nfdu8filteritem_t filter = { desc, ext };
nfdu8char_t* fn;
if( NFD_OpenDialogU8( &fn, &filter, 1, nullptr ) == NFD_OKAY )
{
ret.assign( fn );
callback( (const char*)fn );
NFD_FreePathU8( fn );
}
#endif
return ret;
}
std::string SaveFile( const char* ext, const char* desc )
void SaveFile( const char* ext, const char* desc, std::function<void(const char*)> callback )
{
std::string ret;
#ifndef TRACY_NO_FILESELECTOR
nfdu8filteritem_t filter = { desc, ext };
nfdu8char_t* fn;
if( NFD_SaveDialogU8( &fn, &filter, 1, nullptr, nullptr ) == NFD_OKAY )
{
ret.assign( fn );
callback( (const char*)fn );
NFD_FreePathU8( fn );
}
#endif
return ret;
}
}