void LoadGui() { var viewportAdapter = new DefaultViewportAdapter(_sceneHandler._graphicsDevice); var guiRenderer = new GuiSpriteBatchRenderer(_sceneHandler._graphicsDevice, () => Matrix.Identity); var font = _sceneHandler._content.Load <BitmapFont>("Sensation"); var JoinButton = new Button { Content = "Start" }; JoinButton.PressedStateChanged += OnJoinButtonClick; BitmapFont.UseKernings = false; Skin.CreateDefault(font); chatText = new TextBox { Text = "Send message", Position = new Point(0, 150) }; var controlTest = new StackPanel { Items = { chatText, JoinButton }, VerticalAlignment = VerticalAlignment.Bottom }; var demoScreen = new Screen { Content = controlTest, }; _guiSystem = new GuiSystem(viewportAdapter, guiRenderer) { ActiveScreen = demoScreen }; }
/// <summary> /// Sets up user interface using MonoGame.Extended.Gui. /// </summary> private void SetupUserInterface() { var viewportAdapter = new BoxingViewportAdapter( this.Window, this.GraphicsDevice, this.ScreenWidth, this.ScreenHeight); var guiRenderer = new GuiSpriteBatchRenderer(this.GraphicsDevice, () => Matrix.Identity); BitmapFont guiFont = this.Content.Load <BitmapFont>("fonts/PixelAzureBondsBitmap24"); BitmapFont.UseKernings = false; Skin.CreateDefault(guiFont); this.guiSystem = new GuiSystem(viewportAdapter, guiRenderer) { ActiveScreen = new MonoGame.Extended.Gui.Screen { Content = new StackPanel { Width = this.ScreenWidth, Height = this.ScreenHeight, } } }; this.guiSystem.ActiveScreen.Hide(); }
protected override void LoadContent() { ViewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); //var skin = GuiSkin.FromFile(Content, @"Raw/adventure-gui-skin.json"); var guiRenderer = new GuiSpriteBatchRenderer(GraphicsDevice, ViewportAdapter.GetScaleMatrix); var font = Content.Load <BitmapFont>("small-font"); BitmapFont.UseKernings = false; Skin.CreateDefault(font); _selectDemoScreen = new SelectDemoScreen(_demos, LoadDemo, Exit); _guiSystem = new GuiSystem(ViewportAdapter, guiRenderer) { ActiveScreen = _selectDemoScreen, }; }
protected override void LoadContent() { Services.RegisterGameComponent <InputListenerComponent>(); Services.RegisterGameComponent <World>(); Services.RegisterGameComponent <ScreenManager>(); var bitmapFont = Content.Load <BitmapFont>("Fonts/bryndan-medium"); Skin.CreateDefault(bitmapFont); MessageHub.Subscribe <StartGameMessage>(msg => { LoadScreen <BattleScreen>(); MessageHub.Publish(new ResetWorldMessage(msg.GameState)); }); MessageHub.Subscribe <ExitGameMessage>(_ => { LoadScreen <MenuScreen>(); }); MessageHub.Subscribe <ServerDisconnectedMessage>(msg => { LoadScreen <MenuScreen>(); }); LoadScreen <MenuScreen>(); }
protected override void LoadContent() { ViewportAdapter = new DefaultViewportAdapter(GraphicsDevice); var guiRenderer = new GuiSpriteBatchRenderer(GraphicsDevice, () => Matrix.Identity); var font = Game.Content.Load <BitmapFont>("Menus/Color Picker/Sensation"); BitmapFont.UseKernings = false; Skin.CreateDefault(font); var demoScreen = new Screen { Content = new StackPanel { Margin = 5, Orientation = Orientation.Vertical, Items = { new Label("Buttons") { Margin = 5 }, new Label("TextBox") { Margin = 5 }, new MonoGame.Extended.Gui.Controls.TextBox { Text = "TextBox" }, } } }; guiSystem = new GuiSystem(ViewportAdapter, guiRenderer) { ActiveScreen = demoScreen }; base.LoadContent(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); plain = new Texture2D(GraphicsDevice, 1, 1); plain.SetData(new[] { Color.White }); font = Content.Load <SpriteFont>("font"); Skin.CreateDefault(Content.Load <BitmapFont>("arial")); _gui = new GuiSystem(new DefaultViewportAdapter(GraphicsDevice), new GuiSpriteBatchRenderer(GraphicsDevice, () => Matrix.Identity)); SDockPanel sDockPanel; CheckBox c_usercontrol; CheckBox c_traj; CheckBox c_drag; CheckBox c_resize; CheckBox c_cursor; CheckBox c_anglerand; Button okaybutton; Button exitbutton; NumericalBar speedbar; NumericalBar gspeedbar; NumericalBar trailbar; Label warninglabel; _gui.ActiveScreen = new Screen { Content = sDockPanel = new SDockPanel { Items = { new DockPanel { AttachedProperties ={ { DockPanel.DockProperty, Dock.Bottom } }, Items = { new DockPanel { Items = { (exitbutton = new Button{ Content = "Exit", Width = 100, AttachedProperties ={ { DockPanel.DockProperty, Dock.Right } } }), (okaybutton = new Button{ Content = "OK", }), } } } }, new StackPanel { Spacing = 0, BackgroundColor = Color.DimGray, Items = { new Label("Options") { Height = 70, Margin = new Thickness(10, 10, 10, 3), }, new Canvas { Height = 2, BackgroundColor = Color.White }, (c_usercontrol = new CheckBox{ Content = "User can control", Margin = new Thickness(1), IsChecked = false, }), (c_traj = new CheckBox{ Content = "Draw trajectories", Margin = new Thickness(1), IsChecked = true, }), (c_drag = new CheckBox{ Content = "Move ball", Margin = new Thickness(1), IsChecked = true, }), (c_resize = new CheckBox{ Content = "Resize window", Margin = new Thickness(1), IsChecked = false, }), (c_cursor = new CheckBox{ Content = "Show cursor", Margin = new Thickness(1), IsChecked = true, }), (c_anglerand = new CheckBox{ Content = "Angle randomisation", Margin = new Thickness(1), IsChecked = false, }), new DockPanel { Items = { new Label("Ball speed: ") { AttachedProperties ={ { DockPanel.DockProperty, Dock.Left } } }, (speedbar = new NumericalBar() { Suffix = "x", LBound = 0.1f, UBound = 8f, DecimalPlaces = 1, Value = 1f }) } }, //new DockPanel //{ // Items = // { // new Label("Game speed: ") // { // AttachedProperties ={{DockPanel.DockProperty, Dock.Left}} // }, // (gspeedbar=new NumericalBar() // { // Suffix="fps", // LBound=10, // UBound=500f, // DecimalPlaces=0, // Value=60f // }) // } //}, new DockPanel { Items = { new Label("Ball trail (experimental): ") { AttachedProperties ={ { DockPanel.DockProperty, Dock.Left } } }, (trailbar = new NumericalBar() { LBound = 0f, UBound = 100f, DecimalPlaces = 0, Value = 0f }) } }, (warninglabel = new Label("NB: AI performance may be reduced with the current options") { TextColor = Color.Transparent, }), }, }, } } }; sDockPanel.OnPointerMoveEvent += (object sender, EventArgs e) => { if (c_anglerand.IsChecked || speedbar.Value > 3.09) { warninglabel.TextColor = Color.PaleVioletRed; } else { warninglabel.TextColor = Color.Transparent; } }; okaybutton.Clicked += (object sender, EventArgs e) => { trail.Clear(); this.bothAI = !c_usercontrol.IsChecked; this.drawTraj = c_traj.IsChecked; this.allowDrag = c_drag.IsChecked; base.Window.AllowUserResizing = c_resize.IsChecked; base.IsMouseVisible = c_cursor.IsChecked; this.angleRandomisation = c_anglerand.IsChecked; this.trailno = (int)trailbar.Value; this.ballspeed = speedbar.Value; if (ballvel == Vector2.Zero) { ballvel = new Vector2(5 * ballspeed, 5 * ballspeed); } else { ballvel = new Vector2(Math.Sign(ballvel.X) * 5 * ballspeed, Math.Sign(ballvel.Y) * 5 * ballspeed); } _gui.ActiveScreen.Hide(); uiDismissed = true; }; exitbutton.Clicked += (object sender, EventArgs e) => { Exit(); }; }
void LoadGui() { var viewportAdapter = new DefaultViewportAdapter(_sceneHandler._graphicsDevice); var guiRenderer = new GuiSpriteBatchRenderer(_sceneHandler._graphicsDevice, () => Matrix.Identity); var font = _sceneHandler._content.Load <BitmapFont>("Sensation"); BitmapFont.UseKernings = false; Skin.CreateDefault(font); var JoinButton = new Button { Content = "Join to server" }; IPTextBox = new TextBox { Text = "127.0.0.1", HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom }; NameTextBox = new TextBox { Text = "Name", HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom }; JoinButton.PressedStateChanged += ChatText_PressedStateChanged; var controlTest = new StackPanel { Items = { new StackPanel { Items = { new Label("Name:") { HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, }, NameTextBox, }, Orientation = Orientation.Horizontal }, new StackPanel { Items = { new Label("Ip:") { HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, }, IPTextBox, }, Orientation = Orientation.Horizontal }, JoinButton } , VerticalAlignment = VerticalAlignment.Centre, HorizontalAlignment = HorizontalAlignment.Centre, Spacing = 5 }; var demoScreen = new Screen { Content = controlTest }; _guiSystem = new GuiSystem(viewportAdapter, guiRenderer) { ActiveScreen = demoScreen }; }
public GuiDesigner(GraphicsDevice graphicsDevice, BitmapFont font) { Skin.CreateDefault(font); _guiSystem = CreateUI(graphicsDevice); CommandManager.GroupAdded += CommandManagerOnGroupAdded; }
protected override void LoadContent() { var viewportAdapter = new DefaultViewportAdapter(GraphicsDevice); var guiRenderer = new GuiSpriteBatchRenderer(GraphicsDevice, () => Matrix.Identity); var font = Content.Load <BitmapFont>("Sensation"); BitmapFont.UseKernings = false; Skin.CreateDefault(font); //var parser = new MarkupParser(); //var mainScreen = new Screen //{ // Content = parser.Parse("Features/MainWindow.mgeml", new object()) //}; //var textBox = mainScreen.FindControl<TextBox>("TextBox"); //var statusLabel = mainScreen.FindControl<Label>("StatusLabel"); //textBox.CaretIndexChanged += (sender, args) => // statusLabel.Content = $"Ln {textBox.LineIndex + 1}, Ch {textBox.CaretIndex + 1}"; var stackTest = new DemoViewModel("Stack Panels", new StackPanel { Items = { new Button { Content = "Press Me", HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }, new Button { Content = "Press Me", HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom }, new Button { Content = "Press Me", HorizontalAlignment = HorizontalAlignment.Centre, VerticalAlignment = VerticalAlignment.Centre }, new Button { Content = "Press Me", HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }, } }); var dockTest = new DemoViewModel("Dock Panels", new DockPanel { Items = { new Button { Content = "Dock.Top", AttachedProperties ={ { DockPanel.DockProperty, Dock.Top } } }, new Button { Content = "Dock.Bottom", AttachedProperties ={ { DockPanel.DockProperty, Dock.Bottom } } }, new Button { Content = "Dock.Left", AttachedProperties ={ { DockPanel.DockProperty, Dock.Left } } }, new Button { Content = "Dock.Right", AttachedProperties ={ { DockPanel.DockProperty, Dock.Right } } }, new Button { Content = "Fill" } } }); var controlTest = new DemoViewModel("Basic Controls", new StackPanel { Margin = 5, Orientation = Orientation.Vertical, Items = { new Label("Buttons") { Margin = 5 }, new StackPanel { Orientation = Orientation.Horizontal, Spacing = 5, Items = { new Button { Content = "Enabled" }, new Button { Content = "Disabled", IsEnabled = false }, new ToggleButton { Content = "ToggleButton" } } }, new Label("TextBox") { Margin = 5 }, new TextBox { Text = "TextBox" }, new Label("CheckBox") { Margin = 5 }, new CheckBox { Content = "Check me please!" }, new Label("ListBox") { Margin = 5 }, new ListBox { Items = { "ListBoxItem1", "ListBoxItem2", "ListBoxItem3" }, SelectedIndex = 0 }, new Label("ProgressBar") { Margin = 5 }, new ProgressBar { Progress = 0.5f, Width = 100 }, new Label("ComboBox") { Margin = 5 }, new ComboBox { Items = { "ComboBoxItemA", "ComboBoxItemB", "ComboBoxItemC" }, SelectedIndex =0, HorizontalAlignment = HorizontalAlignment.Left } } }); var demoScreen = new Screen { Content = new DockPanel { LastChildFill = true, Items = { new ListBox { Name = "DemoList", AttachedProperties = { { DockPanel.DockProperty, Dock.Left } }, ItemPadding = new Thickness(5), VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Left, SelectedIndex = 0, Items ={ controlTest, stackTest, dockTest } }, new ContentControl { Name = "Content", BackgroundColor = new Color(30, 30, 30) } } } }; _guiSystem = new GuiSystem(viewportAdapter, guiRenderer) { ActiveScreen = demoScreen }; var demoList = demoScreen.FindControl <ListBox>("DemoList"); var demoContent = demoScreen.FindControl <ContentControl>("Content"); demoList.SelectedIndexChanged += (sender, args) => demoContent.Content = (demoList.SelectedItem as DemoViewModel)?.Content; demoContent.Content = (demoList.SelectedItem as DemoViewModel)?.Content; }