void ChatUserInterface::onEscape() const { // Don't leave if UIQueryServers is a parent unless we're in-game... // Is UIQueryServers supposed to be a parent of UIGame?? if(!getUIManager()->cameFrom<QueryServersUserInterface>() || getUIManager()->cameFrom<GameUserInterface>()) leaveLobbyChat(); getUIManager()->reactivatePrevUI(); playBoop(); }
bool ItemListSelectUserInterface::processMenuSpecificKeys(InputCode inputCode) { string inputString = InputCodeManager::inputCodeToPrintableChar(inputCode); if(inputString == "") return false; mNameSoFar.append(inputString); string mNameSoFarLc = lcase(mNameSoFar); if(stringContainsAllTheSameCharacter(mNameSoFarLc)) { mSelectedIndex = getIndexOfNext(mNameSoFarLc.substr(0, 1)); if(mNameSoFar.size() > 1 && lcase(getMenuItem(mSelectedIndex)->getValue()).substr(0, mNameSoFar.length()) != mNameSoFarLc) mNameSoFar = mNameSoFar.substr(0, mNameSoFar.length() - 1); // Remove final char, the one we just added above } else mSelectedIndex = getIndexOfNext(mNameSoFarLc); mStillTypingNameTimer.reset(); mItemSelectedWithMouse = false; // Move the mouse to the new selection to make things "feel better" MenuItemSize size = getMenuItem(mFirstVisibleItem)->getSize(); S32 y = getYStart(); for(S32 j = mFirstVisibleItem; j < mSelectedIndex; j++) { size = getMenuItem(j)->getSize(); y += getTextSize(size) + getGap(size); } y += getTextSize(size) / 2; // WarpMouse fires a mouse event, which will cause the cursor to become visible, which we don't want. Therefore, // we must resort to the kind of gimicky/hacky method of setting a flag, telling us that we should ignore the // next mouse event that comes our way. It might be better to handle this at the Event level, by creating a custom // method called WarpMouse that adds the suppression. At this point, however, the only place we care about this // is here so... well... this works. SDL_WarpMouseInWindow(DisplayManager::getScreenInfo()->sdlWindow, (S32)DisplayManager::getScreenInfo()->getMousePos()->x, y); Cursor::disableCursor(); mIgnoreNextMouseEvent = true; playBoop(); return true; }
bool KeyDefMenuUserInterface::onKeyDown(InputCode inputCode) { if(Parent::onKeyDown(inputCode)) { /* Do nothing */ } // InputCode entry else if(mChangingItem != NONE) { playBoop(); if(inputCode == KEY_ESCAPE || inputCode == BUTTON_BACK) { mChangingItem = NONE; return true; } // Check for reserved keys (F1-F12, Ctrl, Esc, Button_Back) if(inputCode >= KEY_F1 && inputCode <= KEY_F12) { errorMsgTimer.reset(); errorMsg = "Keys F1 - F12 are reserved. You cannot redefine them. Sorry!"; return true; } else if(inputCode == KEY_CTRL) { errorMsgTimer.reset(); errorMsg = "Control key is reserved. You cannot use it for binding. Sorry!"; return true; } // Fail silently on joystick motion if(inputCode >= STICK_1_LEFT && inputCode <= STICK_2_DOWN) return true; // Assign key setInputCode(menuItems[mChangingItem].primaryControl, inputCode); mChangingItem = NONE; if(inputCode == KEY_CTRL) { errorMsgTimer.reset(); errorMsg = "Be careful when using the Ctrl key -- some keys will not work when Ctrl is pressed"; } return true; } // We're not doing InputCode entry, so let's try menu navigation if(inputCode == KEY_SPACE || inputCode == KEY_ENTER || inputCode == BUTTON_START || inputCode == MOUSE_LEFT) // Set key for selected item { playBoop(); mChangingItem = selectedIndex; } else if(inputCode == KEY_RIGHT || inputCode == BUTTON_DPAD_RIGHT || inputCode == KEY_LEFT || inputCode == BUTTON_DPAD_LEFT) // Change col { playBoop(); if(menuItems[selectedIndex].column == 1) // Switching to right column selectedIndex += firstItemInCol2; else // Switching to left column { selectedIndex -= firstItemInCol2; while(menuItems[selectedIndex].column == 2) selectedIndex--; } Cursor::disableCursor(); // Turn off cursor } else if(inputCode == KEY_ESCAPE || inputCode == BUTTON_BACK) // Quit { playBoop(); saveSettingsToINI(&GameSettings::iniFile, mGameSettings); getUIManager()->reactivatePrevUI(); // to gOptionsMenuUserInterface } else if(inputCode == KEY_UP || inputCode == BUTTON_DPAD_UP) // Prev item { playBoop(); selectedIndex--; if(selectedIndex < 0) selectedIndex = menuItems.size() - 1; Cursor::disableCursor(); // Turn off cursor } else if(inputCode == KEY_DOWN || inputCode == BUTTON_DPAD_DOWN) // Next item { playBoop(); selectedIndex++; if(selectedIndex >= menuItems.size()) selectedIndex = 0; Cursor::disableCursor(); // Turn off cursor } else // No key has been handled return false; // A key was handled return true; }