Downloading missing tools if they get deleted during runtime

This commit is contained in:
NicoAICP 2020-04-10 22:23:49 +02:00
parent 03514b7abc
commit 97aafc5388
2 changed files with 36 additions and 5 deletions

View file

@ -36,8 +36,9 @@ namespace UWUVCI_AIO_WPF
* darkRemoval = Only used for N64. Indicates whether the dark filter should be removed.
*/
public static bool Inject(GameConfig Configuration, string RomPath)
public static bool Inject(GameConfig Configuration, string RomPath, MainViewModel mvm)
{
mvm.InjcttoolCheck();
try
{
@ -183,8 +184,9 @@ namespace UWUVCI_AIO_WPF
Clean();
}
public static void Packing(string gameName)
public static void Packing(string gameName, MainViewModel mvm)
{
mvm.InjcttoolCheck();
if (gameName == null || gameName == string.Empty) gameName = "NoName";
//string outputPath = Path.Combine(Properties.Settings.Default.InjectionPath, gameName);
string outputPath = Path.Combine(Properties.Settings.Default.OutPath, $"[WUP]{gameName}");
@ -213,7 +215,7 @@ namespace UWUVCI_AIO_WPF
public static void Download(MainViewModel mvm)
{
mvm.InjcttoolCheck();
//GetCurrentSelectedBase
GameBases b = mvm.getBasefromName(mvm.SelectedBaseAsString);
//GetKeyOfBase

View file

@ -471,7 +471,7 @@ namespace UWUVCI_AIO_WPF
}
else
{
Injection.Packing(GameConfiguration.GameName);
Injection.Packing(GameConfiguration.GameName, this);
}
LGameBasesString.Clear();
CanInject = false;
@ -483,7 +483,7 @@ namespace UWUVCI_AIO_WPF
}
public void Inject()
{
if (Injection.Inject(GameConfiguration, RomPath)) Injected = true;
if (Injection.Inject(GameConfiguration, RomPath, this)) Injected = true;
else Injected = false;
@ -803,6 +803,35 @@ namespace UWUVCI_AIO_WPF
}
}
public void InjcttoolCheck()
{
if (ToolCheck.DoesToolsFolderExist())
{
List<MissingTool> missingTools = new List<MissingTool>();
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";
Directory.CreateDirectory("Tools");
InjcttoolCheck();
}
}
private void toolCheck()
{
if (ToolCheck.DoesToolsFolderExist())