private bool ValidateOrbitType(OrbitData obData, OrbitGeneratorFactory factory)
 {
     if (obData.orbitType == OrbitType.KOLNIYA && !CelestialUtilities.CanBodyBeKolniya(obData.targetBody))
     {
         string error = StringBuilderCache.Format("Cannot use a Kolniya orbit with {0}.", obData.targetBody.CleanDisplayName());
         if (factory != null)
         {
             LoggingUtil.LogError(factory, "{0} : {1}", factory.ErrorPrefix(), error);
             return(false);
         }
         else
         {
             throw new ArgumentException(error);
         }
     }
     else if (obData.orbitType == OrbitType.TUNDRA && !CelestialUtilities.CanBodyBeTundra(obData.targetBody))
     {
         string error = StringBuilderCache.Format("Cannot use a tundra orbit with {0}.", obData.targetBody.CleanDisplayName());
         if (factory != null)
         {
             LoggingUtil.LogError(factory, "{0} : {1}", factory.ErrorPrefix(), error);
             return(false);
         }
         else
         {
             throw new ArgumentException(error);
         }
     }
     return(true);
 }
            public void OnSave(ConfigNode configNode)
            {
                configNode.AddValue("condition", condition);
                configNode.AddValue("position", position);
                configNode.AddValue("width", width);
                configNode.AddValue("height", height);
                if (!string.IsNullOrEmpty(title))
                {
                    configNode.AddValue("title", title);
                }
                if (!string.IsNullOrEmpty(parameter))
                {
                    configNode.AddValue("parameter", parameter);
                }

                int a = (int)(titleColor.a * 255);
                int r = (int)(titleColor.r * 255);
                int g = (int)(titleColor.g * 255);
                int b = (int)(titleColor.b * 255);

                configNode.AddValue("titleColor", StringBuilderCache.Format("#{0}{1}{2}{3}", a.ToString("X2"), r.ToString("X2"), g.ToString("X2"), b.ToString("X2")));

                foreach (Section section in sections)
                {
                    ConfigNode sectionNode = new ConfigNode(section.GetType().Name);
                    configNode.AddNode(sectionNode);
                    section.OnSave(sectionNode);
                }
            }
Exemple #3
0
        public override ExperienceTrait ConvertFrom <U>(U value)
        {
            LoggingUtil.LogDebug(this, StringBuilderCache.Format("ExperienceTraitParser.ConvertFrom<{0}>({1}", typeof(U), value));
            if (typeof(U) == typeof(string))
            {
                string sVal = (string)(object)value;

                if (HighLogic.CurrentGame == null)
                {
                    currentDataNode.SetDeterministic(currentKey, false);
                    return(null);
                }

                for (int index = 0; index < GameDatabase.Instance.ExperienceConfigs.Categories.Count; ++index)
                {
                    if (sVal == GameDatabase.Instance.ExperienceConfigs.Categories[index].Name)
                    {
                        Type type = KerbalRoster.GetExperienceTraitType(sVal) ?? typeof(ExperienceTrait);
                        return(ExperienceTrait.Create(type, GameDatabase.Instance.ExperienceConfigs.Categories[index], null));
                    }
                }

                throw new ArgumentException("'" + sVal + "' is not a valid experience trait.");
            }
            throw new DataStoreCastException(typeof(U), typeof(ExperienceTrait));
        }
Exemple #4
0
        private static void WindowGUI(int windowID)
        {
            GUI.skin = HighLogic.Skin;

            string label = "An unexpected exception occurred!  Please copy the error message below, and either post it on the Contract Configurator thread on the KSP forums, or raise an issue on our GitHub tracker.";

            if (actionString != null)
            {
                label += "\n\n" + actionString;
            }
            string message = displayedException != null?displayedException.ToString() : "";

            GUILayout.BeginVertical();

            GUILayout.Label(label);
            scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Height(280));
            GUILayout.TextArea(StringBuilderCache.Format("Exception occured {0}:\n{1}", situationString, message), GUILayout.ExpandHeight(true));
            GUILayout.EndScrollView();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("OK"))
            {
                displayedException = null;
            }
            if (GUILayout.Button("Ignore Exception"))
            {
                loggedExceptions[displayedException.StackTrace] = true;
                displayedException = null;
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();

            GUI.DragWindow();
        }
        protected override string GetParameterTitle()
        {
            string output = null;

            if (string.IsNullOrEmpty(title))
            {
                if (vesselIdentifier != null)
                {
                    output = Localizer.Format("#cc.param.KerbalDeaths.vessel", countMax - 1, ContractVesselTracker.GetDisplayName(vesselIdentifier.identifier));
                }
                else if (!kerbals.Any())
                {
                    output = Localizer.Format("#cc.param.KerbalDeaths.generic", countMax - 1);
                }
                else
                {
                    output = Localizer.Format("#cc.param.KerbalDeaths.specific");
                    if (state != ParameterState.Incomplete || ParameterCount == 1)
                    {
                        if (ParameterCount == 1)
                        {
                            output       = StringBuilderCache.Format("{0}: {1}", output, ParameterDelegate <ProtoCrewMember> .GetDelegateText(this));
                            hideChildren = true;
                        }
                    }
                }
            }
            else
            {
                output = title;
            }

            return(output);
        }
