mirror of
https://github.com/WiiDatabase/nusdownloader.git
synced 2024-12-25 18:11:51 +01:00
Did some more work on allowing scripting.
TODO: Fix the bit of the script running function that requires it to ignore illegal cross-thread calls.
This commit is contained in:
parent
16ab72564d
commit
2cc5fd70a3
1
NUS Downloader/Form1.Designer.cs
generated
1
NUS Downloader/Form1.Designer.cs
generated
@ -142,6 +142,7 @@
|
|||||||
this.PALMassUpdate = new System.Windows.Forms.ToolStripMenuItem();
|
this.PALMassUpdate = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.NTSCMassUpdate = new System.Windows.Forms.ToolStripMenuItem();
|
this.NTSCMassUpdate = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.KoreaMassUpdate = new System.Windows.Forms.ToolStripMenuItem();
|
this.KoreaMassUpdate = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
|
||||||
this.databaseStrip.SuspendLayout();
|
this.databaseStrip.SuspendLayout();
|
||||||
this.tmdgpbox.SuspendLayout();
|
this.tmdgpbox.SuspendLayout();
|
||||||
this.ticketgpbox.SuspendLayout();
|
this.ticketgpbox.SuspendLayout();
|
||||||
|
@ -29,6 +29,7 @@ namespace NUS_Downloader
|
|||||||
|
|
||||||
// Cross-thread Windows Formsing
|
// Cross-thread Windows Formsing
|
||||||
delegate void AddToolStripItemToStripCallback(int type, ToolStripMenuItem additionitem, XmlAttributeCollection attributes); //TODO
|
delegate void AddToolStripItemToStripCallback(int type, ToolStripMenuItem additionitem, XmlAttributeCollection attributes); //TODO
|
||||||
|
delegate void WriteStatusCallback(string Update);
|
||||||
|
|
||||||
// Images do not compare unless globalized...
|
// Images do not compare unless globalized...
|
||||||
Image green = Properties.Resources.bullet_green;
|
Image green = Properties.Resources.bullet_green;
|
||||||
@ -53,6 +54,7 @@ namespace NUS_Downloader
|
|||||||
// TODO: OOP scripting
|
// TODO: OOP scripting
|
||||||
string script_filename;
|
string script_filename;
|
||||||
bool script_mode = false;
|
bool script_mode = false;
|
||||||
|
string[] nusentries;
|
||||||
|
|
||||||
// Proxy stuff...
|
// Proxy stuff...
|
||||||
string proxy_url;
|
string proxy_url;
|
||||||
@ -95,6 +97,9 @@ namespace NUS_Downloader
|
|||||||
public Form1()
|
public Form1()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
KoreaMassUpdate.DropDownItemClicked += new ToolStripItemClickedEventHandler(upditem_itemclicked);
|
||||||
|
NTSCMassUpdate.DropDownItemClicked += new ToolStripItemClickedEventHandler(upditem_itemclicked);
|
||||||
|
PALMassUpdate.DropDownItemClicked += new ToolStripItemClickedEventHandler(upditem_itemclicked);
|
||||||
this.fds = new BackgroundWorker();
|
this.fds = new BackgroundWorker();
|
||||||
this.fds.DoWork += new DoWorkEventHandler(DoAllDatabaseyStuff);
|
this.fds.DoWork += new DoWorkEventHandler(DoAllDatabaseyStuff);
|
||||||
this.fds.RunWorkerCompleted += new RunWorkerCompletedEventHandler(DoAllDatabaseyStuff_Completed);
|
this.fds.RunWorkerCompleted += new RunWorkerCompletedEventHandler(DoAllDatabaseyStuff_Completed);
|
||||||
@ -505,6 +510,14 @@ namespace NUS_Downloader
|
|||||||
/// <param name="Update">The update.</param>
|
/// <param name="Update">The update.</param>
|
||||||
public void WriteStatus(string Update)
|
public void WriteStatus(string Update)
|
||||||
{
|
{
|
||||||
|
// Check if thread-safe
|
||||||
|
if (this.InvokeRequired)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("InvokeRequired...");
|
||||||
|
WriteStatusCallback wsc = new WriteStatusCallback(WriteStatus);
|
||||||
|
this.Invoke(wsc, new object[] { Update });
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Small function for writing text to the statusbox...
|
// Small function for writing text to the statusbox...
|
||||||
if (statusbox.Text == "")
|
if (statusbox.Text == "")
|
||||||
statusbox.Text = Update;
|
statusbox.Text = Update;
|
||||||
@ -1826,6 +1839,7 @@ namespace NUS_Downloader
|
|||||||
break;
|
break;
|
||||||
case "titleIDs":
|
case "titleIDs":
|
||||||
updateScript = ChildrenOfTheNode[z].InnerText;
|
updateScript = ChildrenOfTheNode[z].InnerText;
|
||||||
|
XMLToolStripItem.AccessibleDescription = updateScript; // TODO: Find somewhere better to put this. AND FAST.
|
||||||
break;
|
break;
|
||||||
case "version":
|
case "version":
|
||||||
string[] versions = ChildrenOfTheNode[z].InnerText.Split(',');
|
string[] versions = ChildrenOfTheNode[z].InnerText.Split(',');
|
||||||
@ -1975,7 +1989,7 @@ namespace NUS_Downloader
|
|||||||
Debug.WriteLine("Oops - database error");
|
Debug.WriteLine("Oops - database error");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
additionitem.Click += new ToolStripItemClickedEventHandler(upditem_itemclicked);
|
//additionitem.Click += new EventHandler(upditem_itemclicked);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2100,6 +2114,26 @@ namespace NUS_Downloader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void upditem_itemclicked(object sender, ToolStripItemClickedEventArgs e)
|
||||||
|
{
|
||||||
|
WriteStatus("Preparing to run download script...");
|
||||||
|
Control.CheckForIllegalCrossThreadCalls = false;
|
||||||
|
script_mode = true;
|
||||||
|
statusbox.Text = "";
|
||||||
|
WriteStatus("Starting script download. Please be patient!");
|
||||||
|
string[] NUS_Entries = e.ClickedItem.AccessibleDescription.Split('\n'); // TODO: Find somewhere better to put this. AND FAST!
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void sysitem_versionclicked(object sender, ToolStripItemClickedEventArgs e)
|
void sysitem_versionclicked(object sender, ToolStripItemClickedEventArgs e)
|
||||||
{
|
{
|
||||||
titleidbox.Text = e.ClickedItem.OwnerItem.Text.Substring(0, 16);
|
titleidbox.Text = e.ClickedItem.OwnerItem.Text.Substring(0, 16);
|
||||||
@ -4142,7 +4176,15 @@ namespace NUS_Downloader
|
|||||||
script_mode = true;
|
script_mode = true;
|
||||||
statusbox.Text = "";
|
statusbox.Text = "";
|
||||||
WriteStatus("Starting script download. Please be patient!");
|
WriteStatus("Starting script download. Please be patient!");
|
||||||
string[] NUS_Entries = File.ReadAllLines(script_filename);
|
string[] NUS_Entries;
|
||||||
|
if (script_filename != "\000")
|
||||||
|
{
|
||||||
|
NUS_Entries = File.ReadAllLines(script_filename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NUS_Entries = nusentries;
|
||||||
|
}
|
||||||
WriteStatus(String.Format(" - Script loaded ({0} Titles)", NUS_Entries.Length));
|
WriteStatus(String.Format(" - Script loaded ({0} Titles)", NUS_Entries.Length));
|
||||||
|
|
||||||
for (int a = 0; a < NUS_Entries.Length; a++)
|
for (int a = 0; a < NUS_Entries.Length; a++)
|
||||||
|
Loading…
Reference in New Issue
Block a user