Skip to content

Commit 9bcbc31

Browse files
Unpackaged support
1 parent 3821cf4 commit 9bcbc31

File tree

4 files changed

+37
-28
lines changed

4 files changed

+37
-28
lines changed

KinectHandler/KinectHandler.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
</ItemGroup>
9696
<ItemGroup>
9797
<PackageReference Include="Amethyst.Plugins.Contract">
98-
<Version>0.3.33</Version>
98+
<Version>0.3.35</Version>
9999
</PackageReference>
100100
<PackageReference Include="System.ComponentModel">
101101
<Version>4.3.0</Version>

plugin_KinectOne/PackageUtils.cs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,27 @@
22
using System;
33
using System.Diagnostics;
44
using System.IO;
5+
using System.Reflection;
6+
using System.Threading.Tasks;
57
using Windows.ApplicationModel;
68
using Windows.Storage;
79

810
namespace plugin_KinectOne;
911

10-
public static class PackageUtils
12+
public static class PathsHandler
1113
{
14+
public static async Task Setup()
15+
{
16+
if (IsAmethystPackaged) return;
17+
18+
var root = await StorageFolder.GetFolderFromPathAsync(
19+
Path.Join(ProgramLocation.DirectoryName!));
20+
21+
TemporaryFolderUnpackaged = await (await root
22+
.CreateFolderAsync("AppData", CreationCollisionOption.OpenIfExists))
23+
.CreateFolderAsync("TempState", CreationCollisionOption.OpenIfExists);
24+
}
25+
1226
public static bool IsAmethystPackaged
1327
{
1428
get
@@ -24,15 +38,11 @@ public static bool IsAmethystPackaged
2438
}
2539
}
2640

27-
public static string GetAmethystAppDataPath()
28-
{
29-
return ApplicationData.Current.LocalFolder.Path;
30-
}
41+
public static FileInfo ProgramLocation => new(Assembly.GetExecutingAssembly().Location);
3142

32-
public static string GetAmethystTempPath()
33-
{
34-
return ApplicationData.Current.TemporaryFolder.Path;
35-
}
43+
public static StorageFolder TemporaryFolder => IsAmethystPackaged ? ApplicationData.Current.TemporaryFolder : TemporaryFolderUnpackaged;
44+
45+
public static StorageFolder TemporaryFolderUnpackaged { get; set; } // Assigned on Setup()
3646
}
3747

3848
public static class StorageExtensions

plugin_KinectOne/RuntimeInstaller.cs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,25 +115,24 @@ public async Task<bool> Install(IProgress<InstallationProgress> progress, Cancel
115115
"Assets", "Resources", "Dependencies", "KinectRuntime-x64.msi")
116116
};
117117

118+
await PathsHandler.Setup();
119+
118120
// Copy to temp if amethyst is packaged
119121
// ReSharper disable once InvertIf
120-
if (PackageUtils.IsAmethystPackaged)
121-
{
122-
// Create a shared folder with the dependencies
123-
var dependenciesFolder = await ApplicationData.Current.TemporaryFolder.CreateFolderAsync(
124-
Guid.NewGuid().ToString().ToUpper(), CreationCollisionOption.OpenIfExists);
125-
126-
// Copy all driver files to Amethyst's local data folder
127-
new DirectoryInfo(Path.Join(Directory.GetParent(Assembly.GetExecutingAssembly().Location)!.FullName,
128-
"Assets", "Resources", "Dependencies"))
129-
.CopyToFolder(dependenciesFolder.Path);
130-
131-
// Update the installation paths
132-
paths =
133-
[
134-
Path.Join(dependenciesFolder.Path, "KinectRuntime-x64.msi")
135-
];
136-
}
122+
// Create a shared folder with the dependencies
123+
var dependenciesFolder = await PathsHandler.TemporaryFolder.CreateFolderAsync(
124+
Guid.NewGuid().ToString().ToUpper(), CreationCollisionOption.OpenIfExists);
125+
126+
// Copy all driver files to Amethyst's local data folder
127+
new DirectoryInfo(Path.Join(Directory.GetParent(Assembly.GetExecutingAssembly().Location)!.FullName,
128+
"Assets", "Resources", "Dependencies"))
129+
.CopyToFolder(dependenciesFolder.Path);
130+
131+
// Update the installation paths
132+
paths =
133+
[
134+
Path.Join(dependenciesFolder.Path, "KinectRuntime-x64.msi")
135+
];
137136

138137
// Finally install the packages
139138
return InstallFiles(paths, progress, cancellationToken);

plugin_KinectOne/plugin_KinectOne.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="Amethyst.Plugins.Contract" Version="0.3.33" />
19+
<PackageReference Include="Amethyst.Plugins.Contract" Version="0.3.35" />
2020
<PackageReference Include="NAudio.Sdl2" Version="2.2.6" />
2121
<PackageReference Include="RestSharp" Version="108.0.3" />
2222
<PackageReference Include="System.ComponentModel.Composition" Version="8.0.0" />

0 commit comments

Comments
 (0)