Add SetMediaPath() to change screenshot/gif recording directory

This commit is contained in:
Anthony Samms 2025-10-28 16:59:44 -04:00
parent f106301d46
commit 4127733677
10 changed files with 18 additions and 3 deletions

View File

@ -818,6 +818,7 @@ int InitPlatform(void)
InitAssetManager(platform.app->activity->assetManager, platform.app->activity->internalDataPath); // Initialize assets manager InitAssetManager(platform.app->activity->assetManager, platform.app->activity->internalDataPath); // Initialize assets manager
CORE.Storage.basePath = platform.app->activity->internalDataPath; // Define base path for storage 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"); TRACELOG(LOG_INFO, "PLATFORM: ANDROID: Initialized successfully");

View File

@ -1759,6 +1759,7 @@ int InitPlatform(void)
// Initialize storage system // Initialize storage system
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
CORE.Storage.basePath = GetWorkingDirectory(); CORE.Storage.basePath = GetWorkingDirectory();
strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1);
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
#if defined(__NetBSD__) #if defined(__NetBSD__)

View File

@ -1394,6 +1394,7 @@ int InitPlatform(void)
// Initialize storage system // Initialize storage system
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
CORE.Storage.basePath = GetWorkingDirectory(); CORE.Storage.basePath = GetWorkingDirectory();
strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1);
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
#if defined(RGFW_WAYLAND) #if defined(RGFW_WAYLAND)

View File

@ -2116,6 +2116,7 @@ int InitPlatform(void)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Define base path for storage // Define base path for storage
CORE.Storage.basePath = SDL_GetBasePath(); // Alternative: GetWorkingDirectory(); CORE.Storage.basePath = SDL_GetBasePath(); // Alternative: GetWorkingDirectory();
strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1);
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
#if defined(USING_VERSION_SDL3) #if defined(USING_VERSION_SDL3)

View File

@ -1652,6 +1652,7 @@ int InitPlatform(void)
// Initialize storage system // Initialize storage system
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
CORE.Storage.basePath = GetWorkingDirectory(); CORE.Storage.basePath = GetWorkingDirectory();
strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1);
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
TRACELOG(LOG_INFO, "PLATFORM: DESKTOP: WIN32: Initialized successfully"); TRACELOG(LOG_INFO, "PLATFORM: DESKTOP: WIN32: Initialized successfully");

View File

@ -1609,6 +1609,7 @@ int InitPlatform(void)
// Initialize storage system // Initialize storage system
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
CORE.Storage.basePath = GetWorkingDirectory(); CORE.Storage.basePath = GetWorkingDirectory();
strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1);
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
#if defined(SUPPORT_DRM_CACHE) #if defined(SUPPORT_DRM_CACHE)

View File

@ -597,6 +597,7 @@ int InitPlatform(void)
// TODO: Initialize storage system // TODO: Initialize storage system
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
CORE.Storage.basePath = GetWorkingDirectory(); CORE.Storage.basePath = GetWorkingDirectory();
strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1);
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
TRACELOG(LOG_INFO, "PLATFORM: CUSTOM: Initialized successfully"); TRACELOG(LOG_INFO, "PLATFORM: CUSTOM: Initialized successfully");

View File

@ -1388,6 +1388,7 @@ int InitPlatform(void)
// Initialize storage system // Initialize storage system
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
CORE.Storage.basePath = GetWorkingDirectory(); CORE.Storage.basePath = GetWorkingDirectory();
strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1);
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
TRACELOG(LOG_INFO, "PLATFORM: WEB: Initialized successfully"); TRACELOG(LOG_INFO, "PLATFORM: WEB: Initialized successfully");

View File

@ -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 RLAPI void UnloadRandomSequence(int *sequence); // Unload random values sequence
// Misc. functions // 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 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 SetConfigFlags(unsigned int flags); // Setup init configuration flags (view FLAGS)
RLAPI void OpenURL(const char *url); // Open URL with default system browser (if available) RLAPI void OpenURL(const char *url); // Open URL with default system browser (if available)

View File

@ -317,7 +317,8 @@ typedef struct CoreData {
} Window; } Window;
struct { struct {
const char *basePath; // Base path for data storage const char *basePath; // Base path for data storage
char mediaPath[MAX_FILEPATH_LENGTH]; // Media path for data storage
} Storage; } Storage;
struct { struct {
@ -1011,7 +1012,7 @@ void EndDrawing(void)
MsfGifResult result = msf_gif_end(&gifState); 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); msf_gif_free(result);
TRACELOG(LOG_INFO, "SYSTEM: Finish animated GIF recording"); 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 }; 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 }; 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 ExportImage(image, path); // WARNING: Module required: rtextures
RL_FREE(imgData); RL_FREE(imgData);
@ -1921,6 +1922,11 @@ void TakeScreenshot(const char *fileName)
#endif #endif
} }
void SetMediaPath(char *path)
{
snprintf(CORE.Storage.mediaPath, MAX_FILEPATH_LENGTH, "%s", path);
}
// Setup window configuration flags (view FLAGS) // Setup window configuration flags (view FLAGS)
// NOTE: This function is expected to be called before window creation, // NOTE: This function is expected to be called before window creation,
// because it sets up some flags for the window creation process // because it sets up some flags for the window creation process