77 lines
1.3 KiB
C++
77 lines
1.3 KiB
C++
#include "menumenu.h"
|
|
|
|
MenuMenu::MenuMenu() {
|
|
itempos = 0;
|
|
centermenu = false;
|
|
centerScreenX = false;
|
|
basefontsize = 20;
|
|
maxwidth = 0;
|
|
valuewidth = 100;
|
|
offset = 20;
|
|
}
|
|
|
|
void MenuMenu::setPos(const Punkt2D &p) {
|
|
menupos = p;
|
|
}
|
|
|
|
void MenuMenu::setCenter(bool _c) {
|
|
centermenu = _c;
|
|
}
|
|
|
|
void MenuMenu::setCenterScreenX(bool _c) {
|
|
centerScreenX = _c;
|
|
}
|
|
|
|
void MenuMenu::setBaseFontSize(int _bfs) {
|
|
if(_bfs>0)
|
|
basefontsize = _bfs;
|
|
}
|
|
|
|
void MenuMenu::setMaxWidth(int _mw) {
|
|
if(_mw>0)
|
|
maxwidth = _mw;
|
|
}
|
|
|
|
void MenuMenu::addMenuItem(MenuItem* mi) {
|
|
menuitems.push_back(mi);
|
|
}
|
|
|
|
void MenuMenu::up() {
|
|
if(itempos==0)
|
|
itempos = menuitems.size()-1;
|
|
else
|
|
itempos--;
|
|
}
|
|
|
|
void MenuMenu::down() {
|
|
if(itempos==menuitems.size()-1)
|
|
itempos = 0;
|
|
else
|
|
itempos++;
|
|
}
|
|
|
|
void MenuMenu::left() {
|
|
menuitems[itempos]->left();
|
|
}
|
|
|
|
void MenuMenu::right() {
|
|
menuitems[itempos]->right();
|
|
}
|
|
|
|
void MenuMenu::select() {
|
|
menuitems[itempos]->select();
|
|
}
|
|
|
|
void MenuMenu::render() {
|
|
Punkt2D pos = menupos;
|
|
if(centerScreenX) {
|
|
SDL_Surface *screen = SDL_GetVideoSurface();
|
|
pos.x = screen->w/2;
|
|
}
|
|
|
|
for(unsigned int i=0; i<menuitems.size(); i++) {
|
|
menuitems[i]->render(pos, centermenu, basefontsize, maxwidth, valuewidth, itempos==i);
|
|
pos.y += basefontsize + menuitems[i]->getFontSizeAdd() + offset;
|
|
}
|
|
}
|