diff --git a/UWUVCI AIO WPF/Classes/GameConfig.cs b/UWUVCI AIO WPF/Classes/GameConfig.cs index e613e6c..e702228 100644 --- a/UWUVCI AIO WPF/Classes/GameConfig.cs +++ b/UWUVCI AIO WPF/Classes/GameConfig.cs @@ -5,7 +5,7 @@ using UWUVCI_AIO_WPF.Classes; namespace UWUVCI_AIO_WPF { [Serializable] - class GameConfig + public class GameConfig { public GameConsoles Console { get; set; } public GameBases BaseRom { get; set; } diff --git a/UWUVCI AIO WPF/Classes/Injection.cs b/UWUVCI AIO WPF/Classes/Injection.cs index 1940fe5..c7f84b1 100644 --- a/UWUVCI AIO WPF/Classes/Injection.cs +++ b/UWUVCI AIO WPF/Classes/Injection.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Text; +using System.Threading; using System.Windows; using System.Xml; using UWUVCI_AIO_WPF.Classes; @@ -13,14 +14,15 @@ using UWUVCI_AIO_WPF.UI.Windows; namespace UWUVCI_AIO_WPF { + internal static class Injection { - private static readonly string tempPath = Path.Combine(Directory.GetCurrentDirectory(), "temp"); + private static readonly string tempPath = Path.Combine(Directory.GetCurrentDirectory(),"bin", "temp"); private static readonly string baseRomPath = Path.Combine(tempPath, "baserom"); private static readonly string imgPath = Path.Combine(tempPath, "img"); - private static readonly string toolsPath = Path.Combine(Directory.GetCurrentDirectory(), "Tools"); + private static readonly string toolsPath = Path.Combine(Directory.GetCurrentDirectory(),"bin", "Tools"); static string code = null; static MainViewModel mvvm; @@ -38,7 +40,7 @@ namespace UWUVCI_AIO_WPF * iniPath = Only used for N64. Path to the INI configuration. If "blank", a blank ini will be used. * darkRemoval = Only used for N64. Indicates whether the dark filter should be removed. */ - + [STAThread] public static bool Inject(GameConfig Configuration, string RomPath, MainViewModel mvm, bool force) { mvvm = mvm; @@ -77,7 +79,8 @@ namespace UWUVCI_AIO_WPF mvm.msg = "Changing Images..."; Images(Configuration); mvm.Progress = 100; - MessageBox.Show("Injection Finished, please choose how you want to export the Inject next", "Finished Injection Part", MessageBoxButton.OK, MessageBoxImage.Information); + + code = null; return true; }catch(Exception e) @@ -107,6 +110,7 @@ namespace UWUVCI_AIO_WPF { mvm.Index = -1; mvm.LR = false; + mvm.msg = ""; } } @@ -224,6 +228,33 @@ namespace UWUVCI_AIO_WPF tik.StartInfo.FileName = Path.Combine(toolsPath, "wit.exe"); mvvm.Progress = 45; } + if (mvm.Patch) + { + mvvm.msg = "Video Patching ROM..."; + using (Process process = new Process()) + { + process.StartInfo.FileName = "wii-vmc.exe"; + process.StartInfo.Arguments = $"\"{Path.Combine(tempPath, "IsoExt", "sys", "main.dol")}\""; + process.StartInfo.RedirectStandardInput = true; + process.StartInfo.UseShellExecute = false; + process.Start(); + process.StandardInput.WriteLine("a"); + if (mvm.toPal) + { + process.StandardInput.WriteLine("1"); + } + else + { + process.StandardInput.WriteLine("2"); + } + + Thread.Sleep(200); + process.StandardInput.WriteLine(); + process.WaitForExit(); + } + mvvm.Progress = 50; + } + mvvm.msg = "Creating ISO from trimmed ROM..."; Console.WriteLine("Creating ISO from trimmed ROM..."); tik.StartInfo.Arguments = $"copy \"{Path.Combine(tempPath, "IsoExt")}\" --DEST \"{Path.Combine(tempPath, "game.iso")}\" -ovv --links --iso"; @@ -395,7 +426,7 @@ namespace UWUVCI_AIO_WPF Directory.Delete(tempPath, true); } } - + [STAThread] public static void Loadiine(string gameName) { if (gameName == null || gameName == string.Empty) gameName = "NoName"; @@ -409,11 +440,11 @@ namespace UWUVCI_AIO_WPF } DirectoryCopy(baseRomPath,outputPath, true); - MessageBox.Show($"Injection Complete! The Inject is stored here:\n{outputPath}\n\nThe Configuration will not be cleared, so you can Export the Config if you want. To clear the Configuration, reselect the Console you want to Inject into.", "Inject Complete", MessageBoxButton.OK, MessageBoxImage.Information); + new Custom_Message("Injection Complete", $"Config will stay filled, choose a Console again to clear it.\nTo Open the Location of the Inject press Open Folder.", Settings.Default.OutPath).ShowDialog(); Clean(); } - + [STAThread] public static void Packing(string gameName, MainViewModel mvm) { mvm.msg = "Checking Tools..."; @@ -450,12 +481,8 @@ namespace UWUVCI_AIO_WPF mvm.msg = "Cleaning..."; Clean(); mvm.Progress = 100; - string extra = ""; - if (mvm.GameConfiguration.Console == GameConsoles.WII) extra = "\nDISCLAIMER: Some games cannot reboot into the WiiU Menu. Shut down the console via the GamePad Power Button.\nIf Stuck in a BlackScreen, you need to unplug your wiiu"; - if (mvm.GC) extra = "\nDISCLAIMER: Make sure to have Nintendont + config on your sd card. You can add them under Settings -> \"Start Nintendont Config Tool\""; - MessageBox.Show($"Injection Complete!\nDisclaimer: Only install injections to USB to prevent a brick in a worst case scenario{extra}\n\nThe Inject is stored here:\n{outputPath}\n\nThe Configuration will not be cleared, so you can Export the Config if you want. To clear the Configuration, reselect the Console you want to Inject into.", "Inject Complete", MessageBoxButton.OK, MessageBoxImage.Information); - + mvm.msg = ""; } public static void Download(MainViewModel mvm) @@ -1042,7 +1069,17 @@ namespace UWUVCI_AIO_WPF } else { - Images.Add(false); + if(File.Exists(Path.Combine(toolsPath, "iconTex.tga"))) + { + CopyAndConvertImage(Path.Combine(toolsPath, "iconTex.tga"), Path.Combine(imgPath), false, 128, 128, 32, "iconTex.tga"); + + Images.Add(true); + } + else + { + Images.Add(false); + } + } } else @@ -1051,6 +1088,36 @@ namespace UWUVCI_AIO_WPF CopyAndConvertImage($"iconTex.{config.TGAIco.extension}", Path.Combine(imgPath), true, 128, 128, 32, "iconTex.tga"); Images.Add(true); } + if (config.TGATv.ImgBin == null) + { + //use path + if (config.TGATv.ImgPath != null) + { + Images.Add(true); + CopyAndConvertImage(config.TGATv.ImgPath, Path.Combine(imgPath), false, 1280, 720, 24, "bootTvTex.tga"); + config.TGATv.ImgPath = Path.Combine(imgPath, "bootTvTex.tga"); + } + else + { + if (File.Exists(Path.Combine(toolsPath, "bootTvTex.tga"))) + { + CopyAndConvertImage(Path.Combine(toolsPath, "bootTvTex.tga"), Path.Combine(imgPath), false, 128, 128, 32, "iconTex.tga"); + + Images.Add(true); + } + else + { + Images.Add(false); + } + } + } + else + { + ReadFileFromBin(config.TGATv.ImgBin, $"bootTvTex.{config.TGATv.extension}"); + CopyAndConvertImage($"bootTvTex.{config.TGATv.extension}", Path.Combine(imgPath), true, 1280, 720, 24, "bootTvTex.tga"); + config.TGATv.ImgPath = Path.Combine(imgPath, "bootTvTex.tga"); + Images.Add(true); + } //Drc if (config.TGADrc.ImgBin == null) @@ -1063,7 +1130,30 @@ namespace UWUVCI_AIO_WPF } else { - Images.Add(false); + if (Images[1]) + { + using(Process conv = new Process()) + { + if (!mvvm.debug) + { + conv.StartInfo.UseShellExecute = false; + conv.StartInfo.CreateNoWindow = true; + } + conv.StartInfo.FileName = Path.Combine(toolsPath, "tga2png.exe"); + + conv.StartInfo.Arguments = $"-i \"{config.TGATv.ImgPath}\" -o \"{Path.Combine(tempPath)}\""; + conv.Start(); + conv.WaitForExit(); + File.Move(Path.Combine(tempPath, "bootTvTex.png"), Path.Combine(tempPath, "bootDrcTex.png")); + CopyAndConvertImage(Path.Combine(tempPath, "bootDrcTex.png"), Path.Combine(imgPath), false, 854, 480, 24, "bootDrcTex.tga"); + Images.Add(true); + } + } + else + { + Images.Add(false); + } + } } else @@ -1074,25 +1164,8 @@ namespace UWUVCI_AIO_WPF } //tv - if (config.TGATv.ImgBin == null) - { - //use path - if (config.TGATv.ImgPath != null) - { - Images.Add(true); - CopyAndConvertImage(config.TGATv.ImgPath, Path.Combine(imgPath), false,1280,720,24, "bootTvTex.tga"); - } - else - { - Images.Add(false); - } - } - else - { - ReadFileFromBin(config.TGATv.ImgBin, $"bootTvTex.{config.TGATv.extension}"); - CopyAndConvertImage($"bootTvTex.{config.TGATv.extension}", Path.Combine(imgPath), true, 1280, 720, 24, "bootTvTex.tga"); - Images.Add(true); - } + + //logo if (config.TGALog.ImgBin == null) @@ -1154,12 +1227,12 @@ namespace UWUVCI_AIO_WPF Console.ReadLine(); } - if (Images[2]) + if (Images[1]) { File.Delete(Path.Combine(baseRomPath, "meta", "bootTvTex.tga")); File.Move(Path.Combine(imgPath, "bootTvTex.tga"), Path.Combine(baseRomPath, "meta", "bootTvTex.tga")); } - if (Images[1]) + if (Images[2]) { File.Delete(Path.Combine(baseRomPath, "meta", "bootDrcTex.tga")); File.Move(Path.Combine(imgPath, "bootDrcTex.tga"), Path.Combine(baseRomPath, "meta", "bootDrcTex.tga")); @@ -1240,7 +1313,7 @@ namespace UWUVCI_AIO_WPF } } - private static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs) + public static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs) { // Get the subdirectories for the specified directory. DirectoryInfo dir = new DirectoryInfo(sourceDirName); diff --git a/UWUVCI AIO WPF/Classes/KeyFile.cs b/UWUVCI AIO WPF/Classes/KeyFile.cs index 8bb60d2..e3177aa 100644 --- a/UWUVCI AIO WPF/Classes/KeyFile.cs +++ b/UWUVCI AIO WPF/Classes/KeyFile.cs @@ -32,8 +32,8 @@ namespace UWUVCI_AIO_WPF.Classes } public static void ExportFile(List precomp, GameConsoles console) { - CheckAndFixFolder("keys"); - Stream createConfigStream = new FileStream($@"keys\{console.ToString().ToLower()}.vck", FileMode.Create, FileAccess.Write); + CheckAndFixFolder("bin\\keys"); + Stream createConfigStream = new FileStream($@"bin\keys\{console.ToString().ToLower()}.vck", FileMode.Create, FileAccess.Write); GZipStream compressedStream = new GZipStream(createConfigStream, CompressionMode.Compress); IFormatter formatter = new BinaryFormatter(); formatter.Serialize(compressedStream, precomp); diff --git a/UWUVCI AIO WPF/Classes/N64Conf.cs b/UWUVCI AIO WPF/Classes/N64Conf.cs index 2c89fbd..8dd1488 100644 --- a/UWUVCI AIO WPF/Classes/N64Conf.cs +++ b/UWUVCI AIO WPF/Classes/N64Conf.cs @@ -8,7 +8,7 @@ namespace UWUVCI_AIO_WPF.Classes { [Serializable] - class N64Conf + public class N64Conf { private string iniPath = null; diff --git a/UWUVCI AIO WPF/Classes/PNGTGA.cs b/UWUVCI AIO WPF/Classes/PNGTGA.cs index 3d98d37..604d128 100644 --- a/UWUVCI AIO WPF/Classes/PNGTGA.cs +++ b/UWUVCI AIO WPF/Classes/PNGTGA.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace UWUVCI_AIO_WPF.Classes { [Serializable] - class PNGTGA + public class PNGTGA { private string imgPath = null; diff --git a/UWUVCI AIO WPF/Classes/ToolCheck.cs b/UWUVCI AIO WPF/Classes/ToolCheck.cs index 78c7232..cbb0cbe 100644 --- a/UWUVCI AIO WPF/Classes/ToolCheck.cs +++ b/UWUVCI AIO WPF/Classes/ToolCheck.cs @@ -9,7 +9,7 @@ namespace UWUVCI_AIO_WPF.Classes { class ToolCheck { - static string FolderName = "Tools"; + static string FolderName = "bin\\Tools"; public static string[] ToolNames = { "CDecrypt.exe", @@ -39,7 +39,10 @@ namespace UWUVCI_AIO_WPF.Classes "cyggcc_s-1.dll", "IKVM.zip", "NintendontConfig.exe", - "BASE.zip" + "BASE.zip", + "tga2png.exe", + "iconTex.tga", + "wii-vnc.exe" }; public static bool DoesToolsFolderExist() diff --git a/UWUVCI AIO WPF/Models/MainViewModel.cs b/UWUVCI AIO WPF/Models/MainViewModel.cs index 5a492f5..a0d2da1 100644 --- a/UWUVCI AIO WPF/Models/MainViewModel.cs +++ b/UWUVCI AIO WPF/Models/MainViewModel.cs @@ -22,7 +22,7 @@ using AutoUpdaterDotNET; namespace UWUVCI_AIO_WPF { - class MainViewModel : BaseModel + public class MainViewModel : BaseModel { //public GameConfig GameConfiguration { get; set; } private GameConfig gameConfiguration = new GameConfig(); @@ -255,7 +255,10 @@ namespace UWUVCI_AIO_WPF public bool GC = false; public bool debug = false; public string doing = ""; + public bool Patch = false; + public bool toPal = false; private string Msg; + public string msg { @@ -282,6 +285,31 @@ namespace UWUVCI_AIO_WPF public MainViewModel() { + + //if (Directory.Exists(@"Tools")) Directory.Delete(@"Tools", true); + if (Directory.Exists(@"bases")) Directory.Delete(@"bases", true); + if (Directory.Exists(@"temp")) Directory.Delete(@"temp", true); + + if (Directory.Exists(@"keys")) + { + if(Directory.Exists(@"bin\keys")) Directory.Delete(@"bin\keys", true); + Injection.DirectoryCopy("keys", "bin/keys", true); + Directory.Delete("keys", true); + } + if (!Directory.Exists("InjectedGames")) Directory.CreateDirectory("InjectedGames"); + if (!Directory.Exists("SourceFiles")) Directory.CreateDirectory("SourceFiles"); + if (!Directory.Exists("bin\\BaseGames")) Directory.CreateDirectory("bin\\BaseGames"); + if(Properties.Settings.Default.OutPath == "" || Properties.Settings.Default.OutPath == null) + { + Settings.Default.OutPath = Path.Combine(Directory.GetCurrentDirectory(), "InjectedGames"); + } + if(Settings.Default.BasePath == "" || Properties.Settings.Default.BasePath == null) + { + Settings.Default.BasePath = Path.Combine(Directory.GetCurrentDirectory(), "bin", "BaseGames"); + } + Settings.Default.Save(); + ArePathsSet(); + Update(); toolCheck(); @@ -496,15 +524,20 @@ namespace UWUVCI_AIO_WPF if (loadiine) { Injection.Loadiine(GameConfiguration.GameName); - + // } else { Task.Run(() => { Injection.Packing(GameConfiguration.GameName, this); }); - new DownloadWait("Packing Inject - Please Wait", "").ShowDialog(); + new DownloadWait("Packing Inject - Please Wait", "",this).ShowDialog(); Progress = 0; + string extra = ""; + if (GameConfiguration.Console == GameConsoles.WII) extra = "\nSome games cannot reboot into the WiiU Menu. Shut down via the GamePad.\nIf Stuck in a BlackScreen, you need to unplug your WiiU."; + if (GC) extra = "\nMake sure to have Nintendon't + config on your SD.\nYou can add them under Settings -> \"Start Nintendont Config Tool\"."; + + new Custom_Message("Injection Complete", $"Only Install to USB!{extra}\nConfig will stay filled, choose a Console again to clear it!\nTo Open the Location of the Inject press Open Folder.", Settings.Default.OutPath).ShowDialog(); } LGameBasesString.Clear(); CanInject = false; @@ -514,72 +547,85 @@ namespace UWUVCI_AIO_WPF GameConfiguration.CBasePath = null; GC = false; } + [STAThread] public void Inject(bool force) { + Task.Run(() => { if (Injection.Inject(GameConfiguration, RomPath, this, force)) Injected = true; else Injected = false; }); - new DownloadWait("Injecting Game - Please Wait", "").ShowDialog(); - + new DownloadWait("Injecting Game - Please Wait", "",this).ShowDialog(); + if (Injected) + { + new Custom_Message("Finished Injection Part", "Injection Finished, please choose how you want to export the Inject next.").ShowDialog(); + } } private void BaseCheck() { - if (Directory.Exists(@"bases")) + if (Directory.Exists(@"bin\bases")) { var test = GetMissingVCBs(); - if(test.Count > 0) + if (test.Count > 0) { - DialogResult res = MessageBox.Show("There are vcb Base files missing in the bases folder. Would you like to download the missing base files?", "Error 004: \"Missing VCB Bases\"", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); - if(res == DialogResult.Yes) + Progress = 0; + Task.Run(() => { - foreach(string s in test) + double stuff = 100 / test.Count; + foreach (string s in test) { DownloadBase(s); - + Progress += Convert.ToInt32(stuff); } - BaseCheck(); - - } - else if(res == DialogResult.No) - { - MessageBox.Show("The Programm will now terminate."); - Environment.Exit(1); - } + Progress = 100; + }); + new DownloadWait("Downloading needed Data - Please Wait", "",this).ShowDialog(); + BaseCheck(); + + + } } else { - DialogResult res = MessageBox.Show("No bases folder found.\nShould a bases folder be created and the missing vcb bases downloaded?", "Error 003: \"Missing VCB Bases Folder\"", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); - if (res == DialogResult.Yes) + + Directory.CreateDirectory(@"bin\bases"); + var test = GetMissingVCBs(); + Progress = 0; + Task.Run(() => { - Directory.CreateDirectory(@"bases"); - var test = GetMissingVCBs(); + double stuff = 100 / test.Count; foreach (string s in test) { DownloadBase(s); - + Progress += Convert.ToInt32(stuff); } - BaseCheck(); - } - else - { - MessageBox.Show("The Programm will now terminate."); - Environment.Exit(1); - } + Progress = 100; + }); + new DownloadWait("Downloading needed Data - Please Wait", "",this).ShowDialog(); + BaseCheck(); + } - + } public void UpdateTools() { string[] bases = ToolCheck.ToolNames; - foreach (string s in bases) + Task.Run(() => { - DeleteTool(s); - DownloadTool(s); - } + Progress = 0; + double l = 100 / bases.Length; + foreach (string s in bases) + { + DeleteTool(s); + DownloadTool(s); + Progress += Convert.ToInt32(l); + } + Progress = 100; + }); + new DownloadWait("Updating Tools - Please Wait", "", this).ShowDialog(); MessageBox.Show("Finished Updating Tools! Restarting UWUVCI AIO"); System.Diagnostics.Process.Start(System.Windows.Application.ResourceAssembly.Location); Environment.Exit(0); @@ -589,13 +635,14 @@ namespace UWUVCI_AIO_WPF DialogResult res = MessageBox.Show("This Option will reset all entered TitleKeys meaning you will need to reenter them again!\nDo you still wish to continue?", "Resetting TitleKeys", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if(res == DialogResult.Yes) { - File.Delete("keys/gba.vck"); - File.Delete("keys/nds.vck"); - File.Delete("keys/nes.vck"); - File.Delete("keys/n64.vck"); - File.Delete("keys/msx.vck"); - File.Delete("keys/tg16.vck"); - File.Delete("keys/snes.vck"); + File.Delete("bin/keys/gba.vck"); + File.Delete("bin/keys/nds.vck"); + File.Delete("bin/keys/nes.vck"); + File.Delete("bin/keys/n64.vck"); + File.Delete("bin/keys/msx.vck"); + File.Delete("bin/keys/tg16.vck"); + File.Delete("bin/keys/snes.vck"); + File.Delete("bin/keys/wii.vck"); MessageBox.Show("Reset complete! The Programm will now Restart!"); System.Diagnostics.Process.Start(System.Windows.Application.ResourceAssembly.Location); Environment.Exit(0); @@ -606,22 +653,29 @@ namespace UWUVCI_AIO_WPF { string[] bases = { "bases.vcbnds", "bases.vcbn64", "bases.vcbgba", "bases.vcbsnes", "bases.vcbnes", "bases.vcbtg16", "bases.vcbmsx", "bases.vcbwii" }; - foreach(string s in bases) - { - DownloadBase(s); - DeleteBase(s); - CopyBase(s); - GameConsoles g = new GameConsoles(); - if (s.Contains("nds")) g = GameConsoles.NDS; - if (s.Contains("nes")) g = GameConsoles.NES; - if (s.Contains("snes")) g = GameConsoles.SNES; - if (s.Contains("n64")) g = GameConsoles.N64; - if (s.Contains("gba")) g = GameConsoles.GBA; - if (s.Contains("tg16")) g = GameConsoles.TG16; - if (s.Contains("msx")) g = GameConsoles.MSX; - if (s.Contains("wii")) g = GameConsoles.WII; - UpdateKeyFile(VCBTool.ReadBasesFromVCB($@"bases/{s}"),g); - } + Task.Run(() => { + Progress = 0; + double l = 100 / bases.Length; + foreach (string s in bases) + { + DeleteBase(s); + DownloadBase(s); + + GameConsoles g = new GameConsoles(); + if (s.Contains("nds")) g = GameConsoles.NDS; + if (s.Contains("nes")) g = GameConsoles.NES; + if (s.Contains("snes")) g = GameConsoles.SNES; + if (s.Contains("n64")) g = GameConsoles.N64; + if (s.Contains("gba")) g = GameConsoles.GBA; + if (s.Contains("tg16")) g = GameConsoles.TG16; + if (s.Contains("msx")) g = GameConsoles.MSX; + if (s.Contains("wii")) g = GameConsoles.WII; + UpdateKeyFile(VCBTool.ReadBasesFromVCB($@"bin/bases/{s}"), g); + Progress += Convert.ToInt32(l); + } + Progress = 100; + }); + new DownloadWait("Updating Base Files - Please Wait", "", this).ShowDialog(); MessageBox.Show("Finished Updating Bases! Restarting UWUVCI AIO"); System.Diagnostics.Process.Start(System.Windows.Application.ResourceAssembly.Location); Environment.Exit(0); @@ -759,22 +813,22 @@ namespace UWUVCI_AIO_WPF private static void CopyBase(string console) { - File.Copy(console, $@"bases\{console}"); + File.Copy(console, $@"bin\bases\{console}"); File.Delete(console); } private static void DeleteTool(string tool) { - File.Delete($@"Tools\{tool}"); + File.Delete($@"bin\Tools\{tool}"); } private static void DeleteBase(string console) { - File.Delete($@"bases\{console}"); + File.Delete($@"bin\bases\{console}"); } public static List GetMissingVCBs() { List ret = new List(); - string path = @"bases\bases.vcb"; + string path = @"bin\bases\bases.vcb"; if (!File.Exists(path + "nds")) { ret.Add(path + "nds"); @@ -811,12 +865,16 @@ namespace UWUVCI_AIO_WPF } public static void DownloadBase(string name) { + string olddir = Directory.GetCurrentDirectory(); try { - string basePath = $@"\bases\{name}"; + string basePath = $@"bin\bases\"; + Directory.SetCurrentDirectory(basePath); using (var client = new WebClient()) + { - client.DownloadFile(getDownloadLink(name, false), name); + var fixname = name.Split('\\'); + client.DownloadFile(getDownloadLink(name, false), fixname[fixname.Length -1]); } }catch(Exception e) { @@ -824,18 +882,21 @@ namespace UWUVCI_AIO_WPF MessageBox.Show("There was an Error downloading the VCB Base File.\nThe Programm will now terminate.", "Error 005: \"Unable to Download VCB Base\"", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(1); } - + Directory.SetCurrentDirectory(olddir); } public static void DownloadTool(string name) { + string olddir = Directory.GetCurrentDirectory(); try { - string basePath = $@"Tools\{name}"; + + + string basePath = $@"bin\Tools\"; + Directory.SetCurrentDirectory(basePath); using (var client = new WebClient()) { client.DownloadFile(getDownloadLink(name, true), name); - File.Copy(name, basePath); - File.Delete(name); + } } @@ -845,7 +906,7 @@ namespace UWUVCI_AIO_WPF MessageBox.Show("There was an Error downloading the Tool.\nThe Programm will now terminate.", "Error 006: \"Unable to Download Tool\"", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(1); } - + Directory.SetCurrentDirectory(olddir); } private static string getDownloadLink(string toolname, bool tool) { @@ -879,7 +940,6 @@ namespace UWUVCI_AIO_WPF return null; } } - public void InjcttoolCheck() { if (ToolCheck.DoesToolsFolderExist()) @@ -889,21 +949,26 @@ namespace UWUVCI_AIO_WPF missingTools = ToolCheck.CheckForMissingTools(); if (missingTools.Count > 0) { - MessageBox.Show("There are tools missing.\nThe Download will start after you press OK", "Missing Tools", MessageBoxButtons.OK, MessageBoxIcon.Information); - //Download Tools + + + foreach (MissingTool m in missingTools) { DownloadTool(m.Name); + } + + + InjcttoolCheck(); } } else { - string path = $@"{Directory.GetCurrentDirectory()}\Tools"; + string path = $@"{Directory.GetCurrentDirectory()}bin\\Tools"; - Directory.CreateDirectory("Tools"); + Directory.CreateDirectory($@"{Directory.GetCurrentDirectory()}bin\\Tools"); InjcttoolCheck(); } @@ -917,44 +982,26 @@ namespace UWUVCI_AIO_WPF missingTools = ToolCheck.CheckForMissingTools(); if(missingTools.Count > 0) { - string errorMessage = "Error 002:\nFollowing Tools seem to be missing:\n\n"; - foreach(MissingTool m in missingTools) - { - errorMessage += $"{m.Name}\n"; - } - errorMessage += "\nDo you want to automatically download them?"; - DialogResult res = MessageBox.Show(errorMessage, "Error 002: \"Missing Tools\"", MessageBoxButtons.YesNo, MessageBoxIcon.Error); + + - if (res == DialogResult.Yes) - { - //Download Tools - foreach(MissingTool m in missingTools) + foreach (MissingTool m in missingTools) { DownloadTool(m.Name); } + + //Download Tools + toolCheck(); - } - else - { - MessageBox.Show("The Programm will now terminate"); - Environment.Exit(1); - } + } } else { - string path = $@"{Directory.GetCurrentDirectory()}\Tools"; - DialogResult res = MessageBox.Show($"Error: 001\nThe Tools folder seems to be missing.\nDo you want to create one?", "Error 001: \"Missing Tools folder\"", MessageBoxButtons.YesNo, MessageBoxIcon.Error); - if(res == DialogResult.Yes) - { - Directory.CreateDirectory("Tools"); + + Directory.CreateDirectory("bin/Tools"); toolCheck(); - } - else - { - MessageBox.Show("The Programm will now terminate"); - Environment.Exit(1); - } + } } @@ -1012,7 +1059,7 @@ namespace UWUVCI_AIO_WPF public void GetBases(GameConsoles Console) { List lTemp = new List(); - string vcbpath = $@"bases/bases.vcb{Console.ToString().ToLower()}"; + string vcbpath = $@"bin/bases/bases.vcb{Console.ToString().ToLower()}"; lTemp = VCBTool.ReadBasesFromVCB(vcbpath); LBases.Clear(); GameBases custom = new GameBases(); @@ -1103,14 +1150,14 @@ namespace UWUVCI_AIO_WPF LTG16.Clear(); LMSX.Clear(); LWII.Clear(); - lNDS = VCBTool.ReadBasesFromVCB($@"bases/bases.vcbnds"); - lNES = VCBTool.ReadBasesFromVCB($@"bases/bases.vcbnes"); - lSNES = VCBTool.ReadBasesFromVCB($@"bases/bases.vcbsnes"); - lN64 = VCBTool.ReadBasesFromVCB($@"bases/bases.vcbn64"); - lGBA = VCBTool.ReadBasesFromVCB($@"bases/bases.vcbgba"); - lTG16 = VCBTool.ReadBasesFromVCB($@"bases/bases.vcbtg16"); - lMSX = VCBTool.ReadBasesFromVCB($@"bases/bases.vcbmsx"); - lWii = VCBTool.ReadBasesFromVCB($@"bases/bases.vcbwii"); + 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"); CreateSettingIfNotExist(lNDS, GameConsoles.NDS); CreateSettingIfNotExist(lNES, GameConsoles.NES); CreateSettingIfNotExist(lSNES, GameConsoles.SNES); @@ -1122,7 +1169,7 @@ namespace UWUVCI_AIO_WPF } private void CreateSettingIfNotExist(List l, GameConsoles console) { - string file = $@"keys\{console.ToString().ToLower()}.vck"; + string file = $@"bin\keys\{console.ToString().ToLower()}.vck"; if (!File.Exists(file)) { List temp = new List(); @@ -1138,10 +1185,10 @@ namespace UWUVCI_AIO_WPF } private void UpdateKeyFile(List l, GameConsoles console) { - string file = $@"keys\{console.ToString().ToLower()}.vck"; + string file = $@"bin\keys\{console.ToString().ToLower()}.vck"; if (File.Exists(file)) { - List keys = KeyFile.ReadBasesFromKeyFile($@"keys\{console.ToString().ToLower()}.vck"); + List keys = KeyFile.ReadBasesFromKeyFile($@"bin\keys\{console.ToString().ToLower()}.vck"); List newTK = new List(); foreach(GameBases gb in l) { @@ -1163,7 +1210,7 @@ namespace UWUVCI_AIO_WPF newTK.Add(tkn); } } - File.Delete($@"keys\{console.ToString().ToLower()}.vck"); + File.Delete($@"bin\keys\{console.ToString().ToLower()}.vck"); KeyFile.ExportFile(newTK, console); } } @@ -1229,7 +1276,7 @@ namespace UWUVCI_AIO_WPF { if(GbTemp.KeyHash == key.ToLower().GetHashCode()) { - UpdateKeyInFile(key, $@"keys\{GetConsoleOfBase(gbTemp).ToString().ToLower()}.vck", GbTemp, GetConsoleOfBase(gbTemp)); + UpdateKeyInFile(key, $@"bin\keys\{GetConsoleOfBase(gbTemp).ToString().ToLower()}.vck", GbTemp, GetConsoleOfBase(gbTemp)); return true; } return false; @@ -1252,7 +1299,7 @@ namespace UWUVCI_AIO_WPF } public bool isKeySet(GameBases bases) { - var temp = KeyFile.ReadBasesFromKeyFile($@"keys\{GetConsoleOfBase(bases).ToString().ToLower()}.vck"); + var temp = KeyFile.ReadBasesFromKeyFile($@"bin\keys\{GetConsoleOfBase(bases).ToString().ToLower()}.vck"); foreach(TKeys t in temp) { if(t.Base.Name == bases.Name && t.Base.Region == bases.Region) @@ -1282,7 +1329,7 @@ namespace UWUVCI_AIO_WPF } public TKeys getTkey(GameBases bases) { - var temp = KeyFile.ReadBasesFromKeyFile($@"keys\{GetConsoleOfBase(bases).ToString().ToLower()}.vck"); + var temp = KeyFile.ReadBasesFromKeyFile($@"bin\keys\{GetConsoleOfBase(bases).ToString().ToLower()}.vck"); foreach (TKeys t in temp) { if (t.Base.Name == bases.Name && t.Base.Region == bases.Region) @@ -1300,7 +1347,7 @@ namespace UWUVCI_AIO_WPF { Task.Run(() => { Injection.Download(this); }); - new DownloadWait("Downloading Base - Please Wait", "test").ShowDialog(); + new DownloadWait("Downloading Base - Please Wait", "", this).ShowDialog(); Progress = 0; } @@ -1512,10 +1559,9 @@ namespace UWUVCI_AIO_WPF { if (ValidatePathsStillExist()) { - if (isCkeySet()) - { + Settings.Default.PathsSet = true; - } + Settings.Default.Save(); } diff --git a/UWUVCI AIO WPF/UI/Frames/InjectFrame.xaml b/UWUVCI AIO WPF/UI/Frames/InjectFrame.xaml index a0a8a23..b076aac 100644 --- a/UWUVCI AIO WPF/UI/Frames/InjectFrame.xaml +++ b/UWUVCI AIO WPF/UI/Frames/InjectFrame.xaml @@ -18,7 +18,7 @@