Wii Update Simulation outputs NUS Script

This commit is contained in:
givememystuffplease 2009-08-28 03:12:10 +00:00
parent 51b148aaab
commit 622682371c

View File

@ -46,6 +46,7 @@ namespace NUS_Downloader
// TODO: OOP scripting // TODO: OOP scripting
string script_filename; string script_filename;
bool script_mode = false;
// Proxy stuff... // Proxy stuff...
string proxy_url; string proxy_url;
@ -711,7 +712,7 @@ namespace NUS_Downloader
WriteStatus("Please enter SOME info..."); WriteStatus("Please enter SOME info...");
return; return;
} }
else else if (!(script_mode))
{ {
try try
{ {
@ -723,6 +724,8 @@ namespace NUS_Downloader
statusbox.Text = " --- " + titleidbox.Text + " ---"; statusbox.Text = " --- " + titleidbox.Text + " ---";
} }
} }
else
statusbox.Text += "\r\n --- " + titleidbox.Text + " ---";
// Handle SaveAs here so it shows up properly... // Handle SaveAs here so it shows up properly...
if (saveaswadbox.Checked) if (saveaswadbox.Checked)
@ -746,7 +749,8 @@ namespace NUS_Downloader
{ {
// Preparations for Downloading // Preparations for Downloading
Control.CheckForIllegalCrossThreadCalls = false; Control.CheckForIllegalCrossThreadCalls = false;
WriteStatus("Starting NUS Download. Please be patient!"); if (!(script_mode))
WriteStatus("Starting NUS Download. Please be patient!");
SetEnableforDownload(false); SetEnableforDownload(false);
downloadstartbtn.Text = "Starting NUS Download!"; downloadstartbtn.Text = "Starting NUS Download!";
@ -1173,6 +1177,9 @@ namespace NUS_Downloader
if (IsWin7()) if (IsWin7())
dlprogress.ShowInTaskbar = false; dlprogress.ShowInTaskbar = false;
if (script_mode)
statusbox.Text = "";
} }
/// <summary> /// <summary>
@ -3571,6 +3578,8 @@ namespace NUS_Downloader
return; return;
} }
string script_text = "";
XmlDocument xDoc = new XmlDocument(); XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(update_xml); xDoc.LoadXml(update_xml);
XmlNodeList TitleList = xDoc.GetElementsByTagName("TitleVersion"); XmlNodeList TitleList = xDoc.GetElementsByTagName("TitleVersion");
@ -3598,7 +3607,25 @@ namespace NUS_Downloader
if ((File.Exists("database.xml") == true) && ((!(String.IsNullOrEmpty(NameFromDatabase(TitleID)))))) if ((File.Exists("database.xml") == true) && ((!(String.IsNullOrEmpty(NameFromDatabase(TitleID))))))
statusbox.Text += String.Format(" [{0}]", NameFromDatabase(TitleID)); statusbox.Text += String.Format(" [{0}]", NameFromDatabase(TitleID));
script_text += String.Format("{0} {1}\n", TitleID, DisplayBytes(NewIntegertoByteArray(Convert.ToInt32(Version), 2), ""));
} }
WriteStatus(" - Outputting results to NUS script...");
// Current directory...
string currentdir = Application.StartupPath;
if (!(currentdir.EndsWith(@"\")) || !(currentdir.EndsWith(@"/")))
currentdir += @"\";
if (!(Directory.Exists(currentdir + "scripts")))
{
Directory.CreateDirectory(currentdir + "scripts");
WriteStatus(" - Created 'scrips\' directory.");
}
string time = RemoveIllegalCharacters(DateTime.Now.ToShortTimeString());
File.WriteAllText(String.Format(currentdir + "scripts\\{0}_Update_{1}_{2}_{3} {4}.nus", RegionID, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Year, time), script_text);
WriteStatus(" - Script written!");
} }
/// <summary> /// <summary>
@ -3898,6 +3925,7 @@ namespace NUS_Downloader
private void RunScript(object sender, System.ComponentModel.DoWorkEventArgs e) private void RunScript(object sender, System.ComponentModel.DoWorkEventArgs e)
{ {
Control.CheckForIllegalCrossThreadCalls = false; Control.CheckForIllegalCrossThreadCalls = false;
script_mode = true;
WriteStatus("Starting script download. Please be patient!"); WriteStatus("Starting script download. Please be patient!");
string[] NUS_Entries = File.ReadAllLines(script_filename); string[] NUS_Entries = File.ReadAllLines(script_filename);
WriteStatus(String.Format(" - Script loaded ({0} Titles)", NUS_Entries.Length)); WriteStatus(String.Format(" - Script loaded ({0} Titles)", NUS_Entries.Length));
@ -3905,6 +3933,7 @@ namespace NUS_Downloader
for (int a = 0; a < NUS_Entries.Length; a++) for (int a = 0; a < NUS_Entries.Length; a++)
{ {
// Download the title // Download the title
WriteStatus(String.Format(" - Running Download ({0}/{1})", a+1, NUS_Entries.Length));
string[] title_info = NUS_Entries[a].Split(' '); string[] title_info = NUS_Entries[a].Split(' ');
titleidbox.Text = title_info[0]; titleidbox.Text = title_info[0];
titleversion.Text = Convert.ToString(256*(byte.Parse(title_info[1].Substring(0, 2), System.Globalization.NumberStyles.HexNumber))); titleversion.Text = Convert.ToString(256*(byte.Parse(title_info[1].Substring(0, 2), System.Globalization.NumberStyles.HexNumber)));
@ -3919,7 +3948,7 @@ namespace NUS_Downloader
Thread.Sleep(1000); Thread.Sleep(1000);
} }
} }
script_mode = false;
WriteStatus("Script completed!"); WriteStatus("Script completed!");
} }
} }