This commit is contained in:
Nayla Hanegan 2023-05-26 15:52:58 -04:00
commit 871da4e307
No known key found for this signature in database
GPG key ID: BAFE9001DA16CFA2
275 changed files with 33002 additions and 27474 deletions

View file

@ -118,7 +118,7 @@ std::string GenerateChangelog(const picojson::array& versions)
changelog += ver_obj["shortrev"].get<std::string>();
}
const std::string escaped_description =
GetEscapedHtml(ver_obj["short_descr"].get<std::string>());
Common::GetEscapedHtml(ver_obj["short_descr"].get<std::string>());
changelog += " by <a href = \"" + ver_obj["author_url"].get<std::string>() + "\">" +
ver_obj["author"].get<std::string>() + "</a> &mdash; " + escaped_description;
}

View file

@ -21,15 +21,16 @@
#include <fmt/format.h>
#include "Common/Hash.h"
#include "Common/HttpRequest.h"
#include "Common/StringUtil.h"
#endif
namespace Discord
{
#ifdef USE_DISCORD_PRESENCE
static bool s_using_custom_client = false;
#ifdef USE_DISCORD_PRESENCE
namespace
{
Handler* event_handler = nullptr;
@ -94,83 +95,14 @@ void HandleDiscordJoin(const char* join_secret)
event_handler->DiscordJoin();
}
std::string ArtworkForGameId(const std::string& gameid)
std::string ArtworkForGameId()
{
static const std::set<std::string> REGISTERED_GAMES{
"GAF", // GAFE01: Animal Crossing
"RUU", // RUUE01: Animal Crossing: City Folk
"SF8", // SF8E01: Donkey Kong Country Returns
"RDB", // RDBE70: Dragon Ball Z: Budokai Tenkaichi 2
"RDS", // RDSE70: Dragon Ball Z: Budokai Tenkaichi 3
"GFZ", // GFZE01: F-Zero GX
"GFE", // GFEE01: Fire Emblem: Path of Radiance
"RFE", // RFEE01: Fire Emblem: Radiant Dawn
"S5S", // S5SJHF: Inazuma Eleven GO: Strikers 2013
"GKY", // GKYE01: Kirby Air Ride
"SUK", // SUKE01: Kirby's Return to Dream Land
"GLM", // GLME01: Luigi's Mansion
"GFT", // GFTE01: Mario Golf: Toadstool Tour
"RMC", // RMCE01: Mario Kart Wii
"GM4", // GM4E01: Mario Kart: Double Dash!!
"SSQ", // SSQE01: Mario Party 9
"GOM", // GOME01: Mario Power Tennis
"GYQ", // GYQE01: Mario Superstar Baseball
"GGS", // GGSE01: Metal Gear Solid: The Twin Snakes
"GM8", // GM8E01: Metroid Prime
"G2M", // G2ME01: Metroid Prime 2: Echoes
"RM3", // RM3E01: Metroid Prime 3: Corruption
"R3M", // R3ME01: Metroid Prime: Trilogy
"SMN", // SMNE01: New Super Mario Bros. Wii
"G8M", // G8ME01: Paper Mario: The Thousand-Year Door
"GPI", // GPIE01: Pikmin (GC)
"R9I", // R9IE01: Pikmin (Wii)
"GPV", // GPVE01: Pikmin 2 (GC)
"R92", // R92E01: Pikmin 2 (Wii)
"GC6", // GC6E01: Pokemon Colosseum
"GXX", // GXXE01: Pokemon XD: Gale of Darkness
"GBI", // GBIE08: Resident Evil
"GHA", // GHAE08: Resident Evil 2
"GLE", // GLEE08: Resident Evil 3: Nemesis
"G4B", // G4BE08: Resident Evil 4
"GSN", // GSNE8P: Sonic Adventure 2: Battle
"GXS", // GXSE8P: Sonic Adventure DX: Director's Cut
"SNC", // SNCE8P: Sonic Colors
"G9S", // G9SE8P: Sonic Heroes
"GRS", // GRSEAF: SoulCalibur II
"RSL", // RSLEAF: SoulCalibur Legends
"GK2", // GK2E52: Spider-Man 2
"GQP", // GQPE78: SpongeBob SquarePants: Battle for Bikini Bottom
"SVM", // SVME01: Super Mario All-Stars: 25th Anniversary Edition
"RMG", // RMGE01: Super Mario Galaxy
"SB4", // SB4E01: Super Mario Galaxy 2
"G4Q", // G4QE01: Super Mario Strikers
"GMS", // GMSE01: Super Mario Sunshine
"GMB", // GMBE8P: Super Monkey Ball
"GM2", // GM2E8P: Super Monkey Ball 2
"R8P", // R8PE01: Super Paper Mario
"RSB", // RSBE01: Super Smash Bros. Brawl
"GAL", // GALE01: Super Smash Bros. Melee
"PZL", // PZLE01: The Legend of Zelda: Collector's Edition
"G4S", // G4SE01: The Legend of Zelda: Four Swords Adventures
"D43", // D43E01: The Legend of Zelda: Ocarina of Time / Master Quest
"SOU", // SOUE01: The Legend of Zelda: Skyward Sword
"GZL", // GZLE01: The Legend of Zelda: The Wind Waker
"GZ2", // GZ2E01: The Legend of Zelda: Twilight Princess (GC)
"RZD", // RZDE01: The Legend of Zelda: Twilight Princess (Wii)
"GHQ", // GHQE7D: The Simpsons: Hit & Run
"RSP", // RSPE01: Wii Sports
"RZT", // RZTE01: Wii Sports Resort
"SX4", // SX4E01: Xenoblade Chronicles
};
const DiscIO::Region region = SConfig::GetInstance().m_region;
const bool is_wii = SConfig::GetInstance().bWii;
const std::string region_code = SConfig::GetInstance().GetGameTDBImageRegionCode(is_wii, region);
std::string region_neutral_gameid = gameid.substr(0, 3);
if (REGISTERED_GAMES.count(region_neutral_gameid) != 0)
{
// Discord asset keys can only be lowercase.
Common::ToLower(&region_neutral_gameid);
return "game_" + region_neutral_gameid;
}
return "";
static constexpr char cover_url[] = "https://discord.dolphin-emu.org/cover-art/{}/{}.png";
return fmt::format(cover_url, region_code, SConfig::GetInstance().GetGameTDBID());
}
} // namespace
@ -277,7 +209,8 @@ void UpdateDiscordPresence(int party_size, SecretType type, const std::string& s
const std::string& title =
current_game.empty() ? SConfig::GetInstance().GetTitleDescription() : current_game;
std::string game_artwork = ArtworkForGameId(SConfig::GetInstance().GetGameID());
std::string game_artwork =
SConfig::GetInstance().GetGameTDBID().empty() ? "" : ArtworkForGameId();
DiscordRichPresence discord_presence = {};
if (game_artwork.empty())

View file

@ -246,49 +246,8 @@ void GameFile::DownloadDefaultCover()
if (File::Exists(png_path))
return;
std::string region_code;
switch (m_region)
{
case DiscIO::Region::NTSC_J:
region_code = "JA";
break;
case DiscIO::Region::NTSC_U:
region_code = "US";
break;
case DiscIO::Region::NTSC_K:
region_code = "KO";
break;
case DiscIO::Region::PAL:
{
const auto user_lang = SConfig::GetInstance().GetCurrentLanguage(DiscIO::IsWii(GetPlatform()));
switch (user_lang)
{
case DiscIO::Language::German:
region_code = "DE";
break;
case DiscIO::Language::French:
region_code = "FR";
break;
case DiscIO::Language::Spanish:
region_code = "ES";
break;
case DiscIO::Language::Italian:
region_code = "IT";
break;
case DiscIO::Language::Dutch:
region_code = "NL";
break;
case DiscIO::Language::English:
default:
region_code = "EN";
break;
}
break;
}
case DiscIO::Region::Unknown:
region_code = "EN";
break;
}
const std::string region_code =
SConfig::GetInstance().GetGameTDBImageRegionCode(DiscIO::IsWii(GetPlatform()), m_region);
Common::HttpRequest request;
static constexpr char cover_url[] = "https://art.gametdb.com/wii/cover/{}/{}.png";

View file

@ -6,45 +6,8 @@
#include "Common/Assert.h"
#include "VideoCommon/VideoConfig.h"
#ifdef _WIN32
#include <Windows.h>
#endif
#ifdef HAVE_XRANDR
#include "UICommon/X11Utils.h"
#endif
namespace VideoUtils
{
#if !defined(__APPLE__)
std::vector<std::string> GetAvailableResolutions(X11Utils::XRRConfiguration* xrr_config)
{
std::vector<std::string> resos;
#ifdef _WIN32
DWORD iModeNum = 0;
DEVMODE dmi;
ZeroMemory(&dmi, sizeof(dmi));
dmi.dmSize = sizeof(dmi);
while (EnumDisplaySettings(nullptr, iModeNum++, &dmi) != 0)
{
char res[100];
sprintf(res, "%dx%d", dmi.dmPelsWidth, dmi.dmPelsHeight);
std::string strRes(res);
// Only add unique resolutions
if (std::find(resos.begin(), resos.end(), strRes) == resos.end())
{
resos.push_back(strRes);
}
ZeroMemory(&dmi, sizeof(dmi));
}
#elif defined(HAVE_XRANDR) && HAVE_XRANDR
xrr_config->AddResolutions(resos);
#endif
return resos;
}
#endif
std::vector<std::string> GetAvailableAntialiasingModes(int& msaa_modes)
{
std::vector<std::string> modes;

View file

@ -6,16 +6,7 @@
#include <string>
#include <vector>
namespace X11Utils
{
class XRRConfiguration;
}
namespace VideoUtils
{
#if !defined(__APPLE__)
std::vector<std::string> GetAvailableResolutions(X11Utils::XRRConfiguration* xrr_config);
#endif
std::vector<std::string> GetAvailableAntialiasingModes(int& m_msaa_modes);
} // namespace VideoUtils