Menu::addButton(3,"Delete User",NULL,400,10,-1,-1);
Menu::addButton(4,"Main Menu",NULL,5,10,-1,-1);
Menu::addButton(5,"Change User",NULL,5,180,-1,-1);
- Menu::addButton(6,"",NULL,200,420,-1,-1);
+ Menu::addButton(6,"Campaign : "+accountactive->getCurrentCampaign(),NULL,200,420,-1,-1);
//show campaign map
//with (2,-5) offset from old code
if(!active)
itemsize/=2;
- if(i>=1)
- Menu::addMapLine(campaignlevels[i-1].getCenter(),midpoint,0.5,active?1:0.5,active?1:0.5,0,0);
+ if(i>=1){
+ XYZ start=campaignlevels[i-1].getCenter();
+ Menu::addMapLine(start.x,start.y,midpoint.x-start.x,midpoint.y-start.y,0.5,active?1:0.5,active?1:0.5,0,0);
+ }
Menu::addMapMarker(NB_CAMPAIGN_MENU_ITEM+i, Mapcircletexture, NULL,
midpoint.x-itemsize/2, midpoint.y-itemsize/2, itemsize, itemsize, active?1:0.5, 0, 0);
}
}
}
- Menu::setButtonText(6,"Campaign : "+accountactive->getCurrentCampaign());
}
break;
case 6: {
float r,g,b;
float effectfade;
- XYZ linestart;
- XYZ lineend;
float linestartsize;
float lineendsize;
- MenuItem(MenuItemType _type, int _id, const string& _label, int _texture, MBCallback _cb,
- int _x, int _y, int _w, int _h, float _r, float _g, float _b):
- type(_type),id(_id),label(_label),texture(_texture),cb(_cb),
- x(_x),y(_y),w(_w),h(_h),r(_r),g(_g),b(_b),effectfade(0) {
+ void init(MenuItemType _type, int _id, const string& _label, int _texture, MBCallback _cb,
+ int _x, int _y, int _w, int _h, float _r, float _g, float _b,
+ float _linestartsize=1, float _lineendsize=1){
+ type=_type;
+ id=_id;
+ label=_label;
+ texture=_texture;
+ cb=_cb;
+ x=_x; y=_y; w=_w; h=_h;
+ r=_r; g=_g; b=_b;
+ effectfade=0;
+ linestartsize=_linestartsize;
+ lineendsize=_lineendsize;
if(type==MenuItem::BUTTON){
if(w==-1)
w=label.length()*10;
h=20;
}
}
- MenuItem(const XYZ& start, const XYZ& end, float startsize, float endsize, float _r, float _g, float _b):
- type(MAPLINE),id(-1),label(""),r(_r),g(_g),b(_b),
- linestart(start),lineend(end),linestartsize(startsize),lineendsize(endsize) { }
};
vector<MenuItem> items;
}
void Menu::addLabel(int id,const string& label,int x,int y){
- items.push_back(MenuItem(MenuItem::LABEL,id,label,0,NULL,x,y,-1,-1,1,0,0));
-}
-void Menu::addButton(int id,const string& label,MBCallback cb,int x,int y,int w,int h){
- items.push_back(MenuItem(MenuItem::BUTTON,id,label,0,cb,x,y,w,h,1,0,0));
+ items.push_back(MenuItem());
+ items.back().init(MenuItem::LABEL,id,label,0,NULL,x,y,-1,-1,1,0,0);
}
void Menu::addButton(int id,const string& label,MBCallback cb,int x,int y,int w,int h,float r,float g,float b){
- items.push_back(MenuItem(MenuItem::BUTTON,id,label,0,cb,x,y,w,h,r,g,b));
+ items.push_back(MenuItem());
+ items.back().init(MenuItem::BUTTON,id,label,0,cb,x,y,w,h,r,g,b);
}
void Menu::addImage(int id,int texture,int x,int y,int w,int h){
- items.push_back(MenuItem(MenuItem::IMAGE,id,"",texture,NULL,x,y,w,h,1,1,1));
-}
-void Menu::addImageButton(int id,int texture,MBCallback cb,int x,int y,int w,int h){
- items.push_back(MenuItem(MenuItem::IMAGEBUTTON,id,"",texture,cb,x,y,w,h,1,1,1));
+ items.push_back(MenuItem());
+ items.back().init(MenuItem::IMAGE,id,"",texture,NULL,x,y,w,h,1,1,1);
}
void Menu::addImageButton(int id,int texture,MBCallback cb,int x,int y,int w,int h,float r,float g,float b){
- items.push_back(MenuItem(MenuItem::IMAGEBUTTON,id,"",texture,cb,x,y,w,h,r,g,b));
+ items.push_back(MenuItem());
+ items.back().init(MenuItem::IMAGEBUTTON,id,"",texture,cb,x,y,w,h,r,g,b);
}
-void Menu::addMapLine(const XYZ& start, const XYZ& end, float startsize, float endsize, float r,float g,float b){
- items.push_back(MenuItem(start,end,startsize,endsize,r,g,b));
+void Menu::addMapLine(int x, int y, int w, int h, float startsize, float endsize, float r,float g,float b){
+ items.push_back(MenuItem());
+ items.back().init(MenuItem::MAPLINE,-1,"",0,NULL,x,y,w,h,r,g,b,startsize,endsize);
}
void Menu::addMapMarker(int id,int texture,MBCallback cb,int x,int y,int w,int h,float r,float g,float b){
- items.push_back(MenuItem(MenuItem::MAPMARKER,id,"",texture,cb,x,y,w,h,r,g,b));
+ items.push_back(MenuItem());
+ items.back().init(MenuItem::MAPMARKER,id,"",texture,cb,x,y,w,h,r,g,b);
}
void Menu::setMapItem(int id){
game->text.glPrintOutlined(0.9,0,0,it->x,it->y,it->label.c_str(),0,0.6,640,480);
break;
case MenuItem::MAPLINE: {
- XYZ linestart=it->linestart;
- XYZ lineend=it->lineend;
+ XYZ linestart;
+ linestart.x=it->x;
+ linestart.y=it->y;
+ linestart.z=0;
+ XYZ lineend;
+ lineend.x=it->x+it->w;
+ lineend.y=it->y+it->h;
+ lineend.z=0;
XYZ offset=lineend-linestart;
XYZ fac=offset;
Normalise(&fac);
void GUITick(Game* game);
void clearMenu();
void addLabel(int id,const string& label,int x,int y);
- void addButton(int id,const string& label,MBCallback cb,int x,int y,int w,int h);
- void addButton(int id,const string& label,MBCallback cb,int x,int y,int w,int h,float r,float g,float b);
+ void addButton(int id,const string& label,MBCallback cb,int x,int y,int w,int h,float r=1,float g=0,float b=0);
void addImage(int id,int texture,int x,int y,int w,int h);
- void addImageButton(int id,int texture,MBCallback cb,int x,int y,int w,int h);
- void addImageButton(int id,int texture,MBCallback cb,int x,int y,int w,int h,float r,float g,float b);
- void addMapLine(const XYZ& start, const XYZ& end, float startsize, float endsize, float r,float g,float b);
+ void addImageButton(int id,int texture,MBCallback cb,int x,int y,int w,int h,float r=1,float g=1,float b=1);
+ void addMapLine(int x, int y, int w, int h, float startsize, float endsize, float r,float g,float b);
void addMapMarker(int id,int texture,MBCallback cb,int x,int y,int w,int h,float r,float g,float b);
void setMapItem(int id);
void setButtonText(int id,const string& label);