added more fucking stuff that i dont know how it works
This commit is contained in:
parent
6892bc2a47
commit
f9a593f234
69
EZPPClient Installer/DownloadUtil.cs
Normal file
69
EZPPClient Installer/DownloadUtil.cs
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
using ModernWpf.Controls;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace EZPPClient_Installer
|
||||||
|
{
|
||||||
|
public class DownloadUtil
|
||||||
|
{
|
||||||
|
|
||||||
|
public static List<string> FilesToDownload(string pathToEZPP)
|
||||||
|
{
|
||||||
|
bool directoryExists = Directory.Exists(pathToEZPP);
|
||||||
|
|
||||||
|
List<string> downloadList = new List<string>();
|
||||||
|
List<MD5File> md5Files = new List<MD5File>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
using (WebClient wc = new WebClient())
|
||||||
|
{
|
||||||
|
var data = wc.DownloadString("https://ez-pp.farm/static/client/client.data");
|
||||||
|
string[] dataList = data.Split('\n');
|
||||||
|
foreach (string datastring in dataList)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(datastring))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string[] se = datastring.Split('#');
|
||||||
|
string md5 = se[0];
|
||||||
|
string name = se[1];
|
||||||
|
md5Files.Add(new MD5File(name, md5));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(WebException error)
|
||||||
|
{
|
||||||
|
new ContentDialog()
|
||||||
|
{
|
||||||
|
Title = "Oops...",
|
||||||
|
Content = "A error occurred while trying to fetch all needed Files.\n" + error.Message,
|
||||||
|
PrimaryButtonText = "Okay"
|
||||||
|
}.ShowAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!directoryExists)
|
||||||
|
{
|
||||||
|
foreach (MD5File md5File in md5Files)
|
||||||
|
downloadList.Add(md5File.getName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return downloadList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> CheckForUpdate()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -74,6 +74,9 @@
|
||||||
<DependentUpon>App.xaml</DependentUpon>
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="MD5File.cs" />
|
||||||
|
<Compile Include="DownloadUtil.cs" />
|
||||||
|
<Compile Include="UpdateState.cs" />
|
||||||
<Compile Include="Util.cs" />
|
<Compile Include="Util.cs" />
|
||||||
<Compile Include="MainWindow.xaml.cs">
|
<Compile Include="MainWindow.xaml.cs">
|
||||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||||
|
|
33
EZPPClient Installer/MD5File.cs
Normal file
33
EZPPClient Installer/MD5File.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EZPPClient_Installer
|
||||||
|
{
|
||||||
|
class MD5File
|
||||||
|
{
|
||||||
|
|
||||||
|
private string md5;
|
||||||
|
private string name;
|
||||||
|
|
||||||
|
public MD5File(string name, string md5)
|
||||||
|
{
|
||||||
|
this.md5 = md5;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string getMD5()
|
||||||
|
{
|
||||||
|
return md5;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,14 +9,15 @@
|
||||||
xmlns:ui="http://schemas.modernwpf.com/2019"
|
xmlns:ui="http://schemas.modernwpf.com/2019"
|
||||||
ui:WindowHelper.UseModernWindowStyle="True" ResizeMode="CanMinimize" Icon="circle_new.ico" Topmost="True" WindowStartupLocation="CenterScreen">
|
ui:WindowHelper.UseModernWindowStyle="True" ResizeMode="CanMinimize" Icon="circle_new.ico" Topmost="True" WindowStartupLocation="CenterScreen">
|
||||||
<ui:SimpleStackPanel Margin="12" Spacing="24">
|
<ui:SimpleStackPanel Margin="12" Spacing="24">
|
||||||
<CheckBox x:Name="linkFoldersCheckbox" Content="Link Song and Skins Folder" HorizontalAlignment="Stretch" Height="32" VerticalAlignment="Top" Margin="150,73,150,-73" IsChecked="True" />
|
<CheckBox x:Name="linkFoldersCheckbox" Content="Link Song and Skins Folder" HorizontalAlignment="Stretch" Height="32" VerticalAlignment="Top" Margin="150,62,150,-62" IsChecked="True" />
|
||||||
<TextBox x:Name="folderTextbox" HorizontalAlignment="Left" Height="32" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="422" Margin="10,-34,0,0" IsReadOnly="true"/>
|
<TextBox x:Name="folderTextbox" HorizontalAlignment="Left" Height="32" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="422" Margin="10,-34,0,0" IsReadOnly="true"/>
|
||||||
<Button x:Name="InstallButton" Content="Install" HorizontalAlignment="Stretch" Height="32" VerticalAlignment="Bottom" Margin="176,0,176,-73" Style="{StaticResource AccentButtonStyle}" Click="Install_Click"/>
|
<Button x:Name="InstallButton" Content="Install" HorizontalAlignment="Stretch" Height="32" VerticalAlignment="Bottom" Margin="176,0,176,-58" Style="{StaticResource AccentButtonStyle}" Click="Install_Click"/>
|
||||||
<Label HorizontalAlignment="Left" Height="19" VerticalAlignment="Top" Width="149" Margin="360,59,-12,-59" Cursor="Hand" RenderTransformOrigin="0.492,0.509">
|
<Label HorizontalAlignment="Left" Height="19" VerticalAlignment="Top" Width="149" Margin="360,59,-12,-59" Cursor="Hand" RenderTransformOrigin="0.492,0.509">
|
||||||
<TextBlock Height="19" Width="149">
|
<TextBlock Height="19" Width="149">
|
||||||
<Hyperlink NavigateUri="https://ez-pp.farm" RequestNavigate="Hyperlink_RequestNavigate"><Run Text="Copyright @ EZPPFarm"/></Hyperlink>
|
<Hyperlink NavigateUri="https://ez-pp.farm" RequestNavigate="Hyperlink_RequestNavigate"><Run Text="Copyright @ EZPPFarm"/></Hyperlink>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</Label>
|
</Label>
|
||||||
<Button Content="..." HorizontalAlignment="Stretch" Height="32" VerticalAlignment="Top" Margin="437,-125,10,0" Click="Browse_Click"/>
|
<Button Content="..." HorizontalAlignment="Stretch" Height="32" VerticalAlignment="Top" Margin="437,-125,10,0" Click="Browse_Click"/>
|
||||||
|
<Button x:Name="Uninstall_Button" Content="Uninstall" HorizontalAlignment="Stretch" Height="31" VerticalAlignment="Bottom" Margin="176,-28,176,-3" Click="Install_Click" Background="#CCCB3737" Foreground="White" Visibility="Hidden"/>
|
||||||
</ui:SimpleStackPanel>
|
</ui:SimpleStackPanel>
|
||||||
</Window>
|
</Window>
|
||||||
|
|
|
@ -37,6 +37,7 @@ namespace EZPPClient_Installer
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
DownloadUtil.FilesToDownload("yeet");
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,14 +46,14 @@ namespace EZPPClient_Installer
|
||||||
|
|
||||||
UpdateInstallButton(false);
|
UpdateInstallButton(false);
|
||||||
|
|
||||||
UpdateStatus status = await CheckForUpdates();
|
UpdateState status = await CheckForInstallerUpdates();
|
||||||
|
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case UpdateStatus.UpdateFound:
|
case UpdateState.UpdateFound:
|
||||||
ShowUpdateDialog();
|
ShowInstallerUpdateDialog();
|
||||||
return;
|
return;
|
||||||
case UpdateStatus.Error:
|
case UpdateState.Error:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +69,13 @@ namespace EZPPClient_Installer
|
||||||
{
|
{
|
||||||
bool foundInstall = await isEZPPClientInstallationFound(osuPath);
|
bool foundInstall = await isEZPPClientInstallationFound(osuPath);
|
||||||
if (foundInstall)
|
if (foundInstall)
|
||||||
InstallButton.Content = "Uninstall";
|
{
|
||||||
|
Uninstall_Button.Visibility = Visibility.Visible;
|
||||||
|
UpdateInstallButton(false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
folderTextbox.Text = osuPath;
|
folderTextbox.Text = osuPath;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +89,7 @@ namespace EZPPClient_Installer
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<UpdateStatus> CheckForUpdates()
|
private async Task<UpdateState> CheckForInstallerUpdates()
|
||||||
{
|
{
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
|
@ -100,16 +107,16 @@ namespace EZPPClient_Installer
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ver > VERSION)
|
if (ver > VERSION)
|
||||||
return UpdateStatus.UpdateFound;
|
return UpdateState.UpdateFound;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (WebException e)
|
catch (WebException e)
|
||||||
{
|
{
|
||||||
ShowErrorDialog(e.Message);
|
ShowErrorDialog(e.Message);
|
||||||
return UpdateStatus.Error;
|
return UpdateState.Error;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return UpdateStatus.UpToDate;
|
return UpdateState.UpToDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void ShowErrorDialog(string error)
|
private async void ShowErrorDialog(string error)
|
||||||
|
@ -124,8 +131,9 @@ namespace EZPPClient_Installer
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void ShowUpdateDialog()
|
private async void ShowInstallerUpdateDialog()
|
||||||
{
|
{
|
||||||
|
UpdateInstallButton(false);
|
||||||
var dialog = new ContentDialog()
|
var dialog = new ContentDialog()
|
||||||
{
|
{
|
||||||
Title = "New version available.",
|
Title = "New version available.",
|
||||||
|
@ -137,7 +145,7 @@ namespace EZPPClient_Installer
|
||||||
if (result == ContentDialogResult.Primary)
|
if (result == ContentDialogResult.Primary)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Process.Start("https://ez-pp.farm/download");
|
System.Diagnostics.Process.Start("https://ez-pp.farm/download");
|
||||||
ShowUpdateDialog();
|
ShowInstallerUpdateDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,8 +204,15 @@ namespace EZPPClient_Installer
|
||||||
folderTextbox.Text = fbd.SelectedPath;
|
folderTextbox.Text = fbd.SelectedPath;
|
||||||
|
|
||||||
if (foundInstall)
|
if (foundInstall)
|
||||||
InstallButton.Content = "Uninstall";
|
{
|
||||||
|
Uninstall_Button.Visibility = Visibility.Visible;
|
||||||
|
UpdateInstallButton(false);
|
||||||
|
|
||||||
|
string osuEZPPPath = folderTextbox.Text + @"\EZPPClient";
|
||||||
|
|
||||||
|
List<string> outdatedFiles = DownloadUtil.FilesToDownload(osuEZPPPath)
|
||||||
|
|
||||||
|
}else
|
||||||
UpdateInstallButton(true);
|
UpdateInstallButton(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,11 +273,6 @@ namespace EZPPClient_Installer
|
||||||
File,
|
File,
|
||||||
Directory
|
Directory
|
||||||
}
|
}
|
||||||
private enum UpdateStatus
|
|
||||||
{
|
|
||||||
UpdateFound,
|
|
||||||
UpToDate,
|
|
||||||
Error
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
9
EZPPClient Installer/UpdateState.cs
Normal file
9
EZPPClient Installer/UpdateState.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
namespace EZPPClient_Installer
|
||||||
|
{
|
||||||
|
public enum UpdateState
|
||||||
|
{
|
||||||
|
UpdateFound,
|
||||||
|
UpToDate,
|
||||||
|
Error
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user