示例#1
0
 public void ModeSwitched(object sender, EditorMode e)
 {
     if (e == EditorMode.EditObject)
         window.KeyDown += KeyPressed;
     else
         window.KeyDown -= KeyPressed;
 }
示例#2
0
        public EditorState()
        {
            _tool = EditorTool.Spiro;
            _mode = EditorMode.Create;

            _displayKnots = true;
            _displayGuides = true;

            _snapX = 15.0;
            _snapY = 15.0;
            _enableSnap = true;

            _shape = null;
            _hitTreshold = 7;
            _hitTresholdSquared = 49;
            _hitSetShapes = new HashSet<SpiroShape>();
            _hitSetPoints = new HashSet<int>();
            _hitListShapes = new ObservableCollection<SpiroShape>();
            _hitListPoints = new ObservableCollection<int>();
            _isStroked = true;
            _isFilled = false;
            _isClosed = true;
            _isTagged = false;
            _pointType = SpiroPointType.G4;

            _isCaptured = false;
            _snapTreshold = 10.0;
            _snapMode = GuideSnapMode.Point | GuideSnapMode.Middle | GuideSnapMode.Intersection | GuideSnapMode.Horizontal | GuideSnapMode.Vertical;
            _snapPointRadius = 3.5;
            _snapPoint = default(GuidePoint);
            _haveSnapPoint = false;
        }
 public ModeChangeAction(ISupportsUndo executor, int index, EditorMode[] oldModes, EditorMode[] newModes)
     : base(executor)
 {
     Index = index;
     OldModes = oldModes;
     NewModes = newModes;
 }
示例#4
0
 public void setMode(EditorMode mode)
 {
     this.mode = mode;
     if (this.mode == EditorMode.create)
         groupBoxEventNavigator.Visible = false;
     else
         groupBoxEventNavigator.Visible = true;
 }
        public static void Configure(this CKEditor.NET.CKEditorControl editor, EditorMode mode = EditorMode.Custom)
        {
            switch (mode)
            {
                case EditorMode.Custom:
                    editor.config.toolbar = new object[]
			        {
				        new object[] { "Source", "Preview", "Templates", "-" },
				        new object[] { "Paste", "PasteText", "PasteFromWord", "-", "SpellChecker", "Scayt" },
				        new object[] { "Undo", "Redo", "-", "Find", "Replace", "-", "SelectAll", "RemoveFormat" },
				        new object[] { "Bold", "Italic", "Underline", "Strike", "-", "Subscript", "Superscript" },
				        new object[] { "Styles", "Format", "Font", "FontSize" },
				        new object[] { "TextColor", "BGColor" },
				        new object[] { "NumberedList", "BulletedList", "-", "Outdent", "Indent", "Blockquote", "CreateDiv" },
				        new object[] { "JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyBlock" },
				        new object[] { "BidiLtr", "BidiRtl" },
				        new object[] { "Link", "Unlink", "Anchor" },
				        new object[] { "Image", "Table" },
			        };
                    break;
                case EditorMode.Full:
                    editor.config.toolbar = new object[]
			        {
				        new object[] { "Source", "-", "Preview", "-", "Templates" },
				        //new object[] { "Source", "-", "Save", "NewPage", "Preview", "-", "Templates" },
				        new object[] { "Cut", "Copy", "Paste", "PasteText", "PasteFromWord", "-", "Print", "SpellChecker", "Scayt" },
				        new object[] { "Undo", "Redo", "-", "Find", "Replace", "-", "SelectAll", "RemoveFormat" },
				        //new object[] { "Form", "Checkbox", "Radio", "TextField", "Textarea", "Select", "Button", "ImageButton", "HiddenField" },
				        "/",
				        new object[] { "Bold", "Italic", "Underline", "Strike", "-", "Subscript", "Superscript" },
				        new object[] { "NumberedList", "BulletedList", "-", "Outdent", "Indent", "Blockquote", "CreateDiv" },
				        new object[] { "JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyBlock" },
				        new object[] { "BidiLtr", "BidiRtl" },
				        new object[] { "Link", "Unlink", "Anchor" },
				        new object[] { "Image", "Table", "HorizontalRule", "Smiley", "SpecialChar", "PageBreak" },
				        //new object[] { "Image", "Flash", "Table", "HorizontalRule", "Smiley", "SpecialChar", "PageBreak", "Iframe" },
				        "/",
				        new object[] { "Styles", "Format", "Font", "FontSize" },
				        new object[] { "TextColor", "BGColor" },
				        new object[] { "Maximize", "ShowBlocks" }
                        //new object[] { "Maximize", "ShowBlocks", "-", "About" }
			        };
                    break;
                case EditorMode.Short:
                    editor.config.toolbar = new object[]
			        {
				        new object[] { "Source" },
				        new object[] { "Bold", "Italic", "Underline", "Strike", "-", "Subscript", "Superscript" },
                        new object[] { "NumberedList", "BulletedList" },
				        new object[] { "Cut", "Copy", "Paste", "PasteText", "PasteFromWord"},
			        };
                    break;
                case EditorMode.Shortest:
                    editor.config.toolbar = "Basic";
                    break;
            }
        }
