コード例 #1
0
        private void updateGroundStationGUIRow(string stationID)
        {
            if (this.currentContentType != ContentType.GROUNDSTATIONS)
            {
                return;
            }

            List <DialogGUIBase> rows = contentLayout.children;

            for (int i = 1; i < rows.Count; i++)
            {
                DialogGUIBase thisRow = rows[i];
                if (thisRow.OptionText.Equals(stationID))
                {
                    DialogGUIImage colorImage = thisRow.children[0] as DialogGUIImage;
                    DialogGUILabel nameLabel  = thisRow.children[1] as DialogGUILabel;
                    DialogGUILabel freqsLabel = thisRow.children[3] as DialogGUILabel;
                    CNCCommNetHome station    = CNCCommNetScenario.Instance.groundStations.Find(x => x.ID.Equals(stationID));
                    colorImage.uiItem.GetComponent <RawImage>().color = station.Color;
                    nameLabel.SetOptionText(station.stationName);
                    freqsLabel.SetOptionText(getFreqString(station.getFrequencyList()));

                    break;
                }
            }
        }
コード例 #2
0
        private void updateConstellationGUIRow(short updatedfrequency, short previousFrequency)
        {
            if (this.currentContentType != ContentType.CONSTELLATIONS)
            {
                return;
            }

            List <DialogGUIBase> rows = contentLayout.children;

            for (int i = 2; i < rows.Count; i++)
            {
                DialogGUIBase thisRow = rows[i];
                if (thisRow.OptionText.Equals(updatedfrequency.ToString()) || thisRow.OptionText.Equals(previousFrequency.ToString()))
                {
                    DialogGUIImage colorImage  = thisRow.children[0] as DialogGUIImage;
                    DialogGUILabel nameLabel   = thisRow.children[1] as DialogGUILabel;
                    DialogGUILabel freqLabel   = thisRow.children[2] as DialogGUILabel;
                    DialogGUILabel vesselLabel = thisRow.children[3] as DialogGUILabel;

                    Constellation updatedConstellation = CNCCommNetScenario.Instance.constellations.Find(x => x.frequency == updatedfrequency);
                    colorImage.uiItem.GetComponent <RawImage>().color = updatedConstellation.color;
                    nameLabel.SetOptionText(updatedConstellation.name);
                    freqLabel.SetOptionText(Localizer.Format("#CNC_Generic_FrequencyLabel") + string.Format(": <color={0}>{1}</color>", UIUtils.colorToHex(updatedConstellation.color), updatedConstellation.frequency)); //Frequency
                    vesselLabel.SetOptionText(Localizer.Format("#CNC_ConstellationControl_numSatsLabel", Constellation.countVessels(updatedConstellation)));                                                              // + " vessels"

                    thisRow.SetOptionText(updatedConstellation.frequency.ToString());
                    break;
                }
            }
        }
コード例 #3
0
 private void SetStatus(string status)
 {
     this.status = status;
     if (dialogStatus != null)
     {
         dialogStatus.SetOptionText(status);
     }
 }
コード例 #4
0
        private void updateVesselGUIRow(Vessel updatedVessel)
        {
            if (this.currentContentType != ContentType.VESSELS)
            {
                return;
            }

            CNCCommNetVessel     thisVessel = (CNCCommNetVessel)updatedVessel.Connection;
            List <DialogGUIBase> rows       = contentLayout.children;

            for (int i = 0; i < rows.Count; i++)
            {
                DialogGUIBase thisRow = rows[i];
                if (thisRow.OptionText.Equals(updatedVessel.id.ToString()))
                {
                    DialogGUILabel freqLabel = thisRow.children[2] as DialogGUILabel;
                    freqLabel.SetOptionText(getFreqString(thisVessel.getFrequencyList(), thisVessel.getStrongestFrequency()));
                    return;
                }
            }
        }
