Lots of collection progress.

This commit is contained in:
Ottermandias 2023-04-11 11:28:56 +02:00
parent d908f22a17
commit 3f33bab296
22 changed files with 666 additions and 636 deletions

View file

@ -57,7 +57,8 @@ public class ItemSwapTab : IDisposable, ITab
};
_communicator.CollectionChange.Subscribe(OnCollectionChange);
_collectionManager.Active.Current.ModSettingChanged += OnSettingChange;
_communicator.ModSettingChanged.Subscribe(OnSettingChange);
_communicator.CollectionInheritanceChanged.Subscribe(OnInheritanceChange);
_communicator.ModOptionChanged.Subscribe(OnModOptionChange);
}
@ -102,7 +103,8 @@ public class ItemSwapTab : IDisposable, ITab
public void Dispose()
{
_communicator.CollectionChange.Unsubscribe(OnCollectionChange);
_collectionManager.Active.Current.ModSettingChanged -= OnSettingChange;
_communicator.ModSettingChanged.Unsubscribe(OnSettingChange);
_communicator.CollectionInheritanceChanged.Unsubscribe(OnInheritanceChange);
_communicator.ModOptionChanged.Unsubscribe(OnModOptionChange);
}
@ -744,21 +746,29 @@ public class ItemSwapTab : IDisposable, ITab
if (collectionType != CollectionType.Current || _mod == null || newCollection == null)
return;
UpdateMod(_mod, _mod.Index < newCollection.Settings.Count ? newCollection.Settings[_mod.Index] : null);
newCollection.ModSettingChanged += OnSettingChange;
if (oldCollection != null)
oldCollection.ModSettingChanged -= OnSettingChange;
UpdateMod(_mod, _mod.Index < newCollection.Settings.Count ? newCollection[_mod.Index].Settings : null);
}
private void OnSettingChange(ModSettingChange type, int modIdx, int oldValue, int groupIdx, bool inherited)
private void OnSettingChange(ModCollection collection, ModSettingChange type, Mod? mod, int oldValue, int groupIdx, bool inherited)
{
if (modIdx != _mod?.Index)
if (collection != _collectionManager.Active.Current || mod != _mod)
return;
_swapData.LoadMod(_mod, _modSettings);
_dirty = true;
}
private void OnInheritanceChange(ModCollection collection, bool _)
{
if (collection != _collectionManager.Active.Current || _mod == null)
return;
UpdateMod(_mod, collection[_mod.Index].Settings);
_swapData.LoadMod(_mod, _modSettings);
_dirty = true;
}
private void OnModOptionChange(ModOptionChangeType type, Mod mod, int a, int b, int c)
{
if (type is ModOptionChangeType.PrepareChange || mod != _mod)