示例#6
0
 public TextAction(ISupportsUndo executor, int index, string text, int[] formats, EditorMode[] modes, CharacterDecorationInfo[] decorations)
     : base(executor)
 {
     Index = index;
     Text = text;
     Formats = formats;
     Modes = modes;
     Decorations = decorations;
 }
        public RouteEditorDialog(Route route, EditorMode mode = EditorMode.View)
        {
            InitializeComponent();
            this.Icon = new Icon("Graphics\\EliteDangerousIcon.ico");

            this.route = route;
            this.mode = mode;

            if (mode == EditorMode.View)
                SetUpViewer();
        }
        public ManifestEditorDialog(Manifest manifest, EditorMode mode = EditorMode.View)
        {
            InitializeComponent();
            this.Icon = new Icon("Graphics\\EliteDangerousIcon.ico");

            this.manifest = manifest;
            this.mode = mode;

            if (mode == EditorMode.View)
                SetUpViewer();
        }
 public TextRemoveAction(ISupportsUndo executor, int index, string text, int selectionStartIndex,
                         int selectionCout, int parentSelectionStartIndex, int[] formats, EditorMode[] modes, 
                         CharacterDecorationInfo[] decorations)
     : base(executor)
 {
     Index = index;
     Text = text;
     Formats = formats;
     Modes = modes;
     Decorations = decorations;
     SelectionStartIndex = selectionStartIndex;
     SelectionCount = selectionCout;
     ParentSelectionStartIndex = parentSelectionStartIndex;
 }
示例#10
0
 public void SetFormattedText(string text, int[] formats, EditorMode[] modes)
 {
     textData.Clear();
     this.formats.Clear();
     this.modes.Clear();
     textData.Append(text);
     this.formats.AddRange(formats);
     this.modes.AddRange(modes);
     SetCaretIndex(text.Length);
     FormatText();
 }
示例#11
0
 public override void ConsumeFormattedText(string text, int[] formats, EditorMode[] modes, CharacterDecorationInfo[] decorations, bool addUndo)
 {
     //this.decorations.AddRange(decorations);
     textData.Insert(caretIndex, text);
     this.formats.InsertRange(caretIndex, formats);
     this.modes.InsertRange(caretIndex, modes);
     if (decorations != null)
     {
         foreach (var d in decorations)
         {
             d.Index = d.Index + caretIndex;
         }
         this.decorations.AddRange(decorations);
     }
     if (addUndo)
     {
         UndoManager.AddUndoAction(new TextAction(this, caretIndex, text, formats, modes, decorations ?? new CharacterDecorationInfo[0]) { UndoFlag = false });
     }
     SetCaretIndex(caretIndex + text.Length);
     FormatText();
 }
示例#12
0
        public override void ConsumeText(string text)
        {
            //text = "\U0001D400";
            //string someText = char.ConvertFromUtf32(0x1D7D9);
            var list = from d in decorations where d.Index >= caretIndex select d;
            foreach (var v in list)
            {
                v.Index = v.Index + text.Length;
            }
            FontStyle style = InputItalic ? FontStyles.Italic : FontStyles.Normal;
            textData.Insert(caretIndex, text);
            string name = FunctionNames.CheckForFunctionName(textData.ToString(0, caretIndex + text.Length));
            if (name != null && EditorMode == Editor.EditorMode.Math && caretIndex - (name.Length - text.Length) >= 0)
            {
                for (int i = caretIndex - (name.Length - text.Length); i < caretIndex; i++)
                {
                    formats[i] = textManager.GetFormatIdForNewStyle(formats[i], FontStyles.Normal);
                    modes[i] = Editor.EditorMode.Math;
                }
                style = FontStyles.Normal;
            }
            else if (text.Length == 1 && EditorMode == Editor.EditorMode.Math)
            {
                if (((int)text[0] >= 65 && (int)text[0] <= 90 || (int)text[0] >= 97 && (int)text[0] <= 122) || char.IsWhiteSpace(text[0]))
                {
                    style = FontStyles.Italic;
                }
                else
                {
                    style = FontStyles.Normal;
                }
            }

            int formatId = textManager.GetFormatId(FontSize, fontType, style, InputBold ? FontWeights.Bold : FontWeights.Normal,
                                                   Brushes.Black, InputUnderline);
            int[] tempFormats = new int[text.Length];
            EditorMode[] tempModes = new EditorMode[text.Length];
            for (int i = 0; i < text.Length; i++)
            {
                formats.Insert(i + caretIndex, formatId);
                modes.Insert(i + caretIndex, EditorMode);
                tempFormats[i] = formatId;
                tempModes[i] = EditorMode;
            }
            UndoManager.AddUndoAction(new TextAction(this, caretIndex, text, tempFormats, tempModes, new CharacterDecorationInfo[0]) { UndoFlag = false });
            SetCaretIndex(caretIndex + text.Length);
            FormatText();
        }
