Ejemplo n.º 1
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();
                }
            }
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
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;
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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;
            };
        }
Ejemplo n.º 8
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);
            };
        }