private void CreateAliasBrush(string brushName, Brush targetBrush)
        {
            var newAliasBrush = BrushUtility.CreateAliasBrush(brushName, targetBrush);

            ToolUtility.ShowBrushInDesigner(newAliasBrush);

            ToolUtility.RepaintBrushPalette();
        }
Example #2
0
        private void CreateOrientedBrush(string brushName)
        {
            var newOrientedBrush = BrushUtility.CreateOrientedBrush(brushName);

            ToolUtility.ShowBrushInDesigner(newOrientedBrush);

            ToolUtility.RepaintBrushPalette();
        }
        private void _brushList_BrushMouseDown(Brush brush)
        {
            // Double-click to ensure that designer window is shown.
            if (Event.current.clickCount == 2 && brush != null)
            {
                ToolUtility.ShowBrushInDesigner(brush);

                GUIUtility.hotControl = 0;
                GUIUtility.ExitGUI();
                return;
            }

            // If right mouse button was depressed, without holding control key, select
            // as primary brush ready for context menu.
            if (Event.current.button == 1 && !Event.current.control)
            {
                ToolUtility.SelectedBrush = brush;
            }
        }
        private static bool OnOpenAsset(int instanceID, int line)
        {
            var asset = EditorUtility.InstanceIDToObject(instanceID);

            var brush = asset as Brush;

            if (brush != null)
            {
                ToolUtility.ShowBrushInDesigner(brush);
                return(true);
            }

            var tileset = asset as Tileset;

            if (tileset != null)
            {
                ToolUtility.ShowTilesetInDesigner(tileset);
                return(true);
            }

            return(false);
        }
Example #5
0
        protected override void OnHeaderGUI()
        {
            if (!this.hasInitialized)
            {
                this.hasInitialized = true;

                // Find out whether brush asset is accessible via brush database.
                var record = BrushDatabase.Instance.FindRecord(target as Brush);
                this.hasRecord = (record != null);
            }

            if (this.hasRecord)
            {
                var brush = target as Brush;

                GUILayout.BeginHorizontal(RotorzEditorStyles.Instance.InspectorBigTitle);

                Rect previewPosition = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Width(64), GUILayout.Height(65));
                if (Event.current.type == EventType.Repaint)
                {
                    RotorzEditorStyles.Instance.Box.Draw(new Rect(previewPosition.x - 2, previewPosition.y - 2, 68, 68), GUIContent.none, false, false, false, false);
                    previewPosition = new Rect(previewPosition.x, previewPosition.y, 64, 64);
                    RotorzEditorGUI.DrawBrushPreview(previewPosition, brush);
                }

                GUILayout.BeginVertical();
                {
                    GUILayout.Label(brush.name, EditorStyles.largeLabel);

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();

                        var tilesetBrush = brush as TilesetBrush;
                        if (tilesetBrush != null)
                        {
                            EditorGUI.BeginDisabledGroup(tilesetBrush.Tileset == null);
                            if (GUILayout.Button(TileLang.OpensWindow(TileLang.ParticularText("Action", "Goto Tileset")), EditorStyles.miniButton))
                            {
                                ToolUtility.ShowTilesetInDesigner(tilesetBrush.Tileset);
                                GUIUtility.ExitGUI();
                            }
                            EditorGUI.EndDisabledGroup();
                        }

                        if (GUILayout.Button(TileLang.OpensWindow(TileLang.ParticularText("Action", "Show in Designer")), EditorStyles.miniButton))
                        {
                            ToolUtility.ShowBrushInDesigner(brush);
                            GUIUtility.ExitGUI();
                        }
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();

                GUILayout.EndHorizontal();
            }
            else
            {
                // Nope, assume default header!
                base.OnHeaderGUI();
            }
        }
        private void _brushList_BrushContextMenu(Brush brush)
        {
            // Do not attempt to display context menu for "(Erase)" item.
            if (brush == null)
            {
                return;
            }

            var brushRecord = BrushDatabase.Instance.FindRecord(brush);

            var brushContextMenu = new EditorMenu();

            brushContextMenu.AddCommand(TileLang.OpensWindow(TileLang.ParticularText("Action", "Show in Designer")))
            .Enabled(!brushRecord.IsMaster)     // Cannot edit a master brush :)
            .Action(() => {
                ToolUtility.ShowBrushInDesigner(brush);
            });

            var selectedTilesetBrush = brush as TilesetBrush;

            if (selectedTilesetBrush != null)
            {
                brushContextMenu.AddCommand(TileLang.ParticularText("Action", "Goto Tileset"))
                .Action(() => {
                    this.brushList.Model.View            = BrushListView.Tileset;
                    this.brushList.Model.SelectedTileset = selectedTilesetBrush.Tileset;

                    var designerWindow = RotorzWindow.GetInstance <DesignerWindow>();
                    if (designerWindow != null && !designerWindow.IsLocked)
                    {
                        designerWindow.SelectedObject = selectedTilesetBrush.Tileset;
                    }

                    this.Repaint();
                });
            }

            brushContextMenu.AddCommand(TileLang.ParticularText("Action", "Reveal Asset"))
            .Action(() => {
                EditorGUIUtility.PingObject(brush);
            });

            brushContextMenu.AddSeparator();

            brushContextMenu.AddCommand(TileLang.ParticularText("Action", "Refresh Preview"))
            .Action(() => {
                BrushUtility.RefreshPreviewIncludingDependencies(brush);
            });

            brushContextMenu.AddSeparator();

            brushContextMenu.AddCommand(TileLang.OpensWindow(TileLang.ParticularText("Action", "Create Duplicate")))
            .Action(() => {
                var window = CreateBrushWindow.ShowWindow <DuplicateBrushCreator>();
                window.SharedProperties["targetBrush"] = brush;
            });

            var brushDescriptor = BrushUtility.GetDescriptor(brush.GetType());

            brushContextMenu.AddCommand(TileLang.OpensWindow(TileLang.ParticularText("Action", "Create Alias")))
            .Enabled(brushDescriptor.SupportsAliases)
            .Action(() => {
                var window = CreateBrushWindow.ShowWindow <AliasBrushCreator>();
                window.SharedProperties["targetBrush"] = brush;
            });

            brushContextMenu.AddCommand(TileLang.OpensWindow(TileLang.ParticularText("Action", "Delete Brush")))
            .Action(() => {
                TileSystemCommands.DeleteBrush(brush, ToolUtility.SharedBrushListModel.View == BrushListView.Tileset);
            });

            brushContextMenu.ShowAsContext();
        }
 private void ShowTargetBrushInDesigner()
 {
     ToolUtility.ShowBrushInDesigner(this.AliasBrush.target);
 }