mirror of
https://github.com/stuff-by-3-random-dudes/UWUVCI-AIO-WPF
synced 2025-02-16 10:38:23 +00:00
Merge branch 'Asynicify' into AsyncifyMerge
This commit is contained in:
commit
128ad89225
5 changed files with 152 additions and 205 deletions
|
@ -537,9 +537,12 @@ namespace UWUVCI_AIO_WPF
|
|||
{
|
||||
File.Delete(sFile);
|
||||
}
|
||||
File.Move(Path.Combine(tempPath, "game.iso"), Path.Combine(baseRomPath, "content", "game.iso"));
|
||||
File.Copy(Path.Combine(toolsPath, "nfs2iso2nfs.exe"), Path.Combine(baseRomPath, "content", "nfs2iso2nfs.exe"));
|
||||
Directory.SetCurrentDirectory(Path.Combine(baseRomPath, "content"));
|
||||
|
||||
string gamePath = Path.Combine(baseRomPath, "content", "game.iso");
|
||||
string nfsPath = Path.Combine(baseRomPath, "content", "nfs2iso2nfs.exe");
|
||||
File.Move(Path.Combine(tempPath, "game.iso"), gamePath);
|
||||
File.Copy(Path.Combine(toolsPath, "nfs2iso2nfs.exe"), nfsPath);
|
||||
|
||||
using (Process iso2nfs = new Process())
|
||||
{
|
||||
if (!mvm.debug)
|
||||
|
@ -547,7 +550,7 @@ namespace UWUVCI_AIO_WPF
|
|||
|
||||
iso2nfs.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
|
||||
}
|
||||
iso2nfs.StartInfo.FileName = "nfs2iso2nfs.exe";
|
||||
iso2nfs.StartInfo.FileName = nfsPath;
|
||||
string extra = "";
|
||||
if (mvm.Index == 2)
|
||||
{
|
||||
|
@ -557,13 +560,12 @@ namespace UWUVCI_AIO_WPF
|
|||
if (mvm.Index == 4) { extra = "-instantcc "; }
|
||||
if (mvm.Index == 5) { extra = "-nocc "; }
|
||||
if (mvm.LR) { extra += "-lrpatch "; }
|
||||
iso2nfs.StartInfo.Arguments = $"-enc -homebrew {extra}-iso game.iso";
|
||||
iso2nfs.StartInfo.Arguments = $"-enc -homebrew {extra}-iso " + gamePath;
|
||||
iso2nfs.Start();
|
||||
iso2nfs.WaitForExit();
|
||||
File.Delete("nfs2iso2nfs.exe");
|
||||
File.Delete("game.iso");
|
||||
File.Delete(nfsPath);
|
||||
File.Delete(gamePath);
|
||||
}
|
||||
Directory.SetCurrentDirectory(savedir);
|
||||
mvm.Progress = 80;
|
||||
|
||||
|
||||
|
@ -644,9 +646,10 @@ namespace UWUVCI_AIO_WPF
|
|||
{
|
||||
File.Delete(sFile);
|
||||
}
|
||||
File.Move(Path.Combine(tempPath, "game.iso"), Path.Combine(baseRomPath, "content", "game.iso"));
|
||||
File.Copy(Path.Combine(toolsPath, "nfs2iso2nfs.exe"), Path.Combine(baseRomPath, "content", "nfs2iso2nfs.exe"));
|
||||
Directory.SetCurrentDirectory(Path.Combine(baseRomPath, "content"));
|
||||
string gamePath = Path.Combine(baseRomPath, "content", "game.iso");
|
||||
string nfsPath = Path.Combine(baseRomPath, "content", "nfs2iso2nfs.exe");
|
||||
File.Move(Path.Combine(tempPath, "game.iso"), gamePath);
|
||||
File.Copy(Path.Combine(toolsPath, "nfs2iso2nfs.exe"), nfsPath);
|
||||
using (Process iso2nfs = new Process())
|
||||
{
|
||||
if (!mvm.debug)
|
||||
|
@ -654,19 +657,18 @@ namespace UWUVCI_AIO_WPF
|
|||
|
||||
iso2nfs.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
|
||||
}
|
||||
iso2nfs.StartInfo.FileName = "nfs2iso2nfs.exe";
|
||||
iso2nfs.StartInfo.FileName = nfsPath;
|
||||
string pass = "-passthrough ";
|
||||
if(mvm.passtrough != true)
|
||||
{
|
||||
pass = "";
|
||||
}
|
||||
iso2nfs.StartInfo.Arguments = $"-enc -homebrew {pass}-iso game.iso";
|
||||
iso2nfs.StartInfo.Arguments = $"-enc -homebrew {pass}-iso " + gamePath;
|
||||
iso2nfs.Start();
|
||||
iso2nfs.WaitForExit();
|
||||
File.Delete("nfs2iso2nfs.exe");
|
||||
File.Delete("game.iso");
|
||||
File.Delete(gamePath);
|
||||
File.Delete(nfsPath);
|
||||
}
|
||||
Directory.SetCurrentDirectory(savedir);
|
||||
mvm.Progress = 80;
|
||||
|
||||
|
||||
|
@ -839,11 +841,10 @@ namespace UWUVCI_AIO_WPF
|
|||
mvm.msg = "Video Patching ROM...";
|
||||
using (Process vmc = new Process())
|
||||
{
|
||||
var wiiVmcPath = Path.Combine(tempPath, "TEMP", "sys", "wii-vmc.exe");
|
||||
File.Copy(Path.Combine(toolsPath, "wii-vmc.exe"), wiiVmcPath);
|
||||
|
||||
File.Copy(Path.Combine(toolsPath, "wii-vmc.exe"), Path.Combine(tempPath, "TEMP", "sys", "wii-vmc.exe"));
|
||||
|
||||
Directory.SetCurrentDirectory(Path.Combine(tempPath, "TEMP", "sys"));
|
||||
vmc.StartInfo.FileName = "wii-vmc.exe";
|
||||
vmc.StartInfo.FileName = wiiVmcPath;
|
||||
vmc.StartInfo.Arguments = "main.dol";
|
||||
vmc.StartInfo.UseShellExecute = false;
|
||||
vmc.StartInfo.CreateNoWindow = true;
|
||||
|
@ -859,10 +860,9 @@ namespace UWUVCI_AIO_WPF
|
|||
Thread.Sleep(2000);
|
||||
vmc.StandardInput.WriteLine();
|
||||
vmc.WaitForExit();
|
||||
File.Delete("wii-vmc.exe");
|
||||
File.Delete(wiiVmcPath);
|
||||
|
||||
|
||||
Directory.SetCurrentDirectory(savedir);
|
||||
mvm.Progress = 40;
|
||||
}
|
||||
|
||||
|
@ -926,11 +926,10 @@ namespace UWUVCI_AIO_WPF
|
|||
mvm.msg = "Video Patching ROM...";
|
||||
using (Process vmc = new Process())
|
||||
{
|
||||
var wiiVmcPath = Path.Combine(tempPath, "TEMP", "DATA", "sys", "wii-vmc.exe");
|
||||
File.Copy(Path.Combine(toolsPath, "wii-vmc.exe"), wiiVmcPath);
|
||||
|
||||
File.Copy(Path.Combine(toolsPath, "wii-vmc.exe"), Path.Combine(tempPath, "TEMP", "DATA", "sys", "wii-vmc.exe"));
|
||||
|
||||
Directory.SetCurrentDirectory(Path.Combine(tempPath, "TEMP", "DATA", "sys"));
|
||||
vmc.StartInfo.FileName = "wii-vmc.exe";
|
||||
vmc.StartInfo.FileName = wiiVmcPath;
|
||||
vmc.StartInfo.Arguments = "main.dol";
|
||||
vmc.StartInfo.UseShellExecute = false;
|
||||
vmc.StartInfo.CreateNoWindow = true;
|
||||
|
@ -946,10 +945,9 @@ namespace UWUVCI_AIO_WPF
|
|||
Thread.Sleep(2000);
|
||||
vmc.StandardInput.WriteLine();
|
||||
vmc.WaitForExit();
|
||||
File.Delete("wii-vmc.exe");
|
||||
File.Delete(wiiVmcPath);
|
||||
|
||||
|
||||
Directory.SetCurrentDirectory(savedir);
|
||||
mvm.Progress = 40;
|
||||
}
|
||||
|
||||
|
@ -1004,9 +1002,11 @@ namespace UWUVCI_AIO_WPF
|
|||
{
|
||||
File.Delete(sFile);
|
||||
}
|
||||
File.Move(Path.Combine(tempPath, "game.iso"), Path.Combine(baseRomPath, "content", "game.iso"));
|
||||
File.Copy(Path.Combine(toolsPath, "nfs2iso2nfs.exe"), Path.Combine(baseRomPath, "content", "nfs2iso2nfs.exe"));
|
||||
Directory.SetCurrentDirectory(Path.Combine(baseRomPath, "content"));
|
||||
string gamePath = Path.Combine(baseRomPath, "content", "game.iso");
|
||||
string nfsPath = Path.Combine(baseRomPath, "content", "nfs2iso2nfs.exe");
|
||||
File.Move(Path.Combine(tempPath, "game.iso"), gamePath);
|
||||
File.Copy(Path.Combine(toolsPath, "nfs2iso2nfs.exe"), nfsPath);
|
||||
|
||||
using (Process iso2nfs = new Process())
|
||||
{
|
||||
if (!mvm.debug)
|
||||
|
@ -1014,7 +1014,7 @@ namespace UWUVCI_AIO_WPF
|
|||
|
||||
iso2nfs.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
|
||||
}
|
||||
iso2nfs.StartInfo.FileName = "nfs2iso2nfs.exe";
|
||||
iso2nfs.StartInfo.FileName = nfsPath;
|
||||
string extra = "";
|
||||
if (mvm.Index == 2)
|
||||
{
|
||||
|
@ -1024,13 +1024,12 @@ namespace UWUVCI_AIO_WPF
|
|||
if (mvm.Index == 4) { extra = "-instantcc "; }
|
||||
if (mvm.Index == 5) { extra = "-nocc "; }
|
||||
if (mvm.LR) { extra += "-lrpatch "; }
|
||||
iso2nfs.StartInfo.Arguments = $"-enc {extra}-iso game.iso";
|
||||
iso2nfs.StartInfo.Arguments = $"-enc {extra}-iso " + gamePath;
|
||||
iso2nfs.Start();
|
||||
iso2nfs.WaitForExit();
|
||||
File.Delete("nfs2iso2nfs.exe");
|
||||
File.Delete("game.iso");
|
||||
File.Delete(nfsPath);
|
||||
File.Delete(gamePath);
|
||||
}
|
||||
Directory.SetCurrentDirectory(savedir);
|
||||
mvm.Progress = 80;
|
||||
}
|
||||
private static void GC(string romPath, MainViewModel mvm, bool force)
|
||||
|
@ -1336,9 +1335,11 @@ namespace UWUVCI_AIO_WPF
|
|||
{
|
||||
File.Delete(sFile);
|
||||
}
|
||||
File.Move(Path.Combine(tempPath, "game.iso"), Path.Combine(baseRomPath, "content", "game.iso"));
|
||||
File.Copy(Path.Combine(toolsPath, "nfs2iso2nfs.exe"), Path.Combine(baseRomPath, "content", "nfs2iso2nfs.exe"));
|
||||
Directory.SetCurrentDirectory(Path.Combine(baseRomPath, "content"));
|
||||
string gamePath = Path.Combine(baseRomPath, "content", "game.iso");
|
||||
string nfsPath = Path.Combine(baseRomPath, "content", "nfs2iso2nfs.exe");
|
||||
File.Move(Path.Combine(tempPath, "game.iso"), gamePath);
|
||||
File.Copy(Path.Combine(toolsPath, "nfs2iso2nfs.exe"), nfsPath);
|
||||
|
||||
using (Process iso2nfs = new Process())
|
||||
{
|
||||
if (!mvm.debug)
|
||||
|
@ -1346,14 +1347,13 @@ namespace UWUVCI_AIO_WPF
|
|||
|
||||
iso2nfs.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
|
||||
}
|
||||
iso2nfs.StartInfo.FileName = "nfs2iso2nfs.exe";
|
||||
iso2nfs.StartInfo.Arguments = $"-enc -homebrew -passthrough -iso game.iso";
|
||||
iso2nfs.StartInfo.FileName = nfsPath;
|
||||
iso2nfs.StartInfo.Arguments = $"-enc -homebrew -passthrough -iso " + gamePath;
|
||||
iso2nfs.Start();
|
||||
iso2nfs.WaitForExit();
|
||||
File.Delete("nfs2iso2nfs.exe");
|
||||
File.Delete("game.iso");
|
||||
File.Delete(nfsPath);
|
||||
File.Delete(gamePath);
|
||||
}
|
||||
Directory.SetCurrentDirectory(savedir);
|
||||
mvm.Progress = 80;
|
||||
|
||||
}
|
||||
|
@ -1545,7 +1545,6 @@ namespace UWUVCI_AIO_WPF
|
|||
mvvm.msg = "Injecting ROM...";
|
||||
Console.WriteLine("Converting Game to NFS format...");
|
||||
string olddir = Directory.GetCurrentDirectory();
|
||||
Directory.SetCurrentDirectory(Path.Combine(baseRomPath, "content"));
|
||||
tik.StartInfo.FileName = Path.Combine(toolsPath, "nfs2iso2nfs.exe");
|
||||
if (!mvm.GC)
|
||||
{
|
||||
|
@ -1570,7 +1569,6 @@ namespace UWUVCI_AIO_WPF
|
|||
tik.WaitForExit();
|
||||
Console.WriteLine("Finished Conversion");
|
||||
mvvm.Progress = 80;
|
||||
Directory.SetCurrentDirectory(olddir);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1730,7 +1728,6 @@ namespace UWUVCI_AIO_WPF
|
|||
}
|
||||
cnuspacker.Start();
|
||||
cnuspacker.WaitForExit();
|
||||
Directory.SetCurrentDirectory(oldpath);
|
||||
}
|
||||
mvm.Progress = 90;
|
||||
mvm.msg = "Cleaning...";
|
||||
|
|
|
@ -2,14 +2,17 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UWUVCI_AIO_WPF.Classes
|
||||
{
|
||||
class ToolCheck
|
||||
{
|
||||
static string FolderName = "bin\\Tools";
|
||||
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[] ToolNames =
|
||||
{
|
||||
|
@ -73,16 +76,35 @@ namespace UWUVCI_AIO_WPF.Classes
|
|||
public static bool IsToolRight(string name)
|
||||
{
|
||||
bool ret = false;
|
||||
WebClient client = new WebClient();
|
||||
client.DownloadFile(backupulr + name + ".md5", name + ".md5");
|
||||
StreamReader sr = new StreamReader(name + ".md5");
|
||||
var md5 = sr.ReadLine();
|
||||
if(CalculateMD5(name) == md5)
|
||||
string md5Name = FolderName + "\\" + name + ".md5";
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
ret = true;
|
||||
await client.DownloadFileTaskAsync(backupulr + md5Name, md5Name);
|
||||
using (StreamReader sr = new StreamReader(md5Name))
|
||||
{
|
||||
var md5 = sr.ReadLine();
|
||||
if (CalculateMD5(name) == md5)
|
||||
{
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
sr.Close();
|
||||
File.Delete(name + ".md5");
|
||||
//Dumb solution but whatever, hopefully this deletes the md5file
|
||||
try
|
||||
{
|
||||
File.Delete(md5Name);
|
||||
}
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
File.Delete(new FileInfo(System.Reflection.Assembly.GetEntryAssembly().Location).DirectoryName + "\\bin\\Tools\\" + md5Name);
|
||||
}
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
File.Delete(new FileInfo(System.Reflection.Assembly.GetEntryAssembly().Location).DirectoryName + "\\bin\\bases\\" + md5Name);
|
||||
}
|
||||
catch { }
|
||||
return ret;
|
||||
}
|
||||
static string CalculateMD5(string filename)
|
||||
|
@ -116,38 +138,18 @@ namespace UWUVCI_AIO_WPF.Classes
|
|||
if (!File.Exists(path))
|
||||
return false;
|
||||
|
||||
if (path.ToLower().Contains("gba1.zip"))
|
||||
{
|
||||
string p = Path.GetDirectoryName(path);
|
||||
if (!File.Exists(Path.Combine(p, "MArchiveBatchTool.exe")))
|
||||
{
|
||||
using (Process extract = new Process())
|
||||
if (path.ToLower().Contains("gba1.zip") || path.ToLower().Contains("gba2.zip"))
|
||||
if (!File.Exists(Path.Combine(FolderName, "MArchiveBatchTool.exe")) || !File.Exists(Path.Combine(FolderName, "ucrtbase.dll")))
|
||||
try
|
||||
{
|
||||
extract.StartInfo.UseShellExecute = false;
|
||||
extract.StartInfo.CreateNoWindow = false;
|
||||
extract.StartInfo.FileName = "cmd.exe";
|
||||
extract.StartInfo.Arguments = "/c bin\\Tools\\7za.exe x bin\\Tools\\gba1.zip -obin\\Tools";
|
||||
extract.Start();
|
||||
extract.WaitForExit();
|
||||
ZipFile.ExtractToDirectory(path, FolderName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (path.ToLower().Contains("gba2.zip"))
|
||||
{
|
||||
string p = Path.GetDirectoryName(path);
|
||||
if (!File.Exists(Path.Combine(p, "ucrtbase.dll")))
|
||||
{
|
||||
using (Process extract = new Process())
|
||||
catch (Exception)
|
||||
{
|
||||
extract.StartInfo.UseShellExecute = false;
|
||||
extract.StartInfo.CreateNoWindow = false;
|
||||
extract.StartInfo.FileName = "cmd.exe";
|
||||
extract.StartInfo.Arguments = "/c bin\\Tools\\7za.exe x bin\\Tools\\gba2.zip -obin\\Tools";
|
||||
extract.Start();
|
||||
extract.WaitForExit();
|
||||
Thread.Sleep(200);
|
||||
DoesToolExist(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1230,6 +1230,10 @@ namespace UWUVCI_AIO_WPF
|
|||
}
|
||||
Progress = 100;
|
||||
});
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
>>>>>>> Asynicify
|
||||
DownloadWait dw = new DownloadWait("Downloading needed Data - Please Wait", "", this);
|
||||
try
|
||||
{
|
||||
|
@ -1273,6 +1277,10 @@ namespace UWUVCI_AIO_WPF
|
|||
}
|
||||
Progress = 100;
|
||||
});
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
>>>>>>> Asynicify
|
||||
DownloadWait dw = new DownloadWait("Downloading needed Data - Please Wait", "", this);
|
||||
try
|
||||
{
|
||||
|
@ -1299,11 +1307,12 @@ namespace UWUVCI_AIO_WPF
|
|||
}
|
||||
|
||||
}
|
||||
public void UpdateTools()
|
||||
public void UpdateToolsAsync()
|
||||
{
|
||||
if (CheckForInternetConnection())
|
||||
if (Task.Run(() => CheckForInternetConnectionAsync()).GetAwaiter().GetResult())
|
||||
{
|
||||
string[] bases = ToolCheck.ToolNames;
|
||||
Progress = 0;
|
||||
Task.Run(() =>
|
||||
{
|
||||
Progress = 0;
|
||||
|
@ -1410,18 +1419,20 @@ namespace UWUVCI_AIO_WPF
|
|||
|
||||
|
||||
}
|
||||
public void UpdateBases()
|
||||
public void UpdateBaseAsync()
|
||||
{
|
||||
if (CheckForInternetConnection())
|
||||
if (Task.Run(() => CheckForInternetConnectionAsync()).GetAwaiter().GetResult())
|
||||
{
|
||||
string[] bases = { "bases.vcbnds", "bases.vcbn64", "bases.vcbgba", "bases.vcbsnes", "bases.vcbnes", "bases.vcbtg16", "bases.vcbmsx", "bases.vcbwii" };
|
||||
Task.Run(() => {
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
Progress = 0;
|
||||
double l = 100 / bases.Length;
|
||||
foreach (string s in bases)
|
||||
{
|
||||
DeleteBase(s);
|
||||
DownloadBase(s, this);
|
||||
Task.Run(() => DownloadBaseAsync(s, this)).GetAwaiter().GetResult();
|
||||
|
||||
GameConsoles g = new GameConsoles();
|
||||
if (s.Contains("nds")) g = GameConsoles.NDS;
|
||||
|
@ -1718,58 +1729,55 @@ namespace UWUVCI_AIO_WPF
|
|||
}
|
||||
private static void DeleteBase(string console)
|
||||
{
|
||||
File.Delete($@"bin\bases\{console}");
|
||||
File.Delete(Path.Combine(Directory.GetCurrentDirectory(), "bin", "bases", console));
|
||||
}
|
||||
public static List<string> GetMissingVCBs()
|
||||
{
|
||||
List<string> ret = new List<string>();
|
||||
string path = @"bin\bases\bases.vcb";
|
||||
if (!File.Exists(path + "nds"))
|
||||
string prefix = @"bases.vcb";
|
||||
var location = Path.Combine(Directory.GetCurrentDirectory(), "bin", "bases", prefix);
|
||||
if (!File.Exists(location + "nds"))
|
||||
{
|
||||
ret.Add(path + "nds");
|
||||
ret.Add(prefix + "nds");
|
||||
}
|
||||
if (!File.Exists(path + "nes"))
|
||||
if (!File.Exists(location + "nes"))
|
||||
{
|
||||
ret.Add(path + "nes");
|
||||
ret.Add(prefix + "nes");
|
||||
}
|
||||
if (!File.Exists(path + "n64"))
|
||||
if (!File.Exists(location + "n64"))
|
||||
{
|
||||
ret.Add(path + "n64");
|
||||
ret.Add(prefix + "n64");
|
||||
}
|
||||
if (!File.Exists(path + "snes"))
|
||||
if (!File.Exists(location + "snes"))
|
||||
{
|
||||
ret.Add(path + "snes");
|
||||
ret.Add(prefix + "snes");
|
||||
}
|
||||
if (!File.Exists(path + "gba"))
|
||||
if (!File.Exists(location + "gba"))
|
||||
{
|
||||
ret.Add(path + "gba");
|
||||
ret.Add(prefix + "gba");
|
||||
}
|
||||
if (!File.Exists(path + "tg16"))
|
||||
if (!File.Exists(location + "tg16"))
|
||||
{
|
||||
ret.Add(path + "tg16");
|
||||
ret.Add(prefix + "tg16");
|
||||
}
|
||||
if (!File.Exists(path + "msx"))
|
||||
if (!File.Exists(location + "msx"))
|
||||
{
|
||||
ret.Add(path + "msx");
|
||||
ret.Add(prefix + "msx");
|
||||
}
|
||||
if (!File.Exists(path + "wii"))
|
||||
if (!File.Exists(location + "wii"))
|
||||
{
|
||||
ret.Add(path + "wii");
|
||||
ret.Add(prefix + "wii");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public static void DownloadBase(string name, MainViewModel mvm)
|
||||
{
|
||||
string olddir = Directory.GetCurrentDirectory();
|
||||
var filePath = Path.Combine(Directory.GetCurrentDirectory(), "bin", "bases", name);
|
||||
try
|
||||
{
|
||||
string basePath = $@"bin\bases\";
|
||||
Directory.SetCurrentDirectory(basePath);
|
||||
using (var client = new WebClient())
|
||||
|
||||
{
|
||||
var fixname = name.Split('\\');
|
||||
client.DownloadFile(getDownloadLink(name, false), fixname[fixname.Length - 1]);
|
||||
await client.DownloadFileTaskAsync(getDownloadLink(name, false), filePath);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -1784,32 +1792,21 @@ namespace UWUVCI_AIO_WPF
|
|||
cm.ShowDialog();
|
||||
Environment.Exit(1);
|
||||
}
|
||||
Directory.SetCurrentDirectory(olddir);
|
||||
}
|
||||
public static void DownloadTool(string name, MainViewModel mvm)
|
||||
{
|
||||
string olddir = Directory.GetCurrentDirectory();
|
||||
var filePath = Path.Combine(Directory.GetCurrentDirectory(), "bin", "Tools", name);
|
||||
try
|
||||
{
|
||||
|
||||
if (Directory.GetCurrentDirectory().Contains("bin") && Directory.GetCurrentDirectory().Contains("Tools"))
|
||||
{
|
||||
olddir = Directory.GetCurrentDirectory().Replace("bin\\Tools", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
string basePath = $@"bin\Tools\";
|
||||
Directory.SetCurrentDirectory(basePath);
|
||||
}
|
||||
do
|
||||
{
|
||||
if (File.Exists(name))
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(name);
|
||||
File.Delete(filePath);
|
||||
}
|
||||
using (var client = new WebClient())
|
||||
{
|
||||
client.DownloadFile(getDownloadLink(name, true), name);
|
||||
await client.DownloadFileTaskAsync(getDownloadLink(name, true), filePath);
|
||||
}
|
||||
} while (!ToolCheck.IsToolRight(name));
|
||||
|
||||
|
@ -1828,72 +1825,19 @@ namespace UWUVCI_AIO_WPF
|
|||
|
||||
Environment.Exit(1);
|
||||
}
|
||||
Directory.SetCurrentDirectory(olddir);
|
||||
}
|
||||
private static string getDownloadLink(string toolname, bool tool)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool ok = false;
|
||||
try
|
||||
if (tool)
|
||||
{
|
||||
System.Net.WebClient client = new System.Net.WebClient();
|
||||
string result = client.DownloadString("https://uwuvciapi.azurewebsites.net/api/values");
|
||||
ok = true;
|
||||
}
|
||||
catch (System.Net.WebException ex)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
if (ok)
|
||||
{
|
||||
WebRequest request;
|
||||
//get download link from uwuvciapi
|
||||
if (tool)
|
||||
{
|
||||
request = WebRequest.Create("https://uwuvciapi.azurewebsites.net/GetToolLink?tool=" + toolname);
|
||||
}
|
||||
else
|
||||
{
|
||||
request = WebRequest.Create("https://uwuvciapi.azurewebsites.net/GetVcbLink?vcb=" + toolname);
|
||||
}
|
||||
|
||||
var response = request.GetResponse();
|
||||
using (Stream dataStream = response.GetResponseStream())
|
||||
{
|
||||
// Open the stream using a StreamReader for easy access.
|
||||
StreamReader reader = new StreamReader(dataStream);
|
||||
// Read the content.
|
||||
string responseFromServer = reader.ReadToEnd();
|
||||
// Display the content.
|
||||
if (responseFromServer == "")
|
||||
{
|
||||
if (tool)
|
||||
{
|
||||
return $"{ToolCheck.backupulr}{toolname}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $@"https://github.com/Hotbrawl20/UWUVCI-VCB/raw/master/" + toolname;
|
||||
}
|
||||
}
|
||||
return responseFromServer;
|
||||
}
|
||||
return $"{ToolCheck.backupulr}{toolname}";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tool)
|
||||
{
|
||||
return $"{ToolCheck.backupulr}{toolname}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $@"https://github.com/Hotbrawl20/UWUVCI-VCB/raw/master/" + toolname.Replace("bin\\bases\\", "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $@"https://github.com/Hotbrawl20/UWUVCI-VCB/raw/master/" + toolname.Replace("bin\\bases\\", "");
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -1903,7 +1847,8 @@ namespace UWUVCI_AIO_WPF
|
|||
}
|
||||
else
|
||||
{
|
||||
return $@"https://github.com/Hotbrawl20/UWUVCI-VCB/raw/master/" + toolname.Replace("bin\\bases\\", "");
|
||||
var name = toolname.Replace("bin\\bases\\", "");
|
||||
return $@"https://github.com/Hotbrawl20/UWUVCI-VCB/raw/master/" + name;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1912,22 +1857,17 @@ namespace UWUVCI_AIO_WPF
|
|||
{
|
||||
if (ToolCheck.DoesToolsFolderExist())
|
||||
{
|
||||
|
||||
List<MissingTool> missingTools = new List<MissingTool>();
|
||||
missingTools = ToolCheck.CheckForMissingTools();
|
||||
if (missingTools.Count > 0)
|
||||
{
|
||||
|
||||
|
||||
|
||||
foreach (MissingTool m in missingTools)
|
||||
{
|
||||
DownloadTool(m.Name, this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
InjcttoolCheck();
|
||||
|
||||
}
|
||||
|
@ -1943,7 +1883,6 @@ namespace UWUVCI_AIO_WPF
|
|||
}
|
||||
private void ThreadDownload(List<MissingTool> missingTools)
|
||||
{
|
||||
|
||||
var thread = new Thread(() =>
|
||||
{
|
||||
double l = 100 / missingTools.Count;
|
||||
|
@ -1958,7 +1897,7 @@ namespace UWUVCI_AIO_WPF
|
|||
}
|
||||
else
|
||||
{
|
||||
DownloadTool(m.Name, this);
|
||||
Task.Run(() => DownloadToolAsync(m.Name, this)).GetAwaiter();
|
||||
}
|
||||
|
||||
Progress += Convert.ToInt32(l);
|
||||
|
@ -2198,14 +2137,23 @@ namespace UWUVCI_AIO_WPF
|
|||
LTG16.Clear();
|
||||
LMSX.Clear();
|
||||
LWII.Clear();
|
||||
lNDS = VCBTool.ReadBasesFromVCB($@"bin/bases/bases.vcbnds");
|
||||
lNES = VCBTool.ReadBasesFromVCB($@"bin/bases/bases.vcbnes");
|
||||
lSNES = VCBTool.ReadBasesFromVCB($@"bin/bases/bases.vcbsnes");
|
||||
lN64 = VCBTool.ReadBasesFromVCB($@"bin/bases/bases.vcbn64");
|
||||
lGBA = VCBTool.ReadBasesFromVCB($@"bin/bases/bases.vcbgba");
|
||||
lTG16 = VCBTool.ReadBasesFromVCB($@"bin/bases/bases.vcbtg16");
|
||||
lMSX = VCBTool.ReadBasesFromVCB($@"bin/bases/bases.vcbmsx");
|
||||
lWii = VCBTool.ReadBasesFromVCB($@"bin/bases/bases.vcbwii");
|
||||
try
|
||||
{
|
||||
lNDS = VCBTool.ReadBasesFromVCB($@"bin/bases/bases.vcbnds");
|
||||
lNES = VCBTool.ReadBasesFromVCB($@"bin/bases/bases.vcbnes");
|
||||
lSNES = VCBTool.ReadBasesFromVCB($@"bin/bases/bases.vcbsnes");
|
||||
lN64 = VCBTool.ReadBasesFromVCB($@"bin/bases/bases.vcbn64");
|
||||
lGBA = VCBTool.ReadBasesFromVCB($@"bin/bases/bases.vcbgba");
|
||||
lTG16 = VCBTool.ReadBasesFromVCB($@"bin/bases/bases.vcbtg16");
|
||||
lMSX = VCBTool.ReadBasesFromVCB($@"bin/bases/bases.vcbmsx");
|
||||
lWii = VCBTool.ReadBasesFromVCB($@"bin/bases/bases.vcbwii");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//Nico, look at what you made me do
|
||||
Thread.Sleep(200);
|
||||
GetAllBases();
|
||||
}
|
||||
CreateSettingIfNotExist(lNDS, GameConsoles.NDS);
|
||||
CreateSettingIfNotExist(lNES, GameConsoles.NES);
|
||||
CreateSettingIfNotExist(lSNES, GameConsoles.SNES);
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace UWUVCI_AIO_WPF.UI.Frames
|
|||
private void Button_Click_3(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MainViewModel mvm = FindResource("mvm") as MainViewModel;
|
||||
mvm.UpdateBases();
|
||||
mvm.UpdateBaseAsync();
|
||||
}
|
||||
|
||||
private void Button_Click_4(object sender, RoutedEventArgs e)
|
||||
|
@ -92,7 +92,7 @@ namespace UWUVCI_AIO_WPF.UI.Frames
|
|||
private void Button_Click_7(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MainViewModel mvm = FindResource("mvm") as MainViewModel;
|
||||
mvm.UpdateTools();
|
||||
mvm.UpdateToolsAsync();
|
||||
}
|
||||
|
||||
private void Button_Click_8(object sender, RoutedEventArgs e)
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace UWUVCI_AIO_WPF.UI.Windows
|
|||
mvm.Progress += 1;
|
||||
}
|
||||
}
|
||||
if(mvm.Progress == 100)
|
||||
if(mvm.Progress >= 100)
|
||||
{
|
||||
timer.Stop();
|
||||
Close();
|
||||
|
|
Loading…
Add table
Reference in a new issue