From e1c0b8d01124f13d07d0b7bd0e271e88b1178d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 8 Oct 2017 18:23:11 +0200 Subject: [PATCH] TitleDatabase: Add GetTitleName for title IDs --- Source/Core/Core/TitleDatabase.cpp | 9 +++++++++ Source/Core/Core/TitleDatabase.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/Source/Core/Core/TitleDatabase.cpp b/Source/Core/Core/TitleDatabase.cpp index ea8b2916f1..29fe07e57b 100644 --- a/Source/Core/Core/TitleDatabase.cpp +++ b/Source/Core/Core/TitleDatabase.cpp @@ -14,6 +14,7 @@ #include "Common/MsgHandler.h" #include "Common/StringUtil.h" #include "Core/ConfigManager.h" +#include "Core/IOS/ES/Formats.h" #include "DiscIO/Enums.h" namespace Core @@ -165,6 +166,14 @@ std::string TitleDatabase::GetTitleName(const std::string& game_id, TitleType ty return iterator != map.end() ? iterator->second : ""; } +std::string TitleDatabase::GetTitleName(u64 title_id) const +{ + const std::string id{ + {static_cast((title_id >> 24) & 0xff), static_cast((title_id >> 16) & 0xff), + static_cast((title_id >> 8) & 0xff), static_cast(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 { const std::string title_name = GetTitleName(game_id, type); diff --git a/Source/Core/Core/TitleDatabase.h b/Source/Core/Core/TitleDatabase.h index 6b6c53fd9d..27793407a3 100644 --- a/Source/Core/Core/TitleDatabase.h +++ b/Source/Core/Core/TitleDatabase.h @@ -7,6 +7,8 @@ #include #include +#include "Common/CommonTypes.h" + namespace Core { // Reader for title database files. @@ -25,6 +27,7 @@ public: // Get a user friendly title name for a game ID. // 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(u64 title_id) const; // 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;