mirror of
https://github.com/WB3000/nusdownloader.git
synced 2024-11-17 07:09:21 +01:00
Some form of CLI added (wiiNinja style)
This commit is contained in:
parent
f0a6219e1f
commit
7b173829bc
10
NUS Downloader/Form1.Designer.cs
generated
10
NUS Downloader/Form1.Designer.cs
generated
@ -424,7 +424,7 @@ namespace NUS_Downloader
|
|||||||
// runFolderFixToolStripMenuItem
|
// runFolderFixToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.runFolderFixToolStripMenuItem.Name = "runFolderFixToolStripMenuItem";
|
this.runFolderFixToolStripMenuItem.Name = "runFolderFixToolStripMenuItem";
|
||||||
this.runFolderFixToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
this.runFolderFixToolStripMenuItem.Size = new System.Drawing.Size(144, 22);
|
||||||
this.runFolderFixToolStripMenuItem.Text = "Run \'FolderFix\'";
|
this.runFolderFixToolStripMenuItem.Text = "Run \'FolderFix\'";
|
||||||
this.runFolderFixToolStripMenuItem.Click += new System.EventHandler(this.runFolderFixToolStripMenuItem_Click);
|
this.runFolderFixToolStripMenuItem.Click += new System.EventHandler(this.runFolderFixToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
@ -434,20 +434,20 @@ namespace NUS_Downloader
|
|||||||
this.mainPageToolStripMenuItem,
|
this.mainPageToolStripMenuItem,
|
||||||
this.databasePageToolStripMenuItem});
|
this.databasePageToolStripMenuItem});
|
||||||
this.wiiBrewToolStripMenuItem.Name = "wiiBrewToolStripMenuItem";
|
this.wiiBrewToolStripMenuItem.Name = "wiiBrewToolStripMenuItem";
|
||||||
this.wiiBrewToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
this.wiiBrewToolStripMenuItem.Size = new System.Drawing.Size(144, 22);
|
||||||
this.wiiBrewToolStripMenuItem.Text = "WiiBrew";
|
this.wiiBrewToolStripMenuItem.Text = "WiiBrew";
|
||||||
//
|
//
|
||||||
// mainPageToolStripMenuItem
|
// mainPageToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.mainPageToolStripMenuItem.Name = "mainPageToolStripMenuItem";
|
this.mainPageToolStripMenuItem.Name = "mainPageToolStripMenuItem";
|
||||||
this.mainPageToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
this.mainPageToolStripMenuItem.Size = new System.Drawing.Size(147, 22);
|
||||||
this.mainPageToolStripMenuItem.Text = "Main Page";
|
this.mainPageToolStripMenuItem.Text = "Main Page";
|
||||||
this.mainPageToolStripMenuItem.Click += new System.EventHandler(this.mainPageToolStripMenuItem_Click);
|
this.mainPageToolStripMenuItem.Click += new System.EventHandler(this.mainPageToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// databasePageToolStripMenuItem
|
// databasePageToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.databasePageToolStripMenuItem.Name = "databasePageToolStripMenuItem";
|
this.databasePageToolStripMenuItem.Name = "databasePageToolStripMenuItem";
|
||||||
this.databasePageToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
this.databasePageToolStripMenuItem.Size = new System.Drawing.Size(147, 22);
|
||||||
this.databasePageToolStripMenuItem.Text = "Database Page";
|
this.databasePageToolStripMenuItem.Text = "Database Page";
|
||||||
this.databasePageToolStripMenuItem.Click += new System.EventHandler(this.databasePageToolStripMenuItem_Click);
|
this.databasePageToolStripMenuItem.Click += new System.EventHandler(this.databasePageToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
@ -960,7 +960,7 @@ namespace NUS_Downloader
|
|||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.Name = "Form1";
|
this.Name = "Form1";
|
||||||
this.Text = "NUSD";
|
this.Text = " ";
|
||||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
|
||||||
this.Load += new System.EventHandler(this.Form1_Load);
|
this.Load += new System.EventHandler(this.Form1_Load);
|
||||||
this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseWheel);
|
this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseWheel);
|
||||||
|
@ -104,8 +104,31 @@ namespace NUS_Downloader
|
|||||||
|
|
||||||
GUISetup();
|
GUISetup();
|
||||||
|
|
||||||
|
if ((args.Length == 1) && (File.Exists(args[0])))
|
||||||
|
{
|
||||||
BootChecks();
|
BootChecks();
|
||||||
|
|
||||||
|
string script_content = File.ReadAllText(args[0]);
|
||||||
|
FileInfo script_file = new FileInfo(args[0]);
|
||||||
|
script_content += String.Format(";{0}", script_file.Name.Replace("." + script_file.Extension, ""));
|
||||||
|
|
||||||
|
BackgroundWorker scripter = new BackgroundWorker();
|
||||||
|
scripter.DoWork += new DoWorkEventHandler(RunScriptBg);
|
||||||
|
scripter.RunWorkerAsync(script_content);
|
||||||
|
}
|
||||||
|
else if (args.Length >= 2)
|
||||||
|
{
|
||||||
|
RunCommandMode(args);
|
||||||
|
Environment.Exit(0);
|
||||||
|
//this.Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BootChecks();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Fix proxy entry.
|
/* Fix proxy entry.
|
||||||
if (!(String.IsNullOrEmpty(proxy_url)))
|
if (!(String.IsNullOrEmpty(proxy_url)))
|
||||||
while (String.IsNullOrEmpty(proxy_pwd))
|
while (String.IsNullOrEmpty(proxy_pwd))
|
||||||
@ -122,15 +145,86 @@ namespace NUS_Downloader
|
|||||||
folder_fixer.RunWorkerAsync();
|
folder_fixer.RunWorkerAsync();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if ((args.Length == 1) && (File.Exists(args[0])))
|
|
||||||
{
|
|
||||||
string script_content = File.ReadAllText(args[0]);
|
|
||||||
FileInfo script_file = new FileInfo(args[0]);
|
|
||||||
script_content += String.Format(";{0}", script_file.Name.Replace("." + script_file.Extension, ""));
|
|
||||||
|
|
||||||
BackgroundWorker scripter = new BackgroundWorker();
|
}
|
||||||
scripter.DoWork += new DoWorkEventHandler(RunScriptBg);
|
|
||||||
scripter.RunWorkerAsync(script_content);
|
private void RunCommandMode(string[] args)
|
||||||
|
{
|
||||||
|
// CLI mode, inspired and taken from wiiNinja's mod.
|
||||||
|
|
||||||
|
// Initialize the checkboxes and radio boxes
|
||||||
|
packbox.Checked = false; // Create wad - default OFF
|
||||||
|
localuse.Checked = true; // Use local content if already downloaded - default ON
|
||||||
|
decryptbox.Checked = false;
|
||||||
|
keepenccontents.Checked = false;
|
||||||
|
consoleCBox.SelectedIndex = 0; // 0 is Wii, 1 is DS
|
||||||
|
|
||||||
|
// Clear 3 items in ios patches list. This feature is not supported in the command line version at this time.
|
||||||
|
iosPatchCheckbox.Checked = false;
|
||||||
|
iosPatchesListBox.SetItemChecked(0, false);
|
||||||
|
iosPatchesListBox.SetItemChecked(1, false);
|
||||||
|
iosPatchesListBox.SetItemChecked(2, false);
|
||||||
|
|
||||||
|
Console.WriteLine("NUS Downloader - v{0}", version);
|
||||||
|
|
||||||
|
if (args.Length < 2)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Usage:");
|
||||||
|
Console.WriteLine(" nusd <titleID> <titleVersion | *> [optionalArgs]");
|
||||||
|
Console.WriteLine("\nWhere:");
|
||||||
|
Console.WriteLine(" titleID = The ID of the title to be downloaded");
|
||||||
|
Console.WriteLine(" titleVersion = The version of the title to be downloaded");
|
||||||
|
Console.WriteLine(" Use \"*\" (no quotes) to get the latest version");
|
||||||
|
Console.WriteLine(" OptionalArgs:");
|
||||||
|
Console.WriteLine(" packwad = A wad file will be generated");
|
||||||
|
Console.WriteLine(" localuse = Use local contents if available");
|
||||||
|
Console.WriteLine(" decrypt = Create decrypted contents");
|
||||||
|
Console.WriteLine(" keepencrypt = Keep encrypted contents");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < args.Length; i++)
|
||||||
|
{
|
||||||
|
Console.WriteLine("{0}", args[i]);
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
// First command line argument is ALWAYS the TitleID
|
||||||
|
titleidbox.Text = args[i];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
// Second command line argument is ALWAYS the TitleVersion.
|
||||||
|
// User may specify a "*" to retrieve the latest version
|
||||||
|
if (args[i] == "*")
|
||||||
|
titleversion.Text = "";
|
||||||
|
else
|
||||||
|
titleversion.Text = args[i];
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Any other arguments beyond the 2nd one are considered optional
|
||||||
|
if (args[i] == "packwad")
|
||||||
|
packbox.Checked = true;
|
||||||
|
else if (args[i] == "localuse")
|
||||||
|
localuse.Checked = true;
|
||||||
|
else if (args[i] == "decrypt")
|
||||||
|
decryptbox.Checked = true;
|
||||||
|
else if (args[i] == "keepencrypt")
|
||||||
|
keepenccontents.Checked = true;
|
||||||
|
else
|
||||||
|
Console.WriteLine("\n>>>> Warning: Unrecognized command line argument: {0}. This option is ignored...", args[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do this to set the wad file name
|
||||||
|
UpdatePackedName();
|
||||||
|
|
||||||
|
// Call to get the files from server
|
||||||
|
NUSDownloader_DoWork(null, null);
|
||||||
|
|
||||||
|
Console.WriteLine("\nSuccessfully downloaded the title {0} version {1}", args[0], args[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +261,6 @@ namespace NUS_Downloader
|
|||||||
this.scriptsWorker = new BackgroundWorker();
|
this.scriptsWorker = new BackgroundWorker();
|
||||||
this.scriptsWorker.DoWork += new DoWorkEventHandler(OrganizeScripts);
|
this.scriptsWorker.DoWork += new DoWorkEventHandler(OrganizeScripts);
|
||||||
this.scriptsWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(scriptsWorker_RunWorkerCompleted);
|
this.scriptsWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(scriptsWorker_RunWorkerCompleted);
|
||||||
RunScriptOrganizer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Form1_Load(object sender, EventArgs e)
|
private void Form1_Load(object sender, EventArgs e)
|
||||||
@ -232,6 +325,9 @@ namespace NUS_Downloader
|
|||||||
this.fds.RunWorkerAsync();
|
this.fds.RunWorkerAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load scripts (local)
|
||||||
|
RunScriptOrganizer();
|
||||||
|
|
||||||
// Check for Proxy Settings file...
|
// Check for Proxy Settings file...
|
||||||
if (NUSDFileExists("proxy.txt") == true)
|
if (NUSDFileExists("proxy.txt") == true)
|
||||||
{
|
{
|
||||||
@ -415,6 +511,9 @@ namespace NUS_Downloader
|
|||||||
statusbox.SelectionStart = statusbox.TextLength;
|
statusbox.SelectionStart = statusbox.TextLength;
|
||||||
statusbox.SelectionLength = 0;
|
statusbox.SelectionLength = 0;
|
||||||
statusbox.ScrollToCaret();
|
statusbox.ScrollToCaret();
|
||||||
|
|
||||||
|
// Also write to console
|
||||||
|
Console.WriteLine(Update);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Binary file not shown.
@ -6,7 +6,7 @@
|
|||||||
<ProductVersion>9.0.30729</ProductVersion>
|
<ProductVersion>9.0.30729</ProductVersion>
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
<ProjectGuid>{DB1289FA-BA83-408F-A576-326E5EC4CC6D}</ProjectGuid>
|
<ProjectGuid>{DB1289FA-BA83-408F-A576-326E5EC4CC6D}</ProjectGuid>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>NUS_Downloader</RootNamespace>
|
<RootNamespace>NUS_Downloader</RootNamespace>
|
||||||
<AssemblyName>NUS Downloader</AssemblyName>
|
<AssemblyName>NUS Downloader</AssemblyName>
|
||||||
@ -59,6 +59,9 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<StartupObject />
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
|
@ -8,23 +8,60 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace NUS_Downloader
|
namespace NUS_Downloader
|
||||||
{
|
{
|
||||||
static class Program
|
static class Program
|
||||||
{
|
{
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
Console.Title = "NUSD";
|
||||||
|
|
||||||
|
// hide the console window
|
||||||
|
setConsoleWindowVisibility(false, Console.Title);
|
||||||
|
|
||||||
|
if (args.Length != 0)
|
||||||
|
{
|
||||||
|
// hide the console window
|
||||||
|
setConsoleWindowVisibility(true, Console.Title);
|
||||||
|
Application.Run(new Form1(args));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// hide the console window
|
||||||
|
setConsoleWindowVisibility(false, Console.Title);
|
||||||
|
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
if (args.Length != 0)
|
|
||||||
Application.Run(new Form1(args));
|
|
||||||
else
|
|
||||||
Application.Run(new Form1());
|
Application.Run(new Form1());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setConsoleWindowVisibility(bool visible, string title)
|
||||||
|
{
|
||||||
|
//Sometimes System.Windows.Forms.Application.ExecutablePath works for the caption depending on the system you are running under.
|
||||||
|
IntPtr hWnd = FindWindow(null, title);
|
||||||
|
|
||||||
|
if (hWnd != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
if (!visible)
|
||||||
|
//Hide the window
|
||||||
|
ShowWindow(hWnd, 0); // 0 = SW_HIDE
|
||||||
|
else
|
||||||
|
//Show window again
|
||||||
|
ShowWindow(hWnd, 1); //1 = SW_SHOWNORMA
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user