Exemplo n.º 1
0
        protected override string GetTitle()
        {
            if (endTime > 0.01)
            {
                string title = null;
                if (endTime - Planetarium.GetUniversalTime() > 0.0)
                {
                    title = (waitingText ?? "Time to completion:") + " " + DurationUtil.StringValue(endTime - Planetarium.GetUniversalTime());
                }
                else
                {
                    title = completionText ?? "Wait time over";
                }

                // Add the string that we returned to the titleTracker.  This is used to update
                // the contract title element in the GUI directly, as it does not support dynamic
                // text.
                titleTracker.Add(title);

                return(title);
            }
            else
            {
                return((preWaitText ?? "Waiting time required:") + " " + DurationUtil.StringValue(duration));
            }
        }
        protected override string GetTitle()
        {
            if (vessel == null)
            {
                return("");
            }

            string vesselName = vessel.GetDisplayName();

            if (vesselName == null)
            {
                vesselName = vessel.name;
            }

            string result;

            if (string.IsNullOrEmpty(statusLabel))
            {
                result = KERBALISM.Lib.Ellipsis(vesselName, 35);
            }
            else
            {
                result = KERBALISM.Lib.Ellipsis(vesselName, 35) + "\n" + statusLabel;
            }

            titleTracker.Add(result);
            if (lastTitle != result && Root != null && (Root.ContractState == Contract.State.Active || Root.ContractState == Contract.State.Failed))
            {
                titleTracker.UpdateContractWindow(result);
                lastTitle = result;
            }
            return(result);
        }
        protected override string GetTitle()
        {
            string output;

            if (string.IsNullOrEmpty(title))
            {
                // Re-label a couple of scan names to make them nicer
                nameRemap["AltimetryLoRes"] = "Low resolution altimetry";
                nameRemap["AltimetryHiRes"] = "High resolution altimetry";

                string scanTypeName = nameRemap.ContainsKey(scanName) ? nameRemap[scanName] : scanName;
                output = scanTypeName + " scan of " + targetBody.theName + ": ";
                if (currentCoverage > 0.0 && state != ParameterState.Complete)
                {
                    output += currentCoverage.ToString("N0") + "% / ";
                }
                output += coverage.ToString("N0") + "%";
                titleTracker.Add(output);
            }
            else
            {
                output = title;
            }

            return(output);
        }
Exemplo n.º 4
0
        protected override string GetTitle()
        {
            if (hidden)
            {
                return("");
            }

            if (Parent != null)
            {
                ContractConfiguratorParameter ccpParent = Parent as ContractConfiguratorParameter;
                if (ccpParent != null && ccpParent.hideChildren)
                {
                    return("");
                }
            }

            string output = (optional && !fakeOptional && string.IsNullOrEmpty(title) ? "(Optional) " : "") + GetParameterTitle();

            // Update the contract window title
            titleTracker.Add(output);
            if (lastTitle != output && Root != null && (Root.ContractState == Contract.State.Active || Root.ContractState == Contract.State.Failed))
            {
                titleTracker.UpdateContractWindow(output);
                lastTitle = output;
            }

            return(output);
        }
        protected override string GetTitle()
        {
            string result = subRequirement.GetTitle(context);

            titleTracker.Add(result);
            if (lastTitle != result && Root != null && (Root.ContractState == Contract.State.Active || Root.ContractState == Contract.State.Failed))
            {
                titleTracker.UpdateContractWindow(result);
                lastTitle = result;
            }
            return(result);
        }
        protected override string GetTitle()
        {
            string output = "";

            try
            {
                if (hidden)
                {
                    return("");
                }

                if (Parent != null)
                {
                    ContractConfiguratorParameter ccpParent = Parent as ContractConfiguratorParameter;
                    if (ccpParent != null && ccpParent.hideChildren)
                    {
                        return("");
                    }
                }

                // (Optional)
                output = (optional && !fakeOptional && string.IsNullOrEmpty(title) ?
                          StringBuilderCache.Format("{0} {1}", Localizer.GetStringByTag("#cc.param.optionalTag"), GetParameterTitle()) :
                          GetParameterTitle());

                // Update the contract window title
                titleTracker.Add(output);
                if (lastTitle != output && Root != null && (Root.ContractState == Contract.State.Active || Root.ContractState == Contract.State.Failed))
                {
                    titleTracker.UpdateContractWindow(output);
                    lastTitle = output;
                }
            }
            catch (Exception e)
            {
                // Don't let exceptions mess us up
                LoggingUtil.LogException(new ContractConfiguratorException(this, e));
            }

            return(output);
        }
Exemplo n.º 7
0
        protected override string GetTitle()
        {
            string output;

            if (string.IsNullOrEmpty(title))
            {
                output = targetBody.name + ": Communication coverage: ";
                if (currentCoverage >= 0.0)
                {
                    output += (currentCoverage * 100).ToString("F0") + "% / ";
                }
                output += (coverage * 100).ToString("F0") + "%";
                titleTracker.Add(output);
            }
            else
            {
                output = title;
            }

            return(output);
        }
