Esempio n. 1
0
        private void MakeBasicSurface()
        {
            basicSurface.Print(0, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890".Repeat(9));
            basicSurface.SetGlyph(0, 0, 7);
            basicSurface.SetGlyph(1, 0, 8);
            basicSurface.SetGlyph(2, 0, 9);
            basicSurface.SetGlyph(3, 0, 10);
            ColorGradient gradient = new ColorGradient(StarterProject.Theme.Blue, StarterProject.Theme.Yellow);

            for (int i = 0; i < 510; i += 10)
            {
                var point = basicSurface.GetPointFromIndex(i);
                basicSurface.Print(point.X, point.Y, gradient.ToColoredString(basicSurface.GetString(i, 10)));
            }

            // Mirror 1
            int startSet1 = new Point(0, 3).ToIndex(34);
            int startSet2 = new Point(0, 6).ToIndex(34);
            int startSet3 = new Point(0, 9).ToIndex(34);

            for (int i = 0; i < 34 * 3; i++)
            {
                basicSurface.Cells[startSet1 + i].Mirror     = Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipVertically;
                basicSurface.Cells[startSet1 + i].Background = StarterProject.Theme.PurpleDark;

                basicSurface.Cells[startSet2 + i].Mirror     = Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipHorizontally;
                basicSurface.Cells[startSet2 + i].Background = StarterProject.Theme.OrangeDark;

                basicSurface.Cells[startSet3 + i].Mirror     = Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipHorizontally | Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipVertically;
                basicSurface.Cells[startSet3 + i].Background = StarterProject.Theme.GreenDark;
            }
        }
Esempio n. 2
0
        private void MakeLayeredSurface()
        {
            layeredSurface = new Layered();

            var layer = new SadConsole.Surfaces.Basic(34, 15);

            layer.Fill(StarterProject.Theme.Gray, StarterProject.Theme.GrayDark, 0);
            layer.Print(14, 4, "Layer 0");
            layeredSurface.Add(layer);

            layer = new SadConsole.Surfaces.Basic(34, 15);
            layer.Fill(StarterProject.Theme.Green, StarterProject.Theme.GreenDark, 0);
            layer.Fill(new Rectangle(10, 4, 34 - 20, 15 - 8), Color.White, Color.Transparent, 0);
            layer.Print(14, 2, "Layer 1");
            layeredSurface.Add(layer);

            layer = new SadConsole.Surfaces.Basic(34, 15);
            layer.Fill(StarterProject.Theme.Brown, StarterProject.Theme.BrownDark, 0);
            layer.Fill(new Rectangle(5, 2, 34 - 10, 15 - 4), Color.White, Color.Transparent, 0);
            layer.Print(14, 0, "Layer 2");
            layeredSurface.Add(layer);
        }
Esempio n. 3
0
        public MainMenu(int Width, int Height) : base(Width, Height)
        {
            FontMaster fontMaster = SadConsole.Global.LoadFont("cp437_10_ext.font");
            Font       titleFont  = fontMaster.GetFont(Font.FontSizes.Four);

            Basic title = new SadConsole.Surfaces.Basic(20, 1);

            title.Font     = titleFont;
            title.Position = new Point(Width / 4 - "Main Menu".Length / 2, 2);
            title.Print(0, 0, "Main Menu");

            Children.Add(title);

            var tetrisButton = new SadConsole.Controls.Button(11, 3);

            tetrisButton.Text          = "Tetris";
            tetrisButton.TextAlignment = HorizontalAlignment.Center;
            tetrisButton.Position      = new Point(Width / 2 - tetrisButton.Width / 2, 10);
            tetrisButton.Theme         = new SadConsole.Themes.ButtonLinesTheme();

            Add(tetrisButton);

            tetrisButton.Click += (btn, args) =>
            {
                Program.MainMenu.Hide();
                Program.TetrisWindow.Show();
            };

            var snakeButton = new SadConsole.Controls.Button(11, 3);

            snakeButton.Position      = new Point(Width / 2 - snakeButton.Width / 2, 14);
            snakeButton.TextAlignment = HorizontalAlignment.Center;
            snakeButton.Text          = "Snake";
            snakeButton.Theme         = new SadConsole.Themes.ButtonLinesTheme();

            Add(snakeButton);

            snakeButton.Click += (btn, args) =>
            {
                Program.MainMenu.Hide();
                Program.SnakeWindow.Show();
            };

            var themeButton = new SadConsole.Controls.Button(11, 3);

            themeButton.Position      = new Point(Width / 2 - snakeButton.Width / 2, 18);
            themeButton.TextAlignment = HorizontalAlignment.Center;
            themeButton.Text          = "Theme";
            themeButton.Theme         = new SadConsole.Themes.ButtonLinesTheme();

            Add(themeButton);

            themeButton.Click += (btn, args) =>
            {
                Program.MainMenu.Hide();
                Program.ThemeEditor.Show();
            };

            var viewerButton = new SadConsole.Controls.Button(11, 3);

            viewerButton.Position      = new Point(Width / 2 - snakeButton.Width / 2, 22);
            viewerButton.TextAlignment = HorizontalAlignment.Center;
            viewerButton.Text          = "Viewer";
            viewerButton.Theme         = new SadConsole.Themes.ButtonLinesTheme();

            Add(viewerButton);

            viewerButton.Click += (btn, args) =>
            {
                Program.MainMenu.Hide();
                Program.TilesetViewer.Show();
            };

            var mapViewButton = new SadConsole.Controls.Button(11, 3);

            mapViewButton.Position      = new Point(Width / 2 - snakeButton.Width / 2, 26);
            mapViewButton.TextAlignment = HorizontalAlignment.Center;
            mapViewButton.Text          = "MapView";
            mapViewButton.Theme         = new SadConsole.Themes.ButtonLinesTheme();

            Add(mapViewButton);

            mapViewButton.Click += (btn, args) =>
            {
                Program.MainMenu.Hide();
                //Children.Add( Program.MapView );
                //Global.CurrentScreen = Program.MapView;
                Program.MapView.Show();
                Global.FocusedConsoles.Set(Program.MapView);
            };

            var themeRadioButton = new RadioButton(10, 1);

            themeRadioButton.Text      = "Light";
            themeRadioButton.Position  = new Point(60, 2);
            themeRadioButton.GroupName = "Theme";
            Add(themeRadioButton);
            themeRadioButton.IsSelectedChanged += OnThemeRadioChanged;

            themeRadioButton           = new RadioButton(10, 1);
            themeRadioButton.Text      = "Dark";
            themeRadioButton.Position  = new Point(60, 4);
            themeRadioButton.GroupName = "Theme";
            Add(themeRadioButton);
            themeRadioButton.IsSelectedChanged += OnThemeRadioChanged;
        }