Add SetMediaPath() to change screenshot/gif recording directory
This commit is contained in:
parent
f106301d46
commit
4127733677
|
|
@ -818,6 +818,7 @@ int InitPlatform(void)
|
|||
InitAssetManager(platform.app->activity->assetManager, platform.app->activity->internalDataPath); // Initialize assets manager
|
||||
|
||||
CORE.Storage.basePath = platform.app->activity->internalDataPath; // Define base path for storage
|
||||
strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1); // Define base path for media storage
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
TRACELOG(LOG_INFO, "PLATFORM: ANDROID: Initialized successfully");
|
||||
|
|
|
|||
|
|
@ -1759,6 +1759,7 @@ int InitPlatform(void)
|
|||
// Initialize storage system
|
||||
//----------------------------------------------------------------------------
|
||||
CORE.Storage.basePath = GetWorkingDirectory();
|
||||
strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1);
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
|
|
|
|||
|
|
@ -1394,6 +1394,7 @@ int InitPlatform(void)
|
|||
// Initialize storage system
|
||||
//----------------------------------------------------------------------------
|
||||
CORE.Storage.basePath = GetWorkingDirectory();
|
||||
strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1);
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#if defined(RGFW_WAYLAND)
|
||||
|
|
|
|||
|
|
@ -2116,6 +2116,7 @@ int InitPlatform(void)
|
|||
//----------------------------------------------------------------------------
|
||||
// Define base path for storage
|
||||
CORE.Storage.basePath = SDL_GetBasePath(); // Alternative: GetWorkingDirectory();
|
||||
strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1);
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#if defined(USING_VERSION_SDL3)
|
||||
|
|
|
|||
|
|
@ -1652,6 +1652,7 @@ int InitPlatform(void)
|
|||
// Initialize storage system
|
||||
//----------------------------------------------------------------------------
|
||||
CORE.Storage.basePath = GetWorkingDirectory();
|
||||
strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1);
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
TRACELOG(LOG_INFO, "PLATFORM: DESKTOP: WIN32: Initialized successfully");
|
||||
|
|
|
|||
|
|
@ -1609,6 +1609,7 @@ int InitPlatform(void)
|
|||
// Initialize storage system
|
||||
//----------------------------------------------------------------------------
|
||||
CORE.Storage.basePath = GetWorkingDirectory();
|
||||
strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1);
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#if defined(SUPPORT_DRM_CACHE)
|
||||
|
|
|
|||
|
|
@ -597,6 +597,7 @@ int InitPlatform(void)
|
|||
// TODO: Initialize storage system
|
||||
//----------------------------------------------------------------------------
|
||||
CORE.Storage.basePath = GetWorkingDirectory();
|
||||
strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1);
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
TRACELOG(LOG_INFO, "PLATFORM: CUSTOM: Initialized successfully");
|
||||
|
|
|
|||
|
|
@ -1388,6 +1388,7 @@ int InitPlatform(void)
|
|||
// Initialize storage system
|
||||
//----------------------------------------------------------------------------
|
||||
CORE.Storage.basePath = GetWorkingDirectory();
|
||||
strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1);
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
TRACELOG(LOG_INFO, "PLATFORM: WEB: Initialized successfully");
|
||||
|
|
|
|||
|
|
@ -1096,6 +1096,7 @@ RLAPI int *LoadRandomSequence(unsigned int count, int min, int max); // Load ran
|
|||
RLAPI void UnloadRandomSequence(int *sequence); // Unload random values sequence
|
||||
|
||||
// Misc. functions
|
||||
RLAPI void SetMediaPath(char *path); // Set media path for external files loading
|
||||
RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (filename extension defines format)
|
||||
RLAPI void SetConfigFlags(unsigned int flags); // Setup init configuration flags (view FLAGS)
|
||||
RLAPI void OpenURL(const char *url); // Open URL with default system browser (if available)
|
||||
|
|
|
|||
10
src/rcore.c
10
src/rcore.c
|
|
@ -318,6 +318,7 @@ typedef struct CoreData {
|
|||
} Window;
|
||||
struct {
|
||||
const char *basePath; // Base path for data storage
|
||||
char mediaPath[MAX_FILEPATH_LENGTH]; // Media path for data storage
|
||||
|
||||
} Storage;
|
||||
struct {
|
||||
|
|
@ -1011,7 +1012,7 @@ void EndDrawing(void)
|
|||
|
||||
MsfGifResult result = msf_gif_end(&gifState);
|
||||
|
||||
SaveFileData(TextFormat("%s/screenrec%03i.gif", CORE.Storage.basePath, screenshotCounter), result.data, (unsigned int)result.dataSize);
|
||||
SaveFileData(TextFormat("%s/screenrec%03i.gif", CORE.Storage.mediaPath, screenshotCounter), result.data, (unsigned int)result.dataSize);
|
||||
msf_gif_free(result);
|
||||
|
||||
TRACELOG(LOG_INFO, "SYSTEM: Finish animated GIF recording");
|
||||
|
|
@ -1909,7 +1910,7 @@ void TakeScreenshot(const char *fileName)
|
|||
Image image = { imgData, (int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y), 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };
|
||||
|
||||
char path[512] = { 0 };
|
||||
strcpy(path, TextFormat("%s/%s", CORE.Storage.basePath, fileName));
|
||||
strcpy(path, TextFormat("%s/%s", CORE.Storage.mediaPath, fileName));
|
||||
|
||||
ExportImage(image, path); // WARNING: Module required: rtextures
|
||||
RL_FREE(imgData);
|
||||
|
|
@ -1921,6 +1922,11 @@ void TakeScreenshot(const char *fileName)
|
|||
#endif
|
||||
}
|
||||
|
||||
void SetMediaPath(char *path)
|
||||
{
|
||||
snprintf(CORE.Storage.mediaPath, MAX_FILEPATH_LENGTH, "%s", path);
|
||||
}
|
||||
|
||||
// Setup window configuration flags (view FLAGS)
|
||||
// NOTE: This function is expected to be called before window creation,
|
||||
// because it sets up some flags for the window creation process
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user