mirror of
https://github.com/AssetRipper/AssetRipper.git
synced 2025-12-11 20:15:29 +01:00
Add a class filter for the assets (#1949)
* added a class filter for the assets * addressing PR commets * fix formatting * fix formatting * address comments * add Localization for "All"
This commit is contained in:
parent
4cccff3d5a
commit
a22b511abb
@ -1,4 +1,5 @@
|
||||
{
|
||||
"all": "الكل",
|
||||
"appreciation_message": "شكرًا لك على دعمك لـ AssetRipper!",
|
||||
"asset_ripper_free": "AssetRipper المجاني",
|
||||
"asset_ripper_premium": "AssetRipper بريميوم",
|
||||
@ -116,5 +117,6 @@
|
||||
"loading_step_locate_key_functions": "جارٍ مسح الملف الثنائي IL2Cpp للوظائف المكتبية",
|
||||
"export_primary_content": "تصدير المحتوى الأساسي",
|
||||
"export_unity_project": "تصدير مشروع Unity",
|
||||
"c_sharp_langage_version_config_2": "C# 2"
|
||||
"c_sharp_langage_version_config_2": "C# 2",
|
||||
"filter": "تصفية"
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
{
|
||||
"all": "All",
|
||||
"an_error_occured_during_decompilation": "An error occurred during decompilation.",
|
||||
"appreciation_message": "Thank you for supporting AssetRipper!",
|
||||
"assembly_name": "Assembly Name",
|
||||
@ -96,6 +97,7 @@
|
||||
"file_id": "File ID",
|
||||
"format": "Format",
|
||||
"frequency": "Frequency",
|
||||
"filter": "Filter",
|
||||
"game_object": "GameObject",
|
||||
"guid": "GUID",
|
||||
"height": "Height",
|
||||
|
||||
@ -14,15 +14,31 @@ internal static class CollectionAPI
|
||||
public const string Count = Base + "/Count";
|
||||
}
|
||||
|
||||
private const string Path = "Path";
|
||||
public const string Path = "Path";
|
||||
public const string Class = "Class";
|
||||
|
||||
public static string GetViewUrl(CollectionPath path, string? classFilter = null)
|
||||
{
|
||||
string url = $"{Urls.View}?{GetPathQuery(path)}";
|
||||
if (!string.IsNullOrEmpty(classFilter))
|
||||
{
|
||||
url += $"&{Class}={classFilter.ToUrl()}";
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
public static string GetViewUrl(CollectionPath path) => $"{Urls.View}?{GetPathQuery(path)}";
|
||||
public static Task GetView(HttpContext context)
|
||||
{
|
||||
context.Response.DisableCaching();
|
||||
if (TryGetCollectionFromQuery(context, out AssetCollection? collection, out CollectionPath path, out Task? failureTask))
|
||||
{
|
||||
return new ViewPage() { Collection = collection, Path = path }.WriteToResponse(context.Response);
|
||||
string? classFilter = context.Request.Query[Class];
|
||||
return new ViewPage()
|
||||
{
|
||||
Collection = collection,
|
||||
Path = path,
|
||||
ClassFilter = string.IsNullOrWhiteSpace(classFilter) ? null : classFilter
|
||||
}.WriteToResponse(context.Response);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -9,6 +9,7 @@ public sealed class ViewPage : DefaultPage
|
||||
public required AssetCollection Collection { get; init; }
|
||||
public required CollectionPath Path { get; init; }
|
||||
|
||||
public string? ClassFilter { get; init; }
|
||||
public override string GetTitle() => Collection.Name;
|
||||
|
||||
public override void WriteInnerContent(TextWriter writer)
|
||||
@ -27,6 +28,40 @@ public sealed class ViewPage : DefaultPage
|
||||
if (Collection.Count > 0)
|
||||
{
|
||||
new H2(writer).Close(Localization.Assets);
|
||||
using (new Form(writer).WithAction(CollectionAPI.Urls.View).WithMethod("get").End())
|
||||
{
|
||||
new Input(writer)
|
||||
.WithType("hidden")
|
||||
.WithName(CollectionAPI.Path)
|
||||
.WithValue(Path.ToJson().ToHtml())
|
||||
.Close();
|
||||
|
||||
new Label(writer).WithFor("classFilter").WithClass("me-2").Close(Localization.Class);
|
||||
|
||||
using (new Select(writer)
|
||||
.WithId("classFilter")
|
||||
.WithName(CollectionAPI.Class)
|
||||
.End())
|
||||
{
|
||||
new Option(writer)
|
||||
.WithValue(string.Empty)
|
||||
.MaybeWithSelected(string.IsNullOrEmpty(ClassFilter))
|
||||
.Close(Localization.All);
|
||||
|
||||
foreach (string cn in Collection
|
||||
.Select(a => a.ClassName)
|
||||
.Distinct()
|
||||
.Order())
|
||||
{
|
||||
new Option(writer)
|
||||
.WithValue(cn)
|
||||
.MaybeWithSelected(string.Equals(cn, ClassFilter, StringComparison.Ordinal))
|
||||
.Close(cn);
|
||||
}
|
||||
}
|
||||
|
||||
new Button(writer).WithType("submit").WithClass("btn").Close(Localization.Filter);
|
||||
}
|
||||
using (new Table(writer).WithClass("table").End())
|
||||
{
|
||||
using (new Thead(writer).End())
|
||||
@ -42,6 +77,12 @@ public sealed class ViewPage : DefaultPage
|
||||
{
|
||||
foreach (IUnityObjectBase asset in Collection)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ClassFilter) &&
|
||||
!string.Equals(asset.ClassName, ClassFilter, StringComparison.Ordinal))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
using (new Tr(writer).End())
|
||||
{
|
||||
new Td(writer).Close(asset.PathID.ToString());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user