Added a Release Stream Picker
This commit is contained in:
		| @@ -90,13 +90,14 @@ | ||||
|       <DependentUpon>App.xaml</DependentUpon> | ||||
|       <SubType>Code</SubType> | ||||
|     </Compile> | ||||
|     <Compile Include="MD5File.cs" /> | ||||
|     <Compile Include="DownloadUtil.cs" /> | ||||
|     <Compile Include="MD5Util.cs" /> | ||||
|     <Compile Include="ProcessUtil.cs" /> | ||||
|     <Compile Include="Shortcut.cs" /> | ||||
|     <Compile Include="UpdateState.cs" /> | ||||
|     <Compile Include="Util.cs" /> | ||||
|     <Compile Include="Objects\MD5File.cs" /> | ||||
|     <Compile Include="Utils\DownloadUtil.cs" /> | ||||
|     <Compile Include="Utils\MD5Util.cs" /> | ||||
|     <Compile Include="Utils\ProcessUtil.cs" /> | ||||
|     <Compile Include="Utils\ReleaseStreamUtil.cs" /> | ||||
|     <Compile Include="Objects\Shortcut.cs" /> | ||||
|     <Compile Include="Objects\UpdateState.cs" /> | ||||
|     <Compile Include="Utils\OsuUtil.cs" /> | ||||
|     <Compile Include="MainWindow.xaml.cs"> | ||||
|       <DependentUpon>MainWindow.xaml</DependentUpon> | ||||
|       <SubType>Code</SubType> | ||||
| @@ -149,5 +150,6 @@ | ||||
|   <ItemGroup> | ||||
|     <Content Include=".gitignore" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup /> | ||||
|   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||||
| </Project> | ||||
| @@ -5,7 +5,7 @@ | ||||
|         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
|         xmlns:local="clr-namespace:EZPPClient_Installer" | ||||
|         mc:Ignorable="d" | ||||
|         Title="EZPPClient Installer" Height="232.051" Width="525.487" | ||||
|         Title="EZPPClient Installer" Height="237.051" Width="525.487" | ||||
|         xmlns:ui="http://schemas.modernwpf.com/2019" | ||||
|     ui:WindowHelper.UseModernWindowStyle="True" ResizeMode="CanMinimize" Icon="circle_new.ico" Topmost="True" WindowStartupLocation="CenterScreen"> | ||||
|     <ui:SimpleStackPanel Margin="12" Spacing="24"> | ||||
| @@ -16,6 +16,8 @@ | ||||
|         <Button x:Name="Uninstall_Button" Content="Uninstall" HorizontalAlignment="Stretch" Height="31" VerticalAlignment="Bottom" Margin="176,0,176,-47" Click="Uninstall_Button_Click" Background="#CCCB3737" Foreground="White" Visibility="Hidden"/> | ||||
|         <ProgressBar x:Name="Download_Progressbar" Height="1" VerticalAlignment="Top" Margin="15,-34,15,0" IsIndeterminate="True" Visibility="Hidden"/> | ||||
|         <Label x:Name="Download_Text" Content="Downloading: " Height="19" VerticalAlignment="Top" Margin="10,-82,10,0" Visibility="Hidden"/> | ||||
|         <TextBlock Margin="349,-47,0,24"><Hyperlink NavigateUri="https://ez-pp.farm" RequestNavigate="Hyperlink_RequestNavigate"><Run Text="Copyright @ EZPPFarm"/></Hyperlink></TextBlock> | ||||
|         <TextBlock Margin="349,-38,0,15"><Hyperlink NavigateUri="https://ez-pp.farm" RequestNavigate="Hyperlink_RequestNavigate"><Run Text="Copyright @ EZPPFarm"/></Hyperlink></TextBlock> | ||||
|         <ComboBox x:Name="ReleaseStreamComboBox" HorizontalAlignment="Left" Height="31" VerticalAlignment="Top" Width="171" Margin="0,-80,0,0" ClipToBounds="True" SelectionChanged="ReleaseStreamComboBox_SelectionChanged"/> | ||||
|         <Label x:Name="ReleaseStreamLabel" Content="Release:" HorizontalAlignment="Left" Height="19" VerticalAlignment="Top" Width="145" Margin="0,-128,0,0"/> | ||||
|     </ui:SimpleStackPanel> | ||||
| </Window> | ||||
|   | ||||
| @@ -35,6 +35,8 @@ namespace EZPPClient_Installer | ||||
|  | ||||
|     private static double VERSION = 1.6; | ||||
|  | ||||
|     public static string RELEASESTREAM; | ||||
|  | ||||
|     public MainWindow() | ||||
|     { | ||||
|       Instance = this; | ||||
| @@ -62,6 +64,8 @@ namespace EZPPClient_Installer | ||||
|       string versionString = "v" + VERSION; | ||||
|       InstallerWindow.Title = "EZPPClient Installer " + versionString.Replace(",", "."); | ||||
|  | ||||
|       await FetchReleaseStreams(); | ||||
|  | ||||
|       string osuPath = OsuUtil.osuInstallDir(); | ||||
|  | ||||
|       if (osuPath.EndsWith(@"\EZPPClient")) | ||||
| @@ -83,7 +87,7 @@ namespace EZPPClient_Installer | ||||
|           UpdateInstallButton(false); | ||||
|  | ||||
|  | ||||
|           List<string> outdatedFiles = DownloadUtil.FilesToDownload(osuEZPPPath, false); | ||||
|           List<string> outdatedFiles = await DownloadUtil.FilesToDownload(osuEZPPPath, false); | ||||
|  | ||||
|           if (!IsEmpty(outdatedFiles)) | ||||
|           { | ||||
| @@ -105,6 +109,16 @@ namespace EZPPClient_Installer | ||||
|  | ||||
|     } | ||||
|  | ||||
|     private async Task FetchReleaseStreams() | ||||
|     { | ||||
|       List<string> releases = await ReleaseStreamUtil.GetAvailableReleaseStreams(); | ||||
|       foreach(string release in releases) | ||||
|       { | ||||
|         ReleaseStreamComboBox.Items.Add(release.UppercaseFirst()); | ||||
|       } | ||||
|       ReleaseStreamComboBox.SelectedIndex = 0; | ||||
|     } | ||||
|  | ||||
|     private async Task<UpdateState> CheckForInstallerUpdates() | ||||
|     { | ||||
| #if !DEBUG | ||||
| @@ -372,16 +386,20 @@ namespace EZPPClient_Installer | ||||
|  | ||||
|  | ||||
|  | ||||
|       List<string> filesToDownload = DownloadUtil.FilesToDownload(EZPPFolder, InstallButton.Content.Equals("Reinstall")); | ||||
|       List<string> filesToDownload = await DownloadUtil.FilesToDownload(EZPPFolder, InstallButton.Content.Equals("Reinstall")); | ||||
|  | ||||
|       Visibility prevInstallBtnVis = InstallButton.Visibility; | ||||
|       Visibility prevUninstallBtnVis = Uninstall_Button.Visibility; | ||||
|       Visibility prevLinkFCVis = linkFoldersCheckbox.Visibility; | ||||
|       Visibility prevReleaseLabelVis = ReleaseStreamLabel.Visibility; | ||||
|       Visibility prevReleasesVis = ReleaseStreamComboBox.Visibility; | ||||
|  | ||||
|       BrowseButton.IsEnabled = false; | ||||
|       InstallButton.Visibility = Visibility.Hidden; | ||||
|       Uninstall_Button.Visibility = Visibility.Hidden; | ||||
|       linkFoldersCheckbox.Visibility = Visibility.Hidden; | ||||
|       ReleaseStreamComboBox.Visibility = Visibility.Hidden; | ||||
|       ReleaseStreamLabel.Visibility = Visibility.Hidden; | ||||
|  | ||||
|       Download_Text.Visibility = Visibility.Visible; | ||||
|       Download_Progressbar.Visibility = Visibility.Visible; | ||||
| @@ -407,6 +425,8 @@ namespace EZPPClient_Installer | ||||
|       InstallButton.Visibility = prevInstallBtnVis; | ||||
|       Uninstall_Button.Visibility = prevUninstallBtnVis; | ||||
|       linkFoldersCheckbox.Visibility = prevLinkFCVis; | ||||
|       ReleaseStreamComboBox.Visibility = prevReleasesVis; | ||||
|       ReleaseStreamLabel.Visibility = prevReleaseLabelVis; | ||||
|       BrowseButton.IsEnabled = true; | ||||
|  | ||||
|       Download_Text.Visibility = Visibility.Hidden; | ||||
| @@ -415,7 +435,7 @@ namespace EZPPClient_Installer | ||||
|       Uninstall_Button.Visibility = Visibility.Visible; | ||||
|       UpdateInstallButton(false); | ||||
|        | ||||
|       List<string> outdatedFiles = DownloadUtil.FilesToDownload(EZPPFolder, false); | ||||
|       List<string> outdatedFiles = await DownloadUtil.FilesToDownload(EZPPFolder, false); | ||||
|  | ||||
|       if (!IsEmpty(outdatedFiles)) | ||||
|       { | ||||
| @@ -509,7 +529,7 @@ namespace EZPPClient_Installer | ||||
|               UpdateInstallButton(false); | ||||
|  | ||||
|               string osuEZPPPath = folderTextbox.Text + @"\EZPPClient"; | ||||
|               List<string> outdatedFiles = DownloadUtil.FilesToDownload(osuEZPPPath, false); | ||||
|               List<string> outdatedFiles = await DownloadUtil.FilesToDownload(osuEZPPPath, false); | ||||
|  | ||||
|               if (!IsEmpty(outdatedFiles)) | ||||
|               { | ||||
| @@ -634,5 +654,53 @@ namespace EZPPClient_Installer | ||||
|       Instance.Download_Progressbar.Value = progress; | ||||
|       Instance.Download_Text.Content = "Downloading: " + file; | ||||
|     } | ||||
|  | ||||
|     private async void ReleaseStreamComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) | ||||
|     { | ||||
|  | ||||
|       bool init = string.IsNullOrEmpty(RELEASESTREAM); | ||||
|  | ||||
|       RELEASESTREAM = (string)ReleaseStreamComboBox.SelectedValue; | ||||
|  | ||||
|       if (init) | ||||
|         return; | ||||
|  | ||||
|       string osuPath = folderTextbox.Text; | ||||
|  | ||||
|       bool isValidFolder = await isValidOsuFolder(osuPath); | ||||
|       UpdateInstallButton(!string.IsNullOrEmpty(osuPath)); | ||||
|  | ||||
|       if (!string.IsNullOrEmpty(osuPath) && isValidFolder) | ||||
|       { | ||||
|         bool foundInstall = isEZPPClientInstallationFound(osuPath); | ||||
|         if (foundInstall) | ||||
|         { | ||||
|           string osuEZPPPath = osuPath + @"\EZPPClient"; | ||||
|  | ||||
|           Uninstall_Button.Visibility = Visibility.Visible; | ||||
|           UpdateInstallButton(false); | ||||
|  | ||||
|  | ||||
|           List<string> outdatedFiles = await DownloadUtil.FilesToDownload(osuEZPPPath, false); | ||||
|  | ||||
|           if (!IsEmpty(outdatedFiles)) | ||||
|           { | ||||
|             UpdateInstallButton(true); | ||||
|             InstallButton.Content = "Update"; | ||||
|             linkFoldersCheckbox.IsEnabled = false; | ||||
|           } | ||||
|         } | ||||
|  | ||||
|         folderTextbox.Text = osuPath; | ||||
|       } | ||||
|  | ||||
|       _ = new ContentDialog() | ||||
|       { | ||||
|         Title = "Success!", | ||||
|         Content = "ReleaseStream changed to " + RELEASESTREAM, | ||||
|         PrimaryButtonText = "Okay" | ||||
|       }.ShowAsync(); | ||||
|  | ||||
|     } | ||||
|   } | ||||
| } | ||||
|   | ||||
							
								
								
									
										48
									
								
								EZPPClient Installer/Utils/ReleaseStreamUtil.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								EZPPClient Installer/Utils/ReleaseStreamUtil.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,48 @@ | ||||
