Merge pull request #12243 from iwubcode/tolower_assets

VideoCommon: use ToLower function in assets when parsing json
This commit is contained in:
Admiral H. Curtiss 2023-10-17 02:34:18 +02:00 committed by GitHub
commit 7122c7e872
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View File

@ -9,6 +9,7 @@
#include <utility> #include <utility>
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/StringUtil.h"
#include "VideoCommon/Assets/CustomAssetLibrary.h" #include "VideoCommon/Assets/CustomAssetLibrary.h"
namespace VideoCommon namespace VideoCommon
@ -47,8 +48,7 @@ bool ParseShaderProperties(const VideoCommon::CustomAssetLibrary::AssetID& asset
return false; return false;
} }
std::string type = type_iter->second.to_str(); std::string type = type_iter->second.to_str();
std::transform(type.begin(), type.end(), type.begin(), Common::ToLower(&type);
[](unsigned char c) { return std::tolower(c); });
static constexpr std::array<std::pair<std::string_view, ShaderProperty::Type>, static constexpr std::array<std::pair<std::string_view, ShaderProperty::Type>,
static_cast<int>(ShaderProperty::Type::Type_Max)> static_cast<int>(ShaderProperty::Type::Type_Max)>

View File

@ -4,6 +4,7 @@
#include "VideoCommon/Assets/TextureAsset.h" #include "VideoCommon/Assets/TextureAsset.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/StringUtil.h"
#include "VideoCommon/BPMemory.h" #include "VideoCommon/BPMemory.h"
namespace VideoCommon namespace VideoCommon
@ -31,8 +32,7 @@ bool ParseSampler(const VideoCommon::CustomAssetLibrary::AssetID& asset_id,
return false; return false;
} }
std::string sampler_state_mode = sampler_state_mode_iter->second.to_str(); std::string sampler_state_mode = sampler_state_mode_iter->second.to_str();
std::transform(sampler_state_mode.begin(), sampler_state_mode.end(), sampler_state_mode.begin(), Common::ToLower(&sampler_state_mode);
[](unsigned char c) { return std::tolower(c); });
if (sampler_state_mode == "clamp") if (sampler_state_mode == "clamp")
{ {
@ -71,8 +71,7 @@ bool ParseSampler(const VideoCommon::CustomAssetLibrary::AssetID& asset_id,
return false; return false;
} }
std::string sampler_state_filter = sampler_state_filter_iter->second.to_str(); std::string sampler_state_filter = sampler_state_filter_iter->second.to_str();
std::transform(sampler_state_filter.begin(), sampler_state_filter.end(), Common::ToLower(&sampler_state_filter);
sampler_state_filter.begin(), [](unsigned char c) { return std::tolower(c); });
if (sampler_state_filter == "linear") if (sampler_state_filter == "linear")
{ {
sampler->tm0.min_filter = FilterMode::Linear; sampler->tm0.min_filter = FilterMode::Linear;
@ -116,8 +115,7 @@ bool TextureData::FromJson(const CustomAssetLibrary::AssetID& asset_id,
return false; return false;
} }
std::string type = type_iter->second.to_str(); std::string type = type_iter->second.to_str();
std::transform(type.begin(), type.end(), type.begin(), Common::ToLower(&type);
[](unsigned char c) { return std::tolower(c); });
if (type == "texture2d") if (type == "texture2d")
{ {