Added the ability to add a name to files downloaded via the Asset Localizer (items only)

This commit is contained in:
Bitl 2020-01-01 16:37:34 -07:00
parent 56d241b741
commit ce624287ca
3 changed files with 59 additions and 21 deletions

View File

@ -25,17 +25,17 @@ public static class RobloxXMLLocalizer
Pants
}
public static void DownloadFromNodes(string filepath, AssetCacheDef assetdef)
public static void DownloadFromNodes(string filepath, AssetCacheDef assetdef, string name = "")
{
DownloadFromNodes(filepath, assetdef.Class, assetdef.Id[0], assetdef.Ext[0], assetdef.Dir[0], assetdef.GameDir[0]);
DownloadFromNodes(filepath, assetdef.Class, assetdef.Id[0], assetdef.Ext[0], assetdef.Dir[0], assetdef.GameDir[0], name);
}
public static void DownloadFromNodes(string filepath, AssetCacheDef assetdef, int idIndex, int extIndex, int outputPathIndex, int inGameDirIndex)
public static void DownloadFromNodes(string filepath, AssetCacheDef assetdef, int idIndex, int extIndex, int outputPathIndex, int inGameDirIndex, string name = "")
{
DownloadFromNodes(filepath, assetdef.Class, assetdef.Id[idIndex], assetdef.Ext[extIndex], assetdef.Dir[outputPathIndex], assetdef.GameDir[inGameDirIndex]);
DownloadFromNodes(filepath, assetdef.Class, assetdef.Id[idIndex], assetdef.Ext[extIndex], assetdef.Dir[outputPathIndex], assetdef.GameDir[inGameDirIndex], name);
}
public static void DownloadFromNodes(string filepath, string itemClassValue, string itemIdValue, string fileext, string outputPath, string inGameDir)
public static void DownloadFromNodes(string filepath, string itemClassValue, string itemIdValue, string fileext, string outputPath, string inGameDir, string name = "")
{
string oldfile = File.ReadAllText(filepath);
string fixedfile = RemoveInvalidXmlChars(ReplaceHexadecimalSymbols(oldfile));
@ -68,11 +68,19 @@ public static class RobloxXMLLocalizer
//MessageBox.Show(urlFixed, "Novetus Asset Localizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
string peram = "id=";
if (urlFixed.Contains(peram))
if (string.IsNullOrWhiteSpace(name))
{
string IDVal = urlFixed.After(peram);
DownloadFilesFromNode(urlFixed, outputPath, fileext, IDVal);
item3.Value = inGameDir + IDVal + fileext;
if (urlFixed.Contains(peram))
{
string IDVal = urlFixed.After(peram);
DownloadFilesFromNode(urlFixed, outputPath, fileext, IDVal);
item3.Value = inGameDir + IDVal + fileext;
}
}
else
{
DownloadFilesFromNode(urlFixed, outputPath, fileext, name);
item3.Value = inGameDir + name + fileext;
}
}
}

View File

@ -33,11 +33,13 @@
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(12, 39);
this.button1.Location = new System.Drawing.Point(12, 65);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(240, 21);
this.button1.TabIndex = 0;
@ -66,7 +68,7 @@
//
// label2
//
this.label2.Location = new System.Drawing.Point(12, 67);
this.label2.Location = new System.Drawing.Point(12, 96);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(240, 13);
this.label2.TabIndex = 3;
@ -81,12 +83,31 @@
this.backgroundWorker1.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker1_ProgressChanged);
this.backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(140, 39);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(112, 20);
this.textBox1.TabIndex = 4;
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 42);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(125, 13);
this.label1.TabIndex = 5;
this.label1.Text = "Asset Name (Items Only):";
//
// AssetLocalizer
//
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(264, 89);
this.ClientSize = new System.Drawing.Size(264, 118);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.button1);
@ -95,9 +116,10 @@
this.MaximizeBox = false;
this.Name = "AssetLocalizer";
this.Text = "Novetus Asset Localizer";
this.Load += new System.EventHandler(this.AssetLocalizer_Load);
this.Closing += new System.ComponentModel.CancelEventHandler(this.AssetLocalizer_Close);
this.Load += new System.EventHandler(this.AssetLocalizer_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
@ -107,5 +129,7 @@
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label2;
private System.ComponentModel.BackgroundWorker backgroundWorker1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
}
}

View File

@ -15,6 +15,7 @@ namespace NovetusLauncher
{
private RobloxXMLLocalizer.DLType currentType;
private string path;
private string name;
public AssetLocalizer()
{
@ -378,8 +379,8 @@ namespace NovetusLauncher
case RobloxXMLLocalizer.DLType.Hat:
//meshes
worker.ReportProgress(0);
RobloxXMLLocalizer.DownloadFromNodes(path, GlobalVars.ItemHatFonts);
RobloxXMLLocalizer.DownloadFromNodes(path, GlobalVars.ItemHatFonts, 1, 1, 1, 1);
RobloxXMLLocalizer.DownloadFromNodes(path, GlobalVars.ItemHatFonts, name);
RobloxXMLLocalizer.DownloadFromNodes(path, GlobalVars.ItemHatFonts, 1, 1, 1, 1, name);
worker.ReportProgress(25);
RobloxXMLLocalizer.DownloadFromNodes(path, GlobalVars.ItemHatSound);
//scripts
@ -392,32 +393,32 @@ namespace NovetusLauncher
case RobloxXMLLocalizer.DLType.Head:
//meshes
worker.ReportProgress(0);
RobloxXMLLocalizer.DownloadFromNodes(path, GlobalVars.ItemHeadFonts);
RobloxXMLLocalizer.DownloadFromNodes(path, GlobalVars.ItemHeadFonts, 1, 1, 1, 1);
RobloxXMLLocalizer.DownloadFromNodes(path, GlobalVars.ItemHeadFonts, name);
RobloxXMLLocalizer.DownloadFromNodes(path, GlobalVars.ItemHeadFonts, 1, 1, 1, 1, name);
worker.ReportProgress(100);
break;
case RobloxXMLLocalizer.DLType.Face:
//decal
worker.ReportProgress(0);
RobloxXMLLocalizer.DownloadFromNodes(path, GlobalVars.ItemFaceTexture);
RobloxXMLLocalizer.DownloadFromNodes(path, GlobalVars.ItemFaceTexture, name);
worker.ReportProgress(100);
break;
case RobloxXMLLocalizer.DLType.TShirt:
//texture
worker.ReportProgress(0);
RobloxXMLLocalizer.DownloadFromNodes(path, GlobalVars.ItemTShirtTexture);
RobloxXMLLocalizer.DownloadFromNodes(path, GlobalVars.ItemTShirtTexture, name);
worker.ReportProgress(100);
break;
case RobloxXMLLocalizer.DLType.Shirt:
//texture
worker.ReportProgress(0);
RobloxXMLLocalizer.DownloadFromNodes(path, GlobalVars.ItemShirtTexture);
RobloxXMLLocalizer.DownloadFromNodes(path, GlobalVars.ItemShirtTexture, name);
worker.ReportProgress(100);
break;
case RobloxXMLLocalizer.DLType.Pants:
//texture
worker.ReportProgress(0);
RobloxXMLLocalizer.DownloadFromNodes(path, GlobalVars.ItemPantsTexture);
RobloxXMLLocalizer.DownloadFromNodes(path, GlobalVars.ItemPantsTexture, name);
worker.ReportProgress(100);
break;
default:
@ -457,5 +458,10 @@ namespace NovetusLauncher
{
backgroundWorker1.CancelAsync();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
name = textBox1.Text;
}
}
}