Skip to content

Commit e2b98f5

Browse files
committed
Main, General MVVM
1 parent 82b5a26 commit e2b98f5

24 files changed

+4965
-4389
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ jobs:
3333
env:
3434
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3535

36+
- name: Inject build commit hash
37+
shell: pwsh
38+
run: |
39+
(Get-Content Amethyst/Classes/AppData.cs) -replace 'AZ_BUILD_NUMBER', $env:GITHUB_SHA | Set-Content Amethyst/Classes/AppData.cs
40+
3641
- name: Set up .NET
3742
uses: actions/setup-dotnet@v3
3843
with:

Amethyst/Amethyst.csproj

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
<ItemGroup>
1515
<AvaloniaResource Include="Assets\**" />
16+
<AvaloniaResource Remove="Assets\Sounds\**" />
1617
</ItemGroup>
1718

1819
<ItemGroup>
@@ -21,13 +22,10 @@
2122
</ItemGroup>
2223

2324
<ItemGroup>
24-
<Content Include="Strings\**">
25+
<Content Include="Strings\**" Visible="False">
2526
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2627
</Content>
27-
</ItemGroup>
28-
29-
<ItemGroup>
30-
<Content Include="Assets/Sounds\**">
28+
<Content Include="Assets\Sounds\**" Visible="False">
3129
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
3230
</Content>
3331
</ItemGroup>

Amethyst/App.axaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ private async Task SetupCoreApplication()
141141

142142
Logger.Info($"Amethyst version: {AppData.VersionString}");
143143
Logger.Info($"Amethyst web API version: {AppData.ApiVersion}");
144-
Logger.Info("Amethyst build commit: AZ_COMMIT_SHA");
145144

146145
// Read saved settings
147146
Logger.Info("Reading base app settings...");

Amethyst/Classes/Interfacing.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Diagnostics;
2+
using System.Diagnostics.CodeAnalysis;
23
using System.Numerics;
34
using System.Reflection;
45
using System.Runtime.CompilerServices;
@@ -36,12 +37,8 @@ public static bool
3637
// Update check
3738
public static bool
3839
UpdateFound = false,
39-
ManualUpdate = false,
4040
UpdatingNow = false;
4141

42-
// Update file
43-
public static string UpdateFileName = null;
44-
4542
// Position helpers for devices -> GUID, Pose
4643
public static readonly SortedDictionary<string, (Vector3 Position, Quaternion Orientation)>
4744
DeviceHookJointPosition = new(); // This one applies to both
@@ -92,18 +89,12 @@ public static bool
9289
// Amethyst language resource trees
9390
private static LocalisationFileJson _localResources = new(), _englishResources = new();
9491

95-
// Is NUX currently opened?
96-
public static bool IsNuxPending = false;
97-
9892
// Flip defines for the base device - iteration persistent
9993
public static bool BaseFlip = false; // Assume non flipped
10094

10195
// Flip defines for the override device - iteration persistent
10296
public static bool OverrideFlip = false; // Assume non flipped
10397

104-
// For the relay module to override the "Relay active" bar
105-
public static (string Title, string Content, string Button, Action Click, bool Closable)? RelayBarOverride = null;
106-
10798
public static bool IsServiceEndpointPresent => ServiceEndpointStatusCode == 0;
10899

109100
public static AppSettingsReadEventHandler AppSettingsRead { get; set; } = (_, _) => { };
@@ -1139,4 +1130,11 @@ public static void RefreshApplicationInterface()
11391130
});
11401131
}
11411132
}
1133+
1134+
[SuppressMessage("ReSharper", "ExplicitCallerInfoArgument")]
1135+
public static string Localized(this string s, [CallerLineNumber] int lineNumber = 0, [CallerFilePath] string filePath = "",
1136+
[CallerMemberName] string memberName = "")
1137+
{
1138+
return LocalizedJsonString(s, lineNumber, filePath, memberName);
1139+
}
11421140
}

Amethyst/Classes/Shared.cs

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Amethyst.Utils;
2+
using Amethyst.ViewModels;
23
using Avalonia.Controls;
34
using Avalonia.Controls.Primitives;
45
using Avalonia.Media;
@@ -44,6 +45,8 @@ public static readonly ManualResetEvent
4445
public static RaisedEvent RequestJointSettingsRefreshEvent;
4546
public static RaisedEvent RequestReloadRemoteDevicesEvent;
4647

