Ejemplo n.º 1
0
        private void InitializeGui()
        {
            // Create the dialog background
            var background = new Image(Context.Resources.Textures["Gui.Hud.Dialog"]);
            background.HorizontalAlignment = HorizontalAlignment.Center;
            background.VerticalAlignment = VerticalAlignment.Center;
            background.Opacity = 0.9f;
            gui.Elements.Add(background);

            // Create the dialog title
            var title = new TextBlock("Ingame Menu", Context.Resources.Fonts["Global.Default"]);
            title.HorizontalAlignment = HorizontalAlignment.Center;
            title.VerticalAlignment = VerticalAlignment.Center;
            title.Margin = new Thickness(0, 0, 140, 225);
            gui.Elements.Add(title);

            // Create the button stackpanel
            var stackPanel = new StackPanel();
            stackPanel.HorizontalAlignment = HorizontalAlignment.Center;
            stackPanel.VerticalAlignment = VerticalAlignment.Center;
            stackPanel.Margin.Bottom = 100;
            stackPanel.Width = 200;
            stackPanel.Height = 400;
            stackPanel.Spacing.Bottom = 10;
            gui.Elements.Add(stackPanel);

            // Add the buttons to the stackpanel
            stackPanel.Children.Add(CreateButton("Return", ButtonCommand.Return));
            stackPanel.Children.Add(CreateButton("Respawn", ButtonCommand.Respawn));
            stackPanel.Children.Add(CreateButton("Quit", ButtonCommand.Quit));

            buttons.Add(stackPanel.Children[0] as Button);
            buttons.Add(stackPanel.Children[1] as Button);
            buttons.Add(stackPanel.Children[2] as Button);

            // Create the buttons
            //AddButton("Return", new Thickness(0, 0, 90, 180), ButtonCommand.Return);
            //AddButton("Respawn", new Thickness(0, 0, 90, 130), ButtonCommand.Respawn);
            //AddButton("Quit", new Thickness(0, 0, 90, 80), ButtonCommand.Quit);

            gui.UpdateLayout();

            UpdateFocus();
        }
Ejemplo n.º 2
0
        private void InitializeGui()
        {
            // Create the dialog background
            var background = new Image(Context.Resources.Textures["MainMenu.Background"]);
            background.HorizontalAlignment = HorizontalAlignment.Left;
            background.VerticalAlignment = VerticalAlignment.Top;
            background.Width = Context.View.Area.Width;
            background.Height = Context.View.Area.Height;
            gui.Elements.Add(background);

            title = new TextBlock("MAIN MENU", Context.Resources.Fonts["Hud"]);
            title.HorizontalAlignment = HorizontalAlignment.Left;
            title.VerticalAlignment = VerticalAlignment.Top;
            title.Margin = new Thickness(50, 50, 0, 0);
            gui.Elements.Add(title);

            var separatorTop = new Image(Context.Resources.Textures["MainMenu.Separator"]);
            separatorTop.HorizontalAlignment = HorizontalAlignment.Left;
            separatorTop.VerticalAlignment = VerticalAlignment.Top;
            separatorTop.Width = Context.View.Area.Width - 100;
            separatorTop.Height = 2;
            separatorTop.Margin = new Thickness(50, 50 + 40, 0, 0);
            gui.Elements.Add(separatorTop);

            var separatorBottom = new Image(Context.Resources.Textures["MainMenu.Separator"]);
            separatorBottom.HorizontalAlignment = HorizontalAlignment.Left;
            separatorBottom.VerticalAlignment = VerticalAlignment.Bottom;
            separatorBottom.Width = Context.View.Area.Width - 100;
            separatorBottom.Height = 2;
            separatorBottom.Margin = new Thickness(50, 0, 0, 92);
            gui.Elements.Add(separatorBottom);

            gui.UpdateLayout();
            gui.ElementStateChanged += GuiOnElementStateChanged;
        }