I was never a big fan of media for menu systems, so I tend to hard-code generic functions that use basic 2D drawing operations for clean, minimalist feel. My generic button function works like this...
int apiButton(int apiButtonX,int apiButtonY, int apiButtonW, int apiButtonH, char *apiButtonLabel, int apiParentX, int apiParentY){
int apiButtonClicked=0;
int apiButtonHover=0;
//Check if the mouse is hovering
if ((dbMouseX()>apiParentX+apiButtonX)&&(dbMouseX()<apiParentX+apiButtonX+apiButtonW)&&(dbMouseY()>apiParentY+apiButtonY)&&(dbMouseY()<apiParentY+apiButtonY+apiButtonH)){apiButtonHover=1;}
//Draw
if (!apiButtonHover){
dbInk(dbRGB(255,255,255),dbRGB(0,0,0));
dbBox(apiParentX+apiButtonX, apiParentY+apiButtonY, apiParentX+apiButtonX+apiButtonW, apiParentY+apiButtonY+apiButtonH);
dbInk(dbRGB(0,0,0),dbRGB(0,0,0));
dbBox(apiParentX+apiButtonX+1, apiParentY+apiButtonY+1, apiParentX+apiButtonX+apiButtonW-1, apiParentY+apiButtonY+apiButtonH-1);
dbInk(dbRGB(255,255,255),dbRGB(0,0,0));
dbCenterText(apiParentX+apiButtonX+(apiButtonW/2),apiParentY+apiButtonY,apiButtonLabel);
}
if (apiButtonHover){
if (dbMouseClick()!=0){
dbInk(dbRGB(200,200,0),dbRGB(0,0,0));
}
else{
dbInk(dbRGB(255,255,255),dbRGB(0,0,0));
}
dbBox(apiParentX+apiButtonX, apiParentY+apiButtonY, apiParentX+apiButtonX+apiButtonW, apiParentY+apiButtonY+apiButtonH);
dbInk(dbRGB(0,99,204),dbRGB(0,0,0));
dbBox(apiParentX+apiButtonX+1, apiParentY+apiButtonY+1, apiParentX+apiButtonX+apiButtonW-1, apiParentY+apiButtonY+apiButtonH-1);
dbInk(dbRGB(255,255,255),dbRGB(0,0,0));
dbCenterText(apiParentX+apiButtonX+(apiButtonW/2),apiParentY+apiButtonY,apiButtonLabel);
apiButtonClicked=dbMouseClick();
}
return apiButtonClicked;
}
The idea is that no sprites, bitmaps, or images are used, so there is nothing to clean up. The actual usage of this is very simple as well.
int ngmQuitButton;bool ngmQuitButtonCatch=false;
while(LoopGDK()){
//Draw
ngmQuitButton=apiButton(10,58,130,18,"Quit",0,0);
//Clicking
if((ngmQuitButton==1)&&(ngmQuitButtonCatch==false))ngmQuitButtonCatch=true;
if((ngmQuitButton==0)&&(ngmQuitButtonCatch==true)&&(dbMouseClick()==1))ngmQuitButtonCatch=false;
if((ngmQuitButton==0)&&(ngmQuitButtonCatch==true)&&(dbMouseClick()!=1)){
ngmQuitButtonCatch=false;
if(MessageBox(g_pGlob->hWnd,"Are you sure?","Quit",MB_YESNO)==IDYES)
return;
}
}
I don't know if that would compile out right, because this is an excerpt from a program of mine, but that's the basic idea.
My site, for various stuff that I make.