Extend the item identification a bit to count unidentifiable items and handle icons, demihumans and monsters.

This commit is contained in:
Ottermandias 2022-06-01 18:04:11 +02:00
parent 1ad7787e4c
commit 06deddcd8a
7 changed files with 714 additions and 672 deletions

View file

@ -437,7 +437,11 @@ public partial class ModCollection
}
else if( !data.Item1.Contains( modPath.Mod ) )
{
_changedItems[ name ] = ( data.Item1.Append( modPath.Mod ), obj );
_changedItems[ name ] = ( data.Item1.Append( modPath.Mod ), obj is int x && data.Item2 is int y ? x + y : obj);
}
else if (obj is int x && data.Item2 is int y)
{
_changedItems[name] = (data.Item1, x + y);
}
}
}

View file

@ -96,7 +96,7 @@ public partial class ModFileSystemSelector
0 => !( leaf.FullName().Contains( _modFilter.Lower, IgnoreCase ) || mod.Name.Contains( _modFilter ) ),
1 => !mod.Name.Contains( _modFilter ),
2 => !mod.Author.Contains( _modFilter ),
3 => !mod.LowerChangedItemsString.Contains( _modFilter ),
3 => !mod.LowerChangedItemsString.Contains( _modFilter.Lower, IgnoreCase ),
_ => false, // Should never happen
};
}

View file

@ -24,7 +24,9 @@ public partial class ConfigWindow
{
// Functions in here for less pollution.
bool FilterChangedItem( KeyValuePair< string, (SingleArray< Mod >, object?) > item )
=> ( _changedItemFilter.IsEmpty || item.Key.Contains( _changedItemFilter.Lower, StringComparison.InvariantCultureIgnoreCase ) )
=> ( _changedItemFilter.IsEmpty
|| ChangedItemName( item.Key, item.Value.Item2 )
.Contains( _changedItemFilter.Lower, StringComparison.InvariantCultureIgnoreCase ) )
&& ( _changedItemModFilter.IsEmpty || item.Value.Item1.Any( m => m.Name.Contains( _changedItemModFilter ) ) );
void DrawChangedItemColumn( KeyValuePair< string, (SingleArray< Mod >, object?) > item )

View file

@ -28,10 +28,16 @@ public partial class ConfigWindow
private static unsafe void Text( ResourceHandle* resource )
=> Text( resource->FileName(), resource->FileNameLength );
// Apply Changed Item Counters to the Name if necessary.
private static string ChangedItemName( string name, object? data )
=> data is int counter ? $"{counter} Files Manipulating {name}s" : name;
// Draw a changed item, invoking the Api-Events for clicks and tooltips.
// Also draw the item Id in grey if requested
private void DrawChangedItem( string name, object? data, bool drawId )
{
name = ChangedItemName( name, data );
var ret = ImGui.Selectable( name ) ? MouseButton.Left : MouseButton.None;
ret = ImGui.IsItemClicked( ImGuiMouseButton.Right ) ? MouseButton.Right : ret;
ret = ImGui.IsItemClicked( ImGuiMouseButton.Middle ) ? MouseButton.Middle : ret;