Exemplo n.º 1
0
        public void Init()
        {
            _layout = new Canvas()
            {
                HorizontalAlignment = DigitalRune.Game.UI.HorizontalAlignment.Stretch,
                VerticalAlignment = DigitalRune.Game.UI.VerticalAlignment.Stretch
            };

            _background = new Image()
            {
                HorizontalAlignment = DigitalRune.Game.UI.HorizontalAlignment.Stretch,
                VerticalAlignment = DigitalRune.Game.UI.VerticalAlignment.Stretch,
                Texture = _content.GetContent<Texture2D>("UI/StartScreenBG")
            };

            _menuItems = new SpacedStackPanel()
            {
                HorizontalAlignment = DigitalRune.Game.UI.HorizontalAlignment.Center,
                VerticalAlignment = DigitalRune.Game.UI.VerticalAlignment.Center

            };

            _newGameButton = new Button()
            {
                Width = 160,
                Height = 30,
                Content = new TextBlock() {
                    Text = "New Game"
                }
            };

            _exitButton = new Button()
            {
                Width = 160,
                Height = 30,
                Content = new TextBlock() {
                    Text = "Exit"
                }
            };

            _menuItems.Children.Add(_newGameButton);
            _menuItems.Children.Add(_exitButton);

            _layout.Children.Add(_background);
            _layout.Children.Add(_menuItems);
            this.Content = _layout;
        }
Exemplo n.º 2
0
    public RenderTransformWindow()
    {
      Title = "RenderTransform Demo";

      // Ensure that the child controls are drawn outside the window.
      ClipContent = true;

      var textBlock = new TextBlock
      {
        X = 10,
        Y = 10,
        Text = "All controls can be scaled, rotated and translated:"
      };

      _checkBox = new CheckBox
      {
        X = 10,
        Y = 30,
        Content = new TextBlock { Text = "Enable RenderTransform" },
      };

      _button = new Button
      {
        X = 100,
        Y = 150,
        Content = new TextBlock { Text = "Button with\nRenderTransform" },
      };

      var canvas = new Canvas
      {
        Width = 315,
        Height = 250,
      };
      canvas.Children.Add(textBlock);
      canvas.Children.Add(_checkBox);
      canvas.Children.Add(_button);

      Content = canvas;
    }
Exemplo n.º 3
0
    protected override void OnLoad()
    {
      base.OnLoad();

      var screen = Screen;

      var panel = new Canvas
      {
        Margin = new Vector4F(8),
        HorizontalAlignment = HorizontalAlignment.Stretch,
        VerticalAlignment = VerticalAlignment.Stretch,
      };
      Content = panel;

      panel.Children.Add(new TextBlock
      {
        Text = "The GUI can be used in the 3D game! :-)",
      });

      panel.Children.Add(new TextBlock
      {
        Y = 32,
        Text = "Red: ",
      });

      var slider = new Slider
      {
        X = 52,
        Y = 32,
        Width = 200,
        Minimum = 0,
        Maximum = 255,
        Value = screen.Background.R,
      };
      panel.Children.Add(slider);
      GameProperty<float> sliderValue = slider.Properties.Get<float>("Value");
      sliderValue.Changed += (s, e) =>
      {
        Color color = screen.Background;
        color.R = (byte)e.NewValue;
        screen.Background = color;
      };

      panel.Children.Add(new TextBlock
      {
        X = 0,
        Y = 56,
        Text = "Green: ",
      });
      slider = new Slider
      {
        X = 52,
        Y = 56,
        Width = 200,
        Minimum = 0,
        Maximum = 255,
        Value = screen.Background.G,
      };
      panel.Children.Add(slider);
      sliderValue = slider.Properties.Get<float>("Value");
      sliderValue.Changed += (s, e) =>
      {
        Color color = screen.Background;
        color.G = (byte)e.NewValue;
        screen.Background = color;
      };

      panel.Children.Add(new TextBlock
      {
        X = 0,
        Y = 80,
        Text = "Blue: ",
      });
      slider = new Slider
      {
        X = 52,
        Y = 80,
        Width = 200,
        Minimum = 0,
        Maximum = 255,
        Value = screen.Background.B,
      };
      panel.Children.Add(slider);
      sliderValue = slider.Properties.Get<float>("Value");
      sliderValue.Changed += (s, e) =>
      {
        Color color = screen.Background;
        color.B = (byte)e.NewValue;
        screen.Background = color;
      };

      var button = new Button
      {
        X = 60,
        Y = 110,
        Width = 120,
        ToolTip = "Drop a new box",
        Content = new TextBlock { Text = "Drop" },
      };
      button.Click += (s, e) =>
      {
        // Create a new DynamicObject.
        var gameObjectService = _services.GetInstance<IGameObjectService>();
        gameObjectService.Objects.Add(new DynamicObject(_services, 1));
      };
      panel.Children.Add(button);
    }
