public BoxTool() { animSinglePoint = new AnimatedTextSurface("single", 1, 1, Settings.Config.ScreenFont); var _frameSinglePoint = animSinglePoint.CreateFrame(); _frameSinglePoint[0].GlyphIndex = 42; frameEffect = new SadConsole.Effects.Fade() { UseCellBackground = true, FadeForeground = true, FadeDuration = 1f, AutoReverse = true }; _settingsPanel = new BoxToolPanel(); ControlPanels = new CustomPanel[] { _settingsPanel }; // Brush = new SadConsole.Game.GameObject(); Brush.Font = Settings.Config.ScreenFont; AnimatedTextSurface animation = new AnimatedTextSurface("single", 1, 1, Settings.Config.ScreenFont); animation.CreateFrame()[0].GlyphIndex = 42; Brush.Animations.Add(animation.Name, animation); Brush.Animation = animation; }
public Player() : base(SadConsole.Engine.DefaultFont) { Animation = new AnimatedTextSurface("default", 1, 1, SadConsole.Engine.DefaultFont); var frame = Animation.CreateFrame(); frame[0].GlyphIndex = 5; this.CurrentDirection = Direction.None; Health = 70; }
public Hound() : base(SadConsole.Engine.DefaultFont) { AnimatedTextSurface anim = new AnimatedTextSurface("default", 1, 1, SadConsole.Engine.DefaultFont); var frame = anim.CreateFrame(); frame[0].Foreground = Color.Red; frame[0].Background = Color.Black; frame[0].GlyphIndex = 72; Animation = anim; }
public Player() : base(SadConsole.Engine.DefaultFont) { AnimatedTextSurface anim = new AnimatedTextSurface("default", 1, 1, SadConsole.Engine.DefaultFont); var frame = anim.CreateFrame(); frame[0].Foreground = Color.Yellow; frame[0].Background = Color.Black; frame[0].GlyphIndex = 1; Animation = anim; anim.Start(); }
public GameObjectConsole() : base(80, 25) { var animation = new AnimatedTextSurface("default", 1, 1, SadConsole.Engine.DefaultFont); var frame = animation.CreateFrame(); frame.Cells[0].GlyphIndex = 1; player = new SadConsole.Game.GameObject(SadConsole.Engine.DefaultFont); player.Animation = animation; player.RepositionRects = true; player.Position = new Point(textSurface.Width / 2, textSurface.Height / 2); playerPreviousPosition = player.Position; // Setup this console to accept keyboard input. CanUseKeyboard = true; IsVisible = false; }
public CircleTool() { frameEffect = new SadConsole.Effects.Fade() { UseCellBackground = true, FadeForeground = true, FadeDuration = 1f, AutoReverse = true }; // Configure the animations Brush = new SadConsole.Game.GameObject(); Brush.Font = Settings.Config.ScreenFont; AnimatedTextSurface animation = new AnimatedTextSurface("single", 1, 1, Settings.Config.ScreenFont); animation.CreateFrame()[0].GlyphIndex = 42; Brush.Animations.Add(animation.Name, animation); settingsPanel = new CircleToolPanel(); ControlPanels = new CustomPanel[] { settingsPanel, CharacterPickPanel.SharedInstance }; ResetCircle(); }
public void ProcessMouse(MouseInfo info, ITextSurface surface) { if (EditorConsoleManager.ToolsPane.IsMouseOver) { Brush.IsVisible = false; return; } else Brush.IsVisible = true; if (!firstPoint.HasValue) { Brush.Position = info.ConsoleLocation; } else { // Draw the line (erase old) to where the mouse is // create the animation frame AnimatedTextSurface animation = new AnimatedTextSurface("line", Math.Max(firstPoint.Value.X, info.ConsoleLocation.X) - Math.Min(firstPoint.Value.X, info.ConsoleLocation.X) + 1, Math.Max(firstPoint.Value.Y, info.ConsoleLocation.Y) - Math.Min(firstPoint.Value.Y, info.ConsoleLocation.Y) + 1, Settings.Config.ScreenFont); var frame = animation.CreateFrame(); Point p1; if (firstPoint.Value.X > info.ConsoleLocation.X) { if (firstPoint.Value.Y > info.ConsoleLocation.Y) p1 = new Point(frame.Width - 1, frame.Height - 1); else p1 = new Point(frame.Width - 1, 0); } else { if (firstPoint.Value.Y > info.ConsoleLocation.Y) p1 = new Point(0, frame.Height - 1); else p1 = new Point(0, 0); } animation.Center = p1; boxShape = SadConsole.Shapes.Box.GetDefaultBox(); if (_settingsPanel.UseCharacterBorder) boxShape.LeftSideCharacter = boxShape.RightSideCharacter = boxShape.TopLeftCharacter = boxShape.TopRightCharacter = boxShape.TopSideCharacter = boxShape.BottomLeftCharacter = boxShape.BottomRightCharacter = boxShape.BottomSideCharacter = _settingsPanel.BorderCharacter; boxShape.Foreground = _settingsPanel.LineForeColor; boxShape.FillColor = _settingsPanel.FillColor; boxShape.Fill = _settingsPanel.UseFill; boxShape.BorderBackground = _settingsPanel.LineBackColor; boxShape.Location = new Point(0, 0); boxShape.Width = frame.Width; boxShape.Height = frame.Height; boxShape.Draw(new SurfaceEditor(frame)); Brush.Animation = animation; } // TODO: Make this work. They push DOWN on the mouse, start the line from there, if they "Click" then go to mode where they click a second time // If they don't click and hold it down longer than click, pretend a second click happened and draw the line. if (info.LeftClicked) { if (!firstPoint.HasValue) { firstPoint = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y); } else { secondPoint = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y); Point p1 = new Point(Math.Min(firstPoint.Value.X, secondPoint.Value.X), Math.Min(firstPoint.Value.Y, secondPoint.Value.Y)); //Point p2 = new Point(Math.Max(_firstPoint.Value.X, _secondPoint.Value.X), Math.Max(_firstPoint.Value.Y, _secondPoint.Value.Y)); boxShape.Location = p1; boxShape.Draw(new SurfaceEditor(surface)); firstPoint = null; secondPoint = null; Brush.Animation = Brush.Animations["single"]; //surface.ResyncAllCellEffects(); } } else if (info.RightClicked) { if (firstPoint.HasValue && !secondPoint.HasValue) { firstPoint = null; secondPoint = null; Brush.Animation = Brush.Animations["single"]; } } }
private void SetAnimationLine(Point mousePosition) { // Draw the line (erase old) to where the mouse is // create the animation frame AnimatedTextSurface animation = new AnimatedTextSurface("line", Math.Max(firstPoint.Value.X, mousePosition.X) - Math.Min(firstPoint.Value.X, mousePosition.X) + 1, Math.Max(firstPoint.Value.Y, mousePosition.Y) - Math.Min(firstPoint.Value.Y, mousePosition.Y) + 1, Settings.Config.ScreenFont); var frame = animation.CreateFrame(); Point p1; Point p2; if (firstPoint.Value.X > mousePosition.X) { if (firstPoint.Value.Y > mousePosition.Y) { p1 = new Point(frame.Width - 1, frame.Height - 1); p2 = new Point(0, 0); } else { p1 = new Point(frame.Width - 1, 0); p2 = new Point(0, frame.Height - 1); } } else { if (firstPoint.Value.Y > mousePosition.Y) { p1 = new Point(0, frame.Height - 1); p2 = new Point(frame.Width - 1, 0); } else { p1 = new Point(0, 0); p2 = new Point(frame.Width - 1, frame.Height - 1); } } animation.Center = p1; //_lineStyle = new CellAppearance( // EditorConsoleManager.Instance.ToolPane.CommonCharacterPickerPanel.SettingForeground, // EditorConsoleManager.Instance.ToolPane.CommonCharacterPickerPanel.SettingBackground, // EditorConsoleManager.Instance.ToolPane.CommonCharacterPickerPanel.SettingCharacter); //_lineStyle.SpriteEffect = EditorConsoleManager.Instance.ToolPane.CommonCharacterPickerPanel.SettingMirrorEffect; //_lineStyle.CopyAppearanceTo(_lineCell); lineShape = new SadConsole.Shapes.Line(); lineShape.CellAppearance = lineCell; lineShape.UseEndingCell = false; lineShape.UseStartingCell = false; lineShape.StartingLocation = p1; lineShape.EndingLocation = p2; lineShape.Draw(new SurfaceEditor(frame)); settingsPanel.LineLength = frame.Width > frame.Height ? frame.Width : frame.Height; Brush.Animation = animation; }
public SelectionTool() { Brush = new LayeredGameObject(); Brush.Font = Settings.Config.ScreenFont; var animation = new AnimatedTextSurface(AnimationSingle, 1, 1, Settings.Config.ScreenFont); animation.CreateFrame()[0].GlyphIndex = 42; animation.Frames[0][0].Background = Color.Black; Brush.Animations.Add(animation.Name, animation); animation = new AnimatedTextSurface(AnimationSelection, 1, 1, Settings.Config.ScreenFont); Brush.Animations.Add(animation.Name, animation); _frameEffect = new SadConsole.Effects.Fade() { UseCellBackground = true, FadeForeground = true, FadeDuration = 1f, AutoReverse = true }; _panel = new SelectionToolPanel(LoadBrush, SaveBrush); _panel.StateChangedHandler = PanelStateChanged; _panel.State = SelectionToolPanel.CloneState.SelectingPoint1; _altPanel = new SelectionToolAltPanel(); ControlPanels = new CustomPanel[] { _panel, _altPanel }; _pulseAnimation = new SadConsole.Effects.Fade() { FadeBackground = true, UseCellBackground = false, DestinationBackground = Color.Transparent, FadeDuration = 2d, CloneOnApply = false, AutoReverse = true, Repeat = true, }; }
private void MakeBoxAnimation(int width, int height, Point center) { AnimatedTextSurface animation; if (Brush.Animations.ContainsKey(AnimationSelection)) { animation = Brush.Animations[AnimationSelection]; if (animation.Width == width && animation.Height == height && animation.Center == center) { Brush.Animation = animation; return; } } animation = new AnimatedTextSurface(AnimationSelection, width, height, Settings.Config.ScreenFont); Settings.QuickEditor.TextSurface = animation.CreateFrame(); _boxShape = SadConsole.Shapes.Box.GetDefaultBox(); _boxShape.Location = new Point(0, 0); _boxShape.Width = width; _boxShape.Height = height; _boxShape.Draw(Settings.QuickEditor); //frame.SetEffect(frame, _pulseAnimation); animation.Center = center; Brush.Animations[animation.Name] = animation; Brush.Animation = animation; }
public void New(Color foreground, Color background, int width, int height) { Reset(); var gameObject = new GameObject(SadConsoleEditor.Settings.Config.ScreenFont); AnimatedTextSurface animation = new AnimatedTextSurface("default", width, height, SadConsoleEditor.Settings.Config.ScreenFont); animation.DefaultForeground = foreground; animation.DefaultBackground = background; animation.CreateFrame(); animation.AnimationDuration = 1; gameObject.Animations[animation.Name] = animation; gameObject.Animation = animation; gameObject.Name = "game object"; SetEntity(gameObject); }
void addNewAnimation_ButtonClicked(object sender, EventArgs e) { RenamePopup popup = new RenamePopup("", "Animation Name"); popup.Closed += (o, e2) => { if (popup.DialogResult) { string newName = popup.NewName.Trim(); var keys = entity.Animations.Keys.Select(k => k.ToLower()).ToList(); if (keys.Contains(newName.ToLower())) { Window.Message("Name must be unique", "Close"); } else if (string.IsNullOrEmpty(newName)) { Window.Message("Name cannot be blank", "Close"); } else { var previouslySelected = (AnimatedTextSurface)animations.SelectedItem; var animation = new AnimatedTextSurface(newName, previouslySelected.Width, previouslySelected.Height, Settings.Config.ScreenFont); animation.CreateFrame(); animation.AnimationDuration = 1; entity.Animations[animation.Name] = animation; RebuildListBox(); animations.SelectedItem = animation; } } }; popup.Show(true); popup.Center(); }
public void MouseMoveSurface(MouseInfo info, ITextSurface surface) { Brush.IsVisible = true; if (!firstPoint.HasValue) { Brush.Position = info.ConsoleLocation; settingsPanel.CircleWidth = 0; settingsPanel.CircleHeight = 0; } else { AnimatedTextSurface animation; // Draw the line (erase old) to where the mouse is // create the animation frame animation = new AnimatedTextSurface("line", Math.Max(firstPoint.Value.X, info.ConsoleLocation.X) - Math.Min(firstPoint.Value.X, info.ConsoleLocation.X) + 1, Math.Max(firstPoint.Value.Y, info.ConsoleLocation.Y) - Math.Min(firstPoint.Value.Y, info.ConsoleLocation.Y) + 1, Settings.Config.ScreenFont); var frame = animation.CreateFrame(); Point p1; if (firstPoint.Value.X > info.ConsoleLocation.X) { if (firstPoint.Value.Y > info.ConsoleLocation.Y) p1 = new Point(frame.Width - 1, frame.Height - 1); else p1 = new Point(frame.Width - 1, 0); } else { if (firstPoint.Value.Y > info.ConsoleLocation.Y) p1 = new Point(0, frame.Height - 1); else p1 = new Point(0, 0); } settingsPanel.CircleWidth = frame.Width; settingsPanel.CircleHeight = frame.Height; animation.Center = p1; Settings.QuickEditor.TextSurface = frame; ellipseShape = new SadConsole.Shapes.Ellipse(); ellipseShape.BorderAppearance = borderAppearance; ellipseShape.EndingPoint = new Point(frame.Width - 1, frame.Height - 1); ellipseShape.Draw(Settings.QuickEditor); Brush.Animation = animation; } // TODO: Make this work. They push DOWN on the mouse, start the line from there, if they "Click" then go to mode where they click a second time // If they don't click and hold it down longer than click, pretend a second click happened and draw the line. if (info.LeftClicked) { if (!firstPoint.HasValue) { firstPoint = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y); RefreshTool(); } else { secondPoint = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y); Point p1 = new Point(Math.Min(firstPoint.Value.X, secondPoint.Value.X), Math.Min(firstPoint.Value.Y, secondPoint.Value.Y)); Point p2 = new Point(Math.Max(firstPoint.Value.X, secondPoint.Value.X), Math.Max(firstPoint.Value.Y, secondPoint.Value.Y)); Settings.QuickEditor.TextSurface = surface; ellipseShape.StartingPoint = p1; ellipseShape.EndingPoint = p2; ellipseShape.Draw(Settings.QuickEditor); Brush.Animation = Brush.Animations["single"]; Brush.Position = secondPoint.Value; firstPoint = null; secondPoint = null; //surface.ResyncAllCellEffects(); } } else if (info.RightClicked) { if (firstPoint.HasValue && !secondPoint.HasValue) { firstPoint = null; secondPoint = null; settingsPanel.CircleWidth = 0; settingsPanel.CircleHeight = 0; Brush.Animation = Brush.Animations["single"]; Brush.Position = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y); } } }
public Monster(String name, String inventoryName, int roomId, int x, int y, int character, int health, string description, string deadDescription) : base(SadConsole.Engine.DefaultFont) { this.IsAlive = true; this.Name = inventoryName; this.InventoryName = name; this.RoomId = roomId; position.X = x; position.Y = y; this.Character = character; this.Health = health; this.Description = description; this.DeadDescription = deadDescription; this.Value = 100; this.IsGuard = false; Animation = new AnimatedTextSurface("default", 1, 1, SadConsole.Engine.DefaultFont); var frame = Animation.CreateFrame(); frame[0].GlyphIndex = character; }
public void Resize(int width, int height) { //var oldSurface = (LayeredTextSurface)_consoleLayers.TextSurface; //var newSurface = new LayeredTextSurface(width, height, oldSurface.LayerCount); //for (int i = 0; i < oldSurface.LayerCount; i++) //{ // var oldLayer = oldSurface.GetLayer(i); // var newLayer = newSurface.GetLayer(i); // oldSurface.SetActiveLayer(i); // newSurface.SetActiveLayer(i); // oldSurface.Copy(newSurface); // newLayer.Metadata = oldLayer.Metadata; // newLayer.IsVisible = oldLayer.IsVisible; //} List<AnimatedTextSurface> newAnimations = new List<AnimatedTextSurface>(gameObject.Animations.Count); foreach (var oldAnimation in gameObject.Animations.Values) { var newAnimation = new AnimatedTextSurface(oldAnimation.Name, width, height, SadConsoleEditor.Settings.Config.ScreenFont); for (int i = 0; i < oldAnimation.Frames.Count; i++) { oldAnimation.Frames[i].Copy(newAnimation.CreateFrame()); } newAnimation.CurrentFrameIndex = 0; newAnimations.Add(newAnimation); newAnimation.AnimationDuration = oldAnimation.AnimationDuration; newAnimation.Center = oldAnimation.Center; } foreach (var animation in newAnimations) { gameObject.Animations[animation.Name] = animation; if (gameObject.Animation.Name == animation.Name) gameObject.Animation = animation; if (selectedAnimation.Name == animation.Name) selectedAnimation = animation; } // inform the outer box we've changed size //EditorConsoleManager.Instance.UpdateBox(); SetEntity(gameObject); if (EditorConsoleManager.ActiveEditor == this) { EditorConsoleManager.CenterEditor(); EditorConsoleManager.UpdateBorder(consoleWrapper.Position); } }
public bool LoadZone(Zone zone) { var gameObject = new GameObject(Settings.Config.ScreenFont); var animation = new AnimatedTextSurface("default", 10, 10); var frame = animation.CreateFrame(); frame.DefaultBackground = zone.DebugAppearance.Background; gameObject.Name = zone.Title; Settings.QuickEditor.TextSurface = frame; Settings.QuickEditor.Clear(); Settings.QuickEditor.Print(0, 0, zone.Title, Color.DarkGray); gameObject.Animation = animation; gameObject.Position = new Point(zone.Area.Left, zone.Area.Top); gameObject.Update(); var resizable = new ResizableObject<Zone>(ResizableObject.ObjectType.Zone, gameObject, zone); resizable.RenderOffset = consoleWrapper.Position - consoleWrapper.TextSurface.RenderArea.Location; Zones.Add(resizable); ZonesPanel.RebuildListBox(); return true; }
public void LoadBrush(TextSurface surface) { _panel.State = SelectionToolPanel.CloneState.Clone; // Copy data to new animation var cloneAnimation = new AnimatedTextSurface("clone", surface.Width, surface.Height, Settings.Config.ScreenFont); var frame = cloneAnimation.CreateFrame(); surface.Copy(frame); cloneAnimation.Center = new Point(cloneAnimation.Width / 2, cloneAnimation.Height / 2); Brush.SelectedSurface.Animation = cloneAnimation; //Brush.Animation.Tint = new Color(0f, 0f, 0f, 0f); Brush.IsVisible = true; MakeBoxAnimation(surface.Width, surface.Height, cloneAnimation.Center); }
private void cloneSelectedAnimation_ButtonClicked(object sender, EventArgs e) { RenamePopup popup = new RenamePopup("clone"); popup.Closed += (o, e2) => { if (popup.DialogResult) { var animation = (AnimatedTextSurface)animations.SelectedItem; var newAnimation = new AnimatedTextSurface(popup.NewName, animation.Width, animation.Height, Settings.Config.ScreenFont); foreach (var frame in animation.Frames) { var newFrame = newAnimation.CreateFrame(); frame.Copy(newFrame); } newAnimation.CurrentFrameIndex = 0; entity.Animations[newAnimation.Name] = newAnimation; RebuildListBox(); } }; popup.Show(true); popup.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; }