/// <summary>
        /// Gets the appearance of a cell.
        /// </summary>
        /// <param name="x">The x location of the cell.</param>
        /// <param name="y">The y location of the cell.</param>
        /// <returns>The appearance.</returns>
        public ICellAppearance GetCellAppearance(int x, int y)
        {
            CellAppearance appearance = new CellAppearance();

            textSurface.Cells[y * textSurface.Width + x].CopyAppearanceTo(appearance);
            return(appearance);
        }
Beispiel #2
0
 public GameObject()
 {
     Settings  = new List <Setting>();
     Character = new CellAppearance();
     Character.CharacterIndex = 1;
     Name = "New";
 }
Beispiel #3
0
        public override void DetermineAppearance()
        {
            CellAppearance currentappearanceEnds   = _currentAppearanceEnds;
            CellAppearance currentappearanceBar    = _currentAppearanceBar;
            CellAppearance currentappearanceSlider = _currentAppearanceSlider;

            if (!isEnabled)
            {
                _currentAppearanceEnds   = Theme.Ends.Disabled;
                _currentAppearanceBar    = Theme.Bar.Disabled;
                _currentAppearanceSlider = Theme.Slider.Disabled;
            }
            else if (isMouseOver)
            {
                _currentAppearanceEnds   = Theme.Ends.MouseOver;
                _currentAppearanceBar    = Theme.Bar.MouseOver;
                _currentAppearanceSlider = Theme.Slider.MouseOver;
            }
            else if (!isMouseOver)
            {
                _currentAppearanceEnds   = Theme.Ends.Normal;
                _currentAppearanceBar    = Theme.Bar.Normal;
                _currentAppearanceSlider = Theme.Slider.Normal;
            }

            if (currentappearanceEnds != _currentAppearanceEnds ||
                currentappearanceBar != _currentAppearanceBar ||
                currentappearanceSlider != _currentAppearanceSlider)
            {
                this.IsDirty = true;
            }
        }
Beispiel #4
0
 public MapObject(Color foreground, Color background, int character)
 {
     Appearance  = new CellAppearance(foreground, background, character);
     BlocksLight = true;
     BlocksMove  = true;
     Desctiption = "Base MapObject";
 }
Beispiel #5
0
        /// <summary>
        /// Sets the appearance of the control depending on the current state of the control.
        /// </summary>
        public override void DetermineAppearance()
        {
            CellAppearance currentappearance = currentAppearance;

            if (!isEnabled)
            {
                currentAppearance = Theme.Disabled;
            }

            else if (!isMouseDown && isMouseOver)
            {
                currentAppearance = Theme.MouseOver;
            }

            else if (!isMouseDown && !isMouseOver && IsFocused && Engine.ActiveConsole == parent)
            {
                currentAppearance = Theme.Focused;
            }

            else if (isMouseDown && isMouseOver)
            {
                currentAppearance = Theme.MouseClicking;
            }

            else
            {
                currentAppearance = Theme.Normal;
            }

            if (currentappearance != currentAppearance)
            {
                IsDirty = true;
            }
        }
