Merge pull request #2281 from CookiePLMonster/leaderboards-hardcore-only

Allow submitting entries to Leaderboards only in Hardcore Mode.
This commit is contained in:
Connor McLaughlin 2021-06-20 01:19:56 +10:00 committed by GitHub
commit 1fe85a0d91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -590,6 +590,19 @@ static void DisplayAchievementSummary()
{
summary = GetHostInterface()->TranslateString("Cheevos", "This game has no achievements.");
}
if (GetLeaderboardCount() > 0)
{
summary.push_back('\n');
if (g_challenge_mode)
{
summary.append(GetHostInterface()->TranslateString("Cheevos", "Leaderboards are enabled."));
}
else
{
summary.append(
GetHostInterface()->TranslateString("Cheevos", "Leaderboards are DISABLED because Hardcore Mode is off."));
}
}
ImGuiFullscreen::AddNotification(10.0f, std::move(title), std::move(summary), s_game_icon);
}
@ -1350,6 +1363,13 @@ void SubmitLeaderboard(u32 leaderboard_id, int value)
return;
}
if (!g_challenge_mode)
{
Log_WarningPrintf("Skipping sending leaderboard %u result to server because Challenge mode is off.",
leaderboard_id);
return;
}
char url[512];
rc_url_submit_lboard(url, sizeof(url), s_username.c_str(), s_login_token.c_str(), leaderboard_id, value);
s_http_downloader->CreateRequest(url, SubmitLeaderboardCallback);

View File

@ -4505,6 +4505,18 @@ void DrawLeaderboardsWindow()
ImGui::PushFont(g_medium_font);
ImGui::RenderTextClipped(summary_bb.Min, summary_bb.Max, text.GetCharArray(),
text.GetCharArray() + text.GetLength(), nullptr, ImVec2(0.0f, 0.0f), &summary_bb);
if (!IsCheevosHardcoreModeActive())
{
const ImRect hardcore_warning_bb(ImVec2(left, top), ImVec2(right, top + g_medium_font->FontSize));
top += g_medium_font->FontSize + spacing;
ImGui::RenderTextClipped(
hardcore_warning_bb.Min, hardcore_warning_bb.Max,
"Submitting scores is DISABLED because Hardcore Mode is off. Leaderboards are read-only.", nullptr, nullptr,
ImVec2(0.0f, 0.0f), &hardcore_warning_bb);
}
ImGui::PopFont();
}