Script changes/additions

This commit is contained in:
givememystuffplease 2010-07-04 19:35:18 +00:00
parent daad018539
commit 50c36435ca
8 changed files with 152 additions and 40 deletions

View File

@ -92,7 +92,10 @@
this.consoleCBox = new System.Windows.Forms.ComboBox();
this.scriptsbutton = new System.Windows.Forms.Button();
this.scriptsStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
this.scriptsLocalMenuEntry = new System.Windows.Forms.ToolStripMenuItem();
this.scriptsDatabaseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.loadNUSScriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.emulateUpdate = new System.Windows.Forms.ToolStripMenuItem();
this.uSANTSCToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.europePALToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -101,8 +104,6 @@
this.titleversion = new wmgCMS.WaterMarkTextBox();
this.titleidbox = new wmgCMS.WaterMarkTextBox();
this.dlprogress = new wyDay.Controls.Windows7ProgressBar();
this.scriptsMainMenuEntry = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.databaseStrip.SuspendLayout();
this.extrasStrip.SuspendLayout();
this.proxyBox.SuspendLayout();
@ -652,13 +653,30 @@
// scriptsStrip
//
this.scriptsStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.scriptsMainMenuEntry,
this.scriptsLocalMenuEntry,
this.scriptsDatabaseToolStripMenuItem,
this.loadNUSScriptToolStripMenuItem,
this.toolStripSeparator2,
this.emulateUpdate});
this.scriptsStrip.Name = "scriptsStrip";
this.scriptsStrip.ShowItemToolTips = false;
this.scriptsStrip.Size = new System.Drawing.Size(220, 76);
this.scriptsStrip.Size = new System.Drawing.Size(220, 120);
//
// scriptsLocalMenuEntry
//
this.scriptsLocalMenuEntry.Enabled = false;
this.scriptsLocalMenuEntry.Image = global::NUS_Downloader.Properties.Resources.script_code;
this.scriptsLocalMenuEntry.Name = "scriptsLocalMenuEntry";
this.scriptsLocalMenuEntry.Size = new System.Drawing.Size(219, 22);
this.scriptsLocalMenuEntry.Text = "Scripts (Local)";
//
// scriptsDatabaseToolStripMenuItem
//
this.scriptsDatabaseToolStripMenuItem.Enabled = false;
this.scriptsDatabaseToolStripMenuItem.Image = global::NUS_Downloader.Properties.Resources.script_code_red;
this.scriptsDatabaseToolStripMenuItem.Name = "scriptsDatabaseToolStripMenuItem";
this.scriptsDatabaseToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
this.scriptsDatabaseToolStripMenuItem.Text = "Scripts (Database)";
//
// loadNUSScriptToolStripMenuItem
//
@ -668,6 +686,11 @@
this.loadNUSScriptToolStripMenuItem.Text = "Load NUS Script";
this.loadNUSScriptToolStripMenuItem.Click += new System.EventHandler(this.loadNUSScriptToolStripMenuItem_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(216, 6);
//
// emulateUpdate
//
this.emulateUpdate.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -684,25 +707,25 @@
// uSANTSCToolStripMenuItem
//
this.uSANTSCToolStripMenuItem.Name = "uSANTSCToolStripMenuItem";
this.uSANTSCToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.uSANTSCToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
this.uSANTSCToolStripMenuItem.Text = "USA";
//
// europePALToolStripMenuItem
//
this.europePALToolStripMenuItem.Name = "europePALToolStripMenuItem";
this.europePALToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.europePALToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
this.europePALToolStripMenuItem.Text = "EUROPE";
//
// japanNTSCJToolStripMenuItem
//
this.japanNTSCJToolStripMenuItem.Name = "japanNTSCJToolStripMenuItem";
this.japanNTSCJToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.japanNTSCJToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
this.japanNTSCJToolStripMenuItem.Text = "JAPAN";
//
// koreaToolStripMenuItem
//
this.koreaToolStripMenuItem.Name = "koreaToolStripMenuItem";
this.koreaToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.koreaToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
this.koreaToolStripMenuItem.Text = "KOREA";
//
// titleversion
@ -739,18 +762,6 @@
this.dlprogress.Size = new System.Drawing.Size(250, 15);
this.dlprogress.TabIndex = 47;
//
// scriptsMainMenuEntry
//
this.scriptsMainMenuEntry.Enabled = false;
this.scriptsMainMenuEntry.Name = "scriptsMainMenuEntry";
this.scriptsMainMenuEntry.Size = new System.Drawing.Size(219, 22);
this.scriptsMainMenuEntry.Text = "Scripts\\";
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(216, 6);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -870,8 +881,9 @@
private System.Windows.Forms.ToolStripMenuItem koreaToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
private System.Windows.Forms.ToolStripMenuItem updateDatabaseToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem scriptsMainMenuEntry;
private System.Windows.Forms.ToolStripMenuItem scriptsLocalMenuEntry;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem scriptsDatabaseToolStripMenuItem;
}
}

