mirror of
https://github.com/AssetRipper/AssetRipper.git
synced 2025-12-11 20:15:29 +01:00
parent
8429911c25
commit
f3be12008a
@ -28,7 +28,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AssetRipper.Text.Html" Version="1.0.0" />
|
||||
<PackageReference Include="NativeFileDialogs.Net" Version="1.1.0" />
|
||||
<PackageReference Include="NativeFileDialogs.Net" Version="1.2.1" />
|
||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@ -61,6 +61,42 @@ internal static class Dialogs
|
||||
}
|
||||
}
|
||||
|
||||
public static class OpenFolders
|
||||
{
|
||||
public static async Task HandleGetRequest(HttpContext context)
|
||||
{
|
||||
context.Response.DisableCaching();
|
||||
string[]? paths = await Task.Run(static () =>
|
||||
{
|
||||
if (Supported)
|
||||
{
|
||||
GetUserInput(out string[]? paths);
|
||||
return paths;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
});
|
||||
await Results.Json(paths ?? [], AppJsonSerializerContext.Default.StringArray).ExecuteAsync(context);
|
||||
}
|
||||
|
||||
public static NfdStatus GetUserInput(out string[]? paths, string? defaultPath = null)
|
||||
{
|
||||
ThrowIfNotSupported();
|
||||
lock (lockObject)
|
||||
{
|
||||
return Nfd.PickFolderMultiple(out paths, defaultPath);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryGetUserInput([NotNullWhen(true)] out string[]? paths, string? defaultPath = null)
|
||||
{
|
||||
NfdStatus status = GetUserInput(out paths, defaultPath);
|
||||
return status == NfdStatus.Ok && paths is not null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class OpenFile
|
||||
{
|
||||
public static async Task HandleGetRequest(HttpContext context)
|
||||
|
||||
@ -42,23 +42,23 @@ public static class Commands
|
||||
{
|
||||
IFormCollection form = await request.ReadFormAsync();
|
||||
|
||||
string? path;
|
||||
string[]? paths;
|
||||
if (form.TryGetValue("Path", out StringValues values))
|
||||
{
|
||||
path = values;
|
||||
paths = values;
|
||||
}
|
||||
else if (Dialogs.Supported)
|
||||
{
|
||||
Dialogs.OpenFolder.GetUserInput(out path);
|
||||
Dialogs.OpenFolders.GetUserInput(out paths);
|
||||
}
|
||||
else
|
||||
{
|
||||
return CommandsPath;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
if (paths is { Length: > 0 })
|
||||
{
|
||||
GameFileLoader.LoadAndProcess([path]);
|
||||
GameFileLoader.LoadAndProcess(paths);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -194,6 +194,7 @@ public static class WebApplicationLauncher
|
||||
//Dialogs
|
||||
app.MapGet("/Dialogs/SaveFile", Dialogs.SaveFile.HandleGetRequest);
|
||||
app.MapGet("/Dialogs/OpenFolder", Dialogs.OpenFolder.HandleGetRequest);
|
||||
app.MapGet("/Dialogs/OpenFolders", Dialogs.OpenFolders.HandleGetRequest);
|
||||
app.MapGet("/Dialogs/OpenFile", Dialogs.OpenFile.HandleGetRequest);
|
||||
app.MapGet("/Dialogs/OpenFiles", Dialogs.OpenFiles.HandleGetRequest);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user