load/unload layout problem

Celebrien

05-10-2008 13:58:57

Hi all!

My question is not exactly MyGUI performance-related, but I know that if I posted it on the main forum ppl would send me here :) Anyways, what I'm trying to do is to load inventory.layout on press of Tab key, and on the second press to unload this layout. It does work, here's a snippet of code which loads/unloads the layout:


( in the .h file):
MyGUI::VectorWidgetPtr inventoryHUD;

(in the .cpp):
inventoryHUD = LayoutManager::getInstance().load("inventory.layout");
....
....
WidgetManager::getInstance().destroyWidgetsVector(inventoryHUD);


But my problem is that when i press Tab the second time, for the inventory to disappear, it reacts too quickly and as a result the layout disappears and immediately appears again. So I have to press the key, like, super fast to get back to the game (i pause the game when the inventory layout is loaded). Does anyone know how to fix this problem? I tried using a timer (not Ogre::Timer), but that didn't fix it... I really need to find a solution asap, since the game has to be finished in two weeks :(

I'd really appreciate any thoughts and suggestions. Thanks!

Altren

05-10-2008 15:04:56

Show how your handle Tab press (or release) event. Looks like you call it twice.

Celebrien

05-10-2008 18:05:53


if (mKeyboard->isKeyDown(control_manager->getKey("INV"))) //inventory displaying
{
guiMan->showInventory();
guiMan->getGuiObject()->showPointer();
guiMan->setPauseGame(true);
}



guiMan is the object of GuiManager class which handles the methods. "INV" =
Tab. There's a timer in the class :
timer += evt.timeSinceLastFrame;
if (timer > 2){
interacting = false;
timer = 0;
}


I used it for the keypress, but it didn't make a difference... And I don't have an onRelease because I use unbuffered input.