i'm working on key configuration for my game. I would like to do something like this scenario: Player goes into Options, then goes into Input, then (like in real games) he clicks on button (or something like that) and then he press key and done. I have been trying to do that for several hours and nothing :/ There is no such method to block and get any key. I was trying to do some boolean flags and stuff but i doesn't work at all. Here is a bit of my code:
Code: Select all
CEGUI::PushButton* RightSetup = static_cast<CEGUI::PushButton*>(opwmgr.createWindow("TaharezLook/Button", "RightSetup"));
OptionInput->addChildWindow(RightSetup);
RightSetup->setPosition(CEGUI::UVector2( CEGUI::UDim( 0.55f, 0.0f ), CEGUI::UDim( 0.5f, 0.0f) ));
RightSetup->setSize(CEGUI::UVector2( CEGUI::UDim( 0.4f, 0.0f ), CEGUI::UDim( 0.1f, 0.0f ) ));
RightSetup->setText("D");
RightSetup->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&GUI::configKey, this));
and configKey() :
Code: Select all
bool GUI::configKey(const CEGUI::EventArgs &e)
{
CEGUI::WindowManager &gowmgr = CEGUI::WindowManager::getSingleton();
CEGUI::PushButton* button = static_cast<CEGUI::PushButton*>(gowmgr.getWindow("RightSetup"));
button->setText("Press Key");
mSetKey = false;
while(!mSetKey) {}; // <- so stupid, so ugly
button->setText(mKeyText);
return true;
}
and then i have function passingKey() go ten input from my main class which has OIS::KeyListener(), so:
Code: Select all
bool GUI::passingKey(const OIS::KeyEvent &e)
{
if(!mSetKey)
{
mKeyText = e.text;
mSetKey = true;
}
return true;
}
And it of course stop completelly my game and it can't recieve any inputs. Is there any nice way to implement key configuration into game using CEGUI ? How do i do something like block-and-wait for input ?