private bool SelectItem(GUIComponent component, object obj) { if (selectMultiple) { foreach (GUIComponent child in ListBox.Content.Children) { var tickBox = child.GetChild <GUITickBox>(); if (obj == child.UserData) { tickBox.Selected = true; } } } else { GUITextBlock textBlock = component as GUITextBlock; if (textBlock == null) { textBlock = component.GetChild <GUITextBlock>(); if (textBlock == null) { return(false); } } button.Text = textBlock.Text; } Dropped = false; OnSelected?.Invoke(component, component.UserData); return(true); }
private bool SelectItem(GUIComponent component, object obj) { if (selectMultiple) { foreach (GUIComponent child in ListBox.Content.Children) { var tickBox = child.GetChild <GUITickBox>(); if (obj == child.UserData) { tickBox.Selected = true; } } } else { GUITextBlock textBlock = component as GUITextBlock; if (textBlock == null) { textBlock = component.GetChild <GUITextBlock>(); if (textBlock == null) { return(false); } } button.Text = textBlock.Text; } Dropped = false; // TODO: OnSelected can be called multiple times and when it shouldn't be called -> turn into an event so that nobody else can call it. OnSelected?.Invoke(component, component.UserData); return(true); }
private static void StealRandomizeButton(CharacterInfo.AppearanceCustomizationMenu menu, GUIComponent parent) { //This is just stupid var randomizeButton = menu.RandomizeButton; var oldButton = parent.GetChild <GUIButton>(); parent.RemoveChild(oldButton); randomizeButton.RectTransform.Parent = parent.RectTransform; randomizeButton.RectTransform.RelativeSize = Vector2.One * 1.3f; }
private bool SelectItem(GUIComponent component, object obj) { GUITextBlock textBlock = component as GUITextBlock; if (textBlock == null) { textBlock = component.GetChild <GUITextBlock>(); if (textBlock == null) { return(false); } } button.Text = textBlock.Text; Dropped = false; if (OnSelected != null) { OnSelected(component, component.UserData); } return(true); }
protected static void PositionEditingHUD() { int maxHeight = 100; if (Screen.Selected == GameMain.SubEditorScreen) { editingHUD.RectTransform.SetPosition(Anchor.TopRight); editingHUD.RectTransform.AbsoluteOffset = new Point(0, GameMain.SubEditorScreen.TopPanel.Rect.Bottom); maxHeight = (GameMain.GraphicsHeight - GameMain.SubEditorScreen.EntityMenu.Rect.Height) - GameMain.SubEditorScreen.TopPanel.Rect.Bottom * 2 - 20; } else { editingHUD.RectTransform.SetPosition(Anchor.TopRight); editingHUD.RectTransform.RelativeOffset = new Vector2(0.0f, (HUDLayoutSettings.InventoryAreaUpper.Bottom + 10.0f) / (editingHUD.RectTransform.Parent ?? GUI.Canvas).Rect.Height); maxHeight = HUDLayoutSettings.InventoryAreaLower.Bottom - HUDLayoutSettings.InventoryAreaLower.Y - 10; } var listBox = editingHUD.GetChild <GUIListBox>(); if (listBox != null) { int padding = 20; int contentHeight = 0; foreach (GUIComponent child in listBox.Content.Children) { contentHeight += child.Rect.Height + listBox.Spacing; child.RectTransform.MaxSize = new Point(int.MaxValue, child.Rect.Height); child.RectTransform.MinSize = new Point(0, child.Rect.Height); } editingHUD.RectTransform.Resize( new Point( editingHUD.RectTransform.NonScaledSize.X, MathHelper.Clamp(contentHeight + padding * 2, 50, maxHeight)), resizeChildren: false); listBox.RectTransform.Resize(new Point(listBox.RectTransform.NonScaledSize.X, editingHUD.RectTransform.NonScaledSize.Y - padding * 2), resizeChildren: false); } }