protected void setupInfoBox() { if (infoBox != null) { return; } try { getMaxTotalFuel(); resourceBroker = new ResourceBroker(); ResourceRatio[] inputs = inputList.ToArray(); Color clr; for (int index = 0; index < inputs.Length; index++) { if (inputs[index].ResourceName == fuelGaugeResource) { infoBox = this.part.stackIcon.StageIcon.DisplayInfo(); infoBox.SetMessage(fuelGaugeResource); clr = XKCDColors.GreenYellow; //XKCDColors.BrightOlive; clr.a = 0.55f; infoBox.SetMsgTextColor(clr); clr = XKCDColors.Asparagus; clr.a = 0.5f; infoBox.SetMsgBgColor(clr); infoBox.SetProgressBarBgColor(clr); infoBox.Collapse(); break; } } } catch { } }
private IEnumerator <WaitForSeconds> DoSelfDestruct() { Log.Write($"Starting self destruct coroutine"); ScreenMessage msg = ScreenMessages.PostScreenMessage("Starting self destruct sequence", 1.0f, ScreenMessageStyle.UPPER_CENTER); StageIconInfoBox ib = null; if (this.part.stackIcon.StageIcon != null) { this.part.stackIcon.StageIcon.SetIconColor(Color.red); ib = this.part.stackIcon.StageIcon.DisplayInfo(); // ib.SetCaption($"Self Destruct"); ib.SetMsgBgColor(Color.white); ib.SetMsgTextColor(Color.black); } while ((Time.time - countDownTime) < 5.0f) { Log.Write($"Self destruct countdown: {(5.0f - (Time.time - countDownTime)).ToString("#0")}"); msg.message = $"Self destruct in {(5.0f - (Time.time - countDownTime)).ToString("#0")}"; ScreenMessages.PostScreenMessage(msg); if (ib != null) { ib.SetValue((Time.time - countDownTime), 0.0f, 4.0f); ib.SetMessage($"Self Destruct: {(5.0f - (Time.time - countDownTime)).ToString("#0")}s"); } yield return(new WaitForSeconds(1.0f)); } while (vessel.parts.Count > 0) { Part part = vessel.parts.Find(x => x != vessel.rootPart && x != this.part && !x.children.Any() && x.partInfo.name != "pkLES.EscapeMk1v2" && x.partInfo.name != "pkLES.mk2" && x.partInfo.name != "pkLES.mk2.noBPC" && x.partInfo.name != "LaunchEscapeSystem"); if (part != null) { Log.Write($"Exploding {part.partInfo.name} [{part.partInfo.title}]"); part.explode(); yield return(null); } else { while (vessel.parts.Count > 0) { Log.Write($"Exploding {vessel.parts[0].partInfo.name} [{vessel.parts[0].partInfo.title}]"); vessel.parts[0].explode(); yield return(null); } } yield return(new WaitForSeconds(0.1f)); } }
public void Initialize(StageIconInfoBox iconInfo, bool disp, BasicDeltaV_StagePanel pan) { infoBar = iconInfo; display = disp; panel = pan; showText = BasicDeltaV_Settings.Instance.ShowDVText; if (!showText) { infoBar.SetCaption(string.Format("<color=#{0}> ΔV</color>", BasicDeltaV.TextColor)); } if (panel.Stage != null) { infoBar.SetValue((float)panel.Stage.deltaV, 0, (float)panel.Stage.totalDeltaV); } }
private void processFlightStageGroup() { StageManager prefabFlight = null; var prefabs = Resources.FindObjectsOfTypeAll <StageManager>(); for (int i = prefabs.Length - 1; i >= 0; i--) { var pre = prefabs[i]; if (pre.name == "StageManager") { prefabFlight = pre; } } if (prefabFlight == null) { return; } try { var fields = typeof(StageIcon).GetFields(BindingFlags.NonPublic | BindingFlags.Instance).ToArray(); StageIconInfoBox infoBar = fields[12].GetValue(prefabFlight.stageIconPrefab) as StageIconInfoBox; panelInfoBarPrefab = Instantiate(infoBar, BasicDeltaV_Settings.Instance.transform); panelInfoBarPrefab.gameObject.name = "BasicerDeltaV"; RectTransform infoRect = panelInfoBarPrefab.GetComponent <RectTransform>(); infoRect.anchorMin = new Vector2(1, 1); infoRect.anchorMax = new Vector2(1, 1); infoRect.anchoredPosition = new Vector2(25, 12); panelInfoBarPrefab.GetComponent <LayoutElement>().ignoreLayout = true; panelInfoBarPrefab.SetCaption(string.Format("<color=#{0}> ΔV</color>", BasicDeltaV.TextColor)); panelInfoBarPrefab.SetProgressBarBgColor(new Color(0.51765f, 0.71765f, 0.003922f, 0.6f)); panelInfoBarPrefab.SetProgressBarColor(new Color(1, 1, 0.078431f, 0.6f)); Slider slider = panelInfoBarPrefab.GetComponentInChildren <Slider>(); RectTransform sliderRect = slider.GetComponent <RectTransform>(); sliderRect.sizeDelta = new Vector2(sliderRect.sizeDelta.x, 16); sliderRect.anchoredPosition = new Vector2(sliderRect.anchoredPosition.x, -2); TextMeshProUGUI captionText = panelInfoBarPrefab.GetComponentsInChildren <TextMeshProUGUI>()[1]; captionText.color = Color.white; RectTransform captionRect = captionText.rectTransform; captionRect.sizeDelta = new Vector2(captionRect.sizeDelta.x, 16); tooltipPrefab = panelInfoBarPrefab.GetComponent <TooltipController_Text>(); //BasicDeltaV.BasicLogging("Toolip: Enabled: {0} tooltip prefab: {1} instance" , tool.enabled // , tool.prefab == null ? "Null" : "Valid", tool.TooltipPrefabInstance == null ? "Null" : "Valid"); tooltipPrefab.enabled = true; tooltipPrefab.continuousUpdate = true; Destroy(panelInfoBarPrefab.GetComponentInChildren <TextMeshProUGUI>().gameObject); Destroy(panelInfoBarPrefab.GetComponentInChildren <Image>().gameObject); //BasicDeltaV.BasicLogging("DV Panel Prefab processed"); } catch (Exception e) { panelInfoBarPrefab = null; BasicDeltaV.BasicLogging("Error in stage panel info box UI: {0}", e); } StageGroup group = prefabFlight.stageGroupPrefab; if (stageGroupSprite == null) { Transform layout = group.transform.Find("IconLayout"); if (layout != null) { stageGroupSprite = layout.GetComponent <Image>().sprite; } } group.gameObject.AddComponent <BasicDeltaV_StageGroupHandler>(); stageFlightGroupProcessed = true; }
public BasicDeltaV_StagePanel(RectTransform rect, int i, bool right, bool display, StageIconInfoBox info) { parent = rect; index = i; rightPos = right; stage = BasicDeltaV.Instance.GetStage(i); StartModules(); if (info != null) { simpleGauge = info.gameObject.AddComponent <BasicDeltaV_SimpleDeltaVGauge>(); bool displayGauge = BasicDeltaV_Settings.Instance.MoreBasicMode; if (BasicDeltaV_Settings.Instance.BasicCurrentOnly && index != StageManager.LastStage) { displayGauge = false; } if (BasicDeltaV.Instance.ComplexRestrictions) { displayGauge = false; } simpleGauge.Initialize(info, displayGauge && stage != null && stage.stageStartDeltaV > 0, this); } CreatePanel(right, display && stage != null && stage.deltaV > 0); }
private void AddStagePanel(StageGroup group, bool display) { bool iconInfo = false; StageIconInfoBox dvInfo = null; if (HighLogic.LoadedSceneIsFlight) { int checks = 0; for (int i = group.Icons.Count - 1; i >= 0; i--) { StageIcon icon = group.Icons[i]; if (icon.grouped) { if (icon.expanded) { if (checks >= 1) { if (icon.groupedIcons[icon.groupedIcons.Count - 1].isDisplayingInfo) { iconInfo = true; break; } else { break; } } else { checks += 2; } } else { checks++; } if (!icon.isDisplayingInfoInGroup) { continue; } } else { checks++; if (!icon.isDisplayingInfo) { continue; } } iconInfo = true; break; } //BasicDeltaV.BasicLogging("Info Box: {0}", BasicDeltaV_Loader.PanelInfoBarPrefab == null ? "Null" : "Valid"); dvInfo = Instantiate(BasicDeltaV_Loader.PanelInfoBarPrefab, group.transform); dvInfo.transform.SetAsFirstSibling(); } BasicDeltaV_StagePanel panel = new BasicDeltaV_StagePanel(group.RectTransform, group.inverseStageIndex, iconInfo, display, dvInfo); panels.Add(group, panel); }