Пример #1
0
        /// <inheritdoc />
        public override void Draw(ControlsConsole console, CellSurface hostSurface)
        {
            hostSurface.DefaultForeground = FillStyle.Foreground;
            hostSurface.DefaultBackground = FillStyle.Background;
            hostSurface.Fill(hostSurface.DefaultForeground, hostSurface.DefaultBackground, FillStyle.Glyph, null);

            if (!(console is Window window))
            {
                return;
            }

            if (BorderLineStyle != null)
            {
                hostSurface.DrawBox(new Rectangle(0, 0, hostSurface.Width, hostSurface.Height), new Cell(BorderStyle.Foreground,
                                                                                                         BorderStyle.Background, 0), null, BorderLineStyle);
            }

            // Draw title
            string adjustedText  = "";
            int    adjustedWidth = hostSurface.Width - 2;

            TitleAreaLength = 0;
            TitleAreaX      = 0;

            if (!string.IsNullOrEmpty(window.Title))
            {
                if (window.Title.Length > adjustedWidth)
                {
                    adjustedText = window.Title.Substring(0, window.Title.Length - (window.Title.Length - adjustedWidth));
                }
                else
                {
                    adjustedText = window.Title;
                }
            }

            if (!string.IsNullOrEmpty(adjustedText))
            {
                TitleAreaLength = adjustedText.Length;

                if (window.TitleAlignment == HorizontalAlignment.Left)
                {
                    TitleAreaX = 1;
                }
                else if (window.TitleAlignment == HorizontalAlignment.Center)
                {
                    TitleAreaX = ((adjustedWidth - adjustedText.Length) / 2) + 1;
                }
                else
                {
                    TitleAreaX = hostSurface.Width - 1 - adjustedText.Length;
                }

                hostSurface.Print(TitleAreaX, TitleAreaY, adjustedText, TitleStyle);
            }
        }
Пример #2
0
        /// <summary>
        /// Draws the theme to the console.
        /// </summary>
        /// <param name="console">Console associated with the theme.</param>
        /// <param name="hostSurface">Surface used for drawing.</param>
        public virtual void Draw(ControlsConsole console, CellSurface hostSurface)
        {
            Colors colors = console.ThemeColors ?? Library.Default.Colors;

            FillStyle = colors.Appearance_ControlNormal;

            hostSurface.DefaultForeground = FillStyle.Foreground;
            hostSurface.DefaultBackground = FillStyle.Background;
            hostSurface.Fill(hostSurface.DefaultForeground, hostSurface.DefaultBackground, FillStyle.Glyph, null);
        }
Пример #3
0
        protected override void DrawView(CellSurface surface)
        {
            base.DrawView(surface);

            surface.Fill(Color.White, Color.Black, null);

            DrawBrush(surface);

            surface.Print(1, 20, "New image width:");
            surface.Print(20, 20, newImageWidth.ToString());

            surface.Print(1, 22, "New image height:");
            surface.Print(20, 22, newImageHeight.ToString());
        }
Пример #4
0
        public void Draw(CellSurface surface)
        {
            surface.Fill(
                new Rectangle(0, 0, Position.Width, Position.Height),
                EmptyCell.Foreground, EmptyCell.Background, EmptyCell.Glyph);

            var sizeMultiplier = (double)Value / (Max - Min);
            var fillWidth      = (int)Math.Round(Position.Width * sizeMultiplier);

            if (Value > Min && fillWidth == 0)
            {
                fillWidth = 1;
            }

            if (Value < Max && fillWidth == Position.Width)
            {
                fillWidth--;
            }

            surface.Fill(
                new Rectangle(0, 0, fillWidth, Position.Height),
                FillCell.Foreground, FillCell.Background, FillCell.Glyph);
        }
