private void DrawToolbar() { GUILayout.BeginHorizontal(EditorStyles.toolbar); if (GUILayout.Button(TileLang.OpensWindow(TileLang.ParticularText("Action", "Create")), EditorStyles.toolbarButton, RotorzEditorStyles.ContractWidth)) { CreateBrushWindow.ShowWindow().Focus(); GUIUtility.ExitGUI(); } GUILayout.Space(5); this.brushList.DrawToolbarButtons(); GUILayout.EndHorizontal(); }
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 OnGUI_Keyboard() { if (GUIUtility.hotControl != 0) { return; } Event e = Event.current; if (e.type != EventType.KeyDown) { return; } switch (e.keyCode) { case KeyCode.F2: CreateBrushWindow.ShowWindow(); e.Use(); break; case KeyCode.LeftArrow: if (e.alt) { this.History.GoBack(); e.Use(); } break; case KeyCode.RightArrow: if (e.alt) { this.History.GoForward(); e.Use(); } break; case KeyCode.E: if (e.control) { if (this.designerView != null && this.designerView.HasExtendedProperties) { DesignerView.DisplayExtendedProperties = !DesignerView.DisplayExtendedProperties; GUIUtility.keyboardControl = 0; e.Use(); } } break; } // The following keyboard shortcuts do not work when window is locked. if (this.IsLocked) { return; } switch (e.keyCode) { case KeyCode.UpArrow: if (e.control) { this.SelectNextBrush(-1); e.Use(); } break; case KeyCode.PageUp: this.SelectNextBrush(-1); e.Use(); break; case KeyCode.DownArrow: if (e.control) { this.SelectNextBrush(+1); e.Use(); } break; case KeyCode.PageDown: this.SelectNextBrush(+1); e.Use(); break; case KeyCode.Home: if (e.control) { this.SelectBrushByIndex(0); e.Use(); } break; case KeyCode.End: if (e.control) { this.SelectBrushByIndex(BrushListModel.Records.Count - 1); e.Use(); } break; } }