From 0ba19b8ea9de591692176e993e0c6bc485fb7335 Mon Sep 17 00:00:00 2001 From: TheBug233 <33407430+TheBug233@users.noreply.github.com> Date: Sat, 29 Jul 2023 22:33:34 +0800 Subject: [PATCH 1/4] Optimize and add some localization fields With the version update some new features have been added.. Now the localization field for new content is also added --- VRCFaceTracking/Services/ActivationService.cs | 18 ++- VRCFaceTracking/Services/OpenVRService.cs | 14 +- VRCFaceTracking/Strings/en/Resources.resw | 141 ++++++++++++++++++ .../Views/ModuleRegistryDetailControl.xaml.cs | 18 ++- VRCFaceTracking/Views/ModuleRegistryPage.xaml | 2 +- VRCFaceTracking/Views/SettingsPage.xaml | 60 ++++---- VRCFaceTracking/Views/WarningBlock.xaml | 2 +- 7 files changed, 197 insertions(+), 58 deletions(-) diff --git a/VRCFaceTracking/Services/ActivationService.cs b/VRCFaceTracking/Services/ActivationService.cs index b6e30736..1ab369b6 100644 --- a/VRCFaceTracking/Services/ActivationService.cs +++ b/VRCFaceTracking/Services/ActivationService.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.Logging; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; +using Windows.ApplicationModel.Resources; using VRCFaceTracking.Activation; using VRCFaceTracking.Contracts.Services; @@ -23,6 +24,7 @@ public class ActivationService : IActivationService private readonly ModuleInstaller _moduleInstaller; private readonly ILibManager _libManager; private readonly ILogger _logger; + private readonly ResourceLoader _loader = ResourceLoader.GetForViewIndependentUse("Resources"); private UIElement? _shell = null; public ActivationService(ActivationHandler defaultHandler, @@ -38,7 +40,7 @@ public ActivationService(ActivationHandler defaultHand _moduleDataService = moduleDataService; _moduleInstaller = moduleInstaller; _libManager = libManager; - _logger = loggerFactory.CreateLogger("MainStandalone"); + _logger = loggerFactory.CreateLogger(_loader.GetString("MainStandalone")); } public async Task ActivateAsync(object activationArgs) @@ -89,32 +91,32 @@ private async Task StartupAsync() { await _themeSelectorService.SetRequestedThemeAsync(); - _logger.LogInformation("VRCFT Version {version} initializing...", Assembly.GetExecutingAssembly().GetName().Version); + _logger.LogInformation(_loader.GetString("VRCFTVersion"), Assembly.GetExecutingAssembly().GetName().Version); - _logger.LogInformation("Initializing OSC..."); + _logger.LogInformation(_loader.GetString("InitializingOSC")); await _oscService.InitializeAsync().ConfigureAwait(false); - _logger.LogInformation("Initializing main service..."); + _logger.LogInformation(_loader.GetString("InitializingMainService")); await _mainService.InitializeAsync().ConfigureAwait(false); // Before we initialize, we need to delete pending restart modules and check for updates for all our installed modules - _logger.LogDebug("Checking for deletion requests for installed modules..."); + _logger.LogDebug(_loader.GetString("CheckingForDeletionRequests")); var needsDeleting = _moduleDataService.GetInstalledModules().Concat(_moduleDataService.GetLegacyModules()) .Where(m => m.InstallationState == InstallState.AwaitingRestart); foreach (var deleteModule in needsDeleting) _moduleInstaller.UninstallModule(deleteModule); - _logger.LogInformation("Checking for updates for installed modules..."); + _logger.LogInformation(_loader.GetString("CheckingForUpdates")); var localModules = _moduleDataService.GetInstalledModules().Where(m => m.ModuleId != Guid.Empty); var remoteModules = await _moduleDataService.GetRemoteModules(); var outdatedModules = remoteModules.Where(rm => localModules.Any(lm => rm.ModuleId == lm.ModuleId && rm.Version != lm.Version)); foreach (var outdatedModule in outdatedModules) { - _logger.LogInformation($"Updating {outdatedModule.ModuleName} from {localModules.First(rm => rm.ModuleId == outdatedModule.ModuleId).Version} to {outdatedModule.Version}"); + _logger.LogInformation(string.Format(_loader.GetString("UpdatingModule"), outdatedModule.ModuleName, localModules.First(rm => rm.ModuleId == outdatedModule.ModuleId).Version, outdatedModule.Version)); await _moduleInstaller.InstallRemoteModule(outdatedModule); } - _logger.LogInformation("Initializing modules..."); + _logger.LogInformation(_loader.GetString("InitializingModules")); App.MainWindow.DispatcherQueue.TryEnqueue(() => _libManager.Initialize()); await Task.CompletedTask; diff --git a/VRCFaceTracking/Services/OpenVRService.cs b/VRCFaceTracking/Services/OpenVRService.cs index ec113d89..aef7699e 100644 --- a/VRCFaceTracking/Services/OpenVRService.cs +++ b/VRCFaceTracking/Services/OpenVRService.cs @@ -1,6 +1,7 @@ using System.Reflection; using Microsoft.Extensions.Logging; using Valve.VR; +using Windows.ApplicationModel.Resources; namespace VRCFaceTracking.Services; @@ -8,17 +9,18 @@ public class OpenVRService { private CVRSystem _system; private ILogger _logger; - + private readonly ResourceLoader _loader = ResourceLoader.GetForViewIndependentUse("Resources"); + public OpenVRService(ILoggerFactory loggerFactory) { - _logger = loggerFactory.CreateLogger("OpenVRService"); + _logger = loggerFactory.CreateLogger(_loader.GetString("OpenVRService")); EVRInitError error = EVRInitError.None; _system = OpenVR.Init(ref error, EVRApplicationType.VRApplication_Background); if (error != EVRInitError.None) { - _logger.LogWarning("Failed to initialize OpenVR: {0}", error); + _logger.LogWarning(_loader.GetString("FailedInitializeOpenVR"), error); return; } @@ -28,12 +30,12 @@ public OpenVRService(ILoggerFactory loggerFactory) var manifestRegisterResult = OpenVR.Applications.AddApplicationManifest(fullManifestPath, false); if (manifestRegisterResult != EVRApplicationError.None) { - _logger.LogWarning("Failed to register manifest: {0}", manifestRegisterResult); + _logger.LogWarning(_loader.GetString("FailedRegisterManifest"), manifestRegisterResult); return; } IsInitialized = true; - _logger.LogInformation("Successfully initialized OpenVR"); + _logger.LogInformation(_loader.GetString("SuccessfullyInitializedOpenVR")); } public bool IsInitialized { get; } @@ -47,7 +49,7 @@ public bool AutoStart return; var setAutoLaunchResult = OpenVR.Applications.SetApplicationAutoLaunch("benaclejames.vrcft", value); if (setAutoLaunchResult != EVRApplicationError.None) - _logger.LogError("Failed to set auto launch: {0}", setAutoLaunchResult); + _logger.LogError(_loader.GetString("FailedSetAutoLaunch"), setAutoLaunchResult); } } } \ No newline at end of file diff --git a/VRCFaceTracking/Strings/en/Resources.resw b/VRCFaceTracking/Strings/en/Resources.resw index cec5ae0a..256b0ccc 100644 --- a/VRCFaceTracking/Strings/en/Resources.resw +++ b/VRCFaceTracking/Strings/en/Resources.resw @@ -320,4 +320,145 @@ Auto Start when SteamVR is launched + + Heighten the influence your expressions make on calibration temporarily + + + Calibrate + + + Calibrate + + + Toggles whether or not calibration is enabled + + + Calibration Enabled + + + Controls how much of an influence your facial expressions have on overall calibration over time + + + Calibration Influence + + + Checking for deletion requests for installed modules... + + + Checking for updates for installed modules... + + + Slowly calibrates to your facial expressions over time + + + Continuous Calibration + + + Contributions + + + Credits + + + Dismiss + + + Failed to initialize OpenVR: {0} + + + Failed to register manifest: {0} + + + Failed to set auto launch: {0} + + + Force VRCFT to unload and reinitialize all modules + + + Force Re-Initialize + + + Forces sending of all parameters every frame by forcing relevancy + + + Force Relevancy + + + Gremlin Mode + + + Initializing main service... + + + Initializing modules... + + + Initializing OSC... + + + install + + + Install Module from *.zip + + + No changes required to run VRChat localhost + + + IP Address + + + OpenVRService + + + Please Restart VRCFT + + + Re-Initialize + + + This port is used to receive OSC data from VRChat + + + Receive Port + + + Reset + + + Reset all data stored by VRCFT in your AppData folder + + + Reset VRCFT + + + Reset all VRChat OSC config data (will be regenerated when avatar is reloaded) + + + Reset VRChat Configs + + + ⚠no other program occupying the port + + + Send Port + + + Successfully initialized OpenVR + + + Uninstall + + + Update + + + Updating {moduleName} from {oldVersion} to {newVersion} + + + VRCFT Version {version} initializing... + + + Your Rating + \ No newline at end of file diff --git a/VRCFaceTracking/Views/ModuleRegistryDetailControl.xaml.cs b/VRCFaceTracking/Views/ModuleRegistryDetailControl.xaml.cs index 7d377329..d189196c 100644 --- a/VRCFaceTracking/Views/ModuleRegistryDetailControl.xaml.cs +++ b/VRCFaceTracking/Views/ModuleRegistryDetailControl.xaml.cs @@ -4,6 +4,7 @@ using VRCFaceTracking.Core.Models; using VRCFaceTracking.Core.Services; using VRCFaceTracking.ViewModels; +using Windows.ApplicationModel.Resources; namespace VRCFaceTracking.Views; @@ -19,6 +20,7 @@ public InstallableTrackingModule? ListDetailsMenuItem private readonly ModuleInstaller _moduleInstaller; private readonly ILibManager _libManager; private readonly MainViewModel _mainViewModel; + private static readonly ResourceLoader _loader = ResourceLoader.GetForViewIndependentUse("Resources"); public static readonly DependencyProperty ListDetailsMenuItemProperty = DependencyProperty.Register("ListDetailsMenuItem", typeof(TrackingModuleMetadata), typeof(ModuleRegistryDetailControl), new PropertyMetadata(null, OnListDetailsMenuItemPropertyChanged)); @@ -44,16 +46,16 @@ private static async void OnListDetailsMenuItemPropertyChanged(DependencyObject switch (control.ListDetailsMenuItem!.InstallationState) { case InstallState.NotInstalled: - control.InstallButton.Content = "Install"; + control.InstallButton.Content = _loader.GetString("install"); break; case InstallState.Installed: - control.InstallButton.Content = "Uninstall"; + control.InstallButton.Content = _loader.GetString("Uninstall"); break; case InstallState.Outdated: - control.InstallButton.Content = "Update"; + control.InstallButton.Content = _loader.GetString("Update"); break; case InstallState.AwaitingRestart: - control.InstallButton.Content = "Please Restart VRCFT"; + control.InstallButton.Content = _loader.GetString("PleaseRestartVRCFT"); control.InstallButton.IsEnabled = false; break; } @@ -64,7 +66,7 @@ private static async void OnListDetailsMenuItemPropertyChanged(DependencyObject { control.RatingControl.PlaceholderValue = rating; control.RatingControl.Value = rating; - control.RatingControl.Caption = "Your Rating"; + control.RatingControl.Caption = _loader.GetString("YourRating"); } else // Otherwise, set the rating control to the average rating. { @@ -92,7 +94,7 @@ private async void Install_Click(object sender, RoutedEventArgs e) await _moduleDataService.IncrementDownloadsAsync(ListDetailsMenuItem!); ListDetailsMenuItem!.Downloads++; _libManager.Initialize(); - InstallButton.Content = "Uninstall"; + InstallButton.Content = _loader.GetString("Uninstall"); InstallButton.IsEnabled = true; _mainViewModel.NoModulesInstalled = false; } @@ -100,7 +102,7 @@ private async void Install_Click(object sender, RoutedEventArgs e) } case InstallState.Installed: { - InstallButton.Content = "Please Restart VRCFT"; + InstallButton.Content = _loader.GetString("PleaseRestartVRCFT"); InstallButton.IsEnabled = false; _libManager.TeardownAllAndResetAsync(); _moduleInstaller.MarkModuleForDeletion(ListDetailsMenuItem!); @@ -113,7 +115,7 @@ private async void Install_Click(object sender, RoutedEventArgs e) private async void RatingControl_OnValueChanged(RatingControl sender, object args) { - RatingControl.Caption = "Your Rating"; + RatingControl.Caption = _loader.GetString("YourRating"); await _moduleDataService.SetMyRatingAsync(ListDetailsMenuItem!, (int)RatingControl.Value); } diff --git a/VRCFaceTracking/Views/ModuleRegistryPage.xaml b/VRCFaceTracking/Views/ModuleRegistryPage.xaml index 99600d63..a5c60e60 100644 --- a/VRCFaceTracking/Views/ModuleRegistryPage.xaml +++ b/VRCFaceTracking/Views/ModuleRegistryPage.xaml @@ -87,7 +87,7 @@ - + diff --git a/VRCFaceTracking/Views/SettingsPage.xaml b/VRCFaceTracking/Views/SettingsPage.xaml index 6c0edcdb..1f27c238 100644 --- a/VRCFaceTracking/Views/SettingsPage.xaml +++ b/VRCFaceTracking/Views/SettingsPage.xaml @@ -37,9 +37,9 @@ - - - + + + @@ -56,7 +56,7 @@ + x:Uid="Calibration_Enabled"> + x:Uid="Continuous_Calibration"> -