Пример #5
0
        protected override void DrawView(CellSurface surface)
        {
            base.DrawView(surface);

            surface.Print(2, 1, "Player Status");

            surface.Fill(1, 2, Width - 2, FrameColor, DefaultBackground, Glyphs.GetGlyph('─'));
            surface.Print(0, 2, new ColoredGlyph(Glyphs.GetGlyph('╟'), FrameColor, DefaultBackground));
            surface.Print(Width - 1, 2, new ColoredGlyph(Glyphs.GetGlyph('╢'), FrameColor, DefaultBackground));

            PrintProtection(2, 4, surface);
            PrintPlayerStats(25, 4, surface);
            PrintWeapon(2, 20, surface);
        }
Пример #6
0
        private void DrawStats(CellSurface surface)
        {
            surface.Print(2, 1, "Player Status");
            surface.Fill(1, 2, Width - 1, FrameColor, BackgroundColor, Glyphs.GetGlyph('─'));
            surface.DrawVerticalLine(0, 0, Height,
                                     new ColoredGlyph(Glyphs.GetGlyph('│'), FrameColor, BackgroundColor));
            surface.Print(0, 2, new ColoredGlyph(Glyphs.GetGlyph('├'), FrameColor, BackgroundColor));

            surface.Print(2, 3, $"Health [{game.Player.Health} / {game.Player.MaxHealth}]");

            surface.Print(2, 6, $"Mana [{game.Player.Mana} / {game.Player.MaxMana}]");

            surface.Print(2, 9, $"Stamina [{game.Player.Stamina} / {game.Player.MaxStamina}]");

            surface.Print(2, 12, $"Hunger [{game.Player.HungerPercent}%]");
        }
Пример #7
0
        protected override void DrawView(CellSurface surface)
        {
            base.DrawView(surface);

            surface.Print(2, 1, InventoryName);

            surface.Fill(1, 2, Width - 2, FrameColor, DefaultBackground, Glyphs.GetGlyph('─'));
            surface.Print(0, 2, new ColoredGlyph(Glyphs.GetGlyph('╟'), FrameColor, DefaultBackground));
            surface.Print(Width - 1, 2, new ColoredGlyph(Glyphs.GetGlyph('╢'), FrameColor, DefaultBackground));

            surface.Print(Width - 54, 2, new ColoredGlyph(Glyphs.GetGlyph('┬'), FrameColor, DefaultBackground));
            surface.Print(Width - 54, Height - 1, new ColoredGlyph(Glyphs.GetGlyph('╧'), FrameColor, DefaultBackground));
            surface.DrawVerticalLine(Width - 54, 3, Height - 4, new ColoredGlyph(Glyphs.GetGlyph('│'), FrameColor, DefaultBackground));

            surface.Print(Width - 54, 4, new ColoredGlyph(Glyphs.GetGlyph('├'), FrameColor, DefaultBackground));
            surface.Print(Width - 1, 4, new ColoredGlyph(Glyphs.GetGlyph('╢'), FrameColor, DefaultBackground));
        }
Пример #8
0
        public void Draw(CellSurface surface, int y, int maxWidth, bool selected)
        {
            var backColor = selected ? SelectedItemBackColor : DefaultBackColor;

            surface.Fill(0, y, maxWidth, null, backColor, null);

            var indexText = BookIndex < 9 ? $"0{BookIndex + 1}" : $"{BookIndex + 1}";

            surface.Print(1, y, indexText, new Cell(SpellIndexColor, backColor));

            var spellName      = Spell?.Name ?? EmptySpellName;
            var spellNameColor = Spell == null ? EmptySpellNameColor : SpellNameColor;

            surface.Print(4, y, spellName, new Cell(spellNameColor, backColor));

            var manaCost = GetManaCostText();

            surface.Print(maxWidth - 5, y, manaCost, new Cell(TextHelper.ManaColor.ToXna(), backColor));
        }
