Example #1
0
        public ViewsAndSubViews()
        {
            titleAndLine = new Console(80, 25);
            mainView = new Console(59, 24);
            subView = new Console(19, 24);

            IsVisible = false;

            // Draw border and line stuff
            titleAndLine.Print(0, 0, " View and Sub View".Align(System.Windows.HorizontalAlignment.Left, 80), ColorHelper.GreenYellow, ColorHelper.DarkGreen);
            SadConsole.Shapes.Line line = new SadConsole.Shapes.Line();
            line.UseStartingCell = false;
            line.UseEndingCell = false;
            line.CellAppearance.GlyphIndex = 179;
            line.StartingLocation = new Point(59, 1);
            line.EndingLocation = new Point(59, 24);
            line.Draw(titleAndLine);

            // Setup main view
            mainView.Position = new Point(0, 1);
            mainView.Print(1, 1, "Click on a cell to draw");
            mainView.MouseMove += (s, e) => { if (e.LeftButtonDown) e.Cell.Background = Color.Blue; };

            // Setup sub view
            subView.Position = new Point(60, 1);
            subView.TextSurface = new TextSurfaceView(mainView.TextSurface, new Rectangle(0, 0, 20, 24));
            subView.MouseMove += (s, e) => { if (e.LeftButtonDown) e.Cell.Background = Color.Red; };

            // Ad the consoles to the list.
            Add(titleAndLine);
            Add(mainView);
            Add(subView);
        }
Example #2
0
        public FadingExample()
        {
            // Simulate two consoles
            backgroundConsole = new Console(80, 25);
            foregroundConsole = new Console(80, 25);

            // To work with our sample project, all consoles default to not visible. If you're using this
            // on your own, outside of the starter project, delete this line.
            IsVisible = false;

            // Setup main view
            backgroundConsole.FillWithRandomGarbage();

            // Setup sub view
            // Normally the text surface uses a transparent background so you can easily layer. We don't want that.
            foregroundConsole.TextSurface.DefaultBackground = Color.Black;
            foregroundConsole.Clear();

            // Some visuals on the surface so we can see something fade.
            var border = SadConsole.Shapes.Box.GetDefaultBox();

            border.Location = new Point(0, 0);
            border.Width    = 80;
            border.Height   = 25;
            border.Draw(foregroundConsole);

            for (int y = 2; y < 23; y += 2)
            {
                foregroundConsole.Print(9, y, "This is a console that will fade, showing whatever is beind it", Color.Black.GetRandomColor(SadConsole.Engine.Random));
            }

            foregroundConsole.Print(2, 0, "[c:r f:Black][c:r b:White]  PRESS SPACE TO START FADE  ");

            // Console has been drawn on and is ready to be cached for the fade.
            foregroundConsole.Renderer = new SadConsole.Consoles.CachedTextSurfaceRenderer(foregroundConsole.TextSurface);

            // Because of the way the cached renderer handles tinting, we need to set tinting to white
            // This means "render the cahced surface exactly how it was originally drawn."
            foregroundConsole.TextSurface.Tint = Color.White;

            // Ad the consoles to the list.
            Add(backgroundConsole);
            Add(foregroundConsole);

            // Setup the fade animation to go from white to transparent in 2 seconds.
            tintFade = new SadConsole.Instructions.FadeTextSurfaceTint(foregroundConsole.TextSurface, new ColorGradient(Color.White, Color.Transparent), TimeSpan.FromSeconds(2));
        }