コード例 #5
0
        public void Update()
        {
            if (!KerbalHealthGeneralSettings.Instance.modEnabled)
            {
                if (reportWindow != null)
                {
                    reportWindow.Dismiss();
                }
                return;
            }

            if ((reportWindow != null) && dirty)
            {
                if (gridContents == null)
                {
                    Core.Log("gridContents is null.", LogLevel.Error);
                    return;
                }

                // # of tracked kerbals has changed => close & reopen the window
                if (gridContents.Count != (ShipConstruction.ShipManifest.CrewCount + 1) * colNum)
                {
                    Core.Log("Kerbals' number has changed. Recreating the Health Report window.", LogLevel.Important);
                    UndisplayData();
                    DisplayData();
                }

                // Fill the Health Report's grid with kerbals' health data
                int i = 0;
                KerbalHealthStatus khs = null;
                HealthModifierSet.VesselCache.Clear();

                List <ModuleKerbalHealth> trainingParts = Core.GetTrainingCapableParts(EditorLogic.SortedShipList);

                foreach (ProtoCrewMember pcm in ShipConstruction.ShipManifest.GetAllCrew(false).Where(pcm => pcm != null))
                {
                    khs = Core.KerbalHealthList[pcm]?.Clone();
                    if (khs == null)
                    {
                        Core.Log("Could not create a clone of KerbalHealthStatus for " + pcm.name + ". It is " + ((Core.KerbalHealthList[pcm] == null) ? "not " : "") + "found in KerbalHealthList, which contains " + Core.KerbalHealthList.Count + " records.", LogLevel.Error);
                        i++;
                        continue;
                    }

                    gridContents[(i + 1) * colNum].SetOptionText(khs.FullName);
                    khs.HP = khs.MaxHP;
                    // Making this call here, so that GetBalanceHP doesn't have to:
                    double changePerDay = khs.HealthChangePerDay();
                    double balanceHP    = khs.GetBalanceHP();
                    string s            = balanceHP > 0
                        ? "-> " + balanceHP.ToString("F0") + " HP (" + (balanceHP / khs.MaxHP * 100).ToString("F0") + "%)"
                        : Localizer.Format("#KH_ER_HealthPerDay", changePerDay.ToString("F1")); // + " HP/day"
                    gridContents[(i + 1) * colNum + 1].SetOptionText(s);
                    s = balanceHP > khs.NextConditionHP()
                        ? "—"
                        : ((khs.LastRecuperation > khs.LastDecay) ? "> " : "") + Core.ParseUT(khs.TimeToNextCondition(), false, 100);
                    gridContents[(i + 1) * colNum + 2].SetOptionText(s);
                    gridContents[(i + 1) * colNum + 3].SetOptionText(KerbalHealthFactorsSettings.Instance.TrainingEnabled ? Core.ParseUT(TrainingTime(khs, trainingParts), false, 100) : "N/A");
                    i++;
                }

                spaceLbl.SetOptionText("<color=\"white\">" + khs.VesselModifiers.Space.ToString("F1") + "</color>");
                recupLbl.SetOptionText("<color=\"white\">" + khs.VesselModifiers.Recuperation.ToString("F1") + "%</color>");
                shieldingLbl.SetOptionText("<color=\"white\">" + khs.VesselModifiers.Shielding.ToString("F1") + "</color>");
                exposureLbl.SetOptionText("<color=\"white\">" + khs.LastExposure.ToString("P1") + "</color>");
                shelterExposureLbl.SetOptionText("<color=\"white\">" + khs.VesselModifiers.ShelterExposure.ToString("P1") + "</color>");

                dirty = false;
            }
        }
コード例 #6
0
 public void Update()
 {
     if (!Core.ModEnabled)
     {
         if (reportWindow != null)
         {
             reportWindow.Dismiss();
         }
         return;
     }
     if ((reportWindow != null) && dirty)
     {
         if (gridContents == null)
         {
             Core.Log("gridContents is null.", Core.LogLevel.Error);
             return;
         }
         if (gridContents.Count != (ShipConstruction.ShipManifest.CrewCount + 1) * colNum)  // # of tracked kerbals has changed => close & reopen the window
         {
             Core.Log("Kerbals' number has changed. Recreating the Health Report window.", Core.LogLevel.Important);
             UndisplayData();
             DisplayData();
         }
         // Fill the Health Report's grid with kerbals' health data
         int i = 0;
         KerbalHealthStatus khs = null;
         VesselHealthInfo.Cache.Clear();
         foreach (ProtoCrewMember pcm in ShipConstruction.ShipManifest.GetAllCrew(false))
         {
             if (pcm == null)
             {
                 continue;
             }
             gridContents[(i + 1) * colNum].SetOptionText(pcm.name);
             khs = Core.KerbalHealthList?.Find(pcm)?.Clone();
             if (khs == null)
             {
                 Core.Log("Could not create a clone of KerbalHealthStatus for " + pcm.name + ". It is " + ((Core.KerbalHealthList?.Find(pcm) == null) ? "not " : "") + "found in KerbalHealthList, which contains " + Core.KerbalHealthList.Count + " records.", Core.LogLevel.Error);
                 i++;
                 continue;
             }
             khs.HP = khs.MaxHP;
             double ch = khs.HealthChangePerDay();
             double b  = khs.GetBalanceHP();
             string s  = "";
             if (b > 0)
             {
                 s = "-> " + b.ToString("F0") + " HP (" + (b / khs.MaxHP * 100).ToString("F0") + "%)";
             }
             else
             {
                 s = ch.ToString("F1") + " HP/day";
             }
             gridContents[(i + 1) * colNum + 1].SetOptionText(s);
             if (b > khs.NextConditionHP())
             {
                 s = "—";
             }
             else
             {
                 s = ((khs.LastRecuperation > khs.LastDecay) ? "> " : "") + Core.ParseUT(khs.TimeToNextCondition());
             }
             gridContents[(i + 1) * colNum + 2].SetOptionText(s);
             i++;
         }
         spaceLbl.SetOptionText(khs.VesselHealthInfo.Space.ToString("F1"));
         recupLbl.SetOptionText(khs.VesselHealthInfo.Recuperation.ToString("F1") + "%");
         shieldingLbl.SetOptionText(khs.VesselHealthInfo.Shielding.ToString("F1"));
         exposureLbl.SetOptionText(khs.Exposure.ToString("P1"));
         dirty = false;
     }
 }
