TitleDatabase: Add GetTitleName for title IDs

This commit is contained in:
Léo Lam 2017-10-08 18:23:11 +02:00
parent 239167245d
commit e1c0b8d011
2 changed files with 12 additions and 0 deletions

View File

@ -14,6 +14,7 @@
#include "Common/MsgHandler.h" #include "Common/MsgHandler.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
#include "Core/IOS/ES/Formats.h"
#include "DiscIO/Enums.h" #include "DiscIO/Enums.h"
namespace Core namespace Core
@ -165,6 +166,14 @@ std::string TitleDatabase::GetTitleName(const std::string& game_id, TitleType ty
return iterator != map.end() ? iterator->second : ""; return iterator != map.end() ? iterator->second : "";
} }
std::string TitleDatabase::GetTitleName(u64 title_id) const
{
const std::string id{
{static_cast<char>((title_id >> 24) & 0xff), static_cast<char>((title_id >> 16) & 0xff),
static_cast<char>((title_id >> 8) & 0xff), static_cast<char>(title_id & 0xff)}};
return GetTitleName(id, IOS::ES::IsChannel(title_id) ? TitleType::Channel : TitleType::Other);
}
std::string TitleDatabase::Describe(const std::string& game_id, TitleType type) const std::string TitleDatabase::Describe(const std::string& game_id, TitleType type) const
{ {
const std::string title_name = GetTitleName(game_id, type); const std::string title_name = GetTitleName(game_id, type);

View File

@ -7,6 +7,8 @@
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include "Common/CommonTypes.h"
namespace Core namespace Core
{ {
// Reader for title database files. // Reader for title database files.
@ -25,6 +27,7 @@ public:
// Get a user friendly title name for a game ID. // Get a user friendly title name for a game ID.
// This falls back to returning an empty string if none could be found. // This falls back to returning an empty string if none could be found.
std::string GetTitleName(const std::string& game_id, TitleType = TitleType::Other) const; std::string GetTitleName(const std::string& game_id, TitleType = TitleType::Other) const;
std::string GetTitleName(u64 title_id) const;
// Get a description for a game ID (title name if available + game ID). // Get a description for a game ID (title name if available + game ID).
std::string Describe(const std::string& game_id, TitleType = TitleType::Other) const; std::string Describe(const std::string& game_id, TitleType = TitleType::Other) const;