Merge pull request #45 from stuff-by-3-random-dudes/OverhaulToNet6

Overhaul to net6
This commit is contained in:
ZestyTS 2022-08-29 20:44:31 -07:00 committed by GitHub
commit 44ab5a2db6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 64 additions and 53 deletions

View file

@ -1623,25 +1623,21 @@ namespace UWUVCI_AIO_WPF
}
mvm.Progress = 40;
mvm.msg = "Packing...";
using var cnuspacker = new Process();
if (!mvm.debug)
{
cnuspacker.StartInfo.UseShellExecute = false;
cnuspacker.StartInfo.CreateNoWindow = true;
}
if (false)
{
cnuspacker.StartInfo.FileName = Path.Combine(toolsPath, "CNUSPACKER.exe");
cnuspacker.StartInfo.Arguments = $"-in \"{baseRomPath}\" -out \"{outputPath}\" -encryptKeyWith {Properties.Settings.Default.Ckey}";
}
if (Environment.Is64BitProcess)
CNUSPACKER.Program.Main(new string[] { "-in", baseRomPath, "-out", outputPath, "-encryptKeyWith", Properties.Settings.Default.Ckey });
else
{
using var cnuspacker = new Process();
if (!mvm.debug)
{
cnuspacker.StartInfo.UseShellExecute = false;
cnuspacker.StartInfo.CreateNoWindow = true;
}
cnuspacker.StartInfo.FileName = "java";
cnuspacker.StartInfo.Arguments = $"-jar \"{Path.Combine(toolsPath, "NUSPacker.jar")}\" -in \"{baseRomPath}\" -out \"{outputPath}\" -encryptKeyWith {Properties.Settings.Default.Ckey}";
cnuspacker.Start();
cnuspacker.WaitForExit();
}
cnuspacker.Start();
cnuspacker.WaitForExit();
mvm.Progress = 90;
mvm.msg = "Cleaning...";
Clean();
@ -1663,7 +1659,7 @@ namespace UWUVCI_AIO_WPF
var titleData = new TitleData(b.Tid, key.Tkey);
var downloadFolder = Path.Combine(tempPath, "download");
await Downloader.DownloadAsync(titleData, downloadFolder);
await WiiUDownloaderLibrary.Downloader.DownloadAsync(titleData, downloadFolder);
mvm.Progress = 75;
@ -2136,7 +2132,7 @@ namespace UWUVCI_AIO_WPF
for (var i = 0; i < titleIds.Length; i++)
{
var titleData = new TitleData(titleIds[i], Settings.Default.SysKey);
await Downloader.DownloadAsync(titleData, downloadFolder);
await WiiUDownloaderLibrary.Downloader.DownloadAsync(titleData, downloadFolder);
CSharpDecrypt.CSharpDecrypt.Decrypt(new string[] { Settings.Default.Ckey, Path.Combine(downloadFolder, titleIds[i]), paths[i] });
}

View file

