protected ContentControl(GuiSystem guiSystem, XmlElement element) : base(guiSystem, element) { if (element.HasChildNodes) { Child = CreateFromXmlType(guiSystem, (XmlElement)element.FirstChild); } }
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 }; }
protected Game2D(int defaultScreenWidth = 800, int defaultScreenHeight = 600, bool fullscreen = false, bool useGamePad = false, DepthFormat depthFormat = DepthFormat.None, string configFileName = null) { _configFileName = string.IsNullOrEmpty(configFileName) ? DefaultConfigFileName : configFileName; LoadGameProperties(); var width = GetScreenSizeComponent(defaultScreenWidth, GameProperty.GameResolutionXProperty, 800); var height = GetScreenSizeComponent(defaultScreenHeight, GameProperty.GameResolutionYProperty, 600); GraphicsDeviceManager = new GraphicsDeviceManager(this) { PreferredBackBufferWidth = width, PreferredBackBufferHeight = height, PreferredDepthStencilFormat = depthFormat, IsFullScreen = fullscreen }; Content.RootDirectory = "Content"; Keyboard = new KeyboardEx(); Mouse = new MouseEx(); GuiSystem = new GuiSystem(this); DepthRenderer = new DepthRenderer(); Cursor = new Cursor(this); if (useGamePad) { GamePad = new GamePadEx(); } _clearOptions = ClearOptions.Target; if (depthFormat != DepthFormat.None) { _clearOptions |= ClearOptions.DepthBuffer; } _registeredGlobals = new Dictionary <string, GameObject>(); }
protected override void LoadContent() { var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); _camera = new Camera2D(viewportAdapter); var titleScreen = LoadScreen(@"Content/title-screen.json"); var guiRenderer = new GuiSpriteBatchRenderer(GraphicsDevice, titleScreen.Skin.DefaultFont, _camera.GetViewMatrix); _guiSystem = new GuiSystem(viewportAdapter, guiRenderer) { Screen = titleScreen }; var panel = titleScreen.FindControl <GuiPanel>("MainPanel"); var closeButton = titleScreen.FindControl <GuiButton>("CloseButton"); closeButton.Clicked += (sender, args) => { panel.IsVisible = false; }; var quitButton = titleScreen.FindControl <GuiButton>("QuitButton"); quitButton.Clicked += (sender, args) => Exit(); _progressBar = titleScreen.FindControl <GuiProgressBar>("ProgressBar"); }
/// <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 internal override void OnMouseDoubleClicked(MouseEventArgs e) { // base class processing base.OnMouseDoubleClicked(e); if (GuiSystem.IsMouseButtonSet(e.Button, MouseButtons.Left)) { // if masked, set up to select all if (TextMasked) { dragAnchorIndex = 0; this.CaretIndex = text.Length; } else { // not masked, so select the word that was double clicked dragAnchorIndex = TextUtil.GetWordStartIndex(text, (caretIndex == text.Length) ? caretIndex : caretIndex + 1); CaretIndex = TextUtil.GetNextWordStartIndex(text, (caretIndex == text.Length) ? caretIndex : caretIndex + 1); } // perform actual selection operation SetSelection(dragAnchorIndex, caretIndex); e.Handled = true; } }
private void InitializeDrawElements(GuiSystem guiSystem) { var itemDescriptor = guiSystem.GetSkinItemDescriptor<ButtonSkinItemDescriptor>(); _normalSprite = new NinePatchSprite(itemDescriptor.SkinTexture, itemDescriptor.NormalRectangle, itemDescriptor.ButtonBorder); _hoverSprite = new NinePatchSprite(itemDescriptor.SkinTexture, itemDescriptor.HoverRectangle, itemDescriptor.ButtonBorder); }
internal RootElement(GuiSystem gui) { SetGuiSystem(gui ?? throw new ArgumentNullException(nameof(gui))); DefaultAnchor = CanvasAnchor.Fill; DefaultAutoSize = true; DefaultAlignment = Vector2.Zero; }
public BattleScreen(Game game, GuiSystem guiSystem, Variables variables, MessageHub messageHub, SharedContext sharedContext, KeyboardListener keyboardListener) : base(game) { this.guiSystem = guiSystem; this.variables = variables; this.messageHub = messageHub; this.sharedContext = sharedContext; keyboardListener.KeyPressed += KeyboardListenerOnKeyPressed; }
private void InitializeDrawElements(GuiSystem guiSystem) { var itemDescriptor = guiSystem.GetSkinItemDescriptor<FrameSkinItemDescriptor>(); _headerFont = itemDescriptor.BigFont; _contentBorder = new NinePatchSprite(itemDescriptor.SkinTexture, itemDescriptor.SourceRectangle, itemDescriptor.FrameBorder); _headerBorder = new NinePatchSprite(itemDescriptor.SkinTexture, itemDescriptor.SourceRectangle, itemDescriptor.FrameBorder); }
public void Unload() { if (_guiSystem != null) { OnUnload(); _guiSystem = null; } }
public Frame(GuiSystem guiSystem, XmlElement element) : base(guiSystem, element) { InitializeDrawElements(guiSystem); if (element.HasAttribute("Title")) { Title = element.GetAttribute("Title"); } }
static void OnDrawRootGizmo(GuiSystem guiSystem, GizmoType gizmoType) { if (guiSystem.enabled && guiSystem.Camera != null) { var oldColor = Gizmos.color; Gizmos.color = Color.magenta; Gizmos.matrix = Matrix4x4.TRS(guiSystem.transform.position, guiSystem.transform.rotation, guiSystem.transform.localScale); Gizmos.DrawWireCube(Vector3.zero, new Vector3(guiSystem.Camera.aspect * guiSystem.ScreenHeight, guiSystem.ScreenHeight, 0f)); Gizmos.color = oldColor; } }
public void Load(GuiSystem guiSystem) { if (_guiSystem != null) { throw new InvalidOperationException("GUI style has already been bound."); } _guiSystem = guiSystem ?? throw new ArgumentNullException(nameof(guiSystem)); OnLoad(); }
public override void Dispose() { foreach (CeguiDotNet.Imageset imgset in mDebugRTTImageSets) { CeguiDotNet.ImagesetManager.getSingleton().destroyImageset(imgset); } mDebugRTTImageSets.Clear(); mDebugRTTImageSets = null; mMainNode = null; mSpinny = null; mhvListener.Dispose(); mhvListener = null; mhdrListener.Dispose(); mhdrListener = null; mCompositorSelectorViewManager = null; mGuiAvg = null; mGuiCurr = null; mGuiBest = null; mGuiWorst = null; mGuiTris = null; mGuiDbg = null; mGuiRoot = null; mDebugRTTListbox = null; mDebugRTTImageSets = null; if (WindowManager.Instance != null) { WindowManager.Instance.destroyAllWindows(); } if (mGuiSystem != null) { mGuiSystem.Dispose(); } mGuiSystem = null; if (mGuiRenderer != null) { mGuiRenderer.Dispose(); } mGuiRenderer = null; if (mLog != null) { mLog.Dispose(); } mLog = null; base.Dispose(); }
protected internal override void OnMouseUp(MouseEventArgs e) { // base class processing base.OnMouseUp(e); if (GuiSystem.IsMouseButtonSet(e.Button, MouseButtons.Left)) { //ReleaseInput(); e.Handled = true; } }
public Image(GuiSystem guiSystem, XmlElement element) : base(guiSystem, element) { if(element.HasAttribute("Source")) { Texture = guiSystem.GameContext.Content.Load<Texture2D>("Textures/" + element.GetAttribute("Source")); } if(Texture != null) { SourceRectangle = element.HasAttribute("NormalRectangle") ? element.GetAttribute("NormalRectangle").ParseRectangle() : Texture.Bounds; } }
public StackPanel(GuiSystem guiSystem, XmlElement element) : base(guiSystem, element) { if(element.HasAttribute("Orientation")) { Orientation = (Orientation)Enum.Parse(typeof(Orientation), element.GetAttribute("Orientation")); } foreach (XmlElement childElement in element.ChildNodes) { AddChild(CreateFromXmlType(guiSystem, childElement)); } }
public ScrollViewer(GuiSystem guiSystem, XmlElement element) : base(guiSystem, element) { if (element.HasAttribute("CanScrollHorizontally")) { CanScrollHorizontally = Boolean.Parse(element.GetAttribute("CanScrollHorizontally")); } if (element.HasAttribute("CanScrollVertically")) { CanScrollVertically = Boolean.Parse(element.GetAttribute("CanScrollVertically")); } InitializeDrawElements(); }
protected override void LoadContent() { var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); _camera = new OrthographicCamera(viewportAdapter); var skin = GuiSkin.FromFile(Content, @"Raw/adventure-gui-skin.json"); var guiRenderer = new GuiSpriteBatchRenderer(GraphicsDevice, _camera.GetViewMatrix); _guiSystem = new GuiSystem(viewportAdapter, guiRenderer) { Screens = { new GuiLayoutScreen(skin, GraphicsDevice) } }; }
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); _guiSystem = new GuiSystem(ViewportAdapter, guiRenderer) { Screens = { new SelectDemoScreen(skin, _demos, LoadDemo) } }; //LoadDemo(_demoIndex); }
protected override void LoadContent() { base.LoadContent(); var parameters = new GuiSystemSkinParameters { XmlSkinDescriptorFile = "GuiSkin/GuiSkin.xml", BigFont = Content.Load <SpriteFont>(ResourceNames.Spritefonts.BigFont), NormalFont = Content.Load <SpriteFont>(ResourceNames.Spritefonts.NormalFont), SkinTexture = Content.Load <Texture2D>(ResourceNames.Textures.bombrush_guiskin) }; GuiSystem.SetSkin(parameters); IsMouseVisible = true; }
protected override void LoadContent() { IsMouseVisible = false; // _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, _graphicsDeviceManager.PreferredBackBufferWidth, _graphicsDeviceManager.PreferredBackBufferHeight); _viewportAdapter = new WindowViewportAdapter(Window, GraphicsDevice); _skin = GuiSkin.FromFile(Content, @"Content/adventure-gui-skin.json", typeof(MyPanel)); var guiRenderer = new GuiSpriteBatchRenderer(GraphicsDevice, _viewportAdapter.GetScaleMatrix); var viewModel = new ViewModel(); LoadGuiButtonScreen(); //_screen = GuiScreen.FromFile(Content, "Content/test-addition-screen.json", typeof(MyPanel)); //Window.ClientSizeChanged += OnClientSizeChanged; //_screen = GuiScreen.FromFile(Content, "Content/adventure-gui-screen.json", typeof(MyPanel)); //var listBox = _screen.FindControl<GuiListBox>("Listbox"); //listBox.Items.Add(new { Name = "Hello World 1" }); //listBox.Items.Add(new { Name = "Hello World 2" }); //listBox.Items.Add(new { Name = "Hello World 3" }); //listBox.Items.Add(new { Name = "Hello World 4" }); //var comboBox = _screen.FindControl<GuiComboBox>("ComboBox"); //comboBox.Items.Add(new { Name = "Hello World 1" }); //comboBox.Items.Add(new { Name = "Hello World 2" }); //comboBox.Items.Add(new { Name = "Hello World 3" }); //comboBox.Items.Add(new { Name = "Hello World 4" }); //var submit = _screen.FindControl<GuiSubmit>("FormSubmit"); //submit.SetBinding(nameof(GuiButton.Text), nameof(viewModel.Name)); //submit.Clicked += OnFormSubmitClicked; //submit.Clicked += (s, e) => { viewModel.Name = viewModel.Name == "Change" ? "Alistrasza" : "Change"; }; _screen.BindingContext = viewModel; _guiSystem = new GuiSystem(_viewportAdapter, guiRenderer) { Screens = { _screen // new BindingScreen(_skin, viewModel) } }; }
protected override void LoadContent() { base.LoadContent(); Heads.LoadContent(Content); Resources.LoadContent(Content); Resources.ChangeResolution(ScreenWidth, ScreenHeight); Cursor.AddCursorType("Arrow", new CursorType(Content.Load <Texture2D>("textures/cursor"))); var parameters = new GuiSystemSkinParameters { XmlSkinDescriptorFile = "Content/GuiLayouts/Skin/GuiSkin.xml", BigFont = Resources.BigFont, NormalFont = Resources.NormalFont, SkinTexture = Content.Load <Texture2D>("textures/bombrush_guiskin") }; GuiSystem.SetSkin(parameters); }
public GuiManager(ContentManager contentManager, GameWindow gameWindow, GraphicsDevice graphicsDevice, string defaultSkinFileName) { this.contentManager = contentManager; this.gameWindow = gameWindow; this.graphicsDevice = graphicsDevice; int width = (int)(DEFAULT_GUI_HEIGHT * graphicsDevice.Viewport.AspectRatio); int height = DEFAULT_GUI_HEIGHT; viewportAdapter = new BoxingViewportAdapter(gameWindow, graphicsDevice, width, height, width, 0); //Fixed height, any width guiCamera = new Camera2D(viewportAdapter); guiRenderer = new GuiSpriteBatchRenderer(graphicsDevice, guiCamera.GetViewMatrix); guiSystem = new GuiSystem(viewportAdapter, guiRenderer); DefaultSkin = GuiSkin.FromFile(contentManager, defaultSkinFileName); DefaultSkin.Cursor = null; }
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, }; }
public Grid(GuiSystem guiSystem, XmlElement element) : base(guiSystem, element) { var columnDefinitionNodes = element.SelectNodes("Grid.ColumnDefinitions/ColumnDefinition"); var rowDefinitionNodes = element.SelectNodes("Grid.RowDefinitions/RowDefinition"); if(columnDefinitionNodes == null || columnDefinitionNodes.Count == 0) { _columnDefinitions.Add(new GridItemDefinition(GridItemDefinition.MaxSize, 0)); } else { var index = 0; foreach(XmlElement columnElement in columnDefinitionNodes) { _columnDefinitions.Add(new GridItemDefinition("Width", index++, columnElement)); } } if (rowDefinitionNodes == null || rowDefinitionNodes.Count == 0) { _rowDefinitions.Add(new GridItemDefinition(GridItemDefinition.MaxSize, 0)); } else { var index = 0; foreach (XmlElement columnElement in rowDefinitionNodes) { _rowDefinitions.Add(new GridItemDefinition("Height", index++, columnElement)); } } foreach (XmlElement childElement in element.ChildNodes) { if (childElement.LocalName == "Grid.ColumnDefinitions") continue; if (childElement.LocalName == "Grid.RowDefinitions") continue; var gridRow = Math.Min(_rowDefinitions.Count-1, int.Parse(childElement.GetAttribute("Grid.Row"))); var gridColumn = Math.Min(_columnDefinitions.Count-1, int.Parse(childElement.GetAttribute("Grid.Column"))); var childGuiElement = CreateFromXmlType(GuiSystem, childElement); AddChild(gridColumn, gridRow, childGuiElement); } }
public override void Dispose() { mBackgroundWindow.Dispose(); mBackgroundWindow = null; mTestWindow.Dispose(); mTestWindow = null; mQuitButton.Dispose(); mQuitButton = null; mEditbox.Dispose(); mEditbox = null; WindowManager.Instance.destroyAllWindows(); mGuiSystem.Dispose(); mGuiSystem = null; mGuiRenderer.Dispose(); mGuiRenderer = null; base.Dispose(); }
protected override void LoadContent() { IsMouseVisible = false; _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, _graphicsDeviceManager.PreferredBackBufferWidth, _graphicsDeviceManager.PreferredBackBufferHeight); var skin = GuiSkin.FromFile(Content, @"Content/adventure-gui-skin.json", typeof(MyPanel)); var guiRenderer = new GuiSpriteBatchRenderer(GraphicsDevice, _viewportAdapter.GetScaleMatrix); var viewModel = new ViewModel(); _guiSystem = new GuiSystem(_viewportAdapter, guiRenderer) { Screens = { new BindingScreen(skin, viewModel) } }; }
public TextBox(GuiSystem guiSystem, XmlElement element) : base(guiSystem, element) { InitializeDrawElements(); if (element.HasAttribute("InputType")) { InputType = (InputType)Enum.Parse(typeof(InputType), element.GetAttribute("InputType")); } if (element.HasAttribute("MaxInputCharacters")) { MaxInputCharacters = int.Parse(element.GetAttribute("MaxInputCharacters")); } if (element.HasAttribute("Text")) { Text = element.GetAttribute("Text"); } }
protected internal override void OnMouseDown(MouseEventArgs e) { // base class handling base.OnMouseDown(e); if (GuiSystem.IsMouseButtonSet(e.Button, MouseButtons.Left)) { // grab inputs CaptureInput(); // handle mouse down ClearSelection(); dragging = true; Rect absRect = GetVisibleTextArea(); PointF pt = new PointF(e.X - absRect.Left, e.Y - absRect.Top); dragAnchorIndex = GetTextIndexFromPosition(pt); this.CaretIndex = dragAnchorIndex; e.Handled = true; } }
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(); }
protected override void LoadContent() { IsMouseVisible = false; _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); _camera = new Camera2D(_viewportAdapter); _spriteBatch = new SpriteBatch(GraphicsDevice); _backgroundTexture = Content.Load <Texture2D>("Textures/colored_castle"); var titleScreen = GuiScreen.FromFile(Content, @"Content/title-screen.json"); var guiRenderer = new GuiSpriteBatchRenderer(GraphicsDevice, _camera.GetViewMatrix); _guiSystem = new GuiSystem(_viewportAdapter, guiRenderer) { Screens = { titleScreen } }; var quitButton = titleScreen.FindControl <GuiButton>("QuitButton"); quitButton.Clicked += (sender, args) => _game.Back(); }
public override void Dispose() { mBackgroundWindow.Dispose(); mBackgroundWindow = null; mEditorWindow.Dispose(); mEditorWindow = null; mQuitButton.Dispose(); mQuitButton = null; mEditbox.Dispose(); mEditbox = null; mCombobox.Dispose(); mCombobox = null; mCboItem1 = null; mCboItem2 = null; mCboItem3 = null; mCboItem4 = null; WindowManager.Instance.destroyAllWindows(); mGuiSystem.Dispose(); mGuiSystem = null; mGuiRenderer.Dispose(); mGuiRenderer = null; mLog = null; base.Dispose(); }
protected override void CreateScene() { mLog = LogManager.Singleton.createLog("DemoCEGUI.log", false, true); mLog.LogMessage("My new Log. Hells yeah!"); base.mSceneManager.AmbientLight = Color.FromArgb(125, 125, 125, 125); base.mSceneManager.SetSkyDome(true, "Examples/CloudySky", 5, 8); mGuiRenderer = new OgreCEGUIRenderer(base.mRenderWindow, (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY, false, 3000, mSceneManager); mGuiRenderer.Initialise(); mGuiSystem = new GuiSystem(mGuiRenderer); //mGuiSystem = GuiSystem.CreateGuiSystemSpecial(mGuiRenderer); Logger.Instance.setLoggingLevel(LoggingLevel.Informative); SchemeManager.Instance.LoadScheme("TaharezLookSkin.scheme"); mGuiSystem.SetDefaultMouseCursor("TaharezLook", "MouseArrow"); mGuiSystem.DefaultFontName = "BlueHighway-12"; mBackgroundWindow = WindowManager.Instance.CreateWindow("DefaultWindow", "BackgroundWindow"); mGuiSystem.GUISheet = mBackgroundWindow; mEditorWindow = WindowManager.Instance.CreateWindow("TaharezLook/FrameWindow", "TestWindow"); mBackgroundWindow.AddChildWindow(mEditorWindow); mEditorWindow.SetSize(0.9f, 0.9f); mEditorWindow.SetPosition(0.05f, 0.05f); mEditorWindow.Text = "CeguiDotNet Demo"; mEditorWindow.SubscribeEvents(); mQuitButton = WindowManager.Instance.CreatePushButton("TaharezLook/Button", "QuitButton"); mQuitButton.Text = "Quit"; mQuitButton.SetPosition(0.1f, 0.15f); mQuitButton.SetSize(0.8f, 0.15f); mQuitButton.SubscribeEvents(); mQuitButton.Clicked += new WindowEventDelegate(QuitClicked); mEditorWindow.AddChildWindow(mQuitButton); mEditbox = WindowManager.Instance.CreateEditbox("TaharezLook/Editbox", "Editbox"); mEditbox.Text = "Editbox"; mEditbox.SetPosition(0.1f, 0.32f); mEditbox.SetSize(0.8f, 0.15f); mEditbox.setReadOnly(false); mEditbox.SubscribeEvents(); mEditbox.KeyDown += new CeguiDotNet.KeyEventDelegate(this.UsernameCharacterKey); mEditorWindow.AddChildWindow(mEditbox); mCombobox = WindowManager.Instance.CreateCombobox("TaharezLook/Combobox", "Combobox"); mCombobox.SetPosition(0.1f, 0.49f); mCombobox.SetSize(0.8f, 0.25f); mCombobox.setReadOnly(false); mCombobox.SubscribeEvents(); mCombobox.ListSelectionChanged += new WindowEventDelegate(this.combobox_SelectionChanged); mCombobox.TextAccepted += new WindowEventDelegate(this.combobox_TextAccepted); mEditorWindow.AddChildWindow(mCombobox); mCboItem1 = new ListboxTextItem("Item 1", 0, IntPtr.Zero, false, true); mCboItem1.setAutoDeleted(false); mCombobox.addItem(mCboItem1); mCboItem2 = new ListboxTextItem("Item 2", 1, IntPtr.Zero, false, true); mCboItem2.setAutoDeleted(false); mCombobox.addItem(mCboItem2); mCboItem3 = new ListboxTextItem("Item 3", 2, IntPtr.Zero, false, true); mCboItem3.setAutoDeleted(false); mCombobox.addItem(mCboItem3); mCboItem4 = new ListboxTextItem("Item 4", 3, IntPtr.Zero, false, true); mCboItem4.setAutoDeleted(false); mCombobox.addItem(mCboItem4); mEditorWindow.Show(); }
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; }
protected ContentControl(GuiSystem guiSystem) : base(guiSystem) { }
public Frame(GuiSystem guiSystem) : base(guiSystem) { }
public TextBlock(GuiSystem guiSystem) : base(guiSystem) { InitializeDrawElements(); }
public Image(GuiSystem guiSystem) : base(guiSystem) { }
public Grid(GuiSystem guiSystem) : base(guiSystem) { }
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 }; }
static void OnDrawRootGizmo(GuiSystem guiSystem, GizmoType gizmoType) { if (guiSystem.enabled && guiSystem.Camera != null) { var oldColor = Gizmos.color; Gizmos.color = Color.magenta; Gizmos.matrix = Matrix4x4.TRS (guiSystem.transform.position, guiSystem.transform.rotation, guiSystem.transform.localScale); Gizmos.DrawWireCube (Vector3.zero, new Vector3 (guiSystem.Camera.aspect * guiSystem.ScreenHeight, guiSystem.ScreenHeight, 0f)); Gizmos.color = oldColor; } }
public StackPanel(GuiSystem guiSystem) : base(guiSystem) { }
/// <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(); }; }
public TextBlock(GuiSystem guiSystem, XmlElement element) : base(guiSystem, element) { InitializeDrawElements(); if (element.HasAttribute("Text")) Text = element.GetAttribute("Text"); }
public ScrollViewer(GuiSystem guiSystem) : base(guiSystem) { InitializeDrawElements(); }
public Button(GuiSystem guiSystem) : base(guiSystem) { InitializeDrawElements(guiSystem); }
public GuiDesigner(GraphicsDevice graphicsDevice, BitmapFont font) { Skin.CreateDefault(font); _guiSystem = CreateUI(graphicsDevice); CommandManager.GroupAdded += CommandManagerOnGroupAdded; }
public Button(GuiSystem guiSystem, XmlElement element) : base(guiSystem, element) { InitializeDrawElements(guiSystem); }