2010-07-09 19:54:13 +02:00
|
|
|
|
///////////////////////////////////////////
|
|
|
|
|
// NUS Downloader: Form1.cs //
|
|
|
|
|
// $Rev:: $ //
|
|
|
|
|
// $Author:: $ //
|
|
|
|
|
// $Date:: $ //
|
|
|
|
|
///////////////////////////////////////////
|
2010-07-05 04:08:41 +02:00
|
|
|
|
|
2010-07-05 20:12:14 +02:00
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
// Copyright (C) 2010
|
|
|
|
|
//
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
|
2010-07-05 04:08:41 +02:00
|
|
|
|
|
|
|
|
|
using System;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using System.Xml;
|
2009-07-09 04:11:22 +02:00
|
|
|
|
using System.Drawing;
|
2009-08-04 20:17:21 +02:00
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Threading;
|
2009-08-06 04:37:39 +02:00
|
|
|
|
using System.Text;
|
2010-07-01 02:40:30 +02:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
2009-06-11 03:16:49 +02:00
|
|
|
|
namespace NUS_Downloader
|
|
|
|
|
{
|
2010-07-10 05:32:53 +02:00
|
|
|
|
partial class Form1 : Form
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
2010-07-04 19:18:50 +02:00
|
|
|
|
private readonly string CURRENT_DIR = Directory.GetCurrentDirectory();
|
|
|
|
|
|
2010-07-09 23:24:22 +02:00
|
|
|
|
#if DEBUG
|
|
|
|
|
private static string svnversion = "$Rev$";
|
2010-07-09 23:30:15 +02:00
|
|
|
|
private static string version = String.Format("SVN r{0}", ((int.Parse(svnversion.Replace("$"+"R"+"e"+"v"+": ","").Replace(" "+"$","")))+1));
|
2010-07-09 23:24:22 +02:00
|
|
|
|
#else
|
2010-07-09 23:30:15 +02:00
|
|
|
|
// TODO: Always remember to change version!
|
2010-07-04 20:17:05 +02:00
|
|
|
|
private string version = "v2.0 Beta";
|
2010-07-09 23:24:22 +02:00
|
|
|
|
#endif
|
2010-07-09 23:30:15 +02:00
|
|
|
|
|
2010-07-04 05:24:51 +02:00
|
|
|
|
private static bool dsidecrypt = false;
|
2010-07-01 02:40:30 +02:00
|
|
|
|
|
|
|
|
|
// Cross-thread Windows Formsing
|
2010-07-04 05:24:51 +02:00
|
|
|
|
private delegate void AddToolStripItemToStripCallback(
|
2010-07-09 22:41:01 +02:00
|
|
|
|
ToolStripMenuItem menulist, ToolStripMenuItem additionitem);
|
2010-07-10 02:40:09 +02:00
|
|
|
|
private delegate void WriteStatusCallback(string Update, Color writecolor);
|
2010-07-04 20:17:05 +02:00
|
|
|
|
private delegate void BootChecksCallback();
|
2010-07-05 04:00:18 +02:00
|
|
|
|
private delegate void SetEnableForDownloadCallback(bool enabled);
|
2010-07-06 20:41:11 +02:00
|
|
|
|
private delegate void SetPropertyThreadSafeCallback(System.ComponentModel.Component what, object setto, string property);
|
2010-07-08 18:55:01 +02:00
|
|
|
|
private delegate string OfficialWADNamingCallback(string whut);
|
2010-07-04 05:24:51 +02:00
|
|
|
|
|
|
|
|
|
private string WAD_Saveas_Filename;
|
2009-08-20 19:41:08 +02:00
|
|
|
|
|
2009-08-28 00:52:11 +02:00
|
|
|
|
// TODO: OOP scripting
|
2010-07-04 05:24:51 +02:00
|
|
|
|
private string script_filename;
|
|
|
|
|
private bool script_mode = false;
|
|
|
|
|
private string[] nusentries;
|
2009-08-28 00:52:11 +02:00
|
|
|
|
|
2009-08-20 19:41:08 +02:00
|
|
|
|
// Proxy stuff...
|
2010-07-04 05:24:51 +02:00
|
|
|
|
private string proxy_url;
|
|
|
|
|
private string proxy_usr;
|
|
|
|
|
private string proxy_pwd;
|
2009-08-24 01:16:23 +02:00
|
|
|
|
|
2010-06-29 18:06:15 +02:00
|
|
|
|
// Database thread
|
|
|
|
|
private BackgroundWorker fds;
|
|
|
|
|
|
2010-07-04 21:35:18 +02:00
|
|
|
|
// Scripts Thread
|
|
|
|
|
private BackgroundWorker scriptsWorker;
|
|
|
|
|
|
2010-07-10 02:40:09 +02:00
|
|
|
|
// Colours for status box
|
|
|
|
|
private System.Drawing.Color normalcolor = Color.FromName("Black");
|
|
|
|
|
private System.Drawing.Color warningcolor = Color.FromName("DarkGoldenrod");
|
|
|
|
|
private System.Drawing.Color errorcolor = Color.FromName("Crimson");
|
|
|
|
|
private System.Drawing.Color infocolor = Color.FromName("RoyalBlue");
|
|
|
|
|
|
2009-07-10 02:56:17 +02:00
|
|
|
|
// This is the standard entry to the GUI
|
2009-06-11 03:16:49 +02:00
|
|
|
|
public Form1()
|
|
|
|
|
{
|
2010-07-08 18:55:01 +02:00
|
|
|
|
this.Font = new System.Drawing.Font("Tahoma", 8);
|
2009-06-11 03:16:49 +02:00
|
|
|
|
InitializeComponent();
|
2010-07-08 22:01:06 +02:00
|
|
|
|
this.MaximumSize = this.MinimumSize = this.Size; // Lock size down PATCHOW :D
|
2010-07-08 19:18:28 +02:00
|
|
|
|
if (Type.GetType("Mono.Runtime") != null)
|
|
|
|
|
{
|
|
|
|
|
saveaswadbtn.Text = "Save As";
|
|
|
|
|
clearButton.Text = "Clear";
|
|
|
|
|
keepenccontents.Text = "Keep Enc. Contents";
|
2010-07-08 22:01:06 +02:00
|
|
|
|
clearButton.Left -= 41;
|
2010-07-08 19:18:28 +02:00
|
|
|
|
}
|
2010-07-09 01:57:44 +02:00
|
|
|
|
else
|
|
|
|
|
statusbox.Font = new System.Drawing.Font("Microsoft Sans Serif", 7);
|
2010-07-10 02:40:09 +02:00
|
|
|
|
statusbox.SelectionColor = statusbox.ForeColor = normalcolor;
|
|
|
|
|
if (version.StartsWith("SVN"))
|
|
|
|
|
{
|
|
|
|
|
WriteStatus("!!!!! THIS IS A DEBUG BUILD FROM SVN !!!!!", warningcolor);
|
|
|
|
|
WriteStatus("Features CAN and WILL be broken in this build", warningcolor);
|
|
|
|
|
WriteStatus("REMEMBER TO CHANGE TO THE RELEASE CONFIGURATION AND CHANGE VERSION NUMBER BEFORE BUILDING!", warningcolor);
|
2010-07-10 04:55:06 +02:00
|
|
|
|
WriteStatus("\r\n");
|
2010-07-10 02:40:09 +02:00
|
|
|
|
}
|
2010-07-10 05:32:53 +02:00
|
|
|
|
/*
|
2010-07-03 15:12:02 +02:00
|
|
|
|
KoreaMassUpdate.DropDownItemClicked += new ToolStripItemClickedEventHandler(upditem_itemclicked);
|
|
|
|
|
NTSCMassUpdate.DropDownItemClicked += new ToolStripItemClickedEventHandler(upditem_itemclicked);
|
2010-07-10 05:32:53 +02:00
|
|
|
|
PALMassUpdate.DropDownItemClicked += new ToolStripItemClickedEventHandler(upditem_itemclicked);*/
|
2010-07-04 21:35:18 +02:00
|
|
|
|
|
|
|
|
|
// Database BGLoader
|
2010-06-29 18:06:15 +02:00
|
|
|
|
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;
|
2010-07-04 21:35:18 +02:00
|
|
|
|
|
|
|
|
|
// Scripts BGLoader
|
|
|
|
|
this.scriptsWorker = new BackgroundWorker();
|
|
|
|
|
this.scriptsWorker.DoWork += new DoWorkEventHandler(OrganizeScripts);
|
|
|
|
|
this.scriptsWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(scriptsWorker_RunWorkerCompleted);
|
|
|
|
|
RunScriptOrganizer();
|
|
|
|
|
|
2009-06-11 03:16:49 +02:00
|
|
|
|
BootChecks();
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-10 02:56:17 +02:00
|
|
|
|
// CLI Mode
|
2009-06-11 03:16:49 +02:00
|
|
|
|
public Form1(string[] args)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2009-08-07 22:06:34 +02:00
|
|
|
|
Application.DoEvents();
|
2009-06-11 03:16:49 +02:00
|
|
|
|
|
2009-08-20 19:41:08 +02:00
|
|
|
|
BootChecks();
|
2009-08-30 02:43:24 +02:00
|
|
|
|
|
|
|
|
|
// Fix proxy entry.
|
|
|
|
|
if (!(String.IsNullOrEmpty(proxy_url)))
|
|
|
|
|
while (String.IsNullOrEmpty(proxy_pwd))
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
|
2010-07-11 03:09:50 +02:00
|
|
|
|
if ((args.Length == 1) && (args[0] == "folderfix"))
|
|
|
|
|
{
|
|
|
|
|
// Organizing folders from past NUSD releases...
|
|
|
|
|
BackgroundWorker folder_fixer = new BackgroundWorker();
|
|
|
|
|
folder_fixer.DoWork += new DoWorkEventHandler(ReorganizePreviousFolderStructure);
|
|
|
|
|
folder_fixer.RunWorkerCompleted += new RunWorkerCompletedEventHandler(ReorganizePreviousFolderStructure_Completed);
|
|
|
|
|
WriteStatus("Organizing your old folder structure...");
|
|
|
|
|
folder_fixer.RunWorkerAsync();
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-30 02:43:24 +02:00
|
|
|
|
if ((args.Length == 1) && (File.Exists(args[0])))
|
|
|
|
|
{
|
|
|
|
|
script_filename = args[0];
|
|
|
|
|
BackgroundWorker scripter = new BackgroundWorker();
|
|
|
|
|
scripter.DoWork += new DoWorkEventHandler(RunScript);
|
|
|
|
|
scripter.RunWorkerAsync();
|
|
|
|
|
}
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-07-11 03:09:50 +02:00
|
|
|
|
|
|
|
|
|
|
2009-06-11 03:16:49 +02:00
|
|
|
|
private void Form1_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
2010-07-05 02:34:33 +02:00
|
|
|
|
this.Text = String.Format("NUSD - {0}", version); ;
|
2009-06-19 03:57:52 +02:00
|
|
|
|
this.Size = this.MinimumSize;
|
2010-07-04 01:33:23 +02:00
|
|
|
|
consoleCBox.SelectedIndex = 0;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-07-04 21:35:18 +02:00
|
|
|
|
private bool NUSDFileExists(string filename)
|
|
|
|
|
{
|
2010-07-05 02:34:33 +02:00
|
|
|
|
return File.Exists(Path.Combine(CURRENT_DIR, filename));
|
2010-07-04 21:35:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Checks certain file existances, etc.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2009-08-20 19:41:08 +02:00
|
|
|
|
private void BootChecks()
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
2010-07-05 02:34:33 +02:00
|
|
|
|
//Check if correct thread...
|
2010-07-04 20:17:05 +02:00
|
|
|
|
if (this.InvokeRequired)
|
|
|
|
|
{
|
|
|
|
|
Debug.WriteLine("InvokeRequired...");
|
|
|
|
|
BootChecksCallback bcc = new BootChecksCallback(BootChecks);
|
|
|
|
|
this.Invoke(bcc);
|
|
|
|
|
return;
|
2010-07-05 02:34:33 +02:00
|
|
|
|
}
|
2010-07-04 21:35:18 +02:00
|
|
|
|
|
2009-06-11 03:16:49 +02:00
|
|
|
|
// Check for DSi common key bin file...
|
2010-07-04 21:35:18 +02:00
|
|
|
|
if (NUSDFileExists("dsikey.bin") == true)
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
|
|
|
|
WriteStatus("DSi Common Key detected.");
|
|
|
|
|
dsidecrypt = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check for database.xml
|
2010-07-04 21:35:18 +02:00
|
|
|
|
if (NUSDFileExists("database.xml") == false)
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
|
|
|
|
WriteStatus("Database.xml not found. Title database not usable!");
|
2010-07-04 21:35:18 +02:00
|
|
|
|
/*databaseButton.Click -= new System.EventHandler(this.button4_Click);
|
2010-07-04 20:17:05 +02:00
|
|
|
|
databaseButton.Click += new System.EventHandler(this.updateDatabaseToolStripMenuItem_Click);
|
2010-07-04 21:35:18 +02:00
|
|
|
|
databaseButton.Text = "Download DB"; */
|
|
|
|
|
DatabaseEnabled(false);
|
|
|
|
|
updateDatabaseToolStripMenuItem.Enabled = true;
|
2010-07-09 22:41:01 +02:00
|
|
|
|
updateDatabaseToolStripMenuItem.Visible = true;
|
2010-07-04 21:35:18 +02:00
|
|
|
|
updateDatabaseToolStripMenuItem.Text = "Download Database";
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-07-10 04:55:06 +02:00
|
|
|
|
Database db = new Database();
|
|
|
|
|
db.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "database.xml"));
|
|
|
|
|
string version = db.GetDatabaseVersion();
|
2009-06-11 03:16:49 +02:00
|
|
|
|
WriteStatus("Database.xml detected.");
|
2009-08-04 20:17:21 +02:00
|
|
|
|
WriteStatus(" - Version: " + version);
|
2010-07-04 21:35:18 +02:00
|
|
|
|
updateDatabaseToolStripMenuItem.Text = "Update Database";
|
2010-07-06 20:41:11 +02:00
|
|
|
|
//databaseButton.Enabled = false;
|
2010-07-10 04:55:06 +02:00
|
|
|
|
//databaseButton.Text = "DB Loading";
|
|
|
|
|
databaseButton.Text = " [ ]";
|
|
|
|
|
databaseButton.Image = Properties.Resources.arrow_ticker;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
// Load it up...
|
2010-06-29 18:06:15 +02:00
|
|
|
|
this.fds.RunWorkerAsync();
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-08-20 19:41:08 +02:00
|
|
|
|
// Check for Proxy Settings file...
|
2010-07-04 21:35:18 +02:00
|
|
|
|
if (NUSDFileExists("proxy.txt") == true)
|
2009-08-20 19:41:08 +02:00
|
|
|
|
{
|
|
|
|
|
WriteStatus("Proxy settings detected.");
|
2010-07-04 19:18:50 +02:00
|
|
|
|
string[] proxy_file = File.ReadAllLines(Path.Combine(CURRENT_DIR, "proxy.txt"));
|
2009-08-20 19:41:08 +02:00
|
|
|
|
proxy_url = proxy_file[0];
|
2010-07-05 02:34:33 +02:00
|
|
|
|
|
|
|
|
|
// If proxy\nuser\npassword
|
|
|
|
|
if (proxy_file.Length > 2)
|
|
|
|
|
{
|
|
|
|
|
proxy_usr = proxy_file[1];
|
|
|
|
|
proxy_pwd = proxy_file[2];
|
|
|
|
|
}
|
|
|
|
|
else if (proxy_file.Length > 1)
|
2009-08-20 19:41:08 +02:00
|
|
|
|
{
|
|
|
|
|
proxy_usr = proxy_file[1];
|
|
|
|
|
SetAllEnabled(false);
|
2010-07-04 05:24:51 +02:00
|
|
|
|
ProxyVerifyBox.Visible = true;
|
|
|
|
|
ProxyVerifyBox.Enabled = true;
|
|
|
|
|
ProxyPwdBox.Enabled = true;
|
|
|
|
|
SaveProxyBtn.Enabled = true;
|
2009-08-20 19:41:08 +02:00
|
|
|
|
ProxyVerifyBox.Select();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-29 18:06:15 +02:00
|
|
|
|
private void DoAllDatabaseyStuff(object sender, System.ComponentModel.DoWorkEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
BackgroundWorker worker = sender as BackgroundWorker;
|
|
|
|
|
ClearDatabaseStrip();
|
|
|
|
|
FillDatabaseStrip(worker);
|
|
|
|
|
LoadRegionCodes();
|
2010-07-10 05:32:53 +02:00
|
|
|
|
FillDatabaseScripts();
|
2010-06-29 18:06:15 +02:00
|
|
|
|
ShowInnerToolTips(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DoAllDatabaseyStuff_Completed(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
|
|
|
|
|
{
|
2010-07-06 20:41:11 +02:00
|
|
|
|
//this.databaseButton.Enabled = true;
|
2010-06-29 18:06:15 +02:00
|
|
|
|
this.databaseButton.Text = "Database...";
|
2010-07-10 04:55:06 +02:00
|
|
|
|
this.databaseButton.Image = null;
|
2010-07-10 05:32:53 +02:00
|
|
|
|
/*
|
2010-07-04 22:52:03 +02:00
|
|
|
|
if (this.KoreaMassUpdate.HasDropDownItems || this.PALMassUpdate.HasDropDownItems || this.NTSCMassUpdate.HasDropDownItems)
|
|
|
|
|
{
|
|
|
|
|
this.scriptsbutton.Enabled = true;
|
2010-07-10 05:32:53 +02:00
|
|
|
|
}*/
|
2010-06-29 18:06:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DoAllDatabaseyStuff_ProgressChanged(object sender, System.ComponentModel.ProgressChangedEventArgs e)
|
|
|
|
|
{
|
2010-07-10 04:55:06 +02:00
|
|
|
|
if (e.ProgressPercentage == 25)
|
|
|
|
|
databaseButton.Text = " [. ]";
|
|
|
|
|
else if (e.ProgressPercentage == 25)
|
|
|
|
|
databaseButton.Text = " [.. ]";
|
|
|
|
|
else if (e.ProgressPercentage == 75)
|
|
|
|
|
databaseButton.Text = " [... ]";
|
|
|
|
|
else if (e.ProgressPercentage == 100)
|
|
|
|
|
databaseButton.Text = " [....]";
|
2010-06-29 18:06:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-07-04 21:35:18 +02:00
|
|
|
|
private void RunScriptOrganizer()
|
|
|
|
|
{
|
|
|
|
|
this.scriptsWorker.RunWorkerAsync();
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-20 19:41:08 +02:00
|
|
|
|
private void SetAllEnabled(bool enabled)
|
|
|
|
|
{
|
|
|
|
|
for (int a = 0; a < this.Controls.Count; a++)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
this.Controls[a].Enabled = enabled;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
2010-07-04 05:24:51 +02:00
|
|
|
|
// ...
|
2009-08-20 19:41:08 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-07-10 04:55:06 +02:00
|
|
|
|
/*
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the database version.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="file">The database file.</param>
|
|
|
|
|
/// <returns></returns>
|
2009-08-04 20:17:21 +02:00
|
|
|
|
private string GetDatabaseVersion(string file)
|
|
|
|
|
{
|
|
|
|
|
// Read version of Database.xml
|
|
|
|
|
XmlDocument xDoc = new XmlDocument();
|
|
|
|
|
if (file.Contains("<"))
|
|
|
|
|
xDoc.LoadXml(file);
|
|
|
|
|
else
|
2010-06-29 18:06:15 +02:00
|
|
|
|
{
|
|
|
|
|
if (File.Exists(file))
|
|
|
|
|
{
|
|
|
|
|
xDoc.Load(file);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "None Found";
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-08-04 20:17:21 +02:00
|
|
|
|
XmlNodeList DatabaseList = xDoc.GetElementsByTagName("database");
|
|
|
|
|
XmlAttributeCollection Attributes = DatabaseList[0].Attributes;
|
|
|
|
|
return Attributes[0].Value;
|
2010-07-10 04:55:06 +02:00
|
|
|
|
}*/
|
2009-08-04 20:17:21 +02:00
|
|
|
|
|
2010-07-08 18:14:40 +02:00
|
|
|
|
private void extrasMenuButton_Click(object sender, EventArgs e)
|
2009-08-06 04:37:39 +02:00
|
|
|
|
{
|
|
|
|
|
// Show extras menu
|
2010-07-08 01:11:08 +02:00
|
|
|
|
extrasStrip.Show(Extrasbtn, 2, (2+Extrasbtn.Height));
|
2009-08-06 04:37:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Loads the title info from TMD.
|
|
|
|
|
/// </summary>
|
2009-08-06 04:37:39 +02:00
|
|
|
|
private void LoadTitleFromTMD()
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
|
|
|
|
// Show dialog for opening TMD file...
|
|
|
|
|
OpenFileDialog opentmd = new OpenFileDialog();
|
2010-07-20 04:49:48 +02:00
|
|
|
|
opentmd.Filter = "TMD Files|*tmd*";
|
2009-06-11 03:16:49 +02:00
|
|
|
|
opentmd.Title = "Open TMD";
|
|
|
|
|
if (opentmd.ShowDialog() != DialogResult.Cancel)
|
|
|
|
|
{
|
2010-07-08 01:11:08 +02:00
|
|
|
|
libWiiSharp.TMD tmdLocal = new libWiiSharp.TMD();
|
|
|
|
|
tmdLocal.LoadFile(opentmd.FileName);
|
|
|
|
|
WriteStatus(String.Format("TMD Loaded ({0} blocks)", tmdLocal.GetNandBlocks()));
|
2009-06-11 03:16:49 +02:00
|
|
|
|
|
2010-07-08 01:11:08 +02:00
|
|
|
|
titleidbox.Text = tmdLocal.TitleID.ToString("X16");
|
|
|
|
|
WriteStatus("Title ID: " + tmdLocal.TitleID.ToString("X16"));
|
2009-06-11 03:16:49 +02:00
|
|
|
|
|
2010-07-08 01:11:08 +02:00
|
|
|
|
titleversion.Text = tmdLocal.TitleVersion.ToString();
|
|
|
|
|
WriteStatus("Version: " + tmdLocal.TitleVersion);
|
2009-06-11 03:16:49 +02:00
|
|
|
|
|
2010-07-08 01:11:08 +02:00
|
|
|
|
if (tmdLocal.StartupIOS.ToString("X") != "0")
|
|
|
|
|
WriteStatus("Requires: IOS" + int.Parse(tmdLocal.StartupIOS.ToString("X").Substring(7, 2).ToString(), System.Globalization.NumberStyles.HexNumber));
|
|
|
|
|
|
|
|
|
|
WriteStatus("Content Count: " + tmdLocal.NumOfContents);
|
|
|
|
|
|
|
|
|
|
for (int a = 0; a < tmdLocal.Contents.Length; a++)
|
|
|
|
|
{
|
2010-07-09 01:57:44 +02:00
|
|
|
|
WriteStatus(String.Format(" Content {0}: {1} ({2} bytes)", a, tmdLocal.Contents[a].ContentID.ToString("X8"), tmdLocal.Contents[a].Size.ToString()));
|
2010-07-08 01:11:08 +02:00
|
|
|
|
WriteStatus(String.Format(" - Index: {0}", tmdLocal.Contents[a].Index.ToString()));
|
|
|
|
|
WriteStatus(String.Format(" - Type: {0}", tmdLocal.Contents[a].Type.ToString()));
|
2010-07-08 22:32:29 +02:00
|
|
|
|
WriteStatus(String.Format(" - Hash: {0}...", DisplayBytes(tmdLocal.Contents[a].Hash, String.Empty).Substring(0, 8)));
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-07-08 01:11:08 +02:00
|
|
|
|
WriteStatus("TMD information parsed!");
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Writes the status to the statusbox.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Update">The update.</param>
|
2010-07-10 02:40:09 +02:00
|
|
|
|
/// <param name="writecolor">The color to use for writing text into the text box.</param>
|
|
|
|
|
public void WriteStatus(string Update, Color writecolor)
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
2010-07-03 15:12:02 +02:00
|
|
|
|
// Check if thread-safe
|
2010-07-10 02:40:09 +02:00
|
|
|
|
if (statusbox.InvokeRequired)
|
2010-07-03 15:12:02 +02:00
|
|
|
|
{
|
|
|
|
|
Debug.WriteLine("InvokeRequired...");
|
|
|
|
|
WriteStatusCallback wsc = new WriteStatusCallback(WriteStatus);
|
2010-07-10 02:40:09 +02:00
|
|
|
|
this.Invoke(wsc, new object[] { Update, writecolor });
|
2010-07-03 15:12:02 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2009-07-10 02:56:17 +02:00
|
|
|
|
// Small function for writing text to the statusbox...
|
2010-07-10 02:40:09 +02:00
|
|
|
|
int startlen = statusbox.TextLength;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
if (statusbox.Text == "")
|
|
|
|
|
statusbox.Text = Update;
|
|
|
|
|
else
|
2010-07-10 02:40:09 +02:00
|
|
|
|
statusbox.AppendText("\r\n" + Update);
|
|
|
|
|
int endlen = statusbox.TextLength;
|
|
|
|
|
|
|
|
|
|
// Set the color
|
|
|
|
|
statusbox.Select(startlen, endlen - startlen);
|
|
|
|
|
statusbox.SelectionColor = writecolor;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
|
|
|
|
|
// Scroll to end of text box.
|
|
|
|
|
statusbox.SelectionStart = statusbox.TextLength;
|
2010-07-10 02:40:09 +02:00
|
|
|
|
statusbox.SelectionLength = 0;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
statusbox.ScrollToCaret();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-10 02:40:09 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Writes the status to the statusbox.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Update">The update.</param>
|
|
|
|
|
public void WriteStatus(string Update)
|
|
|
|
|
{
|
|
|
|
|
WriteStatus(Update, normalcolor);
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reads the type of the Title ID.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ttlid">The TitleID.</param>
|
2009-06-11 03:16:49 +02:00
|
|
|
|
private void ReadIDType(string ttlid)
|
|
|
|
|
{
|
|
|
|
|
/* Wiibrew TitleID Info...
|
|
|
|
|
# 3 00000001: Essential system titles
|
|
|
|
|
# 4 00010000 and 00010004 : Disc-based games
|
|
|
|
|
# 5 00010001: Downloaded channels
|
|
|
|
|
|
|
|
|
|
* 5.1 000010001-Cxxx : Commodore 64 Games
|
|
|
|
|
* 5.2 000010001-Exxx : NeoGeo Games
|
|
|
|
|
* 5.3 000010001-Fxxx : NES Games
|
|
|
|
|
* 5.4 000010001-Hxxx : Channels
|
|
|
|
|
* 5.5 000010001-Jxxx : SNES Games
|
|
|
|
|
* 5.6 000010001-Nxxx : Nintendo 64 Games
|
|
|
|
|
* 5.7 000010001-Wxxx : WiiWare
|
|
|
|
|
|
|
|
|
|
# 6 00010002: System channels
|
|
|
|
|
# 7 00010004: Game channels and games that use them
|
|
|
|
|
# 8 00010005: Downloaded Game Content
|
|
|
|
|
# 9 00010008: "Hidden" channels
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (ttlid.Substring(0, 8) == "00000001")
|
2010-07-10 02:40:09 +02:00
|
|
|
|
WriteStatus("ID Type: System Title. BE CAREFUL!", warningcolor);
|
2009-06-11 03:16:49 +02:00
|
|
|
|
else if ((ttlid.Substring(0, 8) == "00010000") || (ttlid.Substring(0, 8) == "00010004"))
|
|
|
|
|
WriteStatus("ID Type: Disc-Based Game. Unlikely NUS Content!");
|
|
|
|
|
else if (ttlid.Substring(0, 8) == "00010001")
|
|
|
|
|
WriteStatus("ID Type: Downloaded Channel. Possible NUS Content.");
|
|
|
|
|
else if (ttlid.Substring(0, 8) == "00010002")
|
2010-07-10 02:40:09 +02:00
|
|
|
|
WriteStatus("ID Type: System Channel. BE CAREFUL!", warningcolor);
|
2009-06-11 03:16:49 +02:00
|
|
|
|
else if (ttlid.Substring(0, 8) == "00010004")
|
|
|
|
|
WriteStatus("ID Type: Game Channel. Unlikely NUS Content!");
|
|
|
|
|
else if (ttlid.Substring(0, 8) == "00010005")
|
|
|
|
|
WriteStatus("ID Type: Downloaded Game Content. Unlikely NUS Content!");
|
|
|
|
|
else if (ttlid.Substring(0, 8) == "00010008")
|
|
|
|
|
WriteStatus("ID Type: 'Hidden' Channel. Unlikely NUS Content!");
|
|
|
|
|
else
|
|
|
|
|
WriteStatus("ID Type: Unknown. Unlikely NUS Content!");
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-08 18:14:40 +02:00
|
|
|
|
private void DownloadBtn_Click(object sender, EventArgs e)
|
2010-07-10 02:40:09 +02:00
|
|
|
|
{
|
2010-07-06 04:05:16 +02:00
|
|
|
|
if (titleidbox.Text == String.Empty)
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
2010-07-05 21:16:07 +02:00
|
|
|
|
// Prevent mass deletion and fail
|
2010-07-10 02:40:09 +02:00
|
|
|
|
WriteStatus("Please enter a Title ID!", errorcolor);
|
2009-06-11 03:16:49 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2010-07-05 21:16:07 +02:00
|
|
|
|
else if (!(packbox.Checked) && !(decryptbox.Checked) && !(keepenccontents.Checked))
|
|
|
|
|
{
|
|
|
|
|
// Prevent pointless running by n00bs.
|
2010-07-10 02:40:09 +02:00
|
|
|
|
WriteStatus("Running with your current settings will produce no output!", errorcolor);
|
|
|
|
|
WriteStatus(" - To amend this, look below and check an output type.", errorcolor);
|
2010-07-05 21:16:07 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2009-08-28 05:12:10 +02:00
|
|
|
|
else if (!(script_mode))
|
2009-07-09 04:11:22 +02:00
|
|
|
|
{
|
2009-07-14 21:38:18 +02:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!statusbox.Lines[0].StartsWith(" ---"))
|
2010-07-05 04:00:18 +02:00
|
|
|
|
SetTextThreadSafe(statusbox, " --- " + titleidbox.Text + " ---");
|
2009-07-14 21:38:18 +02:00
|
|
|
|
}
|
|
|
|
|
catch // No lines present...
|
|
|
|
|
{
|
2010-07-05 04:00:18 +02:00
|
|
|
|
SetTextThreadSafe(statusbox, " --- " + titleidbox.Text + " ---");
|
2009-07-14 21:38:18 +02:00
|
|
|
|
}
|
2009-07-09 04:11:22 +02:00
|
|
|
|
}
|
2009-08-28 05:12:10 +02:00
|
|
|
|
else
|
2010-07-10 02:40:09 +02:00
|
|
|
|
WriteStatus(" --- " + titleidbox.Text + " ---");
|
2010-07-05 20:12:14 +02:00
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
|
2009-06-11 03:16:49 +02:00
|
|
|
|
// Running Downloads in background so no form freezing
|
|
|
|
|
NUSDownloader.RunWorkerAsync();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-05 04:00:18 +02:00
|
|
|
|
private void SetTextThreadSafe(System.Windows.Forms.Control what, string setto)
|
2010-07-06 20:41:11 +02:00
|
|
|
|
{
|
|
|
|
|
SetPropertyThreadSafe(what, "Name", setto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetPropertyThreadSafe(System.ComponentModel.Component what, object setto, string property)
|
2010-07-05 04:00:18 +02:00
|
|
|
|
{
|
|
|
|
|
if (this.InvokeRequired)
|
|
|
|
|
{
|
2010-07-06 20:41:11 +02:00
|
|
|
|
SetPropertyThreadSafeCallback sptscb = new SetPropertyThreadSafeCallback(SetPropertyThreadSafe);
|
2010-07-08 18:55:01 +02:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
this.Invoke(sptscb, new object[] { what, setto, property });
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
// FFFFF!
|
|
|
|
|
}
|
2010-07-05 04:00:18 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2010-07-06 20:41:11 +02:00
|
|
|
|
what.GetType().GetProperty(property).SetValue(what, setto, null);
|
|
|
|
|
//what.Text = setto;
|
2010-07-05 04:00:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-06-11 03:16:49 +02:00
|
|
|
|
private void NUSDownloader_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
|
|
|
|
|
{
|
2010-07-06 22:09:10 +02:00
|
|
|
|
Control.CheckForIllegalCrossThreadCalls = false; // this function would need major rewriting to get rid of this...
|
|
|
|
|
if (!(script_mode))
|
2010-07-10 02:40:09 +02:00
|
|
|
|
WriteStatus("Starting NUS Download. Please be patient!", infocolor);
|
2010-07-06 22:09:10 +02:00
|
|
|
|
SetEnableforDownload(false);
|
|
|
|
|
downloadstartbtn.Text = "Starting NUS Download!";
|
|
|
|
|
|
|
|
|
|
// WebClient configuration
|
|
|
|
|
WebClient nusWC = new WebClient();
|
|
|
|
|
nusWC = ConfigureWithProxy(nusWC);
|
|
|
|
|
nusWC.Headers.Add("User-Agent", "wii libnup/1.0"); // Set UserAgent to Wii value
|
|
|
|
|
|
|
|
|
|
// Create\Configure NusClient
|
|
|
|
|
libWiiSharp.NusClient nusClient = new libWiiSharp.NusClient();
|
|
|
|
|
nusClient.ConfigureNusClient(nusWC);
|
|
|
|
|
nusClient.UseLocalFiles = localuse.Checked;
|
|
|
|
|
nusClient.ContinueWithoutTicket = true;
|
2010-07-08 22:32:29 +02:00
|
|
|
|
|
|
|
|
|
// Server
|
|
|
|
|
if (consoleCBox.SelectedIndex == 0)
|
|
|
|
|
nusClient.SetToWiiServer();
|
|
|
|
|
else if (consoleCBox.SelectedIndex == 1)
|
|
|
|
|
nusClient.SetToDSiServer();
|
|
|
|
|
|
|
|
|
|
// Events
|
2010-07-06 22:09:10 +02:00
|
|
|
|
nusClient.Debug += new EventHandler<libWiiSharp.MessageEventArgs>(nusClient_Debug);
|
2010-07-08 22:32:29 +02:00
|
|
|
|
nusClient.Progress += new EventHandler<ProgressChangedEventArgs>(nusClient_Progress);
|
2010-07-06 22:09:10 +02:00
|
|
|
|
|
|
|
|
|
libWiiSharp.StoreType[] storeTypes = new libWiiSharp.StoreType[3];
|
|
|
|
|
if (packbox.Checked) storeTypes[0] = libWiiSharp.StoreType.WAD; else storeTypes[0] = libWiiSharp.StoreType.Empty;
|
|
|
|
|
if (decryptbox.Checked) storeTypes[1] = libWiiSharp.StoreType.DecryptedContent; else storeTypes[1] = libWiiSharp.StoreType.Empty;
|
|
|
|
|
if (keepenccontents.Checked) storeTypes[2] = libWiiSharp.StoreType.EncryptedContent; else storeTypes[2] = libWiiSharp.StoreType.Empty;
|
|
|
|
|
|
2010-07-07 00:50:17 +02:00
|
|
|
|
string wadName;
|
|
|
|
|
if (String.IsNullOrEmpty(WAD_Saveas_Filename))
|
|
|
|
|
wadName = wadnamebox.Text;
|
|
|
|
|
else
|
|
|
|
|
wadName = WAD_Saveas_Filename;
|
|
|
|
|
|
2009-06-11 03:16:49 +02:00
|
|
|
|
try
|
|
|
|
|
{
|
2010-07-08 19:28:24 +02:00
|
|
|
|
nusClient.DownloadTitle(titleidbox.Text, titleversion.Text, Path.Combine(CURRENT_DIR, "titles"), wadName, storeTypes);
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2010-07-10 02:40:09 +02:00
|
|
|
|
WriteStatus("Uhoh, the download bombed: \"" + ex.Message + " ):\"", errorcolor);
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-07-08 22:45:14 +02:00
|
|
|
|
if (iosPatchCheckbox.Checked == true) { // Apply patches then...
|
2010-07-09 19:54:13 +02:00
|
|
|
|
bool didpatch = false;
|
|
|
|
|
int noofpatches = 0;
|
|
|
|
|
string appendpatch = "";
|
2010-07-08 22:45:14 +02:00
|
|
|
|
// Okay, it's checked.
|
|
|
|
|
libWiiSharp.IosPatcher iosp = new libWiiSharp.IosPatcher();
|
|
|
|
|
libWiiSharp.WAD ioswad = new libWiiSharp.WAD();
|
2010-07-09 19:54:13 +02:00
|
|
|
|
wadName = wadName.Replace("[v]", nusClient.TitleVersion.ToString());
|
2010-07-08 22:45:14 +02:00
|
|
|
|
if (wadName.Contains(Path.DirectorySeparatorChar.ToString()) || wadName.Contains(Path.AltDirectorySeparatorChar.ToString()))
|
|
|
|
|
ioswad.LoadFile(wadName);
|
|
|
|
|
else
|
|
|
|
|
ioswad.LoadFile(Path.Combine(Path.Combine(Path.Combine(Path.Combine(CURRENT_DIR, "titles"), titleidbox.Text), nusClient.TitleVersion.ToString()), wadName));
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
iosp.LoadIOS(ref ioswad);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
2010-07-10 02:40:09 +02:00
|
|
|
|
WriteStatus("NUS Download Finished.", infocolor);
|
2010-07-08 22:45:14 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
foreach (object checkItem in iosPatchesListBox.CheckedItems)
|
|
|
|
|
{
|
|
|
|
|
// ensure not 'indeterminate'
|
|
|
|
|
if (iosPatchesListBox.GetItemCheckState(iosPatchesListBox.Items.IndexOf(checkItem)).ToString() == "Checked") {
|
|
|
|
|
switch (checkItem.ToString()) {
|
|
|
|
|
case "Trucha bug":
|
2010-07-09 19:54:13 +02:00
|
|
|
|
noofpatches = iosp.PatchFakeSigning();
|
|
|
|
|
if (noofpatches > 0)
|
|
|
|
|
{
|
2010-07-10 02:40:09 +02:00
|
|
|
|
WriteStatus(" - Patched in fake-signing:", infocolor);
|
2010-07-09 19:54:13 +02:00
|
|
|
|
if (noofpatches > 1)
|
|
|
|
|
appendpatch = "es";
|
|
|
|
|
else
|
|
|
|
|
appendpatch = "";
|
|
|
|
|
WriteStatus(String.Format(" {0} patch{1} applied.", noofpatches, appendpatch));
|
|
|
|
|
didpatch = true;
|
|
|
|
|
}
|
2010-07-08 22:45:14 +02:00
|
|
|
|
else
|
2010-07-10 02:40:09 +02:00
|
|
|
|
WriteStatus(" - Could not patch fake-signing", errorcolor);
|
2010-07-08 22:45:14 +02:00
|
|
|
|
break;
|
|
|
|
|
case "ES_Identify":
|
2010-07-09 19:54:13 +02:00
|
|
|
|
noofpatches = iosp.PatchEsIdentify();
|
|
|
|
|
if (noofpatches > 0)
|
|
|
|
|
{
|
2010-07-10 02:40:09 +02:00
|
|
|
|
WriteStatus(" - Patched in ES_Identify:", infocolor);
|
2010-07-09 19:54:13 +02:00
|
|
|
|
if (noofpatches > 1)
|
|
|
|
|
appendpatch = "es";
|
|
|
|
|
else
|
|
|
|
|
appendpatch = "";
|
|
|
|
|
WriteStatus(String.Format(" {0} patch{1} applied.", noofpatches, appendpatch));
|
|
|
|
|
didpatch = true;
|
|
|
|
|
}
|
2010-07-08 22:45:14 +02:00
|
|
|
|
else
|
2010-07-10 02:40:09 +02:00
|
|
|
|
WriteStatus(" - Could not patch ES_Identify", errorcolor);
|
2010-07-08 22:45:14 +02:00
|
|
|
|
break;
|
|
|
|
|
case "NAND permissions":
|
2010-07-09 19:54:13 +02:00
|
|
|
|
noofpatches = iosp.PatchNandPermissions();
|
|
|
|
|
if (noofpatches > 0)
|
|
|
|
|
{
|
2010-07-10 02:40:09 +02:00
|
|
|
|
WriteStatus(" - Patched in NAND permissions:", infocolor);
|
2010-07-09 19:54:13 +02:00
|
|
|
|
if (noofpatches > 1)
|
|
|
|
|
appendpatch = "es";
|
|
|
|
|
else
|
|
|
|
|
appendpatch = "";
|
|
|
|
|
WriteStatus(String.Format(" {0} patch{1} applied.", noofpatches, appendpatch));
|
|
|
|
|
didpatch = true;
|
|
|
|
|
}
|
2010-07-08 22:45:14 +02:00
|
|
|
|
else
|
2010-07-10 02:40:09 +02:00
|
|
|
|
WriteStatus(" - Could not patch NAND permissions", errorcolor);
|
2010-07-08 22:45:14 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// WriteStatus(iosPatchesListBox.GetItemCheckState(iosPatchesListBox.Items.IndexOf(checkItem)).ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-09 19:54:13 +02:00
|
|
|
|
if (didpatch)
|
|
|
|
|
{
|
|
|
|
|
wadName = wadName.Replace(".wad",".patched.wad");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (wadName.Contains(Path.DirectorySeparatorChar.ToString()) || wadName.Contains(Path.AltDirectorySeparatorChar.ToString()))
|
|
|
|
|
ioswad.Save(wadName);
|
|
|
|
|
else
|
|
|
|
|
ioswad.Save(Path.Combine(Path.Combine(Path.Combine(Path.Combine(CURRENT_DIR, "titles"), titleidbox.Text), nusClient.TitleVersion.ToString()), wadName));
|
2010-07-10 02:40:09 +02:00
|
|
|
|
WriteStatus(String.Format("Patched WAD saved as: {0}", Path.GetFileName(wadName)), infocolor);
|
2010-07-09 19:54:13 +02:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2010-07-10 02:40:09 +02:00
|
|
|
|
WriteStatus(String.Format("Couldn't save patched WAD: \"{0}\" :(",ex.Message), errorcolor);
|
2010-07-09 19:54:13 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-08 22:45:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-06-11 03:16:49 +02:00
|
|
|
|
WriteStatus("NUS Download Finished.");
|
|
|
|
|
|
2010-07-06 22:09:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-07-08 22:32:29 +02:00
|
|
|
|
void nusClient_Progress(object sender, ProgressChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
dlprogress.Value = e.ProgressPercentage;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-06 22:09:10 +02:00
|
|
|
|
void nusClient_Debug(object sender, libWiiSharp.MessageEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
WriteStatus(e.Message);
|
2010-07-06 04:05:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void NUSDownloader_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
WAD_Saveas_Filename = String.Empty;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
|
2009-07-08 01:41:38 +02:00
|
|
|
|
SetEnableforDownload(true);
|
2009-06-19 03:57:52 +02:00
|
|
|
|
downloadstartbtn.Text = "Start NUS Download!";
|
2009-06-11 03:16:49 +02:00
|
|
|
|
dlprogress.Value = 0;
|
2010-07-04 05:24:51 +02:00
|
|
|
|
|
2009-08-24 01:16:23 +02:00
|
|
|
|
if (IsWin7())
|
|
|
|
|
dlprogress.ShowInTaskbar = false;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
|
2009-08-28 05:12:10 +02:00
|
|
|
|
if (script_mode)
|
|
|
|
|
statusbox.Text = "";
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-07-04 01:33:23 +02:00
|
|
|
|
private void consoleCBox_SelectedIndexChanged(object sender, EventArgs e)
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
2010-07-04 01:33:23 +02:00
|
|
|
|
if (consoleCBox.SelectedIndex == 0)
|
|
|
|
|
{
|
|
|
|
|
// Can pack WADs / Decrypt
|
|
|
|
|
packbox.Enabled = true;
|
|
|
|
|
decryptbox.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
if (consoleCBox.SelectedIndex == 1)
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
|
|
|
|
// Cannot Pack WADs
|
|
|
|
|
packbox.Checked = false;
|
|
|
|
|
packbox.Enabled = false;
|
|
|
|
|
|
2010-07-05 20:12:14 +02:00
|
|
|
|
// Can decrypt if dsikey exists...
|
2009-06-11 03:16:49 +02:00
|
|
|
|
if (dsidecrypt == false)
|
|
|
|
|
{
|
|
|
|
|
decryptbox.Checked = false;
|
|
|
|
|
decryptbox.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wadnamebox.Enabled = false;
|
|
|
|
|
wadnamebox.Text = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void packbox_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (packbox.Checked == true)
|
|
|
|
|
{
|
|
|
|
|
wadnamebox.Enabled = true;
|
2010-07-05 02:59:08 +02:00
|
|
|
|
saveaswadbtn.Enabled = true;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
// Change WAD name if applicable
|
2009-07-10 02:56:17 +02:00
|
|
|
|
UpdatePackedName();
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
wadnamebox.Enabled = false;
|
2010-07-05 02:59:08 +02:00
|
|
|
|
saveaswadbtn.Enabled = false;
|
|
|
|
|
wadnamebox.Text = String.Empty;
|
2010-07-09 01:57:44 +02:00
|
|
|
|
if (iosPatchCheckbox.Checked)
|
|
|
|
|
iosPatchCheckbox.Checked = false;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void titleidbox_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2009-07-10 02:56:17 +02:00
|
|
|
|
UpdatePackedName();
|
2010-07-09 01:57:44 +02:00
|
|
|
|
EnablePatchIOSBox();
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void titleversion_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2009-07-10 02:56:17 +02:00
|
|
|
|
UpdatePackedName();
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-07-09 01:57:44 +02:00
|
|
|
|
private void EnablePatchIOSBox()
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
2010-07-09 01:57:44 +02:00
|
|
|
|
iosPatchCheckbox.Enabled = TitleIsIOS(titleidbox.Text);
|
|
|
|
|
if (iosPatchCheckbox.Enabled == false)
|
|
|
|
|
iosPatchCheckbox.Checked = false;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-07-09 01:57:44 +02:00
|
|
|
|
private bool TitleIsIOS(string titleid)
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
2010-07-09 01:57:44 +02:00
|
|
|
|
if (titleid.Length != 16)
|
|
|
|
|
return false;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
|
2010-07-09 01:57:44 +02:00
|
|
|
|
if ((titleid == "0000000100000001") || (titleid == "0000000100000002"))
|
|
|
|
|
return false;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
|
2010-07-09 01:57:44 +02:00
|
|
|
|
if (titleid.Substring(0, 14) == "00000001000000")
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Displays the bytes.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bytes">The bytes.</param>
|
|
|
|
|
/// <param name="spacer">What separates the bytes</param>
|
|
|
|
|
/// <returns></returns>
|
2009-07-10 02:56:17 +02:00
|
|
|
|
public string DisplayBytes(byte[] bytes, string spacer)
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
|
|
|
|
string output = "";
|
|
|
|
|
for (int i = 0; i < bytes.Length; ++i)
|
|
|
|
|
{
|
2009-07-10 02:56:17 +02:00
|
|
|
|
output += bytes[i].ToString("X2") + spacer;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-08 18:14:40 +02:00
|
|
|
|
private void DatabaseButton_Click(object sender, EventArgs e)
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
|
|
|
|
// Open Database button menu...
|
2010-07-08 01:11:08 +02:00
|
|
|
|
databaseStrip.Show(databaseButton, 2, (2+databaseButton.Height));
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Clears the database strip.
|
|
|
|
|
/// </summary>
|
2009-06-11 03:16:49 +02:00
|
|
|
|
private void ClearDatabaseStrip()
|
|
|
|
|
{
|
2010-07-06 20:41:11 +02:00
|
|
|
|
object[] thingstoclear = new object[] {
|
|
|
|
|
SystemMenuList, IOSMenuList, WiiWareMenuList, VCMenuList,
|
|
|
|
|
|
|
|
|
|
// Now Virtual Console
|
|
|
|
|
C64MenuList, NeoGeoMenuList, NESMenuList,
|
|
|
|
|
SNESMenuList, N64MenuList, TurboGrafx16MenuList,
|
|
|
|
|
TurboGrafxCDMenuList, MSXMenuList, SegaMSMenuList,
|
|
|
|
|
GenesisMenuList, VCArcadeMenuList
|
|
|
|
|
};
|
2009-06-11 03:16:49 +02:00
|
|
|
|
|
2010-07-06 20:41:11 +02:00
|
|
|
|
foreach (System.Windows.Forms.ToolStripMenuItem tsmiclear in thingstoclear)
|
|
|
|
|
{
|
|
|
|
|
if (tsmiclear.Name != "VCMenuList") // Don't clear the VC Menu...
|
|
|
|
|
tsmiclear.DropDownItems.Clear();
|
2010-07-10 20:42:35 +02:00
|
|
|
|
/*
|
2010-07-06 20:41:11 +02:00
|
|
|
|
if (tsmiclear.OwnerItem != VCMenuList) // and don't disable the VC menu subparts...
|
2010-07-10 20:42:35 +02:00
|
|
|
|
tsmiclear.Enabled = false;*/
|
2010-07-06 20:41:11 +02:00
|
|
|
|
}
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
2010-07-04 06:15:17 +02:00
|
|
|
|
/// Fills the database strip with the local database.xml file.
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// </summary>
|
2010-06-29 18:06:15 +02:00
|
|
|
|
private void FillDatabaseStrip(BackgroundWorker worker)
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
2010-07-09 22:41:01 +02:00
|
|
|
|
// Something needs to be done to remove this i guess
|
|
|
|
|
//Control.CheckForIllegalCrossThreadCalls = false;
|
|
|
|
|
|
2010-07-10 20:42:35 +02:00
|
|
|
|
// Set fake items visible and real ones not. Only way to stop buggy enabled stuff.
|
|
|
|
|
SetPropertyThreadSafe(SystemMenuList, false, "Visible");
|
|
|
|
|
SetPropertyThreadSafe(IOSMenuList, false, "Visible");
|
|
|
|
|
SetPropertyThreadSafe(VCMenuList, false, "Visible");
|
|
|
|
|
SetPropertyThreadSafe(WiiWareMenuList, false, "Visible");
|
|
|
|
|
|
|
|
|
|
SetPropertyThreadSafe(systemFakeMenuItem, true, "Visible");
|
|
|
|
|
SetPropertyThreadSafe(iosFakeMenuItem, true, "Visible");
|
|
|
|
|
SetPropertyThreadSafe(vcFakeMenuItem, true, "Visible");
|
|
|
|
|
SetPropertyThreadSafe(wwFakeMenuItem, true, "Visible");
|
|
|
|
|
|
2010-07-09 22:41:01 +02:00
|
|
|
|
Database databaseObj = new Database();
|
|
|
|
|
databaseObj.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "database.xml"));
|
|
|
|
|
|
|
|
|
|
ToolStripMenuItem[] systemItems = databaseObj.LoadSystemTitles();
|
|
|
|
|
for (int a = 0; a < systemItems.Length; a++)
|
|
|
|
|
{
|
2010-07-10 00:46:34 +02:00
|
|
|
|
systemItems[a].DropDownItemClicked += new ToolStripItemClickedEventHandler(DatabaseItem_Clicked);
|
|
|
|
|
for (int b = 0; b < systemItems[a].DropDownItems.Count; b++)
|
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem syslowerentry = (ToolStripMenuItem)systemItems[a].DropDownItems[b];
|
|
|
|
|
if (syslowerentry.DropDownItems.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
syslowerentry.DropDownItemClicked += new ToolStripItemClickedEventHandler(DatabaseItem_Clicked);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-09 22:41:01 +02:00
|
|
|
|
AddToolStripItemToStrip(SystemMenuList, systemItems[a]);
|
|
|
|
|
//SystemMenuList.DropDownItems.Add(systemItems[a]);
|
|
|
|
|
}
|
2010-07-10 20:42:35 +02:00
|
|
|
|
SetPropertyThreadSafe(systemFakeMenuItem, false, "Visible");
|
2010-07-09 22:41:01 +02:00
|
|
|
|
SetPropertyThreadSafe(SystemMenuList, true, "Visible");
|
|
|
|
|
|
2010-07-10 04:55:06 +02:00
|
|
|
|
worker.ReportProgress(25);
|
|
|
|
|
|
2010-07-09 22:41:01 +02:00
|
|
|
|
ToolStripMenuItem[] iosItems = databaseObj.LoadIosTitles();
|
|
|
|
|
for (int a = 0; a < iosItems.Length; a++)
|
|
|
|
|
{
|
2010-07-10 00:46:34 +02:00
|
|
|
|
iosItems[a].DropDownItemClicked += new ToolStripItemClickedEventHandler(DatabaseItem_Clicked);
|
2010-07-09 22:41:01 +02:00
|
|
|
|
AddToolStripItemToStrip(IOSMenuList, iosItems[a]);
|
|
|
|
|
//IOSMenuList.DropDownItems.Add(iosItems[a]);
|
|
|
|
|
}
|
2010-07-10 20:42:35 +02:00
|
|
|
|
SetPropertyThreadSafe(iosFakeMenuItem, false, "Visible");
|
2010-07-09 22:41:01 +02:00
|
|
|
|
SetPropertyThreadSafe(IOSMenuList, true, "Visible");
|
|
|
|
|
|
2010-07-10 04:55:06 +02:00
|
|
|
|
worker.ReportProgress(50);
|
|
|
|
|
|
2010-07-09 22:41:01 +02:00
|
|
|
|
ToolStripMenuItem[][] vcItems = databaseObj.LoadVirtualConsoleTitles();
|
|
|
|
|
for (int a = 0; a < vcItems.Length; a++)
|
|
|
|
|
{
|
|
|
|
|
for (int b = 0; b < vcItems[a].Length; b++)
|
|
|
|
|
{
|
2010-07-10 00:46:34 +02:00
|
|
|
|
vcItems[a][b].DropDownItemClicked += new ToolStripItemClickedEventHandler(DatabaseItem_Clicked);
|
|
|
|
|
for (int c = 0; c < vcItems[a][b].DropDownItems.Count; c++)
|
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem lowerentry = (ToolStripMenuItem)vcItems[a][b].DropDownItems[c];
|
2010-07-10 04:55:06 +02:00
|
|
|
|
lowerentry.DropDownItemClicked += new ToolStripItemClickedEventHandler(DatabaseItem_Clicked);
|
|
|
|
|
|
|
|
|
|
//Debug.WriteLine(a + " " + b + " " + c);
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
AddToolStripItemToStrip((ToolStripMenuItem)VCMenuList.DropDownItems[a], vcItems[a][b]);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
Debug.WriteLine(a + " " + b + "FAIL");
|
2010-07-10 00:46:34 +02:00
|
|
|
|
}
|
2010-07-09 22:41:01 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-10 20:42:35 +02:00
|
|
|
|
SetPropertyThreadSafe(vcFakeMenuItem, false, "Visible");
|
2010-07-09 22:41:01 +02:00
|
|
|
|
SetPropertyThreadSafe(VCMenuList, true, "Visible");
|
|
|
|
|
|
2010-07-10 04:55:06 +02:00
|
|
|
|
worker.ReportProgress(75);
|
|
|
|
|
|
2010-07-09 22:41:01 +02:00
|
|
|
|
ToolStripMenuItem[] wwItems = databaseObj.LoadWiiWareTitles();
|
|
|
|
|
for (int a = 0; a < wwItems.Length; a++)
|
|
|
|
|
{
|
2010-07-10 00:46:34 +02:00
|
|
|
|
wwItems[a].DropDownItemClicked += new ToolStripItemClickedEventHandler(DatabaseItem_Clicked);
|
|
|
|
|
for (int b = 0; b < wwItems[a].DropDownItems.Count; b++)
|
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem lowerentry = (ToolStripMenuItem)wwItems[a].DropDownItems[b];
|
|
|
|
|
if (lowerentry.DropDownItems.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
lowerentry.DropDownItemClicked += new ToolStripItemClickedEventHandler(DatabaseItem_Clicked);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-09 22:41:01 +02:00
|
|
|
|
AddToolStripItemToStrip(WiiWareMenuList, wwItems[a]);
|
|
|
|
|
//WiiWareMenuList.DropDownItems.Add(wwItems[a]);
|
|
|
|
|
}
|
2010-07-10 20:42:35 +02:00
|
|
|
|
SetPropertyThreadSafe(wwFakeMenuItem, false, "Visible");
|
2010-07-09 22:41:01 +02:00
|
|
|
|
SetPropertyThreadSafe(WiiWareMenuList, true, "Visible");
|
|
|
|
|
|
2010-07-10 04:55:06 +02:00
|
|
|
|
worker.ReportProgress(100);
|
2010-07-09 22:41:01 +02:00
|
|
|
|
/*
|
2010-07-04 06:15:17 +02:00
|
|
|
|
// Load database.xml into memorystream to perhaps reduce disk reads?
|
2010-07-04 19:18:50 +02:00
|
|
|
|
string databasestr = File.ReadAllText(Path.Combine(CURRENT_DIR, "database.xml"));
|
2010-07-04 06:15:17 +02:00
|
|
|
|
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
|
|
|
|
|
byte[] databasebytes = encoding.GetBytes(databasestr);
|
|
|
|
|
|
|
|
|
|
// Load the memory stream
|
|
|
|
|
MemoryStream databaseStream = new MemoryStream(databasebytes);
|
|
|
|
|
databaseStream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
2009-06-11 03:16:49 +02:00
|
|
|
|
XmlDocument xDoc = new XmlDocument();
|
2010-07-04 06:15:17 +02:00
|
|
|
|
xDoc.Load(databaseStream);
|
2009-06-11 03:16:49 +02:00
|
|
|
|
|
|
|
|
|
// Variables
|
2010-07-04 05:24:51 +02:00
|
|
|
|
string[] XMLNodeTypes = new string[5] {"SYS", "IOS", "VC", "WW", "UPD"};
|
2009-06-11 03:16:49 +02:00
|
|
|
|
|
2010-06-29 18:06:15 +02:00
|
|
|
|
int totalLength = xDoc.SelectNodes("/database/*").Count;
|
|
|
|
|
int rnt = 0;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
// Loop through XMLNodeTypes
|
|
|
|
|
for (int i = 0; i < XMLNodeTypes.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
XmlNodeList XMLSpecificNodeTypeList = xDoc.GetElementsByTagName(XMLNodeTypes[i]);
|
|
|
|
|
|
|
|
|
|
for (int x = 0; x < XMLSpecificNodeTypeList.Count; x++)
|
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem XMLToolStripItem = new ToolStripMenuItem();
|
|
|
|
|
XmlAttributeCollection XMLAttributes = XMLSpecificNodeTypeList[x].Attributes;
|
|
|
|
|
|
|
|
|
|
string titleID = "";
|
2010-07-01 23:35:12 +02:00
|
|
|
|
string updateScript;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
string descname = "";
|
2009-07-09 04:11:22 +02:00
|
|
|
|
bool dangerous = false;
|
|
|
|
|
bool ticket = true;
|
2010-06-29 18:06:15 +02:00
|
|
|
|
|
|
|
|
|
// Okay, so now report the progress...
|
|
|
|
|
rnt = rnt + 1;
|
2010-07-04 05:24:51 +02:00
|
|
|
|
float currentProgress = ((float) rnt/(float) totalLength)*(float) 100;
|
|
|
|
|
if (Convert.ToInt16(Math.Round(currentProgress))%10 == 0)
|
|
|
|
|
worker.ReportProgress(Convert.ToInt16(Math.Round(currentProgress)));
|
|
|
|
|
|
2009-06-11 03:16:49 +02:00
|
|
|
|
// Lol.
|
|
|
|
|
XmlNodeList ChildrenOfTheNode = XMLSpecificNodeTypeList[x].ChildNodes;
|
|
|
|
|
|
|
|
|
|
for (int z = 0; z < ChildrenOfTheNode.Count; z++)
|
|
|
|
|
{
|
|
|
|
|
switch (ChildrenOfTheNode[z].Name)
|
|
|
|
|
{
|
|
|
|
|
case "name":
|
|
|
|
|
descname = ChildrenOfTheNode[z].InnerText;
|
|
|
|
|
break;
|
|
|
|
|
case "titleID":
|
|
|
|
|
titleID = ChildrenOfTheNode[z].InnerText;
|
|
|
|
|
break;
|
2010-07-01 23:35:12 +02:00
|
|
|
|
case "titleIDs":
|
|
|
|
|
updateScript = ChildrenOfTheNode[z].InnerText;
|
2010-07-04 05:24:51 +02:00
|
|
|
|
XMLToolStripItem.AccessibleDescription = updateScript;
|
|
|
|
|
// TODO: Find somewhere better to put this. AND FAST.
|
2010-07-01 23:35:12 +02:00
|
|
|
|
break;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
case "version":
|
|
|
|
|
string[] versions = ChildrenOfTheNode[z].InnerText.Split(',');
|
2009-07-21 23:53:27 +02:00
|
|
|
|
// Add to region things?
|
|
|
|
|
if (XMLToolStripItem.DropDownItems.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int b = 0; b < XMLToolStripItem.DropDownItems.Count; b++)
|
|
|
|
|
{
|
|
|
|
|
if (ChildrenOfTheNode[z].InnerText != "")
|
|
|
|
|
{
|
2010-07-04 05:24:51 +02:00
|
|
|
|
ToolStripMenuItem regitem =
|
|
|
|
|
(ToolStripMenuItem) XMLToolStripItem.DropDownItems[b];
|
2009-07-21 23:53:27 +02:00
|
|
|
|
regitem.DropDownItems.Add("Latest Version");
|
|
|
|
|
for (int y = 0; y < versions.Length; y++)
|
|
|
|
|
{
|
|
|
|
|
regitem.DropDownItems.Add("v" + versions[y]);
|
|
|
|
|
}
|
2010-07-04 05:24:51 +02:00
|
|
|
|
regitem.DropDownItemClicked +=
|
|
|
|
|
new ToolStripItemClickedEventHandler(deepitem_clicked);
|
2009-07-21 23:53:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
2009-07-21 23:53:27 +02:00
|
|
|
|
XMLToolStripItem.DropDownItems.Add("Latest Version");
|
|
|
|
|
if (ChildrenOfTheNode[z].InnerText != "")
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
2009-07-21 23:53:27 +02:00
|
|
|
|
for (int y = 0; y < versions.Length; y++)
|
|
|
|
|
{
|
|
|
|
|
XMLToolStripItem.DropDownItems.Add("v" + versions[y]);
|
|
|
|
|
}
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "region":
|
|
|
|
|
string[] regions = ChildrenOfTheNode[z].InnerText.Split(',');
|
|
|
|
|
if (ChildrenOfTheNode[z].InnerText != "")
|
|
|
|
|
{
|
|
|
|
|
for (int y = 0; y < regions.Length; y++)
|
|
|
|
|
{
|
2010-07-04 05:24:51 +02:00
|
|
|
|
XMLToolStripItem.DropDownItems.Add(RegionFromIndex(Convert.ToInt32(regions[y]),
|
|
|
|
|
xDoc));
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
case "ticket":
|
2009-07-09 04:11:22 +02:00
|
|
|
|
ticket = Convert.ToBoolean(ChildrenOfTheNode[z].InnerText);
|
|
|
|
|
break;
|
|
|
|
|
case "danger":
|
|
|
|
|
dangerous = true;
|
2009-07-10 02:56:17 +02:00
|
|
|
|
XMLToolStripItem.ToolTipText = ChildrenOfTheNode[z].InnerText;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2009-07-09 04:11:22 +02:00
|
|
|
|
XMLToolStripItem.Image = SelectItemImage(ticket, dangerous);
|
2010-07-01 23:35:12 +02:00
|
|
|
|
|
|
|
|
|
if (titleID != "")
|
|
|
|
|
{
|
|
|
|
|
XMLToolStripItem.Text = String.Format("{0} - {1}", titleID, descname);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
XMLToolStripItem.Text = descname;
|
|
|
|
|
}
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
AddToolStripItemToStrip(i, XMLToolStripItem, XMLAttributes);
|
|
|
|
|
}
|
2010-07-06 20:41:11 +02:00
|
|
|
|
// Now enable the specific toolbar
|
|
|
|
|
switch (XMLNodeTypes[i])
|
|
|
|
|
{
|
|
|
|
|
case "IOS":
|
|
|
|
|
//IOSMenuList.Enabled = true;
|
|
|
|
|
SetPropertyThreadSafe(IOSMenuList, true, "Enabled");
|
|
|
|
|
break;
|
|
|
|
|
case "SYS":
|
2010-07-09 22:41:01 +02:00
|
|
|
|
|
2010-07-06 20:41:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case "VC":
|
|
|
|
|
SetPropertyThreadSafe(VCMenuList, true, "Enabled");
|
|
|
|
|
break;
|
|
|
|
|
case "WW":
|
|
|
|
|
SetPropertyThreadSafe(WiiWareMenuList, true, "Enabled");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2010-07-09 22:41:01 +02:00
|
|
|
|
}*/
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Adds the tool strip item to strip.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="type">The type.</param>
|
|
|
|
|
/// <param name="additionitem">The additionitem.</param>
|
|
|
|
|
/// <param name="attributes">The attributes.</param>
|
2010-07-09 22:41:01 +02:00
|
|
|
|
private void AddToolStripItemToStrip(ToolStripMenuItem menulist, ToolStripMenuItem additionitem)
|
2010-07-01 02:40:30 +02:00
|
|
|
|
{
|
2010-07-11 03:09:50 +02:00
|
|
|
|
//Debug.WriteLine(String.Format("Adding item"));
|
2010-07-09 22:41:01 +02:00
|
|
|
|
|
2010-07-01 02:40:30 +02:00
|
|
|
|
if (this.InvokeRequired)
|
|
|
|
|
{
|
2010-07-11 03:09:50 +02:00
|
|
|
|
//Debug.WriteLine("InvokeRequired...");
|
2010-07-01 02:40:30 +02:00
|
|
|
|
AddToolStripItemToStripCallback atsitsc = new AddToolStripItemToStripCallback(AddToolStripItemToStrip);
|
2010-07-09 22:41:01 +02:00
|
|
|
|
this.Invoke(atsitsc, new object[] {menulist, additionitem});
|
2010-07-01 02:40:30 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2010-07-09 22:41:01 +02:00
|
|
|
|
|
|
|
|
|
menulist.DropDownItems.Add(additionitem);
|
2010-07-10 04:55:06 +02:00
|
|
|
|
|
2010-07-09 22:41:01 +02:00
|
|
|
|
/*
|
2009-06-11 03:16:49 +02:00
|
|
|
|
// Deal with VC list depth...
|
|
|
|
|
if (type == 2)
|
|
|
|
|
{
|
2010-07-01 02:40:30 +02:00
|
|
|
|
Debug.WriteLine("Adding:");
|
|
|
|
|
Debug.WriteLine(additionitem);
|
2009-06-11 03:16:49 +02:00
|
|
|
|
switch (attributes[0].Value)
|
|
|
|
|
{
|
2009-07-09 04:11:22 +02:00
|
|
|
|
case "C64":
|
2009-06-11 03:16:49 +02:00
|
|
|
|
C64MenuList.DropDownItems.Add(additionitem);
|
|
|
|
|
break;
|
2009-07-09 04:11:22 +02:00
|
|
|
|
case "NEO":
|
2009-06-11 03:16:49 +02:00
|
|
|
|
NeoGeoMenuList.DropDownItems.Add(additionitem);
|
|
|
|
|
break;
|
|
|
|
|
case "NES":
|
|
|
|
|
NESMenuList.DropDownItems.Add(additionitem);
|
|
|
|
|
break;
|
|
|
|
|
case "SNES":
|
|
|
|
|
SNESMenuList.DropDownItems.Add(additionitem);
|
|
|
|
|
break;
|
|
|
|
|
case "N64":
|
|
|
|
|
N64MenuList.DropDownItems.Add(additionitem);
|
|
|
|
|
break;
|
2009-07-09 04:11:22 +02:00
|
|
|
|
case "TG16":
|
2009-06-11 03:16:49 +02:00
|
|
|
|
TurboGrafx16MenuList.DropDownItems.Add(additionitem);
|
|
|
|
|
break;
|
2009-07-09 04:11:22 +02:00
|
|
|
|
case "TGCD":
|
2009-06-11 03:16:49 +02:00
|
|
|
|
TurboGrafxCDMenuList.DropDownItems.Add(additionitem);
|
|
|
|
|
break;
|
|
|
|
|
case "MSX":
|
|
|
|
|
MSXMenuList.DropDownItems.Add(additionitem);
|
|
|
|
|
break;
|
|
|
|
|
case "SMS":
|
|
|
|
|
SegaMSMenuList.DropDownItems.Add(additionitem);
|
|
|
|
|
break;
|
2009-07-09 04:11:22 +02:00
|
|
|
|
case "GEN":
|
2009-06-11 03:16:49 +02:00
|
|
|
|
GenesisMenuList.DropDownItems.Add(additionitem);
|
|
|
|
|
break;
|
2009-07-09 04:11:22 +02:00
|
|
|
|
case "ARC":
|
2009-06-11 03:16:49 +02:00
|
|
|
|
VCArcadeMenuList.DropDownItems.Add(additionitem);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2010-07-01 23:35:12 +02:00
|
|
|
|
additionitem.DropDownItemClicked += new ToolStripItemClickedEventHandler(wwitem_regionclicked);
|
|
|
|
|
}
|
|
|
|
|
else if (type == 4)
|
|
|
|
|
{
|
|
|
|
|
// I am a brand new combine harvester
|
|
|
|
|
//MassUpdateList.DropDownItems.Add(additionitem);
|
|
|
|
|
switch (attributes[0].Value)
|
|
|
|
|
{
|
|
|
|
|
case "KOR":
|
|
|
|
|
KoreaMassUpdate.DropDownItems.Add(additionitem);
|
2010-07-04 22:52:03 +02:00
|
|
|
|
KoreaMassUpdate.Enabled = true;
|
2010-07-01 23:35:12 +02:00
|
|
|
|
break;
|
|
|
|
|
case "PAL":
|
|
|
|
|
PALMassUpdate.DropDownItems.Add(additionitem);
|
2010-07-04 22:52:03 +02:00
|
|
|
|
PALMassUpdate.Enabled = true;
|
2010-07-01 23:35:12 +02:00
|
|
|
|
break;
|
|
|
|
|
case "NTSC":
|
|
|
|
|
NTSCMassUpdate.DropDownItems.Add(additionitem);
|
2010-07-04 22:52:03 +02:00
|
|
|
|
NTSCMassUpdate.Enabled = true;
|
2010-07-01 23:35:12 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Debug.WriteLine("Oops - database error");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Add SYS, IOS, WW items
|
|
|
|
|
// I thought using index would work in .Items, but I
|
|
|
|
|
// guess this switch will have to do...
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
SystemMenuList.DropDownItems.Add(additionitem);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
IOSMenuList.DropDownItems.Add(additionitem);
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
WiiWareMenuList.DropDownItems.Add(additionitem);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
additionitem.DropDownItemClicked += new ToolStripItemClickedEventHandler(sysitem_versionclicked);
|
2010-07-09 22:41:01 +02:00
|
|
|
|
}*/
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Mods WAD names to be official.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="titlename">The titlename.</param>
|
2010-07-07 00:50:17 +02:00
|
|
|
|
public string OfficialWADNaming(string titlename)
|
2009-08-07 22:51:53 +02:00
|
|
|
|
{
|
2010-07-04 04:16:14 +02:00
|
|
|
|
if (titlename == "MIOS")
|
2010-07-08 18:55:01 +02:00
|
|
|
|
titlename = "RVL-mios-[v].wad";
|
2010-07-04 04:16:14 +02:00
|
|
|
|
else if (titlename.Contains("IOS"))
|
2010-07-08 18:55:01 +02:00
|
|
|
|
titlename = titlename + "-64-[v].wad";
|
2009-08-07 22:51:53 +02:00
|
|
|
|
else if (titlename.Contains("System Menu"))
|
2010-07-08 18:55:01 +02:00
|
|
|
|
titlename = "RVL-WiiSystemmenu-[v].wad";
|
2010-07-04 04:16:14 +02:00
|
|
|
|
else if (titlename.Contains("System Menu"))
|
2010-07-08 18:55:01 +02:00
|
|
|
|
titlename = "RVL-WiiSystemmenu-[v].wad";
|
2010-07-04 04:16:14 +02:00
|
|
|
|
else if (titlename == "BC")
|
2010-07-08 18:55:01 +02:00
|
|
|
|
titlename = "RVL-bc-[v].wad";
|
2010-07-04 04:16:14 +02:00
|
|
|
|
else if (titlename.Contains("Mii Channel"))
|
2010-07-08 18:55:01 +02:00
|
|
|
|
titlename = "RVL-NigaoeNR-[v].wad";
|
2010-07-04 04:16:14 +02:00
|
|
|
|
else if (titlename.Contains("Shopping Channel"))
|
2010-07-08 18:55:01 +02:00
|
|
|
|
titlename = "RVL-Shopping-[v].wad";
|
2010-07-04 04:16:14 +02:00
|
|
|
|
else if (titlename.Contains("Weather Channel"))
|
2010-07-08 18:55:01 +02:00
|
|
|
|
titlename = "RVL-Weather-[v].wad";
|
2009-08-07 22:51:53 +02:00
|
|
|
|
else
|
2010-07-08 18:55:01 +02:00
|
|
|
|
titlename = titlename + "-NUS-[v].wad";
|
|
|
|
|
|
|
|
|
|
if (wadnamebox.InvokeRequired)
|
|
|
|
|
{
|
|
|
|
|
OfficialWADNamingCallback ownc = new OfficialWADNamingCallback(OfficialWADNaming);
|
|
|
|
|
wadnamebox.Invoke(ownc, new object[] { titlename });
|
|
|
|
|
return titlename;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wadnamebox.Text = titlename;
|
2010-07-04 04:16:14 +02:00
|
|
|
|
|
2009-08-07 22:51:53 +02:00
|
|
|
|
if (titleversion.Text != "")
|
|
|
|
|
wadnamebox.Text = wadnamebox.Text.Replace("[v]", "v" + titleversion.Text);
|
2010-07-07 00:50:17 +02:00
|
|
|
|
|
2010-07-08 18:55:01 +02:00
|
|
|
|
return titlename;
|
2009-08-07 22:51:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-07-04 05:24:51 +02:00
|
|
|
|
private void upditem_itemclicked(object sender, ToolStripItemClickedEventArgs e)
|
2010-07-03 15:12:02 +02:00
|
|
|
|
{
|
|
|
|
|
WriteStatus("Preparing to run download script...");
|
|
|
|
|
script_mode = true;
|
2010-07-05 04:00:18 +02:00
|
|
|
|
SetTextThreadSafe(statusbox, "");
|
2010-07-03 15:12:02 +02:00
|
|
|
|
WriteStatus("Starting script download. Please be patient!");
|
2010-07-04 05:24:51 +02:00
|
|
|
|
string[] NUS_Entries = e.ClickedItem.AccessibleDescription.Split('\n');
|
|
|
|
|
// TODO: Find somewhere better to put this. AND FAST!
|
2010-07-03 15:12:02 +02:00
|
|
|
|
for (int i = 0; i < NUS_Entries.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
WriteStatus(NUS_Entries[i]);
|
|
|
|
|
}
|
|
|
|
|
script_filename = "\000";
|
|
|
|
|
nusentries = NUS_Entries;
|
|
|
|
|
BackgroundWorker scripter = new BackgroundWorker();
|
|
|
|
|
scripter.DoWork += new DoWorkEventHandler(RunScript);
|
|
|
|
|
scripter.RunWorkerAsync();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-10 00:46:34 +02:00
|
|
|
|
public void DatabaseItem_Clicked(object sender, ToolStripItemClickedEventArgs e)
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
2010-07-10 00:46:34 +02:00
|
|
|
|
Regex IdandTitle = new Regex(@"[0-9A-Z]*\s-\s.*");
|
|
|
|
|
Regex RegionEntry = new Regex(@"[0-9A-Z][0-9A-Z] \(.*\)");
|
|
|
|
|
Regex VersionEntry = new Regex(@"v[0-9]*.*");
|
2010-07-04 05:24:51 +02:00
|
|
|
|
|
2010-07-10 00:46:34 +02:00
|
|
|
|
// This item is a Titleid - Descname entry
|
|
|
|
|
if (IdandTitle.IsMatch(e.ClickedItem.Text))
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
2010-07-10 00:46:34 +02:00
|
|
|
|
string text = e.ClickedItem.Text.Replace(" - ", "~");
|
|
|
|
|
string[] values = text.Split('~');
|
|
|
|
|
titleidbox.Text = values[0];
|
|
|
|
|
statusbox.Text = String.Format(" --- {0} ---", values[1]);
|
|
|
|
|
titleversion.Text = String.Empty;
|
|
|
|
|
|
2010-07-10 04:55:06 +02:00
|
|
|
|
if ((e.ClickedItem.Image) == (Database.orange) || (e.ClickedItem.Image) == (Database.redorange))
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
2010-07-10 00:46:34 +02:00
|
|
|
|
WriteStatus("Note: This title has no ticket and cannot be packed/decrypted!");
|
|
|
|
|
packbox.Checked = false;
|
|
|
|
|
decryptbox.Checked = false;
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
2010-07-10 00:46:34 +02:00
|
|
|
|
|
|
|
|
|
// Check for danger item
|
2010-07-10 04:55:06 +02:00
|
|
|
|
if ((e.ClickedItem.Image) == (Database.redgreen) || (e.ClickedItem.Image) == (Database.redorange))
|
2010-07-10 00:46:34 +02:00
|
|
|
|
WriteStatus("\n" + e.ClickedItem.ToolTipText);
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
2010-07-10 00:46:34 +02:00
|
|
|
|
|
|
|
|
|
// Region ClickedItem
|
|
|
|
|
if (RegionEntry.IsMatch(e.ClickedItem.Text))
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
2010-07-10 00:46:34 +02:00
|
|
|
|
string text = e.ClickedItem.OwnerItem.Text.Replace(" - ", "~");
|
|
|
|
|
string[] values = text.Split('~');
|
|
|
|
|
titleidbox.Text = values[0];
|
|
|
|
|
statusbox.Text = String.Format(" --- {0} ---", values[1]);
|
|
|
|
|
titleversion.Text = String.Empty;
|
2009-07-09 04:11:22 +02:00
|
|
|
|
|
2010-07-10 00:46:34 +02:00
|
|
|
|
// Put 'XX' into title ID
|
|
|
|
|
titleidbox.Text = titleidbox.Text.Replace("XX", e.ClickedItem.Text.Substring(0, 2));
|
2009-07-09 04:11:22 +02:00
|
|
|
|
|
2010-07-10 04:55:06 +02:00
|
|
|
|
if ((e.ClickedItem.OwnerItem.Image) == (Database.orange) || (e.ClickedItem.OwnerItem.Image) == (Database.redorange))
|
2010-07-10 00:46:34 +02:00
|
|
|
|
{
|
|
|
|
|
WriteStatus("Note: This title has no ticket and cannot be packed/decrypted!");
|
|
|
|
|
packbox.Checked = false;
|
|
|
|
|
decryptbox.Checked = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check for danger item
|
2010-07-10 04:55:06 +02:00
|
|
|
|
if ((e.ClickedItem.OwnerItem.Image) == (Database.redgreen) || (e.ClickedItem.OwnerItem.Image) == (Database.redorange))
|
2010-07-10 00:46:34 +02:00
|
|
|
|
WriteStatus("\n" + e.ClickedItem.OwnerItem.ToolTipText);
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
2010-07-04 05:24:51 +02:00
|
|
|
|
|
2010-07-10 00:46:34 +02:00
|
|
|
|
// Version ClickedItem
|
|
|
|
|
if (VersionEntry.IsMatch(e.ClickedItem.Text) || e.ClickedItem.Text == "Latest Version")
|
2009-07-10 02:56:17 +02:00
|
|
|
|
{
|
2010-07-10 00:46:34 +02:00
|
|
|
|
if (RegionEntry.IsMatch(e.ClickedItem.OwnerItem.Text))
|
|
|
|
|
{
|
|
|
|
|
string text = e.ClickedItem.OwnerItem.OwnerItem.Text.Replace(" - ", "~");
|
|
|
|
|
string[] values = text.Split('~');
|
|
|
|
|
titleidbox.Text = values[0];
|
|
|
|
|
statusbox.Text = String.Format(" --- {0} ---", values[1]);
|
|
|
|
|
|
|
|
|
|
// Put 'XX' into title ID
|
|
|
|
|
titleidbox.Text = titleidbox.Text.Replace("XX", e.ClickedItem.OwnerItem.Text.Substring(0, 2));
|
|
|
|
|
}
|
2009-07-10 02:56:17 +02:00
|
|
|
|
else
|
2010-07-10 00:46:34 +02:00
|
|
|
|
{
|
|
|
|
|
string text = e.ClickedItem.OwnerItem.Text.Replace(" - ", "~");
|
|
|
|
|
string[] values = text.Split('~');
|
|
|
|
|
titleidbox.Text = values[0];
|
|
|
|
|
statusbox.Text = String.Format(" --- {0} ---", values[1]);
|
|
|
|
|
}
|
2009-07-10 02:56:17 +02:00
|
|
|
|
|
2010-07-10 00:46:34 +02:00
|
|
|
|
// Set version
|
|
|
|
|
if (e.ClickedItem.Text == "Latest Version")
|
|
|
|
|
titleversion.Text = String.Empty;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string[] version = e.ClickedItem.Text.Replace("v", "").Split(' ');
|
|
|
|
|
titleversion.Text = version[0];
|
|
|
|
|
}
|
2010-07-10 04:55:06 +02:00
|
|
|
|
|
|
|
|
|
if (RegionEntry.IsMatch(e.ClickedItem.OwnerItem.Text))
|
|
|
|
|
{
|
|
|
|
|
if ((e.ClickedItem.OwnerItem.OwnerItem.Image) == (Database.orange) || (e.ClickedItem.OwnerItem.OwnerItem.Image) == (Database.redorange))
|
|
|
|
|
{
|
|
|
|
|
WriteStatus("Note: This title has no ticket and cannot be packed/decrypted!");
|
|
|
|
|
packbox.Checked = false;
|
|
|
|
|
decryptbox.Checked = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check for danger item
|
|
|
|
|
if ((e.ClickedItem.OwnerItem.OwnerItem.Image) == (Database.redgreen) || (e.ClickedItem.OwnerItem.OwnerItem.Image) == (Database.redorange))
|
|
|
|
|
WriteStatus("\n" + e.ClickedItem.OwnerItem.OwnerItem.ToolTipText);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ((e.ClickedItem.OwnerItem.Image) == (Database.orange) || (e.ClickedItem.OwnerItem.Image) == (Database.redorange))
|
|
|
|
|
{
|
|
|
|
|
WriteStatus("Note: This title has no ticket and cannot be packed/decrypted!");
|
|
|
|
|
packbox.Checked = false;
|
|
|
|
|
decryptbox.Checked = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check for danger item
|
|
|
|
|
if ((e.ClickedItem.OwnerItem.Image) == (Database.redgreen) || (e.ClickedItem.OwnerItem.Image) == (Database.redorange))
|
|
|
|
|
WriteStatus("\n" + e.ClickedItem.OwnerItem.ToolTipText);
|
|
|
|
|
}
|
2009-07-09 04:11:22 +02:00
|
|
|
|
}
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gathers the region based on index
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
/// <param name="databasexml">XmlDocument with database inside</param>
|
|
|
|
|
/// <returns>Region desc</returns>
|
2010-07-04 05:24:51 +02:00
|
|
|
|
private string RegionFromIndex(int index, XmlDocument databasexml)
|
|
|
|
|
{
|
2009-06-11 03:16:49 +02:00
|
|
|
|
/* Typical Region XML
|
|
|
|
|
* <REGIONS>
|
2009-06-13 18:04:54 +02:00
|
|
|
|
<region index="0">41 (All/System)</region>
|
2009-06-11 03:16:49 +02:00
|
|
|
|
<region index=1>44 (German)</region>
|
|
|
|
|
<region index=2>45 (USA/NTSC)</region>
|
|
|
|
|
<region index=3>46 (French)</region>
|
|
|
|
|
<region index=4>4A (Japan)</region>
|
|
|
|
|
<region index=5>4B (Korea)</region>
|
|
|
|
|
<region index=6>4C (Japanese Import to Europe/Australia/PAL)</region>
|
|
|
|
|
<region index=7>4D (American Import to Europe/Australia/PAL)</region>
|
|
|
|
|
<region index=8>4E (Japanese Import to USA/NTSC)</region>
|
|
|
|
|
<region index=9>50 (Europe/PAL)</region>
|
|
|
|
|
<region index=10>51 (Korea w/ Japanese Language)</region>
|
|
|
|
|
<region index=11>54 (Korea w/ English Language)</region>
|
|
|
|
|
<region index=12>58 (Some Homebrew)</region>
|
|
|
|
|
</REGIONS>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
XmlNodeList XMLRegionList = databasexml.GetElementsByTagName("REGIONS");
|
|
|
|
|
XmlNodeList ChildrenOfTheNode = XMLRegionList[0].ChildNodes;
|
|
|
|
|
|
|
|
|
|
// For each child node (region node)
|
|
|
|
|
for (int z = 0; z < ChildrenOfTheNode.Count; z++)
|
|
|
|
|
{
|
|
|
|
|
// Gather attributes (index='x')
|
|
|
|
|
XmlAttributeCollection XMLAttributes = ChildrenOfTheNode[z].Attributes;
|
|
|
|
|
|
|
|
|
|
// Return value of node if index matches
|
|
|
|
|
if (Convert.ToInt32(XMLAttributes[0].Value) == index)
|
|
|
|
|
return ChildrenOfTheNode[z].InnerText;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "XX (Error)";
|
|
|
|
|
}
|
2010-07-10 04:55:06 +02:00
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Loads the region codes.
|
|
|
|
|
/// </summary>
|
2009-06-11 03:16:49 +02:00
|
|
|
|
private void LoadRegionCodes()
|
|
|
|
|
{
|
2010-07-04 20:17:05 +02:00
|
|
|
|
// TODO: make this check InvokeRequired...
|
2010-07-05 04:00:18 +02:00
|
|
|
|
if (this.InvokeRequired)
|
|
|
|
|
{
|
2010-07-06 20:41:11 +02:00
|
|
|
|
BootChecksCallback bcc = new BootChecksCallback(LoadRegionCodes);
|
|
|
|
|
this.Invoke(bcc);
|
|
|
|
|
return;
|
2010-07-05 04:00:18 +02:00
|
|
|
|
}
|
2009-06-11 03:16:49 +02:00
|
|
|
|
|
2010-07-10 04:55:06 +02:00
|
|
|
|
Database databaseObj = new Database();
|
|
|
|
|
databaseObj.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "database.xml"));
|
|
|
|
|
|
|
|
|
|
ToolStripMenuItem[] regionItems = databaseObj.LoadRegionCodes();
|
2009-06-11 03:16:49 +02:00
|
|
|
|
|
|
|
|
|
// For each child node (region node)
|
2010-07-10 04:55:06 +02:00
|
|
|
|
for (int z = 0; z < regionItems.Length; z++)
|
2009-06-11 03:16:49 +02:00
|
|
|
|
{
|
2010-07-10 04:55:06 +02:00
|
|
|
|
RegionCodesList.DropDownItems.Add(regionItems[z].Text);
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
2010-07-10 04:55:06 +02:00
|
|
|
|
}
|
2009-06-11 03:16:49 +02:00
|
|
|
|
|
|
|
|
|
private void RegionCodesList_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (titleidbox.Text.Length == 16)
|
|
|
|
|
titleidbox.Text = titleidbox.Text.Substring(0, 14) + e.ClickedItem.Text.Substring(0, 2);
|
|
|
|
|
}
|
2009-06-17 00:25:19 +02:00
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Removes the illegal characters.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="databasestr">removes the illegal chars</param>
|
|
|
|
|
/// <returns>legal string</returns>
|
2010-07-04 05:24:51 +02:00
|
|
|
|
private static string RemoveIllegalCharacters(string databasestr)
|
|
|
|
|
{
|
2009-07-14 21:38:18 +02:00
|
|
|
|
// Database strings must contain filename-legal characters.
|
|
|
|
|
foreach (char illegalchar in System.IO.Path.GetInvalidFileNameChars())
|
|
|
|
|
{
|
|
|
|
|
if (databasestr.Contains(illegalchar.ToString()))
|
|
|
|
|
databasestr = databasestr.Replace(illegalchar, '-');
|
|
|
|
|
}
|
|
|
|
|
return databasestr;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-08 18:14:40 +02:00
|
|
|
|
private void ClearStatusbox(object sender, EventArgs e)
|
2009-07-04 20:32:52 +02:00
|
|
|
|
{
|
|
|
|
|
// Clear Statusbox.text
|
|
|
|
|
statusbox.Text = "";
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Makes everything disabled/enabled.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="enabled">if set to <c>true</c> [enabled].</param>
|
2009-07-08 01:41:38 +02:00
|
|
|
|
private void SetEnableforDownload(bool enabled)
|
|
|
|
|
{
|
2010-07-05 04:00:18 +02:00
|
|
|
|
if (this.InvokeRequired)
|
|
|
|
|
{
|
|
|
|
|
SetEnableForDownloadCallback sefdcb = new SetEnableForDownloadCallback(SetEnableforDownload);
|
|
|
|
|
this.Invoke(sefdcb, new object[] { enabled });
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-07-09 04:11:22 +02:00
|
|
|
|
// Disable things the user should not mess with during download...
|
2009-07-08 01:41:38 +02:00
|
|
|
|
downloadstartbtn.Enabled = enabled;
|
|
|
|
|
titleidbox.Enabled = enabled;
|
|
|
|
|
titleversion.Enabled = enabled;
|
2009-08-06 04:37:39 +02:00
|
|
|
|
Extrasbtn.Enabled = enabled;
|
2009-07-08 01:41:38 +02:00
|
|
|
|
databaseButton.Enabled = enabled;
|
2009-07-09 04:11:22 +02:00
|
|
|
|
packbox.Enabled = enabled;
|
|
|
|
|
localuse.Enabled = enabled;
|
2010-07-05 02:59:08 +02:00
|
|
|
|
saveaswadbtn.Enabled = enabled;
|
2009-07-09 04:11:22 +02:00
|
|
|
|
decryptbox.Enabled = enabled;
|
2010-07-05 02:59:08 +02:00
|
|
|
|
keepenccontents.Enabled = enabled;
|
|
|
|
|
scriptsbutton.Enabled = enabled;
|
|
|
|
|
consoleCBox.Enabled = enabled;
|
2010-07-08 22:45:14 +02:00
|
|
|
|
iosPatchCheckbox.Enabled = enabled;
|
2009-07-09 04:11:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Makes tooltips disappear in the database, as many contain danger tag info.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="enabled">if set to <c>true</c> [enabled].</param>
|
2009-07-09 04:11:22 +02:00
|
|
|
|
private void ShowInnerToolTips(bool enabled)
|
|
|
|
|
{
|
|
|
|
|
// Force tooltips to GTFO in sub menus...
|
|
|
|
|
foreach (ToolStripItem item in databaseStrip.Items)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2010-07-04 05:24:51 +02:00
|
|
|
|
ToolStripMenuItem menuitem = (ToolStripMenuItem) item;
|
2009-07-09 04:11:22 +02:00
|
|
|
|
menuitem.DropDown.ShowItemToolTips = false;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
// Do nothing, some objects will not cast.
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-10 05:32:53 +02:00
|
|
|
|
foreach (ToolStripItem item in scriptsStrip.Items)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem menuitem = (ToolStripMenuItem)item;
|
|
|
|
|
menuitem.DropDown.ShowItemToolTips = false;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
// Do nothing, some objects will not cast.
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-07-08 01:41:38 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Updates the name of the packed WAD in the textbox.
|
|
|
|
|
/// </summary>
|
2009-07-10 02:56:17 +02:00
|
|
|
|
private void UpdatePackedName()
|
|
|
|
|
{
|
|
|
|
|
// Change WAD name if applicable
|
2009-08-07 22:51:53 +02:00
|
|
|
|
|
|
|
|
|
string title_name = null;
|
|
|
|
|
|
2010-07-05 04:00:18 +02:00
|
|
|
|
if ((titleidbox.Enabled == true || script_mode == true) && (packbox.Checked == true))
|
2009-07-10 02:56:17 +02:00
|
|
|
|
{
|
|
|
|
|
if (titleversion.Text != "")
|
|
|
|
|
{
|
|
|
|
|
wadnamebox.Text = titleidbox.Text + "-NUS-v" + titleversion.Text + ".wad";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
wadnamebox.Text = titleidbox.Text + "-NUS-[v]" + titleversion.Text + ".wad";
|
|
|
|
|
}
|
2009-08-07 22:51:53 +02:00
|
|
|
|
|
|
|
|
|
if ((File.Exists("database.xml") == true) && (titleidbox.Text.Length == 16))
|
|
|
|
|
title_name = NameFromDatabase(titleidbox.Text);
|
|
|
|
|
|
|
|
|
|
if (title_name != null)
|
|
|
|
|
{
|
|
|
|
|
wadnamebox.Text = wadnamebox.Text.Replace(titleidbox.Text, title_name);
|
|
|
|
|
OfficialWADNaming(title_name);
|
|
|
|
|
}
|
2009-07-10 02:56:17 +02:00
|
|
|
|
}
|
2009-07-14 21:38:18 +02:00
|
|
|
|
wadnamebox.Text = RemoveIllegalCharacters(wadnamebox.Text);
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Determines whether OS is win7.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>
|
|
|
|
|
/// <c>true</c> if OS = win7; otherwise, <c>false</c>.
|
|
|
|
|
/// </returns>
|
2010-07-04 06:15:17 +02:00
|
|
|
|
private static bool IsWin7()
|
2009-07-17 18:22:58 +02:00
|
|
|
|
{
|
|
|
|
|
return (Environment.OSVersion.VersionString.Contains("6.1") == true);
|
|
|
|
|
}
|
2009-07-17 20:57:47 +02:00
|
|
|
|
|
|
|
|
|
private byte[] NewIntegertoByteArray(int theInt, int arrayLen)
|
|
|
|
|
{
|
|
|
|
|
byte[] resultArray = new byte[arrayLen];
|
|
|
|
|
|
2010-07-04 05:24:51 +02:00
|
|
|
|
for (int i = arrayLen - 1; i >= 0; i--)
|
2009-07-17 20:57:47 +02:00
|
|
|
|
{
|
2010-07-04 05:24:51 +02:00
|
|
|
|
resultArray[i] = (byte) ((theInt >> (8*i)) & 0xFF);
|
2009-07-17 20:57:47 +02:00
|
|
|
|
}
|
|
|
|
|
Array.Reverse(resultArray);
|
|
|
|
|
|
|
|
|
|
// Fix duplication, rewrite extra to 0x00;
|
|
|
|
|
if (arrayLen > 4)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < (arrayLen - 4); i++)
|
|
|
|
|
{
|
|
|
|
|
resultArray[i] = 0x00;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return resultArray;
|
|
|
|
|
}
|
2009-07-21 23:53:27 +02:00
|
|
|
|
|
2010-07-04 06:15:17 +02:00
|
|
|
|
private WebClient ConfigureWithProxy(WebClient client)
|
2009-08-04 20:17:21 +02:00
|
|
|
|
{
|
2010-07-07 23:43:07 +02:00
|
|
|
|
// Proxy
|
|
|
|
|
if (!(String.IsNullOrEmpty(proxy_url)))
|
2009-08-28 00:52:11 +02:00
|
|
|
|
{
|
2010-07-07 23:43:07 +02:00
|
|
|
|
WebProxy customproxy = new WebProxy();
|
|
|
|
|
customproxy.Address = new Uri(proxy_url);
|
|
|
|
|
if (String.IsNullOrEmpty(proxy_usr))
|
|
|
|
|
customproxy.UseDefaultCredentials = true;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NetworkCredential cred = new NetworkCredential();
|
|
|
|
|
cred.UserName = proxy_usr;
|
2009-08-28 00:52:11 +02:00
|
|
|
|
|
2010-07-07 23:43:07 +02:00
|
|
|
|
if (!(String.IsNullOrEmpty(proxy_pwd)))
|
|
|
|
|
cred.Password = proxy_pwd;
|
2009-08-28 00:52:11 +02:00
|
|
|
|
|
2010-07-07 23:43:07 +02:00
|
|
|
|
customproxy.Credentials = cred;
|
|
|
|
|
}
|
|
|
|
|
client.Proxy = customproxy;
|
|
|
|
|
WriteStatus(" - Custom proxy settings applied!");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
client.Proxy = WebRequest.GetSystemWebProxy();
|
|
|
|
|
client.UseDefaultCredentials = true;
|
|
|
|
|
}
|
|
|
|
|
catch (NotImplementedException)
|
|
|
|
|
{
|
|
|
|
|
// Linux support
|
|
|
|
|
WriteStatus("This operating system does not support automatic system proxy usage. Operating without a proxy...");
|
|
|
|
|
}
|
2009-08-28 00:52:11 +02:00
|
|
|
|
}
|
2010-07-04 06:15:17 +02:00
|
|
|
|
return client;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieves the new database via WiiBrew.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>Database as a String</returns>
|
|
|
|
|
private void RetrieveNewDatabase(object sender, DoWorkEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Retrieve Wiibrew database page source code
|
|
|
|
|
WebClient databasedl = new WebClient();
|
|
|
|
|
|
|
|
|
|
// Proxy
|
|
|
|
|
databasedl = ConfigureWithProxy(databasedl);
|
2009-08-28 00:52:11 +02:00
|
|
|
|
|
2010-07-04 05:24:51 +02:00
|
|
|
|
string wiibrewsource =
|
|
|
|
|
databasedl.DownloadString("http://www.wiibrew.org/wiki/NUS_Downloader/database?cachesmash=" +
|
|
|
|
|
System.DateTime.Now.ToString());
|
2009-08-04 20:17:21 +02:00
|
|
|
|
|
|
|
|
|
// Strip out HTML
|
|
|
|
|
wiibrewsource = Regex.Replace(wiibrewsource, @"<(.|\n)*?>", "");
|
|
|
|
|
|
|
|
|
|
// Shrink to fix only the database
|
|
|
|
|
string startofdatabase = "<database v";
|
|
|
|
|
string endofdatabase = "</database>";
|
2010-07-04 05:24:51 +02:00
|
|
|
|
wiibrewsource = wiibrewsource.Substring(wiibrewsource.IndexOf(startofdatabase),
|
|
|
|
|
wiibrewsource.Length - wiibrewsource.IndexOf(startofdatabase));
|
2009-08-04 20:17:21 +02:00
|
|
|
|
wiibrewsource = wiibrewsource.Substring(0, wiibrewsource.IndexOf(endofdatabase) + endofdatabase.Length);
|
|
|
|
|
|
2009-08-06 04:37:39 +02:00
|
|
|
|
// Fix ", <, >, and spaces
|
2010-07-04 05:24:51 +02:00
|
|
|
|
wiibrewsource = wiibrewsource.Replace("<", "<");
|
|
|
|
|
wiibrewsource = wiibrewsource.Replace(">", ">");
|
|
|
|
|
wiibrewsource = wiibrewsource.Replace(""", '"'.ToString());
|
|
|
|
|
wiibrewsource = wiibrewsource.Replace(" ", " "); // Shouldn't occur, but they happen...
|
2009-08-04 20:17:21 +02:00
|
|
|
|
|
|
|
|
|
// Return parsed xml database...
|
2010-06-29 18:06:15 +02:00
|
|
|
|
e.Result = wiibrewsource;
|
2009-08-04 20:17:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-29 18:06:15 +02:00
|
|
|
|
private void RetrieveNewDatabase_Completed(object sender, RunWorkerCompletedEventArgs e)
|
2009-08-04 20:17:21 +02:00
|
|
|
|
{
|
2010-06-29 18:06:15 +02:00
|
|
|
|
string database = e.Result.ToString();
|
2010-07-10 09:59:10 +02:00
|
|
|
|
try
|
2009-08-04 20:17:21 +02:00
|
|
|
|
{
|
2010-07-10 09:59:10 +02:00
|
|
|
|
Database db = new Database();
|
|
|
|
|
db.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "database.xml"));
|
|
|
|
|
string currentversion = db.GetDatabaseVersion();
|
|
|
|
|
string onlineversion = Database.GetDatabaseVersion(database);
|
|
|
|
|
WriteStatus(" - Database successfully parsed!");
|
|
|
|
|
WriteStatus(" - Current Database Version: " + currentversion);
|
|
|
|
|
WriteStatus(" - Online Database Version: " + onlineversion);
|
|
|
|
|
|
|
|
|
|
if (currentversion == onlineversion)
|
|
|
|
|
{
|
|
|
|
|
WriteStatus(" - You have the latest database version!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (FileNotFoundException)
|
|
|
|
|
{
|
|
|
|
|
WriteStatus(" - Database does not yet exist.");
|
|
|
|
|
WriteStatus(" - Online Database Version: " + Database.GetDatabaseVersion(database));
|
2009-08-04 20:17:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-29 18:06:15 +02:00
|
|
|
|
bool isCreation = false;
|
|
|
|
|
if (File.Exists("database.xml"))
|
|
|
|
|
{
|
|
|
|
|
WriteStatus(" - Overwriting your current database.xml...");
|
|
|
|
|
WriteStatus(" - The old database will become 'olddatabase.xml' in case the new one is faulty.");
|
2009-08-04 20:17:21 +02:00
|
|
|
|
|
2010-06-29 18:06:15 +02:00
|
|
|
|
string olddatabase = File.ReadAllText("database.xml");
|
|
|
|
|
File.WriteAllText("olddatabase.xml", olddatabase);
|
|
|
|
|
File.Delete("database.xml");
|
|
|
|
|
File.WriteAllText("database.xml", database);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
WriteStatus(" - database.xml has been created.");
|
|
|
|
|
File.WriteAllText("database.xml", database);
|
|
|
|
|
isCreation = true;
|
|
|
|
|
}
|
2009-08-04 20:17:21 +02:00
|
|
|
|
|
2009-10-16 00:23:08 +02:00
|
|
|
|
// Load it up...
|
2010-06-29 18:06:15 +02:00
|
|
|
|
this.fds.RunWorkerAsync();
|
|
|
|
|
|
|
|
|
|
if (isCreation)
|
|
|
|
|
{
|
|
|
|
|
WriteStatus("Database successfully created!");
|
2010-06-29 18:56:17 +02:00
|
|
|
|
databaseButton.Visible = true;
|
2010-07-06 20:41:11 +02:00
|
|
|
|
//databaseButton.Enabled = false;
|
2010-06-29 18:56:17 +02:00
|
|
|
|
updateDatabaseToolStripMenuItem.Text = "Download Database";
|
2010-06-29 18:06:15 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
WriteStatus("Database successfully updated!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
statusbox.Text = "";
|
|
|
|
|
WriteStatus("Updating your database.xml from Wiibrew.org");
|
|
|
|
|
|
|
|
|
|
BackgroundWorker dbFetcher = new BackgroundWorker();
|
|
|
|
|
dbFetcher.DoWork += new DoWorkEventHandler(RetrieveNewDatabase);
|
|
|
|
|
dbFetcher.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RetrieveNewDatabase_Completed);
|
|
|
|
|
dbFetcher.RunWorkerAsync();
|
2009-08-04 20:17:21 +02:00
|
|
|
|
}
|
2009-08-06 04:37:39 +02:00
|
|
|
|
|
|
|
|
|
private void loadInfoFromTMDToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Extras menu -> Load TMD...
|
|
|
|
|
LoadTitleFromTMD();
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sends the SOAP request to NUS.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="soap_xml">The Request</param>
|
|
|
|
|
/// <returns></returns>
|
2009-08-06 04:37:39 +02:00
|
|
|
|
public string SendSOAPRequest(string soap_xml)
|
|
|
|
|
{
|
2010-07-04 05:24:51 +02:00
|
|
|
|
System.Net.HttpWebRequest req =
|
|
|
|
|
(System.Net.HttpWebRequest)
|
|
|
|
|
System.Net.HttpWebRequest.Create("http://nus.shop.wii.com:80/nus/services/NetUpdateSOAP");
|
2009-08-06 04:37:39 +02:00
|
|
|
|
req.Method = "POST";
|
|
|
|
|
req.UserAgent = "wii libnup/1.0";
|
|
|
|
|
req.Headers.Add("SOAPAction", '"' + "urn:nus.wsapi.broadon.com/" + '"');
|
2009-08-28 00:52:11 +02:00
|
|
|
|
|
|
|
|
|
// Proxy
|
|
|
|
|
if (!(String.IsNullOrEmpty(proxy_url)))
|
|
|
|
|
{
|
|
|
|
|
WebProxy customproxy = new WebProxy();
|
|
|
|
|
customproxy.Address = new Uri(proxy_url);
|
|
|
|
|
if (String.IsNullOrEmpty(proxy_usr))
|
|
|
|
|
customproxy.UseDefaultCredentials = true;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NetworkCredential cred = new NetworkCredential();
|
|
|
|
|
cred.UserName = proxy_usr;
|
|
|
|
|
|
|
|
|
|
if (!(String.IsNullOrEmpty(proxy_pwd)))
|
|
|
|
|
cred.Password = proxy_pwd;
|
|
|
|
|
|
|
|
|
|
customproxy.Credentials = cred;
|
|
|
|
|
}
|
|
|
|
|
req.Proxy = customproxy;
|
|
|
|
|
WriteStatus(" - Custom proxy settings applied!");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
req.Proxy = WebRequest.GetSystemWebProxy();
|
|
|
|
|
req.UseDefaultCredentials = true;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-06 04:37:39 +02:00
|
|
|
|
Stream writeStream = req.GetRequestStream();
|
|
|
|
|
|
|
|
|
|
UTF8Encoding encoding = new UTF8Encoding();
|
|
|
|
|
byte[] bytes = encoding.GetBytes(soap_xml);
|
|
|
|
|
req.ContentType = "text/xml; charset=utf-8";
|
|
|
|
|
//req.ContentLength = bytes.Length;
|
|
|
|
|
writeStream.Write(bytes, 0, bytes.Length);
|
|
|
|
|
writeStream.Close();
|
|
|
|
|
Application.DoEvents();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string result;
|
2010-07-04 05:24:51 +02:00
|
|
|
|
System.Net.HttpWebResponse resp = (System.Net.HttpWebResponse) req.GetResponse();
|
2009-08-06 04:37:39 +02:00
|
|
|
|
|
|
|
|
|
using (Stream responseStream = resp.GetResponseStream())
|
|
|
|
|
{
|
|
|
|
|
using (StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8))
|
|
|
|
|
{
|
|
|
|
|
result = readStream.ReadToEnd();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
req.Abort();
|
|
|
|
|
Application.DoEvents();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
req.Abort();
|
|
|
|
|
|
|
|
|
|
return ex.Message.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void emulateUpdate_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Begin Wii System Update
|
2009-08-28 00:52:11 +02:00
|
|
|
|
statusbox.Text = "";
|
2009-08-06 04:37:39 +02:00
|
|
|
|
WriteStatus("Starting Wii System Update...");
|
|
|
|
|
|
2010-07-04 19:18:50 +02:00
|
|
|
|
scriptsStrip.Close();
|
2009-08-06 04:37:39 +02:00
|
|
|
|
|
|
|
|
|
string deviceID = "4362227770";
|
|
|
|
|
string messageID = "13198105123219138";
|
|
|
|
|
string attr = "2";
|
|
|
|
|
|
2009-08-28 00:52:11 +02:00
|
|
|
|
string RegionID = e.ClickedItem.Text.Substring(0, 3);
|
|
|
|
|
if (RegionID == "JAP") // Japan fix, only region not w/ 1st 3 letters same as ID.
|
|
|
|
|
RegionID = "JPN";
|
|
|
|
|
|
|
|
|
|
string CountryCode = RegionID.Substring(0, 2);
|
|
|
|
|
|
|
|
|
|
/* [14:26] <Galaxy|> RegionID: USA, Country: US;
|
|
|
|
|
RegionID: JPN, Country: JP;
|
|
|
|
|
RegionID: EUR, Country: EU;
|
|
|
|
|
RegionID: KOR, Country: KO; */
|
2009-08-06 04:37:39 +02:00
|
|
|
|
|
|
|
|
|
string soap_req = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"" +
|
2010-07-04 05:24:51 +02:00
|
|
|
|
" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" +
|
|
|
|
|
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
|
|
|
|
|
"<soapenv:Body>\n<GetSystemUpdateRequest xmlns=\"urn:nus.wsapi.broadon.com\">\n" +
|
|
|
|
|
"<Version>1.0</Version>\n<MessageId>" + messageID + "</MessageId>\n<DeviceId>" + deviceID +
|
|
|
|
|
"</DeviceId>\n" +
|
|
|
|
|
"<RegionId>" + RegionID + "</RegionId>\n<CountryCode>" + CountryCode +
|
|
|
|
|
"</CountryCode>\n<TitleVersion>\n<TitleId>0000000100000001</TitleId>\n" +
|
|
|
|
|
"<Version>2</Version>\n</TitleVersion>\n<TitleVersion>\n<TitleId>0000000100000002</TitleId>\n" +
|
|
|
|
|
"<Version>33</Version>\n</TitleVersion>\n<TitleVersion>\n<TitleId>0000000100000009</TitleId>\n" +
|
|
|
|
|
"<Version>516</Version>\n</TitleVersion>\n<Attribute>" + attr +
|
|
|
|
|
"</Attribute>\n<AuditData></AuditData>\n" +
|
|
|
|
|
"</GetSystemUpdateRequest>\n</soapenv:Body>\n</soapenv:Envelope>";
|
2009-08-06 04:37:39 +02:00
|
|
|
|
|
|
|
|
|
WriteStatus(" - Sending SOAP Request to NUS...");
|
2009-08-28 00:52:11 +02:00
|
|
|
|
WriteStatus(" - Region: " + RegionID);
|
2009-08-06 04:37:39 +02:00
|
|
|
|
string update_xml = SendSOAPRequest(soap_req);
|
|
|
|
|
if (update_xml != null)
|
|
|
|
|
WriteStatus(" - Recieved Update Info!");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
WriteStatus(" - Fail.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-08-30 02:43:24 +02:00
|
|
|
|
WriteStatus(" - Title information:");
|
2009-08-06 04:37:39 +02:00
|
|
|
|
|
2009-08-28 05:12:10 +02:00
|
|
|
|
string script_text = "";
|
|
|
|
|
|
2009-08-06 04:37:39 +02:00
|
|
|
|
XmlDocument xDoc = new XmlDocument();
|
|
|
|
|
xDoc.LoadXml(update_xml);
|
|
|
|
|
XmlNodeList TitleList = xDoc.GetElementsByTagName("TitleVersion");
|
|
|
|
|
for (int a = 0; a < TitleList.Count; a++)
|
|
|
|
|
{
|
|
|
|
|
XmlNodeList TitleInfo = TitleList[a].ChildNodes;
|
|
|
|
|
string TitleID = "";
|
|
|
|
|
string Version = "";
|
|
|
|
|
|
|
|
|
|
for (int b = 0; b < TitleInfo.Count; b++)
|
|
|
|
|
{
|
|
|
|
|
switch (TitleInfo[b].Name)
|
|
|
|
|
{
|
|
|
|
|
case "TitleId":
|
|
|
|
|
TitleID = TitleInfo[b].InnerText;
|
|
|
|
|
break;
|
|
|
|
|
case "Version":
|
|
|
|
|
Version = TitleInfo[b].InnerText;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-08-30 02:43:24 +02:00
|
|
|
|
WriteStatus(String.Format(" - {0} [v{1}]", TitleID, Version));
|
2009-08-28 00:52:11 +02:00
|
|
|
|
|
2010-07-05 21:43:17 +02:00
|
|
|
|
if ((NUSDFileExists("database.xml") == true) && ((!(String.IsNullOrEmpty(NameFromDatabase(TitleID))))))
|
2010-07-10 02:40:09 +02:00
|
|
|
|
//statusbox.Text += String.Format(" [{0}]", NameFromDatabase(TitleID));
|
|
|
|
|
WriteStatus(String.Format(" [{0}]", NameFromDatabase(TitleID)));
|
2009-08-28 05:12:10 +02:00
|
|
|
|
|
2010-07-04 05:24:51 +02:00
|
|
|
|
script_text += String.Format("{0} {1}\n", TitleID,
|
|
|
|
|
DisplayBytes(NewIntegertoByteArray(Convert.ToInt32(Version), 2), ""));
|
2009-08-06 04:37:39 +02:00
|
|
|
|
}
|
2009-08-28 05:12:10 +02:00
|
|
|
|
|
|
|
|
|
WriteStatus(" - Outputting results to NUS script...");
|
|
|
|
|
|
2010-07-04 19:18:50 +02:00
|
|
|
|
if (!(Directory.Exists(Path.Combine(CURRENT_DIR, "scripts"))))
|
2009-08-28 05:12:10 +02:00
|
|
|
|
{
|
2010-07-04 19:18:50 +02:00
|
|
|
|
Directory.CreateDirectory(Path.Combine(CURRENT_DIR, "scripts"));
|
2009-10-16 00:23:08 +02:00
|
|
|
|
WriteStatus(" - Created 'scripts\' directory.");
|
2009-08-28 05:12:10 +02:00
|
|
|
|
}
|
|
|
|
|
string time = RemoveIllegalCharacters(DateTime.Now.ToShortTimeString());
|
2010-07-04 05:24:51 +02:00
|
|
|
|
File.WriteAllText(
|
2010-07-08 18:14:40 +02:00
|
|
|
|
String.Format(Path.Combine(CURRENT_DIR, Path.Combine("scripts","{0}_Update_{1}_{2}_{3} at {4}.nus")), RegionID,
|
2010-07-04 05:24:51 +02:00
|
|
|
|
DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Year, time), script_text);
|
2009-08-28 05:12:10 +02:00
|
|
|
|
WriteStatus(" - Script written!");
|
2010-07-05 21:43:17 +02:00
|
|
|
|
scriptsLocalMenuEntry.Enabled = false;
|
|
|
|
|
this.scriptsWorker.RunWorkerAsync();
|
|
|
|
|
|
2009-08-30 02:43:24 +02:00
|
|
|
|
WriteStatus(" - Run this script if you feel like downloading the update!");
|
2010-07-05 21:43:17 +02:00
|
|
|
|
// TODO: run the script...
|
2009-08-06 04:37:39 +02:00
|
|
|
|
}
|
2009-08-07 22:06:34 +02:00
|
|
|
|
|
2009-08-18 07:02:23 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Looks for a title's name by TitleID in Database.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="titleid">The titleid.</param>
|
|
|
|
|
/// <returns>Existing name; else null</returns>
|
2009-08-07 22:51:53 +02:00
|
|
|
|
private string NameFromDatabase(string titleid)
|
|
|
|
|
{
|
2009-08-28 00:52:11 +02:00
|
|
|
|
// DANGER: BAD h4x HERE!!
|
|
|
|
|
// Fix MIOS/BC naming
|
|
|
|
|
if (titleid == "0000000100000101")
|
|
|
|
|
return "MIOS";
|
|
|
|
|
else if (titleid == "0000000100000100")
|
|
|
|
|
return "BC";
|
|
|
|
|
|
2009-08-07 22:51:53 +02:00
|
|
|
|
XmlDocument xDoc = new XmlDocument();
|
|
|
|
|
xDoc.Load("database.xml");
|
|
|
|
|
|
|
|
|
|
// Variables
|
2010-07-04 05:24:51 +02:00
|
|
|
|
string[] XMLNodeTypes = new string[4] {"SYS", "IOS", "VC", "WW"};
|
2009-08-07 22:51:53 +02:00
|
|
|
|
|
|
|
|
|
// Loop through XMLNodeTypes
|
|
|
|
|
for (int i = 0; i < XMLNodeTypes.Length; i++) // FOR THE FOUR TYPES OF NODES
|
|
|
|
|
{
|
|
|
|
|
XmlNodeList XMLSpecificNodeTypeList = xDoc.GetElementsByTagName(XMLNodeTypes[i]);
|
|
|
|
|
|
2009-08-28 00:52:11 +02:00
|
|
|
|
for (int x = 0; x < XMLSpecificNodeTypeList.Count; x++) // FOR EACH ITEM IN THE LIST OF A NODE TYPE
|
2009-08-07 22:51:53 +02:00
|
|
|
|
{
|
|
|
|
|
bool found_it = false;
|
|
|
|
|
|
|
|
|
|
// Lol.
|
|
|
|
|
XmlNodeList ChildrenOfTheNode = XMLSpecificNodeTypeList[x].ChildNodes;
|
|
|
|
|
|
|
|
|
|
for (int z = 0; z < ChildrenOfTheNode.Count; z++) // FOR EACH CHILD NODE
|
|
|
|
|
{
|
|
|
|
|
switch (ChildrenOfTheNode[z].Name)
|
|
|
|
|
{
|
|
|
|
|
case "titleID":
|
|
|
|
|
if (ChildrenOfTheNode[z].InnerText == titleid)
|
|
|
|
|
found_it = true;
|
2010-07-04 05:24:51 +02:00
|
|
|
|
else if ((ChildrenOfTheNode[z].InnerText.Substring(0, 14) + "XX") ==
|
|
|
|
|
(titleid.Substring(0, 14) + "XX") &&
|
|
|
|
|
(titleid.Substring(0, 14) != "00000001000000"))
|
2009-08-07 22:51:53 +02:00
|
|
|
|
found_it = true;
|
|
|
|
|
else
|
|
|
|
|
found_it = false;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-04 05:24:51 +02:00
|
|
|
|
if (found_it)
|
2009-08-07 22:51:53 +02:00
|
|
|
|
{
|
|
|
|
|
for (int z = 0; z < ChildrenOfTheNode.Count; z++) // FOR EACH CHILD NODE
|
|
|
|
|
{
|
|
|
|
|
switch (ChildrenOfTheNode[z].Name)
|
|
|
|
|
{
|
|
|
|
|
case "name":
|
|
|
|
|
return ChildrenOfTheNode[z].InnerText;
|
2009-08-18 07:02:23 +02:00
|
|
|
|
default:
|
2009-08-07 22:51:53 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2009-08-18 07:02:23 +02:00
|
|
|
|
|
|
|
|
|
private void packbox_EnabledChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2010-07-05 02:59:08 +02:00
|
|
|
|
saveaswadbtn.Enabled = packbox.Enabled;
|
2010-07-05 02:34:33 +02:00
|
|
|
|
//deletecontentsbox.Enabled = packbox.Enabled;
|
2009-08-18 07:02:23 +02:00
|
|
|
|
}
|
2009-08-19 18:40:43 +02:00
|
|
|
|
|
2009-08-20 19:41:08 +02:00
|
|
|
|
private void SaveProxyBtn_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2010-07-04 05:24:51 +02:00
|
|
|
|
if ((String.IsNullOrEmpty(ProxyURL.Text)) && (String.IsNullOrEmpty(ProxyUser.Text)) &&
|
2010-07-04 19:18:50 +02:00
|
|
|
|
((File.Exists(Path.Combine(CURRENT_DIR, "proxy.txt")))))
|
2009-08-20 19:41:08 +02:00
|
|
|
|
{
|
2010-07-04 19:18:50 +02:00
|
|
|
|
File.Delete(Path.Combine(CURRENT_DIR, "proxy.txt"));
|
2009-08-20 19:41:08 +02:00
|
|
|
|
proxyBox.Visible = false;
|
2010-07-04 05:24:51 +02:00
|
|
|
|
proxy_usr = "";
|
|
|
|
|
proxy_url = "";
|
|
|
|
|
proxy_pwd = "";
|
2009-08-20 19:41:08 +02:00
|
|
|
|
WriteStatus("Proxy settings deleted!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-07-04 05:24:51 +02:00
|
|
|
|
else if ((String.IsNullOrEmpty(ProxyURL.Text)) && (String.IsNullOrEmpty(ProxyUser.Text)) &&
|
2010-07-04 19:18:50 +02:00
|
|
|
|
((!(File.Exists(Path.Combine(CURRENT_DIR, "proxy.txt"))))))
|
2009-08-20 19:41:08 +02:00
|
|
|
|
{
|
|
|
|
|
proxyBox.Visible = false;
|
|
|
|
|
WriteStatus("No proxy settings saved!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string proxy_file = "";
|
|
|
|
|
|
|
|
|
|
if (!(String.IsNullOrEmpty(ProxyURL.Text)))
|
|
|
|
|
{
|
|
|
|
|
proxy_file += ProxyURL.Text + "\n";
|
|
|
|
|
proxy_url = ProxyURL.Text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(String.IsNullOrEmpty(ProxyUser.Text)))
|
|
|
|
|
{
|
|
|
|
|
proxy_file += ProxyUser.Text;
|
|
|
|
|
proxy_usr = ProxyUser.Text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(String.IsNullOrEmpty(proxy_file)))
|
|
|
|
|
{
|
2010-07-04 19:18:50 +02:00
|
|
|
|
File.WriteAllText(Path.Combine(CURRENT_DIR, "proxy.txt"), proxy_file);
|
2009-08-20 19:41:08 +02:00
|
|
|
|
WriteStatus("Proxy settings saved!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
proxyBox.Visible = false;
|
|
|
|
|
|
|
|
|
|
SetAllEnabled(false);
|
2010-07-04 05:24:51 +02:00
|
|
|
|
ProxyVerifyBox.Visible = true;
|
|
|
|
|
ProxyVerifyBox.Enabled = true;
|
|
|
|
|
ProxyPwdBox.Enabled = true;
|
|
|
|
|
SaveProxyBtn.Enabled = true;
|
2009-08-20 19:41:08 +02:00
|
|
|
|
ProxyVerifyBox.Select();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void proxySettingsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Check for Proxy Settings file...
|
2010-07-04 19:18:50 +02:00
|
|
|
|
if (File.Exists(Path.Combine(CURRENT_DIR, "proxy.txt")) == true)
|
2009-08-20 19:41:08 +02:00
|
|
|
|
{
|
2010-07-04 19:18:50 +02:00
|
|
|
|
string[] proxy_file = File.ReadAllLines(Path.Combine(CURRENT_DIR, "proxy.txt"));
|
2010-07-04 05:24:51 +02:00
|
|
|
|
|
2009-08-20 19:41:08 +02:00
|
|
|
|
ProxyURL.Text = proxy_file[0];
|
|
|
|
|
if (proxy_file.Length > 1)
|
|
|
|
|
{
|
|
|
|
|
ProxyUser.Text = proxy_file[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
proxyBox.Visible = true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-08 18:14:40 +02:00
|
|
|
|
private void SaveProxyPwdButton_Click(object sender, EventArgs e)
|
2009-08-20 19:41:08 +02:00
|
|
|
|
{
|
|
|
|
|
proxy_pwd = ProxyPwdBox.Text;
|
|
|
|
|
ProxyVerifyBox.Visible = false;
|
|
|
|
|
SetAllEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ProxyPwdBox_KeyPress(object sender, KeyPressEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.KeyChar == Convert.ToChar(Keys.Enter))
|
2010-07-08 18:14:40 +02:00
|
|
|
|
SaveProxyPwdButton_Click("LOLWUT", EventArgs.Empty);
|
2009-08-20 19:41:08 +02:00
|
|
|
|
}
|
2009-08-24 01:16:23 +02:00
|
|
|
|
|
|
|
|
|
private void ProxyAssistBtn_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("If you are behind a proxy, set these settings to get through to NUS." +
|
2010-07-05 02:34:33 +02:00
|
|
|
|
" If you have an alternate port for accessing your proxy, add ':' followed by the port.");
|
2009-08-24 01:16:23 +02:00
|
|
|
|
}
|
2009-08-28 00:52:11 +02:00
|
|
|
|
|
|
|
|
|
private void loadNUSScriptToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Open a NUS script.
|
|
|
|
|
OpenFileDialog ofd = new OpenFileDialog();
|
|
|
|
|
ofd.Multiselect = false;
|
|
|
|
|
ofd.Filter = "NUS Scripts|*.nus|All Files|*.*";
|
2010-07-04 19:18:50 +02:00
|
|
|
|
if (Directory.Exists(Path.Combine(CURRENT_DIR, "scripts")))
|
|
|
|
|
ofd.InitialDirectory = Path.Combine(CURRENT_DIR, "scripts");
|
2009-08-28 00:52:11 +02:00
|
|
|
|
ofd.Title = "Load a NUS/Wiimpersonator script.";
|
|
|
|
|
|
|
|
|
|
if (ofd.ShowDialog() != DialogResult.Cancel)
|
|
|
|
|
{
|
|
|
|
|
script_filename = ofd.FileName;
|
|
|
|
|
BackgroundWorker scripter = new BackgroundWorker();
|
|
|
|
|
scripter.DoWork += new DoWorkEventHandler(RunScript);
|
|
|
|
|
scripter.RunWorkerAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-30 02:43:24 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Runs a NUS script (BG).
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
|
|
/// <param name="e">The <see cref="System.ComponentModel.DoWorkEventArgs"/> instance containing the event data.</param>
|
2009-08-28 00:52:11 +02:00
|
|
|
|
private void RunScript(object sender, System.ComponentModel.DoWorkEventArgs e)
|
|
|
|
|
{
|
2009-08-28 05:12:10 +02:00
|
|
|
|
script_mode = true;
|
2010-07-05 04:00:18 +02:00
|
|
|
|
SetTextThreadSafe(statusbox, "");
|
2009-08-28 00:52:11 +02:00
|
|
|
|
WriteStatus("Starting script download. Please be patient!");
|
2010-07-05 04:00:18 +02:00
|
|
|
|
if (!File.Exists(Path.Combine(CURRENT_DIR, "output_" + Path.GetFileNameWithoutExtension(script_filename))))
|
|
|
|
|
Directory.CreateDirectory(Path.Combine(CURRENT_DIR, "output_" + Path.GetFileNameWithoutExtension(script_filename)));
|
2010-07-03 15:12:02 +02:00
|
|
|
|
string[] NUS_Entries;
|
|
|
|
|
if (script_filename != "\000")
|
|
|
|
|
{
|
|
|
|
|
NUS_Entries = File.ReadAllLines(script_filename);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NUS_Entries = nusentries;
|
|
|
|
|
}
|
2009-08-28 00:52:11 +02:00
|
|
|
|
WriteStatus(String.Format(" - Script loaded ({0} Titles)", NUS_Entries.Length));
|
|
|
|
|
|
|
|
|
|
for (int a = 0; a < NUS_Entries.Length; a++)
|
|
|
|
|
{
|
|
|
|
|
// Download the title
|
2010-07-04 05:24:51 +02:00
|
|
|
|
WriteStatus(String.Format("===== Running Download ({0}/{1}) =====", a + 1, NUS_Entries.Length));
|
2009-08-28 00:52:11 +02:00
|
|
|
|
string[] title_info = NUS_Entries[a].Split(' ');
|
2009-08-30 02:43:24 +02:00
|
|
|
|
// don't let the delete issue reappear...
|
|
|
|
|
if (string.IsNullOrEmpty(title_info[0]))
|
|
|
|
|
break;
|
2010-07-07 00:50:17 +02:00
|
|
|
|
|
|
|
|
|
// WebClient configuration
|
|
|
|
|
WebClient nusWC = new WebClient();
|
|
|
|
|
nusWC = ConfigureWithProxy(nusWC);
|
|
|
|
|
nusWC.Headers.Add("User-Agent", "wii libnup/1.0"); // Set UserAgent to Wii value
|
|
|
|
|
|
|
|
|
|
// Create\Configure NusClient
|
|
|
|
|
libWiiSharp.NusClient nusClient = new libWiiSharp.NusClient();
|
|
|
|
|
nusClient.ConfigureNusClient(nusWC);
|
|
|
|
|
nusClient.UseLocalFiles = localuse.Checked;
|
|
|
|
|
nusClient.ContinueWithoutTicket = true;
|
|
|
|
|
nusClient.Debug += new EventHandler<libWiiSharp.MessageEventArgs>(nusClient_Debug);
|
|
|
|
|
|
|
|
|
|
libWiiSharp.StoreType[] storeTypes = new libWiiSharp.StoreType[1];
|
|
|
|
|
// There's no harm in outputting everything i suppose
|
|
|
|
|
storeTypes[0] = libWiiSharp.StoreType.All;
|
|
|
|
|
|
|
|
|
|
int title_version = int.Parse(title_info[1], System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
|
|
string wadName = NameFromDatabase(title_info[0]);
|
|
|
|
|
if (wadName != null)
|
|
|
|
|
wadName = OfficialWADNaming(wadName);
|
|
|
|
|
else
|
|
|
|
|
wadName = title_info[0] + "-NUS-v" + title_version + ".wad";
|
|
|
|
|
|
|
|
|
|
nusClient.DownloadTitle(title_info[0], title_version.ToString(), Path.Combine(CURRENT_DIR, ("output_" + Path.GetFileNameWithoutExtension(script_filename))), wadName, storeTypes);
|
|
|
|
|
|
|
|
|
|
/*
|
2010-07-05 04:00:18 +02:00
|
|
|
|
SetTextThreadSafe(titleidbox, title_info[0]);
|
|
|
|
|
SetTextThreadSafe(titleversion,
|
2010-07-04 05:24:51 +02:00
|
|
|
|
Convert.ToString(256*
|
|
|
|
|
(byte.Parse(title_info[1].Substring(0, 2),
|
2010-07-05 04:00:18 +02:00
|
|
|
|
System.Globalization.NumberStyles.HexNumber))));
|
|
|
|
|
SetTextThreadSafe(titleversion,
|
2010-07-04 05:24:51 +02:00
|
|
|
|
Convert.ToString(Convert.ToInt32(titleversion.Text) +
|
|
|
|
|
byte.Parse(title_info[1].Substring(2, 2),
|
2010-07-05 04:00:18 +02:00
|
|
|
|
System.Globalization.NumberStyles.HexNumber)));
|
2009-08-28 00:52:11 +02:00
|
|
|
|
|
|
|
|
|
button3_Click("Scripter", EventArgs.Empty);
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
|
|
|
|
|
while (NUSDownloader.IsBusy)
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(1000);
|
2010-07-07 00:50:17 +02:00
|
|
|
|
} */
|
2009-08-28 00:52:11 +02:00
|
|
|
|
}
|
2009-08-28 05:12:10 +02:00
|
|
|
|
script_mode = false;
|
2009-08-28 00:52:11 +02:00
|
|
|
|
WriteStatus("Script completed!");
|
|
|
|
|
}
|
2009-10-14 22:52:16 +02:00
|
|
|
|
|
2010-07-04 18:23:18 +02:00
|
|
|
|
private void scriptsbutton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Show scripts menu
|
2010-07-08 01:11:08 +02:00
|
|
|
|
scriptsStrip.Show(scriptsbutton, 2, (2+scriptsbutton.Height));
|
2010-07-04 18:23:18 +02:00
|
|
|
|
}
|
2010-07-04 21:35:18 +02:00
|
|
|
|
|
|
|
|
|
private void DatabaseEnabled(bool enabled)
|
|
|
|
|
{
|
|
|
|
|
for (int a = 0; a < databaseStrip.Items.Count; a++)
|
|
|
|
|
{
|
2010-07-09 22:41:01 +02:00
|
|
|
|
databaseStrip.Items[a].Enabled = enabled;
|
|
|
|
|
databaseStrip.Items[a].Visible = enabled;
|
2010-07-04 21:35:18 +02:00
|
|
|
|
}
|
2010-07-10 04:55:06 +02:00
|
|
|
|
|
|
|
|
|
for (int b = 0; b < VCMenuList.DropDownItems.Count; b++)
|
|
|
|
|
{
|
|
|
|
|
VCMenuList.DropDownItems[b].Enabled = true;
|
|
|
|
|
VCMenuList.DropDownItems[b].Visible = true;
|
|
|
|
|
}
|
2010-07-04 21:35:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void scriptsWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
|
|
|
|
{
|
2010-07-05 21:43:17 +02:00
|
|
|
|
scriptsLocalMenuEntry.Enabled = true;
|
2010-07-04 21:35:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OrganizeScripts(object sender, DoWorkEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//throw new NotImplementedException();
|
2010-07-05 02:34:33 +02:00
|
|
|
|
|
|
|
|
|
if (Directory.Exists(Path.Combine(CURRENT_DIR, "scripts")) == false)
|
2010-07-04 21:35:18 +02:00
|
|
|
|
{
|
2010-07-05 02:34:33 +02:00
|
|
|
|
WriteStatus("Scripts directory not found...");
|
|
|
|
|
WriteStatus("- Creating it.");
|
|
|
|
|
Directory.CreateDirectory(Path.Combine(CURRENT_DIR, "scripts"));
|
|
|
|
|
}
|
2010-07-04 21:35:18 +02:00
|
|
|
|
|
2010-07-05 21:43:17 +02:00
|
|
|
|
// Clear any entries from previous runthrough
|
|
|
|
|
if (scriptsLocalMenuEntry.DropDownItems.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
// TODO: i suppose this is bad amiright
|
|
|
|
|
Control.CheckForIllegalCrossThreadCalls = false;
|
|
|
|
|
scriptsLocalMenuEntry.DropDownItems.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-07-05 02:34:33 +02:00
|
|
|
|
// Add directories w/ scripts in \scripts\
|
|
|
|
|
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;
|
2010-07-04 22:52:03 +02:00
|
|
|
|
|
2010-07-05 00:46:40 +02:00
|
|
|
|
|
2010-07-05 02:34:33 +02:00
|
|
|
|
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;
|
2010-07-09 01:57:44 +02:00
|
|
|
|
nus_script_item.Image = Properties.Resources.script_start;
|
2010-07-05 02:34:33 +02:00
|
|
|
|
folder_item.DropDownItems.Add(nus_script_item);
|
2010-07-04 22:52:03 +02:00
|
|
|
|
|
2010-07-05 04:00:18 +02:00
|
|
|
|
nus_script_item.Click += new EventHandler(nus_script_item_Click);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scriptsLocalMenuEntry.DropDownItems.Add(folder_item);
|
2010-07-04 22:52:03 +02:00
|
|
|
|
}
|
2010-07-04 21:35:18 +02:00
|
|
|
|
}
|
2010-07-05 02:34:33 +02:00
|
|
|
|
|
|
|
|
|
// Add scripts in \scripts\
|
|
|
|
|
foreach (string nusscript in Directory.GetFiles(Path.Combine(CURRENT_DIR, "scripts"), "*.nus", SearchOption.TopDirectoryOnly))
|
2010-07-04 22:52:03 +02:00
|
|
|
|
{
|
2010-07-05 02:34:33 +02:00
|
|
|
|
FileInfo finfo = new FileInfo(nusscript);
|
|
|
|
|
ToolStripMenuItem nus_script_item = new ToolStripMenuItem();
|
|
|
|
|
nus_script_item.Text = finfo.Name;
|
2010-07-09 01:57:44 +02:00
|
|
|
|
nus_script_item.Image = Properties.Resources.script_start;
|
2010-07-05 02:34:33 +02:00
|
|
|
|
scriptsLocalMenuEntry.DropDownItems.Add(nus_script_item);
|
|
|
|
|
|
2010-07-05 17:42:12 +02:00
|
|
|
|
nus_script_item.Click += new EventHandler(nus_script_item_Click);
|
2010-07-04 22:52:03 +02:00
|
|
|
|
}
|
2010-07-05 02:34:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void aboutNUSDToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Display About Text...
|
|
|
|
|
statusbox.Text = "";
|
|
|
|
|
WriteStatus("NUS Downloader (NUSD)");
|
|
|
|
|
WriteStatus("You are running version: " + version);
|
2010-07-09 23:30:15 +02:00
|
|
|
|
if (version.StartsWith("SVN"))
|
2010-07-10 04:55:06 +02:00
|
|
|
|
WriteStatus("SVN BUILD: DO NOT REPORT BROKEN FEATURES!");
|
|
|
|
|
|
2010-07-05 02:34:33 +02:00
|
|
|
|
WriteStatus("This application created by WB3000");
|
|
|
|
|
WriteStatus("Various sections contributed by lukegb");
|
2010-07-10 04:55:06 +02:00
|
|
|
|
WriteStatus(String.Empty);
|
|
|
|
|
/*
|
2010-07-05 02:34:33 +02:00
|
|
|
|
if (NUSDFileExists("key.bin") == false)
|
|
|
|
|
WriteStatus("Wii Decryption: Need (key.bin)");
|
|
|
|
|
else
|
|
|
|
|
WriteStatus("Wii Decryption: OK");
|
|
|
|
|
|
|
|
|
|
if (NUSDFileExists("kkey.bin") == false)
|
|
|
|
|
WriteStatus("Wii Korea Decryption: Need (kkey.bin)");
|
|
|
|
|
else
|
|
|
|
|
WriteStatus("Wii Korea Decryption: OK");
|
2010-07-10 04:55:06 +02:00
|
|
|
|
*/
|
2010-07-05 02:34:33 +02:00
|
|
|
|
if (NUSDFileExists("dsikey.bin") == false)
|
|
|
|
|
WriteStatus("DSi Decryption: Need (dsikey.bin)");
|
|
|
|
|
else
|
|
|
|
|
WriteStatus("DSi Decryption: OK");
|
|
|
|
|
|
|
|
|
|
if (NUSDFileExists("database.xml") == false)
|
|
|
|
|
WriteStatus("Database: Need (database.xml)");
|
|
|
|
|
else
|
|
|
|
|
WriteStatus("Database: OK");
|
|
|
|
|
|
|
|
|
|
if (IsWin7())
|
|
|
|
|
WriteStatus("Windows 7 Features: Enabled");
|
|
|
|
|
|
|
|
|
|
WriteStatus("");
|
|
|
|
|
WriteStatus("Special thanks to:");
|
|
|
|
|
WriteStatus(" * Crediar for his wadmaker tool + source, and for the advice!");
|
2010-07-07 00:50:17 +02:00
|
|
|
|
WriteStatus(" * Leathl for libWiiSharp.");
|
2010-07-05 02:34:33 +02:00
|
|
|
|
WriteStatus(" * SquidMan/Galaxy/comex/Xuzz for advice/sources.");
|
|
|
|
|
WriteStatus(" * Pasta for database compilation assistance.");
|
|
|
|
|
WriteStatus(" * Napo7 for testing proxy usage.");
|
2010-07-06 04:05:16 +02:00
|
|
|
|
WriteStatus(" * Wyatt O'Day for the Windows7ProgressBar Control.");
|
|
|
|
|
WriteStatus(" * Famfamfam for the Silk Icon Set.");
|
|
|
|
|
WriteStatus(" * #WiiDev for answering the tough questions.");
|
|
|
|
|
WriteStatus(" * Anyone who helped beta test!");
|
2010-07-05 02:34:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void checkBox1_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SaveProxyPwdPermanentBtn.Enabled = checkBox1.Checked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SaveProxyPwdPermanentBtn_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
proxy_pwd = ProxyPwdBox.Text;
|
|
|
|
|
|
|
|
|
|
string proxy_file = File.ReadAllText(Path.Combine(CURRENT_DIR, "proxy.txt"));
|
|
|
|
|
|
|
|
|
|
proxy_file += String.Format("\n{0}", proxy_pwd);
|
|
|
|
|
|
|
|
|
|
File.WriteAllText(Path.Combine(CURRENT_DIR, "proxy.txt"), proxy_file);
|
|
|
|
|
|
|
|
|
|
ProxyVerifyBox.Visible = false;
|
|
|
|
|
SetAllEnabled(true);
|
|
|
|
|
WriteStatus("To delete all traces of proxy settings, delete the proxy.txt file!");
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-08 18:55:01 +02:00
|
|
|
|
private void clearButton_MouseEnter(object sender, EventArgs e)
|
2010-07-05 02:34:33 +02:00
|
|
|
|
{
|
|
|
|
|
// expand clear button
|
2010-07-08 18:55:01 +02:00
|
|
|
|
/*button3.Left = 194;
|
|
|
|
|
button3.Size = new System.Drawing.Size(68, 21);*/
|
2010-07-08 19:18:28 +02:00
|
|
|
|
clearButton.Text = "Clear";
|
2010-07-08 18:55:01 +02:00
|
|
|
|
//button3.ImageAlign = ContentAlignment.MiddleLeft;
|
2010-07-05 02:34:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-07-08 18:55:01 +02:00
|
|
|
|
private void clearButton_MouseLeave(object sender, EventArgs e)
|
2010-07-05 02:34:33 +02:00
|
|
|
|
{
|
|
|
|
|
// shrink clear button
|
2010-07-08 18:55:01 +02:00
|
|
|
|
/*button3.Left = 239;
|
|
|
|
|
button3.Size = new System.Drawing.Size(23, 21);*/
|
2010-07-08 19:18:28 +02:00
|
|
|
|
if (Type.GetType ("Mono.Runtime") == null)
|
|
|
|
|
clearButton.Text = String.Empty;
|
2010-07-08 18:55:01 +02:00
|
|
|
|
//button3.ImageAlign = ContentAlignment.MiddleCenter;
|
2010-07-05 02:34:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-07-05 02:59:08 +02:00
|
|
|
|
private void saveaswadbtn_MouseEnter(object sender, EventArgs e)
|
2010-07-05 02:34:33 +02:00
|
|
|
|
{
|
2010-07-08 18:55:01 +02:00
|
|
|
|
/*saveaswadbtn.Left = 190;
|
|
|
|
|
saveaswadbtn.Size = new Size(72, 22);*/
|
2010-07-05 02:59:08 +02:00
|
|
|
|
saveaswadbtn.Text = "Save As";
|
2010-07-08 18:55:01 +02:00
|
|
|
|
/*saveaswadbtn.ImageAlign = ContentAlignment.MiddleLeft;*/
|
2010-07-05 02:34:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-07-05 02:59:08 +02:00
|
|
|
|
private void saveaswadbtn_MouseLeave(object sender, EventArgs e)
|
2010-07-05 02:34:33 +02:00
|
|
|
|
{
|
2010-07-08 18:55:01 +02:00
|
|
|
|
/*saveaswadbtn.Left = 230;
|
|
|
|
|
saveaswadbtn.Size = new Size(32, 22);*/
|
2010-07-08 19:18:28 +02:00
|
|
|
|
if (Type.GetType("Mono.Runtime") == null)
|
|
|
|
|
saveaswadbtn.Text = String.Empty;
|
2010-07-08 18:55:01 +02:00
|
|
|
|
//saveaswadbtn.ImageAlign = ContentAlignment.MiddleCenter;
|
2010-07-05 02:34:33 +02:00
|
|
|
|
}
|
2010-07-05 04:00:18 +02:00
|
|
|
|
|
|
|
|
|
void nus_script_item_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem tsmi = (ToolStripMenuItem)sender;
|
|
|
|
|
string folderpath = "";
|
|
|
|
|
if (!tsmi.OwnerItem.Equals(this.scriptsLocalMenuEntry))
|
|
|
|
|
{
|
|
|
|
|
folderpath = Path.Combine(tsmi.OwnerItem.Text, folderpath);
|
|
|
|
|
}
|
|
|
|
|
folderpath = Path.Combine(this.CURRENT_DIR, Path.Combine("scripts", Path.Combine(folderpath, tsmi.Text)));
|
|
|
|
|
script_filename = folderpath;
|
|
|
|
|
BackgroundWorker scripter = new BackgroundWorker();
|
|
|
|
|
scripter.DoWork += new DoWorkEventHandler(RunScript);
|
|
|
|
|
scripter.RunWorkerAsync();
|
2010-07-05 20:12:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveaswadbtn_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SaveFileDialog wad_saveas = new SaveFileDialog();
|
|
|
|
|
wad_saveas.Title = "Save WAD File...";
|
|
|
|
|
wad_saveas.Filter = "WAD Files|*.wad|All Files|*.*";
|
|
|
|
|
wad_saveas.AddExtension = true;
|
|
|
|
|
DialogResult dres = wad_saveas.ShowDialog();
|
|
|
|
|
if (dres != DialogResult.Cancel)
|
|
|
|
|
WAD_Saveas_Filename = wad_saveas.FileName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// This prevents errors when exiting before the database is parsed.
|
|
|
|
|
// This is also probably not the best way to accomplish this...
|
|
|
|
|
Environment.Exit(0);
|
|
|
|
|
}
|
2010-07-08 22:45:14 +02:00
|
|
|
|
|
|
|
|
|
private void iosPatchCheckbox_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (iosPatchCheckbox.Checked == true)
|
|
|
|
|
{
|
2010-07-09 01:57:44 +02:00
|
|
|
|
//packbox.Enabled = false;
|
2010-07-08 22:45:14 +02:00
|
|
|
|
packbox.Checked = true;
|
|
|
|
|
SetAllEnabled(false);
|
|
|
|
|
iosPatchGroupBox.Visible = true;
|
|
|
|
|
iosPatchGroupBox.Enabled = true;
|
|
|
|
|
iosPatchesListBox.Enabled = true;
|
|
|
|
|
iosPatchGroupBoxOKbtn.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void iosPatchGroupBoxOKbtn_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SetAllEnabled(true);
|
|
|
|
|
iosPatchGroupBox.Visible = false;
|
2010-07-09 19:54:13 +02:00
|
|
|
|
if (iosPatchesListBox.CheckedIndices.Count == 0)
|
|
|
|
|
// Uncheck the checkbox to indicate no patches
|
|
|
|
|
iosPatchCheckbox.Checked = false;
|
2010-07-08 22:45:14 +02:00
|
|
|
|
}
|
2010-07-10 05:32:53 +02:00
|
|
|
|
|
|
|
|
|
private void FillDatabaseScripts()
|
|
|
|
|
{
|
2010-07-11 03:09:50 +02:00
|
|
|
|
SetPropertyThreadSafe(scriptsDatabaseToolStripMenuItem, false, "Visible");
|
2010-07-10 05:32:53 +02:00
|
|
|
|
Database databaseObj = new Database();
|
|
|
|
|
databaseObj.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "database.xml"));
|
|
|
|
|
|
|
|
|
|
ToolStripMenuItem[] scriptItems = databaseObj.LoadScripts();
|
|
|
|
|
for (int a = 0; a < scriptItems.Length; a++)
|
|
|
|
|
{
|
|
|
|
|
scriptItems[a].DropDownItemClicked += new ToolStripItemClickedEventHandler(ScriptItem_Clicked);
|
|
|
|
|
|
|
|
|
|
AddToolStripItemToStrip(scriptsDatabaseToolStripMenuItem, scriptItems[a]);
|
|
|
|
|
//SystemMenuList.DropDownItems.Add(systemItems[a]);
|
|
|
|
|
}
|
2010-07-11 03:09:50 +02:00
|
|
|
|
|
2010-07-10 05:32:53 +02:00
|
|
|
|
SetPropertyThreadSafe(scriptsDatabaseToolStripMenuItem, true, "Enabled");
|
|
|
|
|
SetPropertyThreadSafe(scriptsDatabaseToolStripMenuItem, true, "Visible");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ScriptItem_Clicked(object sender, ToolStripItemClickedEventArgs e)
|
2010-07-11 03:09:50 +02:00
|
|
|
|
{// STILL TODO
|
|
|
|
|
ToolStripMenuItem tsmi = (ToolStripMenuItem)sender;
|
|
|
|
|
string folderpath = "\000";
|
|
|
|
|
script_filename = folderpath;
|
|
|
|
|
BackgroundWorker scripter = new BackgroundWorker();
|
|
|
|
|
scripter.DoWork += new DoWorkEventHandler(RunScript);
|
|
|
|
|
scripter.RunWorkerAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ReorganizePreviousFolderStructure(object sender, DoWorkEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// 0000000000000000v000\* become titles\0000000000000000\v000\*
|
|
|
|
|
Regex TitleDirectoryRegex = new Regex(@"[a-zA-Z0-9]{16}v?([0-9]*)?");
|
|
|
|
|
|
|
|
|
|
if (Directory.Exists(Path.Combine(CURRENT_DIR, "titles")) == false)
|
|
|
|
|
Directory.CreateDirectory(Path.Combine(CURRENT_DIR, "titles"));
|
|
|
|
|
|
|
|
|
|
string[] directories = Directory.GetDirectories(CURRENT_DIR, "*", SearchOption.TopDirectoryOnly);
|
|
|
|
|
foreach (string directory in directories)
|
|
|
|
|
{
|
|
|
|
|
DirectoryInfo dinfo = new DirectoryInfo(directory);
|
|
|
|
|
if (TitleDirectoryRegex.IsMatch(dinfo.Name.ToString()) == false)
|
|
|
|
|
break;
|
2010-07-20 04:49:48 +02:00
|
|
|
|
|
|
|
|
|
// name is XXXXXXXXXXXXXXXXvYYYY
|
|
|
|
|
if (TitleDirectoryRegex.IsMatch(dinfo.Name.ToString()) && dinfo.Name.Contains("v"))
|
|
|
|
|
{
|
|
|
|
|
string[] title_info = dinfo.Name.Split('v');
|
|
|
|
|
string titleid_dir = Path.Combine(Path.Combine(CURRENT_DIR, "titles"), title_info[0]);
|
|
|
|
|
string newfull_dir = Path.Combine(titleid_dir, String.Format("v{0}", title_info[1]));
|
|
|
|
|
|
|
|
|
|
if (Directory.Exists(titleid_dir) == false)
|
|
|
|
|
Directory.CreateDirectory(titleid_dir);
|
|
|
|
|
|
|
|
|
|
if (Directory.Exists(newfull_dir) == false)
|
|
|
|
|
Directory.CreateDirectory(newfull_dir);
|
|
|
|
|
|
|
|
|
|
string[] files = Directory.GetFiles(directory, "*", SearchOption.TopDirectoryOnly);
|
|
|
|
|
foreach (string file in files)
|
|
|
|
|
{
|
|
|
|
|
FileInfo titlefile = new FileInfo(file);
|
|
|
|
|
titlefile.MoveTo(Path.Combine(newfull_dir, titlefile.Name));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dinfo.GetFiles().Length <= 0 || dinfo.GetDirectories().Length < 0)
|
|
|
|
|
Directory.Delete(directory);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else // name is XXXXXXXXXXXXXXXX
|
|
|
|
|
{
|
|
|
|
|
string titleid_dir = Path.Combine(Path.Combine(CURRENT_DIR, "titles"), dinfo.Name.ToString());
|
|
|
|
|
|
|
|
|
|
libWiiSharp.TMD tmdfile = new libWiiSharp.TMD();
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
|
|
string[] tmdfiles = Directory.GetFiles(directory, "*tmd*", SearchOption.TopDirectoryOnly);
|
|
|
|
|
if (tmdfiles.Length > 1)
|
|
|
|
|
break; //Too many TMD files ?
|
|
|
|
|
|
|
|
|
|
foreach (string file in tmdfiles)
|
|
|
|
|
{
|
|
|
|
|
if (file.Contains("tmd"))
|
|
|
|
|
{
|
|
|
|
|
tmdfile.LoadFile(file);
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (count == 0)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
string version = tmdfile.TitleVersion.ToString();
|
|
|
|
|
string newfull_dir = Path.Combine(titleid_dir, String.Format("v{0}", version));
|
|
|
|
|
|
|
|
|
|
if (Directory.Exists(titleid_dir) == false)
|
|
|
|
|
Directory.CreateDirectory(titleid_dir);
|
|
|
|
|
|
|
|
|
|
if (Directory.Exists(newfull_dir) == false)
|
|
|
|
|
Directory.CreateDirectory(newfull_dir);
|
|
|
|
|
|
|
|
|
|
string[] files = Directory.GetFiles(directory, "*", SearchOption.TopDirectoryOnly);
|
|
|
|
|
foreach (string file in files)
|
|
|
|
|
{
|
|
|
|
|
FileInfo titlefile = new FileInfo(file);
|
|
|
|
|
titlefile.MoveTo(Path.Combine(newfull_dir, titlefile.Name));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dinfo.GetFiles().Length <= 0 || dinfo.GetDirectories().Length < 0)
|
|
|
|
|
Directory.Delete(directory);
|
|
|
|
|
|
|
|
|
|
}
|
2010-07-11 03:09:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ReorganizePreviousFolderStructure_Completed(object sender, RunWorkerCompletedEventArgs e)
|
|
|
|
|
{
|
2010-07-20 04:49:48 +02:00
|
|
|
|
WriteStatus(" - Operation complete!");
|
2010-07-10 20:42:35 +02:00
|
|
|
|
}
|
2009-06-11 03:16:49 +02:00
|
|
|
|
}
|
2010-07-04 05:24:51 +02:00
|
|
|
|
}
|