public override bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { if ((Control.ModifierKeys & Keys.Control) == Keys.None) { this.m_picking = false; return base.OnMouseEvent(mouseEvent, mouseEventArgs); } switch (mouseEvent) { case Editor.MouseEvent.MouseDown: if (!this.m_picking) { this.m_picking = true; this.UpdatePicking(); } break; case Editor.MouseEvent.MouseUp: this.m_picking = false; break; case Editor.MouseEvent.MouseMove: if (this.m_picking) { this.UpdatePicking(); } break; } return false; }
public override bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { if (mouseEvent == Editor.MouseEvent.MouseUp && this.m_painting == ToolPaint.PaintingMode.None) { if (!this.m_rampStarted) { this.m_rampStarted = Editor.RayCastTerrainFromMouse(out this.m_rampStart); } else { Vec3 vec; if (Editor.RayCastTerrainFromMouse(out vec)) { UndoManager.RecordUndo(); TerrainManipulator.Ramp(this.m_rampStart.XY, vec.XY, this.m_radius.Value, this.m_hardness.Value); UndoManager.CommitUndo(); this.m_rampStarted = false; } } } return base.OnMouseEvent(mouseEvent, mouseEventArgs); }
public bool OnKeyEvent(Editor.KeyEvent keyEvent, KeyEventArgs keyEventArgs) { if (keyEvent == Editor.KeyEvent.KeyUp) { Keys keyCode = keyEventArgs.KeyCode; if (keyCode == Keys.Escape) { this.CurrentTool = null; return true; } ButtonItem buttonItem = null; if (this.m_toolShortcuts.TryGetValue(keyEventArgs.KeyCode, out buttonItem)) { this.CurrentTool = (ITool)buttonItem.Tag; return true; } } return false; }
public override bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { switch (mouseEvent) { case Editor.MouseEvent.MouseDown: if (!this.m_paramPreview.Value && (Control.ModifierKeys & Keys.Control) != Keys.None) { this.m_localRotate = true; Editor.Viewport.CaptureMouse = true; return false; } return false; case Editor.MouseEvent.MouseUp: if (!this.m_paramPreview.Value) { if (this.m_localRotate) { this.m_localRotate = false; Editor.Viewport.CaptureMouse = false; return false; } if (!this.m_newObjectValid) { return false; } ObjectInventory.Entry value = this.m_paramObject.Value; if (value != null && value.IsAI && !EditorDocument.NavmeshEnabled) { if (LocalizedMessageBox.Show(MainForm.Instance, Localizer.LocalizeCommon("EDITOR_NAVMESH_PROMPT"), Localizer.Localize("EDITOR_CONFIRMATION"), Localizer.Localize("Generic", "GENERIC_YES"), Localizer.Localize("Generic", "GENERIC_NO"), null, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) != DialogResult.Yes) { return false; } EditorDocument.NavmeshEnabled = true; } UndoManager.RecordUndo(); EditorObjectSelection newSelection = EditorObjectSelection.Create(); this.m_context.m_selection.Clone(newSelection, true); newSelection.Dispose(); foreach (EditorObject current in this.m_context.m_selection.GetObjects()) { ObjectManager.OnObjectAddedFromTool(current); } UndoManager.CommitUndo(); if (!this.m_paramBatchAdd.Value) { this.ClearObjectParam(); return false; } return false; } else { ObjectInventory.Entry entryFromScreenPoint = ObjectLegoBox.GetEntryFromScreenPoint(Editor.Viewport.NormalizedMousePos); if (entryFromScreenPoint.IsValid) { this.m_paramObject.Value = entryFromScreenPoint; this.m_paramPreview.Value = false; this.UpdatePreview(); return false; } return false; } break; case Editor.MouseEvent.MouseMove: { if (this.m_paramPreview.Value || this.m_context.m_selection.Count <= 0) { return false; } this.m_newObjectValid = false; Vec3 raySrc; Vec3 rayDir; Editor.GetWorldRayFromScreenPoint(Editor.Viewport.NormalizedMousePos, out raySrc, out rayDir); Vec3 pos; float num; Vec3 normal; if (Editor.RayCastPhysics(raySrc, rayDir, this.m_context.m_selection, out pos, out num, out normal)) { this.m_context.m_selection.LoadState(); foreach (EditorObject current2 in this.m_context.m_selection.GetObjects()) { if (current2.Entry.AutoOrientation) { Vec3 angles; current2.ComputeAutoOrientation(ref pos, out angles, normal); current2.Angles = angles; } } this.m_context.m_selection.MoveTo(pos, EditorObjectSelection.MoveMode.MoveNormal); this.m_context.m_selection.SaveState(); this.m_context.m_selection.SnapToClosestObjects(); this.m_newObjectValid = true; } using (IEnumerator<EditorObject> enumerator3 = this.m_context.m_selection.GetObjects().GetEnumerator()) { while (enumerator3.MoveNext()) { EditorObject current3 = enumerator3.Current; current3.Visible = this.m_newObjectValid; } return false; } break; } case Editor.MouseEvent.MouseMoveDelta: break; default: return false; } if (!this.m_paramPreview.Value && this.m_context.m_selection.Count > 0) { float num2 = 0.025f * (float)mouseEventArgs.X; this.m_context.m_selection.LoadState(); this.m_newObjectAngle += num2; this.m_context.m_selection.RotateCenter(num2, new Vec3(0f, 0f, 1f)); this.m_context.m_selection.SaveState(); this.m_context.m_selection.SnapToClosestObjects(); } return false; }
public bool OnKeyEvent(Editor.KeyEvent keyEvent, KeyEventArgs keyEventArgs) { return false; }
public override bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { switch (mouseEvent) { case Editor.MouseEvent.MouseUp: base.ReleaseInput(); break; case Editor.MouseEvent.MouseMoveDelta: { Vec3 rotationAxis = this.m_rotationAxis; Vec2 xZ = Camera.Axis.ConvertFromWorld(rotationAxis).XZ; xZ.Normalize(); xZ.Rotate90CW(); Vec2 v = new Vec2((float)mouseEventArgs.X, (float)(-(float)mouseEventArgs.Y)); float num = Vec2.Dot(xZ, v); float angle; if (!this.m_snap) { angle = num * 0.025f; } else { this.m_rotationDelta += num; float num2 = (float)Math.IEEERemainder((double)this.m_rotationDelta, 25.0); angle = (this.m_rotationDelta - num2) / 25f * MathUtils.Deg2Rad(this.m_snapSize); this.m_rotationDelta = num2; } this.m_context.m_selection.LoadState(); switch (this.m_context.m_paramAxisType.Value) { case AxisType.Local: this.m_context.m_selection.Rotate(angle, rotationAxis, this.m_rotationPivot, false); break; case AxisType.World: if (this.m_context.m_selection.Count > 1) { this.m_context.m_selection.RotateCenter(angle, rotationAxis); } else { this.m_context.m_selection.Rotate(angle, rotationAxis, this.m_rotationPivot, false); } break; } this.m_context.m_selection.SaveState(); this.m_context.m_selection.SnapToClosestObjects(); this.m_context.UpdateSelection(); break; } } return false; }
public override bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { switch (mouseEvent) { case Editor.MouseEvent.MouseUp: { Vec3 pos; EditorObject objectFromScreenPoint = ObjectManager.GetObjectFromScreenPoint(Editor.Viewport.NormalizedMousePos, out pos, false, this.m_source); if (objectFromScreenPoint.IsValid && objectFromScreenPoint.GetClosestPivot(pos, out this.m_targetPivot)) { UndoManager.RecordUndo(); this.m_context.m_selection.Center = this.m_sourcePivot.position; this.m_context.m_selection.SnapToPivot(this.m_sourcePivot, this.m_targetPivot, this.PreserveOrientation, this.m_angle); UndoManager.CommitUndo(); } base.ReleaseInput(); break; } case Editor.MouseEvent.MouseMove: { Vec3 pos2; this.m_target = ObjectManager.GetObjectFromScreenPoint(Editor.Viewport.NormalizedMousePos, out pos2, false, this.m_source); if (this.m_target.IsValid) { this.m_target.GetClosestPivot(pos2, out this.m_targetPivot); } break; } } return false; }
public override bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { switch (mouseEvent) { case Editor.MouseEvent.MouseUp: base.ReleaseInput(); break; case Editor.MouseEvent.MouseMove: { Vec3 v; if (this.m_gizmoHelper.GetVirtualPos(out v)) { Vec3 vec = v - this.m_virtualStart; if (this.m_snap) { vec = this.m_refGizmo.Axis.ConvertFromWorld(vec); if (!this.m_snapObject.IsValid) { vec.Snap(this.m_snapSize); } else { if (this.m_snapObject.IsLoaded) { vec.Snap(this.m_snapObject.LocalBounds.Length); } else { vec = new Vec3(0f, 0f, 0f); } } vec = this.m_refGizmo.Axis.ConvertToWorld(vec); } Vec3 vec2 = this.m_startPosition + vec; this.m_context.m_selection.LoadState(); this.m_context.m_selection.MoveTo(vec2, EditorObjectSelection.MoveMode.MoveNormal); this.m_context.m_selection.SnapToClosestObjects(); this.m_pivot = vec2; this.m_context.UpdateSelection(); } break; } } return false; }
public override bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { switch (mouseEvent) { case Editor.MouseEvent.MouseUp: base.ReleaseInput(); break; case Editor.MouseEvent.MouseMove: { if (this.m_delayedMove) { if (Math.Abs(this.m_delayedMoveStart.X - Cursor.Position.X) < 2 && Math.Abs(this.m_delayedMoveStart.Y - Cursor.Position.Y) < 2) { break; } if ((Control.ModifierKeys & Keys.Shift) != Keys.None) { EditorObjectSelection editorObjectSelection = EditorObjectSelection.Create(); this.m_context.m_selection.Clone(editorObjectSelection, true); int num = this.m_context.m_selection.IndexOf(this.m_context.m_gizmoObject); this.m_context.SetSelection(editorObjectSelection, (num != -1) ? editorObjectSelection[num] : EditorObject.Null); } Vec2 normalizedMousePos; if (Editor.GetScreenPointFromWorldPos(this.m_pivot, out normalizedMousePos)) { Editor.Viewport.NormalizedMousePos = normalizedMousePos; } this.m_delayedMove = false; } Vec3 raySrc; Vec3 rayDir; Editor.GetWorldRayFromScreenPoint(Editor.Viewport.NormalizedMousePos, out raySrc, out rayDir); Vec3 vec; float num2; Vec3 normal; if (Editor.RayCastPhysics(raySrc, rayDir, this.m_context.m_selection, out vec, out num2, out normal)) { this.m_context.m_selection.Center = this.m_pivot; this.m_context.m_selection.LoadState(); if (this.m_context.m_selection.Count == 1) { EditorObject editorObject = this.m_context.m_selection[0]; if (editorObject.Entry.AutoOrientation) { Vec3 angles; editorObject.ComputeAutoOrientation(ref vec, out angles, normal); editorObject.Angles = angles; } } this.m_context.m_selection.MoveTo(vec, EditorObjectSelection.MoveMode.MoveNormal); this.m_context.m_selection.SnapToClosestObjects(); this.m_pivot = vec; this.m_context.UpdateSelection(); } break; } case Editor.MouseEvent.MouseMoveDelta: this.m_context.m_selection.LoadState(); this.m_context.m_selection.RotateCenter(0.025f * (float)mouseEventArgs.X, new Vec3(0f, 0f, 1f)); this.m_context.m_selection.SaveState(); this.m_context.m_selection.SnapToClosestObjects(); break; case Editor.MouseEvent.MouseWheel: { this.m_context.m_selection.LoadState(); Vec3 center = this.m_context.m_selection.Center; center.Z += (float)((0.3f * (float)mouseEventArgs.Delta > 0f) ? 1 : -1); this.m_context.m_selection.MoveTo(center, EditorObjectSelection.MoveMode.MoveNormal); this.m_context.m_selection.SaveState(); break; } } return false; }
public override bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { if (mouseEvent == Editor.MouseEvent.MouseDown) { if (this.m_context.m_gizmoActive) { Vec3 position = this.m_context.m_gizmo.Position; Vec3 rotationAxis = default(Vec3); switch (this.m_context.m_gizmo.Active) { case Axis.X: rotationAxis = this.m_context.m_gizmo.Axis.axisX; break; case Axis.Y: rotationAxis = this.m_context.m_gizmo.Axis.axisY; break; case Axis.Z: rotationAxis = this.m_context.m_gizmo.Axis.axisZ; break; } ToolObject.RotateAction rotateAction = new ToolObject.RotateAction(this.m_context); if (this.m_paramSnap.Value) { rotateAction.SetSnap(this.m_paramSnapSize.Value); } rotateAction.Start(position, rotationAxis); } else { Vec3 pos; EditorObject objectFromScreenPoint = ObjectManager.GetObjectFromScreenPoint(Editor.Viewport.NormalizedMousePos, out pos); if (objectFromScreenPoint.IsValid) { if (!this.m_context.m_selection.Contains(objectFromScreenPoint)) { EditorObjectSelection editorObjectSelection = EditorObjectSelection.Create(); if ((Control.ModifierKeys & Keys.Control) != Keys.None) { this.m_context.m_selection.Clone(editorObjectSelection, false); } this.m_context.SelectObject(editorObjectSelection, objectFromScreenPoint); this.m_context.SetSelection(editorObjectSelection, objectFromScreenPoint); } else { this.m_context.SetupGizmo(objectFromScreenPoint); } EditorObjectPivot editorObjectPivot; Vec3 position2; if (objectFromScreenPoint.GetClosestPivot(pos, out editorObjectPivot)) { position2 = editorObjectPivot.position; } else { position2 = objectFromScreenPoint.Position; } Vec3 rotationAxis2 = new Vec3(0f, 0f, 1f); ToolObject.RotateAction rotateAction2 = new ToolObject.RotateAction(this.m_context); if (this.m_paramSnap.Value) { rotateAction2.SetSnap(this.m_paramSnapSize.Value); } rotateAction2.Start(position2, rotationAxis2); } else { ToolObject.SelectAction selectAction = new ToolObject.SelectAction(this.m_context); selectAction.Start(); } } } return false; }
public bool OnKeyEvent(Editor.KeyEvent keyEvent, KeyEventArgs keyEventArgs) { switch (keyEvent) { case Editor.KeyEvent.KeyDown: switch (keyEventArgs.KeyCode) { case Keys.D1: this.SwitchMode(this.m_selectMode); return true; case Keys.D2: this.SwitchMode(this.m_moveMode); return true; case Keys.D3: this.SwitchMode(this.m_rotateMode); return true; case Keys.D4: this.SwitchMode(this.m_addMode); break; } break; case Editor.KeyEvent.KeyUp: { Keys keyCode = keyEventArgs.KeyCode; if (keyCode != Keys.Escape) { if (keyCode == Keys.Delete) { this.DeleteSelection(); return true; } } else { if (this.m_selection.Count > 0) { this.ClearSelection(); return true; } } break; } } return false; }
public bool OnKeyEvent(Editor.KeyEvent keyEvent, KeyEventArgs keyEventArgs) { switch (keyEvent) { case Editor.KeyEvent.KeyDown: switch (keyEventArgs.KeyCode) { case Keys.D1: this.m_paramEditTool.Value = ToolSpline.EditTool.Select; break; case Keys.D2: this.m_paramEditTool.Value = ToolSpline.EditTool.Paint; break; case Keys.D3: this.m_paramEditTool.Value = ToolSpline.EditTool.Add; break; case Keys.D4: this.m_paramEditTool.Value = ToolSpline.EditTool.Remove; break; } break; case Editor.KeyEvent.KeyUp: if (keyEventArgs.KeyCode == Keys.Delete) { this.DeleteSelection(); this.m_spline.RemoveSimilarPoints(); return true; } break; } return false; }
public bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { switch (mouseEvent) { case Editor.MouseEvent.MouseDown: if (this.m_spline.IsValid) { UndoManager.RecordUndo(); switch (this.m_paramEditTool.Value) { case ToolSpline.EditTool.Select: if ((Control.ModifierKeys & Keys.Control) != Keys.None) { this.StartDrag(SplineController.SelectMode.Toggle); } else { if ((Control.ModifierKeys & Keys.Shift) != Keys.None) { this.StartDrag(SplineController.SelectMode.Add); } else { if (this.TestPoints()) { if (!this.m_splineController.IsSelected(this.m_hitPoint)) { this.m_splineController.ClearSelection(); this.m_splineController.SetSelected(this.m_hitPoint, true); } this.m_state = ToolSpline.State.Moving; } else { this.StartDrag(SplineController.SelectMode.Replace); } } } break; case ToolSpline.EditTool.Paint: case ToolSpline.EditTool.Add: { this.m_hitPoint = -1; this.m_hitDelta = new Vec2(0f, 0f); Vec3 vec; if (this.m_spline.Count < 100 && Editor.RayCastTerrainFromMouse(out vec)) { if (this.m_spline.Count <= 1) { if (this.m_spline.Count < 1) { this.m_spline.AddPoint(vec.XY); } this.m_spline.AddPoint(vec.XY); this.m_hitPoint = 1; } else { if (this.TestPoints()) { if (this.m_hitPoint == 0) { this.m_spline.InsertPoint(vec.XY, 0); } else { if (this.m_hitPoint == this.m_spline.Count - 1) { this.m_spline.InsertPoint(vec.XY, this.m_hitPoint + 1); this.m_hitPoint++; } } } else { if (this.TestSegments()) { this.m_hitPoint++; this.m_spline.InsertPoint(vec.XY, this.m_hitPoint); } } } if (this.m_hitPoint != -1) { this.m_splineController.ClearSelection(); this.m_splineController.SetSelected(this.m_hitPoint, true); this.m_spline.UpdateSpline(); if (this.m_paramEditTool.Value == ToolSpline.EditTool.Paint) { this.m_state = ToolSpline.State.Drawing; if (this.m_hitPoint == 0) { this.m_forward = false; } else { if (this.m_hitPoint == this.m_spline.Count - 1) { this.m_forward = true; } else { this.m_state = ToolSpline.State.Moving; } } } else { this.m_state = ToolSpline.State.Moving; } } } break; } case ToolSpline.EditTool.Remove: this.RemovePointUnderMouse(); this.m_state = ToolSpline.State.Removing; break; } if (this.m_state != ToolSpline.State.None) { MainForm.Instance.EnableShortcuts = false; } else { UndoManager.CommitUndo(); } } break; case Editor.MouseEvent.MouseUp: if (this.m_spline.IsValid && this.m_state != ToolSpline.State.None) { UndoManager.CommitUndo(); switch (this.m_state) { case ToolSpline.State.Dragging: { RectangleF dragRectangle = this.DragRectangle; this.m_splineController.SelectFromScreenRect(dragRectangle, 0.015f, this.m_dragMode); break; } case ToolSpline.State.Drawing: { bool flag = false; if (this.m_forward && this.m_hitPoint >= 1) { flag = this.m_spline.OptimizePoint(this.m_hitPoint - 1); } else { if (!this.m_forward && this.m_hitPoint < this.m_spline.Count - 1) { flag = this.m_spline.OptimizePoint(this.m_hitPoint + 1); } } if (flag) { this.m_spline.UpdateSpline(); } break; } } if (this.m_spline.RemoveSimilarPoints()) { this.m_spline.UpdateSpline(); this.m_splineController.ClearSelection(); } if (this.m_state != ToolSpline.State.None) { this.m_spline.FinalizeSpline(); MainForm.Instance.EnableShortcuts = true; } this.m_hitPoint = -1; this.m_state = ToolSpline.State.None; } break; case Editor.MouseEvent.MouseMove: if (this.m_spline.IsValid) { switch (this.m_state) { case ToolSpline.State.Moving: this.MovePointsToMouse(false); break; case ToolSpline.State.Drawing: this.MovePointsToMouse(true); break; case ToolSpline.State.Removing: this.RemovePointUnderMouse(); break; } } break; } return false; }
private static void EventCallback(uint eventType, IntPtr eventPtr) { Editor.OnEditorEvent(eventType, eventPtr); }
private static void UpdateCallback(float dt) { Editor.OnUpdate(dt); }
public static bool RayCastPhysicsFromMouse(out Vec3 hitPos) { return(Editor.RayCastPhysicsFromScreenPoint(Editor.Viewport.NormalizedMousePos, out hitPos)); }
public static bool RayCastPhysics(Vec3 raySrc, Vec3 rayDir, EditorObjectSelection ignore, out Vec3 hitPos, out float hitDist) { Vec3 vec; return(Editor.RayCastPhysics(raySrc, rayDir, ignore, out hitPos, out hitDist, out vec)); }
public static bool GetScreenPointFromWorldPos(Vec3 worldPos, out Vec2 screenPoint) { return(Editor.GetScreenPointFromWorldPos(worldPos, out screenPoint, false)); }
public override bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { if (mouseEvent == Editor.MouseEvent.MouseDown) { ToolObject.SnapAction snapAction = new ToolObject.SnapAction(this.m_context); snapAction.PreserveOrientation = this.m_paramPreserveOrientation.Value; if (this.m_paramUseSnapAngle.Value) { snapAction.AngleSnap = MathUtils.Deg2Rad((this.m_paramAngleDir.Value == RotationDirection.CCW) ? this.m_paramSnapAngle.Value : (-this.m_paramSnapAngle.Value)); } if (!snapAction.Start()) { ToolObject.SelectAction selectAction = new ToolObject.SelectAction(this.m_context); selectAction.Start(); } } return false; }
public static void OnKeyEvent(Editor.KeyEvent keyEvent, KeyEventArgs keyEventArgs) { if (Editor.IsIngame) { if (keyEvent == Editor.KeyEvent.KeyUp && keyEventArgs.KeyCode == Keys.Escape) { Editor.ExitIngame(); return; } } else { foreach (IInputSink current in Editor.GetInputs()) { if (current.OnKeyEvent(keyEvent, keyEventArgs)) { break; } } } }
public override bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { if (mouseEvent == Editor.MouseEvent.MouseDown) { ToolObject.SelectAction selectAction = new ToolObject.SelectAction(this.m_context); selectAction.Start(); } return base.OnMouseEvent(mouseEvent, mouseEventArgs); }
public static void OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { foreach (IInputSink current in Editor.GetInputs()) { if (current.OnMouseEvent(mouseEvent, mouseEventArgs)) { break; } } }
public override bool OnKeyEvent(Editor.KeyEvent keyEvent, KeyEventArgs keyEventArgs) { switch (keyEvent) { case Editor.KeyEvent.KeyDown: if (keyEventArgs.KeyCode == Keys.ControlKey) { this.SetLocalRotate(true); return true; } break; case Editor.KeyEvent.KeyUp: if (keyEventArgs.KeyCode == Keys.ControlKey) { this.SetLocalRotate(false); return true; } break; } return false; }
public bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { switch (mouseEvent) { case Editor.MouseEvent.MouseUp: if (mouseEventArgs.Button == MouseButtons.Left && this.m_cursorValid) { Navmesh.RegenerateTileAt(this.m_cursorPos.XY, true); this.m_regenerateTile.Checked = false; } break; case Editor.MouseEvent.MouseMove: this.m_cursorValid = Editor.RayCastTerrainFromMouse(out this.m_cursorPos); break; } return false; }
public bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { if (mouseEvent == Editor.MouseEvent.MouseMove) { this.TestGizmo(); } return false; }
public virtual bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { switch (mouseEvent) { case Editor.MouseEvent.MouseDown: if ((Control.ModifierKeys & Keys.Shift) == Keys.None) { Vec3 cursorPos; if (Editor.RayCastTerrainFromMouse(out cursorPos)) { this.m_cursorPos = cursorPos; this.OnBeginPaint(); } } else { this.m_painting = ToolPaint.PaintingMode.Shortcut; } if (this.m_painting != ToolPaint.PaintingMode.None) { Editor.Viewport.CaptureMouse = true; Editor.Viewport.CameraEnabled = false; } break; case Editor.MouseEvent.MouseUp: if (this.m_painting != ToolPaint.PaintingMode.None) { switch (this.m_painting) { case ToolPaint.PaintingMode.Plus: case ToolPaint.PaintingMode.Minus: this.OnEndPaint(); break; } this.m_cursorPos.Z = TerrainManager.GetHeightAtWithWater(this.m_cursorPos.XY); Vec2 captureMousePos; if (Editor.GetScreenPointFromWorldPos(this.m_cursorPos, out captureMousePos, true)) { Editor.Viewport.CaptureMousePos = captureMousePos; } Editor.Viewport.CaptureMouse = false; Editor.Viewport.CameraEnabled = true; this.m_painting = ToolPaint.PaintingMode.None; } break; case Editor.MouseEvent.MouseMove: switch (this.m_painting) { case ToolPaint.PaintingMode.None: case ToolPaint.PaintingMode.Plus: case ToolPaint.PaintingMode.Minus: this.m_cursorValid = Editor.RayCastTerrainFromMouse(out this.m_cursorPos); break; } break; case Editor.MouseEvent.MouseMoveDelta: switch (this.m_painting) { case ToolPaint.PaintingMode.Plus: case ToolPaint.PaintingMode.Minus: if (!this.m_grabMode.Value) { Editor.ApplyScreenDeltaToWorldPos(new Vec2((float)mouseEventArgs.X / (float)Editor.Viewport.Width, (float)mouseEventArgs.Y / (float)Editor.Viewport.Height), ref this.m_cursorPos); this.m_cursorPos.Z = TerrainManager.GetHeightAtWithWater(this.m_cursorPos.XY); } else { this.OnPaintGrab((float)mouseEventArgs.X, (float)mouseEventArgs.Y); } break; case ToolPaint.PaintingMode.Shortcut: { float delta; if (Math.Abs(mouseEventArgs.X) > Math.Abs(mouseEventArgs.Y)) { delta = (float)mouseEventArgs.X; } else { delta = (float)(-(float)mouseEventArgs.Y); } this.OnShortcutDelta(delta); break; } } break; } return false; }
public override bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { if (mouseEvent == Editor.MouseEvent.MouseUp) { Vec2 arg_11_0 = Editor.Viewport.NormalizedMousePos; bool flag = (Control.ModifierKeys & Keys.Control) != Keys.None; bool flag2 = (Control.ModifierKeys & Keys.Alt) != Keys.None; bool flag3 = (Control.ModifierKeys & Keys.Shift) != Keys.None; EditorObjectSelection editorObjectSelection = EditorObjectSelection.Create(); if (flag || flag3 || flag2) { this.m_context.m_selection.Clone(editorObjectSelection, false); } EditorObject gizmoObject = EditorObject.Null; RectangleF dragRectangle = this.DragRectangle; if (this.IsDragRectangle(dragRectangle)) { EditorObjectSelection selection; if (flag || flag2) { selection = EditorObjectSelection.Create(); } else { selection = editorObjectSelection; } ObjectManager.GetObjectsFromScreenRect(selection, this.DragRectangle); if (flag) { editorObjectSelection.ToggleSelection(selection); selection.Dispose(); } else { if (flag2) { editorObjectSelection.RemoveSelection(selection); selection.Dispose(); } } } else { Vec3 vec; EditorObject objectFromScreenPoint = ObjectManager.GetObjectFromScreenPoint(Editor.Viewport.NormalizedMousePos, out vec); if (objectFromScreenPoint.IsValid) { this.m_context.SelectObject(editorObjectSelection, objectFromScreenPoint); gizmoObject = objectFromScreenPoint; } } this.m_context.SetSelection(editorObjectSelection, gizmoObject); base.ReleaseInput(); } return false; }
public override bool OnKeyEvent(Editor.KeyEvent keyEvent, KeyEventArgs keyEventArgs) { switch (keyEvent) { case Editor.KeyEvent.KeyDown: { Keys keyCode = keyEventArgs.KeyCode; if (keyCode != Keys.ControlKey) { switch (keyCode) { case Keys.Left: case Keys.Up: case Keys.Right: case Keys.Down: this.m_keyStart = keyEventArgs.KeyCode; if (!this.m_keyMoving) { this.m_keyMoving = true; UndoManager.RecordUndo(); } break; } } else { this.m_context.SetGizmoRotationMode(true); } break; } case Editor.KeyEvent.KeyChar: if (this.m_keyMoving && keyEventArgs.KeyCode == this.m_keyStart && this.m_context.m_gizmo.IsValid) { Vec3 vec = default(Vec3); Vec3 vec2 = default(Vec3); switch (this.m_keyStart) { case Keys.Left: if (!keyEventArgs.Control) { vec.X = -1f; } else { vec2.Z = -1f; } break; case Keys.Up: if (!keyEventArgs.Control) { vec.Y = 1f; } else { vec.Z = 1f; } break; case Keys.Right: if (!keyEventArgs.Control) { vec.X = 1f; } else { vec2.Z = 1f; } break; case Keys.Down: if (!keyEventArgs.Control) { vec.Y = -1f; } else { vec.Z = -1f; } break; } Vec3 vec3 = default(Vec3); CoordinateSystem axis = Camera.Axis; CoordinateSystem axis2 = this.m_context.m_gizmo.Axis; float value = Vec3.Dot(axis2.axisX, axis.axisX); float value2 = Vec3.Dot(axis2.axisY, axis.axisX); if (Math.Abs(value) > Math.Abs(value2)) { vec3 = axis2.axisX * vec.X * (float)Math.Sign(value) + axis2.axisY * vec.Y * (float)Math.Sign(Vec3.Dot(axis2.axisY, axis.axisZ)); } else { vec3 = axis2.axisY * vec.X * (float)Math.Sign(value2) + axis2.axisX * vec.Y * (float)Math.Sign(Vec3.Dot(axis2.axisX, axis.axisZ)); } vec3 += axis2.axisZ * vec.Z * (float)Math.Sign(Vec3.Dot(axis2.axisZ, axis.axisZ)); if (keyEventArgs.Shift) { vec3 *= 0.0025f; vec2 *= MathUtils.Deg2Rad(0.25f); } else { vec3 *= 0.01f; vec2 *= MathUtils.Deg2Rad(1f); } this.m_context.m_selection.Center = this.m_context.m_gizmo.Position; this.m_context.m_selection.MoveTo(this.m_context.m_gizmo.Position + vec3, EditorObjectSelection.MoveMode.MoveNormal); this.m_context.m_selection.Rotate(vec2, axis2.ToAngles(), this.m_context.m_gizmo.Position, false); } break; case Editor.KeyEvent.KeyUp: if (this.m_keyMoving && keyEventArgs.KeyCode == this.m_keyStart) { UndoManager.CommitUndo(); this.m_keyMoving = false; } if (keyEventArgs.KeyCode == Keys.ControlKey) { this.m_context.SetGizmoRotationMode(false); } break; } return false; }
public override bool OnKeyEvent(Editor.KeyEvent keyEvent, KeyEventArgs keyEventArgs) { if (keyEvent == Editor.KeyEvent.KeyUp && keyEventArgs.KeyCode == Keys.Escape && this.m_context.m_selection.Count > 0) { this.ClearObjectParam(); return true; } return false; }
public override bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { if (this.m_actionAlignToObject.Checked) { return this.OnAlignToObjectMouseEvent(mouseEvent, mouseEventArgs); } if (mouseEvent == Editor.MouseEvent.MouseDown) { if (this.m_context.m_gizmoActive) { UndoManager.RecordUndo(); if ((Control.ModifierKeys & Keys.Control) == Keys.None) { if ((Control.ModifierKeys & Keys.Shift) != Keys.None) { EditorObjectSelection editorObjectSelection = EditorObjectSelection.Create(); this.m_context.m_selection.Clone(editorObjectSelection, true); int num = this.m_context.m_selection.IndexOf(this.m_context.m_gizmoObject); this.m_context.SetSelection(editorObjectSelection, (num != -1) ? editorObjectSelection[num] : EditorObject.Null); } ToolObject.MoveAction moveAction = new ToolObject.MoveAction(this.m_context); if (this.m_paramSnap.Value) { if (this.m_paramSnapObjectSize.Value && this.m_context.m_gizmoObject.IsValid) { moveAction.SetSnap(this.m_context.m_gizmoObject); } else { moveAction.SetSnap(this.m_paramSnapSize.Value); } } moveAction.Start(this.m_context.m_gizmo.Position); } else { ToolObject.RotateAction rotateAction = new ToolObject.RotateAction(this.m_context); Vec3 rotationAxis = default(Vec3); switch (this.m_context.m_gizmo.Active) { case Axis.X: rotationAxis = this.m_context.m_gizmo.Axis.axisX; break; case Axis.Y: rotationAxis = this.m_context.m_gizmo.Axis.axisY; break; case Axis.Z: rotationAxis = this.m_context.m_gizmo.Axis.axisZ; break; } rotateAction.Start(this.m_context.m_gizmo.Position, rotationAxis); } } else { UndoManager.RecordUndo(); bool flag = true; Vec3 vec; EditorObject objectFromScreenPoint = ObjectManager.GetObjectFromScreenPoint(Editor.Viewport.NormalizedMousePos, out vec); if (objectFromScreenPoint.IsValid) { if (!this.m_context.m_selection.Contains(objectFromScreenPoint)) { EditorObjectSelection editorObjectSelection2 = EditorObjectSelection.Create(); if ((Control.ModifierKeys & Keys.Control) != Keys.None || (Control.ModifierKeys & Keys.Shift) != Keys.None) { this.m_context.m_selection.Clone(editorObjectSelection2, false); } this.m_context.SelectObject(editorObjectSelection2, objectFromScreenPoint); this.m_context.SetSelection(editorObjectSelection2, objectFromScreenPoint); } else { this.m_context.SetupGizmo(objectFromScreenPoint); } EditorObjectPivot editorObjectPivot; Vec3 position; if (this.m_paramGrabAnchor.Value && objectFromScreenPoint.GetClosestPivot(vec, out editorObjectPivot, (objectFromScreenPoint.Position - vec).Length * 1.1f)) { position = editorObjectPivot.position; } else { position = objectFromScreenPoint.Position; } ToolObject.MovePhysicsAction movePhysicsAction = new ToolObject.MovePhysicsAction(this.m_context); movePhysicsAction.Start(position); flag = false; } if (flag) { ToolObject.SelectAction selectAction = new ToolObject.SelectAction(this.m_context); selectAction.Start(); } } } return false; }
public bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { switch (mouseEvent) { case Editor.MouseEvent.MouseDown: if (mouseEventArgs.Button == MouseButtons.Left) { this.m_painting = true; UndoManager.RecordUndo(); this.OnMouseMove(mouseEventArgs); } break; case Editor.MouseEvent.MouseUp: if (this.m_painting) { this.m_painting = false; UndoManager.CommitUndo(); } break; case Editor.MouseEvent.MouseMove: this.OnMouseMove(mouseEventArgs); break; } return false; }
private bool OnAlignToObjectMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { switch (mouseEvent) { case Editor.MouseEvent.MouseUp: break; case Editor.MouseEvent.MouseMove: { this.m_context.m_selection.LoadState(); Vec3 vec; Vec3 vec2; Editor.GetWorldRayFromScreenPoint(Editor.Viewport.NormalizedMousePos, out vec, out vec2); Vec3 vec3; EditorObject objectFromScreenPoint = ObjectManager.GetObjectFromScreenPoint(Editor.Viewport.NormalizedMousePos, out vec3, false, this.m_context.m_selection); if (!objectFromScreenPoint.IsValid) { return false; } using (IEnumerator<EditorObject> enumerator = this.m_context.m_selection.GetObjects().GetEnumerator()) { while (enumerator.MoveNext()) { EditorObject current = enumerator.Current; current.Position = objectFromScreenPoint.Position; current.Angles = objectFromScreenPoint.Angles; } return false; } break; } default: return false; } if (this.m_context.m_selection.Count != 0) { Vec3 position = this.m_context.m_selection[0].Position; Vec3 angles = this.m_context.m_selection[0].Angles; this.m_context.m_selection.LoadState(); UndoManager.RecordUndo(); foreach (EditorObject current2 in this.m_context.m_selection.GetObjects()) { current2.Position = position; current2.Angles = angles; } UndoManager.CommitUndo(); this.m_context.m_selection.SaveState(); this.m_actionAlignToObject.Checked = false; } return false; }
public bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs) { return false; }
public override bool OnKeyEvent(Editor.KeyEvent keyEvent, KeyEventArgs keyEventArgs) { switch (keyEvent) { case Editor.KeyEvent.KeyDown: switch (keyEventArgs.KeyCode) { case Keys.Left: case Keys.Up: case Keys.Right: case Keys.Down: this.m_keyStart = keyEventArgs.KeyCode; if (!this.m_keyMoving) { this.m_keyMoving = true; UndoManager.RecordUndo(); } break; } break; case Editor.KeyEvent.KeyChar: if (this.m_keyMoving && keyEventArgs.KeyCode == this.m_keyStart && this.m_context.m_gizmo.IsValid) { Vec3 vec = default(Vec3); switch (this.m_keyStart) { case Keys.Left: if (!keyEventArgs.Control) { vec.Z = -1f; } else { vec.Y = -1f; } break; case Keys.Up: if (!keyEventArgs.Control) { vec.Z = -1f; } else { vec.X = -1f; } break; case Keys.Right: if (!keyEventArgs.Control) { vec.Z = 1f; } else { vec.Y = 1f; } break; case Keys.Down: if (!keyEventArgs.Control) { vec.Z = 1f; } else { vec.X = 1f; } break; } CoordinateSystem arg_159_0 = Camera.Axis; CoordinateSystem axis = this.m_context.m_gizmo.Axis; if (keyEventArgs.Shift) { vec *= MathUtils.Deg2Rad(0.25f); } else { vec *= MathUtils.Deg2Rad(1f); } this.m_context.m_selection.Rotate(vec, axis.ToAngles(), this.m_context.m_gizmo.Position, false); } break; case Editor.KeyEvent.KeyUp: if (this.m_keyMoving && keyEventArgs.KeyCode == this.m_keyStart) { UndoManager.CommitUndo(); this.m_keyMoving = false; } break; } return false; }