added more fucking stuff that i dont know how it works

This commit is contained in:
HorizonCode 2021-05-25 11:04:08 +02:00
parent 6892bc2a47
commit f9a593f234
6 changed files with 149 additions and 24 deletions

View 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;
}
}
}

View File

@ -74,6 +74,9 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MD5File.cs" />
<Compile Include="DownloadUtil.cs" />
<Compile Include="UpdateState.cs" />
<Compile Include="Util.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>

View 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;
}
}
}

View File

@ -9,14 +9,15 @@
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">
<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"/>
<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">
<TextBlock Height="19" Width="149">
<Hyperlink NavigateUri="https://ez-pp.farm" RequestNavigate="Hyperlink_RequestNavigate"><Run Text="Copyright @ EZPPFarm"/></Hyperlink>
</TextBlock>
</Label>
<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>
</Window>

View File

@ -37,6 +37,7 @@ namespace EZPPClient_Installer
public MainWindow()
{
InitializeComponent();
DownloadUtil.FilesToDownload("yeet");
Init();
}
@ -45,14 +46,14 @@ namespace EZPPClient_Installer
UpdateInstallButton(false);
UpdateStatus status = await CheckForUpdates();
UpdateState status = await CheckForInstallerUpdates();
switch (status)
{
case UpdateStatus.UpdateFound:
ShowUpdateDialog();
case UpdateState.UpdateFound:
ShowInstallerUpdateDialog();
return;
case UpdateStatus.Error:
case UpdateState.Error:
return;
}
@ -67,8 +68,14 @@ namespace EZPPClient_Installer
if(!string.IsNullOrEmpty(osuPath) && isValidFolder)
{
bool foundInstall = await isEZPPClientInstallationFound(osuPath);
if(foundInstall)
InstallButton.Content = "Uninstall";
if (foundInstall)
{
Uninstall_Button.Visibility = Visibility.Visible;
UpdateInstallButton(false);
}
folderTextbox.Text = osuPath;
}
@ -82,7 +89,7 @@ namespace EZPPClient_Installer
}
private async Task<UpdateStatus> CheckForUpdates()
private async Task<UpdateState> CheckForInstallerUpdates()
{
#if !DEBUG
try
@ -100,16 +107,16 @@ namespace EZPPClient_Installer
}
if (ver > VERSION)
return UpdateStatus.UpdateFound;
return UpdateState.UpdateFound;
}
}
catch (WebException e)
{
ShowErrorDialog(e.Message);
return UpdateStatus.Error;
return UpdateState.Error;
}
#endif
return UpdateStatus.UpToDate;
return UpdateState.UpToDate;
}
private async void ShowErrorDialog(string error)
@ -124,8 +131,9 @@ namespace EZPPClient_Installer
this.Close();
}
private async void ShowUpdateDialog()
private async void ShowInstallerUpdateDialog()
{
UpdateInstallButton(false);
var dialog = new ContentDialog()
{
Title = "New version available.",
@ -137,7 +145,7 @@ namespace EZPPClient_Installer
if (result == ContentDialogResult.Primary)
{
System.Diagnostics.Process.Start("https://ez-pp.farm/download");
ShowUpdateDialog();
ShowInstallerUpdateDialog();
}
}
@ -194,10 +202,17 @@ namespace EZPPClient_Installer
{
bool foundInstall = await isEZPPClientInstallationFound(fbd.SelectedPath);
folderTextbox.Text = fbd.SelectedPath;
if(foundInstall)
InstallButton.Content = "Uninstall";
if (foundInstall)
{
Uninstall_Button.Visibility = Visibility.Visible;
UpdateInstallButton(false);
string osuEZPPPath = folderTextbox.Text + @"\EZPPClient";
List<string> outdatedFiles = DownloadUtil.FilesToDownload(osuEZPPPath)
}else
UpdateInstallButton(true);
}
}
@ -258,11 +273,6 @@ namespace EZPPClient_Installer
File,
Directory
}
private enum UpdateStatus
{
UpdateFound,
UpToDate,
Error
}
}
}

View File

@ -0,0 +1,9 @@
namespace EZPPClient_Installer
{
public enum UpdateState
{
UpdateFound,
UpToDate,
Error
}
}