示例#13
0
 public override void Paste(XElement xElement)
 {
     if (xElement.Name.LocalName == GetType().Name)
     {
         //textData.Insert(caretIndex, xElement.Element("Text").Value);
         string text = xElement.Element("Text").Value;
         string[] formatStrings = xElement.Element("Formats").Value.Split(',');
         string[] modeStrings = xElement.Element("Modes").Value.Split(',');
         int[] formats = new int[text.Length];
         EditorMode[] modes = new EditorMode[text.Length];
         var decos = xElement.Elements().FirstOrDefault(x => x.Name == "Decorations");
         CharacterDecorationInfo[] decorations = null;
         if (decos != null)
         {
             var children = decos.Elements("d").ToList();
             decorations = new CharacterDecorationInfo[children.Count];
             for (int i = 0; i < children.Count; i++)
             {
                 string[] list = children[i].Value.Split(',');
                 decorations[i] = new CharacterDecorationInfo();
                 decorations[i].DecorationType = (CharacterDecorationType)Enum.Parse(typeof(CharacterDecorationType), list[0]);
                 decorations[i].Index = int.Parse(list[1]);
                 decorations[i].Position = (Position)Enum.Parse(typeof(Position), list[2]);
                 decorations[i].UnicodeString = list[3];
             }
         }
         try
         {
             for (int i = 0; i < text.Length; i++)
             {
                 formats[i] = int.Parse(formatStrings[i]);
                 modes[i] = (EditorMode)Enum.Parse(typeof(EditorMode), modeStrings[i]);
             }
         }
         catch
         {
             int formatId = textManager.GetFormatId(FontSize, fontType, FontStyles.Normal, FontWeights.Normal, Brushes.Black, false);
             for (int i = 0; i < text.Length; i++)
             {
                 formats[i] = formatId;
                 modes[i] = Editor.EditorMode.Math;
             }
         }
         ConsumeFormattedText(text, formats, modes, decorations, true);
     }
 }
示例#14
0
 private void toggleModeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     mode = mode != EditorMode.PlayMode ? EditorMode.PlayMode : EditorMode.EditMode;
     suspendUi();
     foreach (var table in layout.getTables())
         table.Mode = mode;
     resumeUi();
 }
示例#15
0
        public override void Update()
        {
            // Keyboard shortcut for centering the camera on origin.
            if (Input.KeyboardTapped(Keys.Home))
            {
                camera = -Engine.RESOLUTION / 2;
                zoom = 1;
            }

            // Allows the camera to be zoomed in and out.
            if (Input.MouseRightButtonDown)
            {
                if (Input.MouseScrollDown && zoom < 1.99f)
                    zoom += 0.1f;
                else if (Input.MouseScrollUp && zoom > 0.501f)
                    zoom -= 0.1f;
            }

            // Toggle edit mode.
            if (Input.KeyboardTapped(Keys.OemTilde))
                pauseGameplay = !pauseGameplay;

            if (Input.KeyboardTapped(Keys.F1))
                helpInfo = !helpInfo;

            if (Input.KeyboardTapped(Keys.F2))
                showCollision = !showCollision;

            if (!pauseGameplay)
            {
                // Update normal game.
                base.Update();
            }
            else
            {
                // Updates the textbox if one exists.
                if (textBoxStack.Count > 0)
                {
                    textBoxStack[textBoxStack.Count - 1].Update();
                    return;
                }

                // Update editor stuff.
                if (Input.KeyboardTapped(Keys.D0))
                    mode = EditorMode.GeneralMode;
                if (Input.KeyboardTapped(Keys.D1))
                    mode = EditorMode.FloorMode;
                if (Input.KeyboardTapped(Keys.D2))
                    mode = EditorMode.SquareMode;
                if (Input.KeyboardTapped(Keys.D3))
                    mode = EditorMode.DecalMode;
                if (Input.KeyboardTapped(Keys.D4))
                    mode = EditorMode.NodeMode;
                if (Input.KeyboardTapped(Keys.D5))
                    mode = EditorMode.CameraMode;

                // Snaps the mouse to the grid.
                SetSnapMouse();

                // Allows for camera moving
                if (Input.MouseRightButtonDown)
                    this.camera -= (Input.MousePosition - Input.MousePrevPosition) * zoom;

                switch (mode)
                {
                    case EditorMode.GeneralMode:
                        UpdateGeneralMode();
                        break;

                    case EditorMode.FloorMode:
                        UpdateFloorMode();
                        break;

                    case EditorMode.SquareMode:
                        UpdateSquareMode();
                        break;

                    case EditorMode.DecalMode:
                        UpdateDecalMode();
                        break;

                    case EditorMode.NodeMode:
                        UpdateNodeMode();
                        break;

                    case EditorMode.CameraMode:
                        UpdateCameraMode();
                        break;
                }
            }
        }
示例#16
0
 public EditorModeChangedMessage(EditorMode newMode)
 {
     this.EditorMode = newMode;
 }
