public override void Init(Game game, GUIData data) { Color = Color.White; var skin = new Skin(data.GreyImageMap, data.GreyMap); var text = new Text(data.GreySpriteFont, Color.Black); Gui = new Gui(game, skin, text) { Widgets = new Widget[] { new Button(10, 10 + (40 * 0), "Button"), new Button(10, 10 + (40 * 1), "Skin"), new Button(10, 10 + (40 * 2), "Change Label", buttonEvent : delegate(Widget widget) { ((Button)widget).Label = _label.Value; }), _label = new SingleLineTextBox(220, 10 + (40 * 2), 100, 10), new Button(10, 10 + (40 * 4), "TextPadding = 25", 25), new Button(10, 10 + (40 * 5), "TextPadding = 25") { TextPadding = 25 }, new Button(10, 10 + (40 * 6), "Change TextPadding", buttonEvent : delegate(Widget widget) { int value; if (int.TryParse(_padding.Value, out value)) { ((Button)widget).TextPadding = value; } }), _padding = new SingleLineTextBox(220, 10 + (40 * 6), 100, 10), new Button(10, 10 + (40 * 8), 200, "Width = 200"), new Button(10, 10 + (40 * 9), "Width = 200") { Width = 200 }, new Button(10, 10 + (40 * 10), "Change Width", buttonEvent : delegate(Widget widget) { int value; if (int.TryParse(_width.Value, out value)) { ((Button)widget).Width = value; } }), _width = new SingleLineTextBox(220, 10 + (40 * 10), 100, 10) } }; }
public override void Init(Game1 game) { Color = Color.White; var skin = new Skin(game.GreyImageMap, game.GreyMap); var text = new Text(game.GreySpriteFont, Color.Black); var testSkin = new Skin(game.TestImageMap, game.TestMap); var testText = new Text(game.TestSpriteFont, Color.Black); var testSkins = new[] { new Tuple<string, Skin>("testSkin", testSkin) }; var testTexts = new[] { new Tuple<string, Text>("testText", testText) }; _gui = new Gui(game, skin, text, testSkins, testTexts) { Widgets = new Widget[] { new Button(10, 10 + (40 * 0), "Button"), new Button(10, 10 + (40 * 1), "Skin") { Skin = "testSkin", Text = "testText" }, new Button(10, 10 + (40 * 2), "Change Label", buttonEvent: delegate(Widget widget) { ((Button)widget).Label = _label.Value; }), _label = new SingleLineTextBox(220, 10 + (40 * 2), 100, 10), new Button(10, 10 + (40 * 4), "TextPadding = 25", 25), new Button(10, 10 + (40 * 5), "TextPadding = 25") { TextPadding = 25 }, new Button(10, 10 + (40 * 6), "Change TextPadding", buttonEvent: delegate(Widget widget) { int value; if (int.TryParse(_padding.Value, out value)) { ((Button)widget).TextPadding = value; } }), _padding = new SingleLineTextBox(220, 10 + (40 * 6), 100, 10), new Button(10, 10 + (40 * 8), 200, "Width = 200"), new Button(10, 10 + (40 * 9), "Width = 200") { Width = 200 }, new Button(10, 10 + (40 * 10), "Change Width", buttonEvent: delegate(Widget widget) { int value; if (int.TryParse(_width.Value, out value)) { ((Button)widget).Width = value; } }), _width = new SingleLineTextBox(220, 10 + (40 * 10), 100, 10) } }; }
public override void OnResize() { base.OnResize(); _gui.Widgets = new Widget[0]; int serverListHeight = SpaceGame.Instance.GetHeight() - Constants.BUTTON_HEIGHT - 1; IP = ServerIP?.Value ?? "127.0.0.1"; ServerList = new Panel(0, 0, SpaceGame.Instance.GetWidth(), serverListHeight); ConnectButton = new Button(0, serverListHeight, 100, "Connect"); RefreshButton = new Button(100, serverListHeight, 100, "Refresh", Refresh); ServerIP = new SingleLineTextBox(200, serverListHeight, 250, 15) { Value = IP }; UpdateServerList(); _gui.AddWidget(ServerList); _gui.AddWidget(ConnectButton); _gui.AddWidget(RefreshButton); _gui.AddWidget(ServerIP); }
// ================================================================================ // Interface // ================================================================================ public override void OnInit() { int leftcolumn = 120; Gui.AddWidgets(new Widget[] { panel_Control = new Elements.Window(4, 4 + 24, leftcolumn, 84), panel_ChunksList = new Elements.Window(4, 4 + 28 + 84, leftcolumn, 592 - 28 - 84), panel_CurrentChunk = new Elements.Window(leftcolumn + 8, 4 + 24, 800 - leftcolumn - 12, 592 - 24), }); panel_Control.AddWidgets(new Widget[] { lblTileSetCount = new Label(8, 14, string.Empty), new Button(leftcolumn - 82, 4, 32, "+", click_AddChunk), new Button(leftcolumn - 46, 4, 32, "-", click_RemoveChunk), cmbTilesets = new ComboBox(4, 40, leftcolumn - 30, string.Empty) { OnSelectionChanged = cmbTilesets_SelectionChanged }, }); panel_ChunksList.AddWidgets(new Widget[] { lstChunks = new Elements.ListBox <Data.Chunk>(0, 0, panel_ChunksList.InputArea.Width, panel_ChunksList.InputArea.Height) { OnSelectionChanged = lstChunks_OnSelectionChanged } }); panel_CurrentChunk.AddWidgets(new Widget[] { new Label(14, 12, "Chunk name:"), txtChunkName = new SingleLineTextBox(100, 8, 200, 20, txtChunkName_ValueChanged), }); createCurrentChunkPanel(); refreshControls(); loadChunk(State.SelectedChunk); }
// ================================================================================ // Initialization // ================================================================================ public override void OnInit() { int leftcolumn = 120; // Add panels: Control, List, CurrentSprite, and TileGfx Gui.AddWidgets(new Widget[] { panel_Control = new Window(4, 4 + 24, leftcolumn, 84), panel_List = new Window(4, 4 + panel_Control.Area.Bottom, leftcolumn, 592 - 28 - panel_Control.Area.Height), panel_CurrentSprite = new Window(leftcolumn + 8, 4 + 24, 800 - leftcolumn - 12, 592 - 24 - 4 - 276), panel_TileGfx = new Window(leftcolumn + 8, 4 + panel_CurrentSprite.Area.Bottom, panel_CurrentSprite.Area.Width, 276) }); panel_Control.AddWidgets(new Widget[] { lblSpriteCount = new Label(8, 14, string.Empty), new Button(leftcolumn - 82, 4, 32, "+", click_AddSprite), new Button(leftcolumn - 46, 4, 32, "-", click_RemoveSprite) }); panel_List.AddWidgets(new Widget[] { lstSprites = new ListBox <Sprite>(0, 0, panel_List.InputArea.Width, panel_List.InputArea.Height) { OnSelectionChanged = lstSprites_OnSelectionChanged } }); panel_CurrentSprite.AddWidgets(new Widget[] { new Label(8, 8, "Name:"), txtSpriteName = new SingleLineTextBox(52, 4, 136, 16) { OnValueChanged = txtSpriteName_OnValueChanged }, lblSpriteDataByte = new Label(8, 30, string.Empty), lblSpriteMetaDataSize = new Label(8, 46, string.Empty) }); int y_offset = 32; panel_CurrentSprite.AddWidgets(new Widget[] { new Label(8, y_offset + 12 + 24 + 4, "Sprite size:"), cmbSpriteSize = new ComboBox(8 + 88, y_offset + 8 + 24, 78, string.Empty, dropDownItems: new List <ComboBox.DropDownItem>() { new ComboBox.DropDownItem("8x8"), new ComboBox.DropDownItem("16x16"), new ComboBox.DropDownItem("24x24"), new ComboBox.DropDownItem("32x32") }) { OnSelectionChanged = cmbSpriteSize_OnSelectionChanged }, new Label(8, y_offset + 20 + 48 + 4, "Extra frames:"), cmbExtraFrames = new ComboBox(8 + 88, y_offset + 18 + 48, 78, string.Empty, dropDownItems: new List <ComboBox.DropDownItem>() { new ComboBox.DropDownItem("0"), new ComboBox.DropDownItem("1"), new ComboBox.DropDownItem("2"), new ComboBox.DropDownItem("3"), new ComboBox.DropDownItem("4"), new ComboBox.DropDownItem("8"), new ComboBox.DropDownItem("16"), new ComboBox.DropDownItem("16*") }) { OnSelectionChanged = cmbExtraFrames_OnSelectionChanged }, chkHasWalkSprites = new CheckBox(8, y_offset + 28 + 72, "Has Walk Sprites") { OnToggle = chkHasWalkSprites_OnToggle }, chkHasExtendedSprites = new CheckBox(8, y_offset + 32 + 96, "Has Extended Sprites") { OnToggle = chkHasExtendedSprites_OnToggle }, }); panel_TileGfx.AddWidgets(new Widget[] { scrTileGfxPages = new ScrollBars() }); createTileGfxPanel(); lstMetaSpriteLabels = new List <Label>(); lstMetaSprites = new List <MetaTile>(); refreshControls(); if (State.SelectedSprite >= 0 && State.SelectedSprite < State.Data.Sprites.Count) { lstSprites.SelectedIndex = State.SelectedSprite; } else { lstSprites.SelectedIndex = State.SelectedSprite = 0; } }
public override void Init(Game game, GUIData data) { Color = new Color(244, 246, 250); var beaker = game.Content.Load <Texture2D>("beaker"); var skin = new Skin(data.GreyImageMap, data.GreyMap); var text = new Text(data.GreySpriteFont, Color.Black); Gui = new Gui(game, skin, text) { Widgets = new Widget[] { //By default the Button is as wide as the width of the label plus the edge of the button graphic new Button(10, 10 + (40 * 0), "Button"), new Button(10, 10 + (40 * 1), "Wide Button"), new Button(10, 10 + (40 * 2), "T"), new Button(10, 10 + (40 * 3), 120, "Width 120"), //Button will resized to fit if the specified width is smaller than the width of the text new Button(10, 10 + (40 * 4), 20, "Width 20"), //The optional padding argument causes the button to be as wide as the label + (padding * 2) new Button(10, 10 + (40 * 5), "5 Padding", 5), new Button(10, 10 + (40 * 6), "10 Padding", 10), //The ToggleButton behaves similarly to the Button but toggles between being //pressed or released each time its clicked. new ToggleButton(150, 10 + (40 * 0), "Button"), new ToggleButton(150, 10 + (40 * 1), "Wide Button"), new ToggleButton(150, 10 + (40 * 2), "T"), new ToggleButton(150, 10 + (40 * 3), 120, "Width 120"), new ToggleButton(150, 10 + (40 * 4), 20, "Width 20"), new ToggleButton(150, 10 + (40 * 5), "5 Padding", 5), new ToggleButton(150, 10 + (40 * 6), "10 Padding", 10), //Standard old checkbox new CheckBox(300, 10, "Check Box"), //Standard old radio button //Only one radio buttons in the same group can have a value of true new RadioButton(300, 40, "GRP", "Group GRP"), new RadioButton(300, 70, "GRP", "Group GRP"), new RadioButton(300, 100, "GRP", "Group GRP"), //Slider allowing anologue selection. Value is the percent selected between 0 and 1 inclusive. _slider = new Slider(300, 130, 200, delegate(Widget slider) { _sliderLabel.Value = "Value = " + ((Slider)slider).Value; }), _sliderLabel = new Label(300, 160, "Value = 0"), _singleLineTextBox = new SingleLineTextBox(300, 180, 100, 10), new Button(410, 177, 100, "Change", delegate { var result = 0.0f; if (float.TryParse(_singleLineTextBox.Value, out result)) { _slider.Value = result; } }), //Combo box allowing that expands to allow the user to select one of the items in the DropDownItem List. new ComboBox(300, 210, "Pick a Color", 2, CardinalDirection.North, new List <ComboBox.DropDownItem> { //The padding argument behaves the same as for the Button new ComboBox.DropDownItem("Violet", null, delegate { Color = Color.Violet; }), new ComboBox.DropDownItem("Tomato", null, delegate { Color = Color.Tomato; }), new ComboBox.DropDownItem("YellowGreen", null, delegate { Color = Color.YellowGreen; }), new ComboBox.DropDownItem("LightSkyBlue", null, delegate { Color = Color.LightSkyBlue; }) }), new ComboBox(300, 250, 131, "Holder Text", CardinalDirection.South, new List <ComboBox.DropDownItem> { new ComboBox.DropDownItem("Test 1"), new ComboBox.DropDownItem("Test 2"), new ComboBox.DropDownItem("Test 3"), new ComboBox.DropDownItem("Test 4"), new ComboBox.DropDownItem("Test 5") }), //For labels with icons the label is centered in the height of the icon new Label(450, 10, "Research"), new Label(450, 40, beaker, "Research"), new Label(450, 70, beaker, "Research", 4), //Use the optional field for padding //ScrollBars no longer have borders so nest them in panels if you need them. //Panels have a min size of twice the renderers border width. new Panel(10, 300, 220, 220) { Children = new Widget[] { new ScrollBars { Children = new Widget[] { new CheckBox(10, 10, "Button"), new CheckBox(210, 10, "Button"), new CheckBox(10, 210, "Button"), new CheckBox(210, 210, "Button") } } } }, //TextBoxs no longer have borders so nest them in panels if you need them. new Panel(240, 300, 400, 400) { Children = new Widget[] { new TextBox(2, 800) { Value = "This is a textbox!" } } }, new SingleLineTextBox(10, 525, 120, 10), //Basic Test new SingleLineTextBox(10, 550, 120, 10) { Value = "0123456789" }, //Test with default value new SingleLineTextBox(10, 575, 120, 10) { Value = "0123456789" } //Test with specified font } }; }
public override void Init(Game1 game) { Color = Color.White; var beaker = game.Content.Load<Texture2D>("beaker"); var skin = new Skin(game.GreyImageMap, game.GreyMap); var text = new Text(game.GreySpriteFont, Color.Black); var testSkin = new Skin(game.TestImageMap, game.TestMap); var testText = new Text(game.TestSpriteFont, Color.Black); var testSkins = new[] { new Tuple<string, Skin>("testSkin", testSkin) }; var testTexts = new[] { new Tuple<string, Text>("testText", testText) }; _gui = new Gui(game, skin, text, testSkins, testTexts) { Widgets = new Widget[] { //By default the Button is as wide as the width of the label plus the edge of the button graphic new Button(10, 10 + (40 * 0), "Button") { Skin = "testSkin", Text = "testText" }, new Button(10, 10 + (40 * 1), "Wide Button"), new Button(10, 10 + (40 * 2), "T"), new Button(10, 10 + (40 * 3), 120, "Width 120"), //Button will resized to fit if the specified width is smaller than the width of the text new Button(10, 10 + (40 * 4), 20, "Width 20"), //The optional padding argument causes the button to be as wide as the label + (padding * 2) new Button(10, 10 + (40 * 5), "5 Padding", 5), new Button(10, 10 + (40 * 6), "10 Padding", 10), //The ToggleButton behaves similarly to the Button but toggles between being //pressed or released each time its clicked. new ToggleButton(150, 10 + (40 * 0), "Button"), new ToggleButton(150, 10 + (40 * 1), "Wide Button"), new ToggleButton(150, 10 + (40 * 2), "T"), new ToggleButton(150, 10 + (40 * 3), 120, "Width 120"), new ToggleButton(150, 10 + (40 * 4), 20, "Width 20"), new ToggleButton(150, 10 + (40 * 5), "5 Padding", 5), new ToggleButton(150, 10 + (40 * 6), "10 Padding", 10), //Standard old checkbox new CheckBox(300, 10, "Check Box"), //Standard old radio button //Only one radio buttons in the same group can have a value of true new RadioButton(300, 40, "GRP", "Group GRP"), new RadioButton(300, 70, "GRP", "Group GRP"), new RadioButton(300, 100, "GRP", "Group GRP"), //Slider allowing anologue selection. Value is the percent selected between 0 and 1 inclusive. _slider = new Slider(300, 130, 200, delegate(Widget slider) { _sliderLabel.Value = "Value = " + ((Slider)slider).Value; }), _sliderLabel = new Label(300, 160, "Value = 0"), _singleLineTextBox = new SingleLineTextBox(300, 180, 100, 10), new Button(410, 177, 100, "Change", delegate { var result = 0.0f; if (float.TryParse(_singleLineTextBox.Value, out result)) { _slider.Value = result; } }), //Combo box allowing that expands to allow the user to select one of the items in the DropDownItem List. new ComboBox(300, 210, "Pick a Color", 2, CardinalDirection.North, new List<ComboBox.DropDownItem> { //The padding argument behaves the same as for the Button new ComboBox.DropDownItem("Violet", null, delegate { Color = Color.Violet; }), new ComboBox.DropDownItem("Tomato", null, delegate { Color = Color.Tomato; }), new ComboBox.DropDownItem("YellowGreen", null, delegate { Color = Color.YellowGreen; }), new ComboBox.DropDownItem("LightSkyBlue", null, delegate { Color = Color.LightSkyBlue; }) }), new ComboBox(300, 250, 131, "Holder Text", CardinalDirection.South, new List<ComboBox.DropDownItem> { new ComboBox.DropDownItem("Test 1"), new ComboBox.DropDownItem("Test 2"), new ComboBox.DropDownItem("Test 3"), new ComboBox.DropDownItem("Test 4"), new ComboBox.DropDownItem("Test 5") }), //For labels with icons the label is centered in the height of the icon new Label(450, 10, "Research"), new Label(450, 40, beaker, "Research"), new Label(450, 70, beaker, "Research", 4), //Use the optional field for padding //ScrollBars no longer have borders so nest them in panels if you need them. //Panels have a min size of twice the renderers border width. new Panel(10, 300, 220, 220) { Children = new Widget[] { new ScrollBars { Children = new Widget[] { new CheckBox(10, 10, "Button"), new CheckBox(210, 10, "Button"), new CheckBox(10, 210, "Button"), new CheckBox(210, 210, "Button") } } } }, //TextBoxs no longer have borders so nest them in panels if you need them. new Panel(240, 300, 400, 400) { Children = new Widget[] { new TextBox(2, 800) { Value = "This is a textbox!" } } }, new SingleLineTextBox(10, 525, 120, 10), //Basic Test new SingleLineTextBox(10, 550, 120, 10) { Value = "0123456789" }, //Test with default value new SingleLineTextBox(10, 575, 120, 10) { Value = "0123456789", Text = "testText" } //Test with specified font } }; }
public override void Init(Game1 game) { Color = Color.White; skin = new Skin(game.GreyImageMap, game.GreyMap); text = new Text(game.GreySpriteFont, Color.Chartreuse); AttributeColour = Color.OrangeRed; resizeNeeded = false; Attributes = GameManager.NewPlayer; gui = new Gui(game, skin, text); gui.AddText("Nixie", new Text(game.Nixie, AttributeColour)); CharCreatePanel = new Panel(1, 1, game.GraphicsDevice.Viewport.Width / 3, game.GraphicsDevice.Viewport.Height - 10); CharCreatePanel.AddWidget(new Label(1, 6, "NAME")); NameBox = new SingleLineTextBox(50, 0, 150, 15); NameBox.Value = GameManager.NewPlayerName; CharCreatePanel.AddWidget(NameBox); AttributePanel = new Panel(1, 50, CharCreatePanel.Area.Width - 10, 70); IndAttributePanels = new Panel[6]; //strength Panel PanelSTR = new Panel(1, 1, AttributePanel.Area.Width / 6, AttributePanel.Area.Height - 10); LabelSTRVAL = new Label(1, 1, Convert.ToString(Attributes.Strength)); LabelSTRVAL.Text = "Nixie"; Label LabelSTR = new Label(1, 35, "STR"); PanelSTR.AddWidget(LabelSTR); PanelSTR.AddWidget(LabelSTRVAL); IndAttributePanels[0] = PanelSTR; //Dex Panel PanelDEX = new Panel((AttributePanel.Area.Width / 6) * 1, 1, AttributePanel.Area.Width / 6, AttributePanel.Area.Height - 10); Label LabelDEX = new Label(1, 35, "DEX"); LabelDEXVAL = new Label(1, 1, Convert.ToString(Attributes.Dexterity)); LabelDEXVAL.Text = "Nixie"; PanelDEX.AddWidget(LabelDEX); PanelDEX.AddWidget(LabelDEXVAL); IndAttributePanels[1] = PanelDEX; //Charisma Panel PanelCHA = new Panel((AttributePanel.Area.Width / 6) * 2, 1, AttributePanel.Area.Width / 6, AttributePanel.Area.Height - 10); Label LabelCHA = new Label(1, 35, "CHA"); LabelCHAVAL = new Label(1, 1, Convert.ToString(Attributes.Charisma)); LabelCHAVAL.Text = "Nixie"; PanelCHA.AddWidget(LabelCHA); PanelCHA.AddWidget(LabelCHAVAL); IndAttributePanels[2] = PanelCHA; //Intelligence Panel PanelINT = new Panel((AttributePanel.Area.Width / 6) * 3, 1, AttributePanel.Area.Width / 6, AttributePanel.Area.Height - 10); Label LabelINT = new Label(1, 35, "INT"); LabelINTVAL = new Label(1, 1, Convert.ToString(Attributes.Intelligence)); LabelINTVAL.Text = "Nixie"; PanelINT.AddWidget(LabelINT); PanelINT.AddWidget(LabelINTVAL); IndAttributePanels[3] = PanelINT; //Constitution Panel PanelCON = new Panel((AttributePanel.Area.Width / 6) * 4, 1, AttributePanel.Area.Width / 6, AttributePanel.Area.Height - 10); Label LabelCON = new Label(1, 35, "CON"); LabelCONVAL = new Label(1, 1, Convert.ToString(Attributes.Constitution)); LabelCONVAL.Text = "Nixie"; PanelCON.AddWidget(LabelCON); PanelCON.AddWidget(LabelCONVAL); IndAttributePanels[4] = PanelCON; //Age Panel PanelAGE = new Panel(((AttributePanel.Area.Width / 6) * 5) - 5, 1, AttributePanel.Area.Width / 6, AttributePanel.Area.Height - 10); Label LabelAGE = new Label(1, 35, "AGE"); LabelAGEVAL = new Label(1, 1, Convert.ToString(Attributes.Age)); LabelAGEVAL.Text = "Nixie"; PanelAGE.AddWidget(LabelAGE); PanelAGE.AddWidget(LabelAGEVAL); IndAttributePanels[5] = PanelAGE; AttributePanel.AddWidgets(IndAttributePanels); CharCreatePanel.AddWidget(AttributePanel); // Panel[] CharModArray = new Panel[3]; Panel SpeciesSelect = new Panel(10, 125, CharCreatePanel.Area.Width - 30, 325); SpeciesSelect.AddWidget(new Label(1, 100, "Select:")); Panel ClassSelect = new Panel(10, 125, CharCreatePanel.Area.Width - 30, 325); ClassSelect.AddWidget(new Button(-5, SpeciesSelect.Area.Height / 2, 10, "<", delegate { SpeciesSelect.Visible = true; ClassSelect.Visible = false; })); ClassSelect.Visible = false; Panel PerkSelect = new Panel(10, 125, CharCreatePanel.Area.Width - 30, 325); PerkSelect.AddWidget(new Button(-10, (SpeciesSelect.Area.Height / 2) - 10, 10, "<", delegate { ClassSelect.Visible = true; PerkSelect.Visible = false; })); PerkSelect.Visible = false; CharModArray[0] = SpeciesSelect; CharModArray[1] = ClassSelect; CharModArray[2] = PerkSelect; CharCreatePanel.AddWidgets(CharModArray); SpeciesSelect.AddWidget(new Button(-5, SpeciesSelect.Area.Height / 2, 10, "<", delegate { })); gui.AddWidget(CharCreatePanel); Console.WriteLine("Character Creation screen initialised"); }