Skip to content

Commit 180770f

Browse files
committed
More MVVM rewrites, dialog host
1 parent e2b98f5 commit 180770f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+331
-230
lines changed

Amethyst.Desktop/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Runtime.InteropServices;
3+
using Amethyst.Utils;
34
using Avalonia;
45
using Avalonia.Controls.ApplicationLifetimes;
56
using DesktopNotifications;

Amethyst.Desktop/SystemShell.Linux.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.IO;
55
using System.Linq;
66
using System.Runtime.InteropServices;
7+
using Amethyst.Utils;
78
using Avalonia;
89
using Avalonia.Media;
910
using Avalonia.Media.Imaging;

Amethyst.Desktop/SystemShell.Mac.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.IO;
55
using System.Linq;
66
using System.Runtime.InteropServices;
7+
using Amethyst.Utils;
78
using Avalonia.Media.Imaging;
89

910
namespace Amethyst.Desktop;

Amethyst.Desktop/SystemShell.Windows.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Runtime.InteropServices;
88
using System.Runtime.InteropServices.ComTypes;
99
using System.Text;
10+
using Amethyst.Utils;
1011
using Avalonia.Media.Imaging;
1112
using Avalonia.Platform;
1213

Amethyst/App.axaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
using Avalonia.Controls;
1616
using Avalonia.Controls.ApplicationLifetimes;
1717
using Avalonia.Markup.Xaml;
18-
using Avalonia.Media;
1918
using Avalonia.Platform.Storage;
2019
using Avalonia.Styling;
2120
using Avalonia.Threading;

Amethyst/Classes/AppPlugins.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
using System.Reflection;
33
using Amethyst.Contract;
44
using Amethyst.Installer.ViewModels;
5-
using Amethyst.MVVM;
5+
using Amethyst.Models;
66
using Amethyst.Utils;
77
using Avalonia.Controls;
88
using Avalonia.Threading;
99
using FluentAvalonia.UI.Media.Animation;
1010
using static Amethyst.Classes.Shared;
11+
using LoadAttemptedPlugin = Amethyst.Models.LoadAttemptedPlugin;
12+
using TrackingDevice = Amethyst.Models.TrackingDevice;
1113

1214
namespace Amethyst.Classes;
1315

Amethyst/Classes/AppSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
using System.Globalization;
44
using System.Numerics;
55
using System.Runtime.CompilerServices;
6-
using Amethyst.MVVM;
76
using Amethyst.Contract;
87
using Amethyst.Utils;
98
using Avalonia.Controls;
109
using KeySharp;
1110
using Newtonsoft.Json;
11+
using TrackingDevice = Amethyst.Models.TrackingDevice;
1212

1313
namespace Amethyst.Classes;
1414

Amethyst/Classes/AppTracker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.ComponentModel;
22
using System.Numerics;
3-
using Amethyst.MVVM;
43
using Amethyst.Contract;
4+
using Amethyst.Models;
55
using Amethyst.Utils;
66
using Avalonia.Threading;
77
using Newtonsoft.Json;

Amethyst/Classes/Main.cs

Lines changed: 41 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public static void FreezeActionToggled(object o, EventArgs eventArgs)
2424
{
2525
Shared.General.GeneralTabSetupFinished = false; // Boiler
2626
Shared.General.ToggleFreezeButton.IsChecked = Interfacing.IsTrackingFrozen;
27-
Shared.General.ToggleFreezeButton.Content = Interfacing.IsTrackingFrozen
28-
? Interfacing.LocalizedJsonString("/GeneralPage/Buttons/Skeleton/Unfreeze")
29-
: Interfacing.LocalizedJsonString("/GeneralPage/Buttons/Skeleton/Freeze");
27+
Shared.General.ToggleFreezeButton.Content = Interfacing.IsTrackingFrozen ?
28+
Interfacing.LocalizedJsonString("/GeneralPage/Buttons/Skeleton/Unfreeze") :
29+
Interfacing.LocalizedJsonString("/GeneralPage/Buttons/Skeleton/Freeze");
3030

3131
Shared.General.GeneralTabSetupFinished = true; // Boiler end
3232
});
@@ -45,9 +45,7 @@ public static void FlipActionToggled(object o, EventArgs eventArgs)
4545

