77using System . Threading ;
88using System . Threading . Tasks ;
99using Windows . Data . Json ;
10- using Amethyst . Plugins . Contract ;
11- using Microsoft . UI . Xaml . Controls ;
10+ using Amethyst . Contract ;
1211using plugin_OpenVR . Utils ;
1312using Windows . Storage ;
14- using Microsoft . UI . Xaml . Markup ;
15- using Microsoft . UI . Xaml . Media ;
13+ using Avalonia . Controls ;
14+ using Avalonia . Media ;
1615
1716namespace plugin_OpenVR ;
1817
1918internal class SetupData : ICoreSetupData
2019{
21- public object PluginIcon => new PathIcon
20+ public object PluginIcon
2221 {
23- Data = ( Geometry ) XamlBindingHelper . ConvertValue ( typeof ( Geometry ) ,
24- "M36.59,0A36.71,36.71,0,0,0,0,33.77L19.68,41.9a10.3,10.3,0,0,1,5.85-1.8h.57l8.76-12.68c0-.06,0-.12,0-.18A13.85,13.85,0,1,1,48.7,41.1h-.31L35.91,50c0,.16,0,.32,0,.49a10.39,10.39,0,0,1-20.58,2L1.26,46.72A36.71,36.71,0,1,0,36.59,0ZM23,55.71,18.5,53.84a7.72,7.72,0,0,0,4,3.82,7.8,7.8,0,0,0,10.2-4.2,7.79,7.79,0,0,0-9.95-10.28l4.66,1.93A5.74,5.74,0,1,1,23,55.71ZM57.93,27.25a9.23,9.23,0,1,0-9.23,9.23A9.24,9.24,0,0,0,57.93,27.25Zm-16.14,0a6.93,6.93,0,1,1,6.93,6.93A6.93,6.93,0,0,1,41.79,27.23ZM248 48 238.98 23.75 235.9 23.75 246.09 50.58 249.7 50.58 259.84 23.75 256.72 23.75 248 48ZM284.25,31.4c0-4.12-2.23-7.65-9.25-7.65h-8.91V50.58h2.83V40h6.92l6.43,10.6h3.2l-6.8-11.06C282.5,38.35,284.25,35.18,284.25,31.4Zm-8.7,6.07h-6.63V26.22h5.7c4.87,0,6.64,2,6.64,5.52C281.26,34.94,279.33,37.47,275.55,37.47ZM104.77,35.14c-4.06-1.46-6.79-2-6.79-4.22,0-1.84,1.54-2.87,4-2.87a11.91,11.91,0,0,1,6.51,2.06l2.38-4.2a15.41,15.41,0,0,0-9-2.62c-5.75,0-9.75,2.86-9.75,7.85,0,4.43,3,6.33,7.37,7.78,3.81,1.27,6.18,1.88,6.18,3.91,0,1.78-1.55,3-4.82,3a16.49,16.49,0,0,1-7.4-1.91l-1.74,4.65A19,19,0,0,0,101.16,51c6.18,0,10.48-3.07,10.48-8.54C111.64,38.5,109.14,36.68,104.77,35.14ZM116.17 28.57 124.33 28.57 124.33 50.58 129.95 50.58 129.95 28.57 138.08 28.57 138.08 23.75 116.17 23.75 116.17 28.57ZM143.9 50.58 161.99 50.58 161.99 45.71 149.52 45.71 149.52 39.41 160.27 39.41 160.27 34.6 149.52 34.6 149.52 28.55 161.99 28.55 161.99 23.75 143.9 23.75 143.9 50.58ZM176.93,23.75,166.87,50.58h5.89l1.77-5.21H185l1.81,5.21h6.09L182.58,23.75Zm-6.4,17.14,3.66-10.74,3.74,10.74ZM212.62 43.11 203.6 23.75 198.24 23.75 198.24 50.58 203.62 50.58 203.62 34.26 210.84 49.79 214.01 49.79 221.35 34.12 221.35 50.58 226.73 50.58 226.73 23.75 221.31 23.75 212.62 43.11ZM286.89 24.35 288.58 24.35 288.58 28.9 289.26 28.9 289.26 24.35 290.95 24.35 290.95 23.75 286.89 23.75 286.89 24.35ZM296.43 23.75 294.54 27.97 292.59 23.75 291.9 23.75 291.9 28.9 292.57 28.9 292.57 25.09 294.32 28.84 294.69 28.84 296.45 25.09 296.45 28.9 297.12 28.9 297.12 23.75 296.43 23.75Z" )
25- } ;
22+ get => new PathIcon
23+ {
24+ Data = Geometry . Parse (
25+ "M36.59,0A36.71,36.71,0,0,0,0,33.77L19.68,41.9a10.3,10.3,0,0,1,5.85-1.8h.57l8.76-12.68c0-.06,0-.12,0-.18A13.85,13.85,0,1,1,48.7,41.1h-.31L35.91,50c0,.16,0,.32,0,.49a10.39,10.39,0,0,1-20.58,2L1.26,46.72A36.71,36.71,0,1,0,36.59,0ZM23,55.71,18.5,53.84a7.72,7.72,0,0,0,4,3.82,7.8,7.8,0,0,0,10.2-4.2,7.79,7.79,0,0,0-9.95-10.28l4.66,1.93A5.74,5.74,0,1,1,23,55.71ZM57.93,27.25a9.23,9.23,0,1,0-9.23,9.23A9.24,9.24,0,0,0,57.93,27.25Zm-16.14,0a6.93,6.93,0,1,1,6.93,6.93A6.93,6.93,0,0,1,41.79,27.23ZM248 48 238.98 23.75 235.9 23.75 246.09 50.58 249.7 50.58 259.84 23.75 256.72 23.75 248 48ZM284.25,31.4c0-4.12-2.23-7.65-9.25-7.65h-8.91V50.58h2.83V40h6.92l6.43,10.6h3.2l-6.8-11.06C282.5,38.35,284.25,35.18,284.25,31.4Zm-8.7,6.07h-6.63V26.22h5.7c4.87,0,6.64,2,6.64,5.52C281.26,34.94,279.33,37.47,275.55,37.47ZM104.77,35.14c-4.06-1.46-6.79-2-6.79-4.22,0-1.84,1.54-2.87,4-2.87a11.91,11.91,0,0,1,6.51,2.06l2.38-4.2a15.41,15.41,0,0,0-9-2.62c-5.75,0-9.75,2.86-9.75,7.85,0,4.43,3,6.33,7.37,7.78,3.81,1.27,6.18,1.88,6.18,3.91,0,1.78-1.55,3-4.82,3a16.49,16.49,0,0,1-7.4-1.91l-1.74,4.65A19,19,0,0,0,101.16,51c6.18,0,10.48-3.07,10.48-8.54C111.64,38.5,109.14,36.68,104.77,35.14ZM116.17 28.57 124.33 28.57 124.33 50.58 129.95 50.58 129.95 28.57 138.08 28.57 138.08 23.75 116.17 23.75 116.17 28.57ZM143.9 50.58 161.99 50.58 161.99 45.71 149.52 45.71 149.52 39.41 160.27 39.41 160.27 34.6 149.52 34.6 149.52 28.55 161.99 28.55 161.99 23.75 143.9 23.75 143.9 50.58ZM176.93,23.75,166.87,50.58h5.89l1.77-5.21H185l1.81,5.21h6.09L182.58,23.75Zm-6.4,17.14,3.66-10.74,3.74,10.74ZM212.62 43.11 203.6 23.75 198.24 23.75 198.24 50.58 203.62 50.58 203.62 34.26 210.84 49.79 214.01 49.79 221.35 34.12 221.35 50.58 226.73 50.58 226.73 23.75 221.31 23.75 212.62 43.11ZM286.89 24.35 288.58 24.35 288.58 28.9 289.26 28.9 289.26 24.35 290.95 24.35 290.95 23.75 286.89 23.75 286.89 24.35ZM296.43 23.75 294.54 27.97 292.59 23.75 291.9 23.75 291.9 28.9 292.57 28.9 292.57 25.09 294.32 28.84 294.69 28.84 296.45 25.09 296.45 28.9 297.12 28.9 297.12 23.75 296.43 23.75Z" )
26+ } ;
27+ }
28+
29+ public string GroupName
30+ {
31+ get => string . Empty ;
32+ }
2633
27- public string GroupName => string . Empty ;
28- public Type PluginType => typeof ( IServiceEndpoint ) ;
34+ public Type PluginType
35+ {
36+ get => typeof ( IServiceEndpoint ) ;
37+ }
2938}
3039
3140internal class DriverInstaller : IDependencyInstaller
3241{
3342 public IDependencyInstaller . ILocalizationHost Host { get ; set ; }
3443
35- public List < IDependency > ListDependencies ( )
44+ public List < IDependency > Dependencies
3645 {
37- List < IDependency > dep =
38- [
39- new VrDriver
40- {
41- Host = Host ,
42- Name = Host ? . RequestLocalizedString ( "/Dependencies/Driver" ) ?? "OpenVR Driver"
43- }
44- ] ;
46+ get
47+ {
48+ List < IDependency > dep =
49+ [
50+ new VrDriver { Host = Host , Name = Host ? . RequestLocalizedString ( "/Dependencies/Driver" ) ?? "OpenVR Driver" }
51+ ] ;
4552
46- if ( SteamVR . Instance is not null )
47- dep . Add ( new NullDriver
48- {
49- Host = Host ,
50- Name = Host ? . RequestLocalizedString ( "/Dependencies/Null" ) ?? "Null Driver"
51- } ) ;
53+ if ( SteamVR . Instance is not null )
54+ dep . Add ( new NullDriver { Host = Host , Name = Host ? . RequestLocalizedString ( "/Dependencies/Null" ) ?? "Null Driver" } ) ;
5255
53- return dep ;
56+ return dep ;
57+ }
5458 }
5559
56- public List < IFix > ListFixes ( )
60+ public List < IFix > Fixes
5761 {
58- return [ ] ;
62+ get => [ ] ;
5963 }
6064}
6165
@@ -64,9 +68,21 @@ internal class VrDriver : IDependency
6468 public IDependencyInstaller . ILocalizationHost Host { get ; set ; }
6569
6670 public string Name { get ; set ; }
67- public bool IsMandatory => true ;
68- public bool IsInstalled => false ;
69- public string InstallerEula => string . Empty ;
71+
72+ public bool IsMandatory
73+ {
74+ get => true ;
75+ }
76+
77+ public bool IsInstalled
78+ {
79+ get => false ;
80+ }
81+
82+ public string InstallerEula
83+ {
84+ get => string . Empty ;
85+ }
7086
7187 public async Task < bool > Install ( IProgress < InstallationProgress > progress , CancellationToken cancellationToken )
7288 {
@@ -93,8 +109,7 @@ public async Task<bool> Install(IProgress<InstallationProgress> progress, Cancel
93109 {
94110 progress . Report ( new InstallationProgress
95111 {
96- IsIndeterminate = true ,
97- StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/OpenVRPathsError" ) !
112+ IsIndeterminate = true , StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/OpenVRPathsError" ) !
98113 } ) ;
99114 return false ;
100115 }
@@ -139,8 +154,7 @@ public async Task<bool> Install(IProgress<InstallationProgress> progress, Cancel
139154 {
140155 progress . Report ( new InstallationProgress
141156 {
142- IsIndeterminate = true ,
143- StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/Elevation" ) !
157+ IsIndeterminate = true , StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/Elevation" ) !
144158 } ) ;
145159
146160 return false ; // Hide and exit the handler
@@ -168,8 +182,7 @@ public async Task<bool> Install(IProgress<InstallationProgress> progress, Cancel
168182 Host ? . Log ( $ "Copied driver not present at expectant path of: { localAmethystDriverPath } ") ;
169183 progress . Report ( new InstallationProgress
170184 {
171- IsIndeterminate = true ,
172- StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/DriverNotFound" ) !
185+ IsIndeterminate = true , StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/DriverNotFound" ) !
173186 } ) ;
174187
175188 return false ; // Hide and exit the handler
@@ -212,8 +225,7 @@ public async Task<bool> Install(IProgress<InstallationProgress> progress, Cancel
212225 {
213226 progress . Report ( new InstallationProgress
214227 {
215- IsIndeterminate = true ,
216- StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/FatalRemoveException_K2EX" ) !
228+ IsIndeterminate = true , StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/FatalRemoveException_K2EX" ) !
217229 } ) ;
218230
219231 return false ; // Hide and exit the handler
@@ -269,8 +281,7 @@ public async Task<bool> Install(IProgress<InstallationProgress> progress, Cancel
269281 {
270282 progress . Report ( new InstallationProgress
271283 {
272- IsIndeterminate = true ,
273- StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/FatalRemoveException" ) !
284+ IsIndeterminate = true , StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/FatalRemoveException" ) !
274285 } ) ;
275286
276287 return false ; // Hide and exit the handler
@@ -280,6 +291,7 @@ public async Task<bool> Install(IProgress<InstallationProgress> progress, Cancel
280291
281292 // If out local amethyst driver was already registered, skip this step
282293 if ( ! isLocalAmethystDriverRegistered )
294+ {
283295 try // Try-Catch it
284296 {
285297 // Register the local Amethyst Driver via OpenVRPaths
@@ -293,8 +305,7 @@ public async Task<bool> Install(IProgress<InstallationProgress> progress, Cancel
293305 {
294306 progress . Report ( new InstallationProgress
295307 {
296- IsIndeterminate = true ,
297- StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/OpenVRPathsWriteError" ) !
308+ IsIndeterminate = true , StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/OpenVRPathsWriteError" ) !
298309 } ) ;
299310
300311 return false ; // Hide and exit the handler
@@ -304,12 +315,12 @@ public async Task<bool> Install(IProgress<InstallationProgress> progress, Cancel
304315 {
305316 progress . Report ( new InstallationProgress
306317 {
307- IsIndeterminate = true ,
308- StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/FatalRegisterException" ) !
318+ IsIndeterminate = true , StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/FatalRegisterException" ) !
309319 } ) ;
310320
311321 return false ; // Hide and exit the handler
312322 }
323+ }
313324
314325 /* 5 */
315326
@@ -347,9 +358,21 @@ internal class NullDriver : IDependency
347358 public IDependencyInstaller . ILocalizationHost Host { get ; set ; }
348359
349360 public string Name { get ; set ; }
350- public bool IsMandatory => false ;
351- public bool IsInstalled => false ;
352- public string InstallerEula => string . Empty ;
361+
362+ public bool IsMandatory
363+ {
364+ get => false ;
365+ }
366+
367+ public bool IsInstalled
368+ {
369+ get => false ;
370+ }
371+
372+ public string InstallerEula
373+ {
374+ get => string . Empty ;
375+ }
353376
354377 public async Task < bool > Install ( IProgress < InstallationProgress > progress , CancellationToken cancellationToken )
355378 {
@@ -372,8 +395,7 @@ public async Task<bool> Install(IProgress<InstallationProgress> progress, Cancel
372395 {
373396 progress . Report ( new InstallationProgress
374397 {
375- IsIndeterminate = true ,
376- StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/OpenVRPathsError" ) !
398+ IsIndeterminate = true , StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/OpenVRPathsError" ) !
377399 } ) ;
378400 return false ;
379401 }
@@ -400,8 +422,7 @@ public async Task<bool> Install(IProgress<InstallationProgress> progress, Cancel
400422 {
401423 progress . Report ( new InstallationProgress
402424 {
403- IsIndeterminate = true ,
404- StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/Elevation" ) !
425+ IsIndeterminate = true , StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/Elevation" ) !
405426 } ) ;
406427
407428 return false ; // Hide and exit the handler
@@ -453,16 +474,12 @@ await File.WriteAllTextAsync(resultPaths.Path.VrSettingsPath, steamVrSettings.To
453474 }
454475 catch ( Exception ex )
455476 {
456- progress . Report ( new InstallationProgress
457- {
458- IsIndeterminate = true ,
459- StageTitle = ex . Message
460- } ) ;
477+ progress . Report ( new InstallationProgress { IsIndeterminate = true , StageTitle = ex . Message } ) ;
461478
462479 return false ; // Hide and exit the handler
463480 }
464481
465482 // Winning it!
466483 return true ;
467484 }
468- }
485+ }
0 commit comments