mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-24 22:34:54 +00:00
Add RAIntegration event handler
Some refactoring done to hardcore toggling so that it's more readily available for the toggle hardcore event.
This commit is contained in:
parent
9caa02493d
commit
90a4be4b36
8 changed files with 43 additions and 21 deletions
|
@ -1438,6 +1438,7 @@ 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_dll_found = true;
|
||||||
|
rc_client_raintegration_set_event_handler(instance.m_client, RAIntegrationEventHandler);
|
||||||
instance.m_dev_menu_callback();
|
instance.m_dev_menu_callback();
|
||||||
// TODO: hook up menu and dll event handlers
|
// TODO: hook up menu and dll event handlers
|
||||||
break;
|
break;
|
||||||
|
@ -1456,6 +1457,31 @@ void AchievementManager::LoadIntegrationCallback(int result, const char* error_m
|
||||||
instance.Login("");
|
instance.Login("");
|
||||||
INFO_LOG_FMT(ACHIEVEMENTS, "Achievement Manager Initialized");
|
INFO_LOG_FMT(ACHIEVEMENTS, "Achievement Manager Initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AchievementManager::RAIntegrationEventHandler(const rc_client_raintegration_event_t* event,
|
||||||
|
rc_client_t* client)
|
||||||
|
{
|
||||||
|
auto& instance = AchievementManager::GetInstance();
|
||||||
|
switch (event->type)
|
||||||
|
{
|
||||||
|
case RC_CLIENT_RAINTEGRATION_EVENT_MENU_CHANGED:
|
||||||
|
case RC_CLIENT_RAINTEGRATION_EVENT_MENUITEM_CHECKED_CHANGED:
|
||||||
|
instance.m_dev_menu_callback();
|
||||||
|
break;
|
||||||
|
case RC_CLIENT_RAINTEGRATION_EVENT_PAUSE:
|
||||||
|
{
|
||||||
|
Core::QueueHostJob([](Core::System& system) { Core::SetState(system, Core::State::Paused); });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RC_CLIENT_RAINTEGRATION_EVENT_HARDCORE_CHANGED:
|
||||||
|
Config::SetBaseOrCurrent(Config::RA_HARDCORE_ENABLED,
|
||||||
|
!Config::Get(Config::RA_HARDCORE_ENABLED));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
WARN_LOG_FMT(ACHIEVEMENTS, "Unsupported raintegration event. {}", event->type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
#endif // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
|
|
||||||
#endif // USE_RETRO_ACHIEVEMENTS
|
#endif // USE_RETRO_ACHIEVEMENTS
|
||||||
|
|
|
@ -251,6 +251,8 @@ private:
|
||||||
#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION
|
#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
static void LoadIntegrationCallback(int result, const char* error_message, rc_client_t* client,
|
static void LoadIntegrationCallback(int result, const char* error_message, rc_client_t* client,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
|
static void RAIntegrationEventHandler(const rc_client_raintegration_event_t* event,
|
||||||
|
rc_client_t* client);
|
||||||
#endif // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
#endif // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||||
|
|
||||||
rc_runtime_t m_runtime{};
|
rc_runtime_t m_runtime{};
|
||||||
|
|
|
@ -34,10 +34,6 @@ AchievementSettingsWidget::AchievementSettingsWidget(QWidget* parent) : QWidget(
|
||||||
|
|
||||||
connect(&Settings::Instance(), &Settings::ConfigChanged, this,
|
connect(&Settings::Instance(), &Settings::ConfigChanged, this,
|
||||||
&AchievementSettingsWidget::LoadSettings);
|
&AchievementSettingsWidget::LoadSettings);
|
||||||
|
|
||||||
// If hardcore is enabled when the emulator starts, make sure it turns off what it needs to
|
|
||||||
if (Config::Get(Config::RA_HARDCORE_ENABLED))
|
|
||||||
UpdateHardcoreMode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AchievementSettingsWidget::UpdateData(int login_failed_code)
|
void AchievementSettingsWidget::UpdateData(int login_failed_code)
|
||||||
|
@ -259,7 +255,6 @@ void AchievementSettingsWidget::ToggleRAIntegration()
|
||||||
instance.Init(reinterpret_cast<void*>(winId()));
|
instance.Init(reinterpret_cast<void*>(winId()));
|
||||||
else
|
else
|
||||||
instance.Shutdown();
|
instance.Shutdown();
|
||||||
UpdateHardcoreMode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AchievementSettingsWidget::Login()
|
void AchievementSettingsWidget::Login()
|
||||||
|
@ -297,7 +292,6 @@ void AchievementSettingsWidget::ToggleHardcore()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
UpdateHardcoreMode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AchievementSettingsWidget::ToggleUnofficial()
|
void AchievementSettingsWidget::ToggleUnofficial()
|
||||||
|
@ -327,14 +321,4 @@ void AchievementSettingsWidget::ToggleProgress()
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AchievementSettingsWidget::UpdateHardcoreMode()
|
|
||||||
{
|
|
||||||
if (Config::Get(Config::RA_HARDCORE_ENABLED))
|
|
||||||
{
|
|
||||||
Settings::Instance().SetDebugModeEnabled(false);
|
|
||||||
}
|
|
||||||
emit Settings::Instance().EmulationStateChanged(Core::GetState(Core::System::GetInstance()));
|
|
||||||
emit Settings::Instance().HardcoreStateChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // USE_RETRO_ACHIEVEMENTS
|
#endif // USE_RETRO_ACHIEVEMENTS
|
||||||
|
|
|
@ -39,8 +39,6 @@ private:
|
||||||
void ToggleDiscordPresence();
|
void ToggleDiscordPresence();
|
||||||
void ToggleProgress();
|
void ToggleProgress();
|
||||||
|
|
||||||
void UpdateHardcoreMode();
|
|
||||||
|
|
||||||
QGroupBox* m_common_box;
|
QGroupBox* m_common_box;
|
||||||
QVBoxLayout* m_common_layout;
|
QVBoxLayout* m_common_layout;
|
||||||
ToolTipCheckBox* m_common_integration_enabled_input;
|
ToolTipCheckBox* m_common_integration_enabled_input;
|
||||||
|
|
|
@ -39,8 +39,6 @@ AchievementsWindow::AchievementsWindow(QWidget* parent) : QDialog(parent)
|
||||||
});
|
});
|
||||||
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
|
||||||
[this] { m_settings_widget->UpdateData(RC_OK); });
|
[this] { m_settings_widget->UpdateData(RC_OK); });
|
||||||
connect(&Settings::Instance(), &Settings::HardcoreStateChanged, this,
|
|
||||||
[this] { AchievementsWindow::UpdateData({.all = true}); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AchievementsWindow::showEvent(QShowEvent* event)
|
void AchievementsWindow::showEvent(QShowEvent* event)
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include "Core/BootManager.h"
|
#include "Core/BootManager.h"
|
||||||
#include "Core/CommonTitles.h"
|
#include "Core/CommonTitles.h"
|
||||||
#include "Core/Config/AchievementSettings.h"
|
#include "Core/Config/AchievementSettings.h"
|
||||||
|
#include "Core/Config/FreeLookSettings.h"
|
||||||
#include "Core/Config/MainSettings.h"
|
#include "Core/Config/MainSettings.h"
|
||||||
#include "Core/Config/NetplaySettings.h"
|
#include "Core/Config/NetplaySettings.h"
|
||||||
#include "Core/Config/UISettings.h"
|
#include "Core/Config/UISettings.h"
|
||||||
|
@ -275,6 +276,12 @@ MainWindow::MainWindow(Core::System& system, std::unique_ptr<BootParameters> boo
|
||||||
AchievementManager::GetInstance().Init(reinterpret_cast<void*>(winId()));
|
AchievementManager::GetInstance().Init(reinterpret_cast<void*>(winId()));
|
||||||
if (AchievementManager::GetInstance().IsHardcoreModeActive())
|
if (AchievementManager::GetInstance().IsHardcoreModeActive())
|
||||||
Settings::Instance().SetDebugModeEnabled(false);
|
Settings::Instance().SetDebugModeEnabled(false);
|
||||||
|
// This needs to trigger on both RA_HARDCORE_ENABLED and RA_ENABLED
|
||||||
|
Config::AddConfigChangedCallback(
|
||||||
|
[this]() { QueueOnObject(this, [this] { this->OnHardcoreChanged(); }); });
|
||||||
|
// If hardcore is enabled when the emulator starts, make sure it turns off what it needs to
|
||||||
|
if (Config::Get(Config::RA_HARDCORE_ENABLED))
|
||||||
|
OnHardcoreChanged();
|
||||||
#endif // USE_RETRO_ACHIEVEMENTS
|
#endif // USE_RETRO_ACHIEVEMENTS
|
||||||
|
|
||||||
#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
|
#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
|
||||||
|
@ -1992,6 +1999,13 @@ void MainWindow::ShowAchievementSettings()
|
||||||
ShowAchievementsWindow();
|
ShowAchievementsWindow();
|
||||||
m_achievements_window->ForceSettingsTab();
|
m_achievements_window->ForceSettingsTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::OnHardcoreChanged()
|
||||||
|
{
|
||||||
|
if (Config::Get(Config::RA_HARDCORE_ENABLED))
|
||||||
|
Settings::Instance().SetDebugModeEnabled(false);
|
||||||
|
emit Settings::Instance().EmulationStateChanged(Core::GetState(Core::System::GetInstance()));
|
||||||
|
}
|
||||||
#endif // USE_RETRO_ACHIEVEMENTS
|
#endif // USE_RETRO_ACHIEVEMENTS
|
||||||
|
|
||||||
void MainWindow::ShowMemcardManager()
|
void MainWindow::ShowMemcardManager()
|
||||||
|
|
|
@ -181,6 +181,7 @@ private:
|
||||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||||
void ShowAchievementsWindow();
|
void ShowAchievementsWindow();
|
||||||
void ShowAchievementSettings();
|
void ShowAchievementSettings();
|
||||||
|
void OnHardcoreChanged();
|
||||||
#endif // USE_RETRO_ACHIEVEMENTS
|
#endif // USE_RETRO_ACHIEVEMENTS
|
||||||
|
|
||||||
void NetPlayInit();
|
void NetPlayInit();
|
||||||
|
|
|
@ -222,7 +222,6 @@ signals:
|
||||||
void SDCardInsertionChanged(bool inserted);
|
void SDCardInsertionChanged(bool inserted);
|
||||||
void USBKeyboardConnectionChanged(bool connected);
|
void USBKeyboardConnectionChanged(bool connected);
|
||||||
void EnableGfxModsChanged(bool enabled);
|
void EnableGfxModsChanged(bool enabled);
|
||||||
void HardcoreStateChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings();
|
Settings();
|
||||||
|
|
Loading…
Add table
Reference in a new issue