Example #3
0
        public FadingExample()
        {
            // Simulate two consoles
            backgroundConsole = new Console(80, 25);
            foregroundConsole = new Console(80, 25);

            // To work with our sample project, all consoles default to not visible. If you're using this
            // on your own, outside of the starter project, delete this line.
            IsVisible = false;

            // Setup main view
            backgroundConsole.FillWithRandomGarbage();

            // Setup sub view
            // Normally the text surface uses a transparent background so you can easily layer. We don't want that.
            foregroundConsole.TextSurface.DefaultBackground = Color.Black;
            foregroundConsole.Clear();

            // Some visuals on the surface so we can see something fade.
            var border = SadConsole.Shapes.Box.GetDefaultBox();
            border.Location = new Point(0, 0);
            border.Width = 80;
            border.Height = 25;
            border.Draw(foregroundConsole);

            for (int y = 2; y < 23; y += 2)
                foregroundConsole.Print(9, y, "This is a console that will fade, showing whatever is beind it", Color.Black.GetRandomColor(SadConsole.Engine.Random));

            foregroundConsole.Print(2, 0, "[c:r f:Black][c:r b:White]  PRESS SPACE TO START FADE  ");

            // Console has been drawn on and is ready to be cached for the fade.
            foregroundConsole.Renderer = new SadConsole.Consoles.CachedTextSurfaceRenderer(foregroundConsole.TextSurface);

            // Because of the way the cached renderer handles tinting, we need to set tinting to white
            // This means "render the cahced surface exactly how it was originally drawn."
            foregroundConsole.TextSurface.Tint = Color.White;

            // Ad the consoles to the list.
            Add(backgroundConsole);
            Add(foregroundConsole);

            // Setup the fade animation to go from white to transparent in 2 seconds.
            tintFade = new SadConsole.Instructions.FadeTextSurfaceTint(foregroundConsole.TextSurface, new ColorGradient(Color.White, Color.Transparent), TimeSpan.FromSeconds(2));
        }
Example #4
0
        public override void Render()
        {
            // These 3 render calls are a hack to get the console data generated and display a message to the user
            // Should add in async calls that let us generate these in the background... That would be cool.

            if (!initialized)
            {
                base.Render();
            }

            else if (!initializedStep2)
            {
                initializedStep2 = true;
                base.Render();
                messageData.Render();
            }
            else if (!initializedStep3)
            {
                base.Render();

                // Generate the content
                //mainData = new CellSurface(2000, 2000);

                // Clear message data and make it transparent so that it acts as a layer
                messageData.Fill(Color.White, Color.Transparent, 0, null);

                generator = new SadConsole.Game.WorldGeneration.WrappingWorldGenerator <SadConsole.Game.WorldGeneration.TextSurfaceMap, TextSurface>();
                generator.Start(512, 256);
                textSurface = generator.BiomeMapRenderer;
                messageData.Print(0, 0, $"[SPACE] Change Map Info [ENTER] New Map -- Biome   ", Color.White, Color.Black);
                textSurface.Font = Engine.Fonts[Engine.DefaultFont.Name].GetFont(SadConsole.Font.FontSizes.Half);

                initializedStep3 = true;
            }

            else
            {
                // Set message data information about where the viewport is located
                //messageData.CellData.Print(0, 0, $"{ViewArea.X} , {ViewArea.Y}            ", Color.White, Color.Black);

                // Create a faux layering system.
                base.Render();

                if (IsVisible)
                {
                    messageData.Render();
                }
            }
        }
Example #5
0
        private static void Engine_EngineStart(object sender, EventArgs e)
        {
            var defaultConsole = (Console)SadConsole.Engine.ActiveConsole;

            defaultConsole.TextSurface = new TextSurface(80, 12);
            defaultConsole.Fill(Color.Blue, Color.Yellow, 0);
            defaultConsole.Print(1, 1, "Hello from console 1");

            var console2 = new Console(80, 13);

            console2.Position = new Point(0, 12);
            console2.Fill(Color.Yellow, Color.Blue, 0);
            console2.Print(1, 1, "Hello from console 2");

            SadConsole.Engine.ConsoleRenderStack.Add(console2);

            SadConsole.Engine.ToggleFullScreen();
        }
