public ButtonView AddOption(string name, Action action, object related = null) { if (this.LastItemSelected == -1) { if (string.IsNullOrEmpty(this.Label)) { ((ButtonView)FindFirstChildByName("button")).Text = name; } this.LastItemSelected.Value = this.DropDownOptions.Count; } var dropDownOption = new DropDownOption() { Text = name, OnClicked = action, Related = related }; DropDownOptions.Add(dropDownOption); var dropButton = new ButtonView(this.ParentGeeUI, DropDownListView, name, Vector2.Zero); dropButton.OnMouseClick += (sender, args) => { OnOptionSelected(dropDownOption); }; return(dropButton); }
public void Refilter() { this._arrowKeysIndex = 0; string text = FilterView.Text; DropDownOption[] goodOptions = (from op in DropDownOptions where op.Text.ToLower().Contains(text.ToLower()) || text == "" select op).ToArray(); DisplayingOptions = goodOptions.ToList(); DropDownListView.Children.Clear(); FilterView.SubmitOnClickAway = false; if (goodOptions.Length > 0) { FilterView.OnTextSubmitted = () => { if (!string.IsNullOrEmpty(text)) { HideDropDown(); } }; } foreach (var option in goodOptions) { var dropButton = new ButtonView(this.ParentGeeUI, DropDownListView, option.Text, Vector2.Zero); dropButton.OnMouseClick += (sender, args) => { OnOptionSelected(option); }; } ArrowKeysHandle(); }
public StartGameInterface() { base.initialize(1); base.blocking = false; MainView = new WindowView(GeeUI.GeeUI.RootView, Main.Center - new Vector2(200, 300), AssetManager.GetFont("Console")) { WindowText = "Start game" }; PanelView p = new PanelView(MainView, Vector2.Zero); MainView.Width = 200; MainView.Height = 300; p.Width = 200; p.Height = 300; HostGameButton = new ButtonView(p, "Host", new Vector2(20, 200), AssetManager.GetFont("Console")); JoinGameButton = new ButtonView(p, "Connect", new Vector2(100, 200), AssetManager.GetFont("Console")); JoinGameButton.OnMouseClick += (sender, e) => { Connect(); }; HostGameButton.OnMouseClick += (sender, e) => { Host(); }; PlayerNameTextField = new TextFieldView(p, new Vector2(5, 10), AssetManager.GetFont("Console")) { Width = 180, Height = 20, MultiLine = false }; ServerIPTextField = new TextFieldView(p, new Vector2(5, 110), AssetManager.GetFont("Console")) { Width = 180, Height = 20, MultiLine = false }; ServerPortTextField = new TextFieldView(p, new Vector2(5, 160), AssetManager.GetFont("Console")) { Width = 180, Height = 20, MultiLine = false }; //AnimationEditorButton = new ButtonView(Main.Center - new Vector2(0, 200), "Animation editor", AssetManager.GetFont("Console"), () => { destroy(); AnimationEditorInterface ae = new AnimationEditorInterface(); ae.initialize(1); }); PlayerNameTextField.Text = "Player1"; ServerIPTextField.Text = "127.0.0.1"; ServerPortTextField.Text = "870"; }
public DropDownView(GeeUIMain theGeeUI, View parentView, Vector2 position) : base(theGeeUI, parentView) { this.numChildrenAllowed = 1; ParentGeeUI.OnKeyPressedHandler += this.keyPressedHandler; var button = new ButtonView(theGeeUI, this, "", Vector2.Zero); button.Add(new Binding <int>(this.Width, button.Width)); button.Add(new Binding <int>(this.Height, button.Height)); button.OnMouseClick += delegate(object sender, EventArgs e) { ToggleDropDown(); this.FilterView.TemporarilyIgnoreMouseClickAway = true; }; button.OnMouseClickAway += delegate(object sender, EventArgs args) { HideDropDown(); }; button.OnMouseRightClick += (sender, args) => { if (AllowRightClickExecute) { ExecuteLast(); } }; button.Name = "button"; this.DropDownPanelView = new PanelView(theGeeUI, theGeeUI.RootView, Vector2.Zero); DropDownPanelView.ChildrenLayouts.Add(new VerticalViewLayout(2, false)); this.DropDownPanelView.SelectedNinepatch = this.DropDownPanelView.UnselectedNinepatch = GeeUIMain.NinePatchDropDown; FilterView = new TextFieldView(theGeeUI, DropDownPanelView, Vector2.Zero); // HACK FilterView.Height.Value = (int)(20 * theGeeUI.Main.MainFontMultiplier); FilterView.MultiLine = false; FilterView.Add(new Binding <int>(FilterView.Width, x => x - 8, DropDownPanelView.Width)); FilterView.OnTextChanged = () => { if (FilterView.Active && DropDownPanelView.Active && AllowFilterText) { Refilter(); } }; DropDownListView = new ListView(theGeeUI, DropDownPanelView); DropDownListView.ChildrenLayouts.Add(new VerticalViewLayout(1, false)); DropDownListView.ScrollMultiplier = 20; DropDownListView.Add(new Binding <int, Rectangle>(DropDownListView.Width, x => Math.Max(200, x.Width), DropDownListView.ChildrenBoundBox)); DropDownListView.Add(new Binding <int, Rectangle>(DropDownListView.Height, x => x.Height, DropDownListView.ChildrenBoundBox)); DropDownPanelView.Add(new Binding <int>(DropDownPanelView.Width, DropDownListView.Width)); DropDownListView.Name = "DropList"; DropDownPanelView.Add(new Binding <int>(DropDownPanelView.Height, (i1) => i1 + 2 + ((AllowFilterText && FilterView.Active) ? FilterView.BoundBox.Height : 0), DropDownListView.Height)); DropDownPanelView.Active.Value = false; this.Add(new SetBinding <string>(this.Label, delegate(string value) { ((ButtonView)FindFirstChildByName("button")).Text = value; })); }
public DropDownView(GeeUIMain theGeeUI, View parentView, Vector2 position) : base(theGeeUI, parentView) { this.numChildrenAllowed = 1; ParentGeeUI.OnKeyPressedHandler += this.keyPressedHandler; var button = new ButtonView(theGeeUI, this, "", Vector2.Zero); button.Add(new Binding<int>(this.Width, button.Width)); button.Add(new Binding<int>(this.Height, button.Height)); button.OnMouseClick += delegate(object sender, EventArgs e) { ToggleDropDown(); button.TemporarilyIgnoreMouseClickAway = true; this.FilterView.TemporarilyIgnoreMouseClickAway = true; }; button.OnMouseClickAway += delegate(object sender, EventArgs args) { HideDropDown(); }; button.OnMouseRightClick += (sender, args) => { if (AllowRightClickExecute) ExecuteLast(); }; button.Name = "button"; this.DropDownPanelView = new PanelView(theGeeUI, theGeeUI.RootView, Vector2.Zero); DropDownPanelView.ChildrenLayouts.Add(new VerticalViewLayout(2, false)); this.DropDownPanelView.SelectedNinepatch = this.DropDownPanelView.UnselectedNinepatch = GeeUIMain.NinePatchDropDown; FilterView = new TextFieldView(theGeeUI, DropDownPanelView, Vector2.Zero); // HACK FilterView.Height.Value = (int)(20 * theGeeUI.Main.FontMultiplier); FilterView.MultiLine = false; FilterView.AllowTab = false; FilterView.Add(new Binding<int>(FilterView.Width, x => x - 8, DropDownPanelView.Width)); FilterView.OnTextChanged = () => { if (FilterView.Active && DropDownPanelView.Active && AllowFilterText) { Refilter(); } }; DropDownListView = new ListView(theGeeUI, DropDownPanelView); DropDownListView.ChildrenLayouts.Add(new VerticalViewLayout(1, false)); DropDownListView.ScrollMultiplier = 20; DropDownListView.Add(new Binding<int, Rectangle>(DropDownListView.Width, x => Math.Max(200, x.Width), DropDownListView.ChildrenBoundBox)); DropDownListView.Add(new Binding<int, Rectangle>(DropDownListView.Height, x => x.Height, DropDownListView.ChildrenBoundBox)); DropDownPanelView.Add(new Binding<int>(DropDownPanelView.Width, DropDownListView.Width)); DropDownListView.Name = "DropList"; DropDownPanelView.Add(new Binding<int>(DropDownPanelView.Height, (i1) => i1 + 2 + ((AllowFilterText && FilterView.Active) ? FilterView.BoundBox.Height : 0), DropDownListView.Height)); DropDownPanelView.Active.Value = false; this.Add(new SetBinding<string>(this.Label, delegate(string value) { ((ButtonView)FindFirstChildByName("button")).Text = value; })); }
public ButtonView AddOption(string name, Action action, object related = null) { if (this.LastItemSelected == -1) { if (string.IsNullOrEmpty(this.Label)) ((ButtonView)FindFirstChildByName("button")).Text = name; this.LastItemSelected.Value = this.DropDownOptions.Count; } var dropDownOption = new DropDownOption() { Text = name, OnClicked = action, Related = related }; DropDownOptions.Add(dropDownOption); var dropButton = new ButtonView(this.ParentGeeUI, DropDownListView, name, Vector2.Zero); dropButton.OnMouseClick += (sender, args) => { OnOptionSelected(dropDownOption); }; return dropButton; }
public void Refilter() { this._arrowKeysIndex = 0; string text = FilterView.Text; DisplayingOptions = (from op in DropDownOptions where op.Text.ToLower().Contains(text.ToLower()) || text == "" select op).ToList(); DropDownListView.Children.Clear(); FilterView.SubmitOnClickAway = false; if (DisplayingOptions.Count > 0) { FilterView.OnTextSubmitted = () => { if (!string.IsNullOrEmpty(text)) HideDropDown(); }; } foreach (var option in DisplayingOptions) { var dropButton = new ButtonView(this.ParentGeeUI, DropDownListView, option.Text, Vector2.Zero); dropButton.OnMouseClick += (sender, args) => { OnOptionSelected(option); }; } ArrowKeysHandle(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. _spriteBatch = new SpriteBatch(GraphicsDevice); var font = Content.Load<SpriteFont>("testFont"); /* agop = Content.Load<Texture2D>("agop"); for(int i = 0; i < 35; i++) { var panel = new View(GeeUI.GeeUI.RootView) {Width = 300, Height = 300}; for(int j = 0; j < 7; j++) { var newImage = new ImageView(panel, agop); newImage.ScaleVector = new Vector2(.75f); } panel.ChildrenLayout = new SpinViewLayout(130, 1.5f); } GeeUI.GeeUI.RootView.ChildrenLayout = new SpinViewLayout(350, -1.5f); */ var panel = new PanelView(GeeUI.GeeUI.RootView, new Vector2(5, 5)) { Width = 600, Height = 400 }; var tabs = new TabHost(panel, new Vector2(0, 0), font) { Width = 570, Height = 300 }; var panel1 = new PanelView(null, Vector2.Zero); var panel2 = new PanelView(null, Vector2.Zero); tabs.AddTab("Tab 1", panel1); tabs.AddTab("Tab 2", panel2); new TextFieldView(panel1, Vector2.Zero, font) { Text = "This is tab 1.", Width = 380, Height = 230 }; for (int i = 0; i < 50; i++) { var button = new ButtonView(panel2, "Button" + (i + 1), Vector2.Zero, font); button.Width = 70; button.OnMouseClick += (sender, e) => panel2.RemoveChild(button); } ButtonView switchLayouts = new ButtonView(panel, "Switch to Spinning Layout", Vector2.Zero, font); switchLayouts.OnMouseClick += (sender, e) => { if (panel2.ChildrenLayout is VerticalViewLayout) { panel2.ChildrenLayout = new SpinViewLayout(115); switchLayouts.Text = "Switch to Vertical Layout"; } else if (panel2.ChildrenLayout is SpinViewLayout) { panel2.ChildrenLayout = new VerticalViewLayout(2, true); switchLayouts.Text = "Switch to Spinning Layout"; } }; panel.ChildrenLayout = new VerticalViewLayout(4, true); panel2.ChildrenLayout = new VerticalViewLayout(2, true); }
public InGameInterface() { MainView = new PanelView(GeeUI.GeeUI.RootView, Vector2.Zero) { Width = 800, Height = 50, Draggable = false }; //Create a new invisible view to limit the draggable range of the Expanded Inventory view. View ContainerView = new View(GeeUI.GeeUI.RootView) { Width = 800, Height = 450, X = 0, Y = 50 }; ExpandedView = new PanelView(ContainerView, new Vector2(0, 55)) { Width = 200, Height = 200, Active = false, ChildrenLayout = new HorizontalViewLayout(20, true) }; BagSizeChange(20); Vector2 start = new Vector2(0, 0); base.blocking = false; start.Y = 10; start.X = 50; for (int i = 0; i < 9; i++) { ButtonView b = new ButtonView(MainView, new ImageView(null, AssetManager.GetTexture("white")), start) { Width = 25, Height = 25 }; new TextView(b, "10", new Vector2(0, 21), AssetManager.GetFont("Console2")) { TextColor = Color.White, Width = 25, Height = 10, TextJustification = TextJustification.Center }; int i1 = i; b.OnMouseClick += (sender, e) => { BlockPressed(i1); }; _buttons.Add(b); start.X += 70; } InputManager.BindMouse(() => { if (++CurSelected >= 9) CurSelected = 0; BlockPressed(CurSelected); }, MouseButton.Scrollup); InputManager.BindMouse(() => { if (--CurSelected < 0) CurSelected = 8; BlockPressed(CurSelected); }, MouseButton.Scrolldown); InputManager.BindKey(() => { if(!blocking && InterfaceManager.blocking) return; blocking = !blocking; ExpandedView.Active = blocking; }, Keys.C); }
public void BagSizeChange(int newBagSize) { _expandedButtons.Clear(); for (int i = ExpandedView.Children.Length - 1; i >= 0; i--) { ExpandedView.RemoveChild(ExpandedView.Children[i]); } for (int i = 0; i < newBagSize - 10; i++) { ButtonView b = new ButtonView(ExpandedView, new ImageView(null, AssetManager.GetTexture("white")), Vector2.Zero) { Width = 25, Height = 25 }; new TextView(b, "10", new Vector2(0, 21), AssetManager.GetFont("Console2")) { TextColor = Color.White, Width = 25, Height = 10, TextJustification = TextJustification.Center }; _expandedButtons.Add(b); } }
public override void destroy() { HostGameButton = null; JoinGameButton = null; PlayerNameTextField = null; ServerIPTextField = null; ServerPortTextField = null; AnimationEditorButton = null; GeeUI.GeeUI.RootView.RemoveChild(MainView); base.destroy(); }