示例#17
0
    private void setEditorMode(EditorMode newMode)
    {
        XRItem lookingAtItem = XRItemRaycaster.Shared.ItemFocus;

        if (currentEditMode == EditorMode.Camera && newMode != EditorMode.Camera)
        {
            // disable camera
            if (highlightedCamera != null)
            {
                highlightedCamera.DisableRender();
            }
        }
        else if (newMode == currentEditMode)
        {
            // double check if looking at floor, dup/delete button are deleted
            if (newMode == EditorMode.LookingAtObject && lookingAtItem != null && !lookingAtItem.gameObject.transform.name.Contains("Floor"))
            {
                duplicateButton.gameObject.SetActive(true);
                deleteButton.gameObject.SetActive(true);
            }

            return;
        }

        bool showExitButton = false;

        // selected object controls
        bool showScaleSlider    = false;
        bool showRotateSlider   = false;
        bool showRotateDropdown = false;
        bool showScaleDropdown  = false;

        // looking at object controls
        bool showSelectButton    = false;
        bool showDuplicateButton = false;
        bool showDeleteButton    = false;

        bool showTakeShotButton = false;
        bool showRawImage       = false;

        if (newMode == EditorMode.None)
        {
            showExitButton = true;
        }
        else if (newMode == EditorMode.LookingAtObject)
        {
            showSelectButton = true;
            showExitButton   = true;

            // prevent deleting and duplicating of floor
            if (lookingAtItem != null && !lookingAtItem.gameObject.transform.name.Contains("Floor"))
            {
                showDuplicateButton = true;
                showDeleteButton    = true;
            }
        }
        else if (newMode == EditorMode.SelectedObject)
        {
            showSelectButton   = true;
            showScaleSlider    = true;
            showRotateSlider   = true;
            showRotateDropdown = true;
            showScaleDropdown  = true;

            // set values back
            if (selectedItem != null)
            {
                DropdownValueChange();
                ScaleDropdownValueChange();
            }

            if (lookingAtItem != null && lookingAtItem.gameObject.transform.name.Contains("camera"))
            {
                highlightedCamera = lookingAtItem.gameObject.GetComponent <ComposarCamera>();
                highlightedCamera.EnableRender();
                cameraDisplay.texture = lookingAtItem.gameObject.GetComponent <ComposarCamera>().GetRenderTexture();
                showRawImage          = true;
                showTakeShotButton    = true;
            }
        }
        else if (newMode == EditorMode.Camera)
        {
            showSelectButton    = true;
            showDuplicateButton = true;
            showDeleteButton    = true;
            showRawImage        = true;
            showTakeShotButton  = true;

            if (lookingAtItem != null)
            {
                highlightedCamera = lookingAtItem.gameObject.GetComponent <ComposarCamera>();
                highlightedCamera.EnableRender();
                cameraDisplay.texture = highlightedCamera.GetRenderTexture();
            }
        }

        scaleSlider.gameObject.SetActive(showScaleSlider);
        rotateSlider.gameObject.SetActive(showRotateSlider);
        rotationDropdown.gameObject.SetActive(showRotateDropdown);
        scaleDropdown.gameObject.SetActive(showScaleDropdown);

        selectButton.gameObject.SetActive(showSelectButton);
        duplicateButton.gameObject.SetActive(showDuplicateButton);
        deleteButton.gameObject.SetActive(showDeleteButton);

        cameraDisplay.gameObject.SetActive(showRawImage);
        takeShotButton.gameObject.SetActive(showTakeShotButton);

        exitButton.gameObject.SetActive(showExitButton);

        currentEditMode = newMode;
    }
 public override void ConsumeFormattedText(string text, int[] formats, EditorMode[] modes, CharacterDecorationInfo[] decorations, bool addUndo)
 {
     ActiveChild.ConsumeFormattedText(text, formats, modes, decorations, addUndo);
     CalculateSize();
 }