Exemplo n.º 8
0
        protected override string GetTitle()
        {
            string output;

            if (string.IsNullOrEmpty(title))
            {
                output  = (hasConnectivity ? "Direct connection to: " : "No direct connection to: ");
                output += ContractVesselTracker.Instance.GetDisplayName(vesselKey);
            }
            else
            {
                output = title;
            }

            // Add the string that we returned to the titleTracker.  This is used to update
            // the contract title element in the GUI directly, as it does not support dynamic
            // text.
            titleTracker.Add(output);

            return(output);
        }
        protected override string GetTitle()
        {
            if (flightData >= requiredData)
            {
                return("All data collected");
            }
            else if (flightData > 0 && flightData < requiredData)
            {
                string title = String.Format("Data remaining: {0:F2}", requiredData - flightData);

                // Add the string that we returned to the titleTracker.  This is used to update
                // the contract title element in the GUI directly, as it does not support dynamic
                // text.
                titleTracker.Add(title);

                return(title);
            }
            else
            {
                return(String.Format("Flight Data: {1}: {0:F2}", requiredData, partName));
            }
        }
Exemplo n.º 10
0
        protected override string GetTitle()
        {
            if (state == ParameterState.Failed)
            {
                return("Time expired!");
            }
            else if (endTime > 0.01)
            {
                string title = "Time remaining: " + DurationUtil.StringValue(endTime - Planetarium.GetUniversalTime());

                // Add the string that we returned to the titleTracker.  This is used to update
                // the contract title element in the GUI directly, as it does not support dynamic
                // text.
                titleTracker.Add(title);

                return(title);
            }
            else
            {
                return("Time limit: " + DurationUtil.StringValue(duration));
            }
        }
        protected override string GetTitle()
        {
            string result = "";
            double now    = Planetarium.GetUniversalTime();

            string remainingStr = durationType == DurationType.countdown
                                ? DurationUtil.StringValue(Math.Max(0, doneAfter - now))
                                : DurationUtil.StringValue(Math.Max(0, duration - accumulatedDuration));

            switch (durationState)
            {
            case DurationState.off:
                result = Localizer.Format("Duration: <<1>>", DurationUtil.StringValue(duration));
                if (waitDuration > 0)
                {
                    result += "\n\t - " + Localizer.Format("Time starts <<1>> after accepting the contract",
                                                           Lib.Color(DurationUtil.StringValue(waitDuration), Lib.Kolor.Yellow));
                }
                if (allowedDowntime > 0)
                {
                    result += "\n\t - " + Localizer.Format("Allows interruptions up to <<1>>",
                                                           DurationUtil.StringValue(allowedDowntime));
                }
                else
                {
                    result += "\n\t - " + "Does not allow interruptions";
                }
                if (!allowReset)
                {
                    result += "\n\t - " + Lib.Color("Will fail if interrupted beyond allowance", Lib.Kolor.Orange);
                }

                break;

            case DurationState.preRun:
                result  = Localizer.Format("Duration: <<1>>", DurationUtil.StringValue(duration));
                result += "\n\t - " + Localizer.Format("Time starts in <<1>>",
                                                       Lib.Color(DurationUtil.StringValue(Math.Max(0, startAfter - now)), Lib.Kolor.Yellow));
                if (allowedDowntime > 0)
                {
                    result += "\n\t - " + Localizer.Format("Allows interruptions up to <<1>>",
                                                           DurationUtil.StringValue(allowedDowntime));
                }

                break;

            case DurationState.running:
                result = Localizer.Format("Remaining: <<1>>", Lib.Color(remainingStr, Lib.Kolor.Green));
                if (allowedDowntime > 0)
                {
                    result += "\n\t - " + Localizer.Format("Allows interruptions up to <<1>>",
                                                           DurationUtil.StringValue(allowedDowntime));
                }

                break;

            case DurationState.preReset:
                result = Localizer.Format("Remaining: <<1>> (stop in: <<2>>)", Lib.Color(remainingStr, Lib.Kolor.Green),
                                          Lib.Color(DurationUtil.StringValue(Math.Max(0, failAfter - now)), allowReset ? Lib.Kolor.Yellow : Lib.Kolor.Red));

                break;

            case DurationState.done:
                result = "Done!";
                break;

            case DurationState.failed:
                result = "Time is up!";
                break;
            }

            titleTracker.Add(result);
            if (lastTitle != result && Root != null && (Root.ContractState == Contract.State.Active || Root.ContractState == Contract.State.Failed))
            {
                titleTracker.UpdateContractWindow(result);
                lastTitle = result;
            }
            return(result);
        }