Example #6
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Default constructor. </summary>
        ///
        /// <remarks>   Darrellp, 8/26/2016. </remarks>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public DungeonScreen()
        {
            StatsConsole = new CharacterConsole(24, 17);
            // ReSharper disable once RedundantArgumentDefaultValue
            DungeonConsole = new DungeonMapConsole(56, 16, 100, 100, Font.FontSizes.One);
            MessageConsole = new MessagesConsole(80, 6);

            // Setup the message header to be as wide as the screen but only 1 character high
            messageHeaderConsole = new Console(80, 1)
            {
                DoUpdate       = false,
                CanUseKeyboard = false,
                CanUseMouse    = false
            };

            // Draw the line for the header
            messageHeaderConsole.Fill(Color.White, Color.Black, 196, null);
            messageHeaderConsole.SetGlyph(56, 0, 193); // This makes the border match the character console's left-edge border

            // Print the header text
            messageHeaderConsole.Print(2, 0, " Messages ");

            // Move the rest of the consoles into position (DungeonConsole is already in position at 0,0)
            StatsConsole.Position         = new Point(56, 0);
            MessageConsole.Position       = new Point(0, 18);
            messageHeaderConsole.Position = new Point(0, 17);

            // Add all consoles to this console list.
            Add(messageHeaderConsole);
            Add(StatsConsole);
            Add(DungeonConsole);
            Add(MessageConsole);

            // Placeholder stuff for the stats screen
            StatsConsole.CharacterName = "Hydorn";
            StatsConsole.MaxHealth     = 200;
            StatsConsole.Health        = 100;

            Engine.ActiveConsole               = this;
            Engine.Keyboard.RepeatDelay        = 0.1f;
            Engine.Keyboard.InitialRepeatDelay = 0.1f;
        }
        public ViewsAndSubViews()
        {
            titleAndLine = new Console(80, 25);
            mainView     = new Console(59, 24);
            subView      = new Console(19, 24);

            IsVisible = false;

            // Draw border and line stuff
            titleAndLine.Print(0, 0, " View and Sub View".Align(System.Windows.HorizontalAlignment.Left, 80), ColorHelper.GreenYellow, ColorHelper.DarkGreen);
            SadConsole.Shapes.Line line = new SadConsole.Shapes.Line();
            line.UseStartingCell           = false;
            line.UseEndingCell             = false;
            line.CellAppearance.GlyphIndex = 179;
            line.StartingLocation          = new Point(59, 1);
            line.EndingLocation            = new Point(59, 24);
            line.Draw(titleAndLine);

            // Setup main view
            mainView.Position = new Point(0, 1);
            mainView.Print(1, 1, "Click on a cell to draw");
            mainView.MouseMove += (s, e) => { if (e.LeftButtonDown)
                                              {
                                                  e.Cell.Background = Color.Blue;
                                              }
            };

            // Setup sub view
            subView.Position    = new Point(60, 1);
            subView.TextSurface = new TextSurfaceView(mainView.TextSurface, new Rectangle(0, 0, 20, 24));
            subView.MouseMove  += (s, e) => { if (e.LeftButtonDown)
                                              {
                                                  e.Cell.Background = Color.Red;
                                              }
            };

            // Ad the consoles to the list.
            Add(titleAndLine);
            Add(mainView);
            Add(subView);
        }
Example #8
0
        public DungeonScreen()
        {
            InventoryConsole = new InventoryConsole(_inventoryWidth, _inventoryHeight);
            InventoryConsole.FillWithRandomGarbage();
            StatsConsole = new StatConsole(_statWidth, _statHeight);
            MapConsole   = new MapConsole(_mapWidth, _mapHeight, dungeonWidth, dungeonHeight);
            //MapConsole.FillWithRandomGarbage(); // Temporary so we can see where the console is on the screen
            MessageConsole = new MessagesConsole(_messageWidth, _messageHeight);

            SadConsole.Engine.Keyboard.RepeatDelay        = 0.07f;
            SadConsole.Engine.Keyboard.InitialRepeatDelay = 0.07f;

            // Setup the message header to be as wide as the screen but only 1 character high
            messageHeaderConsole                = new Console(_messageWidth, 1);
            messageHeaderConsole.DoUpdate       = false;
            messageHeaderConsole.CanUseKeyboard = false;
            messageHeaderConsole.CanUseMouse    = false;

            // Draw the line for the header
            messageHeaderConsole.Fill(Color.White, Color.Black, 196, null);
            messageHeaderConsole.SetGlyph(56, 0, 193); // This makes the border match the character console's left-edge border

            // Print the header text
            messageHeaderConsole.Print(2, 0, " Messages ");

            MapConsole.Position           = new Point(0, 0);
            StatsConsole.Position         = new Point(_messageWidth, 0);
            InventoryConsole.Position     = new Point(_messageWidth, _statHeight);
            MessageConsole.Position       = new Point(0, _mapHeight + 1);
            messageHeaderConsole.Position = new Point(0, _mapHeight);

            // Add all consoles to this console list.
            Add(messageHeaderConsole);
            Add(StatsConsole);
            Add(MapConsole);
            Add(MessageConsole);
            Add(InventoryConsole);

            SadConsole.Engine.ActiveConsole = this;
        }
