Does anyone know how I can use that setVisible() property of IGUIElement to make my main menu buttons go away when switching between different sub-menus on my main menu? I've been trying a couple of different things and have not gotten it to work yet. Here's how I'm setting up my menu:
gui::IGUIEnvironment* mainMenu = device->getGUIEnvironment(); //this is declared globally
void Main_Menu(){
driver->draw2DImage(menuBackground, core::position2d<s32>(0,0), core::rect<s32>(0,0, 800,600), 0, video::SColor(255,255,255,255), true);
mainMenu->addButton(core::rect<s32>(50,40, 160,80), 0, 1, L"New Game");
mainMenu->addButton(core::rect<s32>(50,90, 160,130), 0, 2, L"Load Game");
mainMenu->addButton(core::rect<s32>(50,140, 160,180), 0, 3, L"Save Game");
mainMenu->addButton(core::rect<s32>(50,190, 160,230), 0, 4, L"Options");
mainMenu->addButton(core::rect<s32>(50,240, 160,280), 0, 5, L"Credits");
mainMenu->addButton(core::rect<s32>(50,290, 160,330), 0, 6, L"Exit");
mainMenu->drawAll();
return;
} // end Main_Menu
And then when the Options button gets clicked it does this:
if (id == 4){
musicVolumeScrollbar = mainMenu->addScrollBar(true, core::rect<s32>(250, 45, 450, 60), 0,
;
musicVolumeScrollbar->setMax(100);
mainMenu->addButton(core::rect<s32>(50,40, 160,80), 0, 9, L"Return to Main Menu");
gameState = GAME_STATE_OPTIONS;
return true;
} // end if
As of now, the Return to Main Menu button just appears on top of the New Game button and all other buttons stay there. I need to make them dissappear and have only the scrollbar and return button show up plus whatever else I add in to the options menu. Can anyone explain to me how to do this as well as a simple way to set the transparency of the menu buttons. I tried to get that from the GUI tutorial but my code doesn't work right:
menuSkin = mainMenu->getSkin();
for (s32 i=0; i<gui::EGDC_COUNT ; ++i){
video::SColor col = mainMenu->getSkin()->getColor((gui::EGUI_DEFAULT_COLOR)i);
col.setAlpha(1);
mainMenu->getSkin()->setColor((gui::EGUI_DEFAULT_COLOR)i, col);
}
By mistake that code makes the buttons fade in when the menu appears which looks cool but I would like to understand how to set the transparency correctly.