mirror of
https://github.com/stenzek/duckstation.git
synced 2024-12-03 11:30:49 +00:00
Postprocessing/FX: Fix locating shaders in subdirectories
This commit is contained in:
parent
63055f1e7f
commit
ea3fa7fe3d
@ -1,8 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
|
||||
#include "assert.h"
|
||||
#include "string_util.h"
|
||||
#include "assert.h"
|
||||
|
||||
#include <cctype>
|
||||
#include <codecvt>
|
||||
@ -306,6 +306,22 @@ void StringUtil::ReplaceAll(std::string* subject, const std::string_view search,
|
||||
}
|
||||
}
|
||||
|
||||
std::string StringUtil::ReplaceAll(const std::string_view subject, const char search, const char replacement)
|
||||
{
|
||||
std::string ret(subject);
|
||||
ReplaceAll(&ret, search, replacement);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void StringUtil::ReplaceAll(std::string* subject, const char search, const char replacement)
|
||||
{
|
||||
for (size_t i = 0; i < subject->length(); i++)
|
||||
{
|
||||
const char ch = (*subject)[i];
|
||||
(*subject)[i] = (ch == search) ? replacement : ch;
|
||||
}
|
||||
}
|
||||
|
||||
bool StringUtil::ParseAssignmentString(const std::string_view str, std::string_view* key, std::string_view* value)
|
||||
{
|
||||
const std::string_view::size_type pos = str.find('=');
|
||||
|
@ -223,8 +223,10 @@ std::string_view StripWhitespace(const std::string_view str);
|
||||
void StripWhitespace(std::string* str);
|
||||
|
||||
/// Splits a string based on a single character delimiter.
|
||||
std::vector<std::string_view> SplitString(const std::string_view str, char delimiter, bool skip_empty = true);
|
||||
std::vector<std::string> SplitNewString(const std::string_view str, char delimiter, bool skip_empty = true);
|
||||
[[nodiscard]] std::vector<std::string_view> SplitString(const std::string_view str, char delimiter,
|
||||
bool skip_empty = true);
|
||||
[[nodiscard]] std::vector<std::string> SplitNewString(const std::string_view str, char delimiter,
|
||||
bool skip_empty = true);
|
||||
|
||||
/// Joins a string together using the specified delimiter.
|
||||
template<typename T>
|
||||
@ -253,9 +255,11 @@ static inline std::string JoinString(const T& start, const T& end, const std::st
|
||||
}
|
||||
|
||||
/// Replaces all instances of search in subject with replacement.
|
||||
std::string ReplaceAll(const std::string_view subject, const std::string_view search,
|
||||
const std::string_view replacement);
|
||||
[[nodiscard]] std::string ReplaceAll(const std::string_view subject, const std::string_view search,
|
||||
const std::string_view replacement);
|
||||
void ReplaceAll(std::string* subject, const std::string_view search, const std::string_view replacement);
|
||||
[[nodiscard]] std::string ReplaceAll(const std::string_view subject, const char search, const char replacement);
|
||||
void ReplaceAll(std::string* subject, const char search, const char replacement);
|
||||
|
||||
/// Parses an assignment string (Key = Value) into its two components.
|
||||
bool ParseAssignmentString(const std::string_view str, std::string_view* key, std::string_view* value);
|
||||
|
@ -164,12 +164,10 @@ std::vector<std::pair<std::string, std::string>> PostProcessing::GetAvailableSha
|
||||
if (pos != std::string::npos && pos > 0)
|
||||
fd.FileName.erase(pos);
|
||||
|
||||
#ifdef _WIN32
|
||||
// swap any backslashes for forward slashes so the config is cross-platform
|
||||
for (size_t i = 0; i < fd.FileName.size(); i++)
|
||||
{
|
||||
if (fd.FileName[i] == '\\')
|
||||
fd.FileName[i] = '/';
|
||||
}
|
||||
StringUtil::ReplaceAll(&fd.FileName, '\\', '/');
|
||||
#endif
|
||||
|
||||
if (std::none_of(names.begin(), names.end(), [&fd](const auto& other) { return fd.FileName == other.second; }))
|
||||
{
|
||||
@ -179,11 +177,13 @@ std::vector<std::pair<std::string, std::string>> PostProcessing::GetAvailableSha
|
||||
}
|
||||
|
||||
FileSystem::FindFiles(Path::Combine(EmuFolders::Shaders, "reshade" FS_OSPATH_SEPARATOR_STR "Shaders").c_str(), "*.fx",
|
||||
FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_RELATIVE_PATHS, &results);
|
||||
FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_RECURSIVE | FILESYSTEM_FIND_RELATIVE_PATHS, &results);
|
||||
FileSystem::FindFiles(
|
||||
Path::Combine(EmuFolders::Resources, "shaders" FS_OSPATH_SEPARATOR_STR "reshade" FS_OSPATH_SEPARATOR_STR "Shaders")
|
||||
.c_str(),
|
||||
"*.fx", FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_RELATIVE_PATHS | FILESYSTEM_FIND_KEEP_ARRAY, &results);
|
||||
"*.fx",
|
||||
FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_RECURSIVE | FILESYSTEM_FIND_RELATIVE_PATHS | FILESYSTEM_FIND_KEEP_ARRAY,
|
||||
&results);
|
||||
std::sort(results.begin(), results.end(),
|
||||
[](const auto& lhs, const auto& rhs) { return lhs.FileName < rhs.FileName; });
|
||||
|
||||
@ -193,12 +193,10 @@ std::vector<std::pair<std::string, std::string>> PostProcessing::GetAvailableSha
|
||||
if (pos != std::string::npos && pos > 0)
|
||||
fd.FileName.erase(pos);
|
||||
|
||||
#ifdef _WIN32
|
||||
// swap any backslashes for forward slashes so the config is cross-platform
|
||||
for (size_t i = 0; i < fd.FileName.size(); i++)
|
||||
{
|
||||
if (fd.FileName[i] == '\\')
|
||||
fd.FileName[i] = '/';
|
||||
}
|
||||
StringUtil::ReplaceAll(&fd.FileName, '\\', '/');
|
||||
#endif
|
||||
|
||||
if (std::none_of(names.begin(), names.end(), [&fd](const auto& other) { return fd.FileName == other.second; }))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user