Make identically named options selectable, fix crash after deleting options.

This commit is contained in:
Ottermandias 2022-09-08 16:39:55 +02:00
parent f15c20a999
commit e9b12da97e
3 changed files with 20 additions and 5 deletions

View file

@ -70,7 +70,7 @@ public class ModSettings
var config = Settings[ groupIdx ]; var config = Settings[ groupIdx ];
Settings[ groupIdx ] = group.Type switch Settings[ groupIdx ] = group.Type switch
{ {
SelectType.Single => config >= optionIdx ? Math.Max( 0, config - 1 ) : config, SelectType.Single => config >= optionIdx ? (config > 1 ? config - 1 : 0) : config,
SelectType.Multi => RemoveBit( config, optionIdx ), SelectType.Multi => RemoveBit( config, optionIdx ),
_ => config, _ => config,
}; };

View file

@ -26,12 +26,21 @@ public partial class ConfigWindow
.RegisterEntry( "Files in the UI category will no longer be deduplicated for the moment." ) .RegisterEntry( "Files in the UI category will no longer be deduplicated for the moment." )
.RegisterHighlight( "If you experience UI-related crashes, please re-import your UI mods.", 1 ) .RegisterHighlight( "If you experience UI-related crashes, please re-import your UI mods.", 1 )
.RegisterEntry( "This is a temporary fix against those not-yet fully understood crashes and may be reworked later.", 1 ) .RegisterEntry( "This is a temporary fix against those not-yet fully understood crashes and may be reworked later.", 1 )
.RegisterEntry( "On import, Penumbra will now show files with extensions '.ttmp', '.ttmp2' and '.pmp'. You can still select showing generic archive files." ) .RegisterEntry(
.RegisterEntry( "Penumbra Mod Pack ('.pmp') files are meant to be renames of any of the archive types that could already be imported that contain the necessary Penumbra meta files.", 1 ) "On import, Penumbra will now show files with extensions '.ttmp', '.ttmp2' and '.pmp'. You can still select showing generic archive files." )
.RegisterHighlight( "If you distribute any mod as an archive specifically for Penumbra, you should change its extension to '.pmp'. Supported base archive types are ZIP, 7-Zip and RAR." , 1 ) .RegisterEntry(
"Penumbra Mod Pack ('.pmp') files are meant to be renames of any of the archive types that could already be imported that contain the necessary Penumbra meta files.",
1 )
.RegisterHighlight(
"If you distribute any mod as an archive specifically for Penumbra, you should change its extension to '.pmp'. Supported base archive types are ZIP, 7-Zip and RAR.",
1 )
.RegisterEntry( "Penumbra will now save mod backups with the file extension '.pmp'. They still are regular ZIP files.", 1 ) .RegisterEntry( "Penumbra will now save mod backups with the file extension '.pmp'. They still are regular ZIP files.", 1 )
.RegisterEntry( "Existing backups in your current mod directory should be automatically renamed. If you manage multiple mod directories, you may need to migrate the other ones manually.", 1 ) .RegisterEntry(
"Existing backups in your current mod directory should be automatically renamed. If you manage multiple mod directories, you may need to migrate the other ones manually.",
1 )
.RegisterEntry( "Fixed assigned collections not working correctly on adventurer plates." ) .RegisterEntry( "Fixed assigned collections not working correctly on adventurer plates." )
.RegisterEntry( "Fixed a wrongly displayed folder line in some circumstances." ) .RegisterEntry( "Fixed a wrongly displayed folder line in some circumstances." )
.RegisterEntry( "Fixed crash after deleting mod options." )
.RegisterEntry( "Made identically named options selectable in mod configuration. Do not name your options identically." )
.RegisterEntry( "Added some additional functionality for Mare Synchronos." ); .RegisterEntry( "Added some additional functionality for Mare Synchronos." );
} }

View file

@ -168,10 +168,13 @@ public partial class ConfigWindow
{ {
for( var idx2 = 0; idx2 < group.Count; ++idx2 ) for( var idx2 = 0; idx2 < group.Count; ++idx2 )
{ {
id.Push( idx2 );
if( ImGui.Selectable( group[ idx2 ].Name, idx2 == selectedOption ) ) if( ImGui.Selectable( group[ idx2 ].Name, idx2 == selectedOption ) )
{ {
Penumbra.CollectionManager.Current.SetModSetting( _mod.Index, groupIdx, ( uint )idx2 ); Penumbra.CollectionManager.Current.SetModSetting( _mod.Index, groupIdx, ( uint )idx2 );
} }
id.Pop();
} }
} }
@ -201,6 +204,7 @@ public partial class ConfigWindow
Widget.BeginFramedGroup( group.Name, group.Description ); Widget.BeginFramedGroup( group.Name, group.Description );
for( var idx2 = 0; idx2 < group.Count; ++idx2 ) for( var idx2 = 0; idx2 < group.Count; ++idx2 )
{ {
id.Push( idx2 );
var flag = 1u << idx2; var flag = 1u << idx2;
var setting = ( flags & flag ) != 0; var setting = ( flags & flag ) != 0;
if( ImGui.Checkbox( group[ idx2 ].Name, ref setting ) ) if( ImGui.Checkbox( group[ idx2 ].Name, ref setting ) )
@ -208,6 +212,8 @@ public partial class ConfigWindow
flags = setting ? flags | flag : flags & ~flag; flags = setting ? flags | flag : flags & ~flag;
Penumbra.CollectionManager.Current.SetModSetting( _mod.Index, groupIdx, flags ); Penumbra.CollectionManager.Current.SetModSetting( _mod.Index, groupIdx, flags );
} }
id.Pop();
} }
Widget.EndFramedGroup(); Widget.EndFramedGroup();