private void PanelStateChanged(SelectionToolPanel.CloneState state) { if (state == SelectionToolPanel.CloneState.SelectingPoint1) { Brush.ShowSelectedSurface = false; Brush.IsVisible = false; Brush.Animation = Brush.Animations[AnimationSingle]; } else if (state == SelectionToolPanel.CloneState.Move) { var animation = Brush.Animation; Brush.ShowSelectedSurface = true; ClearBrush(Brush.Position.X, Brush.Position.Y, _previousSurface); animation.Center = new Point(animation.Width / 2, animation.Height / 2); Brush.Position += animation.Center; } else if (state == SelectionToolPanel.CloneState.Clear) { var animation = Brush.Animation; Brush.ShowSelectedSurface = false; ClearBrush(Brush.Position.X, Brush.Position.Y, _previousSurface); _panel.State = SelectionToolPanel.CloneState.SelectingPoint1; } else if (state == SelectionToolPanel.CloneState.Stamp) { var animation = Brush.Animation; Brush.ShowSelectedSurface = true; animation.Center = new Point(animation.Width / 2, animation.Height / 2); //Brush.Position += animation.Center + new Point(1); Brush.SelectedSurface.Animation.Center = Brush.Animation.Center; } }
public void MouseMoveSurface(MouseInfo info, ITextSurface surface) { Brush.IsVisible = true; //_entity.SyncLayers(); if (info.LeftClicked) { if (_panel.State == SelectionToolPanel.CloneState.SelectingPoint1) { _panel.State = SelectionToolPanel.CloneState.SelectingPoint2; Brush.Animation.Tint = new Color(0f, 0f, 0f, 0.5f); } else if (_panel.State == SelectionToolPanel.CloneState.SelectingPoint2) { _secondPoint = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y); _panel.State = SelectionToolPanel.CloneState.Selected; // Copy data to new animation AnimatedTextSurface cloneAnimation = new AnimatedTextSurface("clone", Brush.Width, Brush.Height, Settings.Config.ScreenFont); var frame = cloneAnimation.CreateFrame(); Point topLeftPoint = new Point(Math.Min(_firstPoint.Value.X, _secondPoint.Value.X), Math.Min(_firstPoint.Value.Y, _secondPoint.Value.Y)); surface.Copy(topLeftPoint.X, topLeftPoint.Y, cloneAnimation.Width, cloneAnimation.Height, frame, 0, 0); if (_altPanel.SkipEmptyCells && _altPanel.UseAltEmptyColor) { foreach (var cell in frame.Cells) { if (cell.GlyphIndex == 0 && cell.Background == _altPanel.AltEmptyColor) cell.Background = Color.Transparent; } } cloneAnimation.Center = Brush.Animation.Center; Brush.SelectedSurface.Animation = cloneAnimation; //Brush.Animations[cloneAnimation.Name] = cloneAnimation; //Brush.Animation = cloneAnimation; //Brush.Animation.Tint = new Color(0f, 0f, 0f, 0f); //// Display the rect //var topLayer = new GameObject(Settings.Config.ScreenFont); //Brush.UnderAnimation = topLayer; //topLayer.Animations[_tempAnimation.Name] = _tempAnimation; //topLayer.Animation = _tempAnimation; //topLayer.Animation.Tint = new Color(0f, 0f, 0f, 0.35f); //topLayer.Position = Brush.Position; ////_entity.SyncLayers(); } else if (_panel.State == SelectionToolPanel.CloneState.Selected) { } else if (_panel.State == SelectionToolPanel.CloneState.Clone) { //StampBrush(info.ConsoleLocation.X, info.ConsoleLocation.Y, surface); } else if (_panel.State == SelectionToolPanel.CloneState.Clear) { // Erase selected area } else if (_panel.State == SelectionToolPanel.CloneState.Move) { // Move the selected cells } } else { if (_panel.State == SelectionToolPanel.CloneState.SelectingPoint1) { Brush.Position = info.ConsoleLocation; _firstPoint = Brush.Position; // State was reset and we didn't know about it if (_previousState != _panel.State || Brush.Animation.Name != AnimationSingle) { Brush.Animation = Brush.Animations[AnimationSingle]; Brush.Animation.Tint = new Color(0f, 0f, 0f, 0f); } } if (_panel.State == SelectionToolPanel.CloneState.SelectingPoint2) { int width = Math.Max(_firstPoint.Value.X, info.ConsoleLocation.X) - Math.Min(_firstPoint.Value.X, info.ConsoleLocation.X) + 1; int height = Math.Max(_firstPoint.Value.Y, info.ConsoleLocation.Y) - Math.Min(_firstPoint.Value.Y, info.ConsoleLocation.Y) + 1; Point p1; if (_firstPoint.Value.X > info.ConsoleLocation.X) { if (_firstPoint.Value.Y > info.ConsoleLocation.Y) p1 = new Point(width - 1, height - 1); else p1 = new Point(width - 1, 0); } else { if (_firstPoint.Value.Y > info.ConsoleLocation.Y) p1 = new Point(0, height - 1); else p1 = new Point(0, 0); } MakeBoxAnimation(width, height, p1); } } _previousState = _panel.State; }