diff --git a/EZPPClient Installer/DownloadUtil.cs b/EZPPClient Installer/DownloadUtil.cs
index f9d8f06..592a59f 100644
--- a/EZPPClient Installer/DownloadUtil.cs
+++ b/EZPPClient Installer/DownloadUtil.cs
@@ -50,6 +50,9 @@ namespace EZPPClient_Installer
if (!directoryExists)
{
+#if DEBUG
+ MessageBox.Show("Folder does not exist: " + pathToEZPP);
+#endif
foreach (MD5File md5File in md5Files)
downloadList.Add(md5File.getName());
}
@@ -67,6 +70,9 @@ namespace EZPPClient_Installer
{
string onlineHash = md5file.getMD5();
string pcHash = MD5Util.CalculateMD5(file);
+#if DEBUG
+ MessageBox.Show("Filename: " + md5file.getName() + "\nOnline-Hash: " + onlineHash + "\n PC-Hash: " + pcHash);
+#endif
if (!string.Equals(onlineHash, pcHash))
{
downloadList.Add(md5file.getName());
@@ -86,7 +92,11 @@ namespace EZPPClient_Installer
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
- foreach(string filename in files)
+ foreach(string file in files)
+ if (File.Exists(path + @"\" + file))
+ File.Delete(path + @"\" + file);
+
+ foreach (string filename in files)
{
await DownloadFile(filename, path);
diff --git a/EZPPClient Installer/MainWindow.xaml b/EZPPClient Installer/MainWindow.xaml
index 5ea1b37..6b07954 100644
--- a/EZPPClient Installer/MainWindow.xaml
+++ b/EZPPClient Installer/MainWindow.xaml
@@ -12,8 +12,8 @@
-
-
+
+
diff --git a/EZPPClient Installer/MainWindow.xaml.cs b/EZPPClient Installer/MainWindow.xaml.cs
index d4c3631..78afe7a 100644
--- a/EZPPClient Installer/MainWindow.xaml.cs
+++ b/EZPPClient Installer/MainWindow.xaml.cs
@@ -20,6 +20,9 @@ using System.Net;
using System.Globalization;
using ModernWpf.Controls;
using System.Windows.Forms;
+using System.Media;
+using System.Threading;
+using Windows.System;
namespace EZPPClient_Installer
{
@@ -66,19 +69,28 @@ namespace EZPPClient_Installer
string osuPath = Util.osuInstallDir();
bool isValidFolder = await isValidOsuFolder(osuPath);
UpdateInstallButton(!string.IsNullOrEmpty(osuPath));
-
- if(!string.IsNullOrEmpty(osuPath) && isValidFolder)
+
+ if (!string.IsNullOrEmpty(osuPath) && isValidFolder)
{
bool foundInstall = isEZPPClientInstallationFound(osuPath);
if (foundInstall)
{
+ string osuEZPPPath = osuPath + @"\EZPPClient";
+
Uninstall_Button.Visibility = Visibility.Visible;
UpdateInstallButton(false);
+ List outdatedFiles = DownloadUtil.FilesToDownload(osuEZPPPath);
+ if (!IsEmpty(outdatedFiles))
+ {
+ InstallButton.Content = "Update";
+ UpdateInstallButton(true);
+ linkFoldersCheckbox.IsEnabled = false;
+ }
}
-
+
folderTextbox.Text = osuPath;
}
else
@@ -163,6 +175,7 @@ namespace EZPPClient_Installer
bool isValid = await isValidOsuFolder(osuFolder);
if (!isValid)
{
+ SystemSounds.Asterisk.Play();
await new ContentDialog()
{
Title = "Hmmm..",
@@ -172,14 +185,129 @@ namespace EZPPClient_Installer
return;
}
+ if (!Directory.Exists(osuFolder + "\\EZPPClient"))
+ {
+ Directory.CreateDirectory(osuFolder + "\\EZPPClient");
+ }
+
string EZPPFolder = osuFolder + @"\EZPPClient";
+ if (!InstallButton.Content.Equals("Update"))
+ {
+ if (linkFoldersCheckbox.IsChecked.Value)
+ {
+ if (!Directory.Exists(string.Format(@"{0}\Skins\", EZPPFolder)) && Directory.Exists(string.Format(@"{0}\Skins\", osuFolder)))
+ {
+ if (!CreateSymbolicLink(string.Format(@"{0}\Skins\", EZPPFolder), string.Format(@"{0}\Skins\", osuFolder), SymbolicLink.Directory))
+ {
+ ContentDialog dg = new ContentDialog()
+ {
+ Title = "Hmmm..",
+ Content = "Failed to create Symlink to Skins folder.",
+ PrimaryButtonText = "Okay :/"
+ };
+ await dg.ShowAsync();
+ }
+ }
+ else
+ {
+ ContentDialog dg = new ContentDialog()
+ {
+ Title = "Hmmm..",
+ Content = "Failed to locate Skins folder.",
+ PrimaryButtonText = "Okay :/"
+ };
+ await dg.ShowAsync();
+ }
+
+ if (!Directory.Exists(string.Format(@"{0}\Songs\", EZPPFolder)) && Directory.Exists(string.Format(@"{0}\Songs\", osuFolder)))
+ {
+ if (!CreateSymbolicLink(string.Format(@"{0}\Songs\", EZPPFolder), string.Format(@"{0}\Songs\", osuFolder), SymbolicLink.Directory))
+ {
+ ContentDialog dg = new ContentDialog()
+ {
+ Title = "Hmmm..",
+ Content = "Failed to create Symlink to Songs folder.",
+ PrimaryButtonText = "Okay :/"
+ };
+ await dg.ShowAsync();
+ }
+
+ }
+ else
+ {
+ ContentDialog dg = new ContentDialog()
+ {
+ Title = "Hmmm..",
+ Content = "Failed to locate Songs folder.",
+ PrimaryButtonText = "Okay :/"
+ };
+ await dg.ShowAsync();
+ }
+ }
+ string userName = Environment.UserName;
+ if(File.Exists(string.Format(@"{0}\osu!.{1}.cfg", osuFolder, userName)) && !File.Exists(string.Format(@"{0}\osu!.{1}.cfg", EZPPFolder, userName)))
+ {
+ try
+ {
+ File.Copy(string.Format(@"{0}\osu!.{1}.cfg", osuFolder, userName), string.Format(@"{0}\osu!.{1}.cfg", EZPPFolder, userName));
+ }
+ catch (Exception)
+ {
+ ContentDialog dg = new ContentDialog()
+ {
+ Title = "Hmmm..",
+ Content = string.Format("Failed to copy osu!.{0}.cfg", userName),
+ PrimaryButtonText = "Okay :/"
+ };
+ await dg.ShowAsync();
+ }
+ }
+ if (File.Exists(string.Format(@"{0}\scores.db", osuFolder)) && !File.Exists(string.Format(@"{0}\scores.db", EZPPFolder)))
+ {
+ try
+ {
+ File.Copy(string.Format(@"{0}\scores.db", osuFolder), string.Format(@"{0}\scores.db", EZPPFolder));
+ }
+ catch (Exception)
+ {
+ ContentDialog dg = new ContentDialog()
+ {
+ Title = "Hmmm..",
+ Content = "Failed to copy scores.db",
+ PrimaryButtonText = "Okay :/"
+ };
+ await dg.ShowAsync();
+ }
+ }
+ if (File.Exists(string.Format(@"{0}\collection.db", osuFolder)) && !File.Exists(string.Format(@"{0}\collection.db", EZPPFolder)))
+ {
+ try
+ {
+ File.Copy(string.Format(@"{0}\collection.db", osuFolder), string.Format(@"{0}\collection.db", EZPPFolder));
+ }
+ catch (Exception)
+ {
+ ContentDialog dg = new ContentDialog()
+ {
+ Title = "Hmmm..",
+ Content = "Failed to copy collection.db",
+ PrimaryButtonText = "Okay :/"
+ };
+ await dg.ShowAsync();
+ }
+ }
+ }
+
+
+
List filesToDownload = DownloadUtil.FilesToDownload(EZPPFolder);
Visibility prevInstallBtnVis = InstallButton.Visibility;
Visibility prevUninstallBtnVis = Uninstall_Button.Visibility;
Visibility prevLinkFCVis = linkFoldersCheckbox.Visibility;
+ BrowseButton.IsEnabled = false;
InstallButton.Visibility = Visibility.Hidden;
Uninstall_Button.Visibility = Visibility.Hidden;
linkFoldersCheckbox.Visibility = Visibility.Hidden;
@@ -192,16 +320,19 @@ namespace EZPPClient_Installer
InstallButton.Visibility = prevInstallBtnVis;
Uninstall_Button.Visibility = prevUninstallBtnVis;
linkFoldersCheckbox.Visibility = prevLinkFCVis;
+ BrowseButton.IsEnabled = true;
Download_Text.Visibility = Visibility.Hidden;
Download_Progressbar.Visibility = Visibility.Hidden;
- await new ContentDialog()
+ _ = new ContentDialog()
{
Title = "Success!",
- Content = "The EZPPClient was successfully installed!",
+ Content = InstallButton.Content.Equals("Update") ? "The EZPPClient was successfully updated!" : "The EZPPClient was successfully installed!",
PrimaryButtonText = "Yaaay :3"
}.ShowAsync();
+ SystemSounds.Asterisk.Play();
+ this.Focus();
Uninstall_Button.Visibility = Visibility.Visible;
UpdateInstallButton(false);
@@ -213,6 +344,12 @@ namespace EZPPClient_Installer
{
InstallButton.Content = "Update";
UpdateInstallButton(true);
+ linkFoldersCheckbox.IsEnabled = false;
+ }
+ else
+ {
+ InstallButton.Content = "Install";
+ linkFoldersCheckbox.IsEnabled = false;
}
}
@@ -225,6 +362,8 @@ namespace EZPPClient_Installer
private async void Browse_Click(object sender, RoutedEventArgs e)
{
+ if (InstallButton.Visibility == Visibility.Hidden)
+ return;
using (var fbd = new FolderBrowserDialog())
{
DialogResult result = fbd.ShowDialog();
@@ -235,6 +374,7 @@ namespace EZPPClient_Installer
if (!isValid)
{
+ SystemSounds.Asterisk.Play();
await new ContentDialog()
{
Title = "Hmmm..",
@@ -260,14 +400,51 @@ namespace EZPPClient_Installer
InstallButton.Content = "Update";
UpdateInstallButton(true);
}
-
- }else
- UpdateInstallButton(true);
+ else
+ {
+ InstallButton.Content = "Install";
+ UpdateInstallButton(true);
+ }
+ }
+ else
+ {
+ UpdateInstallButton(true);
+ }
}
}
}
}
+ private async void Uninstall_Button_Click(object sender, RoutedEventArgs e)
+ {
+ SystemSounds.Asterisk.Play();
+ ContentDialog cd = new ContentDialog()
+ {
+ Title = "Confirm uninstall",
+ Content = "Are you sure you want to remove the EZPPClient?",
+ PrimaryButtonText = "Yes",
+ SecondaryButtonText = "No"
+ };
+ ContentDialogResult result = await cd.ShowAsync();
+ if (result == ContentDialogResult.Primary)
+ {
+ string osuEZPPPath = folderTextbox.Text + @"\EZPPClient";
+ if (Directory.Exists(osuEZPPPath))
+ Directory.Delete(osuEZPPPath, true);
+
+ _ = new ContentDialog()
+ {
+ Title = "Success!",
+ Content = "The EZPPClient was successfully uninstalled!",
+ PrimaryButtonText = "Okay"
+ }.ShowAsync();
+ SystemSounds.Asterisk.Play();
+ this.Focus();
+ Uninstall_Button.Visibility = Visibility.Hidden;
+ UpdateInstallButton(true);
+ }
+ }
+
private bool isEZPPClientInstallationFound(string folder)
{
return Directory.Exists(folder + @"\EZPPClient");
@@ -275,14 +452,14 @@ namespace EZPPClient_Installer
private async Task isValidOsuFolder(string folder)
{
- if(string.IsNullOrEmpty(folder) || string.IsNullOrWhiteSpace(folder))
+ if (string.IsNullOrEmpty(folder) || string.IsNullOrWhiteSpace(folder))
return false;
string[] files = Directory.GetFiles(folder, "*");
string[] subDirs = Directory.GetDirectories(folder, "*");
bool hasSongsFolder = false;
bool hasSkinsFolder = false;
bool hasOsuExecutable = false;
- foreach(string file in files)
+ foreach (string file in files)
{
if (file.Contains("osu!.exe"))
{
@@ -327,6 +504,5 @@ namespace EZPPClient_Installer
Instance.Download_Progressbar.Value = progress;
Instance.Download_Text.Content = "Downloading: " + file;
}
-
}
}