summarylogtreecommitdiffstats
path: root/mlc-discord-rich-presence.diff
diff options
context:
space:
mode:
Diffstat (limited to 'mlc-discord-rich-presence.diff')
-rw-r--r--mlc-discord-rich-presence.diff116
1 files changed, 116 insertions, 0 deletions
diff --git a/mlc-discord-rich-presence.diff b/mlc-discord-rich-presence.diff
new file mode 100644
index 000000000000..f9951ab886e1
--- /dev/null
+++ b/mlc-discord-rich-presence.diff
@@ -0,0 +1,116 @@
+--- a/src/Cafe/CafeSystem.cpp
++++ b/src/Cafe/CafeSystem.cpp
+@@ -704,9 +704,8 @@ namespace CafeSystem
+ std::string GetForegroundTitleName()
+ {
+ if (sLaunchModeIsStandalone)
+- return "Missing meta data";
+- // todo - use language based on Cemu console language
+- return sGameInfo_ForegroundTitle.GetBase().GetMetaInfo()->GetShortName(CafeConsoleLanguage::EN);
++ return "Unknown Game";
++ return sGameInfo_ForegroundTitle.GetBase().GetMetaInfo()->GetShortName(GetConfig().console_language);
+ }
+
+ std::string GetForegroundTitleArgStr()
+--- a/src/gui/MainWindow.cpp
++++ b/src/gui/MainWindow.cpp
+@@ -543,8 +543,7 @@ bool MainWindow::FileLoad(std::wstring fileName, wxLaunchGameEvent::INITIATED_BY
+ m_game_list = nullptr;
+ }
+
+- const auto game_name = GetGameName(fileName);
+- m_launched_game_name = boost::nowide::narrow(game_name);
++ m_launched_game_name = CafeSystem::GetForegroundTitleName();
+ #ifdef ENABLE_DISCORD_RPC
+ if (m_discord)
+ m_discord->UpdatePresence(DiscordPresence::Playing, m_launched_game_name);
+@@ -1496,79 +1495,6 @@ void MainWindow::DestroyCanvas()
+ }
+ }
+
+-
+-std::wstring MainWindow::GetGameName(std::wstring_view file_name)
+-{
+- fs::path path{ std::wstring{file_name} };
+- const auto extension = path.extension();
+- if (extension == ".wud" || extension == ".wux")
+- {
+- std::unique_ptr<FSTVolume> volume(FSTVolume::OpenFromDiscImage(path));
+- if (!volume)
+- return path.filename().generic_wstring();
+-
+- bool foundFile = false;
+- std::vector<uint8> metaContent = volume->ExtractFile("meta/meta.xml", &foundFile);
+- if (!foundFile)
+- return path.filename().generic_wstring();
+-
+- namespace xml = tinyxml2;
+- xml::XMLDocument doc;
+- doc.Parse((const char*)metaContent.data(), metaContent.size());
+-
+- // parse meta.xml
+- xml::XMLElement* root = doc.FirstChildElement("menu");
+- if (root)
+- {
+- xml::XMLElement* element = root->FirstChildElement("longname_en");
+- if (element)
+- {
+-
+- auto game_name = boost::nowide::widen(element->GetText());
+- const auto it = game_name.find(L'\n');
+- if (it != std::wstring::npos)
+- game_name.replace(it, 1, L" - ");
+-
+- return game_name;
+- }
+- }
+- return path.filename().generic_wstring();
+- }
+- else if (extension == ".rpx")
+- {
+- if (path.has_parent_path() && path.parent_path().has_parent_path())
+- {
+- auto meta_xml = path.parent_path().parent_path() / "meta/meta.xml";
+- auto metaXmlData = FileStream::LoadIntoMemory(meta_xml);
+- if (metaXmlData)
+- {
+- namespace xml = tinyxml2;
+- xml::XMLDocument doc;
+- if (doc.Parse((const char*)metaXmlData->data(), metaXmlData->size()) == xml::XML_SUCCESS)
+- {
+- xml::XMLElement* root = doc.FirstChildElement("menu");
+- if (root)
+- {
+- xml::XMLElement* element = root->FirstChildElement("longname_en");
+- if (element)
+- {
+-
+- auto game_name = boost::nowide::widen(element->GetText());
+- const auto it = game_name.find(L'\n');
+- if (it != std::wstring::npos)
+- game_name.replace(it, 1, L" - ");
+-
+- return game_name;
+- }
+- }
+- }
+- }
+- }
+- }
+-
+- return path.filename().generic_wstring();
+-}
+-
+ void MainWindow::OnSizeEvent(wxSizeEvent& event)
+ {
+ if (!IsMaximized() && !gui_isFullScreen())
+--- a/src/gui/MainWindow.h
++++ b/src/gui/MainWindow.h
+@@ -130,7 +130,6 @@ class MainWindow : public wxFrame
+ void CreateCanvas();
+ void DestroyCanvas();
+
+- std::wstring GetGameName(std::wstring_view file_name);
+ static void ShowCursor(bool state);
+
+ uintptr_t GetRenderCanvasHWND();