protected override void OnUpdate() { if (waiting && Planetarium.GetUniversalTime() > completionTime) { waiting = false; SetComplete(); } // Every time the clock ticks over, make an attempt to update the contract window // notes. We do this because otherwise the window will only ever read the notes once, // so this is the only way to get our fancy timer to work. else if (waiting && trackedVessel != null && Planetarium.GetUniversalTime() - lastUpdate > 1.0f) { lastUpdate = Planetarium.GetUniversalTime(); // Go through all the list items in the contracts window UIScrollList list = ContractsApp.Instance.cascadingList.cascadingList; for (int i = 0; i < list.Count; i++) { // Try to find a rich text control that matches the expected text UIListItemContainer listObject = (UIListItemContainer)list.GetItem(i); SpriteTextRich richText = listObject.GetComponentInChildren <SpriteTextRich>(); if (richText != null && noteTracker.ContainsKey(richText.Text)) { // Clear the noteTracker, and replace the text noteTracker.Clear(); richText.Text = notePrefix + GetNotes(); } } } }
/// <summary> /// Call this any time the title text has changed - this will make an attempt to update /// the contract window title. We do this because otherwise the window will only ever read /// the title once. /// </summary> /// <param name="newTitle">New title to display</param> public void UpdateContractWindow(ContractParameter param, string newTitle) { // Try to find the cascading list in the contracts window. Note that we may pick up // the ones from the Engineer's report in the VAB/SPH instead - but we don't care about // title updates in those scenes anyway. if (cascadingList == null || !cascadingList.gameObject.activeSelf) { cascadingList = UnityEngine.Object.FindObjectOfType <GenericCascadingList>(); } // Every time the clock ticks over, make an attempt to update the contract window // title. We do this because otherwise the window will only ever read the title once, // so this is the only way to get our fancy timer to work. // Go through all the list items in the contracts window if (cascadingList != null) { UIScrollList list = cascadingList.ruiList.cascadingList; if (list != null) { for (int i = 0; i < list.Count; i++) { // Try to find a rich text control that matches the expected text UIListItemContainer listObject = (UIListItemContainer)list.GetItem(i); SpriteTextRich richText = listObject.GetComponentInChildren <SpriteTextRich>(); if (richText != null) { // Check for any string in titleTracker string found = null; foreach (string title in titles) { if (richText.Text.Contains(title)) { found = title; break; } } // Clear the titleTracker, and replace the text if (found != null) { titles.Clear(); richText.Text = richText.Text.Replace(found, newTitle); titles.Add(newTitle); } } } // Reposition items to account for items where the height increased or decreased list.RepositionItems(); } } // Contracts Window + update ContractsWindow.SetParameterTitle(param, newTitle); }
protected override void OnUpdate() { base.OnUpdate(); // Every time the clock ticks over, make an attempt to update the contract window // title. We do this because otherwise the window will only ever read the title once, // so this is the only way to get our fancy timer to work. if (Planetarium.GetUniversalTime() - lastUpdate > 1.0f) { // Boom! if (Planetarium.GetUniversalTime() > endTime) { SetFailed(); } lastUpdate = Planetarium.GetUniversalTime(); // Go through all the list items in the contracts window UIScrollList list = ContractsApp.Instance.cascadingList.cascadingList; if (list != null) { for (int i = 0; i < list.Count; i++) { // Try to find a rich text control that matches the expected text UIListItemContainer listObject = (UIListItemContainer)list.GetItem(i); SpriteTextRich richText = listObject.GetComponentInChildren <SpriteTextRich>(); if (richText != null) { // Check for any string in titleTracker string found = null; foreach (string title in titleTracker) { if (richText.Text.Contains(title)) { found = title; break; } } // Clear the titleTracker, and replace the text if (found != null) { titleTracker.Clear(); richText.Text = richText.Text.Replace(found, GetTitle()); } } } } } }
/// <summary> /// Call this any time the title text has changed - this will make an attempt to update /// the contract window title. We do this because otherwise the window will only ever read /// the title once. /// </summary> /// <param name="newTitle">New title to display</param> public void UpdateContractWindow(string newTitle) { // Every time the clock ticks over, make an attempt to update the contract window // title. We do this because otherwise the window will only ever read the title once, // so this is the only way to get our fancy timer to work. // Go through all the list items in the contracts window UIScrollList list = ContractsApp.Instance.cascadingList.cascadingList; if (list != null) { for (int i = 0; i < list.Count; i++) { // Try to find a rich text control that matches the expected text UIListItemContainer listObject = (UIListItemContainer)list.GetItem(i); SpriteTextRich richText = listObject.GetComponentInChildren <SpriteTextRich>(); if (richText != null) { // Check for any string in titleTracker string found = null; foreach (string title in titles) { if (richText.Text.Contains(title)) { found = title; break; } } // Clear the titleTracker, and replace the text if (found != null) { titles.Clear(); richText.Text = richText.Text.Replace(found, newTitle); titles.Add(newTitle); } } } // Reposition items to account for items where the height increased or decreased list.RepositionItems(); } }