public override void SetUp() { UIElement.ScreenDimensions = new Size2(this.Graphics.Viewport.Width, this.Graphics.Viewport.Height); var window = new UIPanel(); window.Origin = UIOrigin.TopCentre; window.Placement.RelativeX = 0.5f; window.Placement.RelativeY = 0.2f; window.Size.X = 400; window.Size.Y = 400; window.Colour = new Color(0.1f, 0.1f, 0.1f); var menu = new UIButtonGroup(window); menu.Size.RelativeX = 1f; menu.Size.RelativeY = 0.8f; menu.Origin = UIOrigin.BottomCentre; menu.Placement.RelativeX = 0.5f; menu.Placement.RelativeY = 1f; menu.AddButton(Store.Instance.Fonts("Base", "envy12"), "Button 1", () => { }); menu.AddButton(Store.Instance.Fonts("Base", "envy12"), "Button 2", () => { }); menu.AddButton(Store.Instance.Fonts("Base", "envy12"), "Button 3", () => { }); menu.AddButton(Store.Instance.Fonts("Base", "envy12"), "Button 4", () => { }); this.UI.Add(window); /* * var button = new UIButton(this.window); * button.Colour = Color.DarkBlue; * button.Size = new Size2(this.window.Width / 2, 32); * button.Position = new Vector2(this.window.Width / 2, this.window.Height / 2); * button.Origin = UIOrigin.Centre; * //button.Label.Size = new Size2(this.window.Size.Width, 0); * button.Label.Position = new Vector2(button.Width / 2, button.Height / 2); * button.Label.Text = "Testing"; * button.Label.TextColour = Color.Yellow; * button.Label.Font = this.Store.Fonts("Base", "envy12"); */ }
private void SetupMenu() { this.UI.Clear(); this.UI.Enabled = false; this.UI.DrawMouseCursor = (mouse, renderer) => { Store.Instance.Sprites <SpriteTemplate>("Base", "mouse_cursor").DrawSprite(renderer.Screen, new Vector2(mouse.X, mouse.Y), Color.White, 0, new Vector2(0.5f), SpriteEffects.None); }; UIElement.ScreenDimensions = new Size2(this.Camera.Viewport.Width, this.Camera.Viewport.Height); var window = new UIPanel(); window.Origin = UIOrigin.TopCentre; window.Placement.RelativeX = 0.5f; window.Placement.RelativeY = 0.2f; window.Size.X = 400; window.Size.Y = 400; window.Colour = new Color(0.1f, 0.1f, 0.1f); var menu = new UIButtonGroup(window); menu.Size.RelativeX = 1f; menu.Size.RelativeY = 0.8f; menu.Origin = UIOrigin.BottomCentre; menu.Placement.RelativeX = 0.5f; menu.Placement.RelativeY = 1f; menu.AddButton(Store.Instance.Fonts("Base", "envy12"), "Resume game", () => { this.UI.Enabled = false; }); menu.AddButton(Store.Instance.Fonts("Base", "envy12"), "Quit to menu", () => { this.SceneEnded = true; }); this.UI.Add(window); }
public override void SetUp() { base.SetUp(); this.UI.Clear(); this.UI.DrawMouseCursor = (mouse, renderer) => { Store.Instance.Sprites <SpriteTemplate>("Base", "mouse_cursor").DrawSprite(renderer.Screen, new Vector2(mouse.X, mouse.Y), Color.White, 0, new Vector2(0.5f), SpriteEffects.None); }; this.UI.Enabled = true; UIElement.ScreenDimensions = new Size2(this.Graphics.Viewport.Width, this.Graphics.Viewport.Height); var window = new UIPanel(); window.Origin = UIOrigin.TopCentre; window.Placement.RelativeX = 0.5f; window.Placement.RelativeY = 0.2f; window.Size.X = 400; window.Size.Y = 400; window.Colour = new Color(0.1f, 0.1f, 0.1f); window.Enabled = true; var menu = new UIButtonGroup(window); menu.Size.RelativeX = 1f; menu.Size.RelativeY = 0.8f; menu.Origin = UIOrigin.BottomCentre; menu.Placement.RelativeX = 0.5f; menu.Placement.RelativeY = 1f; menu.AddButton(Store.Instance.Fonts("Base", "envy12"), "Play vs AI", () => { this.selectedItem = MenuItem.PlayGame; this.SceneEnded = true; }); menu.AddButton(Store.Instance.Fonts("Base", "envy12"), "Polygon bounds editor", () => { this.selectedItem = MenuItem.Editor; this.SceneEnded = true; }); //menu.AddButton(this.Store.Fonts("Base", "envy12"), "Button 2", Color.Yellow); //menu.AddButton(this.Store.Fonts("Base", "envy12"), "Button 3", Color.Yellow); menu.AddButton(Store.Instance.Fonts("Base", "envy12"), "Quit immediately", () => { this.selectedItem = MenuItem.Quit; this.SceneEnded = true; }); /* * window.MouseFocus += (owner) => * { * var mouse = Mouse.GetState(); * if (mouse.LeftButton == ButtonState.Pressed) * { * var local = window.ScreenToLocal(new Vector2(mouse.X, mouse.Y)); * if (this.mouseHold == null) * { * this.mouseHold = local; * } * window.Origin = UIOrigin.TopLeft; * local -= this.mouseHold.Value; * window.Placement.X = local.X; * window.Placement.Y = local.Y; * } * else * { * this.mouseHold = null; * } * }; * window.MouseLeave += (owner) => * { * this.mouseHold = null; * }; */ this.UI.Add(window); }