Exemple #6
0
        public static void Log(LogLevel logLevel, Type type, string message, params object[] parameters)
        {
            LogLevel logLevelCheckAgainst = LoggingUtil.logLevel;

            if (logLevel <= LogLevel.DEBUG && specificLogLevels.ContainsKey(type.Name))
            {
                logLevelCheckAgainst = (LogLevel)Math.Min((int)logLevelCheckAgainst, (int)specificLogLevels[type.Name]);
            }

            if (logLevel >= logLevelCheckAgainst)
            {
                if (captureLog)
                {
                    _capturedLog.Append(StringBuilderCache.Format("[{0}] {1}: {2}\n", logLevel, type, (parameters.Length > 0 ? StringBuilderCache.Format(message, parameters) : message)));
                }
                message = StringBuilderCache.Format(logLevel <= LogLevel.INFO ? "[{0}] {1}: {2}" : "{1}: {2}", logLevel, type, (parameters.Length > 0 ? StringBuilderCache.Format(message, parameters) : message));

                if (logLevel <= LogLevel.INFO)
                {
                    UnityEngine.Debug.Log(message);
                }
                else if (logLevel == LogLevel.WARNING)
                {
                    UnityEngine.Debug.LogWarning(message);
                }
                else if (logLevel == LogLevel.ERROR)
                {
                    UnityEngine.Debug.LogError(message);
                }
            }
        }
        public static IEnumerable <Type> GetAllTypes <T>()
        {
            // Get everything that extends the given type
            List <Type> allTypes = new List <Type>();

            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                IEnumerable <Type> types = null;
                try
                {
                    types = from type in assembly.GetTypes() where (type.IsSubclassOf(typeof(T)) || type.GetInterface(typeof(T).Name) != null) select type;
                }
                catch (Exception e)
                {
                    // Only log once
                    if (!badAssemblies.Contains(assembly))
                    {
                        LoggingUtil.LogException(new Exception(StringBuilderCache.Format("Error loading types from assembly {0}", assembly.FullName), e));
                        badAssemblies.Add(assembly);
                    }
                    continue;
                }

                foreach (Type t in types)
                {
                    Type foundType = t;

                    if (foundType != null)
                    {
                        yield return(foundType);
                    }
                }
            }
        }
Exemple #8
0
        protected override string GetParameterTitle()
        {
            Vessel currentVessel = CurrentVessel();

            string title = null;

            if (currentVessel != null && endTimes.ContainsKey(currentVessel.id) && endTimes[currentVessel.id] > 0.01 ||
                currentVessel == null && endTime > 0.01)
            {
                double time = currentVessel != null ? endTimes[currentVessel.id] : endTime;
                if (time - Planetarium.GetUniversalTime() > 0.0)
                {
                    // Time to completion:
                    title = StringBuilderCache.Format("{0} {1}", (waitingText ?? Localizer.GetStringByTag("#cc.param.Duration.waiting")), DurationUtil.StringValue(time - Planetarium.GetUniversalTime()));
                }
                else
                {
                    // Wait time over
                    title = completionText ?? Localizer.GetStringByTag("#cc.param.Duration.completion");
                }
            }
            else
            {
                // Waiting time required:
                title = StringBuilderCache.Format("{0} {1}", (preWaitText ?? Localizer.GetStringByTag("#cc.param.Duration.preWait")), DurationUtil.StringValue(duration));
            }

            return(title);
        }
