Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
b0110a2ecb | |||
fd7c8b244f | |||
9669636a17 | |||
28843b42ad | |||
23b5e76bb1 | |||
ff43c77b2e | |||
0937fa43a3 | |||
d71f0d38fc | |||
2ca4f8beb4 | |||
c14665d8a8 | |||
a4f060debe | |||
2042a829da |
@@ -90,13 +90,14 @@
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MD5File.cs" />
|
||||
<Compile Include="DownloadUtil.cs" />
|
||||
<Compile Include="MD5Util.cs" />
|
||||
<Compile Include="ProcessUtil.cs" />
|
||||
<Compile Include="Shortcut.cs" />
|
||||
<Compile Include="UpdateState.cs" />
|
||||
<Compile Include="Util.cs" />
|
||||
<Compile Include="Models\MD5File.cs" />
|
||||
<Compile Include="Utils\DownloadUtil.cs" />
|
||||
<Compile Include="Utils\MD5Util.cs" />
|
||||
<Compile Include="Utils\ProcessUtil.cs" />
|
||||
<Compile Include="Utils\RegistryUtil.cs" />
|
||||
<Compile Include="Utils\ReleaseStreamUtil.cs" />
|
||||
<Compile Include="Enums\UpdateState.cs" />
|
||||
<Compile Include="Utils\OsuUtil.cs" />
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
@@ -136,12 +137,15 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="DK.WshRuntime">
|
||||
<Version>4.1.3.201115164</Version>
|
||||
<PackageReference Include="DK.Standard">
|
||||
<Version>4.137.4070.201115155</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="ModernWpfUI">
|
||||
<Version>0.9.4</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="semver">
|
||||
<Version>2.0.6</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="circle_new.ico" />
|
||||
@@ -149,5 +153,16 @@
|
||||
<ItemGroup>
|
||||
<Content Include=".gitignore" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<COMReference Include="IWshRuntimeLibrary">
|
||||
<Guid>{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
@@ -5,17 +5,20 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:EZPPClient_Installer"
|
||||
mc:Ignorable="d"
|
||||
Title="EZPPClient Installer" Height="232.051" Width="525.487"
|
||||
Title="EZPPClient Installer" Height="293.333" Width="525"
|
||||
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,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 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>
|
||||
<CheckBox x:Name="linkFoldersCheckbox" Content="Link Song and Skins Folder" HorizontalAlignment="Stretch" Height="32" VerticalAlignment="Top" Margin="150,125,150,-125" IsChecked="True" />
|
||||
<TextBox x:Name="folderTextbox" HorizontalAlignment="Left" Height="32" TextWrapping="Wrap" Text="trying to locate osu! location..." VerticalAlignment="Top" Width="422" Margin="10,-27,0,-5" IsReadOnly="true"/>
|
||||
<Button x:Name="InstallButton" Content="Install" HorizontalAlignment="Stretch" Height="32" VerticalAlignment="Bottom" Margin="176,0,176,-114" Style="{StaticResource AccentButtonStyle}" Click="Install_Click"/>
|
||||
<Button x:Name="BrowseButton" Content="..." HorizontalAlignment="Stretch" Height="32" VerticalAlignment="Top" Margin="437,-75,10,0" Click="Browse_Click"/>
|
||||
<Button x:Name="Uninstall_Button" Content="Uninstall" HorizontalAlignment="Stretch" Height="31" VerticalAlignment="Bottom" Margin="176,0,176,-100" Click="Uninstall_Button_Click" Foreground="White" Visibility="Hidden" IsCancel="True"/>
|
||||
<ProgressBar x:Name="Download_Progressbar" Height="1" VerticalAlignment="Top" Margin="15,22,15,-26" IsIndeterminate="True" Visibility="Hidden"/>
|
||||
<Label x:Name="Download_Text" Content="Downloading: " Height="19" VerticalAlignment="Top" Margin="10,-26,10,0" Visibility="Hidden"/>
|
||||
<TextBlock Margin="349,14,0,-37"><Hyperlink NavigateUri="https://ez-pp.farm" RequestNavigate="Hyperlink_RequestNavigate"><Run Text="Copyright @ EZPPFarm"/></Hyperlink></TextBlock>
|
||||
<ComboBox x:Name="ReleaseStreamComboBox" HorizontalAlignment="Left" Height="31" VerticalAlignment="Top" Width="475" Margin="10,-137,0,0" ClipToBounds="True" SelectionChanged="ReleaseStreamComboBox_SelectionChanged"/>
|
||||
<Label x:Name="ReleaseStreamLabel" Content="Release:" HorizontalAlignment="Left" Height="19" VerticalAlignment="Top" Width="145" Margin="10,-181,0,0"/>
|
||||
<Label Content="Path to osu! Folder:" HorizontalAlignment="Left" Height="19" VerticalAlignment="Top" Width="145" Margin="10,-263,0,0"/>
|
||||
</ui:SimpleStackPanel>
|
||||
</Window>
|
||||
|
@@ -5,16 +5,18 @@ using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Globalization;
|
||||
using ModernWpf.Controls;
|
||||
using System.Windows.Forms;
|
||||
using System.Media;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
using Shortcut;
|
||||
using Path = System.Windows.Shapes.Path;
|
||||
using Path = System.IO.Path;
|
||||
using File = System.IO.File;
|
||||
using EZPPClient_Installer.Utils;
|
||||
using IWshRuntimeLibrary;
|
||||
using System.Windows.Forms.VisualStyles;
|
||||
using Semver;
|
||||
|
||||
#if DEBUG
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
@@ -33,7 +35,9 @@ namespace EZPPClient_Installer
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern bool CreateSymbolicLink(string lpSymlinkFileName, string lpTargetFileName, SymbolicLink dwFlags);
|
||||
|
||||
private static double VERSION = 1.6;
|
||||
private static SemVersion VERSION = new SemVersion(1, 1, 1);
|
||||
|
||||
public static string RELEASESTREAM;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
@@ -62,7 +66,9 @@ namespace EZPPClient_Installer
|
||||
string versionString = "v" + VERSION;
|
||||
InstallerWindow.Title = "EZPPClient Installer " + versionString.Replace(",", ".");
|
||||
|
||||
string osuPath = Util.osuInstallDir();
|
||||
await FetchReleaseStreams();
|
||||
|
||||
string osuPath = OsuUtil.osuInstallDir();
|
||||
|
||||
if (osuPath.EndsWith(@"\EZPPClient"))
|
||||
{
|
||||
@@ -72,6 +78,9 @@ namespace EZPPClient_Installer
|
||||
bool isValidFolder = await isValidOsuFolder(osuPath);
|
||||
UpdateInstallButton(!string.IsNullOrEmpty(osuPath));
|
||||
|
||||
if(string.IsNullOrEmpty(osuPath))
|
||||
folderTextbox.Text = "";
|
||||
|
||||
if (!string.IsNullOrEmpty(osuPath) && isValidFolder)
|
||||
{
|
||||
bool foundInstall = isEZPPClientInstallationFound(osuPath);
|
||||
@@ -83,7 +92,7 @@ namespace EZPPClient_Installer
|
||||
UpdateInstallButton(false);
|
||||
|
||||
|
||||
List<string> outdatedFiles = DownloadUtil.FilesToDownload(osuEZPPPath, false);
|
||||
List<string> outdatedFiles = await DownloadUtil.FilesToDownload(osuEZPPPath, false);
|
||||
|
||||
if (!IsEmpty(outdatedFiles))
|
||||
{
|
||||
@@ -105,6 +114,22 @@ namespace EZPPClient_Installer
|
||||
|
||||
}
|
||||
|
||||
private async Task FetchReleaseStreams()
|
||||
{
|
||||
List<string> releases = await ReleaseStreamUtil.GetAvailableReleaseStreams();
|
||||
foreach(string release in releases)
|
||||
{
|
||||
ReleaseStreamComboBox.Items.Add(release.UppercaseFirst().Trim());
|
||||
}
|
||||
|
||||
string systemRelease = RegistryUtil.GetUsedReleaseStream("Stable");
|
||||
|
||||
bool containsRelease = releases.Contains(systemRelease);
|
||||
|
||||
ReleaseStreamComboBox.SelectedValue = systemRelease;
|
||||
|
||||
}
|
||||
|
||||
private async Task<UpdateState> CheckForInstallerUpdates()
|
||||
{
|
||||
#if !DEBUG
|
||||
@@ -113,17 +138,20 @@ namespace EZPPClient_Installer
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
client.Headers.Add("user-agent", "EZPPClientInstaller");
|
||||
string newVersionString = client.DownloadString("https://new.ez-pp.farm/ezppclient?version");
|
||||
double ver = 0;
|
||||
string newVersionString = await client.DownloadStringTaskAsync("https://new.ez-pp.farm/ezppclient?version");
|
||||
SemVersion newVersion = new SemVersion(9, 9, 9);
|
||||
|
||||
try
|
||||
{
|
||||
ver = double.Parse(newVersionString, CultureInfo.InvariantCulture);
|
||||
newVersion = SemVersion.Parse(newVersionString);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
catch (Exception e){
|
||||
ShowErrorDialog(e.Message);
|
||||
}
|
||||
|
||||
if (ver > VERSION)
|
||||
int versionsBehind = newVersion.CompareTo(VERSION);
|
||||
|
||||
if (versionsBehind > 0)
|
||||
return UpdateState.UpdateFound;
|
||||
}
|
||||
}
|
||||
@@ -188,6 +216,10 @@ namespace EZPPClient_Installer
|
||||
return;
|
||||
}
|
||||
|
||||
var type = InstallButton.Content;
|
||||
|
||||
RegistryUtil.SetUsedReleaseStream(RELEASESTREAM);
|
||||
|
||||
if (!Directory.Exists(osuFolder + "\\EZPPClient"))
|
||||
{
|
||||
Directory.CreateDirectory(osuFolder + "\\EZPPClient");
|
||||
@@ -264,7 +296,6 @@ namespace EZPPClient_Installer
|
||||
{
|
||||
try
|
||||
{
|
||||
//File.Copy(string.Format(@"{0}\osu!.{1}.cfg", osuFolder, userName), string.Format(@"{0}\osu!.{1}.cfg", EZPPFolder, userName));
|
||||
if (!CreateSymbolicLink(string.Format(@"{0}\osu!.{1}.cfg", EZPPFolder, userName), string.Format(@"{0}\osu!.{1}.cfg", osuFolder, userName), SymbolicLink.File))
|
||||
{
|
||||
ContentDialog dg = new ContentDialog()
|
||||
@@ -291,7 +322,6 @@ namespace EZPPClient_Installer
|
||||
{
|
||||
try
|
||||
{
|
||||
//File.Copy(string.Format(@"{0}\scores.db", osuFolder), string.Format(@"{0}\scores.db", EZPPFolder));
|
||||
if (!CreateSymbolicLink(string.Format(@"{0}\scores.db", EZPPFolder), string.Format(@"{0}\scores.db", osuFolder), SymbolicLink.File))
|
||||
{
|
||||
ContentDialog dg = new ContentDialog()
|
||||
@@ -318,7 +348,6 @@ namespace EZPPClient_Installer
|
||||
{
|
||||
try
|
||||
{
|
||||
//File.Copy(string.Format(@"{0}\collection.db", osuFolder), string.Format(@"{0}\collection.db", EZPPFolder));
|
||||
if (!CreateSymbolicLink(string.Format(@"{0}\collection.db", EZPPFolder), string.Format(@"{0}\collection.db", osuFolder), SymbolicLink.File))
|
||||
{
|
||||
ContentDialog dg = new ContentDialog()
|
||||
@@ -345,7 +374,6 @@ namespace EZPPClient_Installer
|
||||
{
|
||||
try
|
||||
{
|
||||
//File.Copy(string.Format(@"{0}\osu.db", osuFolder), string.Format(@"{0}\osu.db", EZPPFolder));
|
||||
if (!CreateSymbolicLink(string.Format(@"{0}\osu!.db", EZPPFolder), string.Format(@"{0}\osu!.db", osuFolder), SymbolicLink.File))
|
||||
{
|
||||
ContentDialog dg = new ContentDialog()
|
||||
@@ -372,7 +400,7 @@ namespace EZPPClient_Installer
|
||||
|
||||
|
||||
|
||||
List<string> filesToDownload = DownloadUtil.FilesToDownload(EZPPFolder, InstallButton.Content.Equals("Reinstall"));
|
||||
List<string> filesToDownload = await DownloadUtil.FilesToDownload(EZPPFolder, InstallButton.Content.Equals("Reinstall"));
|
||||
|
||||
Visibility prevInstallBtnVis = InstallButton.Visibility;
|
||||
Visibility prevUninstallBtnVis = Uninstall_Button.Visibility;
|
||||
@@ -382,32 +410,46 @@ namespace EZPPClient_Installer
|
||||
InstallButton.Visibility = Visibility.Hidden;
|
||||
Uninstall_Button.Visibility = Visibility.Hidden;
|
||||
linkFoldersCheckbox.Visibility = Visibility.Hidden;
|
||||
ReleaseStreamComboBox.IsEnabled = false;
|
||||
|
||||
Download_Text.Visibility = Visibility.Visible;
|
||||
Download_Progressbar.Visibility = Visibility.Visible;
|
||||
|
||||
await DownloadUtil.DownloadFiles(filesToDownload, EZPPFolder);
|
||||
|
||||
if (InstallButton.Content.Equals("Install"))
|
||||
if (type.Equals("Install"))
|
||||
{
|
||||
IShellLink link = (IShellLink)new ShellLink();
|
||||
|
||||
// setup shortcut information
|
||||
link.SetDescription("Starts the EZPPClient");
|
||||
link.SetPath(EZPPFolder + @"\EZPPClient.exe");
|
||||
|
||||
// save it
|
||||
IPersistFile file = (IPersistFile)link;
|
||||
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
|
||||
string LinkFile = System.IO.Path.Combine(desktopPath, "Start EZPPClient.lnk");
|
||||
Console.Out.WriteLine("Saving Shortcut to " + LinkFile);
|
||||
file.Save(LinkFile, false);
|
||||
string desktopLinkFile = Path.Combine(desktopPath, "Start EZPPClient.lnk");
|
||||
|
||||
string startMenuPath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
|
||||
string startMenuPathPrograms = Path.Combine(startMenuPath, "Programs");
|
||||
string startMenuLinkFile = Path.Combine(startMenuPathPrograms, "Start EZPPClient.lnk");
|
||||
|
||||
if (!File.Exists(desktopLinkFile))
|
||||
{
|
||||
WshShell shell = new WshShell();
|
||||
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(desktopLinkFile);
|
||||
shortcut.Description = $"Starts the EZPPClient";
|
||||
shortcut.TargetPath = Path.Combine(EZPPFolder, "EZPPClient.exe");
|
||||
shortcut.Save();
|
||||
}
|
||||
|
||||
if (!File.Exists(startMenuLinkFile))
|
||||
{
|
||||
WshShell shell = new WshShell();
|
||||
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(startMenuLinkFile);
|
||||
shortcut.Description = $"Starts the EZPPClient";
|
||||
shortcut.TargetPath = Path.Combine(EZPPFolder, "EZPPClient.exe");
|
||||
shortcut.Save();
|
||||
}
|
||||
}
|
||||
|
||||
InstallButton.Visibility = prevInstallBtnVis;
|
||||
Uninstall_Button.Visibility = prevUninstallBtnVis;
|
||||
linkFoldersCheckbox.Visibility = prevLinkFCVis;
|
||||
BrowseButton.IsEnabled = true;
|
||||
ReleaseStreamComboBox.IsEnabled = true;
|
||||
|
||||
Download_Text.Visibility = Visibility.Hidden;
|
||||
Download_Progressbar.Visibility = Visibility.Hidden;
|
||||
@@ -415,7 +457,7 @@ namespace EZPPClient_Installer
|
||||
Uninstall_Button.Visibility = Visibility.Visible;
|
||||
UpdateInstallButton(false);
|
||||
|
||||
List<string> outdatedFiles = DownloadUtil.FilesToDownload(EZPPFolder, false);
|
||||
List<string> outdatedFiles = await DownloadUtil.FilesToDownload(EZPPFolder, false);
|
||||
|
||||
if (!IsEmpty(outdatedFiles))
|
||||
{
|
||||
@@ -424,7 +466,7 @@ namespace EZPPClient_Installer
|
||||
linkFoldersCheckbox.IsEnabled = false;
|
||||
string updateText = "It seems like the installation was faulty, please hit Update to repair the EZPPClient.";
|
||||
|
||||
switch (InstallButton.Content)
|
||||
switch (type)
|
||||
{
|
||||
case "Update":
|
||||
updateText = "It seems like the update was faulty, please hit Update to repair the EZPPClient.";
|
||||
@@ -447,7 +489,7 @@ namespace EZPPClient_Installer
|
||||
{
|
||||
string updateText = "The EZPPClient was successfully installed!";
|
||||
|
||||
switch (InstallButton.Content)
|
||||
switch (type)
|
||||
{
|
||||
case "Update":
|
||||
updateText = "The EZPPClient was successfully updated!";
|
||||
@@ -509,7 +551,7 @@ namespace EZPPClient_Installer
|
||||
UpdateInstallButton(false);
|
||||
|
||||
string osuEZPPPath = folderTextbox.Text + @"\EZPPClient";
|
||||
List<string> outdatedFiles = DownloadUtil.FilesToDownload(osuEZPPPath, false);
|
||||
List<string> outdatedFiles = await DownloadUtil.FilesToDownload(osuEZPPPath, false);
|
||||
|
||||
if (!IsEmpty(outdatedFiles))
|
||||
{
|
||||
@@ -557,11 +599,18 @@ namespace EZPPClient_Installer
|
||||
if (Directory.Exists(osuEZPPPath))
|
||||
Directory.Delete(osuEZPPPath, true);
|
||||
|
||||
|
||||
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
|
||||
string linkFile = System.IO.Path.Combine(desktopPath, "Start EZPPClient.lnk");
|
||||
string linkFile = Path.Combine(desktopPath, "Start EZPPClient.lnk");
|
||||
if (File.Exists(linkFile))
|
||||
File.Delete(linkFile);
|
||||
|
||||
string startMenuPath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
|
||||
string startMenuPathPrograms = Path.Combine(startMenuPath, "Programs");
|
||||
string startMenuLinkFile = Path.Combine(startMenuPathPrograms, "Start EZPPClient.lnk");
|
||||
if (File.Exists(startMenuLinkFile))
|
||||
File.Delete(startMenuLinkFile);
|
||||
|
||||
_ = new ContentDialog()
|
||||
{
|
||||
Title = "Success!",
|
||||
@@ -634,5 +683,63 @@ namespace EZPPClient_Installer
|
||||
Instance.Download_Progressbar.Value = progress;
|
||||
Instance.Download_Text.Content = "Downloading: " + file;
|
||||
}
|
||||
|
||||
private async void ReleaseStreamComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||
{
|
||||
|
||||
bool init = string.IsNullOrEmpty(RELEASESTREAM);
|
||||
|
||||
RELEASESTREAM = (string)ReleaseStreamComboBox.SelectedValue;
|
||||
|
||||
if (init)
|
||||
return;
|
||||
|
||||
ReleaseStreamComboBox.IsEnabled = false;
|
||||
BrowseButton.IsEnabled = false;
|
||||
InstallButton.IsEnabled = false;
|
||||
Uninstall_Button.IsEnabled = false;
|
||||
|
||||
string osuPath = folderTextbox.Text;
|
||||
|
||||
bool isValidFolder = await isValidOsuFolder(osuPath);
|
||||
UpdateInstallButton(!string.IsNullOrEmpty(osuPath));
|
||||
|
||||
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 = await DownloadUtil.FilesToDownload(osuEZPPPath, false);
|
||||
|
||||
if (!IsEmpty(outdatedFiles))
|
||||
{
|
||||
UpdateInstallButton(true);
|
||||
InstallButton.Content = "Update";
|
||||
linkFoldersCheckbox.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
folderTextbox.Text = osuPath;
|
||||
}
|
||||
|
||||
_ = new ContentDialog()
|
||||
{
|
||||
Title = "Success!",
|
||||
Content = "ReleaseStream changed to " + RELEASESTREAM,
|
||||
PrimaryButtonText = "Okay"
|
||||
}.ShowAsync();
|
||||
|
||||
ReleaseStreamComboBox.IsEnabled = true;
|
||||
BrowseButton.IsEnabled = true;
|
||||
InstallButton.IsEnabled = true;
|
||||
Uninstall_Button.IsEnabled = true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -10,24 +10,14 @@ namespace EZPPClient_Installer
|
||||
class MD5File
|
||||
{
|
||||
|
||||
private string md5;
|
||||
private string name;
|
||||
public string MD5 { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public MD5File(string name, string md5)
|
||||
{
|
||||
this.md5 = md5;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public string getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public string getMD5()
|
||||
{
|
||||
return md5;
|
||||
}
|
||||
|
||||
this.MD5 = md5;
|
||||
this.Name = name;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
using System.Text;
|
||||
|
||||
namespace Shortcut
|
||||
{
|
||||
[ComImport]
|
||||
[Guid("00021401-0000-0000-C000-000000000046")]
|
||||
internal class ShellLink
|
||||
{
|
||||
}
|
||||
|
||||
[ComImport]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
[Guid("000214F9-0000-0000-C000-000000000046")]
|
||||
internal interface IShellLink
|
||||
{
|
||||
void GetPath([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxPath, out IntPtr pfd, int fFlags);
|
||||
void GetIDList(out IntPtr ppidl);
|
||||
void SetIDList(IntPtr pidl);
|
||||
void GetDescription([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszName, int cchMaxName);
|
||||
void SetDescription([MarshalAs(UnmanagedType.LPWStr)] string pszName);
|
||||
void GetWorkingDirectory([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszDir, int cchMaxPath);
|
||||
void SetWorkingDirectory([MarshalAs(UnmanagedType.LPWStr)] string pszDir);
|
||||
void GetArguments([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs, int cchMaxPath);
|
||||
void SetArguments([MarshalAs(UnmanagedType.LPWStr)] string pszArgs);
|
||||
void GetHotkey(out short pwHotkey);
|
||||
void SetHotkey(short wHotkey);
|
||||
void GetShowCmd(out int piShowCmd);
|
||||
void SetShowCmd(int iShowCmd);
|
||||
void GetIconLocation([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszIconPath, int cchIconPath, out int piIcon);
|
||||
void SetIconLocation([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon);
|
||||
void SetRelativePath([MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, int dwReserved);
|
||||
void Resolve(IntPtr hwnd, int fFlags);
|
||||
void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile);
|
||||
}
|
||||
}
|
@@ -3,16 +3,14 @@ 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 reinstall)
|
||||
public static async Task<List<string>> FilesToDownload(string pathToEZPP, bool reinstall)
|
||||
{
|
||||
bool directoryExists = Directory.Exists(pathToEZPP);
|
||||
|
||||
@@ -21,15 +19,14 @@ namespace EZPPClient_Installer
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
using (WebClient wc = new WebClient())
|
||||
{
|
||||
wc.Headers.Add("user-agent", "EZPPClientInstaller");
|
||||
var data = wc.DownloadString("https://new.ez-pp.farm/ezppclient?list");
|
||||
var data = await wc.DownloadStringTaskAsync("https://new.ez-pp.farm/ezppclient?list&release=" + MainWindow.RELEASESTREAM.ToLower());
|
||||
string[] dataList = data.Split('\n');
|
||||
foreach (string datastring in dataList)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(datastring))
|
||||
if (string.IsNullOrWhiteSpace(datastring) || !datastring.Contains("#"))
|
||||
continue;
|
||||
|
||||
string[] se = datastring.Split('#');
|
||||
@@ -41,7 +38,7 @@ namespace EZPPClient_Installer
|
||||
}
|
||||
catch (WebException error)
|
||||
{
|
||||
new ContentDialog()
|
||||
_ = new ContentDialog()
|
||||
{
|
||||
Title = "Oops...",
|
||||
Content = "A error occurred while trying to fetch all needed Files.\n" + error.Message,
|
||||
@@ -55,28 +52,28 @@ namespace EZPPClient_Installer
|
||||
MessageBox.Show("Folder does not exist: " + pathToEZPP);
|
||||
#endif
|
||||
foreach (MD5File md5File in md5Files)
|
||||
downloadList.Add(md5File.getName());
|
||||
downloadList.Add(md5File.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (MD5File md5file in md5Files)
|
||||
{
|
||||
string file = pathToEZPP + @"\" + md5file.getName();
|
||||
string file = pathToEZPP + @"\" + md5file.Name;
|
||||
bool doesExistOnPC = File.Exists(file);
|
||||
if (!doesExistOnPC)
|
||||
{
|
||||
downloadList.Add(md5file.getName());
|
||||
downloadList.Add(md5file.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
string onlineHash = md5file.getMD5();
|
||||
string onlineHash = md5file.MD5;
|
||||
string pcHash = MD5Util.CalculateMD5(file);
|
||||
#if DEBUG
|
||||
MessageBox.Show("Filename: " + md5file.getName() + "\nOnline-Hash: " + onlineHash + "\n PC-Hash: " + pcHash);
|
||||
MessageBox.Show("Filename: " + md5file.Name + "\nOnline-Hash: " + onlineHash + "\n PC-Hash: " + pcHash);
|
||||
#endif
|
||||
if (!string.Equals(onlineHash, pcHash))
|
||||
{
|
||||
downloadList.Add(md5file.getName());
|
||||
downloadList.Add(md5file.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,7 +148,7 @@ namespace EZPPClient_Installer
|
||||
|
||||
MainWindow.updateProgress(filename + " - " + value.ProgressPercentage + "% - " + Math.Round((averageTransferRate / 1024000D) * 1.8, 2) + "MBit/s", value.ProgressPercentage);
|
||||
};
|
||||
await wc.DownloadFileTaskAsync(@"https://new.ez-pp.farm/ezppclient?file=" + filename, path + @"\" + filename);
|
||||
await wc.DownloadFileTaskAsync(@"https://new.ez-pp.farm/ezppclient?file=" + filename + "&release=" + MainWindow.RELEASESTREAM.ToLower(), path + @"\" + filename); ;
|
||||
}
|
||||
}
|
||||
catch (WebException)
|
@@ -1,11 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EZPPClient_Installer
|
||||
{
|
||||
class MD5Util
|
@@ -1,15 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Path = System.IO.Path;
|
||||
using File = System.IO.File;
|
||||
using Path = System.IO.Path;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace EZPPClient_Installer
|
||||
{
|
||||
class Util
|
||||
class OsuUtil
|
||||
{
|
||||
public static string osuInstallDir()
|
||||
{
|
@@ -1,10 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EZPPClient_Installer
|
||||
{
|
37
EZPPClient Installer/Utils/RegistryUtil.cs
Normal file
37
EZPPClient Installer/Utils/RegistryUtil.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
|
||||
namespace EZPPClient_Installer.Utils
|
||||
{
|
||||
class RegistryUtil
|
||||
{
|
||||
|
||||
public static void SetUsedReleaseStream(string release)
|
||||
{
|
||||
RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\EZPPClientInstaller");
|
||||
key.SetValue("ReleaseStream", release);
|
||||
key.Close();
|
||||
}
|
||||
|
||||
public static String GetUsedReleaseStream(string defaultRelease)
|
||||
{
|
||||
string release = defaultRelease;
|
||||
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\EZPPClientInstaller");
|
||||
|
||||
//if it does exist, retrieve the stored values
|
||||
if (key != null)
|
||||
{
|
||||
release = (string) key.GetValue("ReleaseStream");
|
||||
key.Close();
|
||||
}
|
||||
|
||||
return release;
|
||||
}
|
||||
|
||||
public static void DeleteUsedReleaseStream()
|
||||
{
|
||||
Registry.CurrentUser.DeleteSubKey(@"SOFTWARE\EZPPClientInstaller");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
45
EZPPClient Installer/Utils/ReleaseStreamUtil.cs
Normal file
45
EZPPClient Installer/Utils/ReleaseStreamUtil.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using ModernWpf.Controls;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EZPPClient_Installer
|
||||
{
|
||||
class ReleaseStreamUtil
|
||||
{
|
||||
|
||||
public static async Task<List<string>> GetAvailableReleaseStreams()
|
||||
{
|
||||
|
||||
List<string> releaseStreamList = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
using (WebClient wc = new WebClient())
|
||||
{
|
||||
wc.Headers.Add("user-agent", "EZPPClientInstaller");
|
||||
var data = await wc.DownloadStringTaskAsync("https://new.ez-pp.farm/ezppclient?releases");
|
||||
string[] dataList = data.Split('\n');
|
||||
foreach (string datastring in dataList)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(datastring))
|
||||
continue;
|
||||
releaseStreamList.Add(datastring);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (WebException error)
|
||||
{
|
||||
_ = new ContentDialog()
|
||||
{
|
||||
Title = "Oops...",
|
||||
Content = "A error occurred while trying to fetch the ReleaseStreams.\n" + error.Message,
|
||||
PrimaryButtonText = "Okay"
|
||||
}.ShowAsync();
|
||||
}
|
||||
|
||||
return releaseStreamList;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user