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