19
19
***************************************************************************/
21
21
#include <SDL/SDL_mixer.h>
22
#include "../../include/menu/menu.h"
23
#include "../../include/menu/mainmenu.h"
24
#include "../../include/soundmanager.h"
22
#include "menu/menu.h"
23
#include "menu/mainmenu.h"
24
#include "soundmanager.h"
25
#include "imageloader.h"
25
27
#include <iostream>
27
29
using namespace Balder;
29
31
SDLKey Menu::lastKeyPressed = SDLKey(0);
31
Menu::Menu(SoundManager* s): startgame(false), sound(s)
33
Menu::Menu(Renderer *r, SoundManager* s): startgame(false), render(r), sound(s)
33
35
//screen = SDL_GetVideoSurface();
69
71
// The global font is static and must be set.
70
72
gcn::Widget::setGlobalFont(font);
72
73
// create top level wigets we want on all menus
73
headerImage = new gcn::Image("menu/balderheader.png");
74
pulseAnimation = new Animation(/* Film Strip File Name */"menu/pulse1.png",
75
/* Has Base Frame */true, /* Is Looped */true, /* Play when finished loading */true,
76
/* Strip Location */ 0, /* Frame Width */100, /* Frame Height */100, /* Base Frame Index */0,
77
/* Starting Frame Index */1, /* Animation Frame Quantity Including Starting Frame */3,
78
/* Frame Interval in MS (1Sec == 1000MS) */115);
79
twinkleAnimation = new Animation(/* Film Strip File Name */"menu/twinkle1.png",
80
/* Has Base Frame */true, /* Is Looped */true, /* Play when finished loading */true,
81
/* Strip Location */ 0, /* Frame Width */100, /* Frame Height */100, /* Base Frame Index */0,
82
/* Starting Frame Index */1, /* Animation Frame Quantity Including Starting Frame */3,
83
/* Frame Interval in MS (1Sec == 1000MS) */1);
84
backgroundImage = ImageLoader::LoadGcnImage("menu/menubackground.png");
85
backgroundIcon = new gcn::Icon(backgroundImage);
86
headerImage = ImageLoader::LoadGcnImage("menu/balderheader.png");
74
87
headerIcon = new gcn::Icon(headerImage);
88
topContainer->add(backgroundIcon, 0, 0);
89
topContainer->add(pulseAnimation,575,50);
90
topContainer->add(twinkleAnimation,600,420);
75
91
topContainer->add(headerIcon, 250, 40);
77
93
// now initialize menus
96
112
screen = SDL_GetVideoSurface();
97
graphics->setTarget(screen);
113
graphics->setTarget(screen);
118
// Set fullscreen status for menu.
119
if (fullscreen != ConfigManager::GetIntValue("Video", "fullscreen")) {
120
fullscreen = ConfigManager::GetIntValue("Video", "fullscreen");
121
render->SetScreen(800, 600, fullscreen);
124
// Check to see if music is playing.
101
125
if (!sound->IsMusicPlaying())
103
127
sound->PlayMusic("menu");
122
void Menu::action(const std::string& action)
145
void Menu::action(const gcn::ActionEvent& action)
124
147
// Main menu events.********************************************************
125
if (action == "startgame")
148
if (action.getId() == "startgame")
128
151
startgame = true;
130
else if (action == "quitgame")
153
else if (action.getId() == "quitgame")
133
156
startgame = false;
145
168
if (event.type == SDL_KEYDOWN)
147
170
Menu::lastKeyPressed = event.key.keysym.sym;
148
// if (event.key.keysym.sym == SDLK_ESCAPE)
152
// bindNextKey = false;
158
// startgame = false;
163
// ConfigManager::SetPlayerControl(currentPlayer, actionToBind,
164
// Input::GetKeyString(event.key.keysym.sym));
165
// bindNextKey = false;
169
172
else if(event.type == SDL_QUIT)