Пример #9
0
        protected override void DrawView(CellSurface surface)
        {
            base.DrawView(surface);

            surface.Print(2, 1, "Spell Book:");
            surface.Print(14, 1, new ColoredString(SpellBook.Name, ItemDrawingHelper.GetItemColor(SpellBook).ToXna(), DefaultBackground));

            surface.Fill(1, 2, Width - 2, FrameColor, DefaultBackground, Glyphs.GetGlyph('─'));
            surface.Print(0, 2, new ColoredGlyph(Glyphs.GetGlyph('╟'), FrameColor, DefaultBackground));
            surface.Print(Width - 1, 2, new ColoredGlyph(Glyphs.GetGlyph('╢'), FrameColor, DefaultBackground));

            surface.Print(Width - 59, 2, new ColoredGlyph(Glyphs.GetGlyph('┬'), FrameColor, DefaultBackground));
            surface.Print(Width - 59, Height - 1, new ColoredGlyph(Glyphs.GetGlyph('╧'), FrameColor, DefaultBackground));
            surface.DrawVerticalLine(Width - 59, 3, Height - 4, new ColoredGlyph(Glyphs.GetGlyph('│'), FrameColor, DefaultBackground));

            if (spellDetails.IsVisible)
            {
                surface.Print(Width - 59, 4, new ColoredGlyph(Glyphs.GetGlyph('├'), FrameColor, DefaultBackground));
                surface.Print(Width - 1, 4, new ColoredGlyph(Glyphs.GetGlyph('╢'), FrameColor, DefaultBackground));
            }
        }
Пример #10
0
        protected override void DrawView(CellSurface surface)
        {
            base.DrawView(surface);

            surface.Print(2, 3, "Filter:");

            surface.Print(2, 1, "Spells Library");

            surface.Fill(1, 2, Width - 2, FrameColor, DefaultBackground, Glyphs.GetGlyph('─'));
            surface.Print(0, 2, new ColoredGlyph(Glyphs.GetGlyph('╟'), FrameColor, DefaultBackground));
            surface.Print(Width - 1, 2, new ColoredGlyph(Glyphs.GetGlyph('╢'), FrameColor, DefaultBackground));

            surface.Print(Width - 59, 2, new ColoredGlyph(Glyphs.GetGlyph('┬'), FrameColor, DefaultBackground));
            surface.Print(Width - 59, Height - 1, new ColoredGlyph(Glyphs.GetGlyph('╧'), FrameColor, DefaultBackground));
            surface.DrawVerticalLine(Width - 59, 3, Height - 4, new ColoredGlyph(Glyphs.GetGlyph('│'), FrameColor, DefaultBackground));

            if (spellDetails.IsVisible)
            {
                surface.Print(Width - 59, 4, new ColoredGlyph(Glyphs.GetGlyph('├'), FrameColor, DefaultBackground));
                surface.Print(Width - 1, 4, new ColoredGlyph(Glyphs.GetGlyph('╢'), FrameColor, DefaultBackground));
            }
        }
Пример #11
0
        public void Draw(CellSurface surface, int y, int maxWidth, bool selected)
        {
            var backColor = selected ? SelectedItemBackColor : DefaultBackColor;

            surface.Fill(0, y, maxWidth, null, backColor, null);

            var text = GetNameText(selected, backColor);

            var afterNameText = new List <ColoredString>();

            if (Stack.TopItem is DurableItem durableItem)
            {
                var durabilityColor = TextHelper.GetDurabilityColor(durableItem.Durability, durableItem.MaxDurability);
                afterNameText.Add(new ColoredString(
                                      new ColoredGlyph(Glyphs.GetGlyph('•'), durabilityColor.ToXna(), backColor)));
            }
            afterNameText.AddRange(GetAfterNameText(backColor));
            var formattedText = FormatText(text, afterNameText.ToArray(), backColor, maxWidth - 1);

            surface.Print(1, y, formattedText);
            surface.PrintStyledText(1 + formattedText.Count, y, afterNameText.ToArray());
            surface.Print(maxWidth - 6, y, new ColoredString(GetWeightText(), WeightColor, backColor));
        }
