#ifndef PLODEGUI_H #define PLODEGUI_H #include // for exit() #include "vectortext.h" #include "postscore.h" #define GUIH 11 class PlodeGUI { public: PlodeGUI(const char *uname, bool gamepad) : username(uname), hasgamepad(gamepad), hasmenu(true), showingleaders(false), showinghelp(false), leaderboardtext(0), choice(3), done(false), leaderboardposition(-1) { if (gamepad) lines[0] = "EXAMINE GAMEPAD CONTROLS"; else lines[0] = "EXAMINE DEFAULT KEY CONTROLS"; lines[1] = "EXAMINE LEADERBOARD"; lines[2] = "ACCEPT DEFEAT"; lines[3] = "PRACTICE"; lines[4] = "ATTACK STURMBAHN"; } ~PlodeGUI() { } void SetLeaderBoardText(const char *text) { leaderboardtext = text; if (!text) { postscore_put("---", 0.0); leaderboardtext = postscore_get(); } if (leaderboardtext) { // parse the leaderboard leadernames.clear(); leadertimes.clear(); int numscores = strlen(leaderboardtext) / 16; for (int i=0; i (int) leadernames.size()) offset--; for (int i=0; i4) choice=0; if (choice<0) choice=4; } const std::string &SelectChoice(void) { if (showingleaders) { showingleaders = false; return lines[1]; } if (showinghelp) { showinghelp = false; return lines[0]; } if (choice==0) { showinghelp = true; } if (choice==1) { showingleaders = true; if (!leaderboardtext) SetLeaderBoardText(0); } if (choice==2) { exit(0); } if (choice==3) { hasmenu=false; } if (choice==4) { hasmenu=false; } return lines[choice]; } std::string username; bool hasgamepad; bool hasmenu; bool showingleaders; bool showinghelp; const char *leaderboardtext; protected: int choice; bool done; std::string lines[GUIH]; std::vector leadernames; std::vector leadertimes; int leaderboardposition; }; #endif