Exemple #9
0
 protected override string RequirementText()
 {
     return(Localizer.Format(invertRequirement ? "#cc.req.PartModuleTypeUnlocked.x" : "#cc.req.PartModuleTypeUnlocked",
                             LocalizationUtil.LocalizeList <string>(invertRequirement ? LocalizationUtil.Conjunction.AND : LocalizationUtil.Conjunction.OR, partModuleTypes,
                                                                    x => StringBuilderCache.Format("<color=#{0}>{1}</color>", MissionControlUI.RequirementHighlightColor, Parameters.PartValidation.ModuleTypeName(x))),
                             partModuleTypes.Count));
 }
Exemple #10
0
        private DataNode NodeForKey(ref string key)
        {
            if (!key.Contains(':'))
            {
                return(this);
            }

            string[] names = key.Split(':');
            if (names.Count() > 2)
            {
                throw new ArgumentException(StringBuilderCache.Format("Key value '{0}' is invalid, can only have one namespace preceeded by a colon (:).", key));
            }

            string group = names[0];

            for (DataNode node = (root != null ? root : this).parent; node != null; node = node.parent)
            {
                if (node.name == group)
                {
                    key = names[1];
                    return(node);
                }
            }

            throw new ArgumentException(StringBuilderCache.Format("Contract group '{0}' does not exist, or is not a parent of this contract.", group));
        }
Exemple #11
0
        public override ExperienceTrait ParseIdentifier(Token token)
        {
            // Try to parse more, as ExperienceTrait names can have spaces
            Match  m          = Regex.Match(expression, @"^((?>\s*[\w\d]+)+).*");
            string identifier = m.Groups[1].Value;

            expression = (expression.Length > identifier.Length ? expression.Substring(identifier.Length) : "");
            identifier = token.sval + identifier;

            if (identifier.Equals("null", StringComparison.CurrentCultureIgnoreCase))
            {
                return(null);
            }

            if (HighLogic.CurrentGame == null)
            {
                currentDataNode.SetDeterministic(currentKey, false);
                return(null);
            }

            for (int index = 0; index < GameDatabase.Instance.ExperienceConfigs.Categories.Count; ++index)
            {
                if (identifier == GameDatabase.Instance.ExperienceConfigs.Categories[index].Name)
                {
                    Type type = KerbalRoster.GetExperienceTraitType(identifier) ?? typeof(ExperienceTrait);
                    return(ExperienceTrait.Create(type, GameDatabase.Instance.ExperienceConfigs.Categories[index], null));
                }
            }

            LoggingUtil.LogError(this, StringBuilderCache.Format("Unknown experience trait '{0}'.", identifier));
            return(null);
        }
 public static string Print(this ScienceRecoveryMethod recoveryMethod)
 {
     if (recoveryMethod != ScienceRecoveryMethod.Ideal)
     {
         return(Localizer.GetStringByTag(StringBuilderCache.Format("#cc.param.CollectScience.rm.{0}", recoveryMethod.ToString())));
     }
     return(recoveryMethod.ToString());
 }
Exemple #13
0
        /// <summary>
        /// Some Structured logging to the debug file
        /// </summary>
        /// <param name="Message">Text to be printed - can be formatted as per StringBuilderCache.Format</param>
        /// <param name="strParams">Objects to feed into a StringBuilderCache.Format</param>
        internal static void LogFormatted(String Message, params Object[] strParams)
        {
            Message = StringBuilderCache.Format(Message, strParams);
            String strMessageLine = StringBuilderCache.Format("{0},{2}-{3},{1}",
                                                              DateTime.Now, Message, Assembly.GetExecutingAssembly().GetName().Name,
                                                              MethodBase.GetCurrentMethod().DeclaringType.Name);

            Debug.Log(strMessageLine);
        }
