static HarmonyLoader() { ULog.Message("Applying Harmony patches..."); var harmony = new Harmony("com.dninemfive.D9Framework"); // https://stackoverflow.com/questions/2639418/use-reflection-to-get-a-list-of-static-classes foreach (Type type in typeof(HarmonyLoader).Assembly.GetTypes().Where(t => t.IsClass && t.IsSealed && t.IsAbstract)) { ClassWithPatchesAttribute attr; if ((attr = type.TryGetAttribute <ClassWithPatchesAttribute>()) != null) { if (!D9FModSettings.Patches.ContainsKey(attr.SaveKey)) { D9FModSettings.Patches[attr.SaveKey] = new D9FModSettings.PatchInfo(attr.SaveKey, true, attr.LabelKey, attr.DescKey); } else { D9FModSettings.Patches[attr.SaveKey].apply = D9FModSettings.ShouldPatch(attr.SaveKey); } if (D9FModSettings.ShouldPatch(attr.SaveKey)) { PatchAll(harmony, type); ULog.DebugMessage("\t" + attr.PlainName + " enabled.", false); } } } if (D9FModSettings.ApplyCarryMassFramework) { CMFHarmonyPatch.DoPatch(harmony); ULog.DebugMessage("\tCarry Mass Framework enabled.", false); } if (D9FModSettings.PrintPatchedMethods) { Log.Message("The following methods were successfully patched:", false); foreach (MethodBase mb in harmony.GetPatchedMethods()) { Log.Message("\t" + mb.DeclaringType.Name + "." + mb.Name, false); } } }
public override void DoSettingsWindowContents(Rect inRect) { Listing_Standard listing = new Listing_Standard(); listing.Begin(inRect); listing.CheckboxLabeled("D9FSettingsDebug".Translate(), ref D9FModSettings.DEBUG, "D9FSettingsDebugTooltip".Translate()); if (D9FModSettings.DEBUG) { listing.CheckboxLabeled("D9FSettingsPPM".Translate(), ref D9FModSettings.printPatchedMethods, "D9FSettingsPPMTooltip".Translate()); listing.Label("D9FSettingsApplyAtOwnRisk".Translate()); listing.Label("D9FSettingsRestartToApply".Translate()); listing.Label("D9FSettingsDebugModeRequired".Translate()); List <D9FModSettings.PatchInfo> patches = D9FModSettings.SerializePatches(); foreach (D9FModSettings.PatchInfo pi in patches) { listing.CheckboxLabeled(pi.labelKey.Translate(), ref pi.apply, pi.descKey.Translate()); } D9FModSettings.DeserializePatches(patches); listing.CheckboxLabeled("D9FSettingsApplyCMF".Translate(), ref D9FModSettings.applyCMF, "D9FSettingsApplyCMFTooltip".Translate()); } listing.End(); base.DoSettingsWindowContents(inRect); }
public D9FrameworkMod(ModContentPack con) : base(con) { this.settings = GetSettings <D9FModSettings>(); }