/// <inheritdoc/> public override void OnTool(ToolEvent e, IToolContext context) { switch (e.Type) { case EventType.MouseDown: ToolBase fallbackRestoreTool; Brush pickedBrush = null; if (ToolUtility.ActivePlop != null && ToolUtility.ActivePlop.Brush != null) { fallbackRestoreTool = ToolManager.Instance.Find <PlopTool>(); // Get plop at pointer. pickedBrush = ToolUtility.ActivePlop.Brush; // Pick rotation from tile also! ToolUtility.Rotation = ToolUtility.ActivePlop.PaintedRotation; } else { fallbackRestoreTool = ToolManager.DefaultPaintTool; // Get tile at pointer. var tile = context.TileSystem.GetTile(e.MousePointerTileIndex); if (tile != null) { pickedBrush = tile.brush; // Pick rotation from tile also! ToolUtility.Rotation = tile.PaintedRotation; } } // Select brush in tool window and force auto scroll. if (e.IsLeftButtonPressed) { ToolUtility.SelectedBrush = pickedBrush; ToolUtility.RevealBrush(pickedBrush); } else { ToolUtility.SelectedBrushSecondary = pickedBrush; } ToolUtility.RepaintBrushPalette(); // Switch to previous tool or the "Paint" tool. var toolManager = ToolManager.Instance; if (toolManager.PreviousTool != null && toolManager.PreviousTool != this) { toolManager.CurrentTool = toolManager.PreviousTool; } else { toolManager.CurrentTool = fallbackRestoreTool; } break; } }
private void OnSelectedObjectChanged() { // Finish up with previous brush editor. this.UnloadDesignerView(); if (this.SelectedObject is Brush) { this.LoadBrushDesignerView(); if (!this.IsLocked) { // Make sure that brush is shown in brush list. this.BrushListModel.SelectedBrush = this.SelectedObject as Brush; ToolUtility.RevealBrush(this.BrushListModel.SelectedBrush, false); } } else if (this.SelectedObject is Tileset) { this.LoadTilesetDesignerView(); if (!this.IsLocked) { // Make sure that tileset is shown in brush list. this.BrushListModel.View = BrushListView.Tileset; this.BrushListModel.SelectedTileset = this.SelectedObject as Tileset; } } if (!this.History.IsNavigating) { if (this.designerView != null && this.SelectedObject != null && this.SelectedObject.Exists) { this.currentState = this.designerView.CreateHistoryState(); this.History.AddToRecent(this.SelectedObject); } } // Clear active input control. this._clearFocusControl = true; this.Repaint(); }