Exemple #14
0
 private static void CaptureException(Exception e)
 {
     if (e.InnerException != null)
     {
         CaptureException(e.InnerException);
         _capturedLog.Append("Rethrow as ");
     }
     _capturedLog.Append(StringBuilderCache.Format("{0}: {1}\n{2}\n", e.GetType(), e.Message, e.StackTrace));
 }
        protected override string RequirementText()
        {
            string body = targetBody == null?Localizer.GetStringByTag("#cc.req.ProgressCelestialBody.genericBody") : targetBody.displayName;

            string lat = StringBuilderCache.Format("<color=#{0}>{1}</color>", MissionControlUI.RequirementHighlightColor, latitude.ToString("N1"));
            string lon = StringBuilderCache.Format("<color=#{0}>{1}</color>", MissionControlUI.RequirementHighlightColor, longitude.ToString("N1"));

            return(Localizer.Format(invertRequirement ? "#cc.scansat.req.SCANsatLocationCoverage.x" : "#cc.scansat.req.SCANsatLocationCoverage",
                                    SCANsatCoverage.ScanDisplayName(scanType), lat, lon, body));
        }
 protected override string GetParameterTitle()
 {
     if (state != ParameterState.Incomplete)
     {
         return(StringBuilderCache.Format("{0}: {1}", base.GetParameterTitle(), ParameterDelegate <T> .GetDelegateText(this)));
     }
     else
     {
         return(base.GetParameterTitle());
     }
 }
            public override void OnSave(ConfigNode configNode)
            {
                configNode.AddValue("text", text.Replace("\n", "&br;"));
                int a = (int)(textColor.a * 255);
                int r = (int)(textColor.r * 255);
                int g = (int)(textColor.g * 255);
                int b = (int)(textColor.b * 255);

                configNode.AddValue("textColor", StringBuilderCache.Format("#{0}{1}{2}{3}", a.ToString("X2"), r.ToString("X2"), g.ToString("X2"), b.ToString("X2")));
                configNode.AddValue("fontSize", fontSize);
            }
 private string ErrorPrefix(string name, string type)
 {
     if (contractType != null)
     {
         return(StringBuilderCache.Format("CONTRACT_TYPE '{0}', BEHAVIOUR '{1}' of type '{2}'", contractType.name, (name ?? "<blank>"), type));
     }
     else
     {
         return(StringBuilderCache.Format("BEHAVIOUR '{0}' of type '{1}'", (name ?? "<blank>"), type));
     }
 }
        /// <summary>
        /// Verify the loaded assembly meets a minimum version number.
        /// </summary>
        /// <param name="name">Assembly name</param>
        /// <param name="version">Minium version</param>
        /// <param name="silent">Silent mode</param>
        /// <returns>The assembly if the version check was successful.  If not, logs and error and returns null.</returns>
        public static Assembly VerifyAssemblyVersion(string name, string version, bool silent = false)
        {
            // Logic courtesy of DMagic
            var assemblies = AssemblyLoader.loadedAssemblies.Where(a => a.assembly.GetName().Name == name);
            var assembly   = assemblies.FirstOrDefault();

            if (assembly != null)
            {
                if (assemblies.Count() > 1)
                {
                    LoggingUtil.LogWarning(typeof(ContractConfigurator), StringBuilderCache.Format("Multiple assemblies with name '{0}' found!", name));
                }

                string receivedStr;

                // First try the informational version
                var ainfoV = Attribute.GetCustomAttribute(assembly.assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;
                if (ainfoV != null)
                {
                    receivedStr = ainfoV.InformationalVersion;
                }
                // If that fails, use the product version
                else
                {
                    receivedStr = FileVersionInfo.GetVersionInfo(assembly.assembly.Location).ProductVersion;
                }
                // If that still fails, fall back on AssemblyVersion
                if (string.IsNullOrEmpty(receivedStr) || receivedStr == " ")
                {
                    receivedStr = assembly.assembly.GetName().Version.ToString();
                }

                System.Version expected = ParseVersion(version);
                System.Version received = ParseVersion(receivedStr);

                if (received >= expected)
                {
                    LoggingUtil.LogVerbose(typeof(ContractConfigurator), "Version check for '{0}' passed.  Minimum required is {1}, version found was {2}", name, version, receivedStr);
                    return(assembly.assembly);
                }
                else
                {
                    LoggingUtil.Log(silent ? LoggingUtil.LogLevel.DEBUG : LoggingUtil.LogLevel.ERROR, typeof(Version), "Version check for '{0}' failed!  Minimum required is {1}, version found was {2}", name, version, receivedStr);
                    return(null);
                }
            }
            else
            {
                LoggingUtil.Log(silent ? LoggingUtil.LogLevel.VERBOSE : LoggingUtil.LogLevel.ERROR, typeof(Version), "Couldn't find assembly for '{0}'!", name);
                return(null);
            }
        }
Exemple #20
0
        public static void DisplayFatalException(ExceptionSituation situation, Exception e, params object[] args)
        {
            // Only log once
            if (loggedExceptions.ContainsKey(e.StackTrace))
            {
                return;
            }

            switch (situation)
            {
            case ExceptionSituation.PARAMETER_SAVE:
                situationString = StringBuilderCache.Format("while saving contract parameter '{1}' in contract '{0}'", args);
                actionString    = "The contract data was not correctly saved - reloading the save may result in further errors.  Best case - the contract in question is no longer valid.";
                break;

            case ExceptionSituation.PARAMETER_LOAD:
                situationString = StringBuilderCache.Format("while loading contract parameter '{1}' in contract '{0}'", args);
                actionString    = "The contract data was not correctly loaded.  Avoid saving your game and backup your save file immediately if you wish to prevent contract loss!";
                break;

            case ExceptionSituation.CONTRACT_GENERATION:
                situationString = StringBuilderCache.Format("while attempt to generate contract of type '{0}'", args);
                actionString    = "The contract failed to generate, and you may see additional exceptions";
                break;

            case ExceptionSituation.CONTRACT_SAVE:
                situationString = StringBuilderCache.Format("while saving contract '{0}'", args);
                actionString    = "The contract data was not correctly saved - reloading the save may result in further errors.  Best case - the contract in question is no longer valid.";
                break;

            case ExceptionSituation.CONTRACT_LOAD:
                situationString = StringBuilderCache.Format("while loading contract '{0}'", args);
                actionString    = "The contract data was not correctly loaded.  Avoid saving your game and backup your save file immediately if you wish to prevent contract loss!";
                break;

            case ExceptionSituation.SCENARIO_MODULE_SAVE:
                situationString = StringBuilderCache.Format("while saving ScenarioModule '{0}'", args);
                actionString    = "The ScenarioModule data was not correctly saved - reloading the save may result in further errors.";
                break;

            case ExceptionSituation.SCENARIO_MODULE_LOAD:
                situationString = StringBuilderCache.Format("while loading ScenarioModule '{0}'", args);
                actionString    = "The ScenarioModule data was not correctly loaded.  Avoid saving your game and backup your save file immediately if you wish to prevent save game data loss!";
                break;

            default:
                situationString = "while performing an unspecified operation";
                actionString    = null;
                break;
            }
            displayedException = e;
        }
Exemple #21
0
        protected override string RequirementText()
        {
            string title = StringBuilderCache.Format("<color=#{0}>{1}</color>", MissionControlUI.RequirementHighlightColor, ContractTitle());

            if (cooldownDuration.Value > 0.0)
            {
                return(Localizer.Format(invertRequirement ? "#cc.req.CompleteContract.cooldown.x" : "#cc.req.CompleteContract.cooldown", title, cooldownDuration.ToString()));
            }
            else
            {
                return(Localizer.Format(invertRequirement ? "#cc.req.CompleteContract.x" : "#cc.req.CompleteContract", title));
            }
        }
Exemple #22
0
        public override bool LoadFromConfig(ConfigNode configNode)
        {
            // Load base class
            bool valid = base.LoadFromConfig(configNode);

            tag  = StringBuilderCache.Format("#cc.req.{0}", type);
            tagx = StringBuilderCache.Format("#cc.req.{0}.x", type);

            valid &= ValidateTargetBody(configNode);
            valid &= ConfigNodeUtil.ParseValue <CheckType?>(configNode, "checkType", x => checkType = x, this, (CheckType?)null);

            return(valid);
        }
            public override void OnSave(ConfigNode configNode)
            {
                configNode.AddValue("showName", showName);
                if (!string.IsNullOrEmpty(characterName))
                {
                    configNode.AddValue("characterName", characterName);
                }
                int a = (int)(textColor.a * 255);
                int r = (int)(textColor.r * 255);
                int g = (int)(textColor.g * 255);
                int b = (int)(textColor.b * 255);

                configNode.AddValue("textColor", StringBuilderCache.Format("#{0}{1}{2}{3}", a.ToString("X2"), r.ToString("X2"), g.ToString("X2"), b.ToString("X2")));
            }
Exemple #24
0
        protected override string GetParameterTitle()
        {
            double end    = endTime == 0.0 ? Planetarium.GetUniversalTime() : endTime;
            string prefix = string.IsNullOrEmpty(title) ? Localizer.GetStringByTag("#cc.param.MissionTimer") : title;

            string output;

            if (startTime == 0.0)
            {
                output = StringBuilderCache.Format("{0} 00:00:00", prefix);
            }
            else
            {
                output = StringBuilderCache.Format("{0} {1}", prefix, DurationUtil.StringValue(end - startTime, true, (endTime != 0.0)));
            }

            return(output);
        }
Exemple #25
0
        protected static ExpressionParser <T> GetParser <T>(BaseParser orig)
        {
            ExpressionParser <T> newParser = GetParser <T>();

            if (newParser == null)
            {
                throw new NotSupportedException(StringBuilderCache.Format("Unsupported type: {0}", typeof(T)));
            }

            newParser.Init(orig.expression);
            newParser.parseMode       = orig.parseMode;
            newParser.currentDataNode = orig.currentDataNode;
            newParser.currentKey      = orig.currentKey;
            newParser.spacing         = orig.spacing;
            newParser.parentParser    = orig;

            return(newParser);
        }
        IEnumerator <YieldInstruction> FixStrategyText(KSCFacilityContextMenu menu)
        {
            int currentLevel = (int)Math.Round(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Administration) *
                                               ScenarioUpgradeableFacilities.GetFacilityLevelCount(SpaceCenterFacility.Administration)) + 1;

            string currentLevelText = StringBuilderCache.Format("* Max Active Strategies: {0}", currentLevel);
            string nextLevelText    = StringBuilderCache.Format("<color=#a8ff04>* Max Active Strategies: {0}</color>", currentLevel + 1);

            while (true)
            {
                if (!menu)
                {
                    yield break;
                }

                menu.levelStatsText.text = menu.levelStatsText.text.StartsWith("<color") ? nextLevelText : currentLevelText;

                yield return(null);
            }
        }
        public static void DumpDetails(this System.Object o, string text = null)
        {
            if (!string.IsNullOrEmpty(text))
            {
                Debug.Log(text);
            }
            else
            {
                Debug.Log("Dumping object:");
            }

            foreach (FieldInfo fi in o.GetType().GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | BindingFlags.FlattenHierarchy))
            {
                Debug.Log(StringBuilderCache.Format("    {0} = {1}", fi.Name, fi.GetValue(o)));
            }
            foreach (PropertyInfo pi in o.GetType().GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | BindingFlags.FlattenHierarchy))
            {
                Debug.Log(StringBuilderCache.Format("    {0} = {1}", pi.Name, pi.GetValue(o, null)));
            }
        }
        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);
        }
