public void Update(MyDebugSystem system, MyGuiInput input) { input.GetPressedKeys(m_pressedKeys); short modifier = 0; if (input.IsAnyAltKeyPressed()) { modifier |= (short)MyShortcut.ModifierValue.Alt; } if (input.IsAnyShiftKeyPressed()) { modifier |= (short)MyShortcut.ModifierValue.Shift; } if (input.IsAnyCtrlKeyPressed()) { modifier |= (short)MyShortcut.ModifierValue.Control; } foreach (Keys k in m_pressedKeys) { var key = (Keys)k; if (key == Keys.LeftAlt || key == Keys.RightAlt || key == Keys.LeftShift || key == Keys.RightShift || key == Keys.LeftControl || key == Keys.RightControl) { continue; } if (input.IsNewKeyPress(key)) { OnKeyPressed(system, key, modifier); } } }
public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate) { bool captureInput = base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate); if (Enabled && !captureInput && m_rows.Count > 0) { #region handle scrollbar if (m_verticalScrollBar != null) { if (m_verticalScrollBar.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate)) { captureInput = true; } } if (m_horizontalScrollBar != null) { if (m_horizontalScrollBar.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate)) { captureInput = true; } } #endregion // handle only if mouse is over the control if (IsMouseOver() && !captureInput) { #region handle mouse HandleCurrentMousePreselected(); m_doubleClickTimer += MyConstants.PHYSICS_STEP_SIZE_IN_MILLISECONDS; // selection by mouse var preselectedItem = GetMousePreselectedItem(); if (input.IsNewLeftMousePressed()) { if (preselectedItem != null && preselectedItem.Enabled) { // double click handle if (m_doubleClickTimer <= DOUBLE_CLICK_DELAY && m_mouseLastPosition != null && (m_mouseLastPosition.Value - MyGuiManager.MouseCursorPosition).Length() <= 0.005f) { if (ItemDoubleClick != null) { ItemDoubleClick(this, new MyGuiControlListboxItemEventArgs(m_mousePreselectedRowIndex.Value, m_mousePreselectedItemIndex.Value, preselectedItem.Key)); MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick); MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick); } } // click handle else { int? oldSelectedRowIndex = m_selectedRowIndex; int? oldSelectedItemIndex = m_selectedItemIndex; SetSelectedItem(m_mousePreselectedRowIndex, m_mousePreselectedItemIndex); HandleMultiSelect(input.IsAnyCtrlKeyPressed(), input.IsAnyShiftKeyPressed(), oldSelectedRowIndex, oldSelectedItemIndex, m_selectedRowIndex, m_selectedItemIndex); MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick); ResetPreselected(); } m_mouseLastPosition = MyGuiManager.MouseCursorPosition; m_doubleClickTimer = 0; m_isListboxItemDragging = true; captureInput = true; } } // listbox item dragging else if (input.IsLeftMousePressed()) { if (m_isListboxItemDragging) { if (m_mouseLastPosition != null && preselectedItem != null && preselectedItem.Enabled && m_mousePreselectedItemIndex == m_previousMousePreselectedItemIndex && m_mousePreselectedRowIndex == m_previousMousePreselectedRowIndex) { Vector2 mouseDistanceFromLastUpdate = MyGuiManager.MouseCursorPosition - m_mouseLastPosition.Value; if (mouseDistanceFromLastUpdate.Length() != 0.0f) { if (ItemDrag != null) { ItemDrag(this, new MyGuiControlListboxItemEventArgs(m_mousePreselectedRowIndex.Value, m_previousMousePreselectedItemIndex.Value, preselectedItem.Key)); } m_isListboxItemDragging = false; } captureInput = true; } } m_mouseLastPosition = MyGuiManager.MouseCursorPosition; } else { m_isListboxItemDragging = false; } #endregion #region handle keyboard if (hasKeyboardActiveControl) { // handle selection move if (HandleCurrentPreselected(input)) { captureInput = true; preselectedItem = GetPreselectedItem(); } // selection by keyboard if (input.IsNewKeyPress(Keys.Enter) || input.IsNewKeyPress(Keys.Space)) { if (preselectedItem != null && preselectedItem.Enabled) { SetSelectedItem(m_preselectedRowIndex, m_preselectedItemIndex); MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick); } captureInput = true; } } else { HandleMouseWheelScroll(input, ref captureInput); } #endregion } else { m_mousePreselectedItemIndex = null; m_mousePreselectedRowIndex = null; } } return captureInput; }
//public static event OnVoxelShapeSizeChanged OnVoxelShapeSize; //public static event OnVoxelShapeDistanceChanged OnVoxelShapeDistance; public static void HandleInput(MyGuiInput input) { // exit voxel hand using this key if (input.IsEditorControlNewPressed(MyEditorControlEnums.VOXEL_HAND)) { SwitchEnabled(); } if (m_Enabled == false || !IsAnyEditorActive()) { return; } m_applyToVoxelMap = null; //here possible change if ((input.IsEditorControlNewPressed(MyEditorControlEnums.PRIMARY_ACTION_KEY) || input.IsAnyShiftKeyPressed() && input.IsEditorControlPressed(MyEditorControlEnums.PRIMARY_ACTION_KEY)) && (m_timeFromLastShaping >= MyVoxelConstants.VOXEL_HAND_SHAPING_INTERVAL || MyFakes.RAPID_VOXEL_HAND_SHAPING_ENABLED || MyFakes.MWBUILDER)) { m_timeFromLastShaping = 0; if (DetachedVoxelHand != null && !input.IsKeyPress(Keys.Space)) { return; } MyVoxelMap voxelMap = null; if (VoxelHandShape is MyVoxelHandSphere) { MyVoxelHandSphere sphere = (MyVoxelHandSphere)VoxelHandShape; BoundingSphere vol = sphere.WorldVolume; voxelMap = MyVoxelMaps.GetIntersectionWithSphere(ref vol, SelectedVoxelMap); } else if (VoxelHandShape is MyVoxelHandBox) { MyVoxelHandBox box = (MyVoxelHandBox)VoxelHandShape; BoundingBox localBoundingBox = box.GetLocalBoundingBox(); Vector3 boxWorldPosition = box.GetPosition(); voxelMap = MyVoxelMaps.GetIntersectionWithBox(ref localBoundingBox, ref boxWorldPosition, SelectedVoxelMap); } else if (VoxelHandShape is MyVoxelHandCuboid) { MyVoxelHandCuboid cuboid = (MyVoxelHandCuboid)VoxelHandShape; BoundingBox localBoundingBox = cuboid.GetLocalBoundingBox(); Vector3 boxWorldPosition = cuboid.GetPosition(); voxelMap = MyVoxelMaps.GetIntersectionWithBox(ref localBoundingBox, ref boxWorldPosition, SelectedVoxelMap); } else if (VoxelHandShape is MyVoxelHandCylinder) { MyVoxelHandCylinder cylinder = (MyVoxelHandCylinder)VoxelHandShape; BoundingBox localBoundingBox = cylinder.GetLocalBoundingBox(); Vector3 boxWorldPosition = cylinder.GetPosition(); voxelMap = MyVoxelMaps.GetIntersectionWithBox(ref localBoundingBox, ref boxWorldPosition, SelectedVoxelMap); } else { System.Diagnostics.Debug.Assert(false); } if (voxelMap != null) { m_applyToVoxelMap = voxelMap; } } //////////////////////////////////////////////////////////////////////////////////////////////////////////// // Change size of asteroid tool from camera //////////////////////////////////////////////////////////////////////////////////////////////////////////// /* * if (input.IsAnyShiftKeyPressed()) * { * if (input.PreviousMouseScrollWheelValue() > input.MouseScrollWheelValue()) * { * SetVoxelSize(MyEditorVoxelHand.VoxelHandShape.GetShapeSize() - MyVoxelConstants.VOXEL_HAND_SIZE_STEP); * } * else if (input.PreviousMouseScrollWheelValue() < input.MouseScrollWheelValue()) * { * SetVoxelSize(MyEditorVoxelHand.VoxelHandShape.GetShapeSize() + MyVoxelConstants.VOXEL_HAND_SIZE_STEP); * } * * } * * //////////////////////////////////////////////////////////////////////////////////////////////////////////// * // Change distance of asteroid tool from camera * //////////////////////////////////////////////////////////////////////////////////////////////////////////// * * if (input.IsAnyControlPress()) * { * if (input.PreviousMouseScrollWheelValue() > input.MouseScrollWheelValue()) * { * SetShapeDistance(GetShapeDistance() - MyVoxelConstants.VOXEL_HAND_DISTANCE_STEP); * * } * else if (input.PreviousMouseScrollWheelValue() < input.MouseScrollWheelValue()) * { * SetShapeDistance(GetShapeDistance() + MyVoxelConstants.VOXEL_HAND_DISTANCE_STEP); * } * } */ }