Code: Select all
bool cGUIInterface::handleGrabWeapon(const CEGUI::EventArgs& e)
{
mGrabWeapon = true;
if(weaponWindow)
CEGUI::WindowManager::getSingleton().destroyWindow(weaponWindow);
if(loadGUILayout2)
CEGUI::WindowManager::getSingleton().destroyWindow(loadGUILayout2);
loadGUILayout2 = 0;
return true;
}
Code: Select all
void cGUIInterface::weaponMenu()
{
if(!root)
{
root = (DefaultWindow*)winMgr->createWindow("DefaultWindow", "Root");
CEGUI::System::getSingleton().setGUISheet(root);
}
mGUISystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
if (!loadGUILayout2)
{
loadGUILayout2 = CEGUI::WindowManager::getSingleton().loadWindowLayout((CEGUI::utf8*)"WeaponMenu.layout");
}
weaponWindow = winMgr->getWindow((CEGUI::utf8*)"WeaponWindow");
root->addChildWindow(weaponWindow);
weaponWindow->show();
winMgr->getWindow((CEGUI::utf8*)"ExitButton")->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&cGUIInterface::handleQuitWeaponMenu, this));
winMgr->getWindow((CEGUI::utf8*)"GrabWeaponButton")->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&cGUIInterface::handleGrabWeapon, this));
winMgr->getWindow((CEGUI::utf8*)"PropertiesWeaponButton")->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&cGUIInterface::handleQuitWeaponMenu, this));
}
and this is the function where its called:
Code: Select all
void cWeaponCollisionHandler::setBodyBehavior(Body *body , int damage, bool mode)
{
if(!mode)
mGUI->weaponMenu();
cDebugger::getDebugger()->debug(StringConverter::toString(mGUI->getGrabWeapon()),"grabweapon","grabweapon.txt");
if(mGUI->getGrabWeapon())
{
delete body;
body = 0;
node->removeAndDestroyAllChildren();
delete node;
node = 0;
mGUI->setGrabWeapon(false);
}
}
the problem is that the handlegrabweapon function only takes effect in the second time i call the weapon menu, why?