Skip to content

Commit

Permalink
detect if running as openutau plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
oxygen-dioxide committed Oct 28, 2022
1 parent 77087a1 commit f9d9e50
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand Down
19 changes: 18 additions & 1 deletion SingerUtils.Core/Util/PathManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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))
Expand All @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions SingerUtils.Core/Util/Preferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static Preferences()
Load();
}

public static void Save()
/*public static void Save()
{
try
{
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion SingerUtils/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
{
Expand Down
2 changes: 1 addition & 1 deletion SingerUtils/plugin.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name=OpenUTAU Singer ToolKit
name=SingerUtils
execute=SingerUtils.exe
encoding=utf-8

0 comments on commit f9d9e50

Please sign in to comment.