48+
public static EventHandler<bool> OnAllowNavigationChanged;
49+
4750
public static void RequestInterfaceReload(bool all = true)
4851
{
4952
if (!General.GeneralTabSetupFinished)
@@ -72,36 +75,39 @@ public static class Main
7275
// Vector of std.pair holding the Navigation Tag and the relative Navigation Page.
7376
public static List<(string Tag, Type Page)> Pages;
7477

78+
public static MainViewModel Context;
79+
80+
// Info bars
81+
public static NoticeViewModel PluginsUpdatePendingInfoBar => Context.Notices[NoticeType.PluginsUpdatePending];
82+
public static NoticeViewModel PluginsInstallInfoBar => Context.Notices[NoticeType.PluginsInstall];
83+
public static NoticeViewModel PluginsUninstallInfoBar => Context.Notices[NoticeType.PluginsUninstall];
84+
public static NoticeViewModel NoticeInfoBar => Context.Notices[NoticeType.NoticeInfo];
85+
public static NoticeViewModel ReloadInfoBar => Context.Notices[NoticeType.Reload];
86+
public static NoticeViewModel UpdateDownloadingInfoBar => Context.Notices[NoticeType.UpdateDownloading];
87+
public static NoticeViewModel UpdateInfoBar => Context.Notices[NoticeType.Update];
88+
7589
// Main Window
7690
public static Mutex ApplicationMultiInstanceMutex;
7791
public static bool MainWindowLoaded = false;
7892

7993
public static Window Window;
8094

8195
public static Grid
82-
InterfaceBlockerGrid, NavigationBlockerGrid, MainGrid;
96+
InterfaceBlockerGrid, MainGrid;
8397

8498
public static NavigationView MainNavigationView;
8599
public static Frame MainContentFrame;
86-
public static TextBlock AppTitleLabel;
87100

88101
public static SolidColorBrush
89-
AttentionBrush, NeutralBrush;
90-
91-
public static ProgressBar PluginsUpdatePendingProgressBar;
92-
93-
public static InfoBar
94-
PluginsUpdatePendingInfoBar,
95-
PluginsInstallInfoBar,
96-
PluginsUninstallInfoBar,
97-
PluginsUpdateInfoBar;
102+
AttentionBrush, NeutralBrush,
103+
CriticalBrush, PrimaryBrush;
98104

99105
public static Flyout EulaFlyout;
100106
public static TextBlock EulaHeader;
101107
public static MarkdownScrollViewer EulaText;
102108

103109
public static bool EulaFlyoutResult;
104-
public static SemaphoreSlim EulaFlyoutClosed = new(0);
110+
public static readonly SemaphoreSlim EulaFlyoutClosed = new(0);
105111
public static INotificationManager NotificationManager; // TODO
106112

107113
public static TopLevel TopLevel
@@ -139,7 +145,7 @@ public static void NavigateToPage(string navItemTag,
139145
Interfacing.CurrentPageClass = page.FullName; // Cache the current page tag
140146

141147
ReloadNavigationIcons();
142-
148+
143149
MainContentFrame.Navigate(page, null, transitionInfo);
144150
}
145151

@@ -262,22 +268,14 @@ public static class General
262268
// General Page
263269
public static bool GeneralTabSetupFinished = false;
264270
public static ToggleButton ToggleTrackersButton;
265-
public static ToggleSplitButton SkeletonToggleButton;
266-
public static CheckBox ForceRenderCheckBox;
267271
public static MenuFlyoutItem OffsetsButton;
268-
269-
public static Button
270-
CalibrationButton, ServiceSettingsButton;
272+
public static Button CalibrationButton;
271273

272274
public static TextBlock
273275
DeviceNameLabel,
274276
DeviceStatusLabel,
275277
ErrorWhatText,
276278
TrackingDeviceErrorLabel,
277-
ServerStatusLabel,
278-
ServerErrorLabel,
279-
ServerErrorWhatText,
280-
ForceRenderText,
281279
ToggleTrackersButtonText;
282280

283281
public static Grid
@@ -286,9 +284,6 @@ public static Grid
286284
public static Border
287285
ErrorWhatGrid;
288286

289-
public static Border
290-
ServerErrorWhatGrid;
291-
292287
public static ToggleButton
293288
ToggleFreezeButton;
294289

@@ -395,10 +390,11 @@ public static void ReloadSelectedDeviceSync(bool manual, bool reconnect = false)
395390
}
396391
}
397392

398-
public static async Task ReloadSelectedDevice(bool manual, bool reconnect = false)
393+
public static Task ReloadSelectedDevice(bool manual, bool reconnect = false)
399394
{
400395
// Reload the device
401396
ReloadSelectedDeviceSync(manual, reconnect);
397+
return Task.CompletedTask;
402398
}
403399
}
404400

@@ -408,8 +404,6 @@ public static class MainPage
408404
{
409405
public static TeachingTip
410406
InitializerTeachingTip, EndingTeachingTip;
411-
412-
public static InfoBar ReloadInfoBar;
413407
}
414408

415409
public static class GeneralPage

0 commit comments

Comments
 (0)