From 187b3d9b8f710d187609c2ec70638eff09d7c971 Mon Sep 17 00:00:00 2001 From: pikminmario500 Date: Tue, 13 Aug 2024 01:40:13 +0200 Subject: [PATCH] add process priority (sync) --- Bloxstrap/Bootstrapper.cs | 21 ++++++ Bloxstrap/Enums/PriorityClass.cs | 11 +++ Bloxstrap/Models/Settings.cs | 1 + Bloxstrap/Resources/Strings.Designer.cs | 72 +++++++++++++++++++ Bloxstrap/Resources/Strings.resx | 24 +++++++ .../Settings/Pages/BehaviourPage.xaml | 12 ++++ .../ViewModels/Settings/BehaviourViewModel.cs | 8 +++ 7 files changed, 149 insertions(+) create mode 100644 Bloxstrap/Enums/PriorityClass.cs diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 97b7dbb..cfc962c 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -374,6 +374,27 @@ namespace Bloxstrap } } + Process[] processes = Process.GetProcessesByName("RobloxPlayerBeta"); +#if STUDIO_FEATURES + if (_launchMode == LaunchMode.Studio) + processes = Process.GetProcessesByName("RobloxStudioBeta"); +#endif + + ProcessPriorityClass[] PriorityThing = { + ProcessPriorityClass.Idle, + ProcessPriorityClass.BelowNormal, + ProcessPriorityClass.Normal, + ProcessPriorityClass.AboveNormal, + ProcessPriorityClass.High + }; + + foreach (Process proc in processes) + { + proc.PriorityClass = PriorityThing[(int)App.Settings.Prop.ChoosePriorityClass]; + + App.Logger.WriteLine(LOG_IDENT, $"Launching with priority '{proc.PriorityClass}'"); + } + // event fired, wait for 3 seconds then close await Task.Delay(3000); Dialog?.CloseBootstrapper(); diff --git a/Bloxstrap/Enums/PriorityClass.cs b/Bloxstrap/Enums/PriorityClass.cs new file mode 100644 index 0000000..3d10285 --- /dev/null +++ b/Bloxstrap/Enums/PriorityClass.cs @@ -0,0 +1,11 @@ +namespace Bloxstrap.Enums +{ + public enum PriorityClasses + { + Idle, + BelowNormal, + Normal, + AboveNormal, + High + } +} \ No newline at end of file diff --git a/Bloxstrap/Models/Settings.cs b/Bloxstrap/Models/Settings.cs index 3bc2580..0384b69 100644 --- a/Bloxstrap/Models/Settings.cs +++ b/Bloxstrap/Models/Settings.cs @@ -10,6 +10,7 @@ namespace Bloxstrap.Models public string BootstrapperTitle { get; set; } = App.ProjectName; public string BootstrapperIconCustomLocation { get; set; } = ""; public Theme Theme { get; set; } = Theme.Default; + public PriorityClasses ChoosePriorityClass { get; set; } = PriorityClasses.Normal; public bool CheckForUpdates { get; set; } = true; public bool CreateDesktopIcon { get; set; } = true; public bool ConfirmLaunches { get; set; } = false; diff --git a/Bloxstrap/Resources/Strings.Designer.cs b/Bloxstrap/Resources/Strings.Designer.cs index bf92399..b5f86d3 100644 --- a/Bloxstrap/Resources/Strings.Designer.cs +++ b/Bloxstrap/Resources/Strings.Designer.cs @@ -2963,5 +2963,77 @@ namespace Bloxstrap.Resources { return ResourceManager.GetString("Uninstaller.Uninstall", resourceCulture); } } + + /// + /// Looks up a localized string similar to Change the priority class Roblox uses.. + /// + public static string Menu_Behaviour_ChangePriorityClass_Description { + get { + return ResourceManager.GetString("Menu.Behaviour.ChangePriorityClass.Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Set priority. + /// + public static string Menu_Behaviour_ChangePriorityClass_Title { + get { + return ResourceManager.GetString("Menu.Behaviour.ChangePriorityClass.Title", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Low. + /// + public static string Enums_PriorityClasses_Idle { + get { + return ResourceManager.GetString("Enums.PriorityClasses.Idle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Below normal. + /// + public static string Enums_PriorityClasses_BelowNormal { + get { + return ResourceManager.GetString("Enums.PriorityClasses.BelowNormal", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Normal. + /// + public static string Enums_PriorityClasses_Normal { + get { + return ResourceManager.GetString("Enums.PriorityClasses.Normal", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Above normal. + /// + public static string Enums_PriorityClasses_AboveNormal { + get { + return ResourceManager.GetString("Enums.PriorityClasses.AboveNormal", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to High. + /// + public static string Enums_PriorityClasses_High { + get { + return ResourceManager.GetString("Enums.PriorityClasses.High", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Realtime. + /// + public static string Enums_PriorityClasses_RealTime { + get { + return ResourceManager.GetString("Enums.PriorityClasses.RealTime", resourceCulture); + } + } } } diff --git a/Bloxstrap/Resources/Strings.resx b/Bloxstrap/Resources/Strings.resx index 234c918..82f5b44 100644 --- a/Bloxstrap/Resources/Strings.resx +++ b/Bloxstrap/Resources/Strings.resx @@ -1120,4 +1120,28 @@ If not, then please report this exception to the maintainers of this fork. Do NO Create shortcuts for quick access to specific functions. These will all be placed on the Desktop. + + Set priority + + + Change the priority class Roblox uses. + + + Low + + + Below normal + + + Normal + + + Above normal + + + High + + + Realtime + \ No newline at end of file diff --git a/Bloxstrap/UI/Elements/Settings/Pages/BehaviourPage.xaml b/Bloxstrap/UI/Elements/Settings/Pages/BehaviourPage.xaml index 9bb7ef7..c902631 100644 --- a/Bloxstrap/UI/Elements/Settings/Pages/BehaviourPage.xaml +++ b/Bloxstrap/UI/Elements/Settings/Pages/BehaviourPage.xaml @@ -17,6 +17,18 @@ + + + + + + + + + + diff --git a/Bloxstrap/UI/ViewModels/Settings/BehaviourViewModel.cs b/Bloxstrap/UI/ViewModels/Settings/BehaviourViewModel.cs index dc2945e..8260cbe 100644 --- a/Bloxstrap/UI/ViewModels/Settings/BehaviourViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Settings/BehaviourViewModel.cs @@ -5,6 +5,14 @@ private string _oldPlayerVersionGuid = ""; private string _oldStudioVersionGuid = ""; + public IEnumerable PriorityClassesList { get; } = Enum.GetValues(typeof(PriorityClasses)).Cast(); + + public PriorityClasses ChoosePriorityClass + { + get => App.Settings.Prop.ChoosePriorityClass; + set => App.Settings.Prop.ChoosePriorityClass = value; + } + public bool CreateDesktopIcon { get => App.Settings.Prop.CreateDesktopIcon;