Refactored welcome message to render after game start
Split the "welcome" messages letting players know achievements are active into a separate method that gets called (currently) after a number of frames to ensure that the emulator has started properly and has somewhere to display the messages.
This commit is contained in:
parent
a3d561fdff
commit
db78437498
|
@ -195,32 +195,11 @@ void AchievementManager::LoadGameByFilenameAsync(const std::string& iso_path,
|
|||
{
|
||||
std::lock_guard lg{m_lock};
|
||||
m_is_game_loaded = true;
|
||||
m_framecount = 0;
|
||||
LoadUnlockData([](ResponseType r_type) {});
|
||||
ActivateDeactivateAchievements();
|
||||
ActivateDeactivateLeaderboards();
|
||||
ActivateDeactivateRichPresence();
|
||||
PointSpread spread = TallyScore();
|
||||
if (hardcore_mode_enabled)
|
||||
{
|
||||
OSD::AddMessage(
|
||||
fmt::format("You have {}/{} achievements worth {}/{} points", spread.hard_unlocks,
|
||||
spread.total_count, spread.hard_points, spread.total_points),
|
||||
OSD::Duration::VERY_LONG, OSD::Color::YELLOW,
|
||||
(Config::Get(Config::RA_BADGES_ENABLED)) ? DecodeBadgeToOSDIcon(m_game_badge.badge) :
|
||||
nullptr);
|
||||
OSD::AddMessage("Hardcore mode is ON", OSD::Duration::VERY_LONG, OSD::Color::YELLOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSD::AddMessage(fmt::format("You have {}/{} achievements worth {}/{} points",
|
||||
spread.hard_unlocks + spread.soft_unlocks, spread.total_count,
|
||||
spread.hard_points + spread.soft_points, spread.total_points),
|
||||
OSD::Duration::VERY_LONG, OSD::Color::CYAN,
|
||||
(Config::Get(Config::RA_BADGES_ENABLED)) ?
|
||||
DecodeBadgeToOSDIcon(m_game_badge.badge) :
|
||||
nullptr);
|
||||
OSD::AddMessage("Hardcore mode is OFF", OSD::Duration::VERY_LONG, OSD::Color::CYAN);
|
||||
}
|
||||
}
|
||||
FetchBadges();
|
||||
// Reset this to zero so that RP immediately triggers on the first frame
|
||||
|
@ -562,6 +541,14 @@ void AchievementManager::DoFrame()
|
|||
{
|
||||
if (!m_is_game_loaded)
|
||||
return;
|
||||
if (m_framecount == 0x200)
|
||||
{
|
||||
DisplayWelcomeMessage();
|
||||
}
|
||||
if (m_framecount <= 0x200)
|
||||
{
|
||||
m_framecount++;
|
||||
}
|
||||
Core::RunAsCPUThread([&] {
|
||||
rc_runtime_do_frame(
|
||||
&m_runtime,
|
||||
|
@ -1194,6 +1181,33 @@ AchievementManager::PingRichPresence(const RichPresence& rich_presence)
|
|||
return r_type;
|
||||
}
|
||||
|
||||
void AchievementManager::DisplayWelcomeMessage()
|
||||
{
|
||||
std::lock_guard lg{m_lock};
|
||||
PointSpread spread = TallyScore();
|
||||
if (hardcore_mode_enabled)
|
||||
{
|
||||
OSD::AddMessage(
|
||||
fmt::format("You have {}/{} achievements worth {}/{} points", spread.hard_unlocks,
|
||||
spread.total_count, spread.hard_points, spread.total_points),
|
||||
OSD::Duration::VERY_LONG, OSD::Color::YELLOW,
|
||||
(Config::Get(Config::RA_BADGES_ENABLED)) ? DecodeBadgeToOSDIcon(m_game_badge.badge) :
|
||||
nullptr);
|
||||
OSD::AddMessage("Hardcore mode is ON", OSD::Duration::VERY_LONG, OSD::Color::YELLOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSD::AddMessage(fmt::format("You have {}/{} achievements worth {}/{} points",
|
||||
spread.hard_unlocks + spread.soft_unlocks, spread.total_count,
|
||||
spread.hard_points + spread.soft_points, spread.total_points),
|
||||
OSD::Duration::VERY_LONG, OSD::Color::CYAN,
|
||||
(Config::Get(Config::RA_BADGES_ENABLED)) ?
|
||||
DecodeBadgeToOSDIcon(m_game_badge.badge) :
|
||||
nullptr);
|
||||
OSD::AddMessage("Hardcore mode is OFF", OSD::Duration::VERY_LONG, OSD::Color::CYAN);
|
||||
}
|
||||
}
|
||||
|
||||
void AchievementManager::HandleAchievementTriggeredEvent(const rc_runtime_event_t* runtime_event)
|
||||
{
|
||||
const auto event_id = runtime_event->id;
|
||||
|
|
|
@ -155,6 +155,8 @@ private:
|
|||
ResponseType SubmitLeaderboard(AchievementId leaderboard_id, int value);
|
||||
ResponseType PingRichPresence(const RichPresence& rich_presence);
|
||||
|
||||
void DisplayWelcomeMessage();
|
||||
|
||||
void HandleAchievementTriggeredEvent(const rc_runtime_event_t* runtime_event);
|
||||
void HandleAchievementProgressUpdatedEvent(const rc_runtime_event_t* runtime_event);
|
||||
void HandleLeaderboardStartedEvent(const rc_runtime_event_t* runtime_event);
|
||||
|
@ -178,6 +180,7 @@ private:
|
|||
u32 m_game_id = 0;
|
||||
rc_api_fetch_game_data_response_t m_game_data{};
|
||||
bool m_is_game_loaded = false;
|
||||
u32 m_framecount = 0;
|
||||
BadgeStatus m_game_badge;
|
||||
RichPresence m_rich_presence;
|
||||
time_t m_last_ping_time = 0;
|
||||
|
|
Loading…
Reference in New Issue