summary refs log tree commit diff stats
path: root/hslist.h
blob: 844bf37e27b5cefc3f4b80f0c04727fe10991b68 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#include <SDL.h>
#include <vector>
#include "highscore.h"
#include "state.h"

#ifndef HSLIST_H
#define HSLIST_H

typedef std::vector<Highscore*> hslist_t;

void resetRanks(hslist_t in);

class HighscoreList
{
	public:
		SDL_Surface* render();

	protected:
		hslist_t getLocalHighscores();
		hslist_t getGlobalHighscores();

		hslist_t hslist;
};

class LocalHighscoreList : public HighscoreList {
	public:
		LocalHighscoreList();
		int addHighscore(Highscore* h);
		void writeHighscores();
};

class GlobalHighscoreList : public HighscoreList {
	public:
		GlobalHighscoreList();
		GlobalHighscoreList(Highscore* h);
		SDL_Surface* render();
		bool didFail();

	private:
		typedef HighscoreList super;

	protected:
		bool fail;
};

class ChooseHighscoreListState : public State {
	public:
		State* operator() (SDL_Window* window, SDL_Renderer* renderer);
};

class DisplayLocalHighscoreListState : public State {
	public:
		State* operator() (SDL_Window* window, SDL_Renderer* renderer);
};

class DisplayAndReturnLocalHighscoreListState : public State {
	public:
		State* operator() (SDL_Window* window, SDL_Renderer* renderer);
};

class DisplayGlobalHighscoreListState : public State {
	public:
		State* operator() (SDL_Window* window, SDL_Renderer* renderer);
		
	protected:
		SDL_Surface* list_s;
		SDL_Texture* list;
		GlobalHighscoreList* lhl;
		SDL_mutex* m;
		
	private:
		static int LoadHighscoreList(void* pParam);
};

class EnterHighscoreState : public State {
	public:
		EnterHighscoreState(int level);
		State* operator() (SDL_Window* window, SDL_Renderer* renderer);
		
	private:
		int level;
		int lp;
		char* hsname;
		SDL_Texture* newName;
};

class NewHighscoreState : public State {
	public:
		NewHighscoreState(Highscore* h);
		State* operator() (SDL_Window* window, SDL_Renderer* renderer);
		
	private:
		Highscore* h;
};

class SubmitHighscoreState : public State {
	public:
		SubmitHighscoreState(Highscore* h);
		State* operator() (SDL_Window* window, SDL_Renderer* renderer);
		
	protected:
		Highscore* h;
		SDL_mutex* m;
		GlobalHighscoreList* lhl;
		
	private:
		static int SubmitHighscore(void* pParam);
};

class FailedSubmittingHighscoreState : public State {
	public:
		FailedSubmittingHighscoreState(Highscore* h);
		State* operator() (SDL_Window* window, SDL_Renderer* renderer);
		
	private:
		Highscore* h;
};

class SubmittedHighscoreState : public State {
	public:
		SubmittedHighscoreState(GlobalHighscoreList* lhl, Highscore* h);
		State* operator() (SDL_Window* window, SDL_Renderer* renderer);
		
	private:
		GlobalHighscoreList* lhl;
		Highscore* h;
};

#endif