Example #9
0
        public DungeonScreen()
        {
            InventoryConsole = new InventoryPanel("Inventory", _inventoryWidth, _inventoryHeight + 1);
            StatsConsole     = new StatsConsole(_statWidth, _statHeight);
            MessageConsole   = new MessagePanel(_messageWidth, _messageHeight);
            ViewConsole      = new MapConsole(_mapWidth, _mapHeight, _screenWidth, _screenHeight);
            //            InventoryConsole.FillWithRandomGarbage();

            // Setup the message header to be as wide as the screen but only 1 character high
            messageHeaderConsole                = new Console(_messageWidth + 1, 1);
            messageHeaderConsole.DoUpdate       = false;
            messageHeaderConsole.CanUseKeyboard = false;
            messageHeaderConsole.CanUseMouse    = false;

            // Draw the line for the header
            messageHeaderConsole.Fill(Color.White, Color.Black, 196, null);

            // Print the header text
            messageHeaderConsole.Print(2, 0, " Messages ");

            // Move the rest of the consoles  into position (ViewConsole is already in position at 0).
            InventoryConsole.Position     = new Point(112, _statHeight);
            StatsConsole.Position         = new Point(112, 0);
            MessageConsole.Position       = new Point(0, 36);
            messageHeaderConsole.Position = new Point(0, 34);

            // Add all consoles to this console list.
            Add(messageHeaderConsole);
            Add(StatsConsole);
            Add(ViewConsole);
            Add(MessageConsole);
            Add(InventoryConsole);

            SadConsole.Engine.ActiveConsole = this;

            // Keyboard stuff
            SadConsole.Engine.Keyboard.RepeatDelay        = 0.07f;
            SadConsole.Engine.Keyboard.InitialRepeatDelay = 0.1f;
        }
Example #10
0
        public DungeonScreen()
        {
            StatsConsole   = new CharacterStatusPanel(24, 41);
            ViewConsole    = new DungeonMapConsole(this, 56, 42, 80, 80);
            MessageConsole = MessagesConsole.Instance;             // = new MessagesConsole( ); // defaults to 80,6

            // Setup Input
            CanUseKeyboard = true;
            SadConsole.Engine.ActiveConsole = this;

            SadConsole.Engine.Keyboard.RepeatDelay        = 0.07f;
            SadConsole.Engine.Keyboard.InitialRepeatDelay = 0.1f;

            messageHeaderConsole                = new Console(80, 1);
            messageHeaderConsole.DoUpdate       = false;
            messageHeaderConsole.CanUseKeyboard = false;
            messageHeaderConsole.CanUseMouse    = false;

            // Draw the line for the header
            messageHeaderConsole.Fill(Color.White, Color.Black, 196, null);
            messageHeaderConsole.SetGlyph(56, 0, 193);               // This makes the border match the character console's left-edge border

            // Print the header text
            messageHeaderConsole.Print(2, 0, " Messages ");

            // Move the rest of the consoles into position (ViewConsole is already in position at 0,0)
            StatsConsole.Position         = new Point(56, 0);
            MessageConsole.Position       = new Point(0, 42);
            messageHeaderConsole.Position = new Point(0, 41);

            // Add all consoles to this console list.
            Add(messageHeaderConsole);
            Add(StatsConsole);
            Add(ViewConsole);
            Add(MessageConsole);
        }
        public WorldGenerationConsole()
            : base(80, 25)
        {
            messageData = new Console(1, 1);
            messageData.TextSurface = textSurface;
            IsVisible = false;

            KeyboardHandler = (cons, info) =>
            {

                if (info.IsKeyDown(Keys.Left))
                    cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left - 1, cons.TextSurface.RenderArea.Top, 80 * 2, 25 * 2);

                if (info.IsKeyDown(Keys.Right))
                    cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left + 1, cons.TextSurface.RenderArea.Top, 80 * 2, 25 * 2);

                if (info.IsKeyDown(Keys.Up))
                    cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left, cons.TextSurface.RenderArea.Top - 1, 80 * 2, 25 * 2);

                if (info.IsKeyDown(Keys.Down))
                    cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left, cons.TextSurface.RenderArea.Top + 1, 80 * 2, 25 * 2);

                if (info.IsKeyReleased(Keys.Enter))
                {
                    messageData.Fill(Color.White, Color.Black, 0, null);
                    messageData.Print(0, 0, "Generating map, please wait...");
                    initialized = true;
                    initializedStep2 = false;
                    initializedStep3 = false;
                }

                if (info.IsKeyReleased(Keys.Space))
                {
                    var oldRenderArea = cons.TextSurface.RenderArea;
                    var oldFont = cons.TextSurface.Font;

                    if (textSurface == generator.HeightMapRenderer)
                    {
                        textSurface = generator.HeatMapRenderer;
                        messageData.Print(0, 0, $"[SPACE] Change Map Info [ENTER] New Map -- Heat    ", Color.White, Color.Black);
                    }
                    else if (textSurface == generator.HeatMapRenderer)
                    {
                        textSurface = generator.MoistureMapRenderer;
                        messageData.Print(0, 0, $"[SPACE] Change Map Info [ENTER] New Map -- Moisture", Color.White, Color.Black);
                    }
                    else if (textSurface == generator.MoistureMapRenderer)
                    {
                        textSurface = generator.BiomeMapRenderer;
                        messageData.Print(0, 0, $"[SPACE] Change Map Info [ENTER] New Map -- Biome   ", Color.White, Color.Black);
                    }
                    else
                    {
                        textSurface = generator.HeightMapRenderer;
                        messageData.Print(0, 0, $"[SPACE] Change Map Info [ENTER] New Map -- Height  ", Color.White, Color.Black);
                    }

                    cons.TextSurface.RenderArea = oldRenderArea;
                    cons.TextSurface.Font = oldFont;
                }

                return true;
            };
        }
