TitleDatabase: Don't merge multiple languages into same map

Instead of selecting languages based on the user config at the time
of TitleDatabase creation and merging the different languages into one
map for GC and one map for Wii, have one map for each language, and
have the caller supply the language they want. This makes us not need
the IsGCTitle function, which is inaccurate for IDs that start with D.
This commit is contained in:
JosJuice
2019-02-23 19:18:16 +01:00
parent 8842a0f402
commit 9df763b4ac
6 changed files with 91 additions and 133 deletions

View File

@ -8,6 +8,12 @@
#include <unordered_map>
#include "Common/CommonTypes.h"
#include "Common/Lazy.h"
namespace DiscIO
{
enum class Language;
}
namespace Core
{
@ -20,16 +26,20 @@ public:
// Get a user friendly title name for a GameTDB ID.
// This falls back to returning an empty string if none could be found.
const std::string& GetTitleName(const std::string& gametdb_id) const;
const std::string& GetTitleName(const std::string& gametdb_id, DiscIO::Language language) const;
// Same as above, but takes a title ID instead of a GameTDB ID, and only works for channels.
const std::string& GetChannelName(u64 title_id) const;
const std::string& GetChannelName(u64 title_id, DiscIO::Language language) const;
// Get a description for a GameTDB ID (title name if available + GameTDB ID).
std::string Describe(const std::string& gametdb_id) const;
std::string Describe(const std::string& gametdb_id, DiscIO::Language language) const;
private:
std::unordered_map<std::string, std::string> m_wii_title_map;
std::unordered_map<std::string, std::string> m_gc_title_map;
void AddLazyMap(DiscIO::Language language, const std::string& language_code);
std::unordered_map<DiscIO::Language, Common::Lazy<std::unordered_map<std::string, std::string>>>
m_title_maps;
std::unordered_map<std::string, std::string> m_base_map;
std::unordered_map<std::string, std::string> m_user_title_map;
};
} // namespace Core