Merge pull request #12905 from LillyJadeKatrin/retroachievements-hotkey

Add Open Achievements Hotkey
This commit is contained in:
Admiral H. Curtiss 2024-07-06 14:23:47 +02:00 committed by GitHub
commit 02e1b94149
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 27 additions and 6 deletions

View File

@ -882,9 +882,7 @@ void AchievementManager::HandleAchievementChallengeIndicatorShowEvent(
const auto [iter, inserted] = instance.m_active_challenges.insert(client_event->achievement->id);
if (inserted)
instance.m_challenges_updated = true;
OSD::AddMessage(fmt::format("Challenge Started: {}", client_event->achievement->title),
OSD::Duration::VERY_LONG, OSD::Color::GREEN,
&instance.GetAchievementBadge(client_event->achievement->id, false));
AchievementManager::GetInstance().m_update_callback(UpdatedItems{.rich_presence = true});
}
void AchievementManager::HandleAchievementChallengeIndicatorHideEvent(
@ -894,9 +892,7 @@ void AchievementManager::HandleAchievementChallengeIndicatorHideEvent(
const auto removed = instance.m_active_challenges.erase(client_event->achievement->id);
if (removed > 0)
instance.m_challenges_updated = true;
OSD::AddMessage(fmt::format("Challenge Ended: {}", client_event->achievement->title),
OSD::Duration::VERY_LONG, OSD::Color::GREEN,
&instance.GetAchievementBadge(client_event->achievement->id, false));
AchievementManager::GetInstance().m_update_callback(UpdatedItems{.rich_presence = true});
}
void AchievementManager::HandleAchievementProgressIndicatorShowEvent(

View File

@ -38,6 +38,9 @@ constexpr std::array<const char*, NUM_HOTKEYS> s_hotkey_labels{{
_trans("Center Mouse"),
_trans("Activate NetPlay Chat"),
_trans("Control NetPlay Golf Mode"),
#ifdef USE_RETRO_ACHIEVEMENTS
_trans("Open Achievements"),
#endif // USE_RETRO_ACHIEVEMENTS
_trans("Volume Down"),
_trans("Volume Up"),
@ -330,7 +333,11 @@ struct HotkeyGroupInfo
};
constexpr std::array<HotkeyGroupInfo, NUM_HOTKEY_GROUPS> s_groups_info = {
#ifdef USE_RETRO_ACHIEVEMENTS
{{_trans("General"), HK_OPEN, HK_OPEN_ACHIEVEMENTS},
#else // USE_RETRO_ACHIEVEMENTS
{{_trans("General"), HK_OPEN, HK_REQUEST_GOLF_CONTROL},
#endif // USE_RETROACHIEVEMENTS
{_trans("Volume"), HK_VOLUME_DOWN, HK_VOLUME_TOGGLE_MUTE},
{_trans("Emulation Speed"), HK_DECREASE_EMULATION_SPEED, HK_TOGGLE_THROTTLE},
{_trans("Frame Advance"), HK_FRAME_ADVANCE, HK_FRAME_ADVANCE_RESET_SPEED},
@ -448,6 +455,9 @@ void HotkeyManager::LoadDefaults(const ControllerInterface& ciface)
set_key_expression(HK_STOP, "Escape");
set_key_expression(HK_FULLSCREEN, hotkey_string({"Alt", "Return"}));
#endif
#ifdef USE_RETRO_ACHIEVEMENTS
set_key_expression(HK_OPEN_ACHIEVEMENTS, hotkey_string({"Alt", "A"}));
#endif // USE_RETRO_ACHIEVEMENTS
set_key_expression(HK_STEP, "F11");
set_key_expression(HK_STEP_OVER, hotkey_string({"Shift", "F10"}));
set_key_expression(HK_STEP_OUT, hotkey_string({"Shift", "F11"}));

View File

@ -32,6 +32,9 @@ enum Hotkey
HK_CENTER_MOUSE,
HK_ACTIVATE_CHAT,
HK_REQUEST_GOLF_CONTROL,
#ifdef USE_RETRO_ACHIEVEMENTS
HK_OPEN_ACHIEVEMENTS,
#endif // USE_RETRO_ACHIEVEMENTS
HK_VOLUME_DOWN,
HK_VOLUME_UP,

View File

@ -192,6 +192,11 @@ void HotkeyScheduler::Run()
if (IsHotkey(HK_EXIT))
emit ExitHotkey();
#ifdef USE_RETRO_ACHIEVEMENTS
if (IsHotkey(HK_OPEN_ACHIEVEMENTS))
emit OpenAchievements();
#endif // USE_RETRO_ACHIEVEMENTS
if (!Core::IsRunning(system))
{
// Only check for Play Recording hotkey when no game is running

View File

@ -53,6 +53,9 @@ signals:
void ExportRecording();
void ToggleReadOnlyMode();
void ConnectWiiRemote(int id);
#ifdef USE_RETRO_ACHIEVEMENTS
void OpenAchievements();
#endif // USE_RETRO_ACHIEVEMENTS
void Step();
void StepOver();

View File

@ -658,6 +658,10 @@ void MainWindow::ConnectHotkeys()
movie.SetReadOnly(read_only);
emit ReadOnlyModeChanged(read_only);
});
#ifdef USE_RETRO_ACHIEVEMENTS
connect(m_hotkey_scheduler, &HotkeyScheduler::OpenAchievements, this,
&MainWindow::ShowAchievementsWindow, Qt::QueuedConnection);
#endif // USE_RETRO_ACHIEVEMENTS
connect(m_hotkey_scheduler, &HotkeyScheduler::Step, m_code_widget, &CodeWidget::Step);
connect(m_hotkey_scheduler, &HotkeyScheduler::StepOver, m_code_widget, &CodeWidget::StepOver);