fixed highscores
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
#include "MenuState.h"
|
||||
#include "persistence/Scores.h"
|
||||
#include "../network/supabase_client.h"
|
||||
#include "graphics/Font.h"
|
||||
#include "../graphics/ui/HelpOverlay.h"
|
||||
#include "../core/GlobalState.h"
|
||||
@ -169,6 +170,24 @@ void MenuState::onEnter() {
|
||||
if (ctx.exitPopupSelectedButton) {
|
||||
*ctx.exitPopupSelectedButton = 1;
|
||||
}
|
||||
// Refresh highscores for classic/cooperate/challenge asynchronously
|
||||
try {
|
||||
std::thread([this]() {
|
||||
try {
|
||||
auto c_classic = supabase::FetchHighscores("classic", 12);
|
||||
auto c_coop = supabase::FetchHighscores("cooperate", 12);
|
||||
auto c_challenge = supabase::FetchHighscores("challenge", 12);
|
||||
std::vector<ScoreEntry> combined;
|
||||
combined.reserve(c_classic.size() + c_coop.size() + c_challenge.size());
|
||||
combined.insert(combined.end(), c_classic.begin(), c_classic.end());
|
||||
combined.insert(combined.end(), c_coop.begin(), c_coop.end());
|
||||
combined.insert(combined.end(), c_challenge.begin(), c_challenge.end());
|
||||
if (this->ctx.scores) this->ctx.scores->replaceAll(combined);
|
||||
} catch (...) {
|
||||
// swallow network errors - keep existing scores
|
||||
}
|
||||
}).detach();
|
||||
} catch (...) {}
|
||||
}
|
||||
|
||||
void MenuState::renderMainButtonTop(SDL_Renderer* renderer, float logicalScale, SDL_Rect logicalVP) {
|
||||
|
||||
Reference in New Issue
Block a user