コード例 #7
0
        private void UpdateGUI()
        {
            drewgui = true;

            Vessel vessel    = FlightGlobals.ActiveVessel;
            int    crewCount = vessel.GetCrewCount();
            var    parts     = vessel.FindPartModulesImplementing <LifeSupportReportable>();

            // Update live Kerbal numbers
            foreach (LifeSupportReportable module in parts)
            {
                bool   empty;
                string timestr = module.ReportLifeSupport(out empty);

                if (emptyPartLabels.ContainsKey(module.part))
                {
                    emptyPartLabels[module.part].SetOptionText($"{ORANGE}{timestr}</color>");
                    continue;
                }

                foreach (ProtoCrewMember kerbal in module.part.protoModuleCrew)
                {
                    double evaLS = EVALifeSupportTracker.GetEVALSInfo(kerbal.name).ls_current;

                    if (compress)
                    {
                        if (!vessel.isEVA && !empty)
                        {
                            labelMap[kerbal.name].nameLabel.SetOptionText(labelMap[kerbal.name].compressNames[0]);
                            labelMap[kerbal.name].shipLS.SetOptionText(timestr);
                        }
                        else
                        {
                            labelMap[kerbal.name].nameLabel.SetOptionText(labelMap[kerbal.name].compressNames[1]);
                            string evastr = Util.DaysToString(evaLS / C.EVA_LS_DRAIN_PER_DAY);
                            labelMap[kerbal.name].shipLS.SetOptionText(evastr);
                        }
                    }
                    else
                    {
                        string evastr = Util.DaysToString(evaLS / C.EVA_LS_DRAIN_PER_DAY);
                        labelMap[kerbal.name].shipLS.SetOptionText(timestr);
                        labelMap[kerbal.name].evaLS.SetOptionText(evastr);
                    }

                    if (Config.DEBUG_SHOW_EVA)
                    {
                        var info = EVALifeSupportTracker.GetEVALSInfo(kerbal.name);
                        labelMap[kerbal.name].evaLS_Value.SetOptionText(info.ls_current.ToString());
                        labelMap[kerbal.name].evaProp.SetOptionText(info.prop_current.ToString());
                    }
                }
            }

            // Any Kerbals not found above are assumed KIA
            // Would be great to move this to a GameEvent
            // such as GameEvents.onKerbalRemoved()
            if (crewCount < labelMap.Count)
            {
                List <string> fullcrew = vessel.GetVesselCrew().ConvertAll(a => a.name);
                foreach (string name in labelMap.Keys.ToArray())
                {
                    if (!fullcrew.Contains(name))
                    {
                        labelMap[name].shipLS.SetOptionText("KIA");
                        labelMap[name].evaLS.SetOptionText("KIA");
                        labelMap.Remove(name);
                    }
                }
            }

            // Update status
            double curr, max;

            vessel.GetConnectedResourceTotals(lsID, out curr, out max);

            string statusOne; // Status (no crew/breathable/active)
            string statusTwo; // Remaining Consumables/EVA Life Support
            string lsActive;

            if (crewCount == 0)
            {
                lsActive = "No crew";
            }
            else if (Util.BreathableAir(vessel))
            {
                lsActive = "Breathable air";
            }
            else
            {
                lsActive = "ACTIVE";
            }
            statusOne = $"{(compress ? "" : "Status: ")}{lsActive}";

            if (FlightGlobals.ActiveVessel.isEVA)
            {
                vessel.GetConnectedResourceTotals(evapropID, out curr, out max);
                string prefix = "";
                string suffix = "</color>";
                if (curr < 0.5)
                {
                    prefix = C.GUI_HARDWARN_COLOR;
                }
                else if (curr < 1.0)
                {
                    prefix = C.GUI_LITEWARN_COLOR;
                }
                else
                {
                    suffix = "";
                }
                statusTwo = $"Propellant:  {prefix}{string.Format("{0:0.00}", curr)}{suffix}";
            }
            else
            {
                vessel.GetConnectedResourceTotals(consID, out curr, out max);
                double consDays = curr / C.CONS_PER_LS;
                statusTwo = $"{(compress ? "" : "Consumables:  ")}{Util.DaysToString(consDays)}";
            }

            statusLabel.SetOptionText($"{statusOne}\n{statusTwo}");
        }