Guest User

error code?

a guest
Dec 11th, 2013
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 10.67 KB | None | 0 0
  1. if(Parent::onKeyDown(inputCode))
  2.       return true;
  3.  
  4. #ifndef BF_NO_CONSOLE
  5.    if(gConsole.onKeyDown(inputCode))      // Pass the key on to the console for processing
  6.       return true;
  7.  
  8.    // If console is open, then we want to capture text, so return false
  9.    if(gConsole.isVisible())
  10.       return false;
  11. #endif
  12.  
  13.    string inputString = InputCodeManager::getCurrentInputString(inputCode);
  14.  
  15.  
  16.    if(inputCode == KEY_ENTER || inputCode == KEY_KEYPAD_ENTER)       // Enter - Edit props
  17.       startAttributeEditor();
  18.  
  19.    // Mouse wheel scrolls the plugin list, or zooms in and out
  20.  
  21.    else if(inputCode == MOUSE_WHEEL_UP)
  22.    {
  23.       if(mDockMode == DOCKMODE_PLUGINS && mouseOnDock())
  24.       {
  25.          if(mDockPluginScrollOffset > 0)
  26.             mDockPluginScrollOffset -= 1;
  27.       }
  28.       else
  29.          zoom(0.2f);
  30.    }
  31.    else if(inputCode == MOUSE_WHEEL_DOWN)
  32.    {
  33.       if(mDockMode == DOCKMODE_PLUGINS && mouseOnDock())
  34.       {
  35.          if(mDockPluginScrollOffset < (S32) (mPluginInfos.size() - getDockHeight() / PLUGIN_LINE_SPACING))
  36.             mDockPluginScrollOffset += 1;
  37.       }
  38.       else
  39.          zoom(-0.2f);
  40.    }
  41.    else if(inputCode == MOUSE_MIDDLE)     // Click wheel to drag
  42.    {
  43.       mScrollWithMouseLocation = mMousePos;
  44.       mAutoScrollWithMouseReady = !mAutoScrollWithMouse; // Ready to scroll when button is released
  45.       mAutoScrollWithMouse = false;  // turn off in case we were already auto scrolling.
  46.    }
  47.  
  48.    // Regular key handling from here on down
  49.    else if(InputCodeManager::checkModifier(KEY_SHIFT) && inputCode == KEY_0)  // Shift-0 -> Set team to hostile
  50.       setCurrentTeam(-2);
  51.    else if(inputCode >= KEY_0 && inputCode <= KEY_9 && InputCodeManager::checkModifier(KEY_NONE))  // Change team affiliation of selection with 0-9 keys
  52.    {
  53.       setCurrentTeam((inputCode - KEY_0) - 1);
  54.       return true;
  55.    }
  56.  
  57. #ifdef TNL_OS_MAC_OSX
  58.    // Ctrl-left click is same as right click for Mac users
  59.    else if(inputCode == MOUSE_RIGHT || (inputCode == MOUSE_LEFT && InputCodeManager::checkModifier(KEY_CTRL)))
  60. #else
  61.    else if(inputCode == MOUSE_RIGHT)
  62. #endif
  63.       onMouseClicked_right();
  64.  
  65.    else if(inputCode == MOUSE_LEFT)
  66.       onMouseClicked_left();
  67.  
  68.    // Neither mouse button, let's try some keys
  69.    else if(checkInputCode(InputCodeManager::BINDING_RIGHT, inputCode))              // Pan right
  70.       mRight = true;
  71.    else if(checkInputCode(InputCodeManager::BINDING_FLIP_HORIZ, inputCode))         // Flip horizontal
  72.       flipSelectionHorizontal();
  73.    else if(checkInputCode(InputCodeManager::BINDING_PASTE_SELECTION, inputCode))    // Paste selection
  74.       pasteSelection();
  75.    else if(checkInputCode(InputCodeManager::BINDING_FLIP_VERTICAL, inputCode))      // Flip vertical
  76.       flipSelectionVertical();
  77.    else if(checkInputCode(InputCodeManager::BINDING_CMDCHAT, inputCode))            // Open console
  78.       openConsole(NULL);
  79.    else if(checkInputCode(InputCodeManager::BINDING_RELOAD_LEVEL, inputCode))       // Reload level
  80.    {
  81.       loadLevel();                        
  82.       setSaveMessage("Reloaded " + getLevelFileName(), true);
  83.    }
  84.    else if(checkInputCode(InputCodeManager::BINDING_REDO_ACTION, inputCode))           // Redo
  85.    {
  86.       if(!mCreatingPolyline && !mCreatingPoly && !mDraggingObjects && !mDraggingDockItem)
  87.          redo();
  88.    }
  89.    else if(checkInputCode(InputCodeManager::BINDING_UNDO_ACTION, inputCode))           // Undo
  90.    {
  91.       if(!mCreatingPolyline && !mCreatingPoly && !mDraggingObjects && !mDraggingDockItem)
  92.          undo(true);
  93.    }
  94.    else if(checkInputCode(InputCodeManager::BINDING_RESET_VIEW, inputCode))            // Reset veiw
  95.       centerView();
  96.    else if(checkInputCode(InputCodeManager::BINDING_LVLGEN_SCRIPT, inputCode))         // Run levelgen script, or clear last results
  97.    {
  98.       // Ctrl+R is a toggle -- we either add items or clear them
  99.       if(mLevelGenDatabase.getObjectCount() == 0)
  100.          runLevelGenScript();
  101.       else
  102.          clearLevelGenItems();
  103.    }
  104.    else if(inputString == "Shift+1" || inputString == "Shift+3")  // '!' or '#'
  105.       startSimpleTextEntryMenu(SimpleTextEntryID);
  106.    else if(checkInputCode(InputCodeManager::BINDING_ROTATE_CENTROID, inputCode))       // Spin by arbitrary amount alt-r
  107.       startSimpleTextEntryMenu(SimpleTextEntryRotateCentroid);
  108.    else if(checkInputCode(InputCodeManager::BINDING_ROTATE_ORIGIN, inputCode))         // Rotate by arbitrary amount ctl-alt-r
  109.       startSimpleTextEntryMenu(SimpleTextEntryRotateOrigin);
  110.    else if(checkInputCode(InputCodeManager::BINDING_SPIN_CCW, inputCode))              // Spin CCW R
  111.       rotateSelection(-15.f, false);
  112.    else if(checkInputCode(InputCodeManager::BINDING_SPIN_CW, inputCode))               // Spin CW shift-r
  113.       rotateSelection(15.f, false);
  114.    else if(checkInputCode(InputCodeManager::BINDING_ROTATE_CCW_ORIGIN, inputCode))     // Rotate CCW about origin ctl-r
  115.       rotateSelection(-15.f, true);
  116.    else if(checkInputCode(InputCodeManager::BINDING_ROTATE_CW_ORIGIN, inputCode))      // Rotate CW about origin ctl-shift-r
  117.       rotateSelection(15.f, true);
  118.  
  119.    else if(checkInputCode(InputCodeManager::BINDING_INSERT_GEN_ITEMS, inputCode))      // Insert items generated with script into editor ctl-1
  120.       copyScriptItemsToEditor();
  121.    else if(checkInputCode(InputCodeManager::BINDING_UP, inputCode))                    // W or Up - Pan up
  122.       mUp = true;
  123.    else if(checkInputCode(InputCodeManager::BINDING_ZOOM_IN1, inputCode))              // Zoom in ctl-up
  124.       mIn = true;
  125.    else if(checkInputCode(InputCodeManager::BINDING_ZOOM_OUT, inputCode))              // Zoom out ctl-down
  126.       mOut = true;
  127.    else if(checkInputCode(InputCodeManager::BINDING_DOWN, inputCode))                  // Pan down downarrow
  128.       mDown = true;
  129.    else if(checkInputCode(InputCodeManager::BINDING_SAVE_LEVEL, inputCode))            // Save
  130.       saveLevel(true, true);
  131.    else if(checkInputCode(InputCodeManager::BINDING_DOWN, inputCode))                  // Pan down
  132.       mDown = true;
  133.    else if(checkInputCode(InputCodeManager::BINDING_LEFT, inputCode))                  // Left or A - Pan left
  134.       mLeft = true;
  135.    else if(inputString == "Shift+=" || inputString == "Shift+Keypad +")                // Shifted - Increase barrier width by 1
  136.       changeBarrierWidth(1);
  137.    else if(inputString == "=" || inputString == "Keypad +")                            // Unshifted + --> by 5
  138.       changeBarrierWidth(5);
  139.    else if(inputString == "Shift+-" || inputString == "Shift+Keypad -")                // Shifted - Decrease barrier width by 1
  140.       changeBarrierWidth(-1);
  141.    else if(inputString == "-" || inputString == "Keypad -")                            // Unshifted --> by 5
  142.       changeBarrierWidth(-5);
  143.    else if(checkInputCode(InputCodeManager::BINDING_ZOOM_IN0, inputCode))              // Zoom In
  144.       mIn = true;
  145.    else if(inputString == "\\")           // Split barrier on selected vertex \\
  146.       splitBarrier();
  147.    else if(checkInputCode(InputCodeManager::BINDING_JOIN_SELECTION, inputCode))        // Join selected barrier segments or polygons
  148.       joinBarrier();
  149.    else if(checkInputCode(InputCodeManager::BINDING_SELECT_EVERYTHING, inputCode))     // Select everything
  150.       selectAll(getDatabase());
  151.    else if(checkInputCode(InputCodeManager::BINDING_RESIZE_SELECTION, inputCode))      // Resize selection
  152.       startSimpleTextEntryMenu(SimpleTextEntryScale);
  153.    else if(checkInputCode(InputCodeManager::BINDING_CUT_SELECTION, inputCode))         // Cut selection
  154.    {
  155.       copySelection();
  156.       deleteSelection(true);
  157.    }
  158.    else if(checkInputCode(InputCodeManager::BINDING_COPY_SELECTION, inputCode))        // Copy selection to clipboard
  159.       copySelection();
  160.    else if(checkInputCode(InputCodeManager::BINDING_ZOOM_OUT0, inputCode))             // Zoom out
  161.       mOut = true;
  162.    else if(checkInputCode(InputCodeManager::BINDING_LEVEL_PARAMS_EDITOR, inputCode))   // Level Parameter Editor
  163.    {
  164.       getUIManager()->activate<GameParamUserInterface>();
  165.       playBoop();
  166.    }
  167.    else if(checkInputCode(InputCodeManager::BINDING_TEAM_EDITOR, inputCode))           // Team Editor Menu
  168.    {
  169.       getUIManager()->activate<TeamDefUserInterface>();
  170.       playBoop();
  171.    }
  172.    else if(checkInputCode(InputCodeManager::BINDING_PLACE_TELEPORTER, inputCode))      // Teleporter
  173.       insertNewItem(TeleporterTypeNumber);
  174.    else if(checkInputCode(InputCodeManager::BINDING_PLACE_SPEEDZONE, inputCode))       // SpeedZone
  175.       insertNewItem(SpeedZoneTypeNumber);
  176.    else if(checkInputCode(InputCodeManager::BINDING_PLACE_SPAWN, inputCode))           // Spawn
  177.       insertNewItem(ShipSpawnTypeNumber);
  178.    else if(checkInputCode(InputCodeManager::BINDING_PLACE_SPYBUG, inputCode))          // Spybug
  179.       insertNewItem(SpyBugTypeNumber);
  180.    else if(checkInputCode(InputCodeManager::BINDING_PLACE_REPAIR, inputCode))          // Repair
  181.       insertNewItem(RepairItemTypeNumber);
  182.    else if(checkInputCode(InputCodeManager::BINDING_PLACE_TURRET, inputCode))          // Turret
  183.       insertNewItem(TurretTypeNumber);
  184.    else if(checkInputCode(InputCodeManager::BINDING_PLACE_MINE, inputCode))            // Mine
  185.       insertNewItem(MineTypeNumber);
  186.    else if(checkInputCode(InputCodeManager::BINDING_PLACE_FORCEFIELD, inputCode))      // Forcefield
  187.       insertNewItem(ForceFieldProjectorTypeNumber);
  188.    else if(inputString == "Backspace" || inputString == "Del" || inputString == "Keypad .")   // Keypad . is the keypad's del key
  189.       deleteSelection(false);
  190.    else if(checkInputCode(InputCodeManager::BINDING_HELP, inputCode))                  // Activates help-screen
  191.    {
  192.       getGame()->getUIManager()->activate<EditorInstructionsUserInterface>();
  193.       playBoop();
  194.    }
  195.    else if(checkInputCode(InputCodeManager::BINDING_ACTIVATE_EDITOR_MENU, inputCode))  // Activate the menu
  196.    {
  197.       playBoop();
  198.       getGame()->getUIManager()->activate<EditorMenuUserInterface>();
  199.    }
  200.    else if(checkInputCode(InputCodeManager::BINDING_NO_GRID_SNAPPING, inputCode))      // No snapping to grid, but still to other things
  201.       mSnapContext = NO_GRID_SNAPPING;
  202.    else if(checkInputCode(InputCodeManager::BINDING_NO_SNAPPING, inputCode))           // Completely disable snapping shift-space
  203.       mSnapContext = NO_SNAPPING;
  204.    else if(checkInputCode(InputCodeManager::BINDING_PREVIEW_MODE, inputCode))          // Turn on preview mode
  205.       mPreviewMode = true;
  206.    else if(checkInputCode(InputCodeManager::BINDING_DOCKMODE_ITEMS, inputCode))        // Dockmode Bindings
  207.    {
  208.       if(mDockMode == DOCKMODE_ITEMS)
  209.       {
  210.           mDockMode = DOCKMODE_PLUGINS;
  211.           mDockWidth = findPluginDockWidth();
  212.       }
  213.       else
  214.       {
  215.           mDockMode = DOCKMODE_ITEMS;
  216.           mDockWidth = ITEMS_DOCK_WIDTH;
  217.       }
  218.    }
  219.    else if(checkPluginKeyBindings(inputString))
  220.    {
  221.       // Do nothing
  222.    }
Advertisement
Add Comment
Please, Sign In to add comment