fix custom screenshots and change screenshot directory (#3339)

This commit is contained in:
ManDude 2024-01-26 04:49:35 +00:00 committed by GitHub
parent 6f0d0fa417
commit 9aa291313b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 19 additions and 11 deletions

View file

@ -88,6 +88,11 @@ fs::path get_user_memcard_dir(GameVersion game_version) {
return get_user_config_dir() / game_version_name / "saves"; 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) { fs::path get_user_misc_dir(GameVersion game_version) {
auto game_version_name = game_version_names[game_version]; auto game_version_name = game_version_names[game_version];
return get_user_config_dir() / game_version_name / "misc"; return get_user_config_dir() / game_version_name / "misc";
@ -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 make_screenshot_filepath(const GameVersion game_version, const std::string& name) {
std::string file_name; std::string file_name;
if (name.empty()) { if (name.empty()) {
file_name = fmt::format("{}_{}.png", version_to_game_name(game_version), file_name = fmt::format("{}.png", str_util::current_local_timestamp_no_colons());
str_util::current_local_timestamp_no_colons());
} else { } else {
file_name = fmt::format("{}_{}_{}.png", version_to_game_name(game_version), name, file_name = fmt::format("{}.png", name);
str_util::current_local_timestamp_no_colons());
} }
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); 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) { std::string get_majority_file_line_endings(const std::string& file_contents) {

View file

@ -31,6 +31,7 @@ fs::path get_user_home_dir();
fs::path get_user_config_dir(); fs::path get_user_config_dir();
fs::path get_user_settings_dir(GameVersion game_version); fs::path get_user_settings_dir(GameVersion game_version);
fs::path get_user_memcard_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_user_misc_dir(GameVersion game_version);
fs::path get_jak_project_dir(); fs::path get_jak_project_dir();

View file

@ -883,8 +883,8 @@ void OpenGLRenderer::setup_frame(const RenderOptions& settings) {
m_fbo_state.render_fbo = &m_fbo_state.resources.render_buffer; m_fbo_state.render_fbo = &m_fbo_state.resources.render_buffer;
if (settings.msaa_samples != 1) { if (settings.msaa_samples != 1) {
lg::info("FBO Setup: using second temporary buffer: res: {}x{} {}x{}", window_fb.width, lg::info("FBO Setup: using second temporary buffer: res: {}x{}", settings.game_res_w,
window_fb.height, settings.game_res_w, settings.game_res_h); settings.game_res_h);
// we'll need a temporary fbo to do the msaa resolve step // we'll need a temporary fbo to do the msaa resolve step
// non-multisampled, and doesn't need z/stencil // non-multisampled, and doesn't need z/stencil

View file

@ -117,7 +117,7 @@ void OpenGlDebugGui::draw(const DmaStats& dma_stats) {
ImGui::InputInt("Width", &screenshot_width); ImGui::InputInt("Width", &screenshot_width);
ImGui::InputInt("Height", &screenshot_height); ImGui::InputInt("Height", &screenshot_height);
ImGui::InputInt("MSAA", &screenshot_samples); 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::EndMenu();
} }
ImGui::MenuItem("Subtitle Editor", nullptr, &m_subtitle_editor); ImGui::MenuItem("Subtitle Editor", nullptr, &m_subtitle_editor);

View file

@ -84,6 +84,6 @@ class OpenGlDebugGui {
bool m_subtitle_editor = false; bool m_subtitle_editor = false;
bool m_filters_menu = false; bool m_filters_menu = false;
bool m_want_screenshot = 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; float target_fps_input = 60.f;
}; };

View file

@ -130,8 +130,9 @@ static int gl_init(GfxGlobalSettings& settings) {
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0); SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0);
} }
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
#ifndef __APPLE__
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
#ifdef __APPLE__ #else
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
#endif #endif
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
@ -400,8 +401,11 @@ void render_game_frame(int game_width,
} }
if (g_gfx_data->debug_gui.get_screenshot_flag()) { if (g_gfx_data->debug_gui.get_screenshot_flag()) {
options.save_screenshot = true; options.save_screenshot = true;
options.internal_res_screenshot = true;
options.game_res_w = g_gfx_data->debug_gui.screenshot_width; options.game_res_w = g_gfx_data->debug_gui.screenshot_width;
options.game_res_h = g_gfx_data->debug_gui.screenshot_height; 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_width = options.game_res_w;
options.draw_region_height = options.game_res_h; options.draw_region_height = options.game_res_h;
options.msaa_samples = g_gfx_data->debug_gui.screenshot_samples; options.msaa_samples = g_gfx_data->debug_gui.screenshot_samples;