Address feedback, also sort texture shaders

This commit is contained in:
Henrik Rydgård 2022-12-03 19:30:50 +01:00
parent e46b036482
commit f3ba8fb334
3 changed files with 27 additions and 11 deletions

View file

@ -118,6 +118,9 @@ public:
bool operator <(const Path &other) const {
return path_ < other.path_;
}
bool operator >(const Path &other) const {
return path_ > other.path_;
}
private:
// The internal representation is currently always the plain string.

View file

@ -51,12 +51,6 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector<Path> &direct
shaderInfo.clear();
textureShaderInfo.clear();
TextureShaderInfo textureOff{};
textureOff.name = "Off";
textureOff.section = "Off";
textureShaderInfo.push_back(textureOff);
auto appendShader = [&](const ShaderInfo &info) {
auto beginErase = std::remove(shaderInfo.begin(), shaderInfo.end(), info.name);
if (beginErase != shaderInfo.end()) {
@ -221,6 +215,7 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector<Path> &direct
// Sort shaders alphabetically.
std::sort(shaderInfo.begin(), shaderInfo.end());
std::sort(textureShaderInfo.begin(), textureShaderInfo.end());
ShaderInfo off{};
off.visible = true;
@ -235,6 +230,12 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector<Path> &direct
}
shaderInfo.insert(shaderInfo.begin(), off);
textureShaderInfo.clear();
TextureShaderInfo textureOff{};
textureOff.name = "Off";
textureOff.section = "Off";
textureShaderInfo.push_back(textureOff);
// We always want the not visible ones at the end. Makes menus easier.
for (const auto &info : notVisible) {
appendShader(info);

View file

@ -60,16 +60,19 @@ struct ShaderInfo {
// TODO: Add support for all kinds of fun options like mapping the depth buffer,
// SRGB texture reads, etc. prev shader?
bool operator == (const std::string &other) {
bool operator == (const std::string &other) const {
return name == other;
}
bool operator == (const ShaderInfo &other) {
bool operator == (const ShaderInfo &other) const {
return name == other.name;
}
bool operator < (const ShaderInfo &other) {
bool operator < (const ShaderInfo &other) const {
if (name < other.name) return true;
if (name > other.name) return false;
// Tie breaker
if (iniFile < other.iniFile) return true;
if (iniFile > other.iniFile) return false;
return false;
}
};
@ -84,12 +87,21 @@ struct TextureShaderInfo {
// Upscaling shaders have a fixed scale factor.
int scaleFactor;
bool operator == (const std::string &other) {
bool operator == (const std::string &other) const {
return name == other;
}
bool operator == (const TextureShaderInfo &other) {
bool operator == (const TextureShaderInfo &other) const {
return name == other.name;
}
bool operator < (const TextureShaderInfo &other) const {
if (name < other.name) return true;
if (name > other.name) return false;
// Tie breaker
if (iniFile < other.iniFile) return true;
if (iniFile > other.iniFile) return false;
return false;
}
};
void ReloadAllPostShaderInfo(Draw::DrawContext *draw);