diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-08-28 00:29:14 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-08-29 00:18:56 +0300 |
commit | e71b8c2bd9722aae29ed36b78806867964a3121d (patch) | |
tree | a33809860b6b2be44905e17075f15a48fbd20c04 /src | |
parent | 9a93f235386bcb47887a33527478700df77dce94 (diff) | |
download | plus-e71b8c2bd9722aae29ed36b78806867964a3121d.tar.gz plus-e71b8c2bd9722aae29ed36b78806867964a3121d.tar.bz2 plus-e71b8c2bd9722aae29ed36b78806867964a3121d.tar.xz plus-e71b8c2bd9722aae29ed36b78806867964a3121d.zip |
add support for process all input events before entering game.
add flag for in game action conditions.
Diffstat (limited to 'src')
-rw-r--r-- | src/actionmanager.cpp | 2 | ||||
-rw-r--r-- | src/client.cpp | 4 | ||||
-rw-r--r-- | src/inputmanager.cpp | 2 | ||||
-rw-r--r-- | src/inputmanager.h | 30 | ||||
-rw-r--r-- | src/keyboarddata.h | 38 |
5 files changed, 42 insertions, 34 deletions
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp index b0018f670..54bf179ae 100644 --- a/src/actionmanager.cpp +++ b/src/actionmanager.cpp @@ -319,6 +319,8 @@ impHandler0(scrollChatDown) impHandler0(quit) { + if (!Game::instance()) + return false; if (viewport && viewport->isPopupMenuVisible()) { viewport->closePopupMenu(); diff --git a/src/client.cpp b/src/client.cpp index c51083151..a04a20512 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1010,7 +1010,9 @@ int Client::gameExec() #endif } - guiInput->pushInput(event); + if (inputManager.handleEvent(event)) + continue; + #ifdef USE_MUMBLE if (player_node && mumbleManager) { diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp index 03aba6ecf..c04185f50 100644 --- a/src/inputmanager.cpp +++ b/src/inputmanager.cpp @@ -659,6 +659,8 @@ void InputManager::updateConditionMask() { mMask |= COND_NOTARGET; } + if (Game::instance()) + mMask |= COND_INGAME; if (!player_node || player_node->getFollow().empty()) mMask |= COND_NOFOLLOW; diff --git a/src/inputmanager.h b/src/inputmanager.h index 2f3a9afc1..d3c245379 100644 --- a/src/inputmanager.h +++ b/src/inputmanager.h @@ -73,20 +73,22 @@ struct KeyFunction final enum KeyCondition { - COND_DEFAULT = 1, // default condition - COND_ENABLED = 2, // keyboard must be enabled - COND_NOINPUT = 4, // input items must be unfocused - COND_NOAWAY = 8, // player not in away mode - COND_NOSETUP = 16, // setup window is hidde - COND_VALIDSPEED = 32, // valid speed - COND_NOMODAL = 64, // modal windows inactive - COND_NONPCINPUT = 128, // npc input field inactive - COND_EMODS = 256, // game modifiers enabled - COND_NOTARGET = 512, // no target/untarget keys pressed - COND_NOFOLLOW = 1024, // follow mode disabled - COND_SHORTCUT = 2 + 4 + 16 + 512, // flags for shortcut keys - COND_GAME = 2 + 4 + 8 + 16 + 64, // main game key - COND_GAME2 = 2 + 8 + 16 + 64 + COND_DEFAULT = 1, // default condition + COND_ENABLED = 2, // keyboard must be enabled + COND_NOINPUT = 4, // input items must be unfocused + COND_NOAWAY = 8, // player not in away mode + COND_NOSETUP = 16, // setup window is hidde + COND_VALIDSPEED = 32, // valid speed + COND_NOMODAL = 64, // modal windows inactive + COND_NONPCINPUT = 128, // npc input field inactive + COND_EMODS = 256, // game modifiers enabled + COND_NOTARGET = 512, // no target/untarget keys + // pressed + COND_NOFOLLOW = 1024, // follow mode disabled + COND_INGAME = 2048, // game must be started + COND_SHORTCUT = 2 + 4 + 16 + 512 + 2048, // flags for shortcut keys + COND_GAME = 2 + 4 + 8 + 16 + 64 + 2048, // main game key + COND_GAME2 = 2 + 8 + 16 + 64 + 2048 }; class InputManager final diff --git a/src/keyboarddata.h b/src/keyboarddata.h index 79da45049..c22ca08fc 100644 --- a/src/keyboarddata.h +++ b/src/keyboarddata.h @@ -109,7 +109,7 @@ static const KeyData keyData[Input::KEY_TOTAL] = { Input::GRP_DEFAULT, nullptr, Input::KEY_NO_VALUE, 50, - COND_DEFAULT}, + COND_DEFAULT | COND_INGAME}, {"keyTalk", INPUT_KEYBOARD, SDLK_t, INPUT_UNKNOWN, Input::KEY_NO_VALUE, @@ -221,7 +221,7 @@ static const KeyData keyData[Input::KEY_TOTAL] = { Input::GRP_DEFAULT, nullptr, Input::KEY_NO_VALUE, 50, - COND_DEFAULT}, + COND_DEFAULT | COND_INGAME}, {"keyShortcut1", INPUT_KEYBOARD, SDLK_1, INPUT_UNKNOWN, Input::KEY_NO_VALUE, @@ -368,7 +368,7 @@ static const KeyData keyData[Input::KEY_TOTAL] = { Input::GRP_DEFAULT | Input::GRP_GUI, &ActionManager::helpWindowShow, Input::KEY_NO_VALUE, 50, - COND_GAME | COND_NOTARGET}, + COND_SHORTCUT}, {"keyWindowStatus", INPUT_KEYBOARD, SDLK_F2, INPUT_UNKNOWN, Input::KEY_NO_VALUE, @@ -515,21 +515,21 @@ static const KeyData keyData[Input::KEY_TOTAL] = { Input::GRP_DEFAULT | Input::GRP_GUI, &ActionManager::prevSocialTab, Input::KEY_NO_VALUE, 50, - COND_NOINPUT}, + COND_NOINPUT | COND_INGAME}, {"keySocialNextTab", INPUT_UNKNOWN, Input::KEY_NO_VALUE, INPUT_UNKNOWN, Input::KEY_NO_VALUE, Input::GRP_DEFAULT | Input::GRP_GUI, &ActionManager::nextSocialTab, Input::KEY_NO_VALUE, 50, - COND_NOINPUT}, + COND_NOINPUT | COND_INGAME}, {"keySmilie", INPUT_KEYBOARD, SDLK_LALT, INPUT_UNKNOWN, Input::KEY_NO_VALUE, Input::GRP_DEFAULT, nullptr, Input::KEY_NO_VALUE, 50, - COND_DEFAULT}, + COND_DEFAULT | COND_INGAME}, {"keyEmoteShortcut1", INPUT_KEYBOARD, SDLK_1, INPUT_UNKNOWN, Input::KEY_NO_VALUE, @@ -872,14 +872,14 @@ static const KeyData keyData[Input::KEY_TOTAL] = { Input::GRP_DEFAULT, nullptr, Input::KEY_NO_VALUE, 50, - COND_DEFAULT}, + COND_DEFAULT | COND_INGAME}, {"keyCopyOutfit", INPUT_KEYBOARD, SDLK_RALT, INPUT_UNKNOWN, Input::KEY_NO_VALUE, Input::GRP_DEFAULT, nullptr, Input::KEY_NO_VALUE, 50, - COND_DEFAULT}, + COND_DEFAULT | COND_INGAME}, {"keyCopyEquipedOutfit", INPUT_KEYBOARD, SDLK_RIGHTBRACKET, INPUT_UNKNOWN, Input::KEY_NO_VALUE, @@ -1565,56 +1565,56 @@ static const KeyData keyData[Input::KEY_TOTAL] = { Input::GRP_DEFAULT | Input::GRP_CHAT, &ActionManager::toggleChat, Input::KEY_NO_VALUE, 50, - COND_NOINPUT | COND_NOAWAY | COND_NOMODAL}, + COND_NOINPUT | COND_NOAWAY | COND_NOMODAL | COND_INGAME}, {"keyChatScrollUp", INPUT_KEYBOARD, SDLK_PAGEUP, INPUT_UNKNOWN, Input::KEY_NO_VALUE, Input::GRP_DEFAULT | Input::GRP_GUI, &ActionManager::scrollChatUp, Input::KEY_NO_VALUE, 50, - COND_DEFAULT}, + COND_DEFAULT | COND_INGAME}, {"keyChatScrollDown", INPUT_KEYBOARD, SDLK_PAGEDOWN, INPUT_UNKNOWN, Input::KEY_NO_VALUE, Input::GRP_DEFAULT | Input::GRP_GUI, &ActionManager::scrollChatDown, Input::KEY_NO_VALUE, 50, - COND_DEFAULT}, + COND_DEFAULT | COND_INGAME}, {"keyChatPrevTab", INPUT_KEYBOARD, SDLK_KP7, INPUT_UNKNOWN, Input::KEY_NO_VALUE, Input::GRP_DEFAULT | Input::GRP_GUI, &ActionManager::prevChatTab, Input::KEY_NO_VALUE, 50, - COND_NOINPUT}, + COND_NOINPUT | COND_INGAME}, {"keyChatNextTab", INPUT_KEYBOARD, SDLK_KP9, INPUT_UNKNOWN, Input::KEY_NO_VALUE, Input::GRP_DEFAULT | Input::GRP_GUI, &ActionManager::nextChatTab, Input::KEY_NO_VALUE, 50, - COND_NOINPUT}, + COND_NOINPUT | COND_INGAME}, {"keyChatCloseTab", INPUT_UNKNOWN, Input::KEY_NO_VALUE, INPUT_UNKNOWN, Input::KEY_NO_VALUE, Input::GRP_DEFAULT | Input::GRP_GUI, &ActionManager::closeChatTab, Input::KEY_NO_VALUE, 50, - COND_NOINPUT}, + COND_NOINPUT | COND_INGAME}, {"keyChatPrevHistory", INPUT_KEYBOARD, SDLK_KP7, INPUT_UNKNOWN, Input::KEY_NO_VALUE, Input::GRP_CHAT | Input::GRP_GUICHAN, nullptr, Input::KEY_NO_VALUE, 50, - COND_DEFAULT}, + COND_DEFAULT | COND_INGAME}, {"keyChatNextHistory", INPUT_KEYBOARD, SDLK_KP9, INPUT_UNKNOWN, Input::KEY_NO_VALUE, Input::GRP_CHAT | Input::GRP_GUICHAN, nullptr, Input::KEY_NO_VALUE, 50, - COND_DEFAULT}, + COND_DEFAULT | COND_INGAME}, {"keyIgnoreInput1", #ifdef USE_SDL2 INPUT_UNKNOWN, Input::KEY_NO_VALUE, @@ -1797,7 +1797,7 @@ static const KeyData keyData[Input::KEY_TOTAL] = { Input::GRP_DEFAULT, &ActionManager::mouseClick, Input::KEY_NO_VALUE, 50, - COND_NOINPUT | COND_NOAWAY | COND_NOMODAL}, + COND_NOINPUT | COND_NOAWAY | COND_NOMODAL | COND_INGAME}, {"keyCameraMode", INPUT_KEYBOARD, SDLK_KP_PLUS, INPUT_UNKNOWN, Input::KEY_NO_VALUE, @@ -1937,7 +1937,7 @@ static const KeyData keyData[Input::KEY_TOTAL] = { Input::GRP_DEFAULT, &ActionManager::stopSit, Input::KEY_NO_VALUE, 50, - COND_DEFAULT}, + COND_DEFAULT | COND_INGAME}, {"keyShowKeyboard", INPUT_UNKNOWN, Input::KEY_NO_VALUE, INPUT_UNKNOWN, Input::KEY_NO_VALUE, @@ -1958,7 +1958,7 @@ static const KeyData keyData[Input::KEY_TOTAL] = { Input::GRP_CHAT, nullptr, Input::KEY_NO_VALUE, 50, - COND_DEFAULT} + COND_DEFAULT | COND_INGAME} }; #endif // KEYBOARDDATA_H |