69 lines
873 B
C++
69 lines
873 B
C++
|
#include "menu.hpp"
|
||
|
|
||
|
|
||
|
Menu::Menu()
|
||
|
{
|
||
|
select = 0;
|
||
|
|
||
|
# ifdef DEBUG
|
||
|
cout << "First item selected" << endl;
|
||
|
# endif
|
||
|
}
|
||
|
|
||
|
Menu::~Menu()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
void Menu::addItem(const char* nazov, void (* action)(game*))
|
||
|
{
|
||
|
MenuItem item = MenuItem(nazov, action);
|
||
|
|
||
|
polozky.push_back(item);
|
||
|
|
||
|
# ifdef DEBUG
|
||
|
cout << "Item was added" << endl;
|
||
|
# endif
|
||
|
}
|
||
|
|
||
|
void Menu::Execute(game* Game)
|
||
|
{
|
||
|
polozky[select].Execute(Game);
|
||
|
}
|
||
|
|
||
|
void Menu::Draw(game* Game)
|
||
|
{
|
||
|
int i = 0;
|
||
|
|
||
|
for (vector<MenuItem>::iterator it = polozky.begin(); it != polozky.end(); it++)
|
||
|
{
|
||
|
it->draw(Game, 100, (i * 50 + 50), (i == select));
|
||
|
|
||
|
i++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void Menu::Down(game* Game)
|
||
|
{
|
||
|
if (polozky.size() > (select + 1))
|
||
|
{
|
||
|
select++;
|
||
|
|
||
|
# ifdef DEBUG
|
||
|
cout << "Next item" << endl;
|
||
|
# endif
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void Menu::Up(game* Game)
|
||
|
{
|
||
|
if (select > 0)
|
||
|
{
|
||
|
# ifdef DEBUG
|
||
|
cout << "Previous item" << endl;
|
||
|
# endif
|
||
|
|
||
|
select--;
|
||
|
}
|
||
|
}
|