Example #1
0
        /// <summary>
        /// Прихващане на координатите при натискането на бутон на мишката и проверка (в обратен ред) дали не е
        /// щракнато върху елемент. Ако е така то той се отбелязва като селектиран и започва процес на "влачене".
        /// Промяна на статуса и инвалидиране на контрола, в който визуализираме.
        /// Реализацията се диалогът с потребителя, при който се избира "най-горния" елемент от екрана.
        /// </summary>
        void ViewPortMouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (pickUpSpeedButton.Checked)
            {
                if (e.Button == MouseButtons.Left)
                {
                    var shp = dialogProcessor.ContainsPoint(e.Location);
                    if (shp != null)
                    {
                        if (dialogProcessor.Selection.Contains(shp))
                        {
                            dialogProcessor.Selection.Remove(shp);
                            shp.BorderColor = Color.Black;
                        }
                        else
                        {
                            dialogProcessor.Selection.Add(shp);
                            shp.BorderColor = Color.Red;
                        }

                        statusBar.Items[0].Text      = "Последно действие: Селекция на примитив";
                        dialogProcessor.IsDragging   = true;
                        dialogProcessor.LastLocation = e.Location;
                        viewPort.Invalidate();
                    }
                }
                else if (e.Button == MouseButtons.Right)
                {
                    Shape shape = dialogProcessor.ContainsPoint(e.Location);
                    copyShape = shape;
                    if (shape != null)
                    {
                        MouseMenu.Show(e.Location);
                    }
                    else
                    {
                        mouseLocation = e.Location;
                        PanelMouseMenu.Show(e.Location);
                    }
                }
            }
        }
Example #2
0
        }   // end of SetUpMenus();

        public void NoActorOnSelect(MouseMenu menu)
        {
            if (menu.CurString == Strings.Localize("mouseEdit.addObject"))
            {
                Vector2 position = new Vector2(menuCursorPosition.X, menuCursorPosition.Y);
                inGame.editObjectUpdateObj.ActivateNewItemSelector(position, true);
            }
            else if (menu.CurString == Strings.Localize("mouseEdit.worldTweak"))
            {
                inGame.CurrentUpdateMode = Boku.InGame.UpdateMode.EditWorldParameters;
                // Set return mode so we come back to ObjectEdit when done.
                inGame.mouseEditUpdateObj.ReturnMode = Boku.InGame.BaseEditUpdateObj.ToolMode.EditObject;
                inGame.touchEditUpdateObj.ReturnMode = Boku.InGame.BaseEditUpdateObj.ToolMode.EditObject;
            }
            else if (menu.CurString == pasteMenuString)
            {
                inGame.editObjectUpdateObj.PasteAction(null, menuCursorPosition);
            }
            else
            {
                Debug.Assert(false, "Should never get here.");
            }
        }   // end of NoActorOnSelect()
Example #3
0
        }   // end of NodeOnSelect()

        public void EdgeOnSelect(MouseMenu menu)
        {
            if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
            {
                if (menu.CurString == Strings.Localize("mouseEdit.directions"))
                {
                    if (touchOver.ActOnPath)
                    {
                        touchOver.Path.IncDir();
                    }
                    else
                    {
                        touchOver.edge.IncDir();
                    }
                }
                else if (menu.CurString == Strings.Localize("mouseEdit.split"))
                {
                    touchOver.SplitCurrentEdge();
                }
                else if (menu.CurString == Strings.Localize("mouseEdit.delete"))
                {
                    if (touchOver.ActOnPath)
                    {
                        touchOver.Path.Delete();
                    }
                    else
                    {
                        touchOver.edge.Delete();
                    }
                    touchOver.Clear();
                }
                else
                {
                    Debug.Assert(false, "Should never EVER get here.");
                }
            }
            else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
            {
                if (menu.CurString == Strings.Localize("mouseEdit.directions"))
                {
                    if (mouseOver.ActOnPath)
                    {
                        mouseOver.Path.IncDir();
                    }
                    else
                    {
                        mouseOver.edge.IncDir();
                    }
                }
                else if (menu.CurString == Strings.Localize("mouseEdit.split"))
                {
                    mouseOver.SplitCurrentEdge();
                }
                else if (menu.CurString == Strings.Localize("mouseEdit.delete"))
                {
                    if (mouseOver.ActOnPath)
                    {
                        mouseOver.Path.Delete();
                    }
                    else
                    {
                        mouseOver.edge.Delete();
                    }
                }
                else
                {
                    Debug.Assert(false, "Should never get here.");
                }
            }
        }   // end of EdgeOnSelect()