示例#19
0
        private void SetMode(EditorMode mode)
        {
            if (mode == Mode) return;
            Mode = mode;
            Document.GetElementById("availablePartsList")?.SetProperty("display", "none");
            _hardpointSystem.IsEnabled = mode == EditorMode.Weapons;

            if(mode == EditorMode.Simulator)
            {
                CurrentShip.Tag = "PlayerShip";
            }
            else
            {
                CurrentShip.Tag = null;
                CurrentShip.SetRigidBodyTransform(Vector2.Zero, 0);
                var body = CurrentShip.GetComponent<RigidBodyComponent>().Body;
                body.AngularVelocity = 0;
                body.LinearVelocity = Vector2.Zero;
                foreach (var turret in CurrentShip.GetComponent<ShipComponent>().Weapons.Select(w=>w.GetComponent<WeaponComponent>().Turret.GetComponent<TurretComponent>()))
                {
                    turret.Rotation = 0;
                    turret.DesiredRotation = 0;
                }

            }
        }
        void InkCanvas_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Point curCursorPosition = e.GetPosition(_currentInkCanvas);

                if (e.RightButton == MouseButtonState.Pressed)
                {
                    //"Select" some near point on the canvas

                    UpdateStrokeAndSetToNull();
                    if (_curEditorMode == EditorMode.Polygon)
                    {
                        foreach (InkCanvas inkCanvas in _canvasList.Children)
                        {
                            foreach (Stroke stroke in inkCanvas.Strokes)
                            {
                                for (int pointIndex = 0; pointIndex < stroke.StylusPoints.Count; pointIndex++)
                                {
                                    StylusPoint stylusPoint = stroke.StylusPoints[pointIndex];
                                    double distanceOf2Points = ((Vector)(FromStylusPointToPoint(stylusPoint) - curCursorPosition)).Length;
                                    if (distanceOf2Points < _maxEndPointDistance * 2)
                                    {
                                        SelectPoint(pointIndex);
                                        _Stroke = stroke;
                                        _curEditorMode = EditorMode.MovingPoint;
                                    }
                                }
                            }
                        }
                    }
                }
                if (e.LeftButton == MouseButtonState.Pressed)
                {
                    if (_curEditorMode == EditorMode.Polygon)
                    {
                        curCursorPosition = GetCorrectCursorPosition(curCursorPosition);
                        AddNewPointToStroke(curCursorPosition);
                    }
                    else if (_curEditorMode == EditorMode.MovingPoint)
                    {
                        _curEditorMode = EditorMode.Polygon;
                        curCursorPosition = e.GetPosition(_currentInkCanvas);
                        if (_Stroke != null)
                        {
                            //move selected point to the new location
                            _Stroke.StylusPoints[_curPointIndex] = new StylusPoint(curCursorPosition.X, curCursorPosition.Y);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorMessageBox.Show(ex);
            }
        }
 public void SetMode(InkCanvasEditingMode mode, EditorMode customMode)
 {
     UpdateStrokeAndSetToNull();
     _currentInkCanvas.EditingMode = mode;
     _curEditorMode = customMode;
 }
示例#22
0
 public virtual void ConsumeFormattedText(string text, int[] formats, EditorMode[] modes, CharacterDecorationInfo[] decorations, bool addUndo)
 {
 }
示例#23
0
 public void ModeSwitched(object sender, EditorMode e)
 {
     if (e == EditorMode.EditObject)
     {
         window.KeyDown -= KeyPressed;
         window.MouseDown -= MouseButtonPressed;
         window.MouseUp -= MouseButtonReleased;
         window.MouseMove -= MouseMoved;
     }
     else
     {
         window.KeyDown += KeyPressed;
         window.MouseDown += MouseButtonPressed;
         window.MouseUp += MouseButtonReleased;
         window.MouseMove += MouseMoved;
     }
 }
 public EditorModeData(EditorMode editorMode)
 {
     EditorMode = editorMode;
     ImageSource = GetImageSource();
 }
示例#25
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            KeyboardState cks = Keyboard.GetState();
            MouseState cms = Mouse.GetState();
            Vector2 mousePos = new Vector2(cms.X, cms.Y);
            Vector2 mousedelta = mousePos - new Vector2(lms.X, lms.Y);
            int wheelDelta = cms.ScrollWheelValue - lms.ScrollWheelValue;

            //Mode select
            if (cks.IsKeyDown(Keys.F1) && !lks.IsKeyDown(Keys.F1))
            {
                Mode = EditorMode.Construction;
            }
            if (cks.IsKeyDown(Keys.F2) && !lks.IsKeyDown(Keys.F2))
            {
                Mode = EditorMode.Painting;
                currentTrackPos = 0;
                paintPos = 0;
            }
            if (cks.IsKeyDown(Keys.F3) && !lks.IsKeyDown(Keys.F3))
            {
                Mode = EditorMode.Testing;
                ResetCars();
                Camera.Position = Cars[7].CameraPosition;
                //car = new car(0, Track);
            }
            if (cks.IsKeyDown(Keys.F5) && !lks.IsKeyDown(Keys.F5))
            {
                Save();
            }

            if (cks.IsKeyDown(Keys.F12) && !lks.IsKeyDown(Keys.F12))
            {
                Load();
            }

            if (Mode == EditorMode.Construction)// || Mode == EditorMode.Testing)
            {
                Camera.AttachedToCar = false;

                if (cks.IsKeyDown(Keys.PageUp) && !lks.IsKeyDown(Keys.PageUp))
                {
                    selectedPoint++;
                    if (selectedPoint == ControlPoints.Count) selectedPoint = 0;
                }
                if (cks.IsKeyDown(Keys.PageDown) && !lks.IsKeyDown(Keys.PageDown))
                {
                    selectedPoint--;
                    if (selectedPoint == -1) selectedPoint = ControlPoints.Count - 1;
                }
                if (cks.IsKeyDown(Keys.Space) && !lks.IsKeyDown(Keys.Space))
                {
                    int pos = selectedPoint;
                    int nextpos = selectedPoint + 1;
                    if (pos >= ControlPoints.Count) pos = pos - (ControlPoints.Count);
                    if (nextpos >= ControlPoints.Count) nextpos = nextpos - ControlPoints.Count;
                    Vector3 delta = (ControlPoints[nextpos] - ControlPoints[pos]);
                    delta.X = delta.X / 2;
                    delta.Z = delta.Z / 2;
                    ControlPoints.Insert(selectedPoint + 1, ControlPoints[pos] + delta);
                    selectedPoint++;
                    Track.Rebuild(ControlPoints);
                }

                if (cks.IsKeyDown(Keys.Back) && !lks.IsKeyDown(Keys.Back))
                {
                    if(selectedPoint!=0)
                    {ControlPoints.RemoveAt(selectedPoint);
                    selectedPoint--;
                        }
                    Track.Rebuild(ControlPoints);
                }

                Vector3 moveVector = new Vector3(0, 0, 0);
                if (cks.IsKeyDown(Keys.Up) || cks.IsKeyDown(Keys.W))
                    moveVector += new Vector3(0, 0, -1);
                if (cks.IsKeyDown(Keys.Down) || cks.IsKeyDown(Keys.S))
                    moveVector += new Vector3(0, 0, 1);
                if (cks.IsKeyDown(Keys.Right) || cks.IsKeyDown(Keys.D))
                    moveVector += new Vector3(1, 0, 0);
                if (cks.IsKeyDown(Keys.Left) || cks.IsKeyDown(Keys.A))
                    moveVector += new Vector3(-1, 0, 0);
                Camera.AddToPosition(moveVector);

                if (cms.RightButton == ButtonState.Pressed)
                {
                    Vector3 pos = ControlPoints[selectedPoint];
                    pos.X += mousedelta.X * 0.05f;
                    pos.Z += mousedelta.Y * 0.05f;
                    ControlPoints[selectedPoint] = pos;

                    if (wheelDelta != 0)
                    {
                        if (wheelDelta > 0)
                            pos.Y += 1;
                        else
                            pos.Y -= 1;
                        ControlPoints[selectedPoint] = pos;
                    }
                    Track.Rebuild(ControlPoints);
                }
                else
                {
                    if (wheelDelta != 0)
                    {
                        if (wheelDelta > 0)
                        {
                            selectedPoint++;
                            if (selectedPoint == ControlPoints.Count) selectedPoint = 0;
                        }
                        else
                        {
                            selectedPoint--;
                            if (selectedPoint == -1) selectedPoint = ControlPoints.Count - 1;
                        }
                    }
                }

                if (cms.LeftButton == ButtonState.Pressed)
                {
                    Camera.Rotate(mousedelta.X, mousedelta.Y);
                }
            }

            if (Mode == EditorMode.Painting)
            {
                Camera.AttachedToCar = false;

                if (cks.IsKeyDown(Keys.Up) || cks.IsKeyDown(Keys.W))
                {
                    currentTrackPos++;
                    paintPos = currentTrackPos;
                }
                if (cks.IsKeyDown(Keys.Down) || cks.IsKeyDown(Keys.S))
                {
                    currentTrackPos--;
                    paintPos = currentTrackPos;
                }
                if (cks.IsKeyDown(Keys.Insert) && !lks.IsKeyDown(Keys.Insert))
                {
                    LeftBrush++;
                    if((int)LeftBrush > Enum.GetValues(typeof(SceneryBrush)).Length-1) LeftBrush = 0;
                }
                if (cks.IsKeyDown(Keys.Delete) && !lks.IsKeyDown(Keys.Delete))
                {
                    LeftBrush--;
                    if ((int)LeftBrush < 0) LeftBrush = (SceneryBrush)Enum.GetValues(typeof(SceneryBrush)).Length - 1;
                }
                if (cks.IsKeyDown(Keys.Home) && !lks.IsKeyDown(Keys.Home))
                {
                    RoadBrush++;
                    if ((int)RoadBrush > Enum.GetValues(typeof(RoadBrush)).Length - 1) RoadBrush = 0;
                }
                if (cks.IsKeyDown(Keys.End) && !lks.IsKeyDown(Keys.End))
                {
                    RoadBrush--;
                    if ((int)RoadBrush < 0) RoadBrush = (RoadBrush)Enum.GetValues(typeof(RoadBrush)).Length - 1;
                }
                if (cks.IsKeyDown(Keys.PageUp) && !lks.IsKeyDown(Keys.PageUp))
                {
                    RightBrush++;
                    if ((int)RightBrush > Enum.GetValues(typeof(SceneryBrush)).Length - 1) RightBrush = 0;
                }
                if (cks.IsKeyDown(Keys.PageDown) && !lks.IsKeyDown(Keys.PageDown))
                {
                    RightBrush--;
                    if ((int)RightBrush < 0) RightBrush = (SceneryBrush)Enum.GetValues(typeof(SceneryBrush)).Length - 1;
                }
                if (cks.IsKeyDown(Keys.NumPad7) && !lks.IsKeyDown(Keys.NumPad7))
                {
                    AboveBrush++;
                    if ((int)AboveBrush > Enum.GetValues(typeof(AboveBrush)).Length - 1) AboveBrush = 0;
                }
                if (cks.IsKeyDown(Keys.NumPad4) && !lks.IsKeyDown(Keys.NumPad4))
                {
                    AboveBrush--;
                    if ((int)AboveBrush < 0) AboveBrush = (AboveBrush)Enum.GetValues(typeof(AboveBrush)).Length - 1;
                }

                if (cks.IsKeyDown(Keys.R) && !lks.IsKeyDown(Keys.R))
                {
                    Track.Horizon++;
                    if ((int)Track.Horizon > Enum.GetValues(typeof(Horizon)).Length - 1) Track.Horizon = 0;
                    Track.LoadHorizon(Content, parallaxManager);
                }
                if (cks.IsKeyDown(Keys.F) && !lks.IsKeyDown(Keys.F))
                {
                    Track.Horizon--;
                    if ((int)Track.Horizon < 0) Track.Horizon = (Horizon)Enum.GetValues(typeof(Horizon)).Length - 1;
                    Track.LoadHorizon(Content, parallaxManager);
                }

                if (cks.IsKeyDown(Keys.T))
                {
                    Track.GroundColor.R++;
                }
                if (cks.IsKeyDown(Keys.G))
                {
                    Track.GroundColor.R--;
                }
                if (cks.IsKeyDown(Keys.Y))
                {
                    Track.GroundColor.G++;
                }
                if (cks.IsKeyDown(Keys.H))
                {
                    Track.GroundColor.G--;
                }
                if (cks.IsKeyDown(Keys.U))
                {
                    Track.GroundColor.B++;
                }
                if (cks.IsKeyDown(Keys.J))
                {
                    Track.GroundColor.B--;
                }

                if (currentTrackPos == Track.Length) currentTrackPos = 0;
                if (currentTrackPos == -1) currentTrackPos = Track.Length - 1;

                if (cks.IsKeyDown(Keys.Space))
                {
                    Track.TrackSegments[paintPos].Paint(paintPos, RoadBrush, AboveBrush, LeftBrush, RightBrush);
                    paintPos++;
                    if (paintPos > Track.TrackSegments.Count - 1) paintPos = 0;
                }

                if (cks.IsKeyDown(Keys.B) && !lks.IsKeyDown(Keys.B))
                {
                    Track.TrackSegments[paintPos].Paint(paintPos, RoadBrush, AboveBrush, LeftBrush, RightBrush);
                    paintPos++;
                    if (paintPos > Track.TrackSegments.Count - 1) paintPos = 0;
                }

                int nextpos = (currentTrackPos + 1);
                if (nextpos >= Track.TrackSegments.Count) nextpos = nextpos - Track.TrackSegments.Count;
                //Camera.viewMatrix = Matrix.CreateLookAt(Track.TrackSegments[currentTrackPos].Position + new Vector3(0, 0.5f, 0),
                //                                        Track.TrackSegments[nextpos].Position + new Vector3(0, 0.5f, 0),
                //                                        Vector3.Up);
                Camera.Position = Track.TrackSegments[currentTrackPos].Position + new Vector3(0, 0.5f, 0);
                Camera.LookAt(Track.TrackSegments[nextpos].Position + new Vector3(0, 0.5f, 0), 0f);

            }

            if (Mode == EditorMode.Testing)
            {
                if (!lockCameraToCar)
                {
                    Vector3 moveVector = new Vector3(0, 0, 0);
                    if (cks.IsKeyDown(Keys.Up) || cks.IsKeyDown(Keys.W))
                        moveVector += new Vector3(0, 0, -1);
                    if (cks.IsKeyDown(Keys.Down) || cks.IsKeyDown(Keys.S))
                        moveVector += new Vector3(0, 0, 1);
                    if (cks.IsKeyDown(Keys.Right) || cks.IsKeyDown(Keys.D))
                        moveVector += new Vector3(1, 0, 0);
                    if (cks.IsKeyDown(Keys.Left) || cks.IsKeyDown(Keys.A))
                        moveVector += new Vector3(-1, 0, 0);
                    Camera.AddToPosition(moveVector);

                    if (cms.LeftButton == ButtonState.Pressed)
                    {
                        Camera.Rotate(mousedelta.X, mousedelta.Y);
                    }
                }
                else
                {
                    Cars[7].ApplyThrottle(0f);
                    Cars[7].ApplyBrake(false);

                    if(cks.IsKeyDown(Keys.W) ||
                       cks.IsKeyDown(Keys.Up))
                    {
                        Cars[7].ApplyThrottle(1f);
                    }
                    else Cars[7].ApplyThrottle(0f);

                    if (cks.IsKeyDown(Keys.S) ||
                       cks.IsKeyDown(Keys.Down))
                    {
                        Cars[7].ApplyBrake(true);
                    }
                    else Cars[7].ApplyBrake(false);

                    if (cks.IsKeyDown(Keys.A) ||
                       cks.IsKeyDown(Keys.Left))
                    {
                        if (steeringAmount > 0f) steeringAmount -= 0.015f;
                        steeringAmount -= 0.01f;
                        steeringAmount = MathHelper.Clamp(steeringAmount, -0.5f, 0.5f);
                    }
                    else if (cks.IsKeyDown(Keys.D) ||
                            cks.IsKeyDown(Keys.Right))
                    {
                        if (steeringAmount < 0f) steeringAmount += 0.015f;
                        steeringAmount += 0.01f;
                        steeringAmount = MathHelper.Clamp(steeringAmount, -0.5f, 0.5f);
                    }
                    else steeringAmount = MathHelper.Lerp(steeringAmount, 0f, 0.15f);

                    Cars[7].Steer(steeringAmount);
                }

                if (cks.IsKeyDown(Keys.Space) && !lks.IsKeyDown(Keys.Space))
                {
                    lockCameraToCar = !lockCameraToCar;
                }
            }

            lks = cks;
            lms = cms;

            if (Mode == EditorMode.Testing)
            {
                foreach (Car c in Cars)
                {
                    c.Update(gameTime, Track, Cars);
                }

                if (lockCameraToCar)
                {
                    Camera.Position = Cars[7].CameraPosition;
                    Camera.LookAt(Cars[7].CameraLookat, (Cars[7].steeringAmount * 0.5f));
                    Camera.AttachedToCar = true;
                }
                else
                    Camera.AttachedToCar = false;
            }

            parallaxManager.Update(gameTime, new Vector2(((GraphicsDevice.Viewport.Width * 4) / MathHelper.TwoPi) * Helper.WrapAngle(Camera.Yaw), 0f));

            drawEffect.View = Camera.viewMatrix;
            drawAlphaEffect.View = Camera.viewMatrix;

            base.Update(gameTime);
        }
