Esempio n. 1
0
        protected override void OnInitialize()
        {
            SpriteFont font = game.Content.Load <SpriteFont>("default");

            background = new SpriteBox(game);

            background.Renderer = new DisortSpriteRenderer(background,
                                                           minX: -5.0f,
                                                           maxX: 5.0f,
                                                           minY: -5.0f,
                                                           maxY: 5.0f);

            background.Sprite        = new Sprite(game.Content.Load <Texture2D>("taustatemp"));
            background.SizeBehaviour = Gui.SizeBehaviour.OverwriteBoth;
            background.Size          = new Vector2(105f);
            background.Position      = new Vector2(-5f, -5f);

            background.DisableFocusing();

            root      = new Canvas(game);
            root.Size = new Vector2(100f);
            root.Add(background);

            grid = new Grid(game)
            {
                Rows    = 6,
                Columns = 4
            };

            grid.SetRowHeight(0, 25f);
            grid.SetRowHeight(1, 25f);
            grid.SetRowHeight(2, 10f);
            grid.SetRowHeight(3, 10f);
            grid.SetRowHeight(4, 10f);

            grid.SetColumnWidth(0, 5f);

            root.Add(grid);

            header = new Label(game)
            {
                Font          = font,
                Text          = "Massacre simulator 3000",
                Brush         = new Brush(Color.White),
                SizeBehaviour = SizeBehaviour.OverwriteBoth,
                Size          = new Vector2(100f, 55f)
            };

            start = new Button(game)
            {
                // TODO: continue tai start riippuen siitä onko pelissä jo save file.
                Text                    = "Start",
                TextColor               = Color.White,
                Font                    = font,
                SizeBehaviour           = Gui.SizeBehaviour.OverwriteBoth,
                VerticalAlingment       = Vertical.Center,
                HorizontalAlingment     = Horizontal.Left,
                Brush                   = new Gui.Brush(Color.Transparent),
                TextSize                = new Vector2(55f, 45f),
                Size                    = new Vector2(25f, 100f),
                TextHorizontalAlingment = Horizontal.Left
            };

            start.MouseButtonDown += start_MouseButtonDown;
            start.ButtonPressed   += start_ButtonPressed;

            options = new Button(game)
            {
                Text                    = "Options",
                TextColor               = Color.White,
                Font                    = font,
                SizeBehaviour           = Gui.SizeBehaviour.OverwriteBoth,
                VerticalAlingment       = Vertical.Center,
                HorizontalAlingment     = Horizontal.Left,
                Brush                   = new Gui.Brush(Color.Transparent),
                TextSize                = new Vector2(55f, 45f),
                Size                    = new Vector2(25f, 100f),
                TextHorizontalAlingment = Horizontal.Left
            };

            options.MouseButtonDown += options_MouseButtonDown;
            options.ButtonPressed   += options_ButtonPressed;

            exit = new Button(game)
            {
                Text                    = "Exit",
                TextColor               = Color.White,
                Font                    = font,
                SizeBehaviour           = Gui.SizeBehaviour.OverwriteBoth,
                VerticalAlingment       = Vertical.Center,
                HorizontalAlingment     = Horizontal.Left,
                Brush                   = new Gui.Brush(Color.Transparent),
                TextSize                = new Vector2(45f, 45f),
                Size                    = new Vector2(25f, 100f),
                TextHorizontalAlingment = Horizontal.Left
            };

            exit.MouseButtonDown += exit_MouseButtonDown;
            exit.ButtonPressed   += exit_ButtonPressed;

            grid.SetColumnWidth(1, 50f);

            grid.Add(header, 0, 1);
            grid.Add(start, 2, 1);
            grid.Add(options, 3, 1);
            grid.Add(exit, 4, 1);

            SetContent(root);
        }
