static TechAdvancingStartupClass() // Initialize the mod { ConfigTabValueSavedAttribute.BuildDefaultValueCache(); ConfigButtonTexture = ContentFinder <Texture2D> .Get("TechAdvancingSettingsLogo", true); HarmonyDetours.Setup(); if (MP.enabled) { MP.RegisterAll(); } }
public override void ExposeData() { if (Current.ProgramState == ProgramState.Entry) { if (Scribe.mode == LoadSaveMode.LoadingVars) { ConfigTabValueSavedAttribute.BuildDefaultValueCache(); LogOutput.WriteLogMessage(Errorlevel.Debug, "Loading default vars"); var dict = new Dictionary <string, int>(); Scribe_Collections.Look(ref dict, "TA_Expose_Default_Numbers", LookMode.Value, LookMode.Value); //LogOutput.WriteLogMessage(Errorlevel.Debug, $"DefaultDict: {string.Join(";", ConfigTabValueSavedAttribute.attributeDefaultValues.Select(x => $"{x.Key}={x.Value}"))}"); if (dict != null) { //LogOutput.WriteLogMessage(Errorlevel.Debug, $"SavedDict: {string.Join(";", dict.Select(x => $"{x.Key}={x.Value}"))}"); foreach (var kv in dict) { if (ConfigTabValueSavedAttribute.attributeDefaultValues.ContainsKey(kv.Key)) // load existing keys { ConfigTabValueSavedAttribute.attributeDefaultValues[kv.Key] = kv.Value; } else { LogOutput.WriteLogMessage(Errorlevel.Debug, $"Wiped old value with key {kv.Key}"); } } } } else if (Scribe.mode == LoadSaveMode.Saving) { LogOutput.WriteLogMessage(Errorlevel.Debug, "Saving default vars"); var dict = ConfigTabValueSavedAttribute.attributeDefaultValues.ToDictionary(x => x.Key, x => x.Value); Scribe_Collections.Look(ref dict, "TA_Expose_Default_Numbers", LookMode.Value, LookMode.Value); settingsText = null; } } else { this.tempdict = ConfigTabValueSavedAttribute.attributeDefaultValues.ToDictionary(x => x.Key, x => x.Value); Scribe_Collections.Look(ref this.tempdict, "TA_Expose_Default_Numbers", LookMode.Value, LookMode.Value); // because rimworld thinks its a great idea to clear configs otherwise... } base.ExposeData(); }