From 1f40efd10d12392d8427856b6d01bde9f60122fc Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Sat, 15 Apr 2023 01:41:11 +0100 Subject: [PATCH] Add manual channel entry (#132) --- Bloxstrap/Helpers/DeployManager.cs | 31 ++----- Bloxstrap/ViewModels/InstallationViewModel.cs | 88 +++++++++---------- Bloxstrap/Views/Pages/InstallationPage.xaml | 7 +- Bloxstrap/Views/Pages/ModsPage.xaml | 2 +- 4 files changed, 51 insertions(+), 77 deletions(-) diff --git a/Bloxstrap/Helpers/DeployManager.cs b/Bloxstrap/Helpers/DeployManager.cs index 40d0165..77f8b77 100644 --- a/Bloxstrap/Helpers/DeployManager.cs +++ b/Bloxstrap/Helpers/DeployManager.cs @@ -19,35 +19,16 @@ namespace Bloxstrap.Helpers public string BaseUrl { get; private set; } = DefaultBaseUrl; public string Channel { get; private set; } = DefaultChannel; - // basically any channel that has had a deploy within the past month with a windowsplayer build - public static readonly List ChannelsAbstracted = new() + // most commonly used/interesting channels + public static readonly List SelectableChannels = new() { "LIVE", - "ZNext", - "ZCanary", - "ZIntegration" - }; - - // why not? - public static readonly List ChannelsAll = new() - { - "LIVE", - "ZAvatarTeam", - "ZAvatarRelease", - "ZCanary", - "ZCanary1", - "ZCanary2", - "ZCanary3", - "ZCanaryApps", "ZFlag", - "ZIntegration", - "ZIntegration1", - "ZLive", - "ZLive1", "ZNext", - "ZSocialTeam", - "ZStudioInt1", - "ZStudioInt2" + "ZCanary", + "ZIntegration", + "ZAvatarTeam", + "ZSocialTeam" }; #endregion diff --git a/Bloxstrap/ViewModels/InstallationViewModel.cs b/Bloxstrap/ViewModels/InstallationViewModel.cs index 86cee6d..81e40d5 100644 --- a/Bloxstrap/ViewModels/InstallationViewModel.cs +++ b/Bloxstrap/ViewModels/InstallationViewModel.cs @@ -1,17 +1,15 @@ -using Bloxstrap.Enums; -using System; +using System; using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; using System.Linq; -using System.Text; using System.Threading.Tasks; +using System.Windows; +using System.Windows.Forms; using System.Windows.Input; using CommunityToolkit.Mvvm.Input; -using System.Windows.Forms; -using Wpf.Ui.Mvvm.Interfaces; -using System.ComponentModel; using Bloxstrap.Helpers; using Bloxstrap.Models; -using System.Diagnostics; namespace Bloxstrap.ViewModels { @@ -20,14 +18,13 @@ namespace Bloxstrap.ViewModels public event PropertyChangedEventHandler? PropertyChanged; public void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - private IEnumerable _channels = DeployManager.ChannelsAbstracted.Contains(App.Settings.Prop.Channel) ? DeployManager.ChannelsAbstracted : DeployManager.ChannelsAll; - private bool _showAllChannels = !DeployManager.ChannelsAbstracted.Contains(App.Settings.Prop.Channel); + private bool _manualChannelEntry = !DeployManager.SelectableChannels.Contains(App.Settings.Prop.Channel); public ICommand BrowseInstallLocationCommand => new RelayCommand(BrowseInstallLocation); public ICommand OpenFolderCommand => new RelayCommand(OpenFolder); - - public DeployInfo? ChannelDeployInfo { get; private set; } = null; //new DeployInfo(){ Version = "hi", VersionGuid = "hi", Timestamp = "January 25 2023 at 6:03:48 PM" }; + public DeployInfo? ChannelDeployInfo { get; private set; } = null; + public string ChannelInfoLoadingText { get; private set; } = null!; public InstallationViewModel() { @@ -36,20 +33,32 @@ namespace Bloxstrap.ViewModels private async Task LoadChannelDeployInfo(string channel) { + ChannelInfoLoadingText = "Fetching latest deploy info, please wait..."; + OnPropertyChanged(nameof(ChannelInfoLoadingText)); + ChannelDeployInfo = null; OnPropertyChanged(nameof(ChannelDeployInfo)); App.DeployManager.SetChannel(channel); - ClientVersion info = await App.DeployManager.GetLastDeploy(true); - ChannelDeployInfo = new DeployInfo + try { - Version = info.Version, - VersionGuid = info.VersionGuid, - Timestamp = info.Timestamp?.ToString("dddd, d MMMM yyyy 'at' h:mm:ss tt", App.CultureFormat)! - }; + ClientVersion info = await App.DeployManager.GetLastDeploy(true); - OnPropertyChanged(nameof(ChannelDeployInfo)); + ChannelDeployInfo = new DeployInfo + { + Version = info.Version, + VersionGuid = info.VersionGuid, + Timestamp = info.Timestamp?.ToString("dddd, d MMMM yyyy 'at' h:mm:ss tt", App.CultureFormat)! + }; + + OnPropertyChanged(nameof(ChannelDeployInfo)); + } + catch (Exception) + { + ChannelInfoLoadingText = "Failed to get deploy info.\nIs the channel name valid?"; + OnPropertyChanged(nameof(ChannelInfoLoadingText)); + } } private void BrowseInstallLocation() @@ -74,53 +83,36 @@ namespace Bloxstrap.ViewModels set => App.BaseDirectory = value; } - public IEnumerable Channels - { - get - { - if (_channels == DeployManager.ChannelsAll && !_channels.Contains(App.Settings.Prop.Channel)) - _channels = _channels.Append(App.Settings.Prop.Channel); - - return _channels; - } - set => _channels = value; - } + public IEnumerable Channels => DeployManager.SelectableChannels; public string Channel { get => App.Settings.Prop.Channel; set { - //Task.Run(() => GetChannelInfo(value)); Task.Run(() => LoadChannelDeployInfo(value)); App.Settings.Prop.Channel = value; } } - public bool ShowAllChannels + public bool ManualChannelEntry { - get => _showAllChannels; + get => _manualChannelEntry; set { - if (value) - { - Channels = DeployManager.ChannelsAll; - } - else - { - Channels = DeployManager.ChannelsAbstracted; + _manualChannelEntry = value; - if (!Channels.Contains(Channel)) - { - Channel = DeployManager.DefaultChannel; - OnPropertyChanged(nameof(Channel)); - } - } + if (!value && !Channels.Contains(Channel)) + Channel = DeployManager.DefaultChannel; - OnPropertyChanged(nameof(Channels)); - - _showAllChannels = value; + OnPropertyChanged(nameof(Channel)); + OnPropertyChanged(nameof(ChannelComboBoxVisibility)); + OnPropertyChanged(nameof(ChannelTextBoxVisibility)); } } + + // cant use data bindings so i have to do whatever tf this is + public Visibility ChannelComboBoxVisibility => ManualChannelEntry ? Visibility.Collapsed : Visibility.Visible; + public Visibility ChannelTextBoxVisibility => ManualChannelEntry ? Visibility.Visible : Visibility.Collapsed; } } diff --git a/Bloxstrap/Views/Pages/InstallationPage.xaml b/Bloxstrap/Views/Pages/InstallationPage.xaml index 6142e79..a67d256 100644 --- a/Bloxstrap/Views/Pages/InstallationPage.xaml +++ b/Bloxstrap/Views/Pages/InstallationPage.xaml @@ -59,7 +59,8 @@ - + + @@ -114,10 +115,10 @@ - + - + diff --git a/Bloxstrap/Views/Pages/ModsPage.xaml b/Bloxstrap/Views/Pages/ModsPage.xaml index 107515a..c6360f4 100644 --- a/Bloxstrap/Views/Pages/ModsPage.xaml +++ b/Bloxstrap/Views/Pages/ModsPage.xaml @@ -135,7 +135,7 @@ - +