Example #1
0
        public SubConsoleCursor()
        {
            mainView = new Console(80, 23);
            subView  = new Console(new SurfaceView(mainView.TextSurface, new Rectangle(4, 4, 25, 10)));

            UseKeyboard = true;

            // Setup main view
            mainView.FillWithRandomGarbage();
            mainView.MouseMove += (s, e) => { if (e.MouseState.Mouse.LeftButtonDown)
                                              {
                                                  e.MouseState.Cell.Background = Color.Blue;
                                              }
            };

            // Setup sub view
            subView.Position   = new Point(4, 4);
            subView.MouseMove += (s, e) => { if (e.MouseState.Mouse.LeftButtonDown)
                                             {
                                                 e.MouseState.Cell.Background = Color.Red;
                                             }
            };
            subView.Clear();
            subView.VirtualCursor.IsVisible = true;

            // Ad the consoles to the list.
            Children.Add(mainView);
            Children.Add(subView);
        }
Example #2
0
        protected override void Initialize()
        {
            SizeChanged += Game_SizeChanged;

            // must be initialized. required by Content loading and rendering (will add itself to the Services)
            _graphicsDeviceManager = new WpfGraphicsDeviceService(this);

            // wpf and keyboard need reference to the host control in order to receive input
            // this means every WpfGame control will have it's own keyboard & mouse manager which will only react if the mouse is in the control
            _keyboard = new WpfKeyboard(this);
            _mouse    = new WpfMouse(this);

            // must be called after the WpfGraphicsDeviceService instance was created
            base.Initialize();
            // content loading now possible

            Global.GraphicsDevice = GraphicsDevice;
            //Global.GraphicsDeviceManager = GraphicsDeviceManager;
            Global.SpriteBatch = new Microsoft.Xna.Framework.Graphics.SpriteBatch(GraphicsDevice);
            Global.FontDefault = Global.LoadFont("Fonts\\Cheepicus12.font").GetFont(Font.FontSizes.One);


            var con = new SadConsole.Console(10, 10);

            Global.CurrentScreen = con;
            con.FillWithRandomGarbage();
        }
Example #3
0
        static void Init()
        {
            var console = new Console(80, 25);

            console.FillWithRandomGarbage();
            console.Fill(new Rectangle(3, 3, 23, 3), Color.Violet, Color.Black, 0, 0);
            console.Print(4, 4, "Hello from SadConsole");

            SadConsole.Global.CurrentScreen = console;
        }
Example #4
0
        private static void Init()
        {
            // Any startup code for your game. We will use an example console for now
            Console startingConsole = new Console(Width, Height);

            startingConsole.FillWithRandomGarbage();
            startingConsole.Fill(new Rectangle(3, 3, 27, 5), null, Color.Black, 0, SpriteEffects.None);
            startingConsole.Print(6, 5, "Hello from SadConsole", ColorAnsi.CyanBright);

            // Set our new console as the main object SadConsole processes
            SadConsole.Global.CurrentScreen = startingConsole;
        }
Example #5
0
        private static void Init()
        {
            // Any custom loading and prep. We will use a sample console for now

            SadConsole.Console startingConsole = new Console(80, 25);
            startingConsole.FillWithRandomGarbage();
            startingConsole.Fill(new Rectangle(3, 3, 27, 5), null, Color.Black, 0);
            startingConsole.Print(6, 5, "Hello from SadConsole", ColorAnsi.CyanBright);

            // Set our new console as the thing to render and process
            SadConsole.Global.CurrentScreen = startingConsole;
        }
Example #6
0
        /// <inheritdoc />
        public override void Render(TimeSpan delta)
        {
            // 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 (IsVisible)
            {
                if (!initialized)
                {
                    base.Render(delta);
                }
                else if (!initializedStep2)
                {
                    initializedStep2 = true;
                    base.Render(delta);
                }
                else if (!initializedStep3)
                {
                    base.Render(delta);

                    mainData.SadComponents.Clear();

                    // Generate the content
                    mainData.Resize(80, 23, 2000, 2000, false);
                    mainData.SadComponents.Add(new InputHandling.MoveViewPortKeyboardHandler());
                    mainData.FillWithRandomGarbage(Font);
                    mainData.IsVisible = true;

                    // Clear message data and make it transparent so that it acts as a layer
                    messageData.IsVisible = false;

                    // We need to set celldata to the big console data so we can use the FillWithRandom method.
                    initializedStep3 = true;
                }

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

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

                    //Renderer.Render(messageData.TextSurface, new Point(0, 0));
                }
            }
        }
Example #7
0
        private static void Init()
        {
            // Load the fonts
            _kenneyFont           = Global.LoadFont("Fonts/Kenney/Kenney.font");
            _kenneyFontCharacters = Global.LoadFont("Fonts/Kenney/KenneyCharacters.font");
            _cheepicusFont        = Global.LoadFont("Fonts/DwarfFortress/Cheepicus.font");

            _console   = new Console(Width, Height, _kenneyFont.GetFont(Font.FontSizes.One));
            _uiConsole = new Console(Width, Height, _cheepicusFont.GetFont(Font.FontSizes.One));

            _uiConsole.Parent = _console;

            // Any startup code for your game. We will use an example console for now
            _uiConsole.FillWithRandomGarbage();
            _uiConsole.Fill(new Rectangle(3, 3, 27, 5), null, Color.Black, 0, SpriteEffects.None);
            _uiConsole.Print(6, 5, "Hello from SadConsole", ColorAnsi.CyanBright);

            Global.CurrentScreen = _console;
        }
