mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-05-27 22:36:36 +00:00
Add RetroAchievements development menu
When the menu exists, it replaces the Achievements action in the Tools menu.
This commit is contained in:
parent
36c7e7f3c7
commit
9caa02493d
4 changed files with 89 additions and 2 deletions
|
@ -637,6 +637,22 @@ std::vector<std::string> AchievementManager::GetActiveLeaderboards() const
|
||||||
return display_values;
|
return display_values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
|
const rc_client_raintegration_menu_t* AchievementManager::GetDevelopmentMenu()
|
||||||
|
{
|
||||||
|
if (!m_dll_found)
|
||||||
|
return nullptr;
|
||||||
|
return rc_client_raintegration_get_menu(m_client);
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 AchievementManager::ActivateDevMenuItem(u32 menu_item_id)
|
||||||
|
{
|
||||||
|
if (!m_dll_found)
|
||||||
|
return 0;
|
||||||
|
return rc_client_raintegration_activate_menu_item(m_client, menu_item_id);
|
||||||
|
}
|
||||||
|
#endif // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
|
|
||||||
void AchievementManager::DoState(PointerWrap& p)
|
void AchievementManager::DoState(PointerWrap& p)
|
||||||
{
|
{
|
||||||
if (!m_client || !Config::Get(Config::RA_ENABLED))
|
if (!m_client || !Config::Get(Config::RA_ENABLED))
|
||||||
|
@ -732,6 +748,7 @@ void AchievementManager::Shutdown()
|
||||||
// DON'T log out - keep those credentials for next run.
|
// DON'T log out - keep those credentials for next run.
|
||||||
rc_client_destroy(m_client);
|
rc_client_destroy(m_client);
|
||||||
m_client = nullptr;
|
m_client = nullptr;
|
||||||
|
m_dll_found = false;
|
||||||
INFO_LOG_FMT(ACHIEVEMENTS, "Achievement Manager shut down.");
|
INFO_LOG_FMT(ACHIEVEMENTS, "Achievement Manager shut down.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1420,6 +1437,8 @@ void AchievementManager::LoadIntegrationCallback(int result, const char* error_m
|
||||||
{
|
{
|
||||||
case RC_OK:
|
case RC_OK:
|
||||||
INFO_LOG_FMT(ACHIEVEMENTS, "RAIntegration.dll found.");
|
INFO_LOG_FMT(ACHIEVEMENTS, "RAIntegration.dll found.");
|
||||||
|
instance.m_dll_found = true;
|
||||||
|
instance.m_dev_menu_callback();
|
||||||
// TODO: hook up menu and dll event handlers
|
// TODO: hook up menu and dll event handlers
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,10 @@
|
||||||
#include "DiscIO/Volume.h"
|
#include "DiscIO/Volume.h"
|
||||||
#include "VideoCommon/Assets/CustomTextureData.h"
|
#include "VideoCommon/Assets/CustomTextureData.h"
|
||||||
|
|
||||||
|
#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
|
#include <rcheevos/include/rc_client_raintegration.h>
|
||||||
|
#endif // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
class CPUThreadGuard;
|
class CPUThreadGuard;
|
||||||
|
@ -161,6 +165,15 @@ public:
|
||||||
const std::unordered_set<AchievementId>& GetActiveChallenges() const;
|
const std::unordered_set<AchievementId>& GetActiveChallenges() const;
|
||||||
std::vector<std::string> GetActiveLeaderboards() const;
|
std::vector<std::string> GetActiveLeaderboards() const;
|
||||||
|
|
||||||
|
#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
|
const rc_client_raintegration_menu_t* GetDevelopmentMenu();
|
||||||
|
u32 ActivateDevMenuItem(u32 menu_item_id);
|
||||||
|
void SetDevMenuUpdateCallback(std::function<void(void)> callback)
|
||||||
|
{
|
||||||
|
m_dev_menu_callback = callback;
|
||||||
|
};
|
||||||
|
#endif // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
|
|
||||||
void DoState(PointerWrap& p);
|
void DoState(PointerWrap& p);
|
||||||
|
|
||||||
void CloseGame();
|
void CloseGame();
|
||||||
|
@ -271,6 +284,11 @@ private:
|
||||||
std::unordered_set<AchievementId> m_active_challenges;
|
std::unordered_set<AchievementId> m_active_challenges;
|
||||||
std::vector<rc_client_leaderboard_tracker_t> m_active_leaderboards;
|
std::vector<rc_client_leaderboard_tracker_t> m_active_leaderboards;
|
||||||
|
|
||||||
|
bool m_dll_found = false;
|
||||||
|
#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
|
std::function<void(void)> m_dev_menu_callback;
|
||||||
|
#endif // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
|
|
||||||
Common::WorkQueueThread<std::function<void()>> m_queue;
|
Common::WorkQueueThread<std::function<void()>> m_queue;
|
||||||
Common::WorkQueueThread<std::function<void()>> m_image_queue;
|
Common::WorkQueueThread<std::function<void()>> m_image_queue;
|
||||||
mutable std::recursive_mutex m_lock;
|
mutable std::recursive_mutex m_lock;
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
|
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
|
||||||
#include "DolphinQt/QtUtils/ModalMessageBox.h"
|
#include "DolphinQt/QtUtils/ModalMessageBox.h"
|
||||||
#include "DolphinQt/QtUtils/ParallelProgressDialog.h"
|
#include "DolphinQt/QtUtils/ParallelProgressDialog.h"
|
||||||
|
#include "DolphinQt/QtUtils/QueueOnObject.h"
|
||||||
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
|
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
|
||||||
#include "DolphinQt/Settings.h"
|
#include "DolphinQt/Settings.h"
|
||||||
#include "DolphinQt/Updater.h"
|
#include "DolphinQt/Updater.h"
|
||||||
|
@ -71,6 +72,10 @@
|
||||||
#include "UICommon/AutoUpdate.h"
|
#include "UICommon/AutoUpdate.h"
|
||||||
#include "UICommon/GameFile.h"
|
#include "UICommon/GameFile.h"
|
||||||
|
|
||||||
|
#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
|
#include <rcheevos/include/rc_client_raintegration.h>
|
||||||
|
#endif // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
|
|
||||||
QPointer<MenuBar> MenuBar::s_menu_bar;
|
QPointer<MenuBar> MenuBar::s_menu_bar;
|
||||||
|
|
||||||
QString MenuBar::GetSignatureSelector() const
|
QString MenuBar::GetSignatureSelector() const
|
||||||
|
@ -284,8 +289,14 @@ void MenuBar::AddToolsMenu()
|
||||||
tools_menu->addSeparator();
|
tools_menu->addSeparator();
|
||||||
|
|
||||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||||
|
m_achievements_action =
|
||||||
tools_menu->addAction(tr("Achievements"), this, [this] { emit ShowAchievementsWindow(); });
|
tools_menu->addAction(tr("Achievements"), this, [this] { emit ShowAchievementsWindow(); });
|
||||||
|
#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
|
m_achievements_dev_menu = tools_menu->addMenu(tr("RetroAchievements Development"));
|
||||||
|
AchievementManager::GetInstance().SetDevMenuUpdateCallback(
|
||||||
|
[this]() { QueueOnObject(this, [this] { this->UpdateAchievementDevelopmentMenu(); }); });
|
||||||
|
m_achievements_dev_menu->menuAction()->setVisible(false);
|
||||||
|
#endif // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
tools_menu->addSeparator();
|
tools_menu->addSeparator();
|
||||||
#endif // USE_RETRO_ACHIEVEMENTS
|
#endif // USE_RETRO_ACHIEVEMENTS
|
||||||
|
|
||||||
|
@ -1123,6 +1134,38 @@ void MenuBar::UpdateToolsMenu(const Core::State state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
|
void MenuBar::UpdateAchievementDevelopmentMenu()
|
||||||
|
{
|
||||||
|
auto* dev_menu = AchievementManager::GetInstance().GetDevelopmentMenu();
|
||||||
|
if (dev_menu)
|
||||||
|
{
|
||||||
|
m_achievements_dev_menu->menuAction()->setVisible(true);
|
||||||
|
m_achievements_dev_menu->clear();
|
||||||
|
for (u32 i = 0; i < dev_menu->num_items; i++)
|
||||||
|
{
|
||||||
|
const auto& menu_item = dev_menu->items[i];
|
||||||
|
if (menu_item.label == nullptr)
|
||||||
|
{
|
||||||
|
m_achievements_dev_menu->addSeparator();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
auto* ra_dev_menu_item = m_achievements_dev_menu->addAction(
|
||||||
|
QString::fromStdString(menu_item.label), this,
|
||||||
|
[menu_item]() { AchievementManager::GetInstance().ActivateDevMenuItem(menu_item.id); });
|
||||||
|
ra_dev_menu_item->setEnabled(menu_item.enabled);
|
||||||
|
// Recommended hardcode by RAIntegration.dll developer Jamiras
|
||||||
|
ra_dev_menu_item->setCheckable(i < 2);
|
||||||
|
ra_dev_menu_item->setChecked(menu_item.checked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_achievements_dev_menu->menuAction()->setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
|
|
||||||
void MenuBar::InstallWAD()
|
void MenuBar::InstallWAD()
|
||||||
{
|
{
|
||||||
QString wad_file = DolphinFileDialog::getOpenFileName(this, tr("Select Title to Install to NAND"),
|
QString wad_file = DolphinFileDialog::getOpenFileName(this, tr("Select Title to Install to NAND"),
|
||||||
|
|
|
@ -44,6 +44,9 @@ public:
|
||||||
explicit MenuBar(QWidget* parent = nullptr);
|
explicit MenuBar(QWidget* parent = nullptr);
|
||||||
|
|
||||||
void UpdateToolsMenu(Core::State state);
|
void UpdateToolsMenu(Core::State state);
|
||||||
|
#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
|
void UpdateAchievementDevelopmentMenu();
|
||||||
|
#endif // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
|
|
||||||
QMenu* GetListColumnsMenu() const { return m_cols_menu; }
|
QMenu* GetListColumnsMenu() const { return m_cols_menu; }
|
||||||
|
|
||||||
|
@ -205,6 +208,10 @@ private:
|
||||||
QAction* m_wad_install_action;
|
QAction* m_wad_install_action;
|
||||||
QMenu* m_perform_online_update_menu;
|
QMenu* m_perform_online_update_menu;
|
||||||
QAction* m_perform_online_update_for_current_region;
|
QAction* m_perform_online_update_for_current_region;
|
||||||
|
QAction* m_achievements_action;
|
||||||
|
#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
|
QMenu* m_achievements_dev_menu;
|
||||||
|
#endif // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
QAction* m_ntscj_ipl;
|
QAction* m_ntscj_ipl;
|
||||||
QAction* m_ntscu_ipl;
|
QAction* m_ntscu_ipl;
|
||||||
QAction* m_pal_ipl;
|
QAction* m_pal_ipl;
|
||||||
|
|
Loading…
Add table
Reference in a new issue