diff --git a/App.xaml b/App.xaml index 0b82fe9..ce30a0b 100644 --- a/App.xaml +++ b/App.xaml @@ -6,6 +6,10 @@ StartupUri="MainWindow.xaml"> + + + + diff --git a/AssetEntry.cs b/AssetEntry.cs index aa140a7..091f075 100644 --- a/AssetEntry.cs +++ b/AssetEntry.cs @@ -13,9 +13,11 @@ namespace HashCalculator.GUI public string Name { get; } public string NameString { get; } public IReadOnlyList DisplayLabels { get; } - public uint InstanceId => SageHash.CalculateLowercaseHash(Name); + public uint InstanceId { get; } + public uint TypeId { get; } - public string InstanceIdString => $"{InstanceId:x8} ({InstanceId,10})"; + public string InstanceIdString { get; } + public string TypeIdString { get; } public string LocalizedNames { @@ -79,6 +81,10 @@ namespace HashCalculator.GUI var transformLabels = from name in element.Elements(ModXml.EalaAsset + "DisplayNameTransformed") select name.Value; DisplayLabels = labels.Concat(transformLabels).ToArray(); + InstanceId = SageHash.CalculateLowercaseHash(Name); + TypeId = SageHash.CalculateBinaryHash(Type); + InstanceIdString = $"{InstanceId:x8} ({InstanceId,10})"; + TypeIdString = $"{TypeId:x8} ({TypeId,10})"; } public AssetEntry(Asset asset) @@ -91,10 +97,14 @@ namespace HashCalculator.GUI Name = asset.InstanceName; NameString = $"{Type}:{Name}"; DisplayLabels = Array.Empty(); - if (InstanceId != asset.InstanceId || SageHash.CalculateBinaryHash(Type) != asset.TypeId) + InstanceId = SageHash.CalculateLowercaseHash(Name); + TypeId = SageHash.CalculateBinaryHash(Type); + if (InstanceId != asset.InstanceId || TypeId != asset.TypeId) { throw new InvalidDataException(); } + InstanceIdString = $"{InstanceId:x8} ({InstanceId,10})"; + TypeIdString = $"{TypeId:x8} ({TypeId,10})"; } public bool Equals(AssetEntry? entry) diff --git a/MainWindow.xaml b/MainWindow.xaml index d9cffb4..78e9d30 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -179,9 +179,20 @@ Content="只显示 GameObject" IsChecked="{Binding GameObjectOnly}" Command="{Binding FilterDisplayEntries}" - Width="155" + Padding="4,0" + Margin="8,0" VerticalAlignment="Center" /> + + diff --git a/ViewModel.cs b/ViewModel.cs index a0f2abe..9537a0c 100644 --- a/ViewModel.cs +++ b/ViewModel.cs @@ -67,6 +67,13 @@ namespace HashCalculator.GUI set => SetField(ref _gameObjectOnly, value); } + private bool _considerTypeId; + public bool ConsiderTypeId + { + get => _considerTypeId; + set => SetField(ref _considerTypeId, value); + } + public Command FilterDisplayEntries { get; } private int _totalCount; @@ -188,11 +195,11 @@ namespace HashCalculator.GUI foreach (var chunk in Filter!.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)) { - if (entry.NameString.IndexOf(chunk, StringComparison.OrdinalIgnoreCase) != -1) + if (entry.NameString.Contains(chunk, StringComparison.OrdinalIgnoreCase)) { return true; } - if (entry.InstanceIdString.IndexOf(chunk, StringComparison.OrdinalIgnoreCase) != -1) + if (entry.InstanceIdString.Contains(chunk, StringComparison.OrdinalIgnoreCase)) { return true; } @@ -203,6 +210,13 @@ namespace HashCalculator.GUI return true; } } + if (!GameObjectOnly && ConsiderTypeId) + { + if (entry.TypeIdString.Contains(chunk, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } } return false; }