Beispiel #6
0
        /// <summary>
        /// Draws the line shape across all of the cells. Will not draw the effect. Must be done outside of this method.
        /// </summary>
        /// <param name="cells">The cells to draw on.</param>
        public void Draw(IEnumerable <Cell> cells)
        {
            List <Cell> newCells = new List <Cell>(cells);

            if (newCells.Count > 1)
            {
                if (UseStartingCell)
                {
                    StartingCellAppearance.Copy(newCells[0]);
                }
                else
                {
                    CellAppearance.Copy(newCells[0]);
                }

                if (UseEndingCell)
                {
                    EndingCellAppearance.Copy(newCells[newCells.Count - 1]);
                }
                else
                {
                    CellAppearance.Copy(newCells[newCells.Count - 1]);
                }

                for (int i = 1; i < newCells.Count - 1; i++)
                {
                    CellAppearance.Copy(newCells[i]);
                }
            }
            else if (newCells.Count == 1)
            {
                CellAppearance.Copy(newCells[0]);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Creates a new instance of the line class with default values.
        /// </summary>
        public Line()
        {
            var colors = new CellAppearance(Color.White, Color.Black);

            StartingCellAppearance = new Cell()
            {
                Background = colors.Background,
                Foreground = colors.Foreground,
                GlyphIndex = 195
            };
            EndingCellAppearance = new Cell()
            {
                Background = colors.Background,
                Foreground = colors.Foreground,
                GlyphIndex = 180
            };
            CellAppearance = new Cell()
            {
                Background = colors.Background,
                Foreground = colors.Foreground,
                GlyphIndex = 196
            };

            UseStartingCell = true;
            UseEndingCell   = true;
        }
Beispiel #8
0
        public MapObjectBase(Color foreground, Color background, int character)
        {
            Appearance = new CellAppearance(foreground, background, character);
            Info       = new TileInfo();

            Info.IsInFOV    = false;
            Info.IsExplored = false;

            Info.Description = "MapbjectBase";

            EffectExplored = new Recolor()
            {
                Foreground   = Color.LightGray * 0.4f,
                Background   = Color.LightGray * 0.1f,
                DoForeground = true,
                DoBackground = true,
                CloneOnApply = false
            };

            EffectHidden = new Recolor()
            {
                Foreground   = Color.Black,
                Background   = Color.Black,
                DoForeground = true,
                DoBackground = true,
                CloneOnApply = false
            };
        }
Beispiel #9
0
        /// <summary>
        /// Creates a new instance of the line class with default values.
        /// </summary>
        public Line()
        {
            var colors = new CellAppearance(Color.White, Color.Black);
            StartingCellAppearance = new Cell()
            {
                Background = colors.Background,
                Foreground = colors.Foreground,
                CharacterIndex = 195
            };
            EndingCellAppearance = new Cell()
            {
                Background = colors.Background,
                Foreground = colors.Foreground,
                CharacterIndex = 180
            };
            CellAppearance = new Cell()
            {
                Background = colors.Background,
                Foreground = colors.Foreground,
                CharacterIndex = 196
            };

            UseStartingCell = true;
            UseEndingCell = true;
        }
Beispiel #10
0
        private void Constructor()
        {
            IsVisible = false;
            AutomaticallyShiftRowsUp = true;

            PrintAppearance = new CellAppearance(Color.White, Color.Black);

            CursorRenderCell            = new Cell();
            CursorRenderCell.GlyphIndex = _cursorCharacter;
            CursorRenderCell.Foreground = Color.White;
            CursorRenderCell.Background = Color.Transparent;

            ResetCursorEffect();
        }
Beispiel #11
0
        /// <summary>
        /// Creates a new instance of the cursor class that will work with the specified console.
        /// </summary>
        /// <param name="console">The console this cursor will print on.</param>
        public Cursor(SurfaceEditor console)
        {
            _console  = new WeakReference(console);
            IsVisible = false;

            PrintAppearance          = new CellAppearance(Color.White, Color.Black);
            AutomaticallyShiftRowsUp = true;

            CursorRenderCell            = new Cell();
            CursorRenderCell.GlyphIndex = _cursorCharacter;
            CursorRenderCell.Foreground = Color.White;
            CursorRenderCell.Background = Color.Transparent;

            ResetCursorEffect();
        }
Beispiel #12
0
        public RenderComponent(int owner, CellAppearance appearance, int layer = 0)
        {
            OwnerID    = owner;
            Appearance = appearance;
            Layer      = layer;

            Explored = new Recolor()
            {
                Foreground   = Color.LightGray * 0.3f,
                Background   = Color.LightGray * 0.3f,
                DoForeground = true,
                DoBackground = true,
                CloneOnApply = false
            };
        }
Beispiel #13
0
        /// <summary>
        /// Resets the cursor appearance to the console's default foreground and background.
        /// </summary>
        /// <returns>This cursor object.</returns>
        /// <exception cref="Exception">Thrown when the backing console's CellData is null.</exception>
        public Cursor ResetAppearanceToConsole()
        {
            var console = ((SurfaceEditor)_console.Target);

            if (console.TextSurface != null)
            {
                PrintAppearance = new CellAppearance(console.TextSurface.DefaultForeground, console.TextSurface.DefaultBackground);
            }
            else
            {
                throw new Exception("CellData of the attached console is null. Cannot reset appearance.");
            }

            return(this);
        }
Beispiel #14
0
        /// <summary>
        /// Determines the appearance of the control based on its current state.
        /// </summary>
        public override void DetermineAppearance()
        {
            CellAppearance currentappearanceButton = _currentAppearanceButton;
            CellAppearance currentappearanceText   = _currentAppearanceText;

            if (!isEnabled)
            {
                _currentAppearanceButton = Theme.Button.Disabled;
                _currentAppearanceText   = Theme.Disabled;
            }

            else if (!_isMouseDown && isMouseOver)
            {
                _currentAppearanceButton = Theme.Button.MouseOver;
                _currentAppearanceText   = Theme.MouseOver;
            }

            else if (!_isMouseDown && !isMouseOver && IsFocused && Engine.ActiveConsole == parent)
            {
                _currentAppearanceButton = Theme.Button.Focused;
                _currentAppearanceText   = Theme.Focused;
            }

            else if (_isMouseDown && isMouseOver)
            {
                _currentAppearanceButton = Theme.Button.MouseClicking;
                _currentAppearanceText   = Theme.MouseClicking;
            }

            else if (_isSelected)
            {
                _currentAppearanceButton = Theme.Button.Selected;
                _currentAppearanceText   = Theme.Selected;
            }

            else
            {
                _currentAppearanceButton = Theme.Button.Normal;
                _currentAppearanceText   = Theme.Normal;
            }

            if (currentappearanceButton != _currentAppearanceButton ||
                currentappearanceText != _currentAppearanceText)
            {
                this.IsDirty = true;
            }
        }
Beispiel #15
0
            /// <summary>
            /// Creates a new instance of the cursor class that will work with the specified console.
            /// </summary>
            /// <param name="console">The console this cursor will print on.</param>
            public Cursor(Console console)
            {
                _console = new WeakReference(console);
                IsVisible = false;

                SadConsole.Effects.Blink blinkEffect = new Effects.Blink();
                blinkEffect.BlinkSpeed = 0.35f;

                PrintAppearance = new CellAppearance(Color.White, Color.Black);
                AutomaticallyShiftRowsUp = true;

                CursorRenderCell = new Cell();
                CursorRenderCell.CharacterIndex = _cursorCharacter;
                CursorRenderCell.Effect = blinkEffect;
                CursorRenderCell.Foreground = Color.White;
                CursorRenderCell.Background = Color.Transparent;
            }
            /// <summary>
            /// Creates a new instance of the cursor class that will work with the specified console.
            /// </summary>
            /// <param name="console">The console this cursor will print on.</param>
            public Cursor(Console console)
            {
                _console  = new WeakReference(console);
                IsVisible = false;

                SadConsole.Effects.Blink blinkEffect = new Effects.Blink();
                blinkEffect.BlinkSpeed = 0.35f;

                PrintAppearance          = new CellAppearance(Color.White, Color.Black);
                AutomaticallyShiftRowsUp = true;

                CursorRenderCell = new Cell();
                CursorRenderCell.CharacterIndex = _cursorCharacter;
                CursorRenderCell.Effect         = blinkEffect;
                CursorRenderCell.Foreground     = Color.White;
                CursorRenderCell.Background     = Color.Transparent;
            }
Beispiel #17
0
 public static int CreatePlayer()
 {
     if (playerCreated == false)
     {
         //Player = CreateEntity(); //Create Player
         playerCreated = true;
         int Player = 0;
         _entities[0] = Player;
         CellAppearance  ca = new CellAppearance(Colors.Player, Colors.FloorBackgroundFov, 64);
         RenderComponent rc = new RenderComponent(Player, ca, 2);
         ComponentManager.AddComponent(Player, rc);
         PositionComponent pc = new PositionComponent(Player, new Point(0, 0));
         ComponentManager.AddComponent(Player, pc);
         PlayerControlComponent pcc = new PlayerControlComponent(Player);
         ComponentManager.AddComponent(Player, pcc);
     }
     return(0);
 }
Beispiel #18
0
 public Door(bool closed) : base(Colors.Floor, Colors.FloorBackground, 43)
 {
     Closed = closed;
     if (closed)
     {
         BlocksLight = true;
         BlocksMove  = true;
         Desctiption = "Firmly closed door with a tiny keyhole.";
     }
     else
     {
         Appearance  = new CellAppearance(Colors.Floor, Colors.FloorBackground, 46);
         BlocksLight = false;
         BlocksMove  = false;
         Desctiption = "There is a open door.";
     }
     InFOV    = false;
     Explored = false;
 }
Beispiel #19
0
        /// <summary>
        /// Draws the line shape.
        /// </summary>
        /// <param name="surface">The cell surface to draw on.</param>
        public void Draw(SurfaceEditor surface)
        {
            List <Cell> cells = new List <Cell>();

            Algorithms.Line(StartingLocation.X, StartingLocation.Y, EndingLocation.X, EndingLocation.Y, (x, y) => { cells.Add(surface[x, y]); return(true); });

            if (cells.Count > 1)
            {
                if (UseStartingCell)
                {
                    StartingCellAppearance.Copy(cells[0]);
                    cells[0].Effect = StartingCellAppearance.Effect;
                }
                else
                {
                    CellAppearance.Copy(cells[0]);
                    cells[0].Effect = StartingCellAppearance.Effect;
                }

                if (UseEndingCell)
                {
                    EndingCellAppearance.Copy(cells[cells.Count - 1]);
                    cells[cells.Count - 1].Effect = EndingCellAppearance.Effect;
                }
                else
                {
                    CellAppearance.Copy(cells[cells.Count - 1]);
                    cells[cells.Count - 1].Effect = CellAppearance.Effect;
                }

                for (int i = 1; i < cells.Count - 1; i++)
                {
                    CellAppearance.Copy(cells[i]);
                    cells[i].Effect = CellAppearance.Effect;
                }
            }
            else if (cells.Count == 1)
            {
                CellAppearance.Copy(cells[0]);
                cells[0].Effect = CellAppearance.Effect;
            }
        }
Beispiel #20
0
        public MapObjectBase(Color foreground, Color background, int character)
        {
            Appearance = new CellAppearance(foreground, background, character);
            EffectSeen = new Recolor()
            {
                Foreground   = Color.LightGray * 0.3f,
                Background   = Color.LightGray * 0.3f,
                DoForeground = true,
                DoBackground = true,
                CloneOnApply = false
            };

            EffectHidden = new Recolor()
            {
                Foreground   = Color.Black,
                Background   = Color.Black,
                DoForeground = true,
                DoBackground = true,
                CloneOnApply = false
            };
        }
Beispiel #21
0
        public override void Draw(ITextSurface surface, Rectangle area)
        {
            if (Item is Color || Item is Tuple <Color, Color, string> )
            {
                var    editor = new SurfaceEditor(surface);
                string value  = new string(' ', area.Width - 2);

                CellAppearance cellLook = _currentAppearance.Clone();

                if (Item is Color)
                {
                    cellLook.Background = (Color)Item;
                    editor.Print(area.Left + 1, area.Top, value, cellLook);
                }
                else
                {
                    cellLook.Foreground = ((Tuple <Color, Color, string>)Item).Item2;
                    cellLook.Background = ((Tuple <Color, Color, string>)Item).Item1;
                    value = ((Tuple <Color, Color, string>)Item).Item3.Align(HorizontalAlignment.Left, area.Width - 2);
                    editor.Print(area.Left + 1, area.Top, value, cellLook);
                }

                editor.Print(area.Left, area.Top, " ", _currentAppearance);
                editor.Print(area.Left + area.Width - 1, area.Top, " ", _currentAppearance);

                if (IsSelected)
                {
                    editor.SetGlyph(area.Left, area.Top, 16);
                    editor.SetGlyph(area.Left + area.Width - 1, area.Top, 17);
                }

                IsDirty = false;
            }
            else
            {
                base.Draw(surface, area);
            }
        }
Beispiel #22
0
        /// <summary>
        /// Determines the appearance of the control based on its current state.
        /// </summary>
        public override void DetermineAppearance()
        {
            CellAppearance currentappearance = _currentAppearance;

            if (_isMouseOver)
            {
                _currentAppearance = Theme.MouseOver;
            }

            else if (base.IsFocused && Engine.ActiveConsole == _parent)
            {
                _currentAppearance = Theme.Focused;
            }
            else
            {
                _currentAppearance = Theme.Normal;
            }

            if (currentappearance != _currentAppearance)
            {
                IsDirty = true;
            }
        }
Beispiel #23
0
        public override void Draw(CellSurface surface, Rectangle area)
        {
            if (Item is Color || Item is Tuple <Color, Color, string> )
            {
                string value = new string(' ', area.Width - 2);

                CellAppearance cellLook = _currentAppearance.Clone();

                if (Item is Color)
                {
                    cellLook.Background = (Color)Item;
                    surface.Print(area.X + 1, area.Y, value, cellLook);
                }
                else
                {
                    cellLook.Foreground = ((Tuple <Color, Color, string>)Item).Item2;
                    cellLook.Background = ((Tuple <Color, Color, string>)Item).Item1;
                    value = ((Tuple <Color, Color, string>)Item).Item3.Align(HorizontalAlignment.Left, area.Width - 2);
                    surface.Print(area.X + 1, area.Y, value, cellLook);
                }

                surface.Print(area.X, area.Y, " ", _currentAppearance);
                surface.Print(area.X + area.Width - 1, area.Y, " ", _currentAppearance);

                if (IsSelected)
                {
                    surface.SetCharacter(area.X, area.Y, 16);
                    surface.SetCharacter(area.X + area.Width - 1, area.Y, 17);
                }

                IsDirty = false;
            }
            else
            {
                base.Draw(surface, area);
            }
        }
Beispiel #24
0
        protected virtual void DetermineAppearance()
        {
            CellAppearance currentappearance = _currentAppearance;

            if (_isSelected)
            {
                _currentAppearance = Theme.Selected;
            }

            else if (_isMouseOver)
            {
                _currentAppearance = Theme.MouseOver;
            }

            else
            {
                _currentAppearance = Theme.Normal;
            }

            if (currentappearance != _currentAppearance)
            {
                IsDirty = true;
            }
        }
Beispiel #25
0
 public GuiHighLight(  )
 {
     Appearance = new CellAppearance(Color.Yellow, Color.LightYellow, 177);
 }
Beispiel #26
0
        private void Constructor()
        {
            IsVisible = false;
            AutomaticallyShiftRowsUp = true;

            PrintAppearance = new CellAppearance(Color.White, Color.Black);

            CursorRenderCell = new Cell();
            CursorRenderCell.GlyphIndex = _cursorCharacter;
            CursorRenderCell.Foreground = Color.White;
            CursorRenderCell.Background = Color.Transparent;

            ResetCursorEffect();
        }
Beispiel #27
0
        /// <summary>
        /// Determines the appearance of the control based on its current state.
        /// </summary>
        public override void DetermineAppearance()
        {
            CellAppearance currentappearance = _currentAppearance;

            if (_isMouseOver)
                _currentAppearance = Theme.MouseOver;

            else if (base.IsFocused && Engine.ActiveConsole == _parent)
                _currentAppearance = Theme.Focused;
            else
                _currentAppearance = Theme.Normal;

            if (currentappearance != _currentAppearance)
                IsDirty = true;
        }
Beispiel #28
0
        public override void DetermineAppearance()
        {
            CellAppearance currentappearanceEnds = _currentAppearanceEnds;
            CellAppearance currentappearanceBar = _currentAppearanceBar;
            CellAppearance currentappearanceSlider = _currentAppearanceSlider;

            if (!_isEnabled)
            {
                _currentAppearanceEnds = Theme.Ends.Disabled;
                _currentAppearanceBar = Theme.Bar.Disabled;
                _currentAppearanceSlider = Theme.Slider.Disabled;
            }
            else if (_isMouseOver)
            {
                _currentAppearanceEnds = Theme.Ends.MouseOver;
                _currentAppearanceBar = Theme.Bar.MouseOver;
                _currentAppearanceSlider = Theme.Slider.MouseOver;
            }
            else if (!_isMouseOver)
            {
                _currentAppearanceEnds = Theme.Ends.Normal;
                _currentAppearanceBar = Theme.Bar.Normal;
                _currentAppearanceSlider = Theme.Slider.Normal;
            }

            if (currentappearanceEnds != _currentAppearanceEnds ||
                currentappearanceBar != _currentAppearanceBar ||
                currentappearanceSlider != _currentAppearanceSlider)

                this.IsDirty = true;
        }
Beispiel #29
0
            /// <summary>
            /// Resets the cursor appearance to the console's default foreground and background.
            /// </summary>
            /// <returns>This cursor object.</returns>
            /// <exception cref="Exception">Thrown when the backing console's CellData is null.</exception>
            public Cursor ResetAppearanceToConsole()
            {
                Console console = ((Console)_console.Target);

                if (console.CellData != null)
                    PrintAppearance = new CellAppearance(console.CellData.DefaultForeground, console.CellData.DefaultBackground);
                else
                    throw new Exception("CellData of the attached console is null. Cannot reset appearance.");

                return this;
            }
Beispiel #30
0
        /// <summary>
        /// Sets the appearance of the control depending on the current state of the control.
        /// </summary>
        public override void DetermineAppearance()
        {
            CellAppearance currentappearance = _currentAppearance;

            if (!_isEnabled)
                _currentAppearance = Theme.Disabled;

            else if (!_isMouseDown && _isMouseOver)
                _currentAppearance = Theme.MouseOver;

            else if (!_isMouseDown && !_isMouseOver && IsFocused && Engine.ActiveConsole == _parent)
                _currentAppearance = Theme.Focused;

            else if (_isMouseDown && _isMouseOver)
                _currentAppearance = Theme.MouseClicking;

            else
                _currentAppearance = Theme.Normal;

            if (currentappearance != _currentAppearance)
                IsDirty = true;
        }
Beispiel #31
0
 public Monster() : base()
 {
     Appearance = new CellAppearance(Color.GreenYellow, Color.TransparentBlack, 'T');
     Info       = new ActorInfo("Generic Troll", 0, 4);
 }
Beispiel #32
0
 public MapObject(CellAppearance appearance)
 {
     Appearance   = appearance;
     EffectHidden = EffectHiddenDefault;
     EffectSeen   = EffectSeenDefault;
 }
Beispiel #33
0
 public Hero() : base()
 {
     Appearance = new CellAppearance(Color.White, Color.Black, '@');
     Info       = new ActorInfo("Donk", 0, 7);
     SightRange = 8;
 }
Beispiel #34
0
 public void SetCellAppearance(CellAppearance appearance)
 {
     Appearance = appearance;
     Changed    = true;
 }
Beispiel #35
0
        /// <summary>
        /// Determines the appearance of the control based on its current state.
        /// </summary>
        public override void DetermineAppearance()
        {
            CellAppearance currentappearanceButton = _currentAppearanceButton;
            CellAppearance currentappearanceText = _currentAppearanceText;

            if (!isEnabled)
            {
                _currentAppearanceButton = Theme.Button.Disabled;
                _currentAppearanceText = Theme.Disabled;
            }

            else if (!_isMouseDown && isMouseOver)
            {
                _currentAppearanceButton = Theme.Button.MouseOver;
                _currentAppearanceText = Theme.MouseOver;
            }

            else if (!_isMouseDown && !isMouseOver && IsFocused && Engine.ActiveConsole == parent)
            {
                _currentAppearanceButton = Theme.Button.Focused;
                _currentAppearanceText = Theme.Focused;
            }

            else if (_isMouseDown && isMouseOver)
            {
                _currentAppearanceButton = Theme.Button.MouseClicking;
                _currentAppearanceText = Theme.MouseClicking;
            }

            else if (_isSelected)
            {
                _currentAppearanceButton = Theme.Button.Selected;
                _currentAppearanceText = Theme.Selected;
            }

            else
            {
                _currentAppearanceButton = Theme.Button.Normal;
                _currentAppearanceText = Theme.Normal;
            }

            if (currentappearanceButton != _currentAppearanceButton ||
                currentappearanceText != _currentAppearanceText)

                this.IsDirty = true;
        }
Beispiel #36
0
 /// <summary>
 /// Gets the appearance of a cell.
 /// </summary>
 /// <param name="x">The x location of the cell.</param>
 /// <param name="y">The y location of the cell.</param>
 /// <returns>The appearance.</returns>
 public ICellAppearance GetCellAppearance(int x, int y)
 {
     CellAppearance appearance = new CellAppearance();
     textSurface.Cells[y * textSurface.Width + x].CopyAppearanceTo(appearance);
     return appearance;
 }