Exemple #29
0
        public void ResearchBodiesCheck(ConfiguredContract contract)
        {
            if (Util.Version.VerifyResearchBodiesVersion())
            {
                LoggingUtil.LogVerbose(this, "ResearchBodies check for contract type {0}", name);

                // Check each body that the contract references
                Dictionary <CelestialBody, RBWrapper.CelestialBodyInfo> bodyInfoDict = RBWrapper.RBactualAPI.CelestialBodies;
                foreach (CelestialBody body in contract.ContractBodies)
                {
                    if (bodyInfoDict.ContainsKey(body) && !body.isHomeWorld)
                    {
                        RBWrapper.CelestialBodyInfo bodyInfo = bodyInfoDict[body];
                        if (!bodyInfo.isResearched)
                        {
                            throw new ContractRequirementException(StringBuilderCache.Format("Research Bodies: {0} has not yet been researched.", body.name));
                        }
                    }
                }
            }
        }
Exemple #30
0
        protected override string GetParameterTitle()
        {
            string output = null;

            if (string.IsNullOrEmpty(title))
            {
                // "Complete any ONE of the following"
                if (state == ParameterState.Complete)
                {
                    output = StringBuilderCache.Format("{0}: {1}", Localizer.GetStringByTag("#cc.param.Any"),
                                                       LocalizationUtil.LocalizeList <ContractParameter>(LocalizationUtil.Conjunction.AND, this.GetChildren().Where(x => x.State == ParameterState.Complete), x => x.Title));
                }
                else
                {
                    output = Localizer.GetStringByTag("#cc.param.Any");
                }
            }
            else
            {
                output = title;
            }

            return(output);
        }