Esempio n. 2
0
        protected override void OnInitialize()
        {
            // 100% koko.
            Size = new Vector2(100f);
            SpriteFont font = game.Content.Load <SpriteFont>("guifont");

            // Root ja background init.
            root = new Canvas(game)
            {
                Brush = new Brush(Color.Transparent),
                Size  = SizeInPixels
            };

            background = new SpriteBox(game)
            {
                Size = new Vector2(100f, 200f),

                Sprite = new Sprite(game.Content.Load <Texture2D>("taustatemp"))
                {
                    Size = new Vector2(1280f, 720f)
                },

                Brush = new Brush(Color.White)
            };

            background.DisableFocusing();

            root.Add(background);

            // Grid init.
            grid = new Grid(game)
            {
                Rows    = 3,
                Columns = 6,
            };

            grid.SetColumnWidth(0, 15f);
            grid.SetColumnWidth(5, 15f);
            grid.SetRowHeight(0, 15f);
            grid.SetRowHeight(2, 15f);

            root.Add(grid);

            // Player label inits.
            p1Label = new Label(game)
            {
                Font                = font,
                Text                = "Connected (P1)",
                SizeBehaviour       = SizeBehaviour.OverwriteBoth,
                VerticalAlingment   = Vertical.Top,
                HorizontalAlingment = Horizontal.Center,
                SizeValueType       = Gui.SizeValueType.Fixed,
                DrawOrder           = 1
            };

            p1Label.Size = font.MeasureString(p1Label.Text) * 0.75f;

            p2Label = new Label(game)
            {
                Font                = font,
                Text                = "Not connected",
                SizeBehaviour       = SizeBehaviour.OverwriteBoth,
                VerticalAlingment   = Vertical.Top,
                HorizontalAlingment = Horizontal.Center,
                SizeValueType       = Gui.SizeValueType.Fixed,
                DrawOrder           = 1
            };

            p2Label.Size = font.MeasureString(p2Label.Text) * 0.75f;

            p3Label = new Label(game)
            {
                Font                = font,
                Text                = "Not connected",
                SizeBehaviour       = SizeBehaviour.OverwriteBoth,
                VerticalAlingment   = Vertical.Top,
                HorizontalAlingment = Horizontal.Center,
                SizeValueType       = Gui.SizeValueType.Fixed,
                DrawOrder           = 1
            };

            p3Label.Size = font.MeasureString(p3Label.Text) * 0.75f;

            p4Label = new Label(game)
            {
                Font                = font,
                Text                = "Not connected",
                SizeBehaviour       = SizeBehaviour.OverwriteBoth,
                VerticalAlingment   = Vertical.Top,
                HorizontalAlingment = Horizontal.Center,
                SizeValueType       = Gui.SizeValueType.Fixed,
                DrawOrder           = 1
            };

            p4Label.Size = font.MeasureString(p4Label.Text) * 0.75f;

            Labels = new []
            {
                p2Label,
                p3Label,
                p4Label
            };

            grid.Add(p1Label, 1, 1);
            grid.Add(p2Label, 1, 2);
            grid.Add(p3Label, 1, 3);
            grid.Add(p4Label, 1, 4);

            // Player box init.
            Texture2D texture = game.Content.Load <Texture2D>("slot");

            p1Box = new SpriteBox(game)
            {
                Sprite = new Sprite(texture),
                Margin = new Margin(left: 10f, right: 10f, top: -15f, bottom: 5f)
            };

            p2Box = new SpriteBox(game)
            {
                Sprite = new Sprite(texture),
                Margin = new Margin(left: 10f, right: 10f, top: -15f, bottom: 5f)
            };

            p3Box = new SpriteBox(game)
            {
                Sprite = new Sprite(texture),
                Margin = new Margin(left: 10f, right: 10f, top: -15f, bottom: 5f)
            };

            p4Box = new SpriteBox(game)
            {
                Sprite = new Sprite(texture),
                Margin = new Margin(left: 10f, right: 10f, top: -15f, bottom: 5f)
            };

            grid.Add(p1Box, 1, 1);
            grid.Add(p2Box, 1, 2);
            grid.Add(p3Box, 1, 3);
            grid.Add(p4Box, 1, 4);

            grid.UpdateLayout(new GuiLayoutEventArgs());

            // Start and go back buttons init.
            start = new Button(game)
            {
                Font                = font,
                Text                = "Start",
                SizeValueType       = Gui.SizeValueType.Fixed,
                SizeBehaviour       = Gui.SizeBehaviour.OverwriteBoth,
                HorizontalAlingment = Horizontal.Center,
                VerticalAlingment   = Vertical.Center,
                Brush               = new Brush(Color.Transparent),
                Size                = new Vector2(100f)
            };

            start.TextSize = font.MeasureString(start.Text) * 1.25f;

            goBack = new Button(game)
            {
                Font                = font,
                Text                = "Go back",
                SizeValueType       = Gui.SizeValueType.Fixed,
                SizeBehaviour       = Gui.SizeBehaviour.OverwriteBoth,
                HorizontalAlingment = Horizontal.Center,
                VerticalAlingment   = Vertical.Center,
                Brush               = new Brush(Color.Transparent),
                Size                = new Vector2(100f)
            };

            goBack.TextSize = font.MeasureString(goBack.Text) * 1.25f;

            grid.Add(start, 2, 0);
            grid.Add(goBack, 2, 5);

            start.MouseButtonDown  += button_MouseButtonDown;
            goBack.MouseButtonDown += button_MouseButtonDown;

            start.ButtonPressed  += start_ButtonPressed;
            goBack.ButtonPressed += goBack_ButtonPressed;

            SetContent(root);
        }