Exemplo n.º 12
0
        protected override string GetTitle()
        {
            // Set the first part of the output
            string output;

            if (!string.IsNullOrEmpty(title))
            {
                output = title;
            }
            else
            {
                // Set the vessel name
                output = "Vessel: ";
                if ((waiting || state == ParameterState.Complete) && trackedVessel != null)
                {
                    output += trackedVessel.vesselName;
                }
                else if (!string.IsNullOrEmpty(define))
                {
                    output += define + " (new)";
                }
                else if (vesselList.Any())
                {
                    bool first = true;
                    foreach (string vesselName in vesselList)
                    {
                        if (!first)
                        {
                            output += " OR ";
                        }
                        if (ContractVesselTracker.Instance != null)
                        {
                            output += ContractVesselTracker.Instance.GetDisplayName(vesselName);
                        }
                        else
                        {
                            LoggingUtil.LogWarning(this, "Unable to get vessel display name for '" + vesselName + "' - ContractVesselTracker is null.  This is likely caused by another ScenarioModule crashing, preventing others from loading.");
                            output += vesselName;
                        }
                        first = false;
                    }
                }
                else
                {
                    output += "Any";
                }
            }

            // Not yet complete, add duration
            if (state != ParameterState.Complete)
            {
                // Add duration
                if (completionTime > 0.0)
                {
                    output += "; Time Remaining: " + DurationUtil.StringValue(completionTime - Planetarium.GetUniversalTime());
                }
                else if (duration > 0.0)
                {
                    output += "; Duration: " + DurationUtil.StringValue(duration);
                }
            }
            // If we're complete and a custom title hasn't been provided, try to get a better title
            else if (string.IsNullOrEmpty(title))
            {
                if (ParameterCount == 1)
                {
                    output = "";
                    if (trackedVessel != null)
                    {
                        output += "Vessel: " + trackedVessel.vesselName + ": ";
                    }
                    output += GetParameter(0).Title;
                }
            }

            // Add the string that we returned to the titleTracker.  This is used to update
            // the contract title element in the GUI directly, as it does not support dynamic
            // text.
            titleTracker.Add(output);

            return(output);
        }
Exemplo n.º 13
0
        protected override string GetTitle()
        {
            InitStrings();

            string result = "";
            double now    = Planetarium.GetUniversalTime();

            string remainingStr = durationType == DurationType.countdown
                                ? DurationUtil.StringValue(Math.Max(0, doneAfter - now))
                                : DurationUtil.StringValue(Math.Max(0, duration - accumulatedDuration));

            switch (durationState)
            {
            case DurationState.off:
                result = KerCon_Duration_X;                         // Duration: <<1>>
                if (waitDuration > 0)
                {
                    result += "\n\t - " + KerCon_TimeStartsAfterAccepting;
                }
                if (allowedDowntime > 0)
                {
                    result += "\n\t - " + KerCon_AllowsInterruptionsUpTo;
                }
                else if (durationType == DurationType.accumulating)
                {
                    result += "\n\t - " + KerCon_AccumulatingDuration;
                }
                else
                {
                    result += "\n\t - " + KerCon_DoesNotAllowInterruptions;                             // Does not allow interruptions
                }
                if (!allowReset)
                {
                    result += "\n\t - " + KerCon_WillFailIfInterrupted;                             // Will fail if interrupted beyond allowance
                }
                break;

            case DurationState.preRun:
                result  = KerCon_Duration_X;                                   // Duration: <<1>>
                result += "\n\t - " + Localizer.Format("#KerCon_TimeStartsIn", // Time starts in <<1>>
                                                       Lib.Color(DurationUtil.StringValue(Math.Max(0, startAfter - now)), Lib.Kolor.Yellow));
                if (allowedDowntime > 0)
                {
                    result += "\n\t - " + KerCon_AllowsInterruptionsUpTo;
                }

                break;

            case DurationState.running:
                result = Localizer.Format("#KerCon_Reamining_X", Lib.Color(remainingStr, Lib.Kolor.Green));                         // Remaining: <<1>>
                //if (allowedDowntime > 0)
                //	result += "\n\t - " + Localizer.Format("#KerCon_AllowsInterruptionsUpTo", // Allows interruptions up to <<1>>
                //		DurationUtil.StringValue(allowedDowntime));

                break;

            case DurationState.preReset:
                result = Localizer.Format("#KerCon_Reamining_X_stopIn_Y", Lib.Color(remainingStr, Lib.Kolor.Green),                         // Remaining: <<1>> (stop in: <<2>>)
                                          Lib.Color(DurationUtil.StringValue(Math.Max(0, failAfter - now)), allowReset ? Lib.Kolor.Yellow : Lib.Kolor.Red));

                break;

            case DurationState.done:
                result = "#autoLOC_135144";                         // Success!!
                break;

            case DurationState.failed:
                result = "#KerCon_TimeIsUp";                         // Time is up!
                break;
            }

            if (result.StartsWith("#"))
            {
                result = Localizer.Format(result);
            }

            titleTracker.Add(result);
            if (lastTitle != result && Root != null && (Root.ContractState == Contract.State.Active || Root.ContractState == Contract.State.Failed))
            {
                titleTracker.UpdateContractWindow(result);
                lastTitle = result;
            }
            return(result);
        }