public ButtonOption(string option, Action action) { this.grid = new Grid(); grid.HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center; grid.VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center; grid.Width = 475; grid.Height = 139; grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) }); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Proportional) }); Button b_option = new Button() { Text = string.Empty, IsBorder = false, BackgroundImage = Directories.Textures + option + "_bt.png.wpk", PressedBackgroundImage = Directories.Textures + option + "_bt_pressed.png.wpk", VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center, HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center, }; b_option.Click += (s, o) => action(); b_option.SetValue(GridControl.RowProperty, 0); b_option.SetValue(GridControl.ColumnProperty, 0); grid.Add(b_option); TextBlock t_option = new TextBlock() { Width = 322, Height = 65, FontPath = WaveContent.Assets.Fonts.Gotham_Bold_16_ttf, Text = option.ToUpper(), VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center, HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center, DrawOrder = 0.4f, Margin = new WaveEngine.Framework.UI.Thickness(0, 13, 0,0) }; t_option.SetValue(GridControl.RowProperty, 0); t_option.SetValue(GridControl.ColumnProperty, 1); grid.Add(t_option); Image bg_option = new Image(WaveContent.Assets.Textures.bg_options_pause_PNG) { VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center, HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center, Margin = new WaveEngine.Framework.UI.Thickness(-45,0,0,0), DrawOrder = 0.9f, }; bg_option.SetValue(GridControl.RowProperty, 0); bg_option.SetValue(GridControl.ColumnProperty, 1); grid.Add(bg_option); this.entity = grid.Entity; }
public HubPanel() { Grid grid = new Grid("HubPanel") { HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center, VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Top, Width = 800, Height = 40, }; grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) }); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Proportional) }); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Proportional) }); Image background = new Image(WaveContent.Assets.Textures.hubBackground_png); background.SetValue(GridControl.RowProperty, 0); background.SetValue(GridControl.ColumnProperty, 0); grid.Add(background); // Life this.progressBar = new ProgressBar() { Height = 25, Width = 300, Foreground = Color.Gold, Background = Color.Red, HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center, VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center, DrawOrder = -1 }; progressBar.SetValue(GridControl.RowProperty, 0); progressBar.SetValue(GridControl.ColumnProperty, 0); grid.Add(progressBar); // Murders this.murdersText = new TextBlock() { DrawOrder = -1, FontPath = WaveContent.Assets.Fonts.Coalition_16_ttf, Text = "#00", HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center, VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Bottom, }; murdersText.SetValue(GridControl.RowProperty, 0); murdersText.SetValue(GridControl.ColumnProperty, 1); grid.Add(murdersText); this.entity = grid.Entity; }
protected override void CreateScene() { FixedCamera2D camera2d = new FixedCamera2D("camera"); camera2d.BackgroundColor = Color.Gray; EntityManager.Add(camera2d); // Panel gridPanel = new Grid() { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Width = 400, Height = 400, }; EntityManager.Add(gridPanel.Entity); gridPanel.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) }); gridPanel.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) }); gridPanel.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) }); gridPanel.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Proportional) }); gridPanel.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Proportional) }); // Elements Button button; for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { button = new Button() { Text = "[" + i + "," + j + "]", HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Width = 100, Height = 100, Foreground = Color.Yellow, BackgroundColor = Color.Red, }; button.SetValue(GridControl.RowProperty, i); button.SetValue(GridControl.ColumnProperty, j); gridPanel.Add(button); } } // Debug this.CreateDebugMode(); }
/// <summary> /// Creates the scene. /// </summary> /// <remarks> /// This method is called before all <see cref="T:WaveEngine.Framework.Entity" /> instances in this instance are initialized. /// </remarks> protected override void CreateScene() { FixedCamera2D camera2d = new FixedCamera2D("camera2d") { ClearFlags = ClearFlags.DepthAndStencil, }; EntityManager.Add(camera2d); // Dark background Entity dark = new Entity() .AddComponent(new Transform2D() { X = WaveServices.ViewportManager.LeftEdge, Y = WaveServices.ViewportManager.TopEdge, XScale = 1 / WaveServices.ViewportManager.RatioX, YScale = 1 / WaveServices.ViewportManager.RatioY, Opacity = 0.4f, DrawOrder = 2f, }) .AddComponent(new ImageControl(Color.Black, (int)WaveServices.ViewportManager.ScreenWidth, (int)WaveServices.ViewportManager.ScreenHeight)) .AddComponent(new ImageControlRenderer(DefaultLayers.GUI)); EntityManager.Add(dark); // Pause text Image i_pausetext = new Image(WaveContent.Assets.Textures.pause_text_PNG) { HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(0,132,0,0), }; EntityManager.Add(i_pausetext); // Panel Grid gridPanel = new Grid() { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Width = 475, Height = 418, }; EntityManager.Add(gridPanel.Entity); gridPanel.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) }); gridPanel.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) }); gridPanel.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) }); gridPanel.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Proportional) }); // Resume option ButtonOption b_resume = new ButtonOption("resume", ()=> { WaveServices.ScreenContextManager.Pop(); SoundsManager.Instance.PlaySound(SoundsManager.SOUNDS.Button); }); b_resume.Grid.SetValue(GridControl.RowProperty, 0); b_resume.Grid.SetValue(GridControl.ColumnProperty, 0); gridPanel.Add(b_resume.Grid); // Restart option ButtonOption b_restart = new ButtonOption("restart",() => { gameplayScene.CurrentState = GamePlayScene.States.HurryUp; WaveServices.ScreenContextManager.Pop(); SoundsManager.Instance.PlaySound(SoundsManager.SOUNDS.Button); }); b_restart.Grid.SetValue(GridControl.RowProperty, 1); b_restart.Grid.SetValue(GridControl.ColumnProperty, 0); gridPanel.Add(b_restart.Grid); // Exit option ButtonOption b_exit = new ButtonOption("exit", ()=> { gameplayScene.CurrentState = GamePlayScene.States.TapToStart; WaveServices.ScreenContextManager.Pop(); SoundsManager.Instance.PlaySound(SoundsManager.SOUNDS.Button); }); b_exit.Grid.SetValue(GridControl.RowProperty, 2); b_exit.Grid.SetValue(GridControl.ColumnProperty, 0); gridPanel.Add(b_exit.Grid); // Scene behavior this.AddSceneBehavior(new DebugSceneBehavior(), SceneBehavior.Order.PostUpdate); }
private void CreateGrid() { Grid grid = new Grid() { HorizontalAlignment = HorizontalAlignment.Right, Height = WaveServices.Platform.ScreenHeight, }; grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) }); grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(4, GridUnitType.Proportional) }); grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) }); grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) }); grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) }); grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) }); grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(3, GridUnitType.Proportional) }); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(200, GridUnitType.Pixel) }); EntityManager.Add(grid); #region Color UI TextBlock t_colors = new TextBlock() { Text = "Colors", VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(10), }; t_colors.SetValue(GridControl.RowProperty, 0); t_colors.SetValue(GridControl.ColumnProperty, 0); grid.Add(t_colors); StackPanel stackPanel = new StackPanel() { Margin = new Thickness(30, 0, 0, 0), }; stackPanel.SetValue(GridControl.RowProperty, 1); stackPanel.SetValue(GridControl.ColumnProperty, 0); grid.Add(stackPanel); RadioButton radio1 = new RadioButton() { Text = "Red", GroupName = "colors", Foreground = Color.Red, }; radio1.Checked += (s, o) => { this.cubeMaterial.DiffuseColor = Color.Red; }; stackPanel.Add(radio1); RadioButton radio2 = new RadioButton() { Text = "Green", GroupName = "colors", Foreground = Color.Green, }; radio2.Checked += (s, o) => { this.cubeMaterial.DiffuseColor = Color.Green; }; stackPanel.Add(radio2); RadioButton radio3 = new RadioButton() { Text = "Blue", GroupName = "colors", Foreground = Color.Blue, }; radio3.Checked += (s, o) => { this.cubeMaterial.DiffuseColor = Color.Blue; }; stackPanel.Add(radio3); RadioButton radio4 = new RadioButton() { Text = "White", GroupName = "colors", Foreground = Color.White, IsChecked = true, }; radio4.Checked += (s, o) => { this.cubeMaterial.DiffuseColor = Color.White; }; stackPanel.Add(radio4); #endregion #region Texture UI TextBlock t_texture = new TextBlock() { Text = "Textures", VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(10), }; t_texture.SetValue(GridControl.RowProperty, 2); t_texture.SetValue(GridControl.ColumnProperty, 0); grid.Add(t_texture); ToggleSwitch toggleTexture = new ToggleSwitch() { Margin = new Thickness(30, 0, 0, 0), Foreground = darkColor, Background = lightColor, IsOn = true, }; toggleTexture.Toggled += (s, o) => { this.cubeMaterial.TextureEnabled = toggleTexture.IsOn; }; toggleTexture.SetValue(GridControl.RowProperty, 3); toggleTexture.SetValue(GridControl.ColumnProperty, 0); grid.Add(toggleTexture); #endregion #region Scale UI TextBlock t_scale = new TextBlock() { Text = "Scale", VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(10), }; t_scale.SetValue(GridControl.RowProperty, 4); t_scale.SetValue(GridControl.ColumnProperty, 0); grid.Add(t_scale); Slider sliderScale = new Slider() { Width = 150, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(30, 0, 0, 0), Foreground = darkColor, Background = lightColor, Value = 50, }; sliderScale.RealTimeValueChanged += (s, o) => { this.cubeTransform.Scale = Vector3.One / 2 + (Vector3.One * (o.NewValue / 100f)); }; sliderScale.SetValue(GridControl.RowProperty, 5); sliderScale.SetValue(GridControl.ColumnProperty, 0); grid.Add(sliderScale); #endregion #region Reset UI Button b_reset = new Button() { Text = "Reset", Margin = new Thickness(10, 0, 0, 20), VerticalAlignment = VerticalAlignment.Bottom, Foreground = Color.White, BackgroundColor = lightColor, }; b_reset.Click += (s, o) => { radio4.IsChecked = true; toggleTexture.IsOn = true; sliderScale.Value = 50; this.sliderRotX.Value = 0; this.sliderRotY.Value = 0; }; b_reset.SetValue(GridControl.RowProperty, 6); b_reset.SetValue(GridControl.ColumnProperty, 0); grid.Add(b_reset); #endregion }