From 3df367550090a408aef57bad04a1c4ff8a87dcc7 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 15 Jan 2021 12:06:30 +0100 Subject: [PATCH] review: _selectedModIndex fix, redundant initialization removed. --- Penumbra/Mods/ModCollection.cs | 3 --- Penumbra/UI/SettingsInterface.cs | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Penumbra/Mods/ModCollection.cs b/Penumbra/Mods/ModCollection.cs index e0acad54..7a9a853c 100644 --- a/Penumbra/Mods/ModCollection.cs +++ b/Penumbra/Mods/ModCollection.cs @@ -156,9 +156,6 @@ namespace Penumbra.Mods var entry = new ModInfo { Priority = ModSettings.Count, - CurrentGroup = 0, - CurrentTop = 0, - CurrentBottom = 0, FolderName = mod.ModBasePath.Name, Enabled = true, Mod = mod diff --git a/Penumbra/UI/SettingsInterface.cs b/Penumbra/UI/SettingsInterface.cs index 0aec8150..7824e2b1 100644 --- a/Penumbra/UI/SettingsInterface.cs +++ b/Penumbra/UI/SettingsInterface.cs @@ -267,7 +267,9 @@ namespace Penumbra.UI if( ImGui.Button( "Rediscover Mods" ) ) { - ReloadMods(); + ReloadMods(); + _selectedModIndex = 0; + _selectedMod = null; } ImGui.SameLine(); @@ -554,7 +556,17 @@ namespace Penumbra.UI if( ImGui.Button( "Reload JSON" ) ) { ReloadMods(); - _selectedMod = _plugin.ModManager.Mods.ModSettings[ _selectedModIndex ]; + + // May select a different mod than before if mods were added or deleted, but will not crash. + if (_selectedModIndex < _plugin.ModManager.Mods.ModSettings.Count) + { + _selectedMod = _plugin.ModManager.Mods.ModSettings[_selectedModIndex]; + } + else + { + _selectedModIndex = 0; + _selectedMod = null; + } } }