git repos / blockattack-game

commit 094b2dfe

sago007 · 2016-06-12 10:50
094b2dfe907eb2364820e2b3948eab1009004323 patch · browse files
parent b830df0385b65f2ace774b1cefe75a04ae0e8d6f

Started removing the pointers in the menu system

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 4929569..be3a5e3 100644 --- a/source/code/MenuSystem.cpp +++ b/source/code/MenuSystem.cpp
@@ -35,14 +35,14 @@ using std::cerr;
using std::cout;
using std::vector;
+const char* const menu_marked = "menu_marked";
+const char* const menu_unmarked = "menu_unmarked";
ButtonGfx standardButton;
-void ButtonGfx::setSurfaces(sago::SagoSprite* marked, sago::SagoSprite* unmarked) {
- this->marked = marked;
- this->unmarked = unmarked;
- xsize=(marked)->GetWidth();
- ysize=(marked)->GetHeight();
+void ButtonGfx::setSurfaces() {
+ xsize = spriteHolder->GetSprite(menu_marked).GetWidth();
+ ysize = spriteHolder->GetSprite(menu_marked).GetHeight();
if (verboseLevel) {
cout << "Surfaces set, size: " <<xsize << " , " << ysize << "\n";
}
@@ -95,10 +95,10 @@ void Button::drawToScreen() {
//cout << "Painting button: " << label << " at: " << x << "," << y << "\n";
#endif
if (marked) {
- gfx->marked->Draw(screen, SDL_GetTicks(), x, y);
+ spriteHolder->GetSprite("menu_marked").Draw(screen, SDL_GetTicks(), x, y);
}
else {
- gfx->unmarked->Draw(screen, SDL_GetTicks(), x, y);
+ spriteHolder->GetSprite("menu_unmarked").Draw(screen, SDL_GetTicks(), x, y);
}
gfx->thefont->draw(screen, x+gfx->xsize/2,y+gfx->ysize/2-gfx->thefont->getHeight("%s", label.c_str())/2, NFont::CENTER, "%s", label.c_str());
}
diff --git a/source/code/MenuSystem.h b/source/code/MenuSystem.h index 5da18c9..b84e0f0 100644 --- a/source/code/MenuSystem.h +++ b/source/code/MenuSystem.h
@@ -35,16 +35,12 @@ http://blockattack.net
//The ButtonGfx object hold common media for all buttons, so we can reskin them by only changeing one pointer
struct ButtonGfx
{
- //Holds the graphic for a button that is selected
- sago::SagoSprite* marked = nullptr;
- //Holds the graphic for a button that is not selected
- sago::SagoSprite* unmarked = nullptr;
//The size of the buttons, so we don't have to ask w and h from the SDL Surfaces each time
int xsize = 0;
int ysize = 0;
//A TTFont used for writing the label on the buttons
NFont* thefont = nullptr;
- void setSurfaces(sago::SagoSprite* marked, sago::SagoSprite* unmarked);
+ void setSurfaces();
};
extern ButtonGfx standardButton;
diff --git a/source/code/menudef.cpp b/source/code/menudef.cpp index 3a9c625..4b84434 100644 --- a/source/code/menudef.cpp +++ b/source/code/menudef.cpp
@@ -95,7 +95,7 @@ void Button_changekey::doAction() {
}
void InitMenues() {
- standardButton.setSurfaces(&menuMarked,&menuUnmarked);
+ standardButton.setSurfaces();
standardButton.thefont = &nf_scoreboard_font;
}