Example #12
0
        public WorldGenerationConsole() : base(80, 25)
        {
            messageData             = new Console(1, 1);
            messageData.TextSurface = textSurface;
            IsVisible = false;

            KeyboardHandler = (cons, info) =>
            {
                if (info.IsKeyDown(Keys.Left))
                {
                    cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left - 1, cons.TextSurface.RenderArea.Top, 80 * 2, 25 * 2);
                }

                if (info.IsKeyDown(Keys.Right))
                {
                    cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left + 1, cons.TextSurface.RenderArea.Top, 80 * 2, 25 * 2);
                }

                if (info.IsKeyDown(Keys.Up))
                {
                    cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left, cons.TextSurface.RenderArea.Top - 1, 80 * 2, 25 * 2);
                }

                if (info.IsKeyDown(Keys.Down))
                {
                    cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left, cons.TextSurface.RenderArea.Top + 1, 80 * 2, 25 * 2);
                }

                if (info.IsKeyReleased(Keys.Enter))
                {
                    messageData.Fill(Color.White, Color.Black, 0, null);
                    messageData.Print(0, 0, "Generating map, please wait...");
                    initialized      = true;
                    initializedStep2 = false;
                    initializedStep3 = false;
                }

                if (info.IsKeyReleased(Keys.Space))
                {
                    var oldRenderArea = cons.TextSurface.RenderArea;
                    var oldFont       = cons.TextSurface.Font;

                    if (textSurface == generator.HeightMapRenderer)
                    {
                        textSurface = generator.HeatMapRenderer;
                        messageData.Print(0, 0, $"[SPACE] Change Map Info [ENTER] New Map -- Heat    ", Color.White, Color.Black);
                    }
                    else if (textSurface == generator.HeatMapRenderer)
                    {
                        textSurface = generator.MoistureMapRenderer;
                        messageData.Print(0, 0, $"[SPACE] Change Map Info [ENTER] New Map -- Moisture", Color.White, Color.Black);
                    }
                    else if (textSurface == generator.MoistureMapRenderer)
                    {
                        textSurface = generator.BiomeMapRenderer;
                        messageData.Print(0, 0, $"[SPACE] Change Map Info [ENTER] New Map -- Biome   ", Color.White, Color.Black);
                    }
                    else
                    {
                        textSurface = generator.HeightMapRenderer;
                        messageData.Print(0, 0, $"[SPACE] Change Map Info [ENTER] New Map -- Height  ", Color.White, Color.Black);
                    }

                    cons.TextSurface.RenderArea = oldRenderArea;
                    cons.TextSurface.Font       = oldFont;
                }

                return(true);
            };
        }