mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-12-28 03:14:15 +08:00
Added realtime progress update
This commit is contained in:
parent
4e8f2505b5
commit
b0cffd485b
@ -1151,6 +1151,10 @@ bool Steam_User_Stats::IndicateAchievementProgress( const char *pchName, uint32
|
||||
user_achievements[actual_ach_name]["progress"] = nCurProgress;
|
||||
user_achievements[actual_ach_name]["max_progress"] = nMaxProgress;
|
||||
save_achievements();
|
||||
if (!settings->disable_overlay) {
|
||||
overlay->AddAchievementNotification(it.value());
|
||||
overlay->update_achievement_progress(actual_ach_name, nCurProgress);
|
||||
}
|
||||
} catch (...) {}
|
||||
|
||||
{
|
||||
@ -1870,6 +1874,9 @@ bool Steam_User_Stats::GetAchievementProgressLimits( const char *pchName, float
|
||||
catch (...) {}
|
||||
if (defined_achievements.end() == it) return false;
|
||||
|
||||
if (pfMinProgress) *pfMinProgress = 0;
|
||||
if (pfMaxProgress) *pfMaxProgress = 0;
|
||||
|
||||
try {
|
||||
std::string pch_name = it->value("name", std::string());
|
||||
auto ach = user_achievements.find(pch_name);
|
||||
|
@ -254,6 +254,7 @@ public:
|
||||
void FriendDisconnect(Friend _friend);
|
||||
|
||||
void AddAchievementNotification(nlohmann::json const& ach);
|
||||
void update_achievement_progress(std::string const& ach_name, uint32 nCurProgress);
|
||||
};
|
||||
|
||||
#else // EMU_OVERLAY
|
||||
@ -288,6 +289,7 @@ public:
|
||||
void FriendDisconnect(Friend _friend) {}
|
||||
|
||||
void AddAchievementNotification(nlohmann::json const& ach) {}
|
||||
void update_achievement_progress(std::string const& ach_name, uint32 nCurProgress);
|
||||
};
|
||||
|
||||
#endif // EMU_OVERLAY
|
||||
|
@ -365,10 +365,11 @@ void Steam_Overlay::load_achievements_data()
|
||||
ach.icon_name = steamUserStats->get_achievement_icon_name(ach.name.c_str(), true);
|
||||
ach.icon_gray_name = steamUserStats->get_achievement_icon_name(ach.name.c_str(), false);
|
||||
|
||||
float pnMinProgress, pnMaxProgress;
|
||||
steamUserStats->GetAchievementProgressLimits(ach.name.c_str(), &pnMinProgress, &pnMaxProgress);
|
||||
ach.progress = pnMinProgress;
|
||||
ach.max_progress = pnMaxProgress;
|
||||
float pnMinProgress = 0, pnMaxProgress = 0;
|
||||
if (steamUserStats->GetAchievementProgressLimits(ach.name.c_str(), &pnMinProgress, &pnMaxProgress)) {
|
||||
ach.progress = pnMinProgress;
|
||||
ach.max_progress = pnMaxProgress;
|
||||
}
|
||||
|
||||
achievements.push_back(ach);
|
||||
|
||||
@ -379,6 +380,20 @@ void Steam_Overlay::load_achievements_data()
|
||||
|
||||
}
|
||||
|
||||
void Steam_Overlay::update_achievement_progress(std::string const& ach_name, uint32 nCurProgress) {
|
||||
|
||||
PRINT_DEBUG_ENTRY();
|
||||
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||
|
||||
for (auto& ach : achievements) {
|
||||
if (ach.name == ach_name) {
|
||||
ach.progress = (float)nCurProgress;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Steam_Overlay::initial_load_achievements_icons()
|
||||
{
|
||||
{
|
||||
@ -1459,7 +1474,7 @@ void Steam_Overlay::render_main_window()
|
||||
} else {
|
||||
ImGui::TextColored(ImVec4(255, 0, 0, 255), "%s", translationNotAchieved[current_language]);
|
||||
if (x.max_progress > 0) {
|
||||
char buf[32];
|
||||
char buf[32]{};
|
||||
sprintf(buf, "%d/%d", (int)x.progress, (int)x.max_progress);
|
||||
ImGui::ProgressBar(x.progress / x.max_progress, { -1 , settings->overlay_appearance.font_size }, buf);
|
||||
}
|
||||
@ -1972,29 +1987,25 @@ void Steam_Overlay::AddAchievementNotification(nlohmann::json const &ach)
|
||||
// otherwise when you open the achievements list/menu you won't see the new unlock status
|
||||
|
||||
// adjust the local 'is_achieved' and 'unlock_time'
|
||||
std::vector<Overlay_Achievement*> found_achs{};
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock2(global_mutex);
|
||||
std::lock_guard<std::recursive_mutex> lock2(global_mutex);
|
||||
|
||||
std::string ach_name = ach.value("name", std::string());
|
||||
for (auto &a : achievements) {
|
||||
if (a.name == ach_name) {
|
||||
found_achs.push_back(&a);
|
||||
|
||||
bool achieved = false;
|
||||
uint32 unlock_time = 0;
|
||||
get_steam_client()->steam_user_stats->GetAchievementAndUnlockTime(a.name.c_str(), &achieved, &unlock_time);
|
||||
a.achieved = achieved;
|
||||
a.unlock_time = unlock_time;
|
||||
std::string ach_name = ach.value("name", std::string());
|
||||
for (auto &a : achievements) {
|
||||
if (a.name == ach_name) {
|
||||
bool achieved = false;
|
||||
uint32 unlock_time = 0;
|
||||
|
||||
get_steam_client()->steam_user_stats->GetAchievementAndUnlockTime(a.name.c_str(), &achieved, &unlock_time);
|
||||
a.achieved = achieved;
|
||||
a.unlock_time = unlock_time;
|
||||
|
||||
if (achieved) {
|
||||
post_achievement_notification(a);
|
||||
notify_sound_user_achievement();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto found_ach : found_achs) {
|
||||
post_achievement_notification(*found_ach);
|
||||
}
|
||||
|
||||
notify_sound_user_achievement();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user