// Automatically update all relevant collections when a mod is changed. // This means saving if options change in a way where the settings may change and the collection has settings for this mod. // And also updating effective file and meta manipulation lists if necessary. private void OnModOptionsChanged(ModOptionChangeType type, Mod mod, int groupIdx, int optionIdx, int movedToIdx) { // Handle changes that break revertability. if (type == ModOptionChangeType.PrepareChange) { foreach (var collection in this.Where(c => c.HasCache)) { if (collection[mod.Index].Settings is { Enabled: true })
// Give information for each type of change. // If requiresSaving, collections need to be re-saved after this change. // If requiresReloading, caches need to be manipulated after this change. // If wasPrepared, caches have already removed the mod beforehand, then need add it again when this event is fired. // Otherwise, caches need to reload the mod itself. public static void HandlingInfo(this ModOptionChangeType type, out bool requiresSaving, out bool requiresReloading, out bool wasPrepared) { (requiresSaving, requiresReloading, wasPrepared) = type switch { ModOptionChangeType.GroupRenamed => (true, false, false), ModOptionChangeType.GroupAdded => (true, false, false), ModOptionChangeType.GroupDeleted => (true, true, false), ModOptionChangeType.GroupMoved => (true, false, false), ModOptionChangeType.GroupTypeChanged => (true, true, true), ModOptionChangeType.PriorityChanged => (true, true, true), ModOptionChangeType.OptionAdded => (true, true, true), ModOptionChangeType.OptionDeleted => (true, true, false), ModOptionChangeType.OptionMoved => (true, false, false), ModOptionChangeType.OptionFilesChanged => (false, true, false), ModOptionChangeType.OptionFilesAdded => (false, true, true), ModOptionChangeType.OptionSwapsChanged => (false, true, false), ModOptionChangeType.OptionMetaChanged => (false, true, false), ModOptionChangeType.DisplayChange => (false, false, false), _ => (false, false, false), }; }