View File

@ -84,6 +84,9 @@ namespace NUS_Downloader
// Database thread
private BackgroundWorker fds;
// Scripts Thread
private BackgroundWorker scriptsWorker;
// Common Key hash
private byte[] wii_commonkey_sha1 = new byte[20]
{
@ -132,11 +135,20 @@ namespace NUS_Downloader
KoreaMassUpdate.DropDownItemClicked += new ToolStripItemClickedEventHandler(upditem_itemclicked);
NTSCMassUpdate.DropDownItemClicked += new ToolStripItemClickedEventHandler(upditem_itemclicked);
PALMassUpdate.DropDownItemClicked += new ToolStripItemClickedEventHandler(upditem_itemclicked);
// Database BGLoader
this.fds = new BackgroundWorker();
this.fds.DoWork += new DoWorkEventHandler(DoAllDatabaseyStuff);
this.fds.RunWorkerCompleted += new RunWorkerCompletedEventHandler(DoAllDatabaseyStuff_Completed);
this.fds.ProgressChanged += new ProgressChangedEventHandler(DoAllDatabaseyStuff_ProgressChanged);
this.fds.WorkerReportsProgress = true;
// Scripts BGLoader
this.scriptsWorker = new BackgroundWorker();
this.scriptsWorker.DoWork += new DoWorkEventHandler(OrganizeScripts);
this.scriptsWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(scriptsWorker_RunWorkerCompleted);
RunScriptOrganizer();
BootChecks();
}
@ -169,22 +181,31 @@ namespace NUS_Downloader
consoleCBox.SelectedIndex = 0;
}
private bool NUSDFileExists(string filename)
{
if (File.Exists(Path.Combine(CURRENT_DIR, filename)))
return true;
else
return false;
}
/// <summary>
/// Checks certain file existances, etc.
/// </summary>
/// <returns></returns>
private void BootChecks()
{
// Check if correct thread...
/* Check if correct thread...
if (this.InvokeRequired)
{
Debug.WriteLine("InvokeRequired...");
BootChecksCallback bcc = new BootChecksCallback(BootChecks);
this.Invoke(bcc);
return;
}
}*/
// Check for Wii common key bin file...
if (File.Exists(Path.Combine(CURRENT_DIR, "key.bin")) == false)
if (NUSDFileExists("key.bin") == false)
{
WriteStatus("Common Key (key.bin) missing! Decryption disabled!");
WriteStatus(" - Try: Extras -> Retrieve Key -> Common Key");
@ -214,43 +235,43 @@ namespace NUS_Downloader
}
// Check for Wii KOR common key bin file...
if (File.Exists(Path.Combine(CURRENT_DIR, "kkey.bin")) == true)
if (NUSDFileExists("kkey.bin") == true)
{
WriteStatus("Korean Common Key detected.");
}
// Check for DSi common key bin file...
if (File.Exists(Path.Combine(CURRENT_DIR, "dsikey.bin")) == true)
if (NUSDFileExists("dsikey.bin") == true)
{
WriteStatus("DSi Common Key detected.");
dsidecrypt = true;
}
// Check for database.xml
if (File.Exists(Path.Combine(CURRENT_DIR, "database.xml")) == false)
if (NUSDFileExists("database.xml") == false)
{
WriteStatus("Database.xml not found. Title database not usable!");
//databaseButton.Visible = false;
//Extrasbtn.Size = new System.Drawing.Size(134, 20);
databaseButton.Click -= new System.EventHandler(this.button4_Click);
/*databaseButton.Click -= new System.EventHandler(this.button4_Click);
databaseButton.Click += new System.EventHandler(this.updateDatabaseToolStripMenuItem_Click);
databaseButton.Text = "Download DB";
//updateDatabaseToolStripMenuItem.Text = "Download Database";
databaseButton.Text = "Download DB"; */
DatabaseEnabled(false);
updateDatabaseToolStripMenuItem.Enabled = true;
updateDatabaseToolStripMenuItem.Text = "Download Database";
}
else
{
string version = GetDatabaseVersion("database.xml");
WriteStatus("Database.xml detected.");
WriteStatus(" - Version: " + version);
updateDatabaseToolStripMenuItem.Text = "Update Database";
databaseButton.Enabled = false;
databaseButton.Text = "DB Loading";
updateDatabaseToolStripMenuItem.Text = "Update Database";
// Load it up...
this.fds.RunWorkerAsync();
}
// Check for Proxy Settings file...
if (File.Exists(Path.Combine(CURRENT_DIR, "proxy.txt")) == true)
if (NUSDFileExists("proxy.txt") == true)
{
WriteStatus("Proxy settings detected.");
string[] proxy_file = File.ReadAllLines(Path.Combine(CURRENT_DIR, "proxy.txt"));
@ -288,6 +309,12 @@ namespace NUS_Downloader
this.databaseButton.Text = "DB: " + e.ProgressPercentage + "%";
}
private void RunScriptOrganizer()
{
this.scriptsWorker.RunWorkerAsync();
scriptsLocalMenuEntry.Enabled = true;
}
private void SetAllEnabled(bool enabled)
{
for (int a = 0; a < this.Controls.Count; a++)
@ -2447,7 +2474,6 @@ namespace NUS_Downloader
WriteStatus("Database successfully created!");
databaseButton.Visible = true;
databaseButton.Enabled = false;
Extrasbtn.Size = new System.Drawing.Size(55, 20);
updateDatabaseToolStripMenuItem.Text = "Download Database";
}
else
@ -3080,5 +3106,45 @@ namespace NUS_Downloader
// Show scripts menu
scriptsStrip.Show(scriptsbutton, 2, 2);
}
private void DatabaseEnabled(bool enabled)
{
for (int a = 0; a < databaseStrip.Items.Count; a++)
{
databaseStrip.Items[a].Enabled = false;
}
}
void scriptsWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
//throw new NotImplementedException();
}
void OrganizeScripts(object sender, DoWorkEventArgs e)
{
//throw new NotImplementedException();
foreach (string directory in Directory.GetDirectories(Path.Combine(CURRENT_DIR, "scripts"), "*", SearchOption.TopDirectoryOnly))
{
if (Directory.GetFiles(directory, "*.nus", SearchOption.TopDirectoryOnly).Length > 0)
{
DirectoryInfo dinfo = new DirectoryInfo(directory);
ToolStripMenuItem folder_item = new ToolStripMenuItem();
folder_item.Text = dinfo.Name + Path.DirectorySeparatorChar;
folder_item.Image = Properties.Resources.folder_table;
foreach (string nusscript in Directory.GetFiles(directory, "*.nus", SearchOption.TopDirectoryOnly))
{
FileInfo finfo = new FileInfo(nusscript);
ToolStripMenuItem nus_script_item = new ToolStripMenuItem();
nus_script_item.Text = finfo.Name;
nus_script_item.Image = Properties.Resources.script_go;
folder_item.DropDownItems.Add(nus_script_item);
}
scriptsLocalMenuEntry.DropDownItems.Add(folder_item);
}
}
}
}
}

