From cf963c4bdabc21a8460d4675b269f1a75bb6bb80 Mon Sep 17 00:00:00 2001 From: bluepilledgreat <97983689+bluepilledgreat@users.noreply.github.com> Date: Thu, 5 Oct 2023 17:23:20 +0100 Subject: [PATCH] use a function for byfron dialog version text --- .../Bootstrapper/ByfronDialog.xaml.cs | 3 +- .../Bootstrapper/ByfronDialogViewModel.cs | 29 +++---------------- Bloxstrap/Utilities.cs | 18 ++++++++++++ 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/Bloxstrap/UI/Elements/Bootstrapper/ByfronDialog.xaml.cs b/Bloxstrap/UI/Elements/Bootstrapper/ByfronDialog.xaml.cs index e90245a..c94bf59 100644 --- a/Bloxstrap/UI/Elements/Bootstrapper/ByfronDialog.xaml.cs +++ b/Bloxstrap/UI/Elements/Bootstrapper/ByfronDialog.xaml.cs @@ -69,7 +69,8 @@ namespace Bloxstrap.UI.Elements.Bootstrapper public ByfronDialog() { - _viewModel = new ByfronDialogViewModel(this, Bootstrapper?.IsStudioLaunch ?? false); + string version = Utilities.GetRobloxVersion(Bootstrapper?.IsStudioLaunch ?? false); + _viewModel = new ByfronDialogViewModel(this, version); DataContext = _viewModel; Title = App.Settings.Prop.BootstrapperTitle; Icon = App.Settings.Prop.BootstrapperIcon.GetIcon().GetImageSource(); diff --git a/Bloxstrap/UI/ViewModels/Bootstrapper/ByfronDialogViewModel.cs b/Bloxstrap/UI/ViewModels/Bootstrapper/ByfronDialogViewModel.cs index 46d1e0b..f652499 100644 --- a/Bloxstrap/UI/ViewModels/Bootstrapper/ByfronDialogViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Bootstrapper/ByfronDialogViewModel.cs @@ -6,8 +6,6 @@ namespace Bloxstrap.UI.ViewModels.Bootstrapper { public class ByfronDialogViewModel : BootstrapperDialogViewModel { - private bool _studioLaunch; - // Using dark theme for default values. public ImageSource ByfronLogoLocation { get; set; } = new BitmapImage(new Uri("pack://application:,,,/Resources/BootstrapperStyles/ByfronDialog/ByfronLogoDark.jpg")); public Thickness DialogBorder { get; set; } = new Thickness(0); @@ -18,30 +16,11 @@ namespace Bloxstrap.UI.ViewModels.Bootstrapper public Visibility VersionTextVisibility => CancelEnabled ? Visibility.Collapsed : Visibility.Visible; - public string VersionText + public string VersionText { get; init; } + + public ByfronDialogViewModel(IBootstrapperDialog dialog, string version) : base(dialog) { - get - { - string versionGuid = _studioLaunch ? App.State.Prop.StudioVersionGuid : App.State.Prop.PlayerVersionGuid; - string fileName = _studioLaunch ? "RobloxStudioBeta.exe" : "RobloxPlayerBeta.exe"; - - string playerLocation = Path.Combine(Paths.Versions, versionGuid, fileName); - - if (!File.Exists(playerLocation)) - return ""; - - FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(playerLocation); - - if (versionInfo.ProductVersion is null) - return ""; - - return versionInfo.ProductVersion.Replace(", ", "."); - } - } - - public ByfronDialogViewModel(IBootstrapperDialog dialog, bool isStudioLaunch) : base(dialog) - { - _studioLaunch = isStudioLaunch; + VersionText = version; } } } diff --git a/Bloxstrap/Utilities.cs b/Bloxstrap/Utilities.cs index 565dc79..7f33a19 100644 --- a/Bloxstrap/Utilities.cs +++ b/Bloxstrap/Utilities.cs @@ -47,5 +47,23 @@ namespace Bloxstrap return version1.CompareTo(version2); } + + public static string GetRobloxVersion(bool studio) + { + string versionGuid = studio ? App.State.Prop.StudioVersionGuid : App.State.Prop.PlayerVersionGuid; + string fileName = studio ? "RobloxStudioBeta.exe" : "RobloxPlayerBeta.exe"; + + string playerLocation = Path.Combine(Paths.Versions, versionGuid, fileName); + + if (!File.Exists(playerLocation)) + return ""; + + FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(playerLocation); + + if (versionInfo.ProductVersion is null) + return ""; + + return versionInfo.ProductVersion.Replace(", ", "."); + } } }