From 87b96a55d7b34ec8847e2b56e26e9305b53c92f1 Mon Sep 17 00:00:00 2001 From: Bayu Satiyo Date: Thu, 19 Sep 2024 07:08:47 +0700 Subject: [PATCH] Lib: Switch to NativeFileDialogs.Net & Drop .NET 6 support NativeFileDialogs.Net is incompatible with .NET 6. Signed-off-by: Bayu Satiyo --- .github/workflows/build.yml | 4 ++-- README.md | 2 +- USSR.cs | 48 ++++++++++++++++++++++++------------- USSR.csproj | 4 ++-- build.sh | 2 +- 5 files changed, 38 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 791016d..04fc26f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,8 +15,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - dotnet-version: [ '6.0.x', '8.0.x' ] - dotnet-framework: [ 'net6.0', 'net8.0' ] + dotnet-version: [ '8.0.x' ] + dotnet-framework: [ 'net8.0' ] dotnet-runtime: [ 'win-x64', 'win-arm64', 'linux-x64', 'linux-arm64', 'osx-x64', 'osx-arm64' ] steps: diff --git a/README.md b/README.md index 9573523..2f0fe06 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ The tool is an implementation of the guide available at /// Selected file path. - 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() + { + { + "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; } /// diff --git a/USSR.csproj b/USSR.csproj index b0f86d1..9630411 100644 --- a/USSR.csproj +++ b/USSR.csproj @@ -3,7 +3,7 @@ Exe win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64 - net6.0;net8.0 + net8.0 enable enable @@ -12,7 +12,7 @@ - + diff --git a/build.sh b/build.sh index f213e7f..95b7f79 100644 --- a/build.sh +++ b/build.sh @@ -5,7 +5,7 @@ VERSION=$(