Code: Select all
guiRoot->getChild("Root/AddMiner")->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&GameState::addMiner,this));
which works fine. However, it is then swapped, changing the layout and subscribing the layout using this:
Code: Select all
void GameState::showSelectedLayouts(UnitManager* teamMgr){
if (mSelectedObjects.size() >= 1){
CEGUI::WindowManager::getSingleton().destroyWindow(guiRoot);
guiRoot = CEGUI::WindowManager::getSingleton().loadWindowLayout(teamMgr->nodeBeingTracked(mSelectedObjects[0])->LayoutName);
//TODO: make this show a blank GUI if different types get selected at once
CEGUI::System::getSingleton().setGUISheet(guiRoot);
guiRoot->activate();
//subscribe events
if(guiRoot->isChild("Root/AddMiner")){
guiRoot->getChild("Root/AddMiner")->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&GameState::addMiner,this));
}else if(guiRoot->isChild("Root/BuildBridge")){
guiRoot->getChild("Root/BuildBridge")->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&GameState::buildBridge,this));
}
}
}
The correct layout is shown, but the button - Root/BuildBridge - doesn't subscribe. Furthermore, when using that function to swap back and subscribe to the originally select layout/button (Root/AddMiner) that doesn't work either. By the events not working, I mean the function doesn't even run (addMiner or addBridge).
Thanks