40 lines
608 B
C++
40 lines
608 B
C++
|
#include "menuitem.hpp"
|
||
|
|
||
|
|
||
|
MenuItem::MenuItem(const char* nazov, void (* action)(game*))
|
||
|
{
|
||
|
this->nazov = nazov;
|
||
|
this->action = action;
|
||
|
}
|
||
|
|
||
|
void MenuItem::Execute(game* Game)
|
||
|
{
|
||
|
# ifdef DEBUG
|
||
|
cout << "Executing..." << endl;
|
||
|
# endif
|
||
|
|
||
|
action(Game);
|
||
|
}
|
||
|
|
||
|
void MenuItem::draw(game* Game, int x, int y, bool active)
|
||
|
{
|
||
|
SDL_Color textColor;
|
||
|
|
||
|
if (active)
|
||
|
{
|
||
|
textColor = make_color(123, 123, 255);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
textColor = make_color(255, 255, 255);
|
||
|
}
|
||
|
|
||
|
message = TTF_RenderText_Solid( Game->GetfontMenu(), nazov, textColor);
|
||
|
|
||
|
apply_surface(x, y, message, Game->GetScreen());
|
||
|
|
||
|
|
||
|
SDL_FreeSurface(message);
|
||
|
}
|
||
|
|