Example #4
0
        }   // end of GroundOnSelect()

        public void NodeOnSelect(MouseMenu menu)
        {
            if (menu.CurString == Strings.Localize("mouseEdit.addMore"))
            {
                //add more is not supported in this fashion when in touch mode - instead, just use add mode, select the starting point, and then start
                //adding
                if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                {
                    mouseOver.StartAdding(mouseOver.node);
                }
            }
            else if (menu.CurString == Strings.Localize("mouseEdit.height"))
            {
                slider.Label    = Strings.Localize("mouseEdit.heightValue");
                slider.MinValue = 0.0f;
                slider.MaxValue = 30.0f;
                slider.NumberOfDecimalPlaces = 2;
                slider.IncrementByAmount     = 0.01f;

                if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                {
                    slider.CurrentValue = touchOver.node.Height;
                }
                else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                {
                    slider.CurrentValue = mouseOver.node.Height;
                }
                sliderPrevValue = slider.CurrentValue;

                slider.Selected = true;

                sliderActive = true;
            }
            else if (menu.CurString == Strings.Localize("mouseEdit.rotate"))
            {
                slider.Label    = Strings.Localize("mouseEdit.rotationValue");
                slider.MinValue = -180.0f;
                slider.MaxValue = 180.0f;
                slider.NumberOfDecimalPlaces = 1;
                slider.IncrementByAmount     = 0.1f;

                slider.CurrentValue = 0.0f;
                sliderPrevValue     = slider.CurrentValue;

                slider.Selected = true;

                sliderActive = true;
            }
            else if (menu.CurString == Strings.Localize("mouseEdit.type"))
            {
                if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                {
                    touchOver.Path.Road.AdvanceGen(1);
                }
                else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                {
                    mouseOver.Path.Road.AdvanceGen(1);
                }
            }
            else if (menu.CurString == Strings.Localize("mouseEdit.delete"))
            {
                if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                {
                    if (touchOver.ActOnPath)
                    {
                        touchOver.Path.Delete();
                    }
                    else
                    {
                        touchOver.node.Delete();
                    }
                    //clear things out in touch mode
                    touchOver.Clear();
                }
                else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                {
                    if (mouseOver.ActOnPath)
                    {
                        mouseOver.Path.Delete();
                    }
                    else
                    {
                        mouseOver.node.Delete();
                    }
                }
            }
            else
            {
                Debug.Assert(false, "Should never get here.");
            }
        }   // end of NodeOnSelect()
Example #5
0
        }   // end of SetUpMenus();

        public void GroundOnSelect(MouseMenu menu)
        {
            Camera camera = Boku.InGame.inGame.shared.camera;

            // Calc position for new node adjusted for perspective.
            Vector3 terrainToCameraDir = menuPosition - camera.From;

            terrainToCameraDir.Normalize();
            float   nodeRadius = 1.0f;
            Vector3 position   = menuPosition + terrainToCameraDir * (nodeRadius / terrainToCameraDir.Z);

            if (menu.CurString == Strings.Localize("mouseEdit.addNodePlain"))
            {
                Road.GenIndex = 0;
                if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                {
                    touchOver.NewPath(position, focusColorIndex);
                }
                else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                {
                    mouseOver.NewPath(position, focusColorIndex);
                }
            }
            else if (menu.CurString == Strings.Localize("mouseEdit.addNodeRoad"))
            {
                Road.GenIndex = Road.LastRoadCreated;
                if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                {
                    touchOver.NewPath(position, focusColorIndex);
                }
                else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                {
                    mouseOver.NewPath(position, focusColorIndex);
                }
            }
            else if (menu.CurString == Strings.Localize("mouseEdit.addNodeWall"))
            {
                Road.GenIndex = Road.LastWallCreated;
                if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                {
                    touchOver.NewPath(position, focusColorIndex);
                }
                else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                {
                    mouseOver.NewPath(position, focusColorIndex);
                }
            }
            else if (menu.CurString == Strings.Localize("mouseEdit.addNodeFlora"))
            {
                Road.GenIndex = Road.LastVegCreated;
                if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                {
                    touchOver.NewPath(position, focusColorIndex);
                }
                else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                {
                    mouseOver.NewPath(position, focusColorIndex);
                }
            }
            else
            {
                Debug.Assert(false, "Should never get here.");
            }
        }   // end of GroundOnSelect()