Пример #12
0
        /// <summary>
        /// Converts a <see cref="TileLayer"/> to a <see cref="CellSurface"/>.
        /// </summary>
        /// <returns>The convereted surface.</returns>
        public CellSurface ToCellSurface()
        {
            var cells = new CellSurface(Tiles.GetUpperBound(1), Tiles.GetUpperBound(0));
            var transparentColor = new Microsoft.Xna.Framework.Color(255, 0, 255);
            cells.Fill(Microsoft.Xna.Framework.Color.Black, Microsoft.Xna.Framework.Color.Transparent, 0, null);

            for (int y = 0; y < cells.Height; y++)
            {
                for (int x = 0; x < cells.Width; x++)
                {
                    var tile = Tiles[y, x];
                    var backgroundColor = new Microsoft.Xna.Framework.Color(tile.BackgroundRed, tile.BackgroundGreen, tile.BackgroundBlue);
                    if (backgroundColor != transparentColor)
                    {
                        var cell = cells[x, y];
                        cell.CharacterIndex = tile.CharacterCode;
                        cell.Foreground = new Microsoft.Xna.Framework.Color(tile.ForegroundRed, tile.ForegroundGreen, tile.ForegroundBlue);
                        cell.Background = backgroundColor; 
                    }
                }
            }

            return cells;
        }
Пример #13
0
        private void DrawBrush(CellSurface surface)
        {
            const int dX = 4;
            const int dY = 2;

            surface.Print(1, dY, "Brush:");
            surface.Print(dX, dY + 1, "Symbol: ");
            if (brush.Symbol.HasValue)
            {
                surface.Fill(dX + 8, dY + 1, 5, Color.White, Color.Black, ' ');
                surface.Print(dX + 8, dY + 1, new ColoredGlyph(brush.Symbol.Value));
                surface.Print(dX + 10, dY + 1, brush.Symbol.ToString());
            }
            else
            {
                surface.Fill(dX + 8, dY + 1, 5, Color.White, Color.Black, ' ');
                surface.Print(dX + 8, dY + 1, "null");
            }

            surface.Print(dX, dY + 2, "Fore: ");
            if (brush.ForeColor.HasValue)
            {
                surface.Fill(dX + 6, dY + 2, 5, Color.White, Color.Black, ' ');
                surface.Print(dX + 6, dY + 2, new ColoredGlyph(' ', Color.White, brush.ForeColor.Value.ToXna()));
            }
            else
            {
                surface.Fill(dX + 6, dY + 2, 5, Color.White, Color.Black, ' ');
                surface.Print(dX + 6, dY + 2, "null");
            }

            surface.Print(dX, dY + 3, "Back: ");
            if (brush.BackColor.HasValue)
            {
                surface.Fill(dX + 6, dY + 3, 5, Color.White, Color.Black, ' ');
                surface.Print(dX + 6, dY + 3, new ColoredGlyph(' ', Color.White, brush.BackColor.Value.ToXna()));
            }
            else
            {
                surface.Fill(dX + 6, dY + 3, 5, Color.White, Color.Black, ' ');
                surface.Print(dX + 6, dY + 3, "null");
            }
        }
Пример #14
0
 /// <summary>
 /// Draws the theme to the console.
 /// </summary>
 /// <param name="console">Console associated with the theme.</param>
 /// <param name="hostSurface">Surface used for drawing.</param>
 public virtual void Draw(ControlsConsole console, CellSurface hostSurface)
 {
     hostSurface.DefaultForeground = FillStyle.Foreground;
     hostSurface.DefaultBackground = FillStyle.Background;
     hostSurface.Fill(hostSurface.DefaultForeground, hostSurface.DefaultBackground, FillStyle.Glyph, null);
 }