diff --git a/src/Cafe/GraphicPack/GraphicPack2.cpp b/src/Cafe/GraphicPack/GraphicPack2.cpp index aded9188..67ba6edc 100644 --- a/src/Cafe/GraphicPack/GraphicPack2.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2.cpp @@ -328,7 +328,7 @@ GraphicPack2::GraphicPack2(fs::path rulesPath, IniParser& rules) } m_title_ids = ParseTitleIds(rules, "titleIds"); - if(m_title_ids.empty()) + if(m_title_ids.empty() && !m_universal) throw std::exception(); auto option_fsPriority = rules.FindOption("fsPriority"); @@ -532,6 +532,9 @@ std::string GraphicPack2::GetNormalizedPathString() const bool GraphicPack2::ContainsTitleId(uint64_t title_id) const { + if (m_universal) + return true; + const auto it = std::find_if(m_title_ids.begin(), m_title_ids.end(), [title_id](uint64 id) { return id == title_id; }); return it != m_title_ids.end(); } @@ -1188,7 +1191,7 @@ std::vector GraphicPack2::GetActivePresets() const return result; } -std::vector GraphicPack2::ParseTitleIds(IniParser& rules, const char* option_name) const +std::vector GraphicPack2::ParseTitleIds(IniParser& rules, const char* option_name) { std::vector result; @@ -1198,6 +1201,13 @@ std::vector GraphicPack2::ParseTitleIds(IniParser& rules, const char* op for (auto& token : TokenizeView(*option_text, ',')) { + if (token == "*") + { + m_universal = true; + result.clear(); + break; + } + try { result.emplace_back(ConvertString(token, 16)); diff --git a/src/Cafe/GraphicPack/GraphicPack2.h b/src/Cafe/GraphicPack/GraphicPack2.h index b83ac66c..9421e4fa 100644 --- a/src/Cafe/GraphicPack/GraphicPack2.h +++ b/src/Cafe/GraphicPack/GraphicPack2.h @@ -109,6 +109,7 @@ public: bool Reload(); bool HasName() const { return !m_name.empty(); } + bool IsUniversal() const { return m_universal; } const std::string& GetName() const { return m_name.empty() ? m_virtualPath : m_name; } const std::string& GetVirtualPath() const { return m_virtualPath; } // returns the path in the gfx tree hierarchy @@ -229,6 +230,7 @@ private: bool m_activated = false; // set if the graphic pack is currently used by the running game std::vector m_title_ids; bool m_patchedFilesLoaded = false; // set to true once patched files are loaded + bool m_universal = false; // set if this pack applies to every titl eid sint32 m_vsync_frequency = -1; sint32 m_fs_priority = 100; @@ -256,7 +258,7 @@ private: std::unordered_map ParsePresetVars(IniParser& rules) const; - std::vector ParseTitleIds(IniParser& rules, const char* option_name) const; + std::vector ParseTitleIds(IniParser& rules, const char* option_name); CustomShader LoadShader(const fs::path& path, uint64 shader_base_hash, uint64 shader_aux_hash, GP_SHADER_TYPE shader_type, bool isMetalShader) const; void ApplyShaderPresets(std::string& shader_source) const; diff --git a/src/gui/wxgui/GraphicPacksWindow2.cpp b/src/gui/wxgui/GraphicPacksWindow2.cpp index b6f016ff..90f5e17c 100644 --- a/src/gui/wxgui/GraphicPacksWindow2.cpp +++ b/src/gui/wxgui/GraphicPacksWindow2.cpp @@ -43,44 +43,47 @@ void GraphicPacksWindow2::FillGraphicPackList() const for(auto& p : graphic_packs) { - // filter graphic packs by given title id - if (m_filter_installed_games && !m_installed_games.empty()) + if (!p->IsUniversal()) { - bool found = false; - for (uint64 titleId : p->GetTitleIds()) - { - if (std::find(m_installed_games.cbegin(), m_installed_games.cend(), titleId) != m_installed_games.cend()) - { - found = true; - break; - } - } - - if (!found) - continue; - } - - // filter graphic packs by given title id - if(has_filter) - { - bool found = false; - - if (boost::icontains(p->GetVirtualPath(), m_filter)) - found = true; - else + // filter graphic packs by given title id + if (m_filter_installed_games && !m_installed_games.empty()) { + bool found = false; for (uint64 titleId : p->GetTitleIds()) { - if (boost::icontains(fmt::format("{:x}", titleId), m_filter)) + if (std::find(m_installed_games.cbegin(), m_installed_games.cend(), titleId) != m_installed_games.cend()) { found = true; break; } } + + if (!found) + continue; + } + + // filter graphic packs by given title id + if(has_filter) + { + bool found = false; + + if (boost::icontains(p->GetVirtualPath(), m_filter)) + found = true; + else + { + for (uint64 titleId : p->GetTitleIds()) + { + if (boost::icontains(fmt::format("{:x}", titleId), m_filter)) + { + found = true; + break; + } + } + } + + if (!found) + continue; } - - if (!found) - continue; } const auto& path = p->GetVirtualPath();