diff --git a/NovetusLauncher/.vs/NovetusLauncher/v14/.suo b/NovetusLauncher/.vs/NovetusLauncher/v14/.suo index bac4b8d..58074e1 100644 Binary files a/NovetusLauncher/.vs/NovetusLauncher/v14/.suo and b/NovetusLauncher/.vs/NovetusLauncher/v14/.suo differ diff --git a/NovetusLauncher/NovetusFuncs/Downloader.cs b/NovetusLauncher/NovetusFuncs/Downloader.cs index 49e0eb9..bdd9a4e 100644 --- a/NovetusLauncher/NovetusFuncs/Downloader.cs +++ b/NovetusLauncher/NovetusFuncs/Downloader.cs @@ -31,7 +31,7 @@ class Downloader return downloadOutcome; } - public void InitDownload(string additionalText = "") + public void InitDownload(bool gzip, string additionalText = "") { downloadOutcomeAddText = additionalText; @@ -47,7 +47,7 @@ class Downloader { 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; } 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) //and Brokenglass (https://stackoverflow.com/questions/4567313/uncompressing-gzip-response-from-webclient/4567408#4567408) @@ -77,42 +77,17 @@ class Downloader try { // Create a request for the specified remote file name - //WebRequest request = WebRequest.Create(remoteFilename); - var request = (HttpWebRequest)WebRequest.Create(remoteFilename); - request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate"); - request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; - if (request != null) + if (gzip) { - // Send the request to the server and retrieve the - // WebResponse object - response = request.GetResponse(); - if (response != null) - { - // Once the WebResponse object has been retrieved, - // get the stream object associated with the response's data - remoteStream = response.GetResponseStream(); - - // Create the local file - localStream = File.Create(localFilename); - - // Allocate a 1k buffer - byte[] buffer = new byte[1024]; - int bytesRead; - - // Simple do/while loop to read from stream until - // no bytes are returned - do - { - // Read data (up to 1k) from the stream - bytesRead = remoteStream.Read(buffer, 0, buffer.Length); - - // Write the data to the local file - localStream.Write(buffer, 0, bytesRead); - - // Increment total bytes processed - bytesProcessed += bytesRead; - } while (bytesRead > 0); - } + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(remoteFilename); + request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,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) @@ -133,6 +108,43 @@ class Downloader return bytesProcessed; } + private static void processRequest(WebRequest request, WebResponse response, Stream remoteStream, Stream localStream, string localFilename, int bytesProcessed) + { + if (request != null) + { + // Send the request to the server and retrieve the + // WebResponse object + response = request.GetResponse(); + if (response != null) + { + // Once the WebResponse object has been retrieved, + // get the stream object associated with the response's data + remoteStream = response.GetResponseStream(); + + // Create the local file + localStream = File.Create(localFilename); + + // Allocate a 1k buffer + byte[] buffer = new byte[1024]; + int bytesRead; + + // Simple do/while loop to read from stream until + // no bytes are returned + do + { + // Read data (up to 1k) from the stream + bytesRead = remoteStream.Read(buffer, 0, buffer.Length); + + // Write the data to the local file + localStream.Write(buffer, 0, bytesRead); + + // Increment total bytes processed + bytesProcessed += bytesRead; + } while (bytesRead > 0); + } + } + } + void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) { downloadProgress.Value = e.ProgressPercentage; diff --git a/NovetusLauncher/NovetusLauncher/ItemMaker.Designer.cs b/NovetusLauncher/NovetusLauncher/ItemMaker.Designer.cs index 53a6390..ec87d08 100644 --- a/NovetusLauncher/NovetusLauncher/ItemMaker.Designer.cs +++ b/NovetusLauncher/NovetusLauncher/ItemMaker.Designer.cs @@ -36,111 +36,139 @@ namespace NovetusLauncher /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ItemMaker)); - this.button1 = new System.Windows.Forms.Button(); - this.textBox2 = new System.Windows.Forms.TextBox(); - this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.comboBox1 = new System.Windows.Forms.ComboBox(); - this.checkBox1 = new System.Windows.Forms.CheckBox(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); - this.SuspendLayout(); - // - // button1 - // - this.button1.Location = new System.Drawing.Point(3, 80); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(238, 23); - this.button1.TabIndex = 1; - this.button1.Text = "Create!"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.Button1Click); - // - // textBox2 - // - this.textBox2.Location = new System.Drawing.Point(46, 27); - this.textBox2.Name = "textBox2"; - this.textBox2.Size = new System.Drawing.Size(76, 20); - this.textBox2.TabIndex = 2; - // - // numericUpDown1 - // - this.numericUpDown1.Location = new System.Drawing.Point(161, 27); - this.numericUpDown1.Maximum = new decimal(new int[] { - 99, - 0, - 0, - 0}); - this.numericUpDown1.Name = "numericUpDown1"; - this.numericUpDown1.Size = new System.Drawing.Size(36, 20); - this.numericUpDown1.TabIndex = 3; - // - // label2 - // - this.label2.Location = new System.Drawing.Point(63, 10); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(46, 14); - this.label2.TabIndex = 6; - this.label2.Text = "Item ID"; - // - // label3 - // - this.label3.Location = new System.Drawing.Point(161, 9); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(42, 14); - this.label3.TabIndex = 7; - this.label3.Text = "Version"; - this.label3.TextAlign = System.Drawing.ContentAlignment.TopCenter; - // - // comboBox1 - // - this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBox1.FormattingEnabled = true; - this.comboBox1.Items.AddRange(new object[] { - "http://www.roblox.com/", - "http://assetgame.roblox.com/", - "https://www.roblox.com/catalog/", - "https://www.roblox.com/library/"}); - this.comboBox1.Location = new System.Drawing.Point(3, 53); - this.comboBox1.Name = "comboBox1"; - this.comboBox1.Size = new System.Drawing.Size(238, 21); - this.comboBox1.TabIndex = 8; - this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.ComboBox1SelectedIndexChanged); - // - // checkBox1 - // - this.checkBox1.Location = new System.Drawing.Point(18, 109); - this.checkBox1.Name = "checkBox1"; - this.checkBox1.Size = new System.Drawing.Size(214, 24); - this.checkBox1.TabIndex = 9; - this.checkBox1.Text = "Disable Help Message on Item Creation"; - this.checkBox1.UseVisualStyleBackColor = true; - this.checkBox1.CheckedChanged += new System.EventHandler(this.CheckBox1CheckedChanged); - // - // ItemMaker - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.SystemColors.ControlLightLight; - this.ClientSize = new System.Drawing.Size(244, 139); - this.Controls.Add(this.checkBox1); - this.Controls.Add(this.comboBox1); - this.Controls.Add(this.label3); - this.Controls.Add(this.label2); - this.Controls.Add(this.numericUpDown1); - this.Controls.Add(this.textBox2); - this.Controls.Add(this.button1); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.Name = "ItemMaker"; - this.Text = "Novetus Item SDK"; - this.Closing += new System.ComponentModel.CancelEventHandler(this.ItemMakerClose); - this.Load += new System.EventHandler(this.ItemMakerLoad); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ItemMaker)); + this.button1 = new System.Windows.Forms.Button(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + 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(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(3, 80); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(238, 23); + this.button1.TabIndex = 1; + this.button1.Text = "Create!"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.Button1Click); + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(98, 25); + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(76, 20); + this.textBox2.TabIndex = 2; + // + // numericUpDown1 + // + this.numericUpDown1.Location = new System.Drawing.Point(193, 25); + this.numericUpDown1.Maximum = new decimal(new int[] { + 99, + 0, + 0, + 0}); + this.numericUpDown1.Name = "numericUpDown1"; + this.numericUpDown1.Size = new System.Drawing.Size(36, 20); + this.numericUpDown1.TabIndex = 3; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(116, 9); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(41, 14); + this.label2.TabIndex = 6; + this.label2.Text = "Item ID"; + // + // label3 + // + this.label3.Location = new System.Drawing.Point(190, 9); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(42, 14); + this.label3.TabIndex = 7; + this.label3.Text = "Version"; + this.label3.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // + // comboBox1 + // + this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Items.AddRange(new object[] { + "http://www.roblox.com/", + "http://assetgame.roblox.com/", + "https://www.roblox.com/catalog/", + "https://www.roblox.com/library/"}); + this.comboBox1.Location = new System.Drawing.Point(3, 53); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(238, 21); + this.comboBox1.TabIndex = 8; + this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.ComboBox1SelectedIndexChanged); + // + // checkBox1 + // + this.checkBox1.Location = new System.Drawing.Point(12, 126); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(220, 24); + this.checkBox1.TabIndex = 9; + this.checkBox1.Text = "Disable Help Message on Item Creation"; + this.checkBox1.UseVisualStyleBackColor = true; + 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 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.SystemColors.ControlLightLight; + 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.comboBox1); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.numericUpDown1); + this.Controls.Add(this.textBox2); + this.Controls.Add(this.button1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.Name = "ItemMaker"; + this.Text = "Novetus Item SDK"; + this.Closing += new System.ComponentModel.CancelEventHandler(this.ItemMakerClose); + this.Load += new System.EventHandler(this.ItemMakerLoad); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); } private System.Windows.Forms.ComboBox comboBox1; @@ -150,5 +178,8 @@ namespace NovetusLauncher private System.Windows.Forms.TextBox textBox2; private System.Windows.Forms.Button button1; private System.Windows.Forms.CheckBox checkBox1; - } + private System.Windows.Forms.ProgressBar progressBar1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox textBox1; + } } diff --git a/NovetusLauncher/NovetusLauncher/ItemMaker.cs b/NovetusLauncher/NovetusLauncher/ItemMaker.cs index 34f4cc7..059289d 100644 --- a/NovetusLauncher/NovetusLauncher/ItemMaker.cs +++ b/NovetusLauncher/NovetusLauncher/ItemMaker.cs @@ -38,14 +38,44 @@ namespace NovetusLauncher try { string version = ((numericUpDown1.Value != 0) && (isWebSite != true)) ? "&version=" + numericUpDown1.Value : ""; - - System.Diagnostics.Process.Start(url + textBox2.Text + version); - - 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 fullURL = 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) + { + 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) { MessageBox.Show("Error: Unable to download the file. Try using a different file name or ID.","Novetus Item SDK | Error", MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/NovetusTest_FileDownloader/.vs/NovetusTest_FileDownloader/v14/.suo b/NovetusTest_FileDownloader/.vs/NovetusTest_FileDownloader/v14/.suo index ae37a1a..d38f37a 100644 Binary files a/NovetusTest_FileDownloader/.vs/NovetusTest_FileDownloader/v14/.suo and b/NovetusTest_FileDownloader/.vs/NovetusTest_FileDownloader/v14/.suo differ diff --git a/NovetusTest_FileDownloader/NovetusTest_FileDownloader/bin/Debug/NovetusTest_FileDownloader.vshost.exe.manifest b/NovetusTest_FileDownloader/NovetusTest_FileDownloader/bin/Debug/NovetusTest_FileDownloader.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/NovetusTest_FileDownloader/NovetusTest_FileDownloader/bin/Debug/NovetusTest_FileDownloader.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/NovetusTest_FileDownloader/NovetusTest_FileDownloader/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/NovetusTest_FileDownloader/NovetusTest_FileDownloader/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/NovetusTest_FileDownloader/NovetusTest_FileDownloader/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs b/NovetusTest_FileDownloader/NovetusTest_FileDownloader/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs new file mode 100644 index 0000000..e69de29 diff --git a/NovetusTest_FileDownloader/NovetusTest_FileDownloader/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/NovetusTest_FileDownloader/NovetusTest_FileDownloader/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29