mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-07 12:05:52 +00:00
System: Pull screenshot format from path extension
This commit is contained in:
parent
1f10cac42a
commit
437430cbc4
@ -2131,6 +2131,21 @@ const char* Settings::GetDisplayScreenshotFormatExtension(DisplayScreenshotForma
|
|||||||
return s_display_screenshot_format_extensions[static_cast<size_t>(format)];
|
return s_display_screenshot_format_extensions[static_cast<size_t>(format)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<DisplayScreenshotFormat> Settings::GetDisplayScreenshotFormatFromFileName(const std::string_view filename)
|
||||||
|
{
|
||||||
|
const std::string_view extension = Path::GetExtension(filename);
|
||||||
|
int index = 0;
|
||||||
|
for (const char* name : s_display_screenshot_format_extensions)
|
||||||
|
{
|
||||||
|
if (StringUtil::EqualNoCase(extension, name))
|
||||||
|
return static_cast<DisplayScreenshotFormat>(index);
|
||||||
|
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
static constexpr const std::array s_memory_card_type_names = {
|
static constexpr const std::array s_memory_card_type_names = {
|
||||||
"None", "Shared", "PerGame", "PerGameTitle", "PerGameFileTitle", "NonPersistent",
|
"None", "Shared", "PerGame", "PerGameTitle", "PerGameFileTitle", "NonPersistent",
|
||||||
};
|
};
|
||||||
|
@ -547,6 +547,7 @@ struct Settings : public GPUSettings
|
|||||||
static const char* GetDisplayScreenshotFormatName(DisplayScreenshotFormat mode);
|
static const char* GetDisplayScreenshotFormatName(DisplayScreenshotFormat mode);
|
||||||
static const char* GetDisplayScreenshotFormatDisplayName(DisplayScreenshotFormat mode);
|
static const char* GetDisplayScreenshotFormatDisplayName(DisplayScreenshotFormat mode);
|
||||||
static const char* GetDisplayScreenshotFormatExtension(DisplayScreenshotFormat mode);
|
static const char* GetDisplayScreenshotFormatExtension(DisplayScreenshotFormat mode);
|
||||||
|
static std::optional<DisplayScreenshotFormat> GetDisplayScreenshotFormatFromFileName(const std::string_view filename);
|
||||||
|
|
||||||
static std::optional<MemoryCardType> ParseMemoryCardTypeName(const char* str);
|
static std::optional<MemoryCardType> ParseMemoryCardTypeName(const char* str);
|
||||||
static const char* GetMemoryCardTypeName(MemoryCardType type);
|
static const char* GetMemoryCardTypeName(MemoryCardType type);
|
||||||
|
@ -5277,8 +5277,16 @@ void System::SaveScreenshot(const char* path, DisplayScreenshotMode mode, Displa
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
std::string auto_path;
|
std::string auto_path;
|
||||||
if (!path)
|
if (!path || path[0] == '\0')
|
||||||
|
{
|
||||||
path = (auto_path = GetScreenshotPath(Settings::GetDisplayScreenshotFormatExtension(format))).c_str();
|
path = (auto_path = GetScreenshotPath(Settings::GetDisplayScreenshotFormatExtension(format))).c_str();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If the user chose a specific format, use that.
|
||||||
|
format =
|
||||||
|
Settings::GetDisplayScreenshotFormatFromFileName(FileSystem::GetDisplayNameFromPath(path)).value_or(format);
|
||||||
|
}
|
||||||
|
|
||||||
GPUBackend::RenderScreenshotToFile(path, mode, quality, true);
|
GPUBackend::RenderScreenshotToFile(path, mode, quality, true);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user