private void AddPreviouslyUsed(MapEntityPrefab mapEntityPrefab) { if (previouslyUsedList == null || mapEntityPrefab == null) { return; } previouslyUsedList.Deselect(); if (previouslyUsedList.CountChildren == PreviouslyUsedCount) { previouslyUsedList.RemoveChild(previouslyUsedList.children.Last()); } var existing = previouslyUsedList.FindChild(mapEntityPrefab); if (existing != null) { previouslyUsedList.RemoveChild(existing); } string name = ToolBox.LimitString(mapEntityPrefab.Name, 15); var textBlock = new GUITextBlock( new Rectangle(0, 0, 0, 15), ToolBox.LimitString(name, GUI.SmallFont, previouslyUsedList.Rect.Width), "", Alignment.TopLeft, Alignment.CenterLeft, previouslyUsedList, false, GUI.SmallFont); textBlock.UserData = mapEntityPrefab; previouslyUsedList.RemoveChild(textBlock); previouslyUsedList.children.Insert(0, textBlock); }
public void SetCharacterOrder(Character character, Order order) { if (order == null) { return; } var characterFrame = listBox.FindChild(character); if (characterFrame == null) { return; } int characterIndex = listBox.children.IndexOf(characterFrame); orderListBox.children[characterIndex].ClearChildren(); var img = new GUIImage(new Rectangle(0, 0, 30, 30), order.SymbolSprite, Alignment.Center, orderListBox.children[characterIndex]); img.Scale = 30.0f / img.SourceRect.Width; img.Color = order.Color; img.CanBeFocused = false; orderListBox.children[characterIndex].ToolTip = TextManager.Get("Order") + ": " + order.Name; }
private void FilterServers() { serverList.RemoveChild(serverList.FindChild("noresults")); foreach (GUIComponent child in serverList.children) { ServerInfo serverInfo = (ServerInfo)child.UserData; child.Visible = serverInfo.ServerName.ToLowerInvariant().Contains(searchBox.Text.ToLowerInvariant()) && (!filterPassword.Selected || !serverInfo.HasPassword) && (!filterFull.Selected || serverInfo.PlayerCount < serverInfo.MaxPlayers) && (!filterEmpty.Selected || serverInfo.PlayerCount > 0); } if (serverList.children.All(c => !c.Visible)) { new GUITextBlock(new Rectangle(0, 0, 0, 20), "No matching servers found.", "", serverList).UserData = "noresults"; } }