Skip to content

Commit

Permalink
Lib: Switch to NativeFileDialogs.Net & Drop .NET 6 support due to inc…
Browse files Browse the repository at this point in the history
…ompatibility with it

Signed-off-by: Bayu Satiyo <itsyuukunz@gmail.com>
  • Loading branch information
kiraio-moe committed Sep 19, 2024
1 parent 3957192 commit 0587a3f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The tool is an implementation of the guide available at <https://github.com/kira

## Requirements

- [.NET 6.0 SDK](https://dotnet.microsoft.com/download/dotnet/6.0 ".NET 6.0 SDK") or [.NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0 ".NET 8.0 SDK")
- [.NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0 ".NET 8.0 SDK")
- Splash screen `Draw Mode` have been set to `All Sequential` in `Player Settings`.

## Usages
Expand Down
48 changes: 32 additions & 16 deletions USSR.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using AssetsTools.NET;
using AssetsTools.NET.Extra;
using Kiraio.UnityWebTools;
using NativeFileDialogSharp;
using NativeFileDialogs.Net;
using Spectre.Console;
using USSR.Enums;
using USSR.Utilities;
Expand Down Expand Up @@ -394,27 +394,43 @@ static WebCompressionTypes GetCompression()
/// Open file picker dialog.
/// </summary>
/// <returns>Selected file path.</returns>
static string OpenFilePicker()
static string? OpenFilePicker()
{
AnsiConsole.MarkupLine("Opening File Picker...");
try
{
AnsiConsole.MarkupLine("Opening File Picker...");

DialogResult filePicker = Dialog.FileOpen(
null,
Path.GetDirectoryName(Utility.GetLastOpenedFile())
);
NfdStatus filePicker = Nfd.OpenDialog(
out string? path,
new Dictionary<string, string>()
{
{
"Unity Files",
"globalgamemanagers,unity3d,data,data.br,data.gz,data.unityweb"
},
},
Path.GetDirectoryName(Utility.GetLastOpenedFile())
);

if (filePicker.IsCancelled)
AnsiConsole.MarkupLine("( INFO ) Cancelled.");
else if (filePicker.IsError)
switch (filePicker)
{
case NfdStatus.Cancelled:
AnsiConsole.MarkupLine("Cancelled.");
Console.Clear();
return string.Empty;
case NfdStatus.Ok:
return path ?? string.Empty;
default:
return string.Empty;
}
}
catch (NfdException ex)
{
AnsiConsole.MarkupLine(
"[red]( ERR! )[/] Unable to open File Picker! Try using a different Terminal?"
AnsiConsole.MarkupLineInterpolated(
$"[red]( ERR! )[/] Unable to open File Picker! Try using a different Terminal?\n{ex.Message}"
);
return string.Empty;
}

Console.WriteLine();

return filePicker.Path;
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions USSR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -12,7 +12,7 @@
<PackageReference Include="AssetsTools.NET" Version="3.0.0" />
<PackageReference Include="KaitaiStruct.Runtime.CSharp" Version="0.10.0" />
<PackageReference Include="Kiraio.UnityWebTools.NET" Version="1.0.0" />
<PackageReference Include="NativeFileDialogSharp" Version="0.6.0-alpha" />
<PackageReference Include="NativeFileDialogs.Net" Version="1.2.1" />
<PackageReference Include="Spectre.Console" Version="0.49.1" />
<PackageReference Include="Spectre.Console.Cli" Version="0.49.1" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ VERSION=$(<version.txt)
echo "Building USSR v${VERSION}..."
# Define the target operating systems and architectures
TARGET_OS_ARCHITECTURES=("win-x64" "win-arm64" "linux-x64" "linux-arm64" "osx-x64" "osx-arm64")
TARGET_FRAMEWORKS=("net6.0" "net8.0")
TARGET_FRAMEWORKS=("net8.0")

# Build the project for each target OS architecture
for os_arch in "${TARGET_OS_ARCHITECTURES[@]}"
Expand Down

0 comments on commit 0587a3f

Please sign in to comment.