Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(Parent::onKeyDown(inputCode))
- return true;
- #ifndef BF_NO_CONSOLE
- if(gConsole.onKeyDown(inputCode)) // Pass the key on to the console for processing
- return true;
- // If console is open, then we want to capture text, so return false
- if(gConsole.isVisible())
- return false;
- #endif
- string inputString = InputCodeManager::getCurrentInputString(inputCode);
- if(inputCode == KEY_ENTER || inputCode == KEY_KEYPAD_ENTER) // Enter - Edit props
- startAttributeEditor();
- // Mouse wheel scrolls the plugin list, or zooms in and out
- else if(inputCode == MOUSE_WHEEL_UP)
- {
- if(mDockMode == DOCKMODE_PLUGINS && mouseOnDock())
- {
- if(mDockPluginScrollOffset > 0)
- mDockPluginScrollOffset -= 1;
- }
- else
- zoom(0.2f);
- }
- else if(inputCode == MOUSE_WHEEL_DOWN)
- {
- if(mDockMode == DOCKMODE_PLUGINS && mouseOnDock())
- {
- if(mDockPluginScrollOffset < (S32) (mPluginInfos.size() - getDockHeight() / PLUGIN_LINE_SPACING))
- mDockPluginScrollOffset += 1;
- }
- else
- zoom(-0.2f);
- }
- else if(inputCode == MOUSE_MIDDLE) // Click wheel to drag
- {
- mScrollWithMouseLocation = mMousePos;
- mAutoScrollWithMouseReady = !mAutoScrollWithMouse; // Ready to scroll when button is released
- mAutoScrollWithMouse = false; // turn off in case we were already auto scrolling.
- }
- // Regular key handling from here on down
- else if(InputCodeManager::checkModifier(KEY_SHIFT) && inputCode == KEY_0) // Shift-0 -> Set team to hostile
- setCurrentTeam(-2);
- else if(inputCode >= KEY_0 && inputCode <= KEY_9 && InputCodeManager::checkModifier(KEY_NONE)) // Change team affiliation of selection with 0-9 keys
- {
- setCurrentTeam((inputCode - KEY_0) - 1);
- return true;
- }
- #ifdef TNL_OS_MAC_OSX
- // Ctrl-left click is same as right click for Mac users
- else if(inputCode == MOUSE_RIGHT || (inputCode == MOUSE_LEFT && InputCodeManager::checkModifier(KEY_CTRL)))
- #else
- else if(inputCode == MOUSE_RIGHT)
- #endif
- onMouseClicked_right();
- else if(inputCode == MOUSE_LEFT)
- onMouseClicked_left();
- // Neither mouse button, let's try some keys
- else if(checkInputCode(InputCodeManager::BINDING_RIGHT, inputCode)) // Pan right
- mRight = true;
- else if(checkInputCode(InputCodeManager::BINDING_FLIP_HORIZ, inputCode)) // Flip horizontal
- flipSelectionHorizontal();
- else if(checkInputCode(InputCodeManager::BINDING_PASTE_SELECTION, inputCode)) // Paste selection
- pasteSelection();
- else if(checkInputCode(InputCodeManager::BINDING_FLIP_VERTICAL, inputCode)) // Flip vertical
- flipSelectionVertical();
- else if(checkInputCode(InputCodeManager::BINDING_CMDCHAT, inputCode)) // Open console
- openConsole(NULL);
- else if(checkInputCode(InputCodeManager::BINDING_RELOAD_LEVEL, inputCode)) // Reload level
- {
- loadLevel();
- setSaveMessage("Reloaded " + getLevelFileName(), true);
- }
- else if(checkInputCode(InputCodeManager::BINDING_REDO_ACTION, inputCode)) // Redo
- {
- if(!mCreatingPolyline && !mCreatingPoly && !mDraggingObjects && !mDraggingDockItem)
- redo();
- }
- else if(checkInputCode(InputCodeManager::BINDING_UNDO_ACTION, inputCode)) // Undo
- {
- if(!mCreatingPolyline && !mCreatingPoly && !mDraggingObjects && !mDraggingDockItem)
- undo(true);
- }
- else if(checkInputCode(InputCodeManager::BINDING_RESET_VIEW, inputCode)) // Reset veiw
- centerView();
- else if(checkInputCode(InputCodeManager::BINDING_LVLGEN_SCRIPT, inputCode)) // Run levelgen script, or clear last results
- {
- // Ctrl+R is a toggle -- we either add items or clear them
- if(mLevelGenDatabase.getObjectCount() == 0)
- runLevelGenScript();
- else
- clearLevelGenItems();
- }
- else if(inputString == "Shift+1" || inputString == "Shift+3") // '!' or '#'
- startSimpleTextEntryMenu(SimpleTextEntryID);
- else if(checkInputCode(InputCodeManager::BINDING_ROTATE_CENTROID, inputCode)) // Spin by arbitrary amount alt-r
- startSimpleTextEntryMenu(SimpleTextEntryRotateCentroid);
- else if(checkInputCode(InputCodeManager::BINDING_ROTATE_ORIGIN, inputCode)) // Rotate by arbitrary amount ctl-alt-r
- startSimpleTextEntryMenu(SimpleTextEntryRotateOrigin);
- else if(checkInputCode(InputCodeManager::BINDING_SPIN_CCW, inputCode)) // Spin CCW R
- rotateSelection(-15.f, false);
- else if(checkInputCode(InputCodeManager::BINDING_SPIN_CW, inputCode)) // Spin CW shift-r
- rotateSelection(15.f, false);
- else if(checkInputCode(InputCodeManager::BINDING_ROTATE_CCW_ORIGIN, inputCode)) // Rotate CCW about origin ctl-r
- rotateSelection(-15.f, true);
- else if(checkInputCode(InputCodeManager::BINDING_ROTATE_CW_ORIGIN, inputCode)) // Rotate CW about origin ctl-shift-r
- rotateSelection(15.f, true);
- else if(checkInputCode(InputCodeManager::BINDING_INSERT_GEN_ITEMS, inputCode)) // Insert items generated with script into editor ctl-1
- copyScriptItemsToEditor();
- else if(checkInputCode(InputCodeManager::BINDING_UP, inputCode)) // W or Up - Pan up
- mUp = true;
- else if(checkInputCode(InputCodeManager::BINDING_ZOOM_IN1, inputCode)) // Zoom in ctl-up
- mIn = true;
- else if(checkInputCode(InputCodeManager::BINDING_ZOOM_OUT, inputCode)) // Zoom out ctl-down
- mOut = true;
- else if(checkInputCode(InputCodeManager::BINDING_DOWN, inputCode)) // Pan down downarrow
- mDown = true;
- else if(checkInputCode(InputCodeManager::BINDING_SAVE_LEVEL, inputCode)) // Save
- saveLevel(true, true);
- else if(checkInputCode(InputCodeManager::BINDING_DOWN, inputCode)) // Pan down
- mDown = true;
- else if(checkInputCode(InputCodeManager::BINDING_LEFT, inputCode)) // Left or A - Pan left
- mLeft = true;
- else if(inputString == "Shift+=" || inputString == "Shift+Keypad +") // Shifted - Increase barrier width by 1
- changeBarrierWidth(1);
- else if(inputString == "=" || inputString == "Keypad +") // Unshifted + --> by 5
- changeBarrierWidth(5);
- else if(inputString == "Shift+-" || inputString == "Shift+Keypad -") // Shifted - Decrease barrier width by 1
- changeBarrierWidth(-1);
- else if(inputString == "-" || inputString == "Keypad -") // Unshifted --> by 5
- changeBarrierWidth(-5);
- else if(checkInputCode(InputCodeManager::BINDING_ZOOM_IN0, inputCode)) // Zoom In
- mIn = true;
- else if(inputString == "\\") // Split barrier on selected vertex \\
- splitBarrier();
- else if(checkInputCode(InputCodeManager::BINDING_JOIN_SELECTION, inputCode)) // Join selected barrier segments or polygons
- joinBarrier();
- else if(checkInputCode(InputCodeManager::BINDING_SELECT_EVERYTHING, inputCode)) // Select everything
- selectAll(getDatabase());
- else if(checkInputCode(InputCodeManager::BINDING_RESIZE_SELECTION, inputCode)) // Resize selection
- startSimpleTextEntryMenu(SimpleTextEntryScale);
- else if(checkInputCode(InputCodeManager::BINDING_CUT_SELECTION, inputCode)) // Cut selection
- {
- copySelection();
- deleteSelection(true);
- }
- else if(checkInputCode(InputCodeManager::BINDING_COPY_SELECTION, inputCode)) // Copy selection to clipboard
- copySelection();
- else if(checkInputCode(InputCodeManager::BINDING_ZOOM_OUT0, inputCode)) // Zoom out
- mOut = true;
- else if(checkInputCode(InputCodeManager::BINDING_LEVEL_PARAMS_EDITOR, inputCode)) // Level Parameter Editor
- {
- getUIManager()->activate<GameParamUserInterface>();
- playBoop();
- }
- else if(checkInputCode(InputCodeManager::BINDING_TEAM_EDITOR, inputCode)) // Team Editor Menu
- {
- getUIManager()->activate<TeamDefUserInterface>();
- playBoop();
- }
- else if(checkInputCode(InputCodeManager::BINDING_PLACE_TELEPORTER, inputCode)) // Teleporter
- insertNewItem(TeleporterTypeNumber);
- else if(checkInputCode(InputCodeManager::BINDING_PLACE_SPEEDZONE, inputCode)) // SpeedZone
- insertNewItem(SpeedZoneTypeNumber);
- else if(checkInputCode(InputCodeManager::BINDING_PLACE_SPAWN, inputCode)) // Spawn
- insertNewItem(ShipSpawnTypeNumber);
- else if(checkInputCode(InputCodeManager::BINDING_PLACE_SPYBUG, inputCode)) // Spybug
- insertNewItem(SpyBugTypeNumber);
- else if(checkInputCode(InputCodeManager::BINDING_PLACE_REPAIR, inputCode)) // Repair
- insertNewItem(RepairItemTypeNumber);
- else if(checkInputCode(InputCodeManager::BINDING_PLACE_TURRET, inputCode)) // Turret
- insertNewItem(TurretTypeNumber);
- else if(checkInputCode(InputCodeManager::BINDING_PLACE_MINE, inputCode)) // Mine
- insertNewItem(MineTypeNumber);
- else if(checkInputCode(InputCodeManager::BINDING_PLACE_FORCEFIELD, inputCode)) // Forcefield
- insertNewItem(ForceFieldProjectorTypeNumber);
- else if(inputString == "Backspace" || inputString == "Del" || inputString == "Keypad .") // Keypad . is the keypad's del key
- deleteSelection(false);
- else if(checkInputCode(InputCodeManager::BINDING_HELP, inputCode)) // Activates help-screen
- {
- getGame()->getUIManager()->activate<EditorInstructionsUserInterface>();
- playBoop();
- }
- else if(checkInputCode(InputCodeManager::BINDING_ACTIVATE_EDITOR_MENU, inputCode)) // Activate the menu
- {
- playBoop();
- getGame()->getUIManager()->activate<EditorMenuUserInterface>();
- }
- else if(checkInputCode(InputCodeManager::BINDING_NO_GRID_SNAPPING, inputCode)) // No snapping to grid, but still to other things
- mSnapContext = NO_GRID_SNAPPING;
- else if(checkInputCode(InputCodeManager::BINDING_NO_SNAPPING, inputCode)) // Completely disable snapping shift-space
- mSnapContext = NO_SNAPPING;
- else if(checkInputCode(InputCodeManager::BINDING_PREVIEW_MODE, inputCode)) // Turn on preview mode
- mPreviewMode = true;
- else if(checkInputCode(InputCodeManager::BINDING_DOCKMODE_ITEMS, inputCode)) // Dockmode Bindings
- {
- if(mDockMode == DOCKMODE_ITEMS)
- {
- mDockMode = DOCKMODE_PLUGINS;
- mDockWidth = findPluginDockWidth();
- }
- else
- {
- mDockMode = DOCKMODE_ITEMS;
- mDockWidth = ITEMS_DOCK_WIDTH;
- }
- }
- else if(checkPluginKeyBindings(inputString))
- {
- // Do nothing
- }
Advertisement
Add Comment
Please, Sign In to add comment