diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1f424ec..ded5e21 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,16 +24,16 @@ jobs: run: dotnet restore SingerUtils -r win-x64 - name: build x86 - run: dotnet publish SingerUtils -c Release -r win-x86 --self-contained true -o bin/win-x86 + run: dotnet publish SingerUtils -c Release -r win-x86 --self-contained true -o bin/win-x86 /p:version=${{ steps.versioning.outputs.tag }} - name: build x64 - run: dotnet publish SingerUtils -c Release -r win-x64 --self-contained true -o bin/win-x64 + run: dotnet publish SingerUtils -c Release -r win-x64 --self-contained true -o bin/win-x64 /p:version=${{ steps.versioning.outputs.tag }} - name: compress x86 - run: 7z a SingerUtils-x86-${{ steps.versioning.outputs.tag }}.zip bin/win-x86/ + run: 7z a SingerUtils-x86-${{ steps.versioning.outputs.tag }}.zip ./bin/win-x86/* - name: compress x64 - run: 7z a SingerUtils-x64-${{ steps.versioning.outputs.tag }}.zip bin/win-x64/ + run: 7z a SingerUtils-x64-${{ steps.versioning.outputs.tag }}.zip ./bin/win-x64/* - name: Upload artifact x64 uses: actions/upload-artifact@v1.0.0 diff --git a/SingerUtils.Core/Util/PathManager.cs b/SingerUtils.Core/Util/PathManager.cs index a15cf84..0951dd3 100644 --- a/SingerUtils.Core/Util/PathManager.cs +++ b/SingerUtils.Core/Util/PathManager.cs @@ -17,6 +17,7 @@ public PathManager() RootPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); if (OS.IsMacOS()) { + //TODO string userHome = Environment.GetFolderPath(Environment.SpecialFolder.Personal); DataPath = Path.Combine(userHome, "Library", "OpenUtau"); CachePath = Path.Combine(userHome, "Library", "Caches", "OpenUtau"); @@ -34,6 +35,7 @@ public PathManager() } else if (OS.IsLinux()) { + //TODO string userHome = Environment.GetFolderPath(Environment.SpecialFolder.Personal); string dataHome = Environment.GetEnvironmentVariable("XDG_DATA_HOME"); if (string.IsNullOrEmpty(dataHome)) @@ -51,7 +53,22 @@ public PathManager() } else { - DataPath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); + var args = Environment.GetCommandLineArgs(); + if (args.Count() > 1 && File.Exists(Path.Join(args[1],"../../prefs.json"))) //(File.Exists("../../prefs.json")) + { + //If Launched as OpenUTAU Plugin, DataPath is where OpenUTAU is located + DataPath = Path.GetFullPath(Path.Join(args[1], "../..")); + } + else if(File.Exists(Path.Join(Process.GetCurrentProcess().MainModule.FileName,"../../prefs.json"))) + { + //If installed as OpenUTAU Plugin but not launched in OpenUTAU, DataPath is where OpenUTAU is located + DataPath = Path.GetFullPath(Path.Join(Process.GetCurrentProcess().MainModule.FileName, "../..")); + } + else + { + //If not installed as OpenUTAU Plugin, DataPath is where SingerUtils is located + DataPath = Path.GetFullPath("."); + } CachePath = Path.Combine(DataPath, "Cache"); HomePathIsAscii = true; var etor = StringInfo.GetTextElementEnumerator(DataPath); diff --git a/SingerUtils.Core/Util/Preferences.cs b/SingerUtils.Core/Util/Preferences.cs index 5884fd7..f5c83d8 100644 --- a/SingerUtils.Core/Util/Preferences.cs +++ b/SingerUtils.Core/Util/Preferences.cs @@ -19,7 +19,7 @@ static Preferences() Load(); } - public static void Save() + /*public static void Save() { try { @@ -31,12 +31,11 @@ public static void Save() { Log.Error(e, "Failed to save prefs."); } - } + }*/ public static void Reset() { Default = new SerializablePreferences(); - Save(); } private static void Load() diff --git a/SingerUtils/ViewModels/MainWindowViewModel.cs b/SingerUtils/ViewModels/MainWindowViewModel.cs index 65c8aab..484ff69 100644 --- a/SingerUtils/ViewModels/MainWindowViewModel.cs +++ b/SingerUtils/ViewModels/MainWindowViewModel.cs @@ -41,7 +41,7 @@ public MainWindowViewModel() } var args = Environment.GetCommandLineArgs(); - if (args.Count() >= 1 && File.Exists(args[1])) + if (args.Count() > 1 && File.Exists(args[1])) { if (File.Exists(args[1])) { diff --git a/SingerUtils/plugin.txt b/SingerUtils/plugin.txt index ed81389..c8dfcb9 100644 --- a/SingerUtils/plugin.txt +++ b/SingerUtils/plugin.txt @@ -1,3 +1,3 @@ -name=OpenUTAU Singer ToolKit +name=SingerUtils execute=SingerUtils.exe encoding=utf-8 \ No newline at end of file