Skip to content

Commit 9aa2913

Browse files
authored
fix custom screenshots and change screenshot directory (#3339)
1 parent 6f0d0fa commit 9aa2913

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

common/util/FileUtil.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ fs::path get_user_memcard_dir(GameVersion game_version) {
8888
return get_user_config_dir() / game_version_name / "saves";
8989
}
9090

91+
fs::path get_user_screenshots_dir(GameVersion game_version) {
92+
auto game_version_name = game_version_names[game_version];
93+
return get_user_config_dir() / game_version_name / "screenshots";
94+
}
95+
9196
fs::path get_user_misc_dir(GameVersion game_version) {
9297
auto game_version_name = game_version_names[game_version];
9398
return get_user_config_dir() / game_version_name / "misc";
@@ -695,15 +700,13 @@ void copy_file(const fs::path& src, const fs::path& dst) {
695700
std::string make_screenshot_filepath(const GameVersion game_version, const std::string& name) {
696701
std::string file_name;
697702
if (name.empty()) {
698-
file_name = fmt::format("{}_{}.png", version_to_game_name(game_version),
699-
str_util::current_local_timestamp_no_colons());
703+
file_name = fmt::format("{}.png", str_util::current_local_timestamp_no_colons());
700704
} else {
701-
file_name = fmt::format("{}_{}_{}.png", version_to_game_name(game_version), name,
702-
str_util::current_local_timestamp_no_colons());
705+
file_name = fmt::format("{}.png", name);
703706
}
704-
const auto file_path = file_util::get_file_path({"screenshots", file_name});
707+
const auto file_path = get_user_screenshots_dir(game_version) / file_name;
705708
file_util::create_dir_if_needed_for_file(file_path);
706-
return file_path;
709+
return file_path.string();
707710
}
708711

709712
std::string get_majority_file_line_endings(const std::string& file_contents) {

common/util/FileUtil.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ fs::path get_user_home_dir();
3131
fs::path get_user_config_dir();
3232
fs::path get_user_settings_dir(GameVersion game_version);
3333
fs::path get_user_memcard_dir(GameVersion game_version);
34+
fs::path get_user_screenshots_dir(GameVersion game_version);
3435
fs::path get_user_misc_dir(GameVersion game_version);
3536
fs::path get_jak_project_dir();
3637

game/graphics/opengl_renderer/OpenGLRenderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,8 @@ void OpenGLRenderer::setup_frame(const RenderOptions& settings) {
883883
m_fbo_state.render_fbo = &m_fbo_state.resources.render_buffer;
884884

885885
if (settings.msaa_samples != 1) {
886-
lg::info("FBO Setup: using second temporary buffer: res: {}x{} {}x{}", window_fb.width,
887-
window_fb.height, settings.game_res_w, settings.game_res_h);
886+
lg::info("FBO Setup: using second temporary buffer: res: {}x{}", settings.game_res_w,
887+
settings.game_res_h);
888888

889889
// we'll need a temporary fbo to do the msaa resolve step
890890
// non-multisampled, and doesn't need z/stencil

game/graphics/opengl_renderer/debug_gui.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void OpenGlDebugGui::draw(const DmaStats& dma_stats) {
117117
ImGui::InputInt("Width", &screenshot_width);
118118
ImGui::InputInt("Height", &screenshot_height);
119119
ImGui::InputInt("MSAA", &screenshot_samples);
120-
ImGui::Checkbox("Screenshot on F2", &screenshot_hotkey_enabled);
120+
ImGui::Checkbox("Quick-Screenshot on F2", &screenshot_hotkey_enabled);
121121
ImGui::EndMenu();
122122
}
123123
ImGui::MenuItem("Subtitle Editor", nullptr, &m_subtitle_editor);

game/graphics/opengl_renderer/debug_gui.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ class OpenGlDebugGui {
8484
bool m_subtitle_editor = false;
8585
bool m_filters_menu = false;
8686
bool m_want_screenshot = false;
87-
char m_screenshot_save_name[256] = "screenshot.png";
87+
char m_screenshot_save_name[256] = "screenshot";
8888
float target_fps_input = 60.f;
8989
};

game/graphics/pipelines/opengl.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ static int gl_init(GfxGlobalSettings& settings) {
130130
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0);
131131
}
132132
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
133+
#ifndef __APPLE__
133134
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
134-
#ifdef __APPLE__
135+
#else
135136
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
136137
#endif
137138
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
@@ -400,8 +401,11 @@ void render_game_frame(int game_width,
400401
}
401402
if (g_gfx_data->debug_gui.get_screenshot_flag()) {
402403
options.save_screenshot = true;
404+
options.internal_res_screenshot = true;
403405
options.game_res_w = g_gfx_data->debug_gui.screenshot_width;
404406
options.game_res_h = g_gfx_data->debug_gui.screenshot_height;
407+
options.window_framebuffer_width = options.game_res_w;
408+
options.window_framebuffer_height = options.game_res_h;
405409
options.draw_region_width = options.game_res_w;
406410
options.draw_region_height = options.game_res_h;
407411
options.msaa_samples = g_gfx_data->debug_gui.screenshot_samples;

0 commit comments

Comments
 (0)