private void stringParamParse(string s, string type) { paramTypeContainer p; string[] a = s.Split(','); try { if (pTypeList.ContainsKey(type)) { p = pTypeList[type]; } else { DMC_MBE.LogFormatted("Parameter Type Not Found; Removing Type From List"); return; } } catch (Exception e) { DMC_MBE.LogFormatted("Parameter Type List Not Responding: {0}", e); return; } p.RewardFund = stringFloatParse(a[0], true); p.PenaltyFund = stringFloatParse(a[1], true); p.RewardRep = stringFloatParse(a[2], true); p.PenaltyRep = stringFloatParse(a[3], true); p.RewardScience = stringFloatParse(a[4], true); }
private void stringContractParse(string s, string type) { contractTypeContainer c; string[] a = s.Split(','); try { if (cTypeList.ContainsKey(type)) { c = cTypeList[type]; } else { DMC_MBE.LogFormatted("Contract Type Not Found; Removing Type From List"); return; } } catch (Exception e) { DMC_MBE.LogFormatted("Contract Type List Not Responding: {0}", e); return; } c.RewardFund = stringFloatParse(a[0], true); c.AdvanceFund = stringFloatParse(a[1], true); c.PenaltyFund = stringFloatParse(a[2], true); c.RewardRep = stringFloatParse(a[3], true); c.PenaltyRep = stringFloatParse(a[4], true); c.RewardScience = stringFloatParse(a[5], true); c.DurationTime = stringFloatParse(a[6], true); c.MaxOffer = stringFloatParse(a[7], false); c.MaxActive = stringFloatParse(a[8], false); }
/// <summary> /// Copies a skin so you can make a new custom skin from an already defined one /// </summary> /// <param name="SkinID">The string ID of the custom skin</param> /// <returns>The new copy of the skin</returns> internal static GUISkin CopySkin(String SkinID) { if (List.ContainsKey(SkinID)) { return((GUISkin)DMC_MBE.Instantiate(List[SkinID])); } else { DMC_MBE.LogFormatted("Unable to copy GUISkin to {0}, GUISkin not found", SkinID); throw new SystemException(String.Format("Unable to copy GUISkin to {0}, GUISkin not found", SkinID)); } }
private void Start() { //if (stockIcon == null) // stockIcon = contractLoader.Images.LoadAsset<Texture>("toolbar_icon"); Assembly assembly = AssemblyLoader.loadedAssemblies.GetByAssembly(Assembly.GetExecutingAssembly()).assembly; var ainfoV = Attribute.GetCustomAttribute(assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute; switch (ainfoV == null) { case true: infoVersion = ""; break; default: infoVersion = ainfoV.InformationalVersion; break; } try { _cWin = gameObject.AddComponent <contractWindow>(); } catch (Exception e) { DMC_MBE.LogFormatted("Contracts Windows Cannot Be Started: {0}", e); } bool stockToolbar = true; if (contractLoader.Settings != null) { stockToolbar = contractLoader.Settings.useStockToolbar; } if (stockToolbar || !ToolbarManager.ToolbarAvailable || contractLoader.Settings.replaceStockApp) { appLauncherButton = gameObject.AddComponent <contractStockToolbar>(); if (blizzyToolbarButton != null) { Destroy(blizzyToolbarButton); blizzyToolbarButton = null; } } else if (ToolbarManager.ToolbarAvailable && !stockToolbar) { blizzyToolbarButton = gameObject.AddComponent <contractToolbar>(); if (appLauncherButton != null) { Destroy(appLauncherButton); appLauncherButton = null; } } contractParser.onParameterAdded.Add(onParameterAdded); }
internal contractMission getMissionList(string name, bool warn = false) { if (missionList.Contains(name)) { return(missionList[name]); } else if (warn) { DMC_MBE.LogFormatted("No Mission Of Name [{0}] Found In Primary Mission List", name); } return(null); }
internal bool addMissionList(contractMission mission) { if (!missionList.Contains(mission.MissionTitle)) { missionList.Add(mission.MissionTitle, mission); return(true); } else { DMC_MBE.LogFormatted("Missions List Already Contains Mission Of Name: [{0}]; Please Rename", name); } return(false); }
private static bool DMAsteroidAvailable() { if (_DMAst != null) { return(true); } if (DMAstRun) { return(false); } DMAstRun = true; try { Type DMAstType = AssemblyLoader.loadedAssemblies.SelectMany(a => a.assembly.GetExportedTypes()) .SingleOrDefault(t => t.FullName == DMAsteroidTypeName); if (DMAstType == null) { DMC_MBE.LogFormatted_DebugOnly("DMagic Asteroid Type Not Found"); return(false); } _DMAstType = DMAstType; MethodInfo DMastMethod = DMAstType.GetMethod("PartName"); if (DMastMethod == null) { DMC_MBE.LogFormatted_DebugOnly("DMagic Asteroid String Method Not Found"); return(false); } else { _DMAst = (DMAstSci)Delegate.CreateDelegate(typeof(DMAstSci), DMastMethod); DMC_MBE.LogFormatted("DMagic Asteroid Reflection Method Assigned"); } return(_DMAst != null); } catch (Exception e) { DMC_MBE.LogFormatted("Exception While Loading DMagic Asteroid Accessor: {0}", e); } return(false); }
private ConfigNode AsConfigNode() { try { ConfigNode node = new ConfigNode(GetType().Name); node = ConfigNode.CreateConfigFromObject(this, node); return(node); } catch (Exception e) { DMC_MBE.LogFormatted("Failed to generate settings file node...\n{0}", e); return(new ConfigNode(GetType().Name)); } }
internal bool addMissionList(string name) { if (!missionList.Contains(name)) { contractMission mission = new contractMission(name); missionList.Add(name, mission); return(true); } else { DMC_MBE.LogFormatted("Missions List Already Contains Mission Of Name: [{0}]; Please Rename", name); } return(false); }
public bool Save() { try { ConfigNode node = AsConfigNode(); ConfigNode wrapper = new ConfigNode(GetType().Name); wrapper.AddNode(node); wrapper.Save(fullPath); return(true); } catch (Exception e) { DMC_MBE.LogFormatted("Error while saving settings file at [{0}]\n{1}", fullPath, e); return(false); } }
public contractSettings() { fullPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), fileName).Replace("\\", "/"); if (Load()) { DMC_MBE.LogFormatted("Settings File Loaded"); } else { if (Save()) { DMC_MBE.LogFormatted("New Contracts Window + Settings file saved to:\n{0}", fullPath); } } }
internal void removeMissionList(string name, bool delete = true) { if (missionList.Contains(name)) { if (delete) { contractMission c = missionList[name]; c = null; } missionList.Remove(name); } else { DMC_MBE.LogFormatted("No Mission List Of Name: [{0}] Found", name); } }
internal paramTypeContainer(Type PType) { paramType = PType; try { param = (ContractParameter)Activator.CreateInstance(PType); } catch (Exception e) { DMC_MBE.LogFormatted("This Parameter Type: {0} Does Not Have An Empty Constructor And Will Be Skipped: {1]", PType.Name, e); return; } name = PType.Name; name = Regex.Replace(name, "([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z]))", "$1 "); rewardFund = penaltyFund = rewardRep = penaltyRep = rewardScience = 1f; }
internal contractTypeContainer(Type CType) { contractType = CType; try { contractC = (Contract)Activator.CreateInstance(CType); } catch (Exception e) { DMC_MBE.LogFormatted("This Contract Type: {0} Does Not Have An Empty Constructor And Will Be Skipped: {1]", CType.Name, e); } name = CType.Name; name = Regex.Replace(name, "([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z]))", "$1 "); rewardFund = penaltyFund = advanceFund = rewardRep = penaltyRep = rewardScience = durationTime = expirationTime = 1f; maxOffer = maxActive = 10f; }
private static bool MCEAvailable() { if (_MCE != null) { return(true); } if (MCERun) { return(false); } MCERun = true; try { Type MCEType = AssemblyLoader.loadedAssemblies.SelectMany(a => a.assembly.GetExportedTypes()) .SingleOrDefault(t => t.FullName == MCETypeName); if (MCEType == null) { DMC_MBE.LogFormatted_DebugOnly("Mision Controller Type Not Found"); return(false); } _MCEType = MCEType; MethodInfo MCEMethod = MCEType.GetMethod("iPartName", new Type[] { typeof(ContractParameter) }); if (MCEMethod == null) { DMC_MBE.LogFormatted_DebugOnly("Mission Controller String Method Not Found"); return(false); } _MCE = (MCESci)Delegate.CreateDelegate(typeof(MCESci), MCEMethod); DMC_MBE.LogFormatted("Mission Control Reflection Method Assigned"); return(_MCE != null); } catch (Exception e) { DMC_MBE.LogFormatted("Exception While Loading Mission Controller Accessor: {0}", e); } return(false); }
private static bool FPAssemblyLoaded() { if (_FP != null) { return(true); } if (FPRun) { return(false); } FPRun = true; try { Type FPType = AssemblyLoader.loadedAssemblies.SelectMany(a => a.assembly.GetExportedTypes()) .SingleOrDefault(t => t.FullName == FPContractTypeName); if (FPType == null) { DMC_MBE.LogFormatted_DebugOnly("Fine Print Type Not Found"); return(false); } _FPType = FPType; MethodInfo FPMethod = FPType.GetMethod("PartName", new Type[] { typeof(ContractParameter) }); if (FPMethod == null) { DMC_MBE.LogFormatted_DebugOnly("Fine Print String Method Not Found"); return(false); } _FP = (FPSci)Delegate.CreateDelegate(typeof(FPSci), FPMethod); DMC_MBE.LogFormatted("Fine Print Reflection Method Assigned"); return(_FP != null); } catch (Exception e) { DMC_MBE.LogFormatted("Exception While Loading Fine Print Accessor: {0}", e); } return(false); }
public override void OnSave(ConfigNode node) { try { if (contractLoader.Settings != null) { contractLoader.Settings.Save(); } saveWindow(windowRects[currentScene(HighLogic.LoadedScene)]); ConfigNode scenes = new ConfigNode("Contracts_Window_Parameters"); //Scene settings scenes.AddValue("WindowPosition", stringConcat(windowPos, windowPos.Length)); scenes.AddValue("WindowVisible", stringConcat(windowVisible, windowVisible.Length)); for (int i = missionList.Count - 1; i >= 0; i--) { contractMission m = missionList.At(i); if (m == null) { continue; } ConfigNode missionNode = new ConfigNode("Contracts_Window_Mission"); missionNode.AddValue("MissionName", m.InternalName); missionNode.AddValue("ActiveListID", m.stringConcat(m.ActiveMissionList)); missionNode.AddValue("HiddenListID", m.stringConcat(m.HiddenMissionList)); missionNode.AddValue("VesselIDs", m.vesselConcat(currentMission)); missionNode.AddValue("AscendingSort", m.AscendingOrder); missionNode.AddValue("ShowActiveList", m.ShowActiveMissions); missionNode.AddValue("SortMode", (int)m.OrderMode); scenes.AddNode(missionNode); } node.AddNode(scenes); } catch (Exception e) { DMC_MBE.LogFormatted("Contracts Window Settings Cannot Be Saved: {0}", e); } }
private void LoadPrefabs() { prefabs = AssetBundle.LoadFromFile(path + prefabAssetName); if (prefabs != null) { loadedPrefabs = prefabs.LoadAllAssets <GameObject>(); } if (loadedPrefabs == null) { return; } if (!tmpProcessed) { processTMPPrefabs(); } if (!tooltipsProcessed && _tooltipPrefab != null) { processTooltips(); } if (!prefabsProcessed) { processUIPrefabs(); } if (tmpProcessed && tooltipsProcessed && prefabsProcessed) { DMC_MBE.LogFormatted("UI prefab bundle loaded and processed"); } else { DMC_MBE.LogFormatted("Error in processing UI prefab bundle\nSome UI elements may be affected or non-functional"); } prefabsLoaded = true; }
/// <summary> /// Sets the current skin to one of the custom skins /// </summary> /// <param name="SkinID">The string ID of the custom skin</param> internal static void SetCurrent(String SkinID) { DMC_MBE.LogFormatted_DebugOnly("Setting GUISkin to {0}", SkinID); GUISkin OldSkin = _CurrentSkin; //check the skin exists, and throw a log line if it doesnt if (List.ContainsKey(SkinID)) { _CurrentSkin = List[SkinID]; } else { DMC_MBE.LogFormatted("Unable to change GUISkin to {0}, GUISkin not found", SkinID); } //Now set the tooltip style as well SetCurrentTooltip(); if (OldSkin != CurrentSkin && OnSkinChanged != null) { OnSkinChanged(); } }
public bool Load() { try { if (File.Exists(fullPath)) { ConfigNode node = ConfigNode.Load(fullPath); ConfigNode unwrapped = node.GetNode(GetType().Name); ConfigNode.LoadObjectFromConfig(this, unwrapped); return(true); } else { DMC_MBE.LogFormatted("Settings file could not be found [{0}]", fullPath); return(false); } } catch (Exception e) { DMC_MBE.LogFormatted("Error while loading settings file from [{0}]\n{1}", fullPath, e); return(false); } }
/// <summary> /// Add a style to a skin, if the styleID already exists it will update the style /// </summary> /// <param name="SkinToAction">The GUISkin we are going to adjust. The name of the Style is its ID</param> /// <param name="NewStyle">The GUIStyle to add or update</param> internal static void AddStyle(ref GUISkin SkinToAction, GUIStyle NewStyle) { if (NewStyle.name == null || NewStyle.name == "") { DMC_MBE.LogFormatted("No Name Provided in the Style to add to {0}. Cannot add this.", SkinToAction.name); return; } //Convert to a list List <GUIStyle> lstTemp = SkinToAction.customStyles.ToList <GUIStyle>(); //Add or edit the customstyle if (lstTemp.Any(x => x.name == NewStyle.name)) { //if itexists then remove it first GUIStyle styleTemp = lstTemp.First(x => x.name == NewStyle.name); lstTemp.Remove(styleTemp); } //add the new style lstTemp.Add(NewStyle); //Write the list back to the array SkinToAction.customStyles = lstTemp.ToArray <GUIStyle>(); }
//Convert all of our saved strings into the appropriate arrays for each game scene public override void OnLoad(ConfigNode node) { try { if (version == contractAssembly.Version) { ConfigNode scenes = node.GetNode("Contracts_Window_Parameters"); if (scenes != null) { //Contract lists showString = scenes.GetValue("DefaultListID"); hiddenString = scenes.GetValue("HiddenListID"); //Global Settings - Why do these not use KSPFields? Because your mom, that's why... toolTips = stringBoolParse(scenes.GetValue("ToolTips")); fontSmall = stringBoolParse(scenes.GetValue("FontSize")); windowSize = stringintParse(scenes.GetValue("WindowSize")); //Scene settings showHideMode = stringSplit(scenes.GetValue("ShowListMode")); windowMode = stringSplit(scenes.GetValue("WindowMode")); orderMode = stringSplit(scenes.GetValue("SortOrder")); int[] sort = stringSplit(scenes.GetValue("SortMode")); sortMode = new sortClass[4] { (sortClass)sort[0], (sortClass)sort[1], (sortClass)sort[2], (sortClass)sort[3] }; windowPos = stringSplit(scenes.GetValue("WindowPosition")); windowVisible = stringSplitBool(scenes.GetValue("WindowVisible")); int[] winPos = new int[4] { windowPos[4 * currentScene(HighLogic.LoadedScene)], windowPos[(4 * currentScene(HighLogic.LoadedScene)) + 1], windowPos[(4 * currentScene(HighLogic.LoadedScene)) + 2], windowPos[(4 * currentScene(HighLogic.LoadedScene)) + 3] }; loadWindow(winPos); } } version = contractAssembly.Version; } catch (Exception e) { DMC_MBE.LogFormatted("Contracts Window Settings Cannot Be Loaded: {0}", e); } //Start the window object try { cWin = gameObject.AddComponent <contractsWindow>(); cConfig = gameObject.AddComponent <contractConfig>(); } catch (Exception e) { DMC_MBE.LogFormatted("Contracts Windows Cannot Be Started: {0}", e); } try { //Load the contract and parameter types if (cTypeList == null) { cTypeList = new Dictionary <string, contractTypeContainer>(); foreach (AssemblyLoader.LoadedAssembly assembly in AssemblyLoader.loadedAssemblies) { Type[] assemblyTypes = assembly.assembly.GetTypes(); foreach (Type t in assemblyTypes) { if (t.IsSubclassOf(typeof(Contract))) { if (t != typeof(Contract)) { if (!cTypeList.ContainsKey(t.Name)) { cTypeList.Add(t.Name, new contractTypeContainer(t)); } if (cTypeList[t.Name].ContractC == null) { cTypeList.Remove(t.Name); } } } } } } ConfigNode contractTypes = node.GetNode("Contracts_Window_Contract_Types"); if (contractTypes != null) { foreach (ConfigNode contractType in contractTypes.GetNodes("Contract_Type")) { if (contractType != null) { string contractTypeName = contractType.GetValue("TypeName"); string valuesString = contractType.GetValue("ContractValues"); stringContractParse(valuesString, contractTypeName); } } } } catch (Exception e) { DMC_MBE.LogFormatted("Contract Type List Cannot Be Generated Or Loaded: {0}", e); } try { if (pTypeList == null) { pTypeList = new Dictionary <string, paramTypeContainer>(); foreach (AssemblyLoader.LoadedAssembly assembly in AssemblyLoader.loadedAssemblies) { Type[] assemblyTypes = assembly.assembly.GetTypes(); foreach (Type t in assemblyTypes) { if (t.IsSubclassOf(typeof(ContractParameter))) { if (t.Name == "OR" || t.Name == "XOR" || t.Name == "RecoverPart") { continue; } if (t != typeof(ContractParameter)) { if (!pTypeList.ContainsKey(t.Name)) { pTypeList.Add(t.Name, new paramTypeContainer(t)); } if (pTypeList[t.Name].Param == null) { pTypeList.Remove(t.Name); } } } } } } ConfigNode paramTypes = node.GetNode("Contracts_Window_Parameter_Types"); if (paramTypes != null) { foreach (ConfigNode paramType in paramTypes.GetNodes("Parameter_Type")) { if (paramType != null) { string paramTypeName = paramType.GetValue("TypeName"); string valuesString = paramType.GetValue("ParameterValues"); stringParamParse(valuesString, paramTypeName); } } } } catch (Exception e) { DMC_MBE.LogFormatted("Parameter Type List Cannot Be Generated Or Loaded: {0}", e); } }
private void contractOffered(Contract c) { Type contractT = c.GetType(); contractTypeContainer cC; if (cTypeList.ContainsKey(contractT.Name)) { cC = cTypeList[contractT.Name]; } else { DMC_MBE.LogFormatted("Contract Type: {0} Not Present; Allowing All Offers", contractT.Name); return; } if (cC.MaxActive < 10f || cC.MaxOffer < 10f) { var cList = ContractSystem.Instance.Contracts; int active = 0; int offered = 0; for (int i = 0; i < cList.Count; i++) { if (cList[i].GetType() == contractT) { if (cList[i].ContractState == Contract.State.Active) { active++; } else if (cList[i].ContractState == Contract.State.Offered) { offered++; } } } int remainingSlots = (int)(cC.MaxActive * 10) - active; if ((offered - 1) >= (int)(cC.MaxOffer * 10) && cC.MaxOffer < 10f) { c.Unregister(); ContractSystem.Instance.Contracts.Remove(c); DMC_MBE.LogFormatted("Removing Contract Of Type: {0} From The Offered List; Offered Limit Exceeded", contractT.Name); } else if ((offered - 1) >= remainingSlots && cC.MaxActive < 10f) { c.Unregister(); ContractSystem.Instance.Contracts.Remove(c); DMC_MBE.LogFormatted("Removing Contract Of Type: {0} From The Offered List; Active Limit Exceeded", contractT.Name); } else { updateContractValues(cC, c, new float[9] { 1, 1, 1, 1, 1, 1, 1, 1, 1 }); updateParameterValues(c); DMC_MBE.LogFormatted_DebugOnly("Contract: {0} Added To Offered List", contractT.Name); } } else { updateContractValues(cC, c, new float[9] { 1, 1, 1, 1, 1, 1, 1, 1, 1 }); updateParameterValues(c); DMC_MBE.LogFormatted_DebugOnly("Contract: {0} Added To Offered List", contractT.Name); } }
public override void OnSave(ConfigNode node) { try { saveWindow(windowRects[currentScene(HighLogic.LoadedScene)]); ConfigNode scenes = new ConfigNode("Contracts_Window_Parameters"); //Contract lists scenes.AddValue("DefaultListID", stringConcat(showList)); scenes.AddValue("HiddenListID", stringConcat(hiddenList)); //Scene settings scenes.AddValue("ShowListMode", stringConcat(showHideMode, showHideMode.Length)); scenes.AddValue("WindowMode", stringConcat(windowMode, windowMode.Length)); scenes.AddValue("SortOrder", stringConcat(orderMode, orderMode.Length)); int[] sort = new int[4] { (int)sortMode[0], (int)sortMode[1], (int)sortMode[2], (int)sortMode[3] }; scenes.AddValue("SortMode", stringConcat(sort, sort.Length)); scenes.AddValue("WindowPosition", stringConcat(windowPos, windowPos.Length)); scenes.AddValue("WindowVisible", stringConcat(windowVisible, windowVisible.Length)); //Global settings scenes.AddValue("ToolTips", toolTips); scenes.AddValue("FontSize", fontSmall); scenes.AddValue("WindowSize", windowSize); node.AddNode(scenes); } catch (Exception e) { DMC_MBE.LogFormatted("Contracts Window Settings Cannot Be Saved: {0}", e); } //Save values for each contract type try { ConfigNode contractTypes = new ConfigNode("Contracts_Window_Contract_Types"); foreach (contractTypeContainer c in cTypeList.Values) { ConfigNode contractType = new ConfigNode("Contract_Type"); contractType.AddValue("TypeName", c.ContractC.GetType().Name); contractType.AddValue("ContractValues", stringConcat(c)); contractTypes.AddNode(contractType); } node.AddNode(contractTypes); } catch (Exception e) { DMC_MBE.LogFormatted("Contract Types Cannot Be Saved: {0}", e); } //Save values for each parameter type try { ConfigNode paramTypes = new ConfigNode("Contracts_Window_Parameter_Types"); foreach (paramTypeContainer p in pTypeList.Values) { ConfigNode paramType = new ConfigNode("Parameter_Type"); paramType.AddValue("TypeName", p.Param.GetType().Name); paramType.AddValue("ParameterValues", stringConcat(p)); paramTypes.AddNode(paramType); } node.AddNode(paramTypes); } catch (Exception e) { DMC_MBE.LogFormatted("Parameter Type List Cannot Be Saved: {0}", e); } }
//Convert all of our saved strings into the appropriate arrays for each game scene public override void OnLoad(ConfigNode node) { instance = this; try { //The first step is manually checking for active contracts from the Game ConfigNode (ie persistent.sfs file); the count of active contracts will be used later when the window is loading ConfigNode gameNode = HighLogic.CurrentGame.config; if (gameNode != null) { ConfigNode contractSystemNode = gameNode.GetNodes("SCENARIO").FirstOrDefault(c => c.GetValue("name") == "ContractSystem"); if (contractSystemNode != null) { ConfigNode cNode = contractSystemNode.GetNode("CONTRACTS"); if (cNode != null) { foreach (ConfigNode C in cNode.GetNodes("CONTRACT")) { if (C == null) { continue; } if (C.HasValue("autoAccept")) { if (C.GetValue("autoAccept") == "True") { continue; } } if (C.HasValue("state")) { if (C.GetValue("state") == "Active") { contractCount++; } } } } else { DMC_MBE.LogFormatted("Contract System Can't Be Checked... Node Invalid"); } } } ConfigNode scenes = node.GetNode("Contracts_Window_Parameters"); if (scenes != null) { windowPos = stringSplit(scenes.GetValue("WindowPosition")); windowVisible = stringSplitBool(scenes.GetValue("WindowVisible")); int[] winPos = new int[4] { windowPos[4 * currentScene(HighLogic.LoadedScene)], windowPos[(4 * currentScene(HighLogic.LoadedScene)) + 1], windowPos[(4 * currentScene(HighLogic.LoadedScene)) + 2], windowPos[(4 * currentScene(HighLogic.LoadedScene)) + 3] }; //All saved contract missions are loaded here //Each mission has a separate contract list foreach (ConfigNode m in scenes.GetNodes("Contracts_Window_Mission")) { if (m == null) { continue; } string name; string activeString = ""; string hiddenString = ""; string vesselString = ""; bool ascending, showActive; int sortMode; bool master = false; if (m.HasValue("MissionName")) { name = m.GetValue("MissionName"); } else { continue; } if (name == "MasterMission") { master = true; } if (m.HasValue("ActiveListID")) { activeString = m.GetValue("ActiveListID"); } if (m.HasValue("HiddenListID")) { hiddenString = m.GetValue("HiddenListID"); } if (m.HasValue("VesselIDs")) { vesselString = m.GetValue("VesselIDs"); } if (!bool.TryParse(m.GetValue("AscendingSort"), out ascending)) { ascending = true; } if (!bool.TryParse(m.GetValue("ShowActiveList"), out showActive)) { showActive = true; } if (!int.TryParse(m.GetValue("SortMode"), out sortMode)) { sortMode = 0; } contractMission mission = new contractMission(name, activeString, hiddenString, vesselString, ascending, showActive, sortMode, master); if (master) { masterMission = mission; DMC_MBE.LogFormatted_DebugOnly("Setting Master Mission During Load"); } if (!missionList.Contains(name)) { missionList.Add(name, mission); } } loadWindow(winPos); } } catch (Exception e) { DMC_MBE.LogFormatted("Contracts Window Settings Cannot Be Loaded: {0}", e); } }