Example #6
0
        }   // end of EdgeOnSelect()

        public void OnCancel(MouseMenu menu)
        {
        }   // end of OnCancel()
Example #7
0
        }   // end of NoActorOnSelect()

        public void ActorOnSelect(MouseMenu menu)
        {
            if (menu.CurString == Strings.Localize("mouseEdit.rename"))
            {
                if (menuActor != null)
                {
                    TextLineDialog.OnDialogDone callback = delegate(bool canceled, string newText)
                    {
                        if (!canceled && newText.Length > 0)
                        {
                            newText = TextHelper.FilterURLs(newText);
                            newText = TextHelper.FilterEmail(newText);

                            menuActor.DisplayName = newText;
                            Programming.NamedFilter.RegisterInCardSpace(menuActor);
                            Boku.InGame.IsLevelDirty = true;
                        }
                    };

                    TextLineEditor.ValidateText validateCallback = delegate(TextBlob textBlob)
                    {
                        // Deterimine if name is valid.
                        string name = textBlob.ScrubbedText;
                        name = name.Trim();
                        bool valid = !String.IsNullOrWhiteSpace(name);
                        return(valid);
                    };

                    inGame.shared.textLineDialog.Activate(callback, menuActor.DisplayName, validateCallback);
                }
            }
            else if (menu.CurString == Strings.Localize("mouseEdit.program"))
            {
                inGame.ShowEditor(menuActor);
            }
            else if (menu.CurString == Strings.Localize("mouseEdit.objectTweak"))
            {
                if (menuActor != null)
                {
                    inGame.shared.editObjectParameters.Actor = menuActor;
                    inGame.CurrentUpdateMode = Boku.InGame.UpdateMode.EditObjectParameters;
                    // Set return mode so we come back to ObjectEdit when done.
                    inGame.mouseEditUpdateObj.ReturnMode = Boku.InGame.BaseEditUpdateObj.ToolMode.EditObject;
                    inGame.touchEditUpdateObj.ReturnMode = Boku.InGame.BaseEditUpdateObj.ToolMode.EditObject;
                }
            }
            else if (menu.CurString == Strings.Localize("mouseEdit.cut"))
            {
                inGame.editObjectUpdateObj.CutAction(menuActor);
            }
            else if (menu.CurString == Strings.Localize("mouseEdit.copy"))
            {
                inGame.editObjectUpdateObj.CopyAction(menuActor);
            }
            else if (menu.CurString == Strings.Localize("mouseEdit.size"))
            {
                slider.Label    = Strings.Localize("mouseEdit.sizeValue");
                slider.MinValue = 0.2f;
                slider.MaxValue = 4.0f;
                slider.NumberOfDecimalPlaces = 1;
                slider.IncrementByAmount     = 0.1f;

                slider.CurrentValueImmediate = menuActor.ReScale;

                slider.Selected = true;

                slider.RefreshTexture();

                sliderActive = true;
            }
            else if (menu.CurString == Strings.Localize("mouseEdit.rotate"))
            {
                slider.Label    = Strings.Localize("mouseEdit.rotationValue");
                slider.MinValue = 0.0f;
                slider.MaxValue = 360.0f;
                slider.NumberOfDecimalPlaces = 0;
                slider.IncrementByAmount     = 1.0f;

                slider.CurrentValueImmediate = MathHelper.ToDegrees(menuActor.Movement.RotationZ);

                slider.Selected = true;

                slider.RefreshTexture();

                sliderActive = true;
            }
            else if (menu.CurString == Strings.Localize("mouseEdit.height"))
            {
                slider.Label    = Strings.Localize("mouseEdit.heightValue");
                slider.MinValue = menuActor.MinHeight;
                slider.MaxValue = 30.0f;
                slider.NumberOfDecimalPlaces = 2;
                slider.IncrementByAmount     = 0.01f;

                slider.CurrentValueImmediate = menuActor.HeightOffset + menuActor.DefaultEditHeight;

                slider.Selected = true;

                slider.RefreshTexture();

                sliderActive = true;
            }
            else
            {
                Debug.Assert(false, "Should never get here.");
            }
        }   // end of ActorOnSelect()
Example #8
0
        }   // end of ActorOnSelect()

        public void OnCancel(MouseMenu menu)
        {
            menuActor = null;
        }   // end of OnCancel()