@ -2,17 +2,16 @@
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Net.Http;
using System.Net;
using System.Security.Cryptography;
using System.Threading;
using System.Threading.Tasks;
namespace UWUVCI_AIO_WPF.Classes
{
class ToolCheck
{
static string FolderName = new FileInfo(System.Reflection.Assembly.GetEntryAssembly().Location).DirectoryName + "\\bin\\Tools";
public static string backupulr = @"https://github.com/Hotbrawl20/UWUVCI-Tools/raw/master/";
public static string backupulr = @"https://github.com/Hotbrawl20/UWUVCI-Tools/raw/master/" + (Environment.Is64BitProcess ? "x64/" : "");
public static string[] ToolNames =
{
"N64Converter.exe",
@ -55,7 +54,7 @@ namespace UWUVCI_AIO_WPF.Classes
"forwarder.dol",
"gba1.zip",
"gba2.zip",
"CNUSPACKER.exe"
"c2w_patcher.exe"
};
public static bool DoesToolsFolderExist()
@ -63,23 +62,28 @@ namespace UWUVCI_AIO_WPF.Classes
return Directory.Exists(FolderName);
}
public static async Task<bool> IsToolRightAsync(string name)
public static bool IsToolRightAsync(string name)
{
var result = false;
string md5Name = name + ".md5";
string md5Path = FolderName + "\\" + md5Name;
using (var httpClient = new HttpClient())
{
using var response = await httpClient.GetStreamAsync(backupulr + md5Name);
using var fs = new FileStream(md5Path, FileMode.Create);
await response.CopyToAsync(fs);
}
string filePath = FolderName + "\\" + name;
if (!File.Exists(filePath))
return result;
using (var webClient = new WebClient())
webClient.DownloadFile(backupulr + md5Name, md5Path);
var md5 = "";
using (var sr = new StreamReader(md5Path))
md5 = await sr.ReadToEndAsync();
md5 = sr.ReadLine();
return CalculateMD5(md5Path) == md5;
result = CalculateMD5(filePath) == md5.ToLower();
File.Delete(md5Path);
return result;
}
static string CalculateMD5(string filename)
{

View file

@ -434,14 +434,24 @@ namespace UWUVCI_AIO_WPF
//Someone messed up versioning, so eff it just don't even bother then
return;
}
if (comparison > 0)
if (comparison < 0)
{
using (var webClient = new WebClient())
{
webClient.Headers.Add(HttpRequestHeader.UserAgent, "MyUserAgent");
Task.Run(() => webClient.DownloadFileTaskAsync(releases[0].ZipballUrl, "UWUVCI_INSTALLER.exe")).GetAwaiter();
}
var cm = new Custom_Message("Update Available!", "Latest version is currently being downloaded!\nPlease look for the file \"UWUVCI_INSTALLER.exe\" in\n" + Directory.GetCurrentDirectory());
var cm = new Custom_Message("Update Available!", "Latest version is currently being downloaded!\nPlease look for the file \"UWUVCI" + "_" + "INSTALLER.exe\" in\n" + Directory.GetCurrentDirectory());
try
{
cm.Owner = mw;
}
catch (Exception) { }
cm.ShowDialog();
}
else if (comparison > 0)
{
var cm = new Custom_Message("Possible Update Available", "It somehow looks like your version is newer than the public release version:\nhttps://github.com/stuff-by-3-random-dudes/UWUVCI-AIO-WPF/releases/latest\n\nNo update attempt will be made.");
try
{
cm.Owner = mw;
@ -451,6 +461,7 @@ namespace UWUVCI_AIO_WPF
}
else
{
var cm = new Custom_Message("No Update Available", "This is currently the latest version.");
try
{
@ -1168,7 +1179,7 @@ namespace UWUVCI_AIO_WPF
foreach (string s in bases)
{
DeleteTool(s);
Task.Run(() => DownloadToolAsync(s, this)).GetAwaiter();
DownloadToolAsync(s, this);
Progress += Convert.ToInt32(l);
}
@ -1622,21 +1633,19 @@ namespace UWUVCI_AIO_WPF
Environment.Exit(1);
}
}
public static async Task DownloadToolAsync(string name, MainViewModel mvm)
public static void DownloadToolAsync(string name, MainViewModel mvm)
{
var filePath = Path.Combine(Directory.GetCurrentDirectory(), "bin", "Tools", name);
try
{
while (true)
{
var isToolRight = await ToolCheck.IsToolRightAsync(name);
var isToolRight = ToolCheck.IsToolRightAsync(name);
if (isToolRight)
break;
using var httpClient = new HttpClient();
using var response = await httpClient.GetStreamAsync(getDownloadLink(name, true));
using var fs = new FileStream(filePath, FileMode.Create);
await response.CopyToAsync(fs);
using (var webClient = new WebClient())
webClient.DownloadFile(getDownloadLink(name, true), filePath);
}
}
catch (Exception e)
@ -1682,7 +1691,7 @@ namespace UWUVCI_AIO_WPF
if (missingTools.Count > 0)
{
foreach (MissingTool m in missingTools)
Task.Run(() => DownloadToolAsync(m.Name, this)).GetAwaiter();
DownloadToolAsync(m.Name, this);
InjcttoolCheck();
}
@ -1696,6 +1705,7 @@ namespace UWUVCI_AIO_WPF
private void ThreadDownload(List<MissingTool> missingTools)
{
var percentage = 100 / missingTools.Count;
Progress = 0;
var thread = new Thread(() =>
{
foreach (MissingTool m in missingTools)
@ -1706,9 +1716,10 @@ namespace UWUVCI_AIO_WPF
sw.Close();
}
else
Task.Run(() => DownloadToolAsync(m.Name, this)).GetAwaiter();
DownloadToolAsync(m.Name, this);
Progress += percentage;
}
Progress = 100;
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();

View file

@ -51,5 +51,5 @@ using System.Windows;
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.99.0.1")]
[assembly: AssemblyFileVersion("3.99.0.1")]
[assembly: AssemblyVersion("3.99.1.0")]
[assembly: AssemblyFileVersion("3.99.1.0")]

View file

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
@ -366,7 +367,7 @@ namespace UWUVCI_AIO_WPF.UI.Frames.InjectFrames.Configurations
foreach (var titleId in titleIds)
{
Task.Run(() => Downloader.DownloadAsync(titleId, downloadPath)).GetAwaiter().GetResult();
Task.Run(() => WiiUDownloaderLibrary.Downloader.DownloadAsync(titleId, downloadPath)).GetAwaiter().GetResult();
mvm.Progress += 5;
}
@ -384,7 +385,6 @@ namespace UWUVCI_AIO_WPF.UI.Frames.InjectFrames.Configurations
mvm.Progress += 5;
var currentDir = Directory.GetCurrentDirectory();
Directory.SetCurrentDirectory(c2wPath);
using (Process c2w = new Process())
{
@ -393,7 +393,7 @@ namespace UWUVCI_AIO_WPF.UI.Frames.InjectFrames.Configurations
c2w.Start();
c2w.WaitForExit();
}
Directory.SetCurrentDirectory(currentDir);
Directory.SetCurrentDirectory(new FileInfo(Assembly.GetEntryAssembly().Location).DirectoryName);
File.Copy(System.IO.Path.Combine(c2wPath, "c2p.img"), imgFileCode, true);
mvm.Progress = 100;

View file

@ -46,7 +46,7 @@
<Ellipse Fill="#FF2196F3" HorizontalAlignment="Left" Height="21" Margin="12,7,0,0" VerticalAlignment="Top" Width="17"/>
<Ellipse Fill="#FF2196F3" HorizontalAlignment="Left" Height="21" Margin="12,7,0,0" VerticalAlignment="Top" Width="17"/>
<Border BorderBrush="#FF2196F3" BorderThickness="1" HorizontalAlignment="Left" Height="33" Margin="12,6,0,0" VerticalAlignment="Top" Width="1108" CornerRadius="5" Background="#FF2196F3"/>
<Label Content="v3.99.0.1" HorizontalAlignment="Left" Margin="1075,10,0,0" VerticalAlignment="Top" Foreground="#DDFFFFFF" Width="81" Height="24"/>
<Label Content="v3.99.1" HorizontalAlignment="Left" Margin="1075,10,0,0" VerticalAlignment="Top" Foreground="#DDFFFFFF" Width="81" Height="24"/>
<Button HorizontalAlignment="Left" Margin="32,522,0,0" VerticalAlignment="Top" Width="74" Click="Button_Click_13" IsTabStop="False" Height="58" ToolTip="Support UWUVCI on Ko-Fi">
<Image HorizontalAlignment="Left" Height="46" VerticalAlignment="Top" Width="46" Source="/UI/Images/61e111774d3a2f67c827cd25_Frame 5.png" />
</Button>

View file

@ -8,7 +8,7 @@
d:DesignHeight="480" d:DesignWidth="1130"
Title="SettingsFrame" >
<Grid>
<TextBlock x:Name="tb" Margin="10,172,10,192" TextWrapping="Wrap" Text="Welcome to UWUVCI AIO v3.99.0.1. To start Injecting select a Console to your left." FontSize="20" Height="116" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center" Width="1110" />
<TextBlock x:Name="tb" Margin="10,172,10,192" TextWrapping="Wrap" Text="Welcome to UWUVCI AIO v3.99.1. To start Injecting select a Console to your left." FontSize="20" Height="116" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center" Width="1110" />
<TextBlock Margin="15,505,15,0" HorizontalAlignment="Right" VerticalAlignment="Top" Text="Support MAC Development" TextAlignment="Right"></TextBlock>
<Button HorizontalAlignment="Right" Margin="15,525,15,0" VerticalAlignment="Top" Width="74" Click="Button_Click" IsTabStop="False" Height="58" ToolTip="Support UWUVCI MAC Development on Ko-Fi">
<Image HorizontalAlignment="Left" Height="46" VerticalAlignment="Top" Width="46" Source="/UI/Images/61e111774d3a2f67c827cd25_Frame 5.png" />

View file

@ -73,6 +73,7 @@ namespace UWUVCI_AIO_WPF.UI.Windows
if (mvm.Progress < 79)
mvm.Progress += 1;
}
else if (Key.Text.Contains("Downloading Tools")) { }
else
mvm.Progress += 1;

View file

@ -21,7 +21,7 @@
<UseWindowsForms>True</UseWindowsForms>
<UseWPF>true</UseWPF>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<Platforms>AnyCPU;x64;x86</Platforms>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<PropertyGroup>
<SignManifests>false</SignManifests>
@ -34,8 +34,6 @@
</PropertyGroup>
<PropertyGroup>
<StartupObject>UWUVCI_AIO_WPF.App</StartupObject>
<PlatformTarget>x86</PlatformTarget>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="GameBaseClassLibrary">
@ -162,6 +160,7 @@
<ItemGroup>
<PackageReference Include="CDecryptSharp" Version="1.0.4" />
<PackageReference Include="CNUSPACKER" Version="1.0.3" />
<PackageReference Include="Downloader" Version="2.3.7" />
<PackageReference Include="GMWare.M2" Version="1.1.2" />
<PackageReference Include="Json.Net" Version="1.0.33" />
<PackageReference Include="MaterialDesignThemes" Version="2.5.1" />