mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-04-30 15:15:41 -04:00
Merge pull request #3059 from CookiePLMonster/fix-total-unofficial-achievements
Achievements: Fix the percentage counter when only unofficial achievements exist
This commit is contained in:
commit
e5af7fefde
@ -1008,7 +1008,7 @@ void Achievements::DisplayAchievementSummary()
|
|||||||
if (s_game_summary.num_core_achievements > 0)
|
if (s_game_summary.num_core_achievements > 0)
|
||||||
{
|
{
|
||||||
summary = fmt::format(
|
summary = fmt::format(
|
||||||
TRANSLATE_FS("Achievements", "You have unlocked {} of {} achievements, and earned {} of {} points."),
|
TRANSLATE_FS("Achievements", "You have unlocked {0} of {1} achievements, and earned {2} of {3} points."),
|
||||||
s_game_summary.num_unlocked_achievements, s_game_summary.num_core_achievements, s_game_summary.points_unlocked,
|
s_game_summary.num_unlocked_achievements, s_game_summary.num_core_achievements, s_game_summary.points_unlocked,
|
||||||
s_game_summary.points_core);
|
s_game_summary.points_core);
|
||||||
}
|
}
|
||||||
@ -2184,17 +2184,24 @@ void Achievements::DrawAchievementsWindow()
|
|||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
|
|
||||||
const ImRect summary_bb(ImVec2(left, top), ImVec2(right, top + g_medium_font->FontSize));
|
const ImRect summary_bb(ImVec2(left, top), ImVec2(right, top + g_medium_font->FontSize));
|
||||||
if (s_game_summary.num_unlocked_achievements == s_game_summary.num_core_achievements)
|
if (s_game_summary.num_core_achievements > 0)
|
||||||
{
|
{
|
||||||
text.fmt(TRANSLATE_FS("Achievements", "You have unlocked all achievements and earned {} points!"),
|
if (s_game_summary.num_unlocked_achievements == s_game_summary.num_core_achievements)
|
||||||
s_game_summary.points_unlocked);
|
{
|
||||||
|
text.fmt(TRANSLATE_FS("Achievements", "You have unlocked all achievements and earned {} points!"),
|
||||||
|
s_game_summary.points_unlocked);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text.fmt(TRANSLATE_FS("Achievements",
|
||||||
|
"You have unlocked {0} of {1} achievements, earning {2} of {3} possible points."),
|
||||||
|
s_game_summary.num_unlocked_achievements, s_game_summary.num_core_achievements,
|
||||||
|
s_game_summary.points_unlocked, s_game_summary.points_core);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
text.fmt(
|
text.assign(TRANSLATE_SV("Achievements", "This game has no achievements."));
|
||||||
TRANSLATE_FS("Achievements", "You have unlocked {} of {} achievements, earning {} of {} possible points."),
|
|
||||||
s_game_summary.num_unlocked_achievements, s_game_summary.num_core_achievements,
|
|
||||||
s_game_summary.points_unlocked, s_game_summary.points_core);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
top += g_medium_font->FontSize + spacing;
|
top += g_medium_font->FontSize + spacing;
|
||||||
@ -2204,23 +2211,26 @@ void Achievements::DrawAchievementsWindow()
|
|||||||
ImVec2(0.0f, 0.0f), &summary_bb);
|
ImVec2(0.0f, 0.0f), &summary_bb);
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
|
|
||||||
const float progress_height = ImGuiFullscreen::LayoutScale(20.0f);
|
if (s_game_summary.num_core_achievements > 0)
|
||||||
const ImRect progress_bb(ImVec2(left, top), ImVec2(right, top + progress_height));
|
{
|
||||||
const float fraction = static_cast<float>(s_game_summary.num_unlocked_achievements) /
|
const float progress_height = ImGuiFullscreen::LayoutScale(20.0f);
|
||||||
static_cast<float>(s_game_summary.num_core_achievements);
|
const ImRect progress_bb(ImVec2(left, top), ImVec2(right, top + progress_height));
|
||||||
dl->AddRectFilled(progress_bb.Min, progress_bb.Max, ImGui::GetColorU32(ImGuiFullscreen::UIPrimaryDarkColor));
|
const float fraction = static_cast<float>(s_game_summary.num_unlocked_achievements) /
|
||||||
dl->AddRectFilled(progress_bb.Min,
|
static_cast<float>(s_game_summary.num_core_achievements);
|
||||||
ImVec2(progress_bb.Min.x + fraction * progress_bb.GetWidth(), progress_bb.Max.y),
|
dl->AddRectFilled(progress_bb.Min, progress_bb.Max, ImGui::GetColorU32(ImGuiFullscreen::UIPrimaryDarkColor));
|
||||||
ImGui::GetColorU32(ImGuiFullscreen::UISecondaryColor));
|
dl->AddRectFilled(progress_bb.Min,
|
||||||
|
ImVec2(progress_bb.Min.x + fraction * progress_bb.GetWidth(), progress_bb.Max.y),
|
||||||
|
ImGui::GetColorU32(ImGuiFullscreen::UISecondaryColor));
|
||||||
|
|
||||||
text.fmt("{}%", static_cast<int>(std::round(fraction * 100.0f)));
|
text.fmt("{}%", static_cast<int>(std::round(fraction * 100.0f)));
|
||||||
text_size = ImGui::CalcTextSize(text.c_str(), text.end_ptr());
|
text_size = ImGui::CalcTextSize(text.c_str(), text.end_ptr());
|
||||||
const ImVec2 text_pos(progress_bb.Min.x + ((progress_bb.Max.x - progress_bb.Min.x) / 2.0f) - (text_size.x / 2.0f),
|
const ImVec2 text_pos(
|
||||||
progress_bb.Min.y + ((progress_bb.Max.y - progress_bb.Min.y) / 2.0f) -
|
progress_bb.Min.x + ((progress_bb.Max.x - progress_bb.Min.x) / 2.0f) - (text_size.x / 2.0f),
|
||||||
(text_size.y / 2.0f));
|
progress_bb.Min.y + ((progress_bb.Max.y - progress_bb.Min.y) / 2.0f) - (text_size.y / 2.0f));
|
||||||
dl->AddText(g_medium_font, g_medium_font->FontSize, text_pos,
|
dl->AddText(g_medium_font, g_medium_font->FontSize, text_pos,
|
||||||
ImGui::GetColorU32(ImGuiFullscreen::UIPrimaryTextColor), text.c_str(), text.end_ptr());
|
ImGui::GetColorU32(ImGuiFullscreen::UIPrimaryTextColor), text.c_str(), text.end_ptr());
|
||||||
top += progress_height + spacing;
|
top += progress_height + spacing;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGuiFullscreen::EndFullscreenWindow();
|
ImGuiFullscreen::EndFullscreenWindow();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user