summary refs log tree commit diff stats
path: root/hsglobal.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'hsglobal.cpp')
-rw-r--r--hsglobal.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/hsglobal.cpp b/hsglobal.cpp new file mode 100644 index 0000000..37db44b --- /dev/null +++ b/hsglobal.cpp
@@ -0,0 +1,63 @@
1#include "includes.h"
2
3GlobalHighscoreListState::GlobalHighscoreListState()
4{
5 LOADIMAGE(options,hlo_rtm)
6 LOADIMAGE(pointer,pointer)
7
8 list = SDL_CreateRGBSurface(SDL_SWSURFACE || SDL_SRCCOLORKEY, 480, 480, 32, 0,0,0,0);
9 Uint32 bgColor = SDL_MapRGB(list->format, 255, 255, 255);
10 SDL_FillRect(list, NULL, bgColor);
11 SDL_SetColorKey(list, SDL_SRCCOLORKEY, bgColor);
12 TTF_Font* dataFont = loadFont(25);
13 SDL_Color fontColor = {0, 0, 0, 0};
14 SDL_Surface* text = TTF_RenderText_Blended(dataFont, "Fetching highscores....", fontColor);
15 SDL_Rect aSpace = {240-(text->w/2), 240-(text->h/2), text->w, text->h};
16 SDL_BlitSurface(text, NULL, list, &aSpace);
17
18 SDL_Surface* title = TTF_RenderText_Blended(loadFont(40), "Highscore List", fontColor);
19 SDL_Rect tSpace = {240-(title->w/2), 0, title->w, title->h};
20 SDL_BlitSurface(title, NULL, list, &tSpace);
21
22 SDL_Rect oSpace = {0, 440, options->w, options->h};
23 SDL_BlitSurface(options, NULL, list, &oSpace);
24
25 SDL_CreateThread(&LoadHighscoreList, this);
26}
27
28int GlobalHighscoreListState::LoadHighscoreList(void* pParam)
29{
30 GlobalHighscoreList* lhl = new GlobalHighscoreList();
31 ((GlobalHighscoreListState*)pParam)->list = lhl->render();
32
33 SDL_Color fontColor = {0, 0, 0, 0};
34 SDL_Surface* title = TTF_RenderText_Blended(loadFont(40), "Highscore List", fontColor);
35 SDL_Rect tSpace = {240-(title->w/2), 0, title->w, title->h};
36 SDL_BlitSurface(title, NULL, ((GlobalHighscoreListState*)pParam)->list, &tSpace);
37
38 SDL_Rect oSpace = {0, 440, ((GlobalHighscoreListState*)pParam)->options->w, ((GlobalHighscoreListState*)pParam)->options->h};
39 SDL_BlitSurface(((GlobalHighscoreListState*)pParam)->options, NULL, ((GlobalHighscoreListState*)pParam)->list, &oSpace);
40}
41
42void GlobalHighscoreListState::input(SDL_keysym key)
43{
44 if (key.sym == SDLK_RETURN)
45 {
46 changeState(new ChooseHighscoreListState());
47 }
48}
49
50void GlobalHighscoreListState::render(SDL_Surface* screen)
51{
52 SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 255, 255, 255));
53
54 SDL_BlitSurface(list, NULL, screen, NULL);
55
56 SDL_Rect pSpace;
57 pSpace.x = 137;
58 pSpace.y = 449;
59 pSpace.w = pointer->w;
60 pSpace.h = pointer->h;
61
62 SDL_BlitSurface(pointer, NULL, screen, &pSpace);
63}