commit 0c1de203
Small changes to the menu system to prepare for a separete render
Changed files
| M | source/code/MenuSystem.cpp before |
| M | source/code/MenuSystem.h before |
| M | source/code/menudef.cpp before |
diff --git a/source/code/MenuSystem.cpp b/source/code/MenuSystem.cpp
index 0a61132..2b0f4d1 100644
--- a/source/code/MenuSystem.cpp
+++ b/source/code/MenuSystem.cpp
@@ -95,17 +95,17 @@ void Button::doAction() {
cerr << "Warning: button \"" << label << "\" has no action assigned!";
}
-void Button::drawTo(SDL_Surface** surface) {
+void Button::drawToScreen() {
#if DEBUG
//cout << "Painting button: " << label << " at: " << x << "," << y << endl;
#endif
if (marked) {
- gfx->marked->PaintTo(*surface,x,y);
+ gfx->marked->PaintTo(screen, x, y);
}
else {
- gfx->unmarked->PaintTo(*surface,x,y);
+ gfx->unmarked->PaintTo(screen,x,y);
}
- gfx->thefont.setDest(*surface);
+ gfx->thefont.setDest(screen);
gfx->thefont.drawCenter(x+gfx->xsize/2,y+gfx->ysize/2-gfx->thefont.getHeight("%s", label.c_str())/2, "%s", label.c_str());
}
@@ -129,9 +129,9 @@ void Menu::drawSelf() {
DrawIMG(backgroundImage,screen,0,0);
vector<Button*>::iterator it;
for (it = buttons.begin(); it < buttons.end(); it++) {
- (*it)->drawTo(&screen);
+ (*it)->drawToScreen();
}
- exit.drawTo(&screen);
+ exit.drawToScreen();
standardButton.thefont.draw(50, 50, "%s", title.c_str());
mouse->PaintTo(screen,mousex,mousey);
}
@@ -171,15 +171,15 @@ void Menu::addButton(Button* b) {
placeButtons();
}
-Menu::Menu(SDL_Surface** screen) {
- this->screen = *screen;
+Menu::Menu(SDL_Surface* screen) {
+ this->screen = screen;
buttons = vector<Button*>(10);
isSubmenu = true;
exit.setLabel( _("Back") );
}
-Menu::Menu(SDL_Surface** screen,bool submenu) {
- this->screen = *screen;
+Menu::Menu(SDL_Surface* screen,bool submenu) {
+ this->screen = screen;
buttons = vector<Button*>(0);
isSubmenu = submenu;
if (isSubmenu) {
@@ -190,8 +190,8 @@ Menu::Menu(SDL_Surface** screen,bool submenu) {
}
}
-Menu::Menu(SDL_Surface** screen, const string& title, bool submenu) {
- this->screen = *screen;
+Menu::Menu(SDL_Surface* screen, const string& title, bool submenu) {
+ this->screen = screen;
buttons = vector<Button*>(0);
isSubmenu = submenu;
this->title = title;
diff --git a/source/code/MenuSystem.h b/source/code/MenuSystem.h
index b0afee4..342b74e 100644
--- a/source/code/MenuSystem.h
+++ b/source/code/MenuSystem.h
@@ -82,7 +82,7 @@ public:
bool isClicked(int x,int y); //Returns true if (x,y) is within the borders of the button
virtual void doAction(); //Run the callback function
- void drawTo(SDL_Surface **surface);
+ void drawToScreen(void);
void setPopOnRun(bool popOnRun);
bool isPopOnRun() const;
void setGfx(ButtonGfx* gfx); //Draws to screen
@@ -111,9 +111,9 @@ private:
public:
//numberOfItems is the expected numberOfItems for vector initialization
//SubMenu is true by default
- Menu(SDL_Surface **screen,bool isSubmenu);
- Menu(SDL_Surface **screen);
- Menu(SDL_Surface **screen, const std::string& title, bool isSubmenu);
+ Menu(SDL_Surface *screen,bool isSubmenu);
+ Menu(SDL_Surface *screen);
+ Menu(SDL_Surface *screen, const std::string& title, bool isSubmenu);
//Add a button to the menu
void addButton(Button *b);
diff --git a/source/code/menudef.cpp b/source/code/menudef.cpp
index 6fca97d..36d33cc 100644
--- a/source/code/menudef.cpp
+++ b/source/code/menudef.cpp
@@ -187,7 +187,7 @@ static void buttonActionHighscores(Button* b) {
}
static void ChangeKeysMenu(long playernumber) {
- Menu km(&screen,_("Change key bindings"),true);
+ Menu km(screen,_("Change key bindings"),true);
Button_changekey bLeft(&keySettings[playernumber].left,_("Left") );
Button_changekey bRight(&keySettings[playernumber].right,_("Right") );
Button_changekey bUp(&keySettings[playernumber].up,_("Up") );
@@ -212,7 +212,7 @@ static void ChangeKeysMenu2(Button* b) {
}
static void ConfigureMenu(Button* b) {
- Menu cm(&screen,_("Configuration"),true);
+ Menu cm(screen,_("Configuration"),true);
Button bMusic,bSound,buttonFullscreen,bPlayer1Name,bPlayer2Name;
Button bPlayer1Keys, bPlayer2Keys;
bMusic.setLabel(MusicEnabled? _("Music: On") : _("Music: Off") );
@@ -240,7 +240,7 @@ static void ConfigureMenu(Button* b) {
}
static void SinglePlayerVsMenu(Button* b) {
- Menu spvs(&screen,_("Single player VS"),true);
+ Menu spvs(screen,_("Single player VS"),true);
Button d1,d2,d3,d4,d5,d6,d7;
d1.setAction(runSinglePlayerVs);
d2.setAction(runSinglePlayerVs);
@@ -281,7 +281,7 @@ static void SinglePlayerVsMenu(Button* b) {
}
static void MultiplayerMenu(Button* b) {
- Menu mm(&screen,_("Multiplayer"),true);
+ Menu mm(screen,_("Multiplayer"),true);
Button bTT, bVs, bNet;
bTT.setLabel(_("Two player - time trial"));
bTT.setAction(runTwoPlayerTimeTrial);
@@ -294,7 +294,7 @@ static void MultiplayerMenu(Button* b) {
void MainMenu() {
InitMenues();
- Menu m(&screen,_("Block Attack - Rise of the blocks"),false);
+ Menu m(screen,_("Block Attack - Rise of the blocks"),false);
Button bHi,bTimetrial1, bStageClear, bPuzzle, bVs1, bMulti, bConfigure,bHighscore;
bHi.setLabel(_("Single player - endless") );
bHi.setAction(runSinglePlayerEndless);