diff options
| author | cbartondock <cbartondock@gmail.com> | 2021-01-21 10:47:07 -0500 |
|---|---|---|
| committer | cbartondock <cbartondock@gmail.com> | 2021-01-30 09:51:37 -0500 |
| commit | 83c127784b70fe1628a8718ceff52dcbcd08634c (patch) | |
| tree | ab2cae73e20679273b5536a73f1304a86ceb62aa /Source | |
| parent | ebf3b5faf4e4716bbe55174eb2a3d7f5a9fc4599 (diff) | |
Working Game IDs for Elf/Dol files
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/Core/ConfigManager.cpp | 24 | ||||
| -rw-r--r-- | Source/Core/Core/ConfigManager.h | 4 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/GameList/GameList.cpp | 7 | ||||
| -rw-r--r-- | Source/Core/UICommon/GameFile.cpp | 1 | ||||
| -rw-r--r-- | Source/Core/UICommon/GameFileCache.cpp | 2 |
5 files changed, 32 insertions, 6 deletions
diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index d68c215998..45f7f0984e 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -4,11 +4,14 @@ #include "Core/ConfigManager.h" +#include <algorithm> #include <cinttypes> #include <climits> #include <memory> #include <optional> #include <sstream> +#include <string> +#include <string_view> #include <variant> #include <fmt/format.h> @@ -653,6 +656,11 @@ void SConfig::SetRunningGameMetadata(const IOS::ES::TMDReader& tmd, DiscIO::Plat } } +void SConfig::SetRunningGameMetadata(const std::string& game_id) +{ + SetRunningGameMetadata(game_id, "", 0, 0, DiscIO::Region::Unknown); +} + void SConfig::SetRunningGameMetadata(const std::string& game_id, const std::string& gametdb_id, u64 title_id, u16 revision, DiscIO::Region region) { @@ -770,6 +778,15 @@ bool SConfig::IsUSBDeviceWhitelisted(const std::pair<u16, u16> vid_pid) const return m_usb_passthrough_devices.find(vid_pid) != m_usb_passthrough_devices.end(); } +// Static method to make a simple game ID for elf/dol files +std::string SConfig::MakeGameID(std::string_view file_name) +{ + size_t lastdot = file_name.find_last_of("."); + if (lastdot == std::string::npos) + return "ID-" + std::string(file_name); + return "ID-" + std::string(file_name.substr(0, lastdot)); +} + // The reason we need this function is because some memory card code // expects to get a non-NTSC-K region even if we're emulating an NTSC-K Wii. DiscIO::Region SConfig::ToGameCubeRegion(DiscIO::Region region) @@ -840,6 +857,13 @@ struct SetGameMetadata // Strip the .elf/.dol file extension and directories before the name SplitPath(executable.path, nullptr, &config->m_debugger_game_id, nullptr); + // Set DOL/ELF game ID appropriately + std::string executable_path = executable.path; + constexpr char BACKSLASH = '\\'; + constexpr char FORWARDSLASH = '/'; + std::replace(executable_path.begin(), executable_path.end(), BACKSLASH, FORWARDSLASH); + config->SetRunningGameMetadata(SConfig::MakeGameID(PathToFileName(executable_path))); + Host_TitleChanged(); return true; diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 8389e8001a..d1de769706 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -8,6 +8,7 @@ #include <optional> #include <set> #include <string> +#include <string_view> #include <utility> #include <vector> @@ -195,8 +196,9 @@ struct SConfig void ResetRunningGameMetadata(); void SetRunningGameMetadata(const DiscIO::Volume& volume, const DiscIO::Partition& partition); void SetRunningGameMetadata(const IOS::ES::TMDReader& tmd, DiscIO::Platform platform); - + void SetRunningGameMetadata(const std::string& game_id); void LoadDefaults(); + static std::string MakeGameID(std::string_view file_name); // Replaces NTSC-K with some other region, and doesn't replace non-NTSC-K regions static DiscIO::Region ToGameCubeRegion(DiscIO::Region region); // The region argument must be valid for GameCube (i.e. must not be NTSC-K) diff --git a/Source/Core/DolphinQt/GameList/GameList.cpp b/Source/Core/DolphinQt/GameList/GameList.cpp index 1b458bdb35..0e19671186 100644 --- a/Source/Core/DolphinQt/GameList/GameList.cpp +++ b/Source/Core/DolphinQt/GameList/GameList.cpp @@ -304,15 +304,14 @@ void GameList::ShowContextMenu(const QPoint&) { const auto game = GetSelectedGame(); DiscIO::Platform platform = game->GetPlatform(); - + menu->addAction(tr("&Properties"), this, &GameList::OpenProperties); if (platform != DiscIO::Platform::ELFOrDOL) { - menu->addAction(tr("&Properties"), this, &GameList::OpenProperties); menu->addAction(tr("&Wiki"), this, &GameList::OpenWiki); - - menu->addSeparator(); } + menu->addSeparator(); + if (DiscIO::IsDisc(platform)) { menu->addAction(tr("Set as &Default ISO"), this, &GameList::SetDefaultISO); diff --git a/Source/Core/UICommon/GameFile.cpp b/Source/Core/UICommon/GameFile.cpp index a169ef0f66..24d6751fdf 100644 --- a/Source/Core/UICommon/GameFile.cpp +++ b/Source/Core/UICommon/GameFile.cpp @@ -157,6 +157,7 @@ GameFile::GameFile(std::string path) : m_file_path(std::move(path)) { m_valid = true; m_file_size = m_volume_size = File::GetSize(m_file_path); + m_game_id = SConfig::MakeGameID(m_file_name); m_volume_size_is_accurate = true; m_is_datel_disc = false; m_is_nkit = false; diff --git a/Source/Core/UICommon/GameFileCache.cpp b/Source/Core/UICommon/GameFileCache.cpp index 38dd09f8a8..499244f8e4 100644 --- a/Source/Core/UICommon/GameFileCache.cpp +++ b/Source/Core/UICommon/GameFileCache.cpp @@ -27,7 +27,7 @@ namespace UICommon { -static constexpr u32 CACHE_REVISION = 19; // Last changed in PR 9135 +static constexpr u32 CACHE_REVISION = 20; // Last changed in PR 9461 std::vector<std::string> FindAllGamePaths(const std::vector<std::string>& directories_to_scan, bool recursive_scan) |
