WX: Use TitleDatabase for getting title names
This commit is contained in:
parent
89b5549fe0
commit
2f5f9be9ac
|
@ -50,6 +50,7 @@
|
|||
#include "Core/HW/DVD/DVDInterface.h"
|
||||
#include "Core/HW/WiiSaveCrypted.h"
|
||||
#include "Core/Movie.h"
|
||||
#include "Core/TitleDatabase.h"
|
||||
#include "DiscIO/Blob.h"
|
||||
#include "DiscIO/Enums.h"
|
||||
#include "DiscIO/Volume.h"
|
||||
|
@ -154,37 +155,6 @@ static int CompareGameListItems(const GameListItem* iso1, const GameListItem* is
|
|||
return 0;
|
||||
}
|
||||
|
||||
static std::unordered_map<std::string, std::string> LoadCustomTitles()
|
||||
{
|
||||
// Load custom game titles from titles.txt
|
||||
// http://www.gametdb.com/Wii/Downloads
|
||||
const std::string& load_directory = File::GetUserPath(D_LOAD_IDX);
|
||||
|
||||
std::ifstream titlestxt;
|
||||
OpenFStream(titlestxt, load_directory + "titles.txt", std::ios::in);
|
||||
|
||||
if (!titlestxt.is_open())
|
||||
OpenFStream(titlestxt, load_directory + "wiitdb.txt", std::ios::in);
|
||||
|
||||
if (!titlestxt.is_open())
|
||||
return {};
|
||||
|
||||
std::unordered_map<std::string, std::string> custom_titles;
|
||||
|
||||
std::string line;
|
||||
while (!titlestxt.eof() && std::getline(titlestxt, line))
|
||||
{
|
||||
const size_t equals_index = line.find('=');
|
||||
if (equals_index != std::string::npos)
|
||||
{
|
||||
custom_titles.emplace(StripSpaces(line.substr(0, equals_index)),
|
||||
StripSpaces(line.substr(equals_index + 1)));
|
||||
}
|
||||
}
|
||||
|
||||
return custom_titles;
|
||||
}
|
||||
|
||||
static std::vector<std::string> GetFileSearchExtensions()
|
||||
{
|
||||
std::vector<std::string> extensions;
|
||||
|
@ -665,7 +635,7 @@ void CGameListCtrl::ScanForISOs()
|
|||
{
|
||||
m_ISOFiles.clear();
|
||||
|
||||
const auto custom_titles = LoadCustomTitles();
|
||||
const Core::TitleDatabase title_database;
|
||||
auto rFilenames =
|
||||
Common::DoFileSearch(GetFileSearchExtensions(), SConfig::GetInstance().m_ISOFolder,
|
||||
SConfig::GetInstance().m_RecursiveISOFolder);
|
||||
|
@ -688,7 +658,7 @@ void CGameListCtrl::ScanForISOs()
|
|||
if (dialog.WasCancelled())
|
||||
break;
|
||||
|
||||
auto iso_file = std::make_unique<GameListItem>(rFilenames[i], custom_titles);
|
||||
auto iso_file = std::make_unique<GameListItem>(rFilenames[i], title_database);
|
||||
|
||||
if (iso_file->IsValid() && ShouldDisplayGameListItem(*iso_file))
|
||||
{
|
||||
|
@ -703,7 +673,7 @@ void CGameListCtrl::ScanForISOs()
|
|||
|
||||
for (const auto& drive : drives)
|
||||
{
|
||||
auto gli = std::make_unique<GameListItem>(drive, custom_titles);
|
||||
auto gli = std::make_unique<GameListItem>(drive, title_database);
|
||||
|
||||
if (gli->IsValid())
|
||||
m_ISOFiles.push_back(std::move(gli));
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "Core/Boot/Boot.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/IOS/ES/Formats.h"
|
||||
#include "Core/TitleDatabase.h"
|
||||
|
||||
#include "DiscIO/Blob.h"
|
||||
#include "DiscIO/Enums.h"
|
||||
|
@ -62,8 +63,7 @@ static std::string GetLanguageString(DiscIO::Language language,
|
|||
return "";
|
||||
}
|
||||
|
||||
GameListItem::GameListItem(const std::string& _rFileName,
|
||||
const std::unordered_map<std::string, std::string>& custom_titles)
|
||||
GameListItem::GameListItem(const std::string& _rFileName, const Core::TitleDatabase& title_database)
|
||||
: m_FileName(_rFileName), m_title_id(0), m_emu_state(0), m_FileSize(0),
|
||||
m_region(DiscIO::Region::UNKNOWN_REGION), m_Country(DiscIO::Country::COUNTRY_UNKNOWN),
|
||||
m_Revision(0), m_Valid(false), m_ImageWidth(0), m_ImageHeight(0), m_disc_number(0),
|
||||
|
@ -125,18 +125,10 @@ GameListItem::GameListItem(const std::string& _rFileName,
|
|||
|
||||
if (IsValid())
|
||||
{
|
||||
std::string short_game_id = m_game_id;
|
||||
|
||||
// Ignore publisher ID for WAD files
|
||||
if (m_Platform == DiscIO::Platform::WII_WAD && short_game_id.size() > 4)
|
||||
short_game_id.erase(4);
|
||||
|
||||
auto it = custom_titles.find(short_game_id);
|
||||
if (it != custom_titles.end())
|
||||
{
|
||||
m_custom_name_titles_txt = it->second;
|
||||
}
|
||||
|
||||
const auto type = m_Platform == DiscIO::Platform::WII_WAD ?
|
||||
Core::TitleDatabase::TitleType::Channel :
|
||||
Core::TitleDatabase::TitleType::Other;
|
||||
m_custom_name_titles_txt = title_database.GetTitleName(m_game_id, type);
|
||||
ReloadINI();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
|
@ -14,6 +13,11 @@
|
|||
#include <wx/bitmap.h>
|
||||
#include <wx/image.h>
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class TitleDatabase;
|
||||
}
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
enum class BlobType;
|
||||
|
@ -28,8 +32,7 @@ class PointerWrap;
|
|||
class GameListItem
|
||||
{
|
||||
public:
|
||||
GameListItem(const std::string& _rFileName,
|
||||
const std::unordered_map<std::string, std::string>& custom_titles);
|
||||
GameListItem(const std::string& file_name, const Core::TitleDatabase& title_database);
|
||||
~GameListItem();
|
||||
|
||||
// Reload settings after INI changes
|
||||
|
|
Loading…
Reference in New Issue