View File

@ -124,7 +124,10 @@
</ItemGroup>
<ItemGroup>
<Content Include="direction_down.ico" />
<None Include="Resources\script_code_red.png" />
<None Include="Resources\script_code.png" />
<None Include="Resources\database_save.png" />
<None Include="Resources\folder_table.png" />
<Content Include="Resources\key.png" />
<None Include="Resources\page_white_magnify.png" />
<None Include="Resources\server_link.png" />

View File

@ -144,6 +144,13 @@ namespace NUS_Downloader.Properties {
}
}
internal static System.Drawing.Bitmap folder_table {
get {
object obj = ResourceManager.GetObject("folder_table", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap help {
get {
object obj = ResourceManager.GetObject("help", resourceCulture);
@ -186,6 +193,20 @@ namespace NUS_Downloader.Properties {
}
}
internal static System.Drawing.Bitmap script_code {
get {
object obj = ResourceManager.GetObject("script_code", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap script_code_red {
get {
object obj = ResourceManager.GetObject("script_code_red", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap script_go {
get {
object obj = ResourceManager.GetObject("script_go", resourceCulture);

View File

@ -130,12 +130,18 @@
<data name="arrow_up" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrow_up.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="script_code" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\script_code.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="bullet_redgreen" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\bullet_redgreen.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arrow_down" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrow_down.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="server_link" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\server_link.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="server_connect" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\server_connect.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@ -145,12 +151,12 @@
<data name="bullet_green" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\bullet_green.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="bug_error" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\bug_error.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="page_white_magnify" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\page_white_magnify.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="bug_error" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\bug_error.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="script_go" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\script_go.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@ -163,8 +169,8 @@
<data name="link" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\link.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="server_link" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\server_link.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="script_code_red" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\script_code_red.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="key" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\key.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
@ -181,4 +187,8 @@
<data name="database_save" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\database_save.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="folder_table" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\folder_table.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B