Skip to content

Commit

Permalink
fix custom screenshots and change screenshot directory (#3339)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManDude authored Jan 26, 2024
1 parent 6f0d0fa commit 9aa2913
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
15 changes: 9 additions & 6 deletions common/util/FileUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ fs::path get_user_memcard_dir(GameVersion game_version) {
return get_user_config_dir() / game_version_name / "saves";
}

fs::path get_user_screenshots_dir(GameVersion game_version) {
auto game_version_name = game_version_names[game_version];
return get_user_config_dir() / game_version_name / "screenshots";
}

fs::path get_user_misc_dir(GameVersion game_version) {
auto game_version_name = game_version_names[game_version];
return get_user_config_dir() / game_version_name / "misc";
Expand Down Expand Up @@ -695,15 +700,13 @@ void copy_file(const fs::path& src, const fs::path& dst) {
std::string make_screenshot_filepath(const GameVersion game_version, const std::string& name) {
std::string file_name;
if (name.empty()) {
file_name = fmt::format("{}_{}.png", version_to_game_name(game_version),
str_util::current_local_timestamp_no_colons());
file_name = fmt::format("{}.png", str_util::current_local_timestamp_no_colons());
} else {
file_name = fmt::format("{}_{}_{}.png", version_to_game_name(game_version), name,
str_util::current_local_timestamp_no_colons());
file_name = fmt::format("{}.png", name);
}
const auto file_path = file_util::get_file_path({"screenshots", file_name});
const auto file_path = get_user_screenshots_dir(game_version) / file_name;
file_util::create_dir_if_needed_for_file(file_path);
return file_path;
return file_path.string();
}

std::string get_majority_file_line_endings(const std::string& file_contents) {
Expand Down
1 change: 1 addition & 0 deletions common/util/FileUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fs::path get_user_home_dir();
fs::path get_user_config_dir();
fs::path get_user_settings_dir(GameVersion game_version);
fs::path get_user_memcard_dir(GameVersion game_version);
fs::path get_user_screenshots_dir(GameVersion game_version);
fs::path get_user_misc_dir(GameVersion game_version);
fs::path get_jak_project_dir();

Expand Down
4 changes: 2 additions & 2 deletions game/graphics/opengl_renderer/OpenGLRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,8 +883,8 @@ void OpenGLRenderer::setup_frame(const RenderOptions& settings) {
m_fbo_state.render_fbo = &m_fbo_state.resources.render_buffer;

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

// we'll need a temporary fbo to do the msaa resolve step
// non-multisampled, and doesn't need z/stencil
Expand Down
2 changes: 1 addition & 1 deletion game/graphics/opengl_renderer/debug_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void OpenGlDebugGui::draw(const DmaStats& dma_stats) {
ImGui::InputInt("Width", &screenshot_width);
ImGui::InputInt("Height", &screenshot_height);
ImGui::InputInt("MSAA", &screenshot_samples);
ImGui::Checkbox("Screenshot on F2", &screenshot_hotkey_enabled);
ImGui::Checkbox("Quick-Screenshot on F2", &screenshot_hotkey_enabled);
ImGui::EndMenu();
}
ImGui::MenuItem("Subtitle Editor", nullptr, &m_subtitle_editor);
Expand Down
2 changes: 1 addition & 1 deletion game/graphics/opengl_renderer/debug_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ class OpenGlDebugGui {
bool m_subtitle_editor = false;
bool m_filters_menu = false;
bool m_want_screenshot = false;
char m_screenshot_save_name[256] = "screenshot.png";
char m_screenshot_save_name[256] = "screenshot";
float target_fps_input = 60.f;
};
6 changes: 5 additions & 1 deletion game/graphics/pipelines/opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ static int gl_init(GfxGlobalSettings& settings) {
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0);
}
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
#ifndef __APPLE__
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
#ifdef __APPLE__
#else
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
#endif
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
Expand Down Expand Up @@ -400,8 +401,11 @@ void render_game_frame(int game_width,
}
if (g_gfx_data->debug_gui.get_screenshot_flag()) {
options.save_screenshot = true;
options.internal_res_screenshot = true;
options.game_res_w = g_gfx_data->debug_gui.screenshot_width;
options.game_res_h = g_gfx_data->debug_gui.screenshot_height;
options.window_framebuffer_width = options.game_res_w;
options.window_framebuffer_height = options.game_res_h;
options.draw_region_width = options.game_res_w;
options.draw_region_height = options.game_res_h;
options.msaa_samples = g_gfx_data->debug_gui.screenshot_samples;
Expand Down

0 comments on commit 9aa2913

Please sign in to comment.