Now creating symlinks to Songs and Skins Folder, copying collection and scores db to the EZPPClient dir
This commit is contained in:
parent
505fe6f8e2
commit
dca56f330f
|
@ -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);
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
<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,-58" Style="{StaticResource AccentButtonStyle}" Click="Install_Click"/>
|
||||
<Button Content="..." HorizontalAlignment="Stretch" Height="32" VerticalAlignment="Top" Margin="437,-82,10,0" Click="Browse_Click"/>
|
||||
<Button x:Name="Uninstall_Button" Content="Uninstall" HorizontalAlignment="Stretch" Height="31" VerticalAlignment="Bottom" Margin="176,0,176,-44" Click="Install_Click" Background="#CCCB3737" Foreground="White" Visibility="Hidden"/>
|
||||
<Button x:Name="BrowseButton" Content="..." HorizontalAlignment="Stretch" Height="32" VerticalAlignment="Top" Margin="437,-82,10,0" Click="Browse_Click"/>
|
||||
<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>
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
@ -67,16 +70,25 @@ namespace EZPPClient_Installer
|
|||
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<string> outdatedFiles = DownloadUtil.FilesToDownload(osuEZPPPath);
|
||||
|
||||
if (!IsEmpty(outdatedFiles))
|
||||
{
|
||||
InstallButton.Content = "Update";
|
||||
UpdateInstallButton(true);
|
||||
linkFoldersCheckbox.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
folderTextbox.Text = osuPath;
|
||||
|
@ -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<string> 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,11 +400,48 @@ namespace EZPPClient_Installer
|
|||
InstallButton.Content = "Update";
|
||||
UpdateInstallButton(true);
|
||||
}
|
||||
|
||||
}else
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -275,14 +452,14 @@ namespace EZPPClient_Installer
|
|||
|
||||
private async Task<bool> 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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user