Delayed behavior problem

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

majc
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Sat Apr 12, 2008 20:55

Delayed behavior problem

Postby majc » Sun Aug 31, 2008 14:14

I have this code:

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?

Return to “Help”

Who is online

Users browsing this forum: No registered users and 12 guests