示例#26
0
    // i guess they never miss, huh?
    void Update()
    {
        EditorMode newEditorMode = EditorMode.None;

        // they already have an item, so they are moving an object
        if (selectedItem != null)
        {
            // Snap position to actualMovePosition

            if (snapGridToggle.isOn)
            {
                Debug.Log("test");
                float GridSnapSize = 0.25f; // meters

                Vector3 snappedPosition = actuallySelectedObject.transform.position;
                snappedPosition.x = (float)Math.Round(snappedPosition.x / GridSnapSize) * GridSnapSize;
                snappedPosition.y = (float)Math.Round(snappedPosition.y / GridSnapSize) * GridSnapSize;
                snappedPosition.z = (float)Math.Round(snappedPosition.z / GridSnapSize) * GridSnapSize;

                /* Experiments:
                 * float div = 5.0f;
                 * double k = 0.1;
                 * Debug.Log("actual transfor x " + Math.Abs(actuallySelectedObject.transform.position.x) % 2);
                 * Debug.Log("actual transfor y " + Math.Abs(actuallySelectedObject.transform.position.y) % 2);
                 * Debug.Log("actual transfor z " + Math.Abs(actuallySelectedObject.transform.position.z) % 2);
                 *
                 * Vector3 snappedPosition = new Vector3(
                 *  Math.Abs(actuallySelectedObject.transform.position.x) % 2 <= k ? actuallySelectedObject.transform.position.x : selectedItem.gameObject.transform.position.x,
                 *  Math.Abs(actuallySelectedObject.transform.position.y) % 2 <= k ? actuallySelectedObject.transform.position.y : selectedItem.gameObject.transform.position.y,
                 *  Math.Abs(actuallySelectedObject.transform.position.z) % 2 <= k ? actuallySelectedObject.transform.position.z : selectedItem.gameObject.transform.position.z);
                 *
                 * float absX = Math.Abs(actuallySelectedObject.transform.position.x - actuallySelectedObject.transform.position.x) % div;
                 * float absY = Math.Abs(actuallySelectedObject.transform.position.y - actuallySelectedObject.transform.position.y) % div;
                 * float absZ = Math.Abs(actuallySelectedObject.transform.position.z - actuallySelectedObject.transform.position.z) % div;
                 * print(absX);
                 * print(absY);
                 * print(absZ);
                 * snappedPosition.y = absY < k ? actuallySelectedObject.transform.position.y : selectedItem.gameObject.transform.position.y;
                 * snappedPosition.z = absZ < k ? actuallySelectedObject.transform.position.z : selectedItem.gameObject.transform.position.z;
                 */

                // LOCAL ONLY version - selectedItem.gameObject.transform.position = snappedPosition;
                TeleportalAr.Shared.MoveItem(selectedItem.Id, snappedPosition.x, snappedPosition.y, snappedPosition.z, selectedObjectEulerAngles.y, selectedObjectEulerAngles.x);
            }
            else
            {
                // TODO: rotation z does not work
                // TODO: grab mesh and set alpha
                selectedItem.gameObject.transform.eulerAngles = selectedObjectEulerAngles;
            }


            newEditorMode = EditorMode.SelectedObject;
        }
        else
        {
            XRItem lookingAtItem = XRItemRaycaster.Shared.ItemFocus;

            // if they are looking at an item and not holding one, determine if it is camera/object
            if (lookingAtItem != null)
            {
                GameObject lookingAtObject = lookingAtItem.gameObject;

                if (lookingAtObject.transform.name.Contains("camera"))
                {
                    newEditorMode = EditorMode.Camera;
                }
                else
                {
                    newEditorMode = EditorMode.LookingAtObject;
                }
            }
            else
            {
                // if they are not looking at an item, they are looking at none
                newEditorMode = EditorMode.None;
            }
        }

        setEditorMode(newEditorMode);
    }
