Spider: Track quickest game time

This isn't exposed in the game anywhere yet.
This commit is contained in:
Jamie Mansfield 2021-07-27 11:52:46 +01:00 committed by Andreas Kling
parent 29f15cfbae
commit 4df9d05f91
Notes: sideshowbarker 2024-07-18 08:02:59 +09:00

View file

@ -80,6 +80,17 @@ int main(int argc, char** argv)
GUI::MessageBox::show(window, "Configuration could not be saved", "Error", GUI::MessageBox::Type::Error);
};
auto best_time = [&]() {
return static_cast<u32>(config->read_num_entry("BestTimes", mode_id(), 0));
};
auto update_best_time = [&](u32 new_best_time) {
config->write_num_entry("BestTimes", mode_id(), static_cast<int>(new_best_time));
if (!config->sync())
GUI::MessageBox::show(window, "Configuration could not be saved", "Error", GUI::MessageBox::Type::Error);
};
if (mode >= Spider::Mode::__Count)
update_mode(Spider::Mode::SingleSuit);
@ -135,6 +146,11 @@ int main(int argc, char** argv)
update_high_score(score);
statusbar.set_text(1, String::formatted("High Score: {}", score));
}
auto current_best_time = best_time();
if (seconds_elapsed < current_best_time || current_best_time == 0) {
update_best_time(seconds_elapsed);
}
}
statusbar.set_text(2, "Timer starts after your first move");
};