| using ModernWpf.Controls; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Net; | ||||
| using System.Text; | ||||
| using System.Threading.Tasks; | ||||
|  | ||||
| namespace EZPPClient_Installer | ||||
| { | ||||
|   class ReleaseStreamUtil | ||||
|   { | ||||
|  | ||||
|     public static async Task<List<string>> GetAvailableReleaseStreams() | ||||
|     { | ||||
|  | ||||
|       List<string> releaseStreamList = new List<string>(); | ||||
|  | ||||
|       try | ||||
|       { | ||||
|         using (WebClient wc = new WebClient()) | ||||
|         { | ||||
|           wc.Headers.Add("user-agent", "EZPPClientInstaller"); | ||||
|           var data = await wc.DownloadStringTaskAsync("https://new.ez-pp.farm/ezppclient?releases"); | ||||
|           string[] dataList = data.Split('\n'); | ||||
|           foreach (string datastring in dataList) | ||||
|           { | ||||
|             if (string.IsNullOrWhiteSpace(datastring)) | ||||
|               continue; | ||||
|             releaseStreamList.Add(datastring); | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|       catch (WebException error) | ||||
|       { | ||||
|         _ = new ContentDialog() | ||||
|         { | ||||
|           Title = "Oops...", | ||||
|           Content = "A error occurred while trying to fetch the ReleaseStreams.\n" + error.Message, | ||||
|           PrimaryButtonText = "Okay" | ||||
|         }.ShowAsync(); | ||||
|       } | ||||
|  | ||||
|       return releaseStreamList; | ||||
|     } | ||||
|  | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user