Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of el17ajf by
Diff: Menus/ScoresMenu/ScoresMenu.cpp
- Revision:
- 27:2ed9e3c9f4e9
- Parent:
- 21:62d2b5b73160
- Child:
- 28:e09b7ac11dea
--- a/Menus/ScoresMenu/ScoresMenu.cpp Thu Apr 04 18:39:45 2019 +0000 +++ b/Menus/ScoresMenu/ScoresMenu.cpp Fri Apr 05 17:16:59 2019 +0000 @@ -1,14 +1,37 @@ #include "ScoresMenu.h" +#include "Prefs.h" + +Menus::ScoresMenu::ScoresMenu() { + closeable = false; + int highscores[3]; + int players[3]; + + players[0] = Prefs::getInstance()->getKey(Prefs::HIGHSCORE1_PLAYER); + players[1] = Prefs::getInstance()->getKey(Prefs::HIGHSCORE2_PLAYER); + players[2] = Prefs::getInstance()->getKey(Prefs::HIGHSCORE3_PLAYER); + + highscores[0] = Prefs::getInstance()->getKey(Prefs::HIGHSCORE1); + highscores[1] = Prefs::getInstance()->getKey(Prefs::HIGHSCORE2); + highscores[2] = Prefs::getInstance()->getKey(Prefs::HIGHSCORE3); + + for (int i = 0; i < 3; i++) { + if (players[i] == Prefs::EMPTY) { + sprintf(playersLables[i], "%1d. ---", i + 1); + sprintf(highscoresLabels[i], " "); + } else { + sprintf(playersLables[i], "%1d.PLYR %2d", i + 1, players[i]); + sprintf(highscoresLabels[i], " %4dPTS", highscores[i]); + } + } +} void Menus::ScoresMenu::updateAndDraw(UI * ui) { ui->drawTitle("hi scores"); ui->newLine(); - ui->drawLabel("1.PLYR 44"); - ui->drawLabel(" 1312PTS"); - ui->drawLabel("2.PLYR 21"); - ui->drawLabel(" 1311PTS"); - ui->drawLabel("3.PLYR 88"); - ui->drawLabel(" 1310PTS"); + for (int i = 0; i < 3; i++) { + ui->drawLabel(playersLables[i]); + ui->drawLabel(highscoresLabels[i]); + } if (ui->drawAndCheckButton("back")) { close(); }