搜索类型 ID
This commit is contained in:
parent
bedc003966
commit
289f6551c1
4
App.xaml
4
App.xaml
@ -6,6 +6,10 @@
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
<c:ValueConverterAggregate x:Key="FalseToVisibilityConverter">
|
||||
<c:BooleanInvertConverter />
|
||||
<BooleanToVisibilityConverter />
|
||||
</c:ValueConverterAggregate>
|
||||
<c:ValueConverterAggregate x:Key="ValidInputEntryToVisibilityConverter">
|
||||
<c:ValidInputEntryTypeToBooleanConverter />
|
||||
<BooleanToVisibilityConverter />
|
||||
|
@ -13,9 +13,11 @@ namespace HashCalculator.GUI
|
||||
public string Name { get; }
|
||||
public string NameString { get; }
|
||||
public IReadOnlyList<string> 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<string>();
|
||||
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)
|
||||
|
@ -179,9 +179,20 @@
|
||||
Content="只显示 GameObject"
|
||||
IsChecked="{Binding GameObjectOnly}"
|
||||
Command="{Binding FilterDisplayEntries}"
|
||||
Width="155"
|
||||
Padding="4,0"
|
||||
Margin="8,0"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
<CheckBox
|
||||
DockPanel.Dock="Right"
|
||||
Content="搜索类型 ID"
|
||||
IsChecked="{Binding ConsiderTypeId}"
|
||||
Command="{Binding FilterDisplayEntries}"
|
||||
Padding="4,0"
|
||||
Margin="8,0"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="{Binding GameObjectOnly, Converter={StaticResource FalseToVisibilityConverter}}"
|
||||
/>
|
||||
<TextBlock
|
||||
Text="{Binding DisplayEntries.Count, StringFormat=列表里显示了{0}个素材}"
|
||||
Margin="5,0,0,0"
|
||||
@ -238,6 +249,14 @@
|
||||
Path=DataContext.IsXml,
|
||||
Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
/>
|
||||
<DataGridTextColumn
|
||||
Header="类型 ID"
|
||||
Binding="{Binding TypeIdString}"
|
||||
FontFamily="Courier New"
|
||||
Visibility="{Binding Source={x:Reference Name=ReferenceProvider},
|
||||
Path=DataContext.ConsiderTypeId,
|
||||
Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</DockPanel>
|
||||
|
18
ViewModel.cs
18
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user