示例#27
0
 public void ResetTextEquation(int caretIndex, int selectionStartIndex, int selectedItems, string text, int[] formats,
                               EditorMode[] modes, CharacterDecorationInfo[] cdiList)
 {
     textData.Clear();
     textData.Append(text);
     this.caretIndex = caretIndex;
     this.SelectionStartIndex = selectionStartIndex;
     this.SelectedItems = selectedItems;
     this.formats.Clear();
     this.formats.AddRange(formats);
     this.modes.Clear();
     this.modes.AddRange(modes);
     this.decorations.Clear();
     decorations.AddRange(cdiList);
     FormatText();
 }
示例#28
0
 private void PointerBtn_Click(object sender, RoutedEventArgs e)
 {
     mode = EditorMode.Pointer;
     PointerBtn.Tag = "Selected";
     ArrowBtn.Tag = "";
 }
示例#29
0
文件: Form1.cs 项目: wetal/SmartPad
 private void openEditForm(EditorMode mode)
 {
     if (formEditorEvent == null || formEditorEvent.IsDisposed)
     {
         formEditorEvent = new FormEventEditor(this);
     }
     formEditorEvent.Show();
     formEditorEvent.Focus();
     formEditorEvent.setMode(mode);
 }
示例#30
0
 void SetCaretIndex(int index)
 {
     caretIndex = index;
     if (formats.Count > 0)
     {
         int formatIndexToUse = index;
         if (index > 0)
         {
             formatIndexToUse--;
         }
         InputBold = textManager.IsBold(formats[formatIndexToUse]);
         InputItalic = textManager.IsItalic(formats[formatIndexToUse]);
         InputUnderline = textManager.IsUnderline(formats[formatIndexToUse]);
         EditorMode = modes[formatIndexToUse];
         FontType = textManager.GetFontType(formats[formatIndexToUse]);
     }
 }
示例#31
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Mode = EditorMode.Construction;

            lks = Keyboard.GetState();
            lms = Mouse.GetState();

            base.Initialize();
        }