summaryrefslogtreecommitdiff
path: root/src/gui/gui.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-03 01:29:22 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-03 01:29:22 +0300
commit5e4a1bf239d76a5525a4409dc7a2094fbffe0eb3 (patch)
tree2563cd7dd22fb1370b0311e9b7b45b8657f9ecdf /src/gui/gui.cpp
parenta56d6c4d316551940982d622e9b0e3b0f1ad1863 (diff)
downloadmanaverse-5e4a1bf239d76a5525a4409dc7a2094fbffe0eb3.tar.gz
manaverse-5e4a1bf239d76a5525a4409dc7a2094fbffe0eb3.tar.bz2
manaverse-5e4a1bf239d76a5525a4409dc7a2094fbffe0eb3.tar.xz
manaverse-5e4a1bf239d76a5525a4409dc7a2094fbffe0eb3.zip
Put gui input logic before most game input logic.
This solving game and gui shortcuts conflicts.
Diffstat (limited to 'src/gui/gui.cpp')
-rw-r--r--src/gui/gui.cpp90
1 files changed, 89 insertions, 1 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 9d111141b..19361cf2d 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -259,7 +259,95 @@ void Gui::logic()
Palette::advanceGradients();
- gcn::Gui::logic();
+ if (!mTop)
+ return;
+
+ handleModalFocus();
+ handleModalMouseInputFocus();
+
+ if (mInput)
+ {
+// mInput->_pollInput();
+ handleMouseInput();
+ }
+
+ mTop->logic();
+}
+
+bool Gui::handleInput()
+{
+ if (mInput)
+ return handleKeyInput2();
+ else
+ return false;
+}
+
+bool Gui::handleKeyInput2()
+{
+ bool consumed(false);
+
+ while (!mInput->isKeyQueueEmpty())
+ {
+ gcn::KeyInput keyInput = mInput->dequeueKeyInput();
+
+ // Save modifiers state
+ mShiftPressed = keyInput.isShiftPressed();
+ mMetaPressed = keyInput.isMetaPressed();
+ mControlPressed = keyInput.isControlPressed();
+ mAltPressed = keyInput.isAltPressed();
+
+ gcn::KeyEvent keyEventToGlobalKeyListeners(nullptr,
+ mShiftPressed, mControlPressed, mAltPressed, mMetaPressed,
+ keyInput.getType(), keyInput.isNumericPad(), keyInput.getKey());
+
+ distributeKeyEventToGlobalKeyListeners(
+ keyEventToGlobalKeyListeners);
+
+ // If a global key listener consumes the event it will not be
+ // sent further to the source of the event.
+ if (keyEventToGlobalKeyListeners.isConsumed())
+ {
+ consumed = true;
+ continue;
+ }
+
+ bool keyEventConsumed = false;
+
+ if (mFocusHandler)
+ {
+ // Send key inputs to the focused widgets
+ if (mFocusHandler->getFocused())
+ {
+ gcn::KeyEvent keyEvent(getKeyEventSource(),
+ mShiftPressed, mControlPressed, mAltPressed, mMetaPressed,
+ keyInput.getType(), keyInput.isNumericPad(),
+ keyInput.getKey());
+
+ if (!mFocusHandler->getFocused()->isFocusable())
+ mFocusHandler->focusNone();
+ else
+ distributeKeyEvent(keyEvent);
+
+ keyEventConsumed = keyEvent.isConsumed();
+ if (keyEventConsumed)
+ consumed = true;
+ }
+
+ // If the key event hasn't been consumed and
+ // tabbing is enable check for tab press and
+ // change focus.
+ if (!keyEventConsumed && mTabbing
+ && keyInput.getKey().getValue() == Key::TAB
+ && keyInput.getType() == gcn::KeyInput::PRESSED)
+ {
+ if (keyInput.isShiftPressed())
+ mFocusHandler->tabPrevious();
+ else
+ mFocusHandler->tabNext();
+ }
+ }
+ } // end while
+ return consumed;
}
void Gui::draw()