Skip to content

Commit

Permalink
use a function for byfron dialog version text
Browse files Browse the repository at this point in the history
  • Loading branch information
bluepilledgreat committed Oct 5, 2023
1 parent c46a4ec commit cf963c4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
3 changes: 2 additions & 1 deletion Bloxstrap/UI/Elements/Bootstrapper/ByfronDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public bool CancelEnabled

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();
Expand Down
27 changes: 3 additions & 24 deletions Bloxstrap/UI/ViewModels/Bootstrapper/ByfronDialogViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -18,30 +16,11 @@ public class ByfronDialogViewModel : BootstrapperDialogViewModel

public Visibility VersionTextVisibility => CancelEnabled ? Visibility.Collapsed : Visibility.Visible;

public string VersionText
{
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 string VersionText { get; init; }

public ByfronDialogViewModel(IBootstrapperDialog dialog, bool isStudioLaunch) : base(dialog)
public ByfronDialogViewModel(IBootstrapperDialog dialog, string version) : base(dialog)
{
_studioLaunch = isStudioLaunch;
VersionText = version;
}
}
}
18 changes: 18 additions & 0 deletions Bloxstrap/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,23 @@ public static int CompareVersions(string versionStr1, string versionStr2)

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(", ", ".");
}
}
}

0 comments on commit cf963c4

Please sign in to comment.