Exemplo n.º 4
0
        /// <summary>
        /// Load content for this game component
        /// </summary>
        protected override void LoadContent()
        {
            // TODO: Add your initialization code here
            var content = new ContentManager(Game.Services, "NeoforceTheme");
            Theme theme;
            theme = content.Load<Theme>("ThemeRed");

            // Create a UI renderer, which uses the theme info to renderer UI controls.
            var renderer = new UIRenderer(Game, theme);

            // Create a UIScreen and add it to the UI service. The screen is the root of
            // the tree of UI controls. Each screen can have its own renderer.
            _screen = new UIScreen("Default", renderer)
            {
                // Make the screen transparent.
                Background = new Color(0, 0, 0, 0),

            };
            var test = new Canvas()
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
            };

            var maprender = new UIControls.GalaxyMapControl(Game.Services)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
            };
            var minimap = new UIControls.MinimapControl(Game.Services);
            var miniMapWindow = new MiniMapWindow()
            {
                Height = 200,
                Width = 200,
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment = VerticalAlignment.Bottom,
                Name = "MiniMap"
            };
            var controlButtonPanel = new StackPanel()
            {
                Orientation = Orientation.Horizontal,
                VerticalAlignment = VerticalAlignment.Bottom,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            var testButton = new Button()
            {
                Height = 40,
                Width = 200
            };
            controlButtonPanel.Children.Add(testButton);
            miniMapWindow.Content = minimap;
            test.Children.Add(maprender);
            test.Children.Add(controlButtonPanel);
            test.Children.Add(miniMapWindow);

            var mainTabPanel = new TabControl
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch
            };

            var systemMap = new UIControls.SystemMapControl(Game.Services)
            {
                Opacity = 5,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
                ViewData = new SystemMapViewModel() { Rings = new[]
                                                                  {
                                                                      new SystemMapRingViewModel() { Planets = new[]
                                                                                                                   {
                                                                                                                       new SystemMapPlanetViewModel() { Name = "Planet 1", Scale = 1},
                                                                                                                       new SystemMapPlanetViewModel() { Name = "Planet 1 - Moon", Scale = 0.4f},
                                                                                                                   }},
                                                                      new SystemMapRingViewModel() { Planets = new[]
                                                                                                                   {
                                                                                                                       new SystemMapPlanetViewModel() { Name = "Planet 2", Scale = 0.5f},
                                                                                                                   }},
                                                                      new SystemMapRingViewModel() { Planets = new[]
                                                                                                                   {
                                                                                                                       new SystemMapPlanetViewModel() { Name = "Planet 3", Scale = 0.7f},
                                                                                                                       new SystemMapPlanetViewModel() { Name = "Planet 3 - Moon 1", Scale = 0.3f},
                                                                                                                       new SystemMapPlanetViewModel() { Name = "Planet 3 - Moon 2", Scale = 0.3f},
                                                                                                                   }},
                                                                      new SystemMapRingViewModel() { Planets = new[]
                                                                                                                   {
                                                                                                                       new SystemMapPlanetViewModel() { Name = "Planet 4", Scale = 0.2f},
                                                                                                                   }},
                                                                      new SystemMapRingViewModel() { Planets = new[]
                                                                                                                   {
                                                                                                                       new SystemMapPlanetViewModel() { Name = "Planet 5", Scale = 0.9f},
                                                                                                                   }},
                                                                      new SystemMapRingViewModel() { Planets = new[]
                                                                                                                   {
                                                                                                                       new SystemMapPlanetViewModel() { Name = "Planet 6", Scale = 0.6f},
                                                                                                                   }},
                                                                      new SystemMapRingViewModel() { Planets = new[]
                                                                                                                   {
                                                                                                                       new SystemMapPlanetViewModel() { Name = "Planet 7", Scale = 0.3f},
                                                                                                                   }},
                                                                      new SystemMapRingViewModel() { Planets = new[]
                                                                                                                   {
                                                                                                                       new SystemMapPlanetViewModel() { Name = "Planet 8", Scale = 0.5f},
                                                                                                                   }},
                                                                      new SystemMapRingViewModel() { Planets = new[]
                                                                                                                   {
                                                                                                                       new SystemMapPlanetViewModel() { Name = "Planet 9", Scale = 0.8f},
                                                                                                                       new SystemMapPlanetViewModel() { Name = "Planet 9 - Moon 1", Scale = 0.2f},
                                                                                                                       new SystemMapPlanetViewModel() { Name = "Planet 9 - Moon 2", Scale = 0.2f},
                                                                                                                       new SystemMapPlanetViewModel() { Name = "Planet 9 - Moon 3", Scale = 0.2f},
                                                                                                                       new SystemMapPlanetViewModel() { Name = "Planet 9 - Moon 4", Scale = 0.3f},
                                                                                                                   }}
                                                                  }}
            };

            var planetMap = new PlanetMapControl(Game.Services)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
                ViewData = new PlanetMapViewModel()
                               {
                                   Name = "Earth",
                                   BuildingCells = new[,]
                                                       {
                                                           { new BuildingCellViewModel(), new BuildingCellViewModel { Type = CellMultiplier.ExtraEnergy }, new BuildingCellViewModel() },
                                                           { new BuildingCellViewModel(), new BuildingCellViewModel(), new BuildingCellViewModel { Type = CellMultiplier.ExtraEnergy } },
                                                           { new BuildingCellViewModel { Type = CellMultiplier.ExtraEnergy }, new BuildingCellViewModel(), new BuildingCellViewModel() }
                                                       }
                               }
            };

            mainTabPanel.Items.Add(new TabItem() { Content = new TextBlock() { Text = "Star map" }, TabPage = test });
            mainTabPanel.Items.Add(new TabItem() { Content = new TextBlock() { Text = "System map" }, TabPage = systemMap });
            mainTabPanel.Items.Add(new TabItem() { Content = new TextBlock() { Text = "Planet map" }, TabPage = planetMap });

            _console = new ConsoleWindow(_consoleManager);

            StartMenuScreen start = new StartMenuScreen(Game.Services);
            start.Init();
            _screen.Children.Add(start);

            //_screen.Children.Add(mainTabPanel);
            //_screen.Children.Add(_console);
            //_screen.Children.Add(miniMapWindow);
            //_screen.Children.Add(maprender);

            // Add the screen to the UI service.
            _uiService.Screens.Add(_screen);

            base.LoadContent();
        }