diff options
Diffstat (limited to 'hslist.h')
| -rw-r--r-- | hslist.h | 124 |
1 files changed, 14 insertions, 110 deletions
| diff --git a/hslist.h b/hslist.h index efffa9d..0636183 100644 --- a/hslist.h +++ b/hslist.h | |||
| @@ -1,130 +1,34 @@ | |||
| 1 | #ifndef HSLIST_H | ||
| 2 | #define HSLIST_H | ||
| 3 | |||
| 1 | #include <SDL.h> | 4 | #include <SDL.h> |
| 2 | 5 | ||
| 6 | #include <memory> | ||
| 3 | #include <vector> | 7 | #include <vector> |
| 4 | 8 | ||
| 5 | #include "highscore.h" | 9 | #include "highscore.h" |
| 10 | #include "sdl.h" | ||
| 6 | #include "state.h" | 11 | #include "state.h" |
| 7 | 12 | ||
| 8 | #ifndef HSLIST_H | ||
| 9 | #define HSLIST_H | ||
| 10 | |||
| 11 | typedef std::vector<Highscore*> hslist_t; | ||
| 12 | |||
| 13 | void resetRanks(hslist_t in); | ||
| 14 | |||
| 15 | class HighscoreList { | 13 | class HighscoreList { |
| 16 | public: | 14 | public: |
| 17 | SDL_Surface* render(); | 15 | static std::unique_ptr<HighscoreList> GetLocalHighscores(); |
| 18 | 16 | static std::unique_ptr<HighscoreList> GetGlobalHighscores(); | |
| 19 | protected: | ||
| 20 | hslist_t getLocalHighscores(); | ||
| 21 | hslist_t getGlobalHighscores(); | ||
| 22 | |||
| 23 | hslist_t hslist; | ||
| 24 | }; | ||
| 25 | |||
| 26 | class LocalHighscoreList : public HighscoreList { | ||
| 27 | public: | ||
| 28 | LocalHighscoreList(); | ||
| 29 | int addHighscore(Highscore* h); | ||
| 30 | void writeHighscores(); | ||
| 31 | }; | ||
| 32 | |||
| 33 | class GlobalHighscoreList : public HighscoreList { | ||
| 34 | public: | ||
| 35 | GlobalHighscoreList(); | ||
| 36 | GlobalHighscoreList(Highscore* h); | ||
| 37 | SDL_Surface* render(); | ||
| 38 | bool didFail(); | ||
| 39 | |||
| 40 | private: | ||
| 41 | typedef HighscoreList super; | ||
| 42 | |||
| 43 | protected: | ||
| 44 | bool fail; | ||
| 45 | }; | ||
| 46 | |||
| 47 | class ChooseHighscoreListState : public State { | ||
| 48 | public: | ||
| 49 | State* operator()(SDL_Window* window, SDL_Renderer* renderer); | ||
| 50 | }; | ||
| 51 | |||
| 52 | class DisplayLocalHighscoreListState : public State { | ||
| 53 | public: | ||
| 54 | State* operator()(SDL_Window* window, SDL_Renderer* renderer); | ||
| 55 | }; | ||
| 56 | |||
| 57 | class DisplayAndReturnLocalHighscoreListState : public State { | ||
| 58 | public: | ||
| 59 | State* operator()(SDL_Window* window, SDL_Renderer* renderer); | ||
| 60 | }; | ||
| 61 | |||
| 62 | class DisplayGlobalHighscoreListState : public State { | ||
| 63 | public: | ||
| 64 | State* operator()(SDL_Window* window, SDL_Renderer* renderer); | ||
| 65 | |||
| 66 | protected: | ||
| 67 | SDL_Surface* list_s; | ||
| 68 | SDL_Texture* list; | ||
| 69 | GlobalHighscoreList* lhl; | ||
| 70 | SDL_mutex* m; | ||
| 71 | |||
| 72 | private: | ||
| 73 | static int LoadHighscoreList(void* pParam); | ||
| 74 | }; | ||
| 75 | |||
| 76 | class EnterHighscoreState : public State { | ||
| 77 | public: | ||
| 78 | EnterHighscoreState(int level); | ||
| 79 | State* operator()(SDL_Window* window, SDL_Renderer* renderer); | ||
| 80 | |||
| 81 | private: | ||
| 82 | int level; | ||
| 83 | int lp; | ||
| 84 | char* hsname; | ||
| 85 | SDL_Texture* newName; | ||
| 86 | }; | ||
| 87 | |||
| 88 | class NewHighscoreState : public State { | ||
| 89 | public: | ||
| 90 | NewHighscoreState(Highscore* h); | ||
| 91 | State* operator()(SDL_Window* window, SDL_Renderer* renderer); | ||
| 92 | 17 | ||
| 93 | private: | 18 | surface_ptr render(); |
| 94 | Highscore* h; | ||
| 95 | }; | ||
| 96 | 19 | ||
| 97 | class SubmitHighscoreState : public State { | 20 | const std::vector<Highscore>& getList() const { return hslist_; } |
| 98 | public: | ||
| 99 | SubmitHighscoreState(Highscore* h); | ||
| 100 | State* operator()(SDL_Window* window, SDL_Renderer* renderer); | ||
| 101 | 21 | ||
| 102 | protected: | 22 | int addHighscore(Highscore h); |
| 103 | Highscore* h; | ||
| 104 | SDL_mutex* m; | ||
| 105 | GlobalHighscoreList* lhl; | ||
| 106 | 23 | ||
| 107 | private: | 24 | void writeToFile(); |
| 108 | static int SubmitHighscore(void* pParam); | ||
| 109 | }; | ||
| 110 | |||
| 111 | class FailedSubmittingHighscoreState : public State { | ||
| 112 | public: | ||
| 113 | FailedSubmittingHighscoreState(Highscore* h); | ||
| 114 | State* operator()(SDL_Window* window, SDL_Renderer* renderer); | ||
| 115 | 25 | ||
| 116 | private: | 26 | private: |
| 117 | Highscore* h; | 27 | explicit HighscoreList(std::vector<Highscore> hslist); |
| 118 | }; | ||
| 119 | 28 | ||
| 120 | class SubmittedHighscoreState : public State { | 29 | void resetRanks(); |
| 121 | public: | ||
| 122 | SubmittedHighscoreState(GlobalHighscoreList* lhl, Highscore* h); | ||
| 123 | State* operator()(SDL_Window* window, SDL_Renderer* renderer); | ||
| 124 | 30 | ||
| 125 | private: | 31 | std::vector<Highscore> hslist_; |
| 126 | GlobalHighscoreList* lhl; | ||
| 127 | Highscore* h; | ||
| 128 | }; | 32 | }; |
| 129 | 33 | ||
| 130 | #endif | 34 | #endif |
