/// <summary>
        /// Adds an edit mode to the control
        /// </summary>
        private void RegisterEditMode( IEditMode mode )
        {
            Control control = mode.CreateControl( );
            if ( control == null )
            {
                AppLog.Warning( "Edit mode \"{0}\" did not create a control - it will not appear in the edit mode tab pages", mode.DisplayName );
                return;
            }

            AppLog.Info( "Adding Edit mode \"{0}\" to edit mode tab pages", mode.DisplayName );
            TabPage containerPage = new TabPage( mode.DisplayName );
            containerPage.Controls.Add( control );
            control.Dock = DockStyle.Fill;

            containerPage.Tag = mode;
            containerPage.Enter += EditModeTagPageEntered;

            editModeTabs.TabPages.Add( containerPage );
        }
 /// <summary>
 /// Called when an edit mode is added
 /// </summary>
 protected virtual void EditModeAdded( IEditMode editMode )
 {
     UpdateInputsStatusLabel( );
 }
 /// <summary>
 /// Registers an edit mode. This does nothing more that put it in the registered edit mode list
 ///  (<see cref="RegisteredEditModes"/>), and call the register event (<see cref="EditModeRegistered"/>)
 /// </summary>
 /// <param name="mode">Edit mode to register</param>
 /// <remarks>
 /// This method will not register the same mode twice (will return without exception)
 /// </remarks>
 public void RegisterEditMode( IEditMode mode )
 {
     if ( m_RegisteredModes.Contains( mode ) )
     {
         return;
     }
     m_RegisteredModes.Add( mode );
     if ( EditModeRegistered != null )
     {
         EditModeRegistered( mode );
     }
 }
        /// <summary>
        /// Adds an edit mode. If the mode is exclusive, then it replaces the current exclusive mode
        /// </summary>
        /// <param name="mode">Mode to add</param>
        public void ActivateEditMode( IEditMode mode )
        {
            //	Make sure that the mode is registered...
            RegisterEditMode( mode );

            if ( mode.Exclusive )
            {
                if ( m_ExclusiveMode != null )
                {
                    m_ExclusiveMode.Stop( );
                    m_ExclusiveMode.Stopped -= ExclusiveModeStopped;
                }

                //	Stop any shared modes that have the same inputs
                foreach ( IEditMode sharedMode in m_SharedModes )
                {
                    if ( ( sharedMode.Buttons & mode.Buttons ) != 0 )
                    {
                        //	Buttons used by both modes - they can't co-exist, so stop the shared mode
                        sharedMode.Stop( );
                    }
                }

                m_ExclusiveMode = mode;
                mode.Start( );
                mode.Stopped += ExclusiveModeStopped;
            }
            else if ( !m_SharedModes.Contains( mode ) )
            {
                m_SharedModes.Add( mode );
                mode.Start( );
            }

            if ( EditModeActivated != null )
            {
                EditModeActivated( mode );
            }
        }
Esempio n. 5
0
        public static bool HandleSceneKeyDown(IEditMode tool, bool checkForTextEditing = true)
        {
            if (EditorGUIUtility.editingTextField && checkForTextEditing)
            {
                return(false);
            }

            if (Keys.MakeSelectedPassThroughKey.IsKeyPressed() && tool.UsesUnitySelection)
            {
                return(true);
            }
            if (Keys.MakeSelectedAdditiveKey.IsKeyPressed() && tool.UsesUnitySelection)
            {
                return(true);
            }
            if (Keys.MakeSelectedSubtractiveKey.IsKeyPressed() && tool.UsesUnitySelection)
            {
                return(true);
            }
            if (Keys.MakeSelectedIntersectingKey.IsKeyPressed() && tool.UsesUnitySelection)
            {
                return(true);
            }

            if (Keys.ToggleSelectedObjectVisibilityKey.IsKeyPressed() && tool.UsesUnitySelection)
            {
                return(true);
            }
            if (Keys.QuickHideSelectedObjectsKey.IsKeyPressed() && tool.UsesUnitySelection)
            {
                return(true);
            }
            if (Keys.QuickHideUnselectedObjectsKey.IsKeyPressed() && tool.UsesUnitySelection)
            {
                return(true);
            }
            if (Keys.UnHideAllObjectsKey.IsKeyPressed() && tool.UsesUnitySelection)
            {
                return(true);
            }
            if (Keys.CancelActionKey.IsKeyPressed())
            {
                return(true);
            }

            if (Keys.HalfGridSizeKey.IsKeyPressed())
            {
                return(true);
            }
            if (Keys.DoubleGridSizeKey.IsKeyPressed())
            {
                return(true);
            }
            if (Keys.ToggleShowGridKey.IsKeyPressed())
            {
                return(true);
            }
            if (Keys.ToggleSnappingKey.IsKeyPressed())
            {
                return(true);
            }
            return(false);
        }
Esempio n. 6
0
        public static bool HandleSceneKeyUp(IEditMode tool, bool checkForTextEditing = true)
        {
            if (EditorGUIUtility.editingTextField && checkForTextEditing)
            {
                return(false);
            }

            if (Keys.MakeSelectedPassThroughKey.IsKeyPressed() && tool.UsesUnitySelection)
            {
                OperationsUtility.SetPassThroughOnSelected(); return(true);
            }
            if (Keys.MakeSelectedAdditiveKey.IsKeyPressed() && tool.UsesUnitySelection)
            {
                OperationsUtility.ModifyOperationsOnSelected(CSGOperationType.Additive); return(true);
            }
            if (Keys.MakeSelectedSubtractiveKey.IsKeyPressed() && tool.UsesUnitySelection)
            {
                OperationsUtility.ModifyOperationsOnSelected(CSGOperationType.Subtractive); return(true);
            }
            if (Keys.MakeSelectedIntersectingKey.IsKeyPressed() && tool.UsesUnitySelection)
            {
                OperationsUtility.ModifyOperationsOnSelected(CSGOperationType.Intersecting); return(true);
            }

            if (Keys.ToggleSelectedObjectVisibilityKey.IsKeyPressed() && tool.UsesUnitySelection)
            {
                SelectionUtility.ToggleSelectedObjectVisibility(); return(true);
            }
            if (Keys.QuickHideSelectedObjectsKey.IsKeyPressed() && tool.UsesUnitySelection)
            {
                SelectionUtility.HideSelectedObjects(); return(true);
            }
            if (Keys.QuickHideUnselectedObjectsKey.IsKeyPressed() && tool.UsesUnitySelection)
            {
                SelectionUtility.HideUnselectedObjects(); return(true);
            }
            if (Keys.UnHideAllObjectsKey.IsKeyPressed() && tool.UsesUnitySelection)
            {
                SelectionUtility.UnHideAll(); return(true);
            }
            if (Keys.CancelActionKey.IsKeyPressed())
            {
                SelectionUtility.DeselectAll(); return(true);
            }

            if (Keys.HalfGridSizeKey.IsKeyPressed())
            {
                GridUtility.HalfGridSize(); return(true);
            }
            if (Keys.DoubleGridSizeKey.IsKeyPressed())
            {
                GridUtility.DoubleGridSize(); return(true);
            }
            if (Keys.ToggleShowGridKey.IsKeyPressed())
            {
                GridUtility.ToggleShowGrid(); return(true);
            }
            if (Keys.ToggleSnappingKey.IsKeyPressed())
            {
                GridUtility.ToggleSnapToGrid(); return(true);
            }
            return(false);
        }