public MoreEventsMod(ModContentPack content) : base(content) { Settings.RootDir = content.RootDir; ModulesHandler.TryInjectModules(); Settings = GetSettings <Settings>(); //harmonyInstance = HarmonyInstance.Create("net.funkyshit.moreeventsmod"); --> OLD harmonyInstance = new Harmony("net.funkyshit.moreeventsmod"); //--> NEW harmonyInstance.PatchAll(Assembly.GetExecutingAssembly()); //if(!Settings.EventsSettings.ContainsKey("General")) // Settings.CheckSettings(); int useNewMapSizes = int.Parse(GeneralSettings.Parameters["UseNewMapSizes"].Value); if (useNewMapSizes == 1) { Type type = typeof(Dialog_AdvancedGameConfig); FieldInfo field = type.GetField("MapSizes", BindingFlags.NonPublic | BindingFlags.Static); int[] newSizes = new int[] { 25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325 }; field.SetValue(null, newSizes); } }
public void CheckSettings() { if (fileSettings == null) { try { fileSettings = XmlUtility.Deserialize <List <EventSettings> >(SettingsPath); }catch (Exception ex) { Log.Error("Error while deserialize settings file " + ex); } } bool CanHoldSetting(EventSettings fSetting) { return(!(!string.IsNullOrEmpty(fSetting.RequiredModule) && ModulesHandler.GetModule(fSetting.RequiredModule) == null)); } if (fileSettings != null) { if (EventsSettings == null) { EventsSettings = new Dictionary <string, EventSettings>(); } foreach (var fSetting in fileSettings) { bool canHoldSetting = CanHoldSetting(fSetting); if (!EventsSettings.TryGetValue(fSetting.Key, out EventSettings value)) { if (!canHoldSetting) { continue; } Log.Message($"New settings {fSetting.Key} found, added"); fSetting.FinalizeSettings(); EventsSettings.Add(fSetting.Key, fSetting); } else { if (!canHoldSetting) { EventsSettings.Remove(fSetting.Key); Log.Message($"Settings {fSetting.Key} will be deleted (the required module is missing)"); } else if (fSetting.Params != null && value.Parameters.Count != fSetting.Params.Length) { value.Params = fSetting.Params; value.FinalizeSettings(); } } } length = EventsSettings.Count * 60; foreach (var setting in EventsSettings) { foreach (var param in setting.Value.Parameters) { length += 30; } } } }