diff --git a/include/app/app.h b/include/app/app.h index 04d4f43..469e6d2 100644 --- a/include/app/app.h +++ b/include/app/app.h @@ -260,6 +260,16 @@ struct settings { // Hide the cursor after a few seconds of inactivity bool hide_cursor_when_mouse_inactive; + // If set, use the system screenshot directory. + // Otherwise, use the one specified by `screenshot_dir`. + // TODO: Move this elsewhere + bool use_system_screenshot_dir_path; + + // Screenshot directory + // Only relevant if `use_system_screenshot_dir` is set. + // TODO: Move this elsewhere + char *screenshot_dir_path; + /* ** Debug */ diff --git a/source/app/config.c b/source/app/config.c index 4d4f545..6c69ec3 100644 --- a/source/app/config.c +++ b/source/app/config.c @@ -127,6 +127,7 @@ app_config_load( // Video { + char str[4096]; int b; double d; @@ -180,9 +181,18 @@ app_config_load( if (mjson_get_bool(data, data_len, "$.video.hide_cursor_when_mouse_inactive", &b)) { app->settings.video.hide_cursor_when_mouse_inactive = b; } + + if (mjson_get_bool(data, data_len, "$.video.use_system_screenshot_dir_path", &b)) { + app->settings.video.use_system_screenshot_dir_path = b; + } + + if (mjson_get_string(data, data_len, "$.video.screenshot_dir_path", str, sizeof(str)) > 0) { + free(app->settings.video.screenshot_dir_path); + app->settings.video.screenshot_dir_path = strdup(str); + } } - // Video + // Audio { int b; double d; @@ -344,7 +354,9 @@ app_config_save( "texture_filter": %d, "pixel_color_filter": %d, "pixel_scaling_filter": %d, - "hide_cursor_when_mouse_inactive": %B + "hide_cursor_when_mouse_inactive": %B, + "use_system_screenshot_dir_path": %B, + "screenshot_dir_path": %Q }, // Audio @@ -387,6 +399,8 @@ app_config_save( (int)app->settings.video.pixel_color_filter, (int)app->settings.video.pixel_scaling_filter, (int)app->settings.video.hide_cursor_when_mouse_inactive, + (int)app->settings.video.use_system_screenshot_dir_path, + app->settings.video.screenshot_dir_path, (int)app->settings.audio.mute, app->settings.audio.level ); diff --git a/source/app/main.c b/source/app/main.c index b0e9a69..a304b16 100644 --- a/source/app/main.c +++ b/source/app/main.c @@ -80,6 +80,8 @@ app_settings_default( settings->video.pixel_color_filter = PIXEL_COLOR_FILTER_COLOR_CORRECTION; settings->video.pixel_scaling_filter = PIXEL_SCALING_FILTER_LCD_GRID; settings->video.hide_cursor_when_mouse_inactive = true; + settings->video.use_system_screenshot_dir_path = true; + settings->video.screenshot_dir_path = strdup("./screenshots/"); settings->audio.mute = false; settings->audio.level = 1.0f; } diff --git a/source/app/path.c b/source/app/path.c index f019597..2cedc73 100644 --- a/source/app/path.c +++ b/source/app/path.c @@ -154,5 +154,8 @@ char const * app_path_screenshots( struct app *app ) { - return (app->file.sys_pictures_dir_path ?: "screeenshots"); + if (!app->settings.video.use_system_screenshot_dir_path && app->settings.video.screenshot_dir_path) { + return (app->settings.video.screenshot_dir_path); + } + return app->file.sys_pictures_dir_path ?: "screeenshots"; } diff --git a/source/app/windows/settings.c b/source/app/windows/settings.c index b0ef35f..ecef380 100644 --- a/source/app/windows/settings.c +++ b/source/app/windows/settings.c @@ -583,6 +583,44 @@ app_win_settings_video( igTableSetupColumn("##VideoSettingsMiscLabel", ImGuiTableColumnFlags_WidthFixed, vp->WorkSize.x / 5.f, 0); igTableSetupColumn("##VideoSettingsMiscValue", ImGuiTableColumnFlags_WidthStretch, 0.f, 0); + // Use System Directory For Screenshots + igTableNextRow(ImGuiTableRowFlags_None, 0.f); + igTableNextColumn(); + igTextWrapped("Use System Directory For Screenshots"); + + igTableNextColumn(); + igCheckbox("##UseSystemDirectoryForScreenshots", &app->settings.video.use_system_screenshot_dir_path); + + // Screenshot Directory + igTableNextRow(ImGuiTableRowFlags_None, 0.f); + igTableNextColumn(); + igTextWrapped("Screenshot Directory"); + + igBeginDisabled(app->settings.video.use_system_screenshot_dir_path); + + igTableNextColumn(); + igBeginDisabled(true); + igInputText("##ScreenshotDirectory", app->settings.video.screenshot_dir_path, strlen(app->settings.video.screenshot_dir_path), ImGuiInputTextFlags_ReadOnly, NULL, NULL); + igEndDisabled(); + igSameLine(0.0f, -1.0f); + if (igButton("Choose", (ImVec2){ 50.f, 0.f})) { + nfdresult_t result; + nfdchar_t *path; + + result = NFD_PickFolder( + &path, + app->settings.video.screenshot_dir_path + ); + + if (result == NFD_OKAY) { + free(app->settings.video.screenshot_dir_path); + app->settings.video.screenshot_dir_path = strdup(path); + NFD_FreePath(path); + } + } + + igEndDisabled(); + // Hide the cursor when the mouse is inactive igTableNextRow(ImGuiTableRowFlags_None, 0.f); igTableNextColumn();