WIP itemmaker download feature
This commit is contained in:
parent
16a4f28a27
commit
b638c3b689
Binary file not shown.
|
|
@ -31,7 +31,7 @@ class Downloader
|
||||||
return downloadOutcome;
|
return downloadOutcome;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitDownload(string additionalText = "")
|
public void InitDownload(bool gzip, string additionalText = "")
|
||||||
{
|
{
|
||||||
downloadOutcomeAddText = additionalText;
|
downloadOutcomeAddText = additionalText;
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ class Downloader
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int read = DownloadGZipFile(fileURL, saveFileDialog1.FileName);
|
int read = DownloadFile(fileURL, saveFileDialog1.FileName, gzip);
|
||||||
downloadOutcome = "File " + Path.GetFileName(saveFileDialog1.FileName) + " downloaded! " + read + " bytes written!" + downloadOutcomeAddText;
|
downloadOutcome = "File " + Path.GetFileName(saveFileDialog1.FileName) + " downloaded! " + read + " bytes written!" + downloadOutcomeAddText;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -56,8 +56,8 @@ class Downloader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// currently this only DLs GZipped files. Will mod it to download both types later on. - Bitl
|
|
||||||
public static int DownloadGZipFile(string remoteFilename, string localFilename)
|
private static int DownloadFile(string remoteFilename, string localFilename, bool gzip)
|
||||||
{
|
{
|
||||||
//credit to Tom Archer (https://www.codeguru.com/columns/dotnettips/article.php/c7005/Downloading-Files-with-the-WebRequest-and-WebResponse-Classes.htm)
|
//credit to Tom Archer (https://www.codeguru.com/columns/dotnettips/article.php/c7005/Downloading-Files-with-the-WebRequest-and-WebResponse-Classes.htm)
|
||||||
//and Brokenglass (https://stackoverflow.com/questions/4567313/uncompressing-gzip-response-from-webclient/4567408#4567408)
|
//and Brokenglass (https://stackoverflow.com/questions/4567313/uncompressing-gzip-response-from-webclient/4567408#4567408)
|
||||||
|
|
@ -77,10 +77,39 @@ class Downloader
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Create a request for the specified remote file name
|
// Create a request for the specified remote file name
|
||||||
//WebRequest request = WebRequest.Create(remoteFilename);
|
if (gzip)
|
||||||
var request = (HttpWebRequest)WebRequest.Create(remoteFilename);
|
{
|
||||||
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(remoteFilename);
|
||||||
request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate");
|
request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate");
|
||||||
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
|
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
|
||||||
|
processRequest(request, response, remoteStream, localStream, localFilename, bytesProcessed);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WebRequest request = WebRequest.Create(remoteFilename);
|
||||||
|
processRequest(request, response, remoteStream, localStream, localFilename, bytesProcessed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// Close the response and streams objects here
|
||||||
|
// to make sure they're closed even if an exception
|
||||||
|
// is thrown at some point
|
||||||
|
if (response != null) response.Close();
|
||||||
|
if (remoteStream != null) remoteStream.Close();
|
||||||
|
if (localStream != null) localStream.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return total bytes processed to caller.
|
||||||
|
return bytesProcessed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void processRequest(WebRequest request, WebResponse response, Stream remoteStream, Stream localStream, string localFilename, int bytesProcessed)
|
||||||
|
{
|
||||||
if (request != null)
|
if (request != null)
|
||||||
{
|
{
|
||||||
// Send the request to the server and retrieve the
|
// Send the request to the server and retrieve the
|
||||||
|
|
@ -115,23 +144,6 @@ class Downloader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Console.WriteLine(e.Message);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
// Close the response and streams objects here
|
|
||||||
// to make sure they're closed even if an exception
|
|
||||||
// is thrown at some point
|
|
||||||
if (response != null) response.Close();
|
|
||||||
if (remoteStream != null) remoteStream.Close();
|
|
||||||
if (localStream != null) localStream.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return total bytes processed to caller.
|
|
||||||
return bytesProcessed;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
|
void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,9 @@ namespace NovetusLauncher
|
||||||
this.label3 = new System.Windows.Forms.Label();
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
this.comboBox1 = new System.Windows.Forms.ComboBox();
|
this.comboBox1 = new System.Windows.Forms.ComboBox();
|
||||||
this.checkBox1 = new System.Windows.Forms.CheckBox();
|
this.checkBox1 = new System.Windows.Forms.CheckBox();
|
||||||
|
this.progressBar1 = new System.Windows.Forms.ProgressBar();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.textBox1 = new System.Windows.Forms.TextBox();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
|
|
@ -59,14 +62,14 @@ namespace NovetusLauncher
|
||||||
//
|
//
|
||||||
// textBox2
|
// textBox2
|
||||||
//
|
//
|
||||||
this.textBox2.Location = new System.Drawing.Point(46, 27);
|
this.textBox2.Location = new System.Drawing.Point(98, 25);
|
||||||
this.textBox2.Name = "textBox2";
|
this.textBox2.Name = "textBox2";
|
||||||
this.textBox2.Size = new System.Drawing.Size(76, 20);
|
this.textBox2.Size = new System.Drawing.Size(76, 20);
|
||||||
this.textBox2.TabIndex = 2;
|
this.textBox2.TabIndex = 2;
|
||||||
//
|
//
|
||||||
// numericUpDown1
|
// numericUpDown1
|
||||||
//
|
//
|
||||||
this.numericUpDown1.Location = new System.Drawing.Point(161, 27);
|
this.numericUpDown1.Location = new System.Drawing.Point(193, 25);
|
||||||
this.numericUpDown1.Maximum = new decimal(new int[] {
|
this.numericUpDown1.Maximum = new decimal(new int[] {
|
||||||
99,
|
99,
|
||||||
0,
|
0,
|
||||||
|
|
@ -78,15 +81,15 @@ namespace NovetusLauncher
|
||||||
//
|
//
|
||||||
// label2
|
// label2
|
||||||
//
|
//
|
||||||
this.label2.Location = new System.Drawing.Point(63, 10);
|
this.label2.Location = new System.Drawing.Point(116, 9);
|
||||||
this.label2.Name = "label2";
|
this.label2.Name = "label2";
|
||||||
this.label2.Size = new System.Drawing.Size(46, 14);
|
this.label2.Size = new System.Drawing.Size(41, 14);
|
||||||
this.label2.TabIndex = 6;
|
this.label2.TabIndex = 6;
|
||||||
this.label2.Text = "Item ID";
|
this.label2.Text = "Item ID";
|
||||||
//
|
//
|
||||||
// label3
|
// label3
|
||||||
//
|
//
|
||||||
this.label3.Location = new System.Drawing.Point(161, 9);
|
this.label3.Location = new System.Drawing.Point(190, 9);
|
||||||
this.label3.Name = "label3";
|
this.label3.Name = "label3";
|
||||||
this.label3.Size = new System.Drawing.Size(42, 14);
|
this.label3.Size = new System.Drawing.Size(42, 14);
|
||||||
this.label3.TabIndex = 7;
|
this.label3.TabIndex = 7;
|
||||||
|
|
@ -110,20 +113,45 @@ namespace NovetusLauncher
|
||||||
//
|
//
|
||||||
// checkBox1
|
// checkBox1
|
||||||
//
|
//
|
||||||
this.checkBox1.Location = new System.Drawing.Point(18, 109);
|
this.checkBox1.Location = new System.Drawing.Point(12, 126);
|
||||||
this.checkBox1.Name = "checkBox1";
|
this.checkBox1.Name = "checkBox1";
|
||||||
this.checkBox1.Size = new System.Drawing.Size(214, 24);
|
this.checkBox1.Size = new System.Drawing.Size(220, 24);
|
||||||
this.checkBox1.TabIndex = 9;
|
this.checkBox1.TabIndex = 9;
|
||||||
this.checkBox1.Text = "Disable Help Message on Item Creation";
|
this.checkBox1.Text = "Disable Help Message on Item Creation";
|
||||||
this.checkBox1.UseVisualStyleBackColor = true;
|
this.checkBox1.UseVisualStyleBackColor = true;
|
||||||
this.checkBox1.CheckedChanged += new System.EventHandler(this.CheckBox1CheckedChanged);
|
this.checkBox1.CheckedChanged += new System.EventHandler(this.CheckBox1CheckedChanged);
|
||||||
//
|
//
|
||||||
|
// progressBar1
|
||||||
|
//
|
||||||
|
this.progressBar1.Location = new System.Drawing.Point(3, 110);
|
||||||
|
this.progressBar1.Name = "progressBar1";
|
||||||
|
this.progressBar1.Size = new System.Drawing.Size(238, 10);
|
||||||
|
this.progressBar1.TabIndex = 10;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.Location = new System.Drawing.Point(33, 9);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(35, 14);
|
||||||
|
this.label1.TabIndex = 11;
|
||||||
|
this.label1.Text = "Name";
|
||||||
|
//
|
||||||
|
// textBox1
|
||||||
|
//
|
||||||
|
this.textBox1.Location = new System.Drawing.Point(12, 25);
|
||||||
|
this.textBox1.Name = "textBox1";
|
||||||
|
this.textBox1.Size = new System.Drawing.Size(76, 20);
|
||||||
|
this.textBox1.TabIndex = 12;
|
||||||
|
//
|
||||||
// ItemMaker
|
// ItemMaker
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.BackColor = System.Drawing.SystemColors.ControlLightLight;
|
this.BackColor = System.Drawing.SystemColors.ControlLightLight;
|
||||||
this.ClientSize = new System.Drawing.Size(244, 139);
|
this.ClientSize = new System.Drawing.Size(244, 152);
|
||||||
|
this.Controls.Add(this.textBox1);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.progressBar1);
|
||||||
this.Controls.Add(this.checkBox1);
|
this.Controls.Add(this.checkBox1);
|
||||||
this.Controls.Add(this.comboBox1);
|
this.Controls.Add(this.comboBox1);
|
||||||
this.Controls.Add(this.label3);
|
this.Controls.Add(this.label3);
|
||||||
|
|
@ -150,5 +178,8 @@ namespace NovetusLauncher
|
||||||
private System.Windows.Forms.TextBox textBox2;
|
private System.Windows.Forms.TextBox textBox2;
|
||||||
private System.Windows.Forms.Button button1;
|
private System.Windows.Forms.Button button1;
|
||||||
private System.Windows.Forms.CheckBox checkBox1;
|
private System.Windows.Forms.CheckBox checkBox1;
|
||||||
|
private System.Windows.Forms.ProgressBar progressBar1;
|
||||||
|
private System.Windows.Forms.Label label1;
|
||||||
|
private System.Windows.Forms.TextBox textBox1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,12 +38,42 @@ namespace NovetusLauncher
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string version = ((numericUpDown1.Value != 0) && (isWebSite != true)) ? "&version=" + numericUpDown1.Value : "";
|
string version = ((numericUpDown1.Value != 0) && (isWebSite != true)) ? "&version=" + numericUpDown1.Value : "";
|
||||||
|
string fullURL = url + textBox2.Text + version;
|
||||||
|
|
||||||
System.Diagnostics.Process.Start(url + textBox2.Text + version);
|
if (!isWebSite)
|
||||||
|
{
|
||||||
|
Downloader download = new Downloader(fullURL, textBox1.Text, "Roblox Model (*.rbxm)|*.rbxm|Roblox Mesh (*.mesh)|*.mesh|PNG Image (*.png)|*.png|WAV Sound (*.wav)|*.wav", progressBar1);
|
||||||
|
|
||||||
if (!GlobalVars.DisabledHelp)
|
if (!GlobalVars.DisabledHelp)
|
||||||
{
|
{
|
||||||
MessageBox.Show("In order for the item to work in Novetus, you'll need to find an icon for your item (it must be a .png file), then name it the same name as your item.\n\nIf you want to create a local (offline) item, you'll have to download the meshes/textures from the links in the rbxm file, then replace the links in the file pointing to where they are using rbxasset://. Look at the directory in the 'shareddata/charcustom' folder that best suits your item type, then look at the rbxm for any one of the items. If you get a corrupted file, change the URL using the drop down box.\n\nIf you're trying to create a offline item. please use these file extension names when saving your files:\n.rbxm - ROBLOX Model/Item\n.mesh - ROBLOX Mesh\n.png - Texture/Icon\n.wav - Sound","Novetus Item SDK", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
string helptext = "If you're trying to create a offline item, please use these file extension names when saving your files:\n.rbxm - ROBLOX Model/Item\n.mesh - ROBLOX Mesh\n.png - Texture/Icon\n.wav - Sound";
|
||||||
|
MessageBox.Show(helptext, "Novetus Item SDK", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string helptext = "In order for the item to work in Novetus, you'll need to find an icon for your item (it must be a .png file), then name it the same name as your item.\n\nIf you want to create a local (offline) item, you'll have to download the meshes/textures from the links in the rbxm file, then replace the links in the file pointing to where they are using rbxasset://. Look at the directory in the 'shareddata/charcustom' folder that best suits your item type, then look at the rbxm for any one of the items. If you get a corrupted file, change the URL using the drop down box.";
|
||||||
|
download.InitDownload(true, (!GlobalVars.DisabledHelp) ? helptext : "");
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(download.getDownloadOutcome()))
|
||||||
|
{
|
||||||
|
MessageBox.Show(download.getDownloadOutcome(), "Novetus Item SDK", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.Diagnostics.Process.Start(fullURL);
|
||||||
|
|
||||||
|
if (!GlobalVars.DisabledHelp)
|
||||||
|
{
|
||||||
|
string helptext = "In order for the item to work in Novetus, you'll need to find an icon for your item (it must be a .png file), then name it the same name as your item.\n\nIf you want to create a local (offline) item, you'll have to download the meshes/textures from the links in the rbxm file, then replace the links in the file pointing to where they are using rbxasset://. Look at the directory in the 'shareddata/charcustom' folder that best suits your item type, then look at the rbxm for any one of the items. If you get a corrupted file, change the URL using the drop down box.\n\nIf you're trying to create a offline item, please use these file extension names when saving your files:\n.rbxm - ROBLOX Model/Item\n.mesh - ROBLOX Mesh\n.png - Texture/Icon\n.wav - Sound";
|
||||||
|
MessageBox.Show(helptext, "Novetus Item SDK", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception)
|
catch(Exception)
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||||
|
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
|
||||||
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||||
|
<security>
|
||||||
|
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
|
||||||
|
</requestedPrivileges>
|
||||||
|
</security>
|
||||||
|
</trustInfo>
|
||||||
|
</assembly>
|
||||||
Loading…
Reference in New Issue