private bool RefreshServers(GUIButton button, object obj) { if (waitingForRefresh) { return(false); } serverList.ClearChildren(); new GUITextBlock(new Rectangle(0, 0, 0, 20), "Refreshing server list...", "", serverList); CoroutineManager.StartCoroutine(WaitForRefresh()); return(true); }
private void UpdateLimbLists(Character character) { limbList.ClearChildren(); foreach (Limb limb in character.AnimController.Limbs) { GUITextBlock textBlock = new GUITextBlock( new Rectangle(0, 0, 0, 25), limb.type.ToString(), Color.Transparent, Color.White, Alignment.Left, null, limbList); textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f); textBlock.UserData = limb; } jointList.ClearChildren(); foreach (RevoluteJoint joint in character.AnimController.LimbJoints) { Limb limb1 = (Limb)(joint.BodyA.UserData); Limb limb2 = (Limb)(joint.BodyB.UserData); GUITextBlock textBlock = new GUITextBlock( new Rectangle(0, 0, 0, 25), limb1.type.ToString() + " - " + limb2.type.ToString(), Color.Transparent, Color.White, Alignment.Left, null, jointList); textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f); textBlock.UserData = joint; } }
private void UpdateSubList() { var subsToShow = Submarine.SavedSubmarines.Where(s => !s.HasTag(SubmarineTag.HideInMenus)); subList.ClearChildren(); foreach (Submarine sub in subsToShow) { var textBlock = new GUITextBlock( new Rectangle(0, 0, 0, 25), ToolBox.LimitString(sub.Name, GUI.Font, subList.Rect.Width - 65), "ListBoxElement", Alignment.Left, Alignment.Left, subList) { Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f), ToolTip = sub.Description, UserData = sub }; if (sub.HasTag(SubmarineTag.Shuttle)) { textBlock.TextColor = textBlock.TextColor * 0.85f; var shuttleText = new GUITextBlock(new Rectangle(0, 0, 0, 25), "Shuttle", "", Alignment.Left, Alignment.CenterY | Alignment.Right, textBlock, false, GUI.SmallFont); shuttleText.TextColor = textBlock.TextColor * 0.8f; shuttleText.ToolTip = textBlock.ToolTip; } } if (Submarine.SavedSubmarines.Count > 0) { subList.Select(Submarine.SavedSubmarines[0]); } }
private bool SelectItemCategory(MapEntityCategory category) { storeItemList.ClearChildren(); int width = storeItemList.Rect.Width; foreach (MapEntityPrefab mapEntityPrefab in MapEntityPrefab.List) { var itemPrefab = mapEntityPrefab as ItemPrefab; if (itemPrefab == null || !itemPrefab.Category.HasFlag(category)) { continue; } PriceInfo priceInfo = itemPrefab.GetPrice(Campaign.Map.CurrentLocation); if (priceInfo == null) { continue; } CreateItemFrame(new PurchasedItem(itemPrefab, 0), priceInfo, storeItemList, width); } storeItemList.Content.RectTransform.SortChildren( (x, y) => (x.GUIComponent.UserData as PurchasedItem).ItemPrefab.Name.CompareTo((y.GUIComponent.UserData as PurchasedItem).ItemPrefab.Name)); foreach (GUIButton btn in itemCategoryButtons) { btn.Selected = (MapEntityCategory)btn.UserData == category; } storeItemList.BarScroll = 0.0f; return(true); }
private bool SelectItemCategory(GUIButton button, object selection) { if (!(selection is MapEntityCategory)) { return(false); } storeItemList.ClearChildren(); MapEntityCategory category = (MapEntityCategory)selection; var items = MapEntityPrefab.list.FindAll(ep => ep.Price > 0.0f && ep.Category.HasFlag(category)); int width = storeItemList.Rect.Width; foreach (MapEntityPrefab ep in items) { CreateItemFrame(ep, storeItemList, width); } storeItemList.children.Sort((x, y) => (x.UserData as MapEntityPrefab).Name.CompareTo((y.UserData as MapEntityPrefab).Name)); foreach (GUIComponent child in button.Parent.children) { var otherButton = child as GUIButton; if (child.UserData is MapEntityCategory && otherButton != button) { otherButton.Selected = false; } } button.Selected = true; return(true); }
public void UpdateSubList(IEnumerable <Submarine> submarines) { #if DEBUG var subsToShow = submarines.Where(s => !s.HasTag(SubmarineTag.HideInMenus)); #else var subsToShow = submarines; #endif subList.ClearChildren(); foreach (Submarine sub in subsToShow) { var textBlock = new GUITextBlock( new RectTransform(new Vector2(1, 0.1f), subList.Content.RectTransform) { AbsoluteOffset = new Point(10, 0) }, ToolBox.LimitString(sub.Name, GUI.Font, subList.Rect.Width - 65), style: "ListBoxElement") { ToolTip = sub.Description, UserData = sub }; var infoButton = new GUIButton(new RectTransform(new Vector2(0.12f, 0.8f), textBlock.RectTransform, Anchor.CenterRight), text: "?") { UserData = sub }; infoButton.OnClicked += (component, userdata) => { // TODO: use relative size ((Submarine)userdata).CreatePreviewWindow(new GUIMessageBox("", "", 550, 400)); return(true); }; if (sub.HasTag(SubmarineTag.Shuttle)) { textBlock.TextColor = textBlock.TextColor * 0.85f; var shuttleText = new GUITextBlock(new RectTransform(new Point(100, textBlock.Rect.Height), textBlock.RectTransform, Anchor.CenterRight) { IsFixedSize = false, RelativeOffset = new Vector2(infoButton.RectTransform.RelativeSize.X + 0.01f, 0) }, TextManager.Get("Shuttle"), textAlignment: Alignment.Right, font: GUI.SmallFont) { TextColor = textBlock.TextColor * 0.8f, ToolTip = textBlock.ToolTip }; } } if (Submarine.SavedSubmarines.Any()) { var nonShuttles = subsToShow.Where(s => !s.HasTag(SubmarineTag.Shuttle)).ToList(); if (nonShuttles.Count > 0) { subList.Select(nonShuttles[Rand.Int(nonShuttles.Count)]); } } }
public void UpdateCharacterLists() { characterList.ClearChildren(); foreach (CharacterInfo c in GameMain.GameSession.CrewManager.CharacterInfos) { c.CreateCharacterFrame(characterList, c.Name + " (" + c.Job.Name + ") ", c); } }
private void RefreshItemTab() { selectedItemList.ClearChildren(); foreach (ItemPrefab ip in campaign.CargoManager.PurchasedItems) { CreateItemFrame(ip, selectedItemList, selectedItemList.Rect.Width); } }
private void UpdateCharacterLists() { characterList.ClearChildren(); foreach (CharacterInfo c in CrewManager.characterInfos) { c.CreateCharacterFrame(characterList, c.Name + " (" + c.Job.Name + ") ", c); } }
private void RefreshItemTab() { selectedItemList.ClearChildren(); foreach (PurchasedItem pi in campaign.CargoManager.PurchasedItems) { CreateItemFrame(pi, selectedItemList, selectedItemList.Rect.Width); } selectedItemList.children.Sort((x, y) => (x.UserData as PurchasedItem).itemPrefab.Name.CompareTo((y.UserData as PurchasedItem).itemPrefab.Name)); selectedItemList.children.Sort((x, y) => (x.UserData as PurchasedItem).itemPrefab.Category.CompareTo((y.UserData as PurchasedItem).itemPrefab.Category)); selectedItemList.UpdateScrollBarSize(); }
public void UpdateSubList(IEnumerable <SubmarineInfo> submarines) { var subsToShow = submarines.Where(s => s.IsCampaignCompatibleIgnoreClass).ToList(); subsToShow.Sort((s1, s2) => { int p1 = s1.Price > CampaignMode.MaxInitialSubmarinePrice ? 10 : 0; int p2 = s2.Price > CampaignMode.MaxInitialSubmarinePrice ? 10 : 0; return(p1.CompareTo(p2) * 100 + s1.Name.CompareTo(s2.Name)); }); subList.ClearChildren(); foreach (SubmarineInfo sub in subsToShow) { var textBlock = new GUITextBlock( new RectTransform(new Vector2(1, 0.1f), subList.Content.RectTransform) { MinSize = new Point(0, 30) }, ToolBox.LimitString(sub.DisplayName, GUI.Font, subList.Rect.Width - 65), style: "ListBoxElement") { ToolTip = sub.Description, UserData = sub }; if (!sub.RequiredContentPackagesInstalled) { textBlock.TextColor = Color.Lerp(textBlock.TextColor, Color.DarkRed, .5f); textBlock.ToolTip = TextManager.Get("ContentPackageMismatch") + "\n\n" + textBlock.RawToolTip; } var priceText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), textBlock.RectTransform, Anchor.CenterRight), TextManager.GetWithVariable("currencyformat", "[credits]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", sub.Price)), textAlignment: Alignment.CenterRight, font: GUI.SmallFont) { TextColor = sub.Price > CampaignMode.MaxInitialSubmarinePrice ? GUI.Style.Red : textBlock.TextColor * 0.8f, ToolTip = textBlock.ToolTip }; #if !DEBUG if (sub.Price > CampaignMode.MaxInitialSubmarinePrice && !GameMain.DebugDraw) { textBlock.CanBeFocused = false; } #endif } if (SubmarineInfo.SavedSubmarines.Any()) { var nonShuttles = subsToShow.Where(s => s.Type == SubmarineType.Player && !s.HasTag(SubmarineTag.Shuttle) && s.Price <= CampaignMode.MaxInitialSubmarinePrice).ToList(); if (nonShuttles.Count > 0) { subList.Select(nonShuttles[Rand.Int(nonShuttles.Count)]); } } }
private void OnItemsReceived(IList <Facepunch.Steamworks.Workshop.Item> itemDetails) { installedItemList.ClearChildren(); availableItemList.ClearChildren(); foreach (var item in itemDetails) { GUIListBox listBox = item.Installed ? installedItemList : availableItemList; var itemFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.1f), listBox.Content.RectTransform, minSize: new Point(0, 80)), style: "ListBoxElement") { UserData = item }; new GUITextBlock(new RectTransform(new Vector2(0.75f, 0.25f), itemFrame.RectTransform), item.Title); new GUITextBlock(new RectTransform(new Vector2(0.75f, 0.75f), itemFrame.RectTransform, Anchor.BottomLeft), item.Description, wrap: true, font: GUI.SmallFont); if (item.Installed) { var enabledTickBox = new GUITickBox(new RectTransform(new Vector2(0.25f, 0.5f), itemFrame.RectTransform, Anchor.CenterRight), "Enabled") { UserData = item, OnSelected = ToggleItemEnabled }; try { enabledTickBox.Selected = SteamManager.CheckWorkshopItemEnabled(item); } catch (Exception e) { new GUIMessageBox("Error", e.Message); enabledTickBox.Enabled = false; itemFrame.Color = Color.Red; itemFrame.HoverColor = Color.Red; itemFrame.SelectedColor = Color.Red; itemFrame.GetChild <GUITextBlock>().TextColor = Color.Red; } } else if (item.Downloading) { new GUITextBlock(new RectTransform(new Vector2(0.25f, 0.5f), itemFrame.RectTransform, Anchor.CenterRight), "Downloading"); } else { var downloadBtn = new GUIButton(new RectTransform(new Vector2(0.2f, 0.5f), itemFrame.RectTransform, Anchor.CenterRight), TextManager.Get("DownloadButton")) { UserData = item, OnClicked = DownloadItem }; } } }
public void UpdateSubList(IEnumerable <SubmarineInfo> submarines) { #if !DEBUG var subsToShow = submarines.Where(s => !s.HasTag(SubmarineTag.HideInMenus)); #else var subsToShow = submarines; #endif subList.ClearChildren(); foreach (SubmarineInfo sub in subsToShow) { var textBlock = new GUITextBlock( new RectTransform(new Vector2(1, 0.1f), subList.Content.RectTransform) { MinSize = new Point(0, 30) }, ToolBox.LimitString(sub.DisplayName, GUI.Font, subList.Rect.Width - 65), style: "ListBoxElement") { ToolTip = sub.Description, UserData = sub }; if (!sub.RequiredContentPackagesInstalled) { textBlock.TextColor = Color.Lerp(textBlock.TextColor, Color.DarkRed, .5f); textBlock.ToolTip = TextManager.Get("ContentPackageMismatch") + "\n\n" + textBlock.RawToolTip; } if (sub.HasTag(SubmarineTag.Shuttle)) { textBlock.TextColor = textBlock.TextColor * 0.85f; var shuttleText = new GUITextBlock(new RectTransform(new Point(100, textBlock.Rect.Height), textBlock.RectTransform, Anchor.CenterRight) { IsFixedSize = false }, TextManager.Get("Shuttle", fallBackTag: "RespawnShuttle"), textAlignment: Alignment.Right, font: GUI.SmallFont) { TextColor = textBlock.TextColor * 0.8f, ToolTip = textBlock.RawToolTip }; } } if (SubmarineInfo.SavedSubmarines.Any()) { var nonShuttles = subsToShow.Where(s => !s.HasTag(SubmarineTag.Shuttle)).ToList(); if (nonShuttles.Count > 0) { subList.Select(nonShuttles[Rand.Int(nonShuttles.Count)]); } } }
public void StartRound() { listBox.ClearChildren(); characters.Clear(); WayPoint[] waypoints = WayPoint.SelectCrewSpawnPoints(characterInfos, Submarine.MainSub); for (int i = 0; i < waypoints.Length; i++) { Character character; if (characterInfos[i].HullID != null) { var hull = Entity.FindEntityByID((ushort)characterInfos[i].HullID) as Hull; if (hull == null) { continue; } character = Character.Create(characterInfos[i], hull.WorldPosition); } else { character = Character.Create(characterInfos[i], waypoints[i].WorldPosition); Character.Controlled = character; if (character.Info != null && !character.Info.StartItemsGiven) { character.GiveJobItems(waypoints[i]); character.Info.StartItemsGiven = true; } } AddCharacter(character); } if (characters.Any()) { listBox.Select(0); // SelectCharacter(null, characters[0]); } }
private void RefreshPrefabList() { prefabList.ClearChildren(); var particlePrefabs = GameMain.ParticleManager.GetPrefabList(); foreach (ParticlePrefab particlePrefab in particlePrefabs) { var prefabText = new GUITextBlock(new Rectangle(0, 0, 0, 20), particlePrefab.Name, "", prefabList); prefabText.Padding = Vector4.Zero; prefabText.UserData = particlePrefab; } }
public void RefreshMissionTab(Mission selectedMission) { System.Diagnostics.Debug.Assert( selectedMission == null || (GameMain.GameSession.Map?.SelectedConnection != null && GameMain.GameSession.Map.CurrentLocation.AvailableMissions.Contains(selectedMission))); GameMain.GameSession.Map.CurrentLocation.SelectedMission = selectedMission; foreach (GUITickBox missionTickBox in missionTickBoxes) { missionTickBox.Selected = missionTickBox.UserData == selectedMission; } selectedMissionInfo.ClearChildren(); var container = selectedMissionInfo.Content; selectedMissionInfo.Visible = selectedMission != null; selectedMissionInfo.Spacing = 10; if (selectedMission == null) { return; } new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), container.RectTransform), selectedMission.Name, font: GUI.LargeFont) { AutoScale = true, CanBeFocused = false }; new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), container.RectTransform), TextManager.GetWithVariable("Reward", "[reward]", selectedMission.Reward.ToString())) { CanBeFocused = false }; new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), container.RectTransform), selectedMission.Description, wrap: true) { CanBeFocused = false }; if (StartButton != null) { StartButton.Enabled = true; StartButton.Visible = GameMain.Client == null || GameMain.Client.HasPermission(Networking.ClientPermissions.ManageRound) || GameMain.Client.HasPermission(Networking.ClientPermissions.ManageCampaign); } }
public void RefreshLists() { //selectedTexture = null; selectedSprites.Clear(); textureList.ClearChildren(); spriteList.ClearChildren(); ResetWidgets(); HashSet <string> textures = new HashSet <string>(); // Create texture list foreach (Sprite sprite in loadedSprites.OrderBy(s => Path.GetFileNameWithoutExtension(s.FilePath))) { //ignore sprites that don't have a file path (e.g. submarine pics) if (string.IsNullOrEmpty(sprite.FilePath)) { continue; } string normalizedFilePath = Path.GetFullPath(sprite.FilePath); if (!textures.Contains(normalizedFilePath)) { new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), textureList.Content.RectTransform) { MinSize = new Point(0, 20) }, Path.GetFileName(sprite.FilePath)) { Padding = Vector4.Zero, ToolTip = sprite.FilePath, UserData = sprite.Texture }; textures.Add(normalizedFilePath); } } // Create sprite list // TODO: allow the user to choose whether to sort by file name or by texture sheet //foreach (Sprite sprite in loadedSprites.OrderBy(s => GetSpriteName(s))) foreach (Sprite sprite in loadedSprites.OrderBy(s => s.SourceElement.GetAttributeString("texture", string.Empty))) { new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), spriteList.Content.RectTransform) { MinSize = new Point(0, 20) }, GetSpriteName(sprite) + " " + sprite.SourceRect) { Padding = Vector4.Zero, UserData = sprite }; } topPanelContents.Visible = false; }
private bool SelectItemCategory(GUIButton button, object selection) { if (!(selection is MapEntityCategory)) { return(false); } storeItemList.ClearChildren(); storeItemList.BarScroll = 0.0f; MapEntityCategory category = (MapEntityCategory)selection; int width = storeItemList.Rect.Width; foreach (MapEntityPrefab mapEntityPrefab in MapEntityPrefab.List) { var itemPrefab = mapEntityPrefab as ItemPrefab; if (itemPrefab == null || !itemPrefab.Category.HasFlag(category)) { continue; } PriceInfo priceInfo = itemPrefab.GetPrice(campaign.Map.CurrentLocation); if (priceInfo == null) { continue; } CreateItemFrame(new PurchasedItem(itemPrefab, 0), priceInfo, storeItemList, width); } storeItemList.Content.RectTransform.SortChildren( (x, y) => (x.GUIComponent.UserData as PurchasedItem).ItemPrefab.Name.CompareTo((y.GUIComponent.UserData as PurchasedItem).ItemPrefab.Name)); foreach (GUIComponent child in button.Parent.Children) { var otherButton = child as GUIButton; if (child.UserData is MapEntityCategory && otherButton != button) { otherButton.Selected = false; } } button.Selected = true; return(true); }
private bool RefreshServers(GUIButton button, object obj) { if (waitingForRefresh) { return(false); } serverList.ClearChildren(); serverPreview.ClearChildren(); ipBox.Text = null; joinButton.Enabled = false; new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), serverList.Content.RectTransform), TextManager.Get("RefreshingServerList")); CoroutineManager.StartCoroutine(WaitForRefresh()); return(true); }
private void RefreshPrefabList() { prefabList.ClearChildren(); var particlePrefabs = GameMain.ParticleManager.GetPrefabList(); foreach (ParticlePrefab particlePrefab in particlePrefabs) { var prefabText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), prefabList.Content.RectTransform) { MinSize = new Point(0, 20) }, particlePrefab.Name) { Padding = Vector4.Zero, UserData = particlePrefab }; } }
public ParticleEditorScreen() { cam = new Camera(); guiRoot = new GUIFrame(Rectangle.Empty, null, null); leftPanel = new GUIFrame(new Rectangle(0, 0, 150, GameMain.GraphicsHeight), "GUIFrameLeft", guiRoot); leftPanel.Padding = new Vector4(10.0f, 20.0f, 10.0f, 20.0f); rightPanel = new GUIFrame(new Rectangle(0, 0, 450, GameMain.GraphicsHeight), null, Alignment.Right, "GUIFrameRight", guiRoot); rightPanel.Padding = new Vector4(10.0f, 20.0f, 0.0f, 20.0f); var saveAllButton = new GUIButton(new Rectangle(leftPanel.Rect.Right + 20, 10, 150, 20), "Save all", "", guiRoot); saveAllButton.OnClicked += (btn, obj) => { SerializeAll(); return(true); }; var serializeToClipBoardButton = new GUIButton(new Rectangle(leftPanel.Rect.Right + 20, 10, 150, 20), "Copy to clipboard", "", guiRoot); serializeToClipBoardButton.OnClicked += (btn, obj) => { SerializeToClipboard(selectedPrefab); return(true); }; emitter = new Emitter(); var emitterEditor = new SerializableEntityEditor(emitter, false, rightPanel, true); var listBox = new GUIListBox(new Rectangle(0, emitterEditor.Rect.Height + 20, 0, 0), "", rightPanel); prefabList = new GUIListBox(new Rectangle(0, 50, 0, 0), "", leftPanel); prefabList.OnSelected += (GUIComponent component, object obj) => { selectedPrefab = obj as ParticlePrefab; listBox.ClearChildren(); particlePrefabEditor = new SerializableEntityEditor(selectedPrefab, false, listBox, true); return(true); }; }
public void RefreshMissionTab(Mission selectedMission) { System.Diagnostics.Debug.Assert( selectedMission == null || (GameMain.GameSession.Map?.SelectedConnection != null && GameMain.GameSession.Map.CurrentLocation.AvailableMissions.Contains(selectedMission))); GameMain.GameSession.Map.CurrentLocation.SelectedMission = selectedMission; selectedMissionInfo.ClearChildren(); var container = selectedMissionInfo.Content; selectedMissionInfo.Visible = selectedMission != null; selectedMissionInfo.Spacing = 10; if (selectedMission == null) { return; } new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), container.RectTransform), selectedMission.Name, font: GUI.LargeFont) { AutoScale = true, CanBeFocused = false }; new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), container.RectTransform), TextManager.Get("Reward").Replace("[reward]", selectedMission.Reward.ToString())) { CanBeFocused = false }; new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), container.RectTransform), selectedMission.Description, wrap: true) { CanBeFocused = false }; if (startButton != null) { startButton.Enabled = true; } }
public void UpdateSubList() { var subsToShow = Submarine.SavedSubmarines.Where(s => !s.HasTag(SubmarineTag.HideInMenus)); subList.ClearChildren(); foreach (Submarine sub in subsToShow) { var textBlock = new GUITextBlock( new Rectangle(0, 0, 0, 25), ToolBox.LimitString(sub.Name, GUI.Font, subList.Rect.Width - 65), "ListBoxElement", Alignment.Left, Alignment.Left, subList) { Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f), ToolTip = sub.Description, UserData = sub }; if (sub.HasTag(SubmarineTag.Shuttle)) { textBlock.TextColor = textBlock.TextColor * 0.85f; var shuttleText = new GUITextBlock(new Rectangle(-20, 0, 0, 25), TextManager.Get("Shuttle"), "", Alignment.CenterRight, Alignment.CenterRight, textBlock, false, GUI.SmallFont); shuttleText.TextColor = textBlock.TextColor * 0.8f; shuttleText.ToolTip = textBlock.ToolTip; } GUIButton infoButton = new GUIButton(new Rectangle(0, 0, 20, 20), "?", Alignment.CenterRight, "", textBlock); infoButton.UserData = sub; infoButton.OnClicked += (component, userdata) => { var msgBox = new GUIMessageBox("", "", 550, 350); ((Submarine)userdata).CreatePreviewWindow(msgBox.InnerFrame); return(true); }; } if (Submarine.SavedSubmarines.Count > 0) { subList.Select(Submarine.SavedSubmarines[0]); } }
private void RefreshCreateItemFileList() { createItemFileList.ClearChildren(); if (itemContentPackage == null) { return; } var contentTypes = Enum.GetValues(typeof(ContentType)); foreach (ContentFile contentFile in itemContentPackage.Files) { var fileFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.1f), createItemFileList.Content.RectTransform) { MinSize = new Point(0, 15) }, style: "ListBoxElement") { UserData = contentFile }; new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), fileFrame.RectTransform, Anchor.CenterLeft), contentFile.Path); var contentTypeSelection = new GUIDropDown(new RectTransform(new Vector2(0.4f, 1.0f), fileFrame.RectTransform, Anchor.CenterRight), elementCount: contentTypes.Length) { UserData = contentFile, }; contentTypeSelection.OnSelected = (GUIComponent selected, object userdata) => { ((ContentFile)contentTypeSelection.UserData).Type = (ContentType)userdata; itemContentPackage.Save(itemContentPackage.Path); return(true); }; foreach (ContentType contentType in contentTypes) { contentTypeSelection.AddItem(contentType.ToString(), contentType); } contentTypeSelection.SelectItem(contentFile.Type); } }
/*private void ShowDirectJoinPrompt() * { * var msgBox = new GUIMessageBox(TextManager.Get("ServerListDirectJoin"), "", new string[] { TextManager.Get("OK"), TextManager.Get("Cancel") }, * relativeSize: new Vector2(0.25f, 0.2f), minSize: new Point(400, 150)); * * var content = new GUILayoutGroup(new RectTransform(new Vector2(0.8f, 0.3f), msgBox.InnerFrame.RectTransform, Anchor.Center) { MinSize = new Point(0, 50) }) * { * IgnoreLayoutGroups = true, * Stretch = true, * RelativeSpacing = 0.05f * }; * * new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), content.RectTransform), TextManager.Get("ServerIP")); * var ipBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.5f), content.RectTransform)); * * var okButton = msgBox.Buttons[0]; * okButton.Enabled = false; * okButton.OnClicked = (btn, userdata) => * { * JoinServer(ipBox.Text, ""); * msgBox.Close(); * return true; * }; * * var cancelButton = msgBox.Buttons[1]; * cancelButton.OnClicked = msgBox.Close; * * ipBox.OnTextChanged += (textBox, text) => * { * okButton.Enabled = !string.IsNullOrEmpty(text); * return true; * }; * }*/ private void RefreshServers() { if (waitingForRefresh) { return; } serverList.ClearChildren(); serverPreview.ClearChildren(); joinButton.Enabled = false; ipBox.UserData = null; ipBox.Text = ""; new GUITextBlock(new RectTransform(new Vector2(1.0f, 1.0f), serverList.Content.RectTransform), TextManager.Get("RefreshingServerList"), textAlignment: Alignment.Center) { CanBeFocused = false }; CoroutineManager.StartCoroutine(WaitForRefresh()); }
private void FillStoreItemList() { storeItemList.ClearChildren(); int width = storeItemList.Rect.Width; foreach (MapEntityPrefab mapEntityPrefab in MapEntityPrefab.List) { if (!(mapEntityPrefab is ItemPrefab itemPrefab)) { continue; } PriceInfo priceInfo = itemPrefab.GetPrice(Campaign.Map.CurrentLocation); if (priceInfo == null) { continue; } CreateItemFrame(new PurchasedItem(itemPrefab, 0), priceInfo, storeItemList, width); } storeItemList.Content.RectTransform.SortChildren( (x, y) => (x.GUIComponent.UserData as PurchasedItem).ItemPrefab.Name.CompareTo((y.GUIComponent.UserData as PurchasedItem).ItemPrefab.Name)); }
public override void ClearChildren() { listBox.ClearChildren(); }
public void UpdateSubList(IEnumerable <SubmarineInfo> submarines) { List <SubmarineInfo> subsToShow; if (!isMultiplayer && subFilter != CategoryFilter.All) { subsToShow = submarines.Where(s => s.IsCampaignCompatibleIgnoreClass && s.IsVanillaSubmarine() == (subFilter == CategoryFilter.Vanilla)).ToList(); } else { string downloadFolder = Path.GetFullPath(SaveUtil.SubmarineDownloadFolder); subsToShow = submarines.Where(s => s.IsCampaignCompatibleIgnoreClass && Path.GetDirectoryName(Path.GetFullPath(s.FilePath)) != downloadFolder).ToList(); } subsToShow.Sort((s1, s2) => { int p1 = s1.Price > CampaignMode.InitialMoney ? 10 : 0; int p2 = s2.Price > CampaignMode.InitialMoney ? 10 : 0; return(p1.CompareTo(p2) * 100 + s1.Name.CompareTo(s2.Name)); }); subList.ClearChildren(); foreach (SubmarineInfo sub in subsToShow) { var textBlock = new GUITextBlock( new RectTransform(new Vector2(1, 0.1f), subList.Content.RectTransform) { MinSize = new Point(0, 30) }, ToolBox.LimitString(sub.DisplayName, GUI.Font, subList.Rect.Width - 65), style: "ListBoxElement") { ToolTip = sub.Description, UserData = sub }; if (!sub.RequiredContentPackagesInstalled) { textBlock.TextColor = Color.Lerp(textBlock.TextColor, Color.DarkRed, .5f); textBlock.ToolTip = TextManager.Get("ContentPackageMismatch") + "\n\n" + textBlock.RawToolTip; } var priceText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), textBlock.RectTransform, Anchor.CenterRight), TextManager.GetWithVariable("currencyformat", "[credits]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", sub.Price)), textAlignment: Alignment.CenterRight, font: GUI.SmallFont) { TextColor = sub.Price > CampaignMode.InitialMoney ? GUI.Style.Red : textBlock.TextColor * 0.8f, ToolTip = textBlock.ToolTip }; #if !DEBUG if (!GameMain.DebugDraw) { if (sub.Price > CampaignMode.InitialMoney || !sub.IsCampaignCompatible) { textBlock.CanBeFocused = false; textBlock.TextColor *= 0.5f; } } #endif } if (SubmarineInfo.SavedSubmarines.Any()) { var validSubs = subsToShow.Where(s => s.IsCampaignCompatible && s.Price <= CampaignMode.InitialMoney).ToList(); if (validSubs.Count > 0) { subList.Select(validSubs[Rand.Int(validSubs.Count)]); } } }
private void CreateUI() { Frame.ClearChildren(); leftPanel = new GUIFrame(new RectTransform(new Vector2(0.125f, 1.0f), Frame.RectTransform) { MinSize = new Point(150, 0) }, style: "GUIFrameLeft"); var paddedLeftPanel = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.95f), leftPanel.RectTransform, Anchor.CenterLeft) { RelativeOffset = new Vector2(0.02f, 0.0f) }) { RelativeSpacing = 0.01f, Stretch = true }; rightPanel = new GUIFrame(new RectTransform(new Vector2(0.25f, 1.0f), Frame.RectTransform, Anchor.TopRight) { MinSize = new Point(350, 0) }, style: "GUIFrameRight"); var paddedRightPanel = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), rightPanel.RectTransform, Anchor.Center) { RelativeOffset = new Vector2(0.02f, 0.0f) }) { RelativeSpacing = 0.01f, Stretch = true }; var saveAllButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.03f), paddedRightPanel.RectTransform), TextManager.Get("editor.saveall")) { OnClicked = (btn, obj) => { SerializeAll(); return(true); } }; var serializeToClipBoardButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.03f), paddedRightPanel.RectTransform), TextManager.Get("editor.copytoclipboard")) { OnClicked = (btn, obj) => { SerializeToClipboard(selectedPrefab); return(true); } }; emitter = new Emitter(); var emitterEditorContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.25f), paddedRightPanel.RectTransform), style: null); var emitterEditor = new SerializableEntityEditor(emitterEditorContainer.RectTransform, emitter, false, true, elementHeight: 20, titleFont: GUI.SubHeadingFont); emitterEditor.RectTransform.RelativeSize = Vector2.One; emitterEditorContainer.RectTransform.Resize(new Point(emitterEditorContainer.RectTransform.NonScaledSize.X, emitterEditor.ContentHeight), false); var listBox = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.6f), paddedRightPanel.RectTransform)); var filterArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.03f), paddedLeftPanel.RectTransform) { MinSize = new Point(0, 20) }, isHorizontal: true) { Stretch = true, UserData = "filterarea" }; filterLabel = new GUITextBlock(new RectTransform(Vector2.One, filterArea.RectTransform), TextManager.Get("serverlog.filter"), font: GUI.Font) { IgnoreLayoutGroups = true }; filterBox = new GUITextBox(new RectTransform(new Vector2(0.8f, 1.0f), filterArea.RectTransform), font: GUI.Font); filterBox.OnTextChanged += (textBox, text) => { FilterEmitters(text); return(true); }; new GUIButton(new RectTransform(new Vector2(0.05f, 1.0f), filterArea.RectTransform, scaleBasis: ScaleBasis.BothHeight), style: "GUICancelButton") { OnClicked = (btn, userdata) => { FilterEmitters(""); filterBox.Text = ""; filterBox.Flash(Color.White); return(true); } }; prefabList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.8f), paddedLeftPanel.RectTransform)); prefabList.OnSelected += (GUIComponent component, object obj) => { selectedPrefab = obj as ParticlePrefab; listBox.ClearChildren(); new SerializableEntityEditor(listBox.Content.RectTransform, selectedPrefab, false, true, elementHeight: 20, titleFont: GUI.SubHeadingFont); //listBox.Content.RectTransform.NonScaledSize = particlePrefabEditor.RectTransform.NonScaledSize; //listBox.UpdateScrollBarSize(); return(true); }; if (GameMain.ParticleManager != null) { RefreshPrefabList(); } }
public ParticleEditorScreen() { cam = new Camera(); leftPanel = new GUIFrame(new RectTransform(new Vector2(0.07f, 1.0f), Frame.RectTransform) { MinSize = new Point(150, 0) }, style: "GUIFrameLeft"); var paddedLeftPanel = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.95f), leftPanel.RectTransform, Anchor.CenterLeft) { RelativeOffset = new Vector2(0.02f, 0.0f) }) { Stretch = true }; rightPanel = new GUIFrame(new RectTransform(new Vector2(0.25f, 1.0f), Frame.RectTransform, Anchor.TopRight) { MinSize = new Point(450, 0) }, style: "GUIFrameRight"); var paddedRightPanel = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), rightPanel.RectTransform, Anchor.Center) { RelativeOffset = new Vector2(0.02f, 0.0f) }) { Stretch = true, RelativeSpacing = 0.01f }; var saveAllButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.03f), paddedRightPanel.RectTransform), TextManager.Get("ParticleEditorSaveAll")) { OnClicked = (btn, obj) => { SerializeAll(); return(true); } }; var serializeToClipBoardButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.03f), paddedRightPanel.RectTransform), TextManager.Get("ParticleEditorCopyToClipboard")) { OnClicked = (btn, obj) => { SerializeToClipboard(selectedPrefab); return(true); } }; emitter = new Emitter(); var emitterEditorContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.25f), paddedRightPanel.RectTransform), style: null); var emitterEditor = new SerializableEntityEditor(emitterEditorContainer.RectTransform, emitter, false, true, elementHeight: 20); emitterEditor.RectTransform.RelativeSize = Vector2.One; emitterEditorContainer.RectTransform.Resize(new Point(emitterEditorContainer.RectTransform.NonScaledSize.X, emitterEditor.ContentHeight), false); var listBox = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.6f), paddedRightPanel.RectTransform)); prefabList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.8f), paddedLeftPanel.RectTransform)); prefabList.OnSelected += (GUIComponent component, object obj) => { selectedPrefab = obj as ParticlePrefab; listBox.ClearChildren(); particlePrefabEditor = new SerializableEntityEditor(listBox.Content.RectTransform, selectedPrefab, false, true, elementHeight: 20); //listBox.Content.RectTransform.NonScaledSize = particlePrefabEditor.RectTransform.NonScaledSize; //listBox.UpdateScrollBarSize(); return(true); }; }