4646
// Play a Sound and Update UI
4747
AppSounds.PlayAppSound(
48-
AppData.Settings.IsFlipEnabled
49-
? AppSounds.AppSoundType.ToggleOff
50-
: AppSounds.AppSoundType.ToggleOn);
48+
AppData.Settings.IsFlipEnabled ? AppSounds.AppSoundType.ToggleOff : AppSounds.AppSoundType.ToggleOn);
5149

5250
if (Shared.Settings.FlipToggle is not null)
5351
Dispatcher.UIThread.Post(() =>
@@ -169,7 +167,7 @@ await AppPlugins.CurrentServiceEndpoint.UpdateTrackerPoses(Interfacing.ReplayMan
169167
// Run the worker (if applicable)
170168
if (AppData.Settings.CheckForOverlappingTrackers &&
171169
!Interfacing.IsAlreadyAddedTrackersScanRunning)
172-
Dispatcher.UIThread.Post(async () =>
170+
Dispatcher.UIThread.Post(async void () =>
173171
{
174172
Interfacing.IsAlreadyAddedTrackersScanRunning = true;
175173
var wereChangesMade = false; // At least not yet
@@ -247,33 +245,30 @@ private static void UpdateAppTrackers()
247245
AppData.Settings.TrackersVector[0].IsOrientationOverridden;
248246

249247
// Compose flip
250-
var dotFacing = 1.0;
251-
// var dotFacing =
252-
// Support.OrientationDot(
253-
// // Check for external-flip
254-
// extFlip
255-
//
256-
// // Check for internal overrides
257-
// ? extFlipInternal
258-
//
259-
// // Overriden internal amethyst tracker
260-
// ? AppData.Settings.TrackersVector[0].Orientation.Projected()
261-
//
262-
// // External VR waist tracker
263-
// : Interfacing.GetVrTrackerPoseCalibrated("waist").Orientation.Projected()
264-
//
265-
// // Default: VR HMD orientation
266-
// : Interfacing.Plugins.GetHmdPose.Orientation.Projected(),
267-
//
268-
// // Check for external-flip
269-
// extFlip
270-
//
271-
// // If ExtFlip is enabled compare to its calibration
272-
// ? AppData.Settings.ExternalFlipCalibrationMatrix.Projected()
273-
//
274-
// // Default: use the default calibration rotation
275-
// : AppData.Settings.DeviceCalibrationRotationMatrices.GetValueOrDefault(
276-
// AppData.Settings.TrackingDeviceGuid, Quaternion.Identity).Projected()); // TODO
248+
var dotFacing = Support.OrientationDot(
249+
// Check for external-flip
250+
extFlip ?
251+
// Check for internal overrides
252+
extFlipInternal ?
253+
254+
// Overriden internal amethyst tracker
255+
AppData.Settings.TrackersVector[0].Orientation :
256+
257+
// External VR waist tracker
258+
Interfacing.GetVrTrackerPoseCalibrated("waist").Orientation :
259+
260+
// Default: VR HMD orientation
261+
Interfacing.Plugins.GetHmdPose.Orientation,
262+
263+
// Check for external-flip
264+
extFlip ?
265+
266+
// If ExtFlip is enabled compare to its calibration
267+
AppData.Settings.ExternalFlipCalibrationMatrix :
268+
269+
// Default: use the default calibration rotation
270+
AppData.Settings.DeviceCalibrationRotationMatrices.GetValueOrDefault(
271+
AppData.Settings.TrackingDeviceGuid, Quaternion.Identity));
277272

278273
// Not in transition angle area, can compute
279274
if (Math.Abs(dotFacing) >= flipThreshold)
@@ -295,14 +290,16 @@ private static void UpdateAppTrackers()
295290
var joint = isJointFlipped
296291

297292
// If flip : the device contains a joint for the mirrored role
298-
? device.TrackedJoints.FirstOrDefault(
293+
?
294+
device.TrackedJoints.FirstOrDefault(
299295
x => x.Role == TypeUtils.FlippedJointTypeDictionary[
300296
device.TrackedJoints[(int)tracker.SelectedTrackedJointId].Role],
301297
// Otherwise, default to the non-flipped (selected one)
302298
device.TrackedJoints[(int)tracker.SelectedTrackedJointId])
303299

304300
// If no flip
305-
: device.TrackedJoints[(int)tracker.SelectedTrackedJointId];
301+
:
302+
device.TrackedJoints[(int)tracker.SelectedTrackedJointId];
306303

307304
// Copy the orientation to the tracker
308305
tracker.Orientation = tracker.OrientationTrackingOption switch
@@ -317,9 +314,7 @@ private static void UpdateAppTrackers()
317314
JointRotationTrackingOption.DisableJointRotation => Quaternion.Identity,
318315

319316
// Default
320-
_ => isJointFlipped
321-
? Quaternion.Inverse(joint.Orientation)
322-
: joint.Orientation
317+
_ => isJointFlipped ? Quaternion.Inverse(joint.Orientation) : joint.Orientation
323318
};
324319

325320
// Copy the previous orientation to the tracker
@@ -335,9 +330,7 @@ private static void UpdateAppTrackers()
335330
JointRotationTrackingOption.DisableJointRotation => Quaternion.Identity,
336331

337332
// Default
338-
_ => isJointFlipped
339-
? Quaternion.Inverse(joint.PreviousOrientation)
340-
: joint.PreviousOrientation
333+
_ => isJointFlipped ? Quaternion.Inverse(joint.PreviousOrientation) : joint.PreviousOrientation
341334
};
342335

343336
// If math-based orientation is supported, overwrite the orientation with it
@@ -449,27 +442,25 @@ private static void UpdateAppTrackers()
449442
var joint = isJointFlipped
450443

451444
// If flip : the device contains a joint for the mirrored role
452-
? device.TrackedJoints.FirstOrDefault(
445+
?
446+
device.TrackedJoints.FirstOrDefault(
453447
x => x.Role == TypeUtils.FlippedJointTypeDictionary[
454448
device.TrackedJoints[(int)tracker.OverrideJointId].Role],
455449
// Otherwise, default to the non-flipped (selected one)
456450
device.TrackedJoints[(int)tracker.OverrideJointId])
457451

458452
// If no flip
459-
: device.TrackedJoints[(int)tracker.OverrideJointId];
453+
:
454+
device.TrackedJoints[(int)tracker.OverrideJointId];
460455

461456
// If overridden w/ orientation and the selected option is 'device'
462457
if (tracker.IsOrientationOverridden && tracker.OrientationTrackingOption ==
463458
JointRotationTrackingOption.DeviceInferredRotation)
464459
{
465460
// Standard, also apply calibration-related flipped orientation fixes
466-
tracker.Orientation = isJointFlipped
467-
? Quaternion.Inverse(joint.Orientation)
468-
: joint.Orientation;
461+
tracker.Orientation = isJointFlipped ? Quaternion.Inverse(joint.Orientation) : joint.Orientation;
469462

470-
tracker.PreviousOrientation = isJointFlipped
471-
? Quaternion.Inverse(joint.PreviousOrientation)
472-
: joint.PreviousOrientation;
463+
tracker.PreviousOrientation = isJointFlipped ? Quaternion.Inverse(joint.PreviousOrientation) : joint.PreviousOrientation;
473464

474465
// Apply calibration-related flipped orientation fixes
475466
if (isJointFlipped && tracker.OrientationTrackingOption

Amethyst/Classes/PathsHandler.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Reflection;
22
using Amethyst.Contract;
33
using Amethyst.Utils;
4-
using Avalonia.Controls;
54
using Avalonia.Platform.Storage;
65

76
namespace Amethyst.Classes;

0 commit comments

Comments
 (0)