changed endpoints for version,data and listing, its now implemented into the EZPPanel
This commit is contained in:
parent
b4cfdcdc26
commit
d3305aa27c
|
@ -24,7 +24,7 @@ namespace EZPPClient_Installer
|
||||||
|
|
||||||
using (WebClient wc = new WebClient())
|
using (WebClient wc = new WebClient())
|
||||||
{
|
{
|
||||||
var data = wc.DownloadString("https://ez-pp.farm/static/client/client.data");
|
var data = wc.DownloadString("https://new.ez-pp.farm/ezppclient?list");
|
||||||
string[] dataList = data.Split('\n');
|
string[] dataList = data.Split('\n');
|
||||||
foreach (string datastring in dataList)
|
foreach (string datastring in dataList)
|
||||||
{
|
{
|
||||||
|
@ -32,12 +32,13 @@ namespace EZPPClient_Installer
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
string[] se = datastring.Split('#');
|
string[] se = datastring.Split('#');
|
||||||
string md5 = se[0].Replace("\r\n", "").Replace("\r", "").Replace("\n", "");
|
string md5 = StripHTML(se[0]);
|
||||||
string name = se[1].Replace("\r\n", "").Replace("\r", "").Replace("\n", "");
|
string name = StripHTML(se[1]);
|
||||||
md5Files.Add(new MD5File(name, md5));
|
md5Files.Add(new MD5File(name, md5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch(WebException error)
|
}
|
||||||
|
catch (WebException error)
|
||||||
{
|
{
|
||||||
new ContentDialog()
|
new ContentDialog()
|
||||||
{
|
{
|
||||||
|
@ -54,12 +55,7 @@ namespace EZPPClient_Installer
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*string[] files = Directory.GetFiles(pathToEZPP, "*");
|
foreach (MD5File md5file in md5Files)
|
||||||
foreach (var file in files)
|
|
||||||
{
|
|
||||||
|
|
||||||
}*/
|
|
||||||
foreach(MD5File md5file in md5Files)
|
|
||||||
{
|
{
|
||||||
string file = pathToEZPP + @"\" + md5file.getName();
|
string file = pathToEZPP + @"\" + md5file.getName();
|
||||||
bool doesExistOnPC = File.Exists(file);
|
bool doesExistOnPC = File.Exists(file);
|
||||||
|
@ -71,7 +67,7 @@ namespace EZPPClient_Installer
|
||||||
{
|
{
|
||||||
string onlineHash = md5file.getMD5();
|
string onlineHash = md5file.getMD5();
|
||||||
string pcHash = MD5Util.CalculateMD5(file);
|
string pcHash = MD5Util.CalculateMD5(file);
|
||||||
if(!string.Equals(onlineHash, pcHash))
|
if (!string.Equals(onlineHash, pcHash))
|
||||||
{
|
{
|
||||||
downloadList.Add(md5file.getName());
|
downloadList.Add(md5file.getName());
|
||||||
}
|
}
|
||||||
|
@ -79,15 +75,41 @@ namespace EZPPClient_Installer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
MessageBox.Show(downloadList.Count + "/" + md5Files.Count + " Files need for update");
|
MessageBox.Show(downloadList.Count + "/" + md5Files.Count + " Files need for update");
|
||||||
|
#endif
|
||||||
return downloadList;
|
return downloadList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> CheckForUpdate()
|
public static async Task DownloadFiles(List<string> files, string path)
|
||||||
{
|
{
|
||||||
return false;
|
if (!Directory.Exists(path))
|
||||||
|
Directory.CreateDirectory(path);
|
||||||
|
|
||||||
|
foreach(string filename in files)
|
||||||
|
{
|
||||||
|
await DownloadFile(filename, path);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static async Task DownloadFile(string filename, string path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (WebClient wc = new WebClient())
|
||||||
|
{
|
||||||
|
wc.DownloadProgressChanged += (sender, value) => MainWindow.updateProgress(filename + " - " + value.ProgressPercentage + "% - " + Math.Round((value.BytesReceived / 1024000D), 2) + "MB/" + Math.Round((value.TotalBytesToReceive / 1024000D), 2) + "MB", value.ProgressPercentage);
|
||||||
|
await wc.DownloadFileTaskAsync(@"https://new.ez-pp.farm/ezppclient?file=" + filename, path + @"\" + filename);
|
||||||
|
}
|
||||||
|
}catch(WebException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string StripHTML(string input)
|
||||||
|
{
|
||||||
|
return input.Replace("\r\n", "").Replace("\r", "").Replace("\n", "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -29,6 +29,8 @@ namespace EZPPClient_Installer
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static MainWindow Instance { get; private set; }
|
||||||
|
|
||||||
[DllImport("kernel32.dll")]
|
[DllImport("kernel32.dll")]
|
||||||
private static extern bool CreateSymbolicLink(string lpSymlinkFileName, string lpTargetFileName, SymbolicLink dwFlags);
|
private static extern bool CreateSymbolicLink(string lpSymlinkFileName, string lpTargetFileName, SymbolicLink dwFlags);
|
||||||
|
|
||||||
|
@ -36,8 +38,8 @@ namespace EZPPClient_Installer
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
|
Instance = this;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
DownloadUtil.FilesToDownload("yeet");
|
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,13 +63,13 @@ namespace EZPPClient_Installer
|
||||||
string versionString = "v" + VERSION;
|
string versionString = "v" + VERSION;
|
||||||
InstallerWindow.Title = "EZPPClient Installer " + versionString.Replace(",", ".");
|
InstallerWindow.Title = "EZPPClient Installer " + versionString.Replace(",", ".");
|
||||||
|
|
||||||
string osuPath = "";
|
string osuPath = Util.osuInstallDir();
|
||||||
bool isValidFolder = await isValidOsuFolder(osuPath);
|
bool isValidFolder = await isValidOsuFolder(osuPath);
|
||||||
UpdateInstallButton(!string.IsNullOrEmpty(osuPath));
|
UpdateInstallButton(!string.IsNullOrEmpty(osuPath));
|
||||||
|
|
||||||
if(!string.IsNullOrEmpty(osuPath) && isValidFolder)
|
if(!string.IsNullOrEmpty(osuPath) && isValidFolder)
|
||||||
{
|
{
|
||||||
bool foundInstall = await isEZPPClientInstallationFound(osuPath);
|
bool foundInstall = isEZPPClientInstallationFound(osuPath);
|
||||||
if (foundInstall)
|
if (foundInstall)
|
||||||
{
|
{
|
||||||
Uninstall_Button.Visibility = Visibility.Visible;
|
Uninstall_Button.Visibility = Visibility.Visible;
|
||||||
|
@ -96,7 +98,7 @@ namespace EZPPClient_Installer
|
||||||
{
|
{
|
||||||
using (WebClient client = new WebClient())
|
using (WebClient client = new WebClient())
|
||||||
{
|
{
|
||||||
string newVersionString = client.DownloadString("https://ez-pp.farm/static/client/installer.ver");
|
string newVersionString = client.DownloadString("https://new.ez-pp.farm/ezppclient?version");
|
||||||
double ver = 0;
|
double ver = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -170,6 +172,48 @@ namespace EZPPClient_Installer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string EZPPFolder = osuFolder + @"\EZPPClient";
|
||||||
|
|
||||||
|
List<string> filesToDownload = DownloadUtil.FilesToDownload(EZPPFolder);
|
||||||
|
|
||||||
|
Visibility prevInstallBtnVis = InstallButton.Visibility;
|
||||||
|
Visibility prevUninstallBtnVis = Uninstall_Button.Visibility;
|
||||||
|
Visibility prevLinkFCVis = linkFoldersCheckbox.Visibility;
|
||||||
|
|
||||||
|
InstallButton.Visibility = Visibility.Hidden;
|
||||||
|
Uninstall_Button.Visibility = Visibility.Hidden;
|
||||||
|
linkFoldersCheckbox.Visibility = Visibility.Hidden;
|
||||||
|
|
||||||
|
Download_Text.Visibility = Visibility.Visible;
|
||||||
|
Download_Progressbar.Visibility = Visibility.Visible;
|
||||||
|
|
||||||
|
await DownloadUtil.DownloadFiles(filesToDownload, EZPPFolder);
|
||||||
|
|
||||||
|
InstallButton.Visibility = prevInstallBtnVis;
|
||||||
|
Uninstall_Button.Visibility = prevUninstallBtnVis;
|
||||||
|
linkFoldersCheckbox.Visibility = prevLinkFCVis;
|
||||||
|
|
||||||
|
Download_Text.Visibility = Visibility.Hidden;
|
||||||
|
Download_Progressbar.Visibility = Visibility.Hidden;
|
||||||
|
|
||||||
|
await new ContentDialog()
|
||||||
|
{
|
||||||
|
Title = "Success!",
|
||||||
|
Content = "The EZPPClient was successfully installed!",
|
||||||
|
PrimaryButtonText = "Yaaay :3"
|
||||||
|
}.ShowAsync();
|
||||||
|
|
||||||
|
Uninstall_Button.Visibility = Visibility.Visible;
|
||||||
|
UpdateInstallButton(false);
|
||||||
|
|
||||||
|
string osuEZPPPath = folderTextbox.Text + @"\EZPPClient";
|
||||||
|
List<string> outdatedFiles = DownloadUtil.FilesToDownload(osuEZPPPath);
|
||||||
|
|
||||||
|
if (!IsEmpty(outdatedFiles))
|
||||||
|
{
|
||||||
|
InstallButton.Content = "Update";
|
||||||
|
UpdateInstallButton(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +244,7 @@ namespace EZPPClient_Installer
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool foundInstall = await isEZPPClientInstallationFound(fbd.SelectedPath);
|
bool foundInstall = isEZPPClientInstallationFound(fbd.SelectedPath);
|
||||||
folderTextbox.Text = fbd.SelectedPath;
|
folderTextbox.Text = fbd.SelectedPath;
|
||||||
|
|
||||||
if (foundInstall)
|
if (foundInstall)
|
||||||
|
@ -224,21 +268,9 @@ namespace EZPPClient_Installer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> isEZPPClientInstallationFound(string folder)
|
private bool isEZPPClientInstallationFound(string folder)
|
||||||
{
|
{
|
||||||
string[] subDirs = Directory.GetDirectories(folder, "*");
|
return Directory.Exists(folder + @"\EZPPClient");
|
||||||
bool doesExist = false;
|
|
||||||
|
|
||||||
foreach (string dir in subDirs)
|
|
||||||
{
|
|
||||||
if(dir.Contains("EZPPClient"))
|
|
||||||
{
|
|
||||||
doesExist = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return doesExist;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> isValidOsuFolder(string folder)
|
private async Task<bool> isValidOsuFolder(string folder)
|
||||||
|
@ -289,5 +321,12 @@ namespace EZPPClient_Installer
|
||||||
Directory
|
Directory
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void updateProgress(string file, double progress)
|
||||||
|
{
|
||||||
|
Instance.Download_Progressbar.IsIndeterminate = (progress == 100);
|
||||||
|
Instance.Download_Progressbar.Value = progress;
|
||||||
|
Instance.Download_Text.Content = "Downloading: " + file;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user