Example #8
0
        public SubConsoleCursor()
        {
            mainView = new Console(80, 23);
            subView  = new Console(mainView.GetSubSurface(new Rectangle(mainView.Width - 26, mainView.Height - 11, 25, 10)), mainView.Font);
            subView.Cursor.IsEnabled = true;

            UseKeyboard = true;

            // Setup main view
            mainView.FillWithRandomGarbage(mainView.Font);
            mainView.MouseMove += (s, e) => { if (e.Mouse.LeftButtonDown)
                                              {
                                                  e.Cell.Background = Color.Blue;
                                              }
            };

            // Setup sub view
            subView.Position          = new Point(4, 4);
            subView.DefaultBackground = Color.Black;
            subView.MouseMove        += (s, e) => { if (e.Mouse.LeftButtonDown)
                                                    {
                                                        e.Cell.Background = Color.Red;
                                                    }
            };
            subView.IsDirtyChanged += (s, e) => mainView.IsDirty = subView.IsDirty;
            subView.Clear();
            subView.Cursor.IsVisible = true;
            subView.Cursor
            .Print("The left-side box is a small console that uses a small area of the bottom-right of this whole console.")
            .CarriageReturn()
            .LineFeed();


            // Ad the consoles to the list.
            Children.Add(mainView);
            Children.Add(subView);

            IsVisible = false;
        }
        public SubConsoleCursor()
        {
            mainView = new Console(80, 23);
            subView  = Console.FromSurface(mainView.GetViewSurface(new Rectangle(30, 4, 25, 10)));

            UseKeyboard = true;

            // Setup main view
            mainView.FillWithRandomGarbage();
            mainView.MouseMove += (s, e) => { if (e.MouseState.Mouse.LeftButtonDown)
                                              {
                                                  e.MouseState.Cell.Background = Color.Blue;
                                              }
            };

            // Setup sub view
            subView.Position          = new Point(4, 4);
            subView.DefaultBackground = Color.Black;
            subView.MouseMove        += (s, e) => { if (e.MouseState.Mouse.LeftButtonDown)
                                                    {
                                                        e.MouseState.Cell.Background = Color.Red;
                                                    }
            };
            subView.DirtyChanged += (s, e) => mainView.IsDirty = subView.IsDirty;
            subView.Clear();
            subView.Cursor.IsVisible = true;
            subView.Cursor
            .Print("The left box is a whole console which is a view into the box on the right.")
            .CarriageReturn()
            .LineFeed();


            // Ad the consoles to the list.
            Children.Add(mainView);
            Children.Add(subView);

            IsVisible = false;
        }
Example #10
0
        private static void Update(GameTime time)
        {
            // Called each logic update.
            // This gets called repeatedly in real time
            // We only need to do any logic if game state is altered in some way
            if (!map.Player.Energy.HasEnergy())
            {
                Console gameOverConsole = new Console(DisplayWidth, DisplayHeight);
                gameOverConsole.FillWithRandomGarbage();
                SadConsole.Global.CurrentScreen.Children.Add(gameOverConsole);
            }

            // As an example, we'll use the F5 key to make the game full screen
            if (SadConsole.Global.KeyboardState.IsKeyReleased(Microsoft.Xna.Framework.Input.Keys.F5))
            {
                SadConsole.Settings.ToggleFullScreen();
            }

            bool progressState = false;

            if (SadConsole.Global.KeyboardState.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.Up))
            {
                Point newPoint = map.Player.RenderEntity.Position + new Point(0, -1);
                TryMovePlayer(map.Player.RenderEntity, newPoint);
                progressState = true;
            }
            else if (SadConsole.Global.KeyboardState.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.Down))
            {
                Point newPoint = map.Player.RenderEntity.Position + new Point(0, 1);
                TryMovePlayer(map.Player.RenderEntity, newPoint);
                progressState = true;
            }
            else if (SadConsole.Global.KeyboardState.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.Left))
            {
                Point newPoint = map.Player.RenderEntity.Position + new Point(-1, 0);
                TryMovePlayer(map.Player.RenderEntity, newPoint);
                progressState = true;
            }
            else if (SadConsole.Global.KeyboardState.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.Right))
            {
                Point newPoint = map.Player.RenderEntity.Position + new Point(1, 0);
                TryMovePlayer(map.Player.RenderEntity, newPoint);
                progressState = true;
            }

            if (Global.KeyboardState.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.F))
            {
                // Try to use whatever tile the player is on
                map.PlayerInteract();
                progressState = true;
            }

            // Sync entities
            map.UpdateEntities();
            levelConsole.CenterViewPortOnPoint(map.Player.RenderEntity.Position);
            RenderPlayerEnergy();

            if (progressState)
            {
                map.Step();
            }
        }