public static dfButton CreateMenuButton(dfControl parent, string text, bool localize = false, bool act_as_label = false) { var button = parent.AddControl <dfButton>(); button.IsLocalized = localize; button.Text = text; //button.Position = ((PreOptionsMenuController)PreOptionsMenu).TabModsSelector.Position; button.Font = GungeonFont; button.IsVisible = true; button.IsEnabled = true; button.TextColor = UI.MenuTextColor; button.FocusTextColor = act_as_label ? UI.MenuTextColor : UI.MenuFocusTextColor; button.HoverTextColor = act_as_label ? UI.MenuTextColor : UI.MenuHoverTextColor; button.TextScale = UI.MenuTextScale; button.TextAlignment = TextAlignment.Center; button.AutoSize = true; button.WordWrap = true; button.MaximumSize = new Vector2(parent.Width, 999999); Console.WriteLine($"XXXDEBUG button {button.Width} {button.Height}"); Console.WriteLine($"XXXDEBUG parent {parent.Width}"); Console.WriteLine($"XXXDEBUG newbutton {button.Width} {button.Height}"); button.gameObject.SetActive(false); // Delay BraveOptionsMenuItem.Awake to allow us to set buttonControl var menu_item = button.gameObject.AddComponent <BraveOptionsMenuItem>(); menu_item.buttonControl = button; menu_item.itemType = BraveOptionsMenuItem.BraveOptionsMenuItemType.Button; button.gameObject.SetActive(true); button.Anchor = dfAnchorStyle.CenterHorizontal; var ui_key_controls = button.gameObject.AddComponent <UIKeyControls>(); var crosshair_selection_doer = button.gameObject.AddComponent <MenuCrosshairSelectionDoer>(); crosshair_selection_doer.controlToPlace = CachedCrosshairSelectionDoerControl; crosshair_selection_doer.targetControlToEncrosshair = button; if (parent is dfScrollPanel) { var panel = (dfScrollPanel)parent; var diff = panel.FlowPadding.top + panel.FlowPadding.bottom + button.Height; //panel.Height += diff; panel.VertScrollbar.MaxValue += diff; //panel.VertScrollbar.ScrollSize += diff; Console.WriteLine($"height {panel.Height} max val {panel.VertScrollbar.MaxValue} scroll {panel.VertScrollbar.ScrollSize}"); } return(button); }
public void DropSpacer(ref Vector3 vPos) { if (this.spacerLabel != null) { dfControl component = base.GetComponent <dfControl>(); dfControl child = ((GameObject)Object.Instantiate(this.spacerLabel)).GetComponent <dfControl>(); component.AddControl(child); child.Position = vPos; vPos.x += child.Width + 5f; } }
public void Setup(int iPages, int iCurrentPage) { if (this.pageCount == iPages && this.pageCurrent == iCurrentPage) { return; } this.pageCount = iPages; this.pageCurrent = iCurrentPage; dfControl[] componentsInChildren = base.gameObject.GetComponentsInChildren <dfControl>(); for (int i = 0; i < (int)componentsInChildren.Length; i++) { dfControl _dfControl = componentsInChildren[i]; if (_dfControl.gameObject != base.gameObject) { UnityEngine.Object.Destroy(_dfControl.gameObject); } } if (this.pageCount <= 1) { return; } dfControl component = base.GetComponent <dfControl>(); bool flag = true; Vector3 vector3 = new Vector3(0f, 0f, 0f); for (int j = 0; j < this.pageCount; j++) { if (this.buttonGroups - j > 0 || j >= this.pageCount - this.buttonGroups || Math.Abs(j - this.pageCurrent) <= this.buttonGroups / 2) { dfButton str = ((GameObject)UnityEngine.Object.Instantiate(this.clickableButton)).GetComponent <dfButton>(); component.AddControl(str); str.Tooltip = j.ToString(); str.MouseDown += new MouseEventHandler(this.OnButtonClicked); str.Text = (j + 1).ToString(); str.Invalidate(); if (j == this.pageCurrent) { str.Disable(); } str.Position = vector3; vector3.x = vector3.x + (str.Width + 5f); flag = true; } else { if (flag) { this.DropSpacer(ref vector3); } flag = false; } } component.Width = vector3.x; }
public void DropSpacer(ref Vector3 vPos) { if (!this.spacerLabel) { return; } dfControl component = base.GetComponent <dfControl>(); dfControl _dfControl = ((GameObject)UnityEngine.Object.Instantiate(this.spacerLabel)).GetComponent <dfControl>(); component.AddControl(_dfControl); _dfControl.Position = vPos; vPos.x = vPos.x + (_dfControl.Width + 5f); }
public void Setup(int iPages, int iCurrentPage) { if ((this.pageCount != iPages) || (this.pageCurrent != iCurrentPage)) { this.pageCount = iPages; this.pageCurrent = iCurrentPage; foreach (dfControl control in base.gameObject.GetComponentsInChildren <dfControl>()) { if (control.gameObject != base.gameObject) { Object.Destroy(control.gameObject); } } if (this.pageCount > 1) { dfControl component = base.GetComponent <dfControl>(); bool flag = true; Vector3 vPos = new Vector3(0f, 0f, 0f); for (int i = 0; i < this.pageCount; i++) { if ((((this.buttonGroups - i) <= 0) && (i < (this.pageCount - this.buttonGroups))) && (Math.Abs((int)(i - this.pageCurrent)) > (this.buttonGroups / 2))) { if (flag) { this.DropSpacer(ref vPos); } flag = false; } else { dfButton child = ((GameObject)Object.Instantiate(this.clickableButton)).GetComponent <dfButton>(); component.AddControl(child); child.Tooltip = i.ToString(); child.MouseDown += new MouseEventHandler(this.OnButtonClicked); child.Text = (i + 1).ToString(); child.Invalidate(); if (i == this.pageCurrent) { child.Disable(); } child.Position = vPos; vPos.x += child.Width + 5f; flag = true; } } component.Width = vPos.x; } } }
private dfControl instantiateMarker(string markerName) { var markerType = markerTypes.Find(x => x.name == markerName); if (markerType == null) { Debug.LogError("Marker type not found: " + markerName); return(null); } var marker = (dfControl)Instantiate(markerType); marker.hideFlags = HideFlags.DontSave; marker.IsVisible = true; control.AddControl(marker); return(marker); }
public static dfPanel CreateMenuEntryBase(dfControl parent, BraveOptionsMenuItem.BraveOptionsMenuItemType type) { var top_panel = parent.AddControl <dfPanel>(); top_panel.Anchor = (dfAnchorStyle)5; top_panel.Size = new Vector2(828, 39); top_panel.Atlas = CachedOptionsAtlas; top_panel.IsVisible = true; top_panel.gameObject.SetActive(false); // Delay BraveOptionsMenuItem.Awake to allow us to set buttonControl var menu_item = top_panel.gameObject.AddComponent <BraveOptionsMenuItem>(); menu_item.itemType = type; top_panel.gameObject.SetActive(true); var ui_key_controls = top_panel.gameObject.AddComponent <UIKeyControls>(); var crosshair_selection_doer = top_panel.gameObject.AddComponent <MenuCrosshairSelectionDoer>(); crosshair_selection_doer.controlToPlace = CachedCrosshairSelectionDoerControl; crosshair_selection_doer.targetControlToEncrosshair = top_panel; var inside_panel = top_panel.AddControl <dfPanel>(); inside_panel.Anchor = (dfAnchorStyle)65; inside_panel.IsVisible = true; inside_panel.Size = new Vector2(300, 39); inside_panel.Atlas = CachedOptionsAtlas; if (parent is dfScrollPanel) { var panel = (dfScrollPanel)parent; var diff = panel.FlowPadding.top + panel.FlowPadding.bottom + top_panel.Height; panel.VertScrollbar.MaxValue += diff; } return(top_panel); }