Ejemplo n.º 1
0
        protected override void OnToolGUI(Event e)
        {
            if (UIView.HasModalInput() || UIView.HasInputFocus())
            {
                return;
            }

            lock (ActionQueue.instance)
            {
                if (ToolState == ToolStates.Default)
                {
                    if (OptionsKeymapping.undo.IsPressed(e))
                    {
                        m_nextAction = ToolAction.Undo;
                    }
                    else if (OptionsKeymapping.redo.IsPressed(e))
                    {
                        m_nextAction = ToolAction.Redo;
                    }
                }

                if (OptionsKeymapping.clone.IsPressed(e))
                {
                    if (ToolState == ToolStates.Cloning || ToolState == ToolStates.RightDraggingClone)
                    {
                        StopCloning();
                    }
                    else
                    {
                        StartCloning();
                    }
                }
                else if (OptionsKeymapping.bulldoze.IsPressed(e))
                {
                    StartBulldoze();
                }
                else if (OptionsKeymapping.reset.IsPressed(e))
                {
                    StartReset();
                }
                else if (OptionsKeymapping.viewGrid.IsPressed(e))
                {
                    if (gridVisible)
                    {
                        gridVisible = false;
                        UIToolOptionPanel.instance.grid.activeStateIndex = 0;
                    }
                    else
                    {
                        gridVisible = true;
                        UIToolOptionPanel.instance.grid.activeStateIndex = 1;
                    }
                }
                else if (OptionsKeymapping.viewUnderground.IsPressed(e))
                {
                    if (tunnelVisible)
                    {
                        tunnelVisible = false;
                        UIToolOptionPanel.instance.underground.activeStateIndex = 0;
                    }
                    else
                    {
                        tunnelVisible = true;
                        UIToolOptionPanel.instance.underground.activeStateIndex = 1;
                    }
                }
                else if (OptionsKeymapping.viewDebug.IsPressed(e))
                {
                    showDebugPanel.value = !showDebugPanel;
                    if (m_debugPanel != null)
                    {
                        m_debugPanel.Visible(showDebugPanel);
                    }
                }
                else if (OptionsKeymapping.activatePO.IsPressed(e))
                {
                    if (PO.Active == false)
                    {
                        PO.Active = true;
                        UIToolOptionPanel.instance.PO_button.activeStateIndex = 1;
                        PO.ToolEnabled();
                    }
                    else
                    {
                        PO.Active = false;
                        UIToolOptionPanel.instance.PO_button.activeStateIndex = 0;
                    }
                    UIFilters.POToggled();
                }
                else if (OptionsKeymapping.convertToPO.IsPressed(e))
                {
                    if (PO.Enabled && ToolState == ToolStates.Default)
                    {
                        if (PO.Active == false)
                        {
                            PO.Active = true;
                            UIToolOptionPanel.instance.PO_button.activeStateIndex = 1;
                            PO.ToolEnabled();
                            UIFilters.POToggled();
                        }

                        ConvertToPOAction convertAction = new ConvertToPOAction();
                        ActionQueue.instance.Push(convertAction);
                        ActionQueue.instance.Do();
                    }
                }
                else if (OptionsKeymapping.alignHeights.IsPressed(e))
                {
                    ProcessAligning(AlignModes.Height);
                }
                else if (OptionsKeymapping.alignSlope.IsPressed(e))
                {
                    ProcessAligning(AlignModes.Slope);
                }
                else if (OptionsKeymapping.alignMirror.IsPressed(e))
                {
                    ProcessAligning(AlignModes.Mirror);
                }
                else if (OptionsKeymapping.alignSlopeQuick.IsPressed(e))
                {
                    AlignMode = AlignModes.SlopeNode;

                    if (ToolState == ToolStates.Cloning || ToolState == ToolStates.RightDraggingClone)
                    {
                        StopCloning();
                    }

                    AlignSlopeAction asa = new AlignSlopeAction
                    {
                        followTerrain = followTerrain,
                        IsQuick       = true
                    };
                    ActionQueue.instance.Push(asa);
                    ActionQueue.instance.Do();
                    if (autoCloseAlignTools)
                    {
                        UIMoreTools.MoreToolsPanel.isVisible = false;
                    }
                    DeactivateTool();
                }
                else if (OptionsKeymapping.alignInplace.IsPressed(e))
                {
                    ProcessAligning(AlignModes.Inplace);
                }
                else if (OptionsKeymapping.alignGroup.IsPressed(e))
                {
                    ProcessAligning(AlignModes.Group);
                }
                else if (OptionsKeymapping.alignRandom.IsPressed(e))
                {
                    AlignMode = AlignModes.Random;

                    if (ToolState == ToolStates.Cloning || ToolState == ToolStates.RightDraggingClone)
                    {
                        StopCloning();
                    }

                    AlignRandomAction action = new AlignRandomAction();
                    action.followTerrain = followTerrain;
                    ActionQueue.instance.Push(action);
                    ActionQueue.instance.Do();
                    DeactivateTool();
                }

                if (ToolState == ToolStates.Cloning)
                {
                    if (ProcessMoveKeys(e, out Vector3 direction, out float angle))
                    {
                        CloneAction action = ActionQueue.instance.current as CloneAction;

                        action.moveDelta.y += direction.y * YFACTOR;
                        action.angleDelta  += angle;
                    }
                }
                else if (ToolState == ToolStates.Default && Action.selection.Count > 0)
                {
                    if (ProcessMoveKeys(e, out Vector3 direction, out float angle))
                    {
                        if (!(ActionQueue.instance.current is TransformAction action))
                        {
                            action = new TransformAction();
                            ActionQueue.instance.Push(action);
                        }

                        if (direction != Vector3.zero)
                        {
                            direction.x = direction.x * XFACTOR;
                            direction.y = direction.y * YFACTOR;
                            direction.z = direction.z * ZFACTOR;

                            if (!useCardinalMoves)
                            {
                                Matrix4x4 matrix4x = default;
                                matrix4x.SetTRS(Vector3.zero, Quaternion.AngleAxis(Camera.main.transform.localEulerAngles.y, Vector3.up), Vector3.one);

                                direction = matrix4x.MultiplyVector(direction);
                            }
                        }

                        action.moveDelta    += direction;
                        action.angleDelta   += angle;
                        action.followTerrain = followTerrain;

                        m_nextAction = ToolAction.Do;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void MoreToolsClicked(UIComponent c, UIMouseEventParameter p)
        {
            switch (c.name)
            {
            case "MoveIt_MoreToolsBtn":
                if (MoreToolsPanel.isVisible)
                {
                    MoreToolsPanel.isVisible = false;
                }
                else
                {
                    MoreToolsPanel.isVisible = true;
                }
                UpdateMoreTools();
                break;

            case "MoveIt_AlignHeightBtn":
                MIT.ProcessAligning(MoveItTool.AlignModes.Height);
                break;

            case "MoveIt_AlignMirrorBtn":
                MIT.ProcessAligning(MoveItTool.AlignModes.Mirror);
                break;

            case "MoveIt_AlignTerrainHeightBtn":
                MIT.AlignMode = MoveItTool.AlignModes.TerrainHeight;

                if (MIT.ToolState == MoveItTool.ToolStates.Cloning || MIT.ToolState == MoveItTool.ToolStates.RightDraggingClone)
                {
                    MIT.StopCloning();
                }

                AlignTerrainHeightAction atha = new AlignTerrainHeightAction();
                ActionQueue.instance.Push(atha);
                ActionQueue.instance.Do();
                if (MoveItTool.autoCloseAlignTools)
                {
                    MoreToolsPanel.isVisible = false;
                }
                MoveItTool.instance.DeactivateTool();
                break;

            case "MoveIt_AlignSlopeBtn":
                if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))
                {
                    MIT.AlignMode = MoveItTool.AlignModes.SlopeNode;

                    if (MIT.ToolState == MoveItTool.ToolStates.Cloning || MIT.ToolState == MoveItTool.ToolStates.RightDraggingClone)
                    {
                        MIT.StopCloning();
                    }

                    AlignSlopeAction asa = new AlignSlopeAction();
                    asa.followTerrain = MoveItTool.followTerrain;
                    asa.IsQuick       = true;
                    ActionQueue.instance.Push(asa);
                    ActionQueue.instance.Do();
                    if (MoveItTool.autoCloseAlignTools)
                    {
                        MoreToolsPanel.isVisible = false;
                    }
                    MIT.DeactivateTool();
                    break;
                }
                MIT.ProcessAligning(MoveItTool.AlignModes.Slope);
                break;

            case "MoveIt_AlignIndividualBtn":
                MIT.ProcessAligning(MoveItTool.AlignModes.Inplace);
                break;

            case "MoveIt_AlignGroupBtn":
                MIT.ProcessAligning(MoveItTool.AlignModes.Group);
                break;

            case "MoveIt_AlignRandomBtn":
                MIT.AlignMode = MoveItTool.AlignModes.Random;

                if (MIT.ToolState == MoveItTool.ToolStates.Cloning || MIT.ToolState == MoveItTool.ToolStates.RightDraggingClone)
                {
                    MIT.StopCloning();
                }

                AlignRandomAction ara = new AlignRandomAction();
                ara.followTerrain = MoveItTool.followTerrain;
                ActionQueue.instance.Push(ara);
                ActionQueue.instance.Do();
                if (MoveItTool.autoCloseAlignTools)
                {
                    MoreToolsPanel.isVisible = false;
                }
                MIT.DeactivateTool();
                break;

            case "MoveIt_ConvertToPOBtn":
                if (MoveItTool.PO.Enabled && MIT.ToolState == MoveItTool.ToolStates.Default)
                {
                    if (MoveItTool.PO.Active == false)
                    {
                        MoveItTool.PO.Active = true;
                        UIToolOptionPanel.instance.PO_button.activeStateIndex = 1;
                        MoveItTool.PO.ToolEnabled();
                        UIFilters.POToggled();
                    }

                    ConvertToPOAction convertAction = new ConvertToPOAction();
                    ActionQueue.instance.Push(convertAction);
                    ActionQueue.instance.Do();
                }
                if (MoveItTool.autoCloseAlignTools)
                {
                    MoreToolsPanel.isVisible = false;
                }
                MIT.DeactivateTool();
                break;

            case "MoveIt_ResetObjectBtn":
                MoveItTool.instance.StartReset();
                if (MoveItTool.autoCloseAlignTools)
                {
                    MoreToolsPanel.isVisible = false;
                }
                MIT.DeactivateTool();
                break;

            default:
                Debug.Log($"Invalid Tool call ({c.name})");
                break;
            }
        }
Ejemplo n.º 3
0
        public static void MoreToolsClicked(string name, bool simAlt = false, bool simShift = false)
        {
            MoveItTool.instance.DeactivateTool();
            MoveItTool.m_isLowSensitivity = false;

            switch (name)
            {
            case "MoveIt_MoreToolsBtn":
                if (MoreToolsPanel.isVisible)
                {
                    MoreToolsPanel.isVisible = false;
                }
                else
                {
                    MoreToolsPanel.isVisible = true;
                }
                UpdateMoreTools();
                break;

            case "MoveIt_LoadBtn":
                UILoadWindow.Open();
                break;

            case "MoveIt_SaveBtn":
                if (MoveItTool.IsExportSelectionValid())
                {
                    UISaveWindow.Open();
                }
                else
                {
                    UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage(Str.xml_SelectionInvalidTitle, Str.xml_SelectionInvalidMessage, false);
                }
                break;

            case "MoveIt_AlignHeightBtn":
                m_activeToolMenu = MoreButtons["MoveIt_HeightBtn"];
                MIT.ProcessAligning(MoveItTool.MT_Tools.Height);
                break;

            case "MoveIt_AlignMirrorBtn":
                m_activeToolMenu = MoreButtons["MoveIt_OthersBtn"];
                MIT.ProcessAligning(MoveItTool.MT_Tools.Mirror);
                break;

            case "MoveIt_AlignTerrainHeightBtn":
                if (MoveItTool.ToolState == MoveItTool.ToolStates.Cloning || MoveItTool.ToolState == MoveItTool.ToolStates.RightDraggingClone)
                {
                    MIT.StopCloning();
                }

                AlignTerrainHeightAction atha = new AlignTerrainHeightAction();
                ActionQueue.instance.Push(atha);
                ActionQueue.instance.Do();
                CheckCloseMenu();
                MIT.DeactivateTool();
                break;

            case "MoveIt_AlignSlopeBtn":
                if (simShift)
                {
                    m_activeToolMenu = MoreButtons["MoveIt_HeightBtn"];
                    MIT.ProcessAligning(MoveItTool.MT_Tools.Slope);
                    break;
                }

                if (MoveItTool.ToolState == MoveItTool.ToolStates.Cloning || MoveItTool.ToolState == MoveItTool.ToolStates.RightDraggingClone)
                {
                    MIT.StopCloning();
                }

                AlignSlopeAction asa = new AlignSlopeAction
                {
                    followTerrain = MoveItTool.followTerrain,
                    mode          = AlignSlopeAction.Modes.Auto
                };
                if (simAlt)
                {
                    asa.mode = AlignSlopeAction.Modes.Quick;
                }
                ActionQueue.instance.Push(asa);
                ActionQueue.instance.Do();
                CheckCloseMenu();
                MIT.DeactivateTool();
                break;

            case "MoveIt_AlignLineBtn":
                if (MoveItTool.ToolState == MoveItTool.ToolStates.Cloning || MoveItTool.ToolState == MoveItTool.ToolStates.RightDraggingClone)
                {
                    MIT.StopCloning();
                }

                LineAction la = new LineAction
                {
                    followTerrain = MoveItTool.followTerrain,
                    mode          = LineAction.Modes.Spaced,
                };
                if (simShift)
                {
                    la.mode = LineAction.Modes.Unspaced;
                }
                ActionQueue.instance.Push(la);
                ActionQueue.instance.Do();
                CheckCloseMenu();
                MIT.DeactivateTool();
                break;

            case "MoveIt_AlignIndividualBtn":
                m_activeToolMenu = MoreButtons["MoveIt_RotateBtn"];
                MIT.ProcessAligning(MoveItTool.MT_Tools.Inplace);
                break;

            case "MoveIt_AlignGroupBtn":
                m_activeToolMenu = MoreButtons["MoveIt_RotateBtn"];
                MIT.ProcessAligning(MoveItTool.MT_Tools.Group);
                break;

            case "MoveIt_AlignRandomBtn":
                if (MoveItTool.ToolState == MoveItTool.ToolStates.Cloning || MoveItTool.ToolState == MoveItTool.ToolStates.RightDraggingClone)
                {
                    MIT.StopCloning();
                }

                AlignRandomAction ara = new AlignRandomAction
                {
                    followTerrain = MoveItTool.followTerrain
                };
                ActionQueue.instance.Push(ara);
                ActionQueue.instance.Do();
                CheckCloseMenu();
                MIT.DeactivateTool();
                break;

            case "MoveIt_ConvertToPOBtn":
                if (MoveItTool.PO.Enabled && MoveItTool.ToolState == MoveItTool.ToolStates.Default)
                {
                    MoveItTool.PO.StartConvertAction();
                }
                CheckCloseMenu();
                MIT.DeactivateTool();
                break;

            case "MoveIt_ResetObjectBtn":
                MIT.StartReset();
                CheckCloseMenu();
                MIT.DeactivateTool();
                break;

            case "MoveIt_MoveToBtn":
                m_activeToolMenu = MoreButtons["MoveIt_OthersBtn"];
                if (!MoveItTool.instance.StartTool(MoveItTool.ToolStates.ToolActive, MoveItTool.MT_Tools.MoveTo))
                {
                    m_activeToolMenu = null;
                    break;
                }

                MoveToAction mta = new MoveToAction
                {
                    followTerrain = MoveItTool.followTerrain
                };
                ActionQueue.instance.Push(mta);

                MoveItTool.m_moveToPanel.Visible(true);
                CheckCloseMenu();
                break;

            default:
                Log.Debug($"Invalid Tool clicked ({name})");
                break;
            }
        }
Ejemplo n.º 4
0
        public static void AlignToolsClicked(UIComponent c, UIMouseEventParameter p)
        {
            switch (c.name)
            {
            case "MoveIt_AlignToolsBtn":
                if (AlignToolsPanel.isVisible)
                {
                    AlignToolsPanel.isVisible = false;
                }
                else
                {
                    AlignToolsPanel.isVisible = true;
                }
                UpdateAlignTools();
                break;

            case "MoveIt_AlignHeightBtn":
                MIT.ProcessAligning(MoveItTool.AlignModes.Height);
                break;

            case "MoveIt_AlignTerrainHeightBtn":
                MIT.AlignMode = MoveItTool.AlignModes.TerrainHeight;

                if (MIT.ToolState == MoveItTool.ToolStates.Cloning || MIT.ToolState == MoveItTool.ToolStates.RightDraggingClone)
                {
                    MIT.StopCloning();
                }

                AlignTerrainHeightAction atha = new AlignTerrainHeightAction();
                ActionQueue.instance.Push(atha);
                ActionQueue.instance.Do();
                if (MoveItTool.autoCloseAlignTools)
                {
                    AlignToolsPanel.isVisible = false;
                }
                MoveItTool.instance.DeactivateAlignTool();
                break;

            case "MoveIt_AlignSlopeBtn":
                if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))
                {
                    MIT.AlignMode = MoveItTool.AlignModes.SlopeNode;

                    if (MIT.ToolState == MoveItTool.ToolStates.Cloning || MIT.ToolState == MoveItTool.ToolStates.RightDraggingClone)
                    {
                        MIT.StopCloning();
                    }

                    AlignSlopeAction asa = new AlignSlopeAction();
                    asa.followTerrain = MoveItTool.followTerrain;
                    asa.IsQuick       = true;
                    ActionQueue.instance.Push(asa);
                    ActionQueue.instance.Do();
                    if (MoveItTool.autoCloseAlignTools)
                    {
                        AlignToolsPanel.isVisible = false;
                    }
                    MIT.DeactivateAlignTool();
                    break;
                }
                MIT.ProcessAligning(MoveItTool.AlignModes.Slope);
                break;

            case "MoveIt_AlignIndividualBtn":
                MIT.ProcessAligning(MoveItTool.AlignModes.Inplace);
                break;

            case "MoveIt_AlignGroupBtn":
                MIT.ProcessAligning(MoveItTool.AlignModes.Group);
                break;

            case "MoveIt_AlignRandomBtn":
                MIT.AlignMode = MoveItTool.AlignModes.Random;

                if (MIT.ToolState == MoveItTool.ToolStates.Cloning || MIT.ToolState == MoveItTool.ToolStates.RightDraggingClone)
                {
                    MIT.StopCloning();
                }

                AlignRandomAction ara = new AlignRandomAction();
                ara.followTerrain = MoveItTool.followTerrain;
                ActionQueue.instance.Push(ara);
                ActionQueue.instance.Do();
                if (MoveItTool.autoCloseAlignTools)
                {
                    AlignToolsPanel.isVisible = false;
                }
                MoveItTool.instance.DeactivateAlignTool();
                break;

            default:
                Debug.Log($"Invalid Align Tools call ({c.name})");
                break;
            }
            //Debug.Log($"{c.name} clicked, mode is {MoveItTool.alignMode}");
        }