-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <App/ScoreHistApp.h> | ||
#include <Logic/GameScore.h> | ||
#include <Util/uint_to_str.h> | ||
|
||
namespace hitcon { | ||
namespace score_hist { | ||
|
||
char dino_score_str[15] = "Dino "; | ||
char snake_score_str[15] = "Snake "; | ||
char tetris_score_str[15] = "Tetris "; | ||
|
||
ScoreHistApp g_score_hist; | ||
|
||
void ScoreHistApp::SetScores() { | ||
int dino_score = g_game_score.GetScore(GameScoreType::GAME_DINO); | ||
int snake_score = g_game_score.GetScore(GameScoreType::GAME_SNAKE); | ||
int tetris_score = g_game_score.GetScore(GameScoreType::GAME_TETRIS); | ||
|
||
if (dino_score > 9999999) dino_score = 9999999; | ||
if (snake_score > 9999999) snake_score = 9999999; | ||
if (tetris_score > 9999999) tetris_score = 9999999; | ||
|
||
uint_to_chr(&dino_score_str[5], 8, dino_score); | ||
uint_to_chr(&tetris_score_str[7], 8, tetris_score); | ||
uint_to_chr(&snake_score_str[6], 8, snake_score); | ||
} | ||
|
||
void ScoreHistApp::OnEntry() { | ||
SetScores(); | ||
MenuApp::OnEntry(); | ||
} | ||
|
||
} // namespace score_hist | ||
} // namespace hitcon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#ifndef APP_SCORE_HIST_APP | ||
#define APP_SCORE_HIST_APP | ||
|
||
#include <Logic/BadgeController.h> | ||
|
||
#include "MenuApp.h" | ||
|
||
namespace hitcon { | ||
namespace score_hist { | ||
|
||
extern char dino_score_str[15]; | ||
extern char snake_score_str[15]; | ||
extern char tetris_score_str[15]; | ||
|
||
constexpr menu_entry_t score_hist_app_entries[] = { | ||
{dino_score_str, nullptr, nullptr}, | ||
{tetris_score_str, nullptr, nullptr}, | ||
{snake_score_str, nullptr, nullptr}}; | ||
|
||
constexpr size_t score_hist_app_entries_len = | ||
sizeof(score_hist_app_entries) / sizeof(score_hist_app_entries[0]); | ||
|
||
class ScoreHistApp : public MenuApp { | ||
public: | ||
ScoreHistApp() | ||
: MenuApp(score_hist_app_entries, score_hist_app_entries_len) {} | ||
|
||
void OnEntry() override; | ||
|
||
void OnButtonMode() override {} | ||
void OnButtonBack() override { badge_controller.BackToMenu(this); } | ||
void OnButtonLongBack() override { badge_controller.BackToMenu(this); } | ||
|
||
private: | ||
void SetScores(); | ||
}; | ||
|
||
extern ScoreHistApp g_score_hist; | ||
|
||
} // namespace score_hist | ||
} // namespace hitcon | ||
|
||
#endif // APP_SCORE_HIST_APP |