Add Skin Support
This commit is contained in:
parent
68d7dc9608
commit
6397b65de0
Binary file not shown.
|
@ -42,15 +42,22 @@ namespace SignToolsGUI
|
|||
this.SignType = new System.Windows.Forms.Label();
|
||||
this.name = new System.Windows.Forms.Label();
|
||||
this.RemoveImage = new System.Windows.Forms.Button();
|
||||
this.RemoveSkin = new System.Windows.Forms.Button();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.SkinLocations = new System.Windows.Forms.ComboBox();
|
||||
this.AddSkin = new System.Windows.Forms.Button();
|
||||
this.Import = new System.Windows.Forms.Button();
|
||||
this.Export = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.ImagePreview)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ImagePreview
|
||||
//
|
||||
this.ImagePreview.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.ImagePreview.Location = new System.Drawing.Point(15, 92);
|
||||
this.ImagePreview.Location = new System.Drawing.Point(30, 177);
|
||||
this.ImagePreview.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.ImagePreview.Name = "ImagePreview";
|
||||
this.ImagePreview.Size = new System.Drawing.Size(620, 265);
|
||||
this.ImagePreview.Size = new System.Drawing.Size(1238, 508);
|
||||
this.ImagePreview.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
this.ImagePreview.TabIndex = 0;
|
||||
this.ImagePreview.TabStop = false;
|
||||
|
@ -58,9 +65,10 @@ namespace SignToolsGUI
|
|||
// AddImage
|
||||
//
|
||||
this.AddImage.Enabled = false;
|
||||
this.AddImage.Location = new System.Drawing.Point(337, 44);
|
||||
this.AddImage.Location = new System.Drawing.Point(674, 85);
|
||||
this.AddImage.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.AddImage.Name = "AddImage";
|
||||
this.AddImage.Size = new System.Drawing.Size(100, 25);
|
||||
this.AddImage.Size = new System.Drawing.Size(200, 48);
|
||||
this.AddImage.TabIndex = 1;
|
||||
this.AddImage.Text = "Add Image";
|
||||
this.AddImage.UseVisualStyleBackColor = true;
|
||||
|
@ -68,9 +76,10 @@ namespace SignToolsGUI
|
|||
//
|
||||
// OpenMap
|
||||
//
|
||||
this.OpenMap.Location = new System.Drawing.Point(12, 44);
|
||||
this.OpenMap.Location = new System.Drawing.Point(24, 85);
|
||||
this.OpenMap.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.OpenMap.Name = "OpenMap";
|
||||
this.OpenMap.Size = new System.Drawing.Size(100, 25);
|
||||
this.OpenMap.Size = new System.Drawing.Size(200, 48);
|
||||
this.OpenMap.TabIndex = 2;
|
||||
this.OpenMap.Text = "Open Map";
|
||||
this.OpenMap.UseVisualStyleBackColor = true;
|
||||
|
@ -79,17 +88,19 @@ namespace SignToolsGUI
|
|||
// mapdir
|
||||
//
|
||||
this.mapdir.Enabled = false;
|
||||
this.mapdir.Location = new System.Drawing.Point(12, 19);
|
||||
this.mapdir.Location = new System.Drawing.Point(24, 37);
|
||||
this.mapdir.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.mapdir.Name = "mapdir";
|
||||
this.mapdir.Size = new System.Drawing.Size(298, 20);
|
||||
this.mapdir.Size = new System.Drawing.Size(592, 31);
|
||||
this.mapdir.TabIndex = 3;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(9, 3);
|
||||
this.label1.Location = new System.Drawing.Point(18, 6);
|
||||
this.label1.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(31, 13);
|
||||
this.label1.Size = new System.Drawing.Size(60, 25);
|
||||
this.label1.TabIndex = 4;
|
||||
this.label1.Text = "Map:";
|
||||
//
|
||||
|
@ -98,18 +109,20 @@ namespace SignToolsGUI
|
|||
this.Locations.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.Locations.Enabled = false;
|
||||
this.Locations.FormattingEnabled = true;
|
||||
this.Locations.Location = new System.Drawing.Point(337, 19);
|
||||
this.Locations.Location = new System.Drawing.Point(674, 37);
|
||||
this.Locations.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.Locations.Name = "Locations";
|
||||
this.Locations.Size = new System.Drawing.Size(206, 21);
|
||||
this.Locations.Size = new System.Drawing.Size(408, 33);
|
||||
this.Locations.TabIndex = 5;
|
||||
this.Locations.SelectedIndexChanged += new System.EventHandler(this.Selection);
|
||||
//
|
||||
// SaveMap
|
||||
//
|
||||
this.SaveMap.Enabled = false;
|
||||
this.SaveMap.Location = new System.Drawing.Point(118, 44);
|
||||
this.SaveMap.Location = new System.Drawing.Point(236, 85);
|
||||
this.SaveMap.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.SaveMap.Name = "SaveMap";
|
||||
this.SaveMap.Size = new System.Drawing.Size(100, 25);
|
||||
this.SaveMap.Size = new System.Drawing.Size(200, 48);
|
||||
this.SaveMap.TabIndex = 7;
|
||||
this.SaveMap.Text = "Save Map";
|
||||
this.SaveMap.UseVisualStyleBackColor = true;
|
||||
|
@ -118,54 +131,129 @@ namespace SignToolsGUI
|
|||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(334, 3);
|
||||
this.label2.Location = new System.Drawing.Point(668, 6);
|
||||
this.label2.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(52, 13);
|
||||
this.label2.Size = new System.Drawing.Size(155, 25);
|
||||
this.label2.TabIndex = 8;
|
||||
this.label2.Text = "Positions:";
|
||||
this.label2.Text = "Sign Positions:";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(12, 76);
|
||||
this.label3.Location = new System.Drawing.Point(24, 146);
|
||||
this.label3.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(31, 13);
|
||||
this.label3.Size = new System.Drawing.Size(58, 25);
|
||||
this.label3.TabIndex = 9;
|
||||
this.label3.Text = "Sign:";
|
||||
this.label3.Text = "Item:";
|
||||
//
|
||||
// SignType
|
||||
//
|
||||
this.SignType.AutoSize = true;
|
||||
this.SignType.Location = new System.Drawing.Point(58, 76);
|
||||
this.SignType.Location = new System.Drawing.Point(116, 146);
|
||||
this.SignType.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.SignType.Name = "SignType";
|
||||
this.SignType.Size = new System.Drawing.Size(0, 13);
|
||||
this.SignType.Size = new System.Drawing.Size(0, 25);
|
||||
this.SignType.TabIndex = 10;
|
||||
this.SignType.Visible = false;
|
||||
//
|
||||
// name
|
||||
//
|
||||
this.name.AutoSize = true;
|
||||
this.name.Location = new System.Drawing.Point(46, 76);
|
||||
this.name.Location = new System.Drawing.Point(92, 146);
|
||||
this.name.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.name.Name = "name";
|
||||
this.name.Size = new System.Drawing.Size(0, 13);
|
||||
this.name.Size = new System.Drawing.Size(0, 25);
|
||||
this.name.TabIndex = 11;
|
||||
//
|
||||
// RemoveImage
|
||||
//
|
||||
this.RemoveImage.Enabled = false;
|
||||
this.RemoveImage.Location = new System.Drawing.Point(443, 44);
|
||||
this.RemoveImage.Location = new System.Drawing.Point(886, 85);
|
||||
this.RemoveImage.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.RemoveImage.Name = "RemoveImage";
|
||||
this.RemoveImage.Size = new System.Drawing.Size(100, 25);
|
||||
this.RemoveImage.Size = new System.Drawing.Size(200, 48);
|
||||
this.RemoveImage.TabIndex = 12;
|
||||
this.RemoveImage.Text = "Remove Image";
|
||||
this.RemoveImage.UseVisualStyleBackColor = true;
|
||||
this.RemoveImage.Click += new System.EventHandler(this.RemoveImage_Click);
|
||||
//
|
||||
// RemoveSkin
|
||||
//
|
||||
this.RemoveSkin.Enabled = false;
|
||||
this.RemoveSkin.Location = new System.Drawing.Point(1368, 85);
|
||||
this.RemoveSkin.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.RemoveSkin.Name = "RemoveSkin";
|
||||
this.RemoveSkin.Size = new System.Drawing.Size(200, 48);
|
||||
this.RemoveSkin.TabIndex = 16;
|
||||
this.RemoveSkin.Text = "Remove Skin";
|
||||
this.RemoveSkin.UseVisualStyleBackColor = true;
|
||||
this.RemoveSkin.Click += new System.EventHandler(this.RemoveSkin_Click);
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(1150, 6);
|
||||
this.label4.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(154, 25);
|
||||
this.label4.TabIndex = 15;
|
||||
this.label4.Text = "Skin Positions:";
|
||||
//
|
||||
// SkinLocations
|
||||
//
|
||||
this.SkinLocations.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.SkinLocations.Enabled = false;
|
||||
this.SkinLocations.FormattingEnabled = true;
|
||||
this.SkinLocations.Location = new System.Drawing.Point(1156, 37);
|
||||
this.SkinLocations.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.SkinLocations.Name = "SkinLocations";
|
||||
this.SkinLocations.Size = new System.Drawing.Size(408, 33);
|
||||
this.SkinLocations.TabIndex = 14;
|
||||
this.SkinLocations.SelectedIndexChanged += new System.EventHandler(this.Selection2);
|
||||
//
|
||||
// AddSkin
|
||||
//
|
||||
this.AddSkin.Enabled = false;
|
||||
this.AddSkin.Location = new System.Drawing.Point(1156, 85);
|
||||
this.AddSkin.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.AddSkin.Name = "AddSkin";
|
||||
this.AddSkin.Size = new System.Drawing.Size(200, 48);
|
||||
this.AddSkin.TabIndex = 13;
|
||||
this.AddSkin.Text = "Add Skin";
|
||||
this.AddSkin.UseVisualStyleBackColor = true;
|
||||
this.AddSkin.Click += new System.EventHandler(this.AddSkin_Click);
|
||||
//
|
||||
// Import
|
||||
//
|
||||
this.Import.Location = new System.Drawing.Point(1600, 6);
|
||||
this.Import.Name = "Import";
|
||||
this.Import.Size = new System.Drawing.Size(245, 64);
|
||||
this.Import.TabIndex = 17;
|
||||
this.Import.Text = "Import Settings";
|
||||
this.Import.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// Export
|
||||
//
|
||||
this.Export.Location = new System.Drawing.Point(1600, 76);
|
||||
this.Export.Name = "Export";
|
||||
this.Export.Size = new System.Drawing.Size(245, 57);
|
||||
this.Export.TabIndex = 18;
|
||||
this.Export.Text = "Export Settings";
|
||||
this.Export.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1056, 641);
|
||||
this.ClientSize = new System.Drawing.Size(2112, 1233);
|
||||
this.Controls.Add(this.Export);
|
||||
this.Controls.Add(this.Import);
|
||||
this.Controls.Add(this.RemoveSkin);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.SkinLocations);
|
||||
this.Controls.Add(this.AddSkin);
|
||||
this.Controls.Add(this.RemoveImage);
|
||||
this.Controls.Add(this.name);
|
||||
this.Controls.Add(this.SignType);
|
||||
|
@ -179,10 +267,11 @@ namespace SignToolsGUI
|
|||
this.Controls.Add(this.AddImage);
|
||||
this.Controls.Add(this.ImagePreview);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "Form1";
|
||||
this.Text = "SignToolsGUI 002";
|
||||
this.Text = "SignToolsGUI 003";
|
||||
((System.ComponentModel.ISupportInitialize)(this.ImagePreview)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
@ -203,6 +292,12 @@ namespace SignToolsGUI
|
|||
private System.Windows.Forms.Label SignType;
|
||||
private System.Windows.Forms.Label name;
|
||||
private System.Windows.Forms.Button RemoveImage;
|
||||
private System.Windows.Forms.Button RemoveSkin;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.ComboBox SkinLocations;
|
||||
private System.Windows.Forms.Button AddSkin;
|
||||
private System.Windows.Forms.Button Import;
|
||||
private System.Windows.Forms.Button Export;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
320
Form1.cs
320
Form1.cs
|
@ -6,8 +6,10 @@ using System.Drawing;
|
|||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace SignToolsGUI
|
||||
{
|
||||
|
@ -17,7 +19,10 @@ namespace SignToolsGUI
|
|||
uint Version;
|
||||
Dictionary<string, byte[]> SerializedImageData = new Dictionary<string, byte[]>();
|
||||
Dictionary<string, byte[]> ModdedSerializedImageData = new Dictionary<string, byte[]>();
|
||||
Dictionary<string, uint> SerializedSkinData = new Dictionary<string, uint>();
|
||||
Dictionary<string, uint> ModdedSerializedSkinData = new Dictionary<string, uint>();
|
||||
uint[] signids = { 1447270506, 4057957010, 120534793, 58270319, 4290170446, 3188315846, 3215377795, 1960724311, 3159642196, 3725754530, 1957158128, 637495597, 1283107100, 4006597758, 3715545584, 3479792512, 3618197174, 550204242 };
|
||||
uint[] skinnableids = { 1844023509, 177343599, 3994459244, 4196580066, 3110378351, 2206646561, 2931042549, 159326486, 2245774897, 1560881570, 3647679950, 170207918, 202293038, 1343928398, 43442943, 201071098, 1418678061, 2662124780 };
|
||||
private Dictionary<string, SignSize> _signSizes = new Dictionary<string, SignSize>
|
||||
{
|
||||
{"4006597758", new SignSize(512, 512)},
|
||||
|
@ -59,6 +64,25 @@ namespace SignToolsGUI
|
|||
{"4057957010", "sign.post.town.roof"},
|
||||
{"550204242", "sign.hanging"},
|
||||
{"1283107100", "sign.hanging.ornate"},
|
||||
{"1844023509", "Fridge" },
|
||||
{"177343599", "Lockers" },
|
||||
{"3994459244", "Reactive.Target" },
|
||||
{"4196580066", "Rug" },
|
||||
{"3110378351", "Rug.Bear" },
|
||||
{"2206646561", "Box.Large" },
|
||||
{"2931042549","Furnace" },
|
||||
{"159326486", "Sleeping.Bag" },
|
||||
{"2245774897","VendingMachine" },
|
||||
{"1560881570","Box.Small" },
|
||||
{"3647679950","GarageDoor" },
|
||||
{"170207918","ArmourDoor" },
|
||||
{"202293038","MetalDoor" },
|
||||
{"1343928398","WoodDoor" },
|
||||
{"43442943","Double.WoodDoor" },
|
||||
{"201071098","Double.ArmourDoor" },
|
||||
{"1418678061","Double.MetalDoor" },
|
||||
{"2662124780","Table" }
|
||||
|
||||
};
|
||||
private class SignSize
|
||||
{
|
||||
|
@ -97,7 +121,20 @@ namespace SignToolsGUI
|
|||
string z = xmldata.Split(new string[] { "</z></position>" }, StringSplitOptions.None)[0].Replace("<x>" + x + "</x><y>" + y + "</y><z>", "");
|
||||
string texture = xmldata.Split(new string[] { "<texture>" }, StringSplitOptions.None)[1].Replace("</texture>", "").Replace("</SerializedImageData>", "");
|
||||
byte[] ImageData = Convert.FromBase64String(texture);
|
||||
SerializedImageData.Add("("+ x+", "+y + ", "+z+")", ImageData);
|
||||
SerializedImageData.Add("(" + x + ", " + y + ", " + z + ")", ImageData);
|
||||
}
|
||||
}
|
||||
void XMLDecodeSkin(string SerialData)
|
||||
{
|
||||
string[] DataParse = SerialData.Split(new string[] { "<position>" }, StringSplitOptions.None);
|
||||
foreach (string xmldata in DataParse)
|
||||
{
|
||||
if (xmldata.Contains("xml version")) continue;
|
||||
string x = xmldata.Split(new string[] { "</x><y>" }, StringSplitOptions.None)[0].Replace("<x>", "");
|
||||
string y = xmldata.Split(new string[] { "</y><z>" }, StringSplitOptions.None)[0].Replace("<x>" + x + "</x><y>", "");
|
||||
string z = xmldata.Split(new string[] { "</z></position>" }, StringSplitOptions.None)[0].Replace("<x>" + x + "</x><y>" + y + "</y><z>", "");
|
||||
uint skinid = uint.Parse(xmldata.Split(new string[] { "<skin>" }, StringSplitOptions.None)[1].Replace("</skin>", "").Replace("</SerializedSkinData>", ""));
|
||||
SerializedSkinData.Add("(" + x + ", " + y + ", " + z + ")", skinid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,6 +162,27 @@ namespace SignToolsGUI
|
|||
XMLData = XMLData + SerialData + "</SerializedImageData>";
|
||||
return XMLData;
|
||||
}
|
||||
string XMLEncodeSkin()
|
||||
{
|
||||
string XMLData = @"<? xml version=""1.0""?><SerializedSkinData>";
|
||||
string SerialData = "";
|
||||
foreach (KeyValuePair<string, uint> _skin in ModdedSerializedSkinData)
|
||||
{
|
||||
string[] xmlbreakdown = _skin.Key.Replace("(", "").Replace(" ", "").Replace(")", "").Split(',');
|
||||
|
||||
|
||||
SerialData += ("<position>" +
|
||||
"<x>" + xmlbreakdown[0] + "</x>" +
|
||||
"<y>" + xmlbreakdown[1] + "</y>" +
|
||||
"<z>" + xmlbreakdown[2] + "</z>" +
|
||||
"</position>" +
|
||||
"<skin>" +
|
||||
_skin.Value +
|
||||
"</skin>");
|
||||
}
|
||||
XMLData = XMLData + SerialData + "</SerializedSkinData>";
|
||||
return XMLData;
|
||||
}
|
||||
|
||||
private void DisableButtons()
|
||||
{
|
||||
|
@ -140,7 +198,12 @@ namespace SignToolsGUI
|
|||
return (signids.Contains(sign.id));
|
||||
}
|
||||
|
||||
|
||||
private bool isSkinnable(PrefabData entity)
|
||||
{
|
||||
//Checks prefab has a valid skinnable id
|
||||
return (skinnableids.Contains(entity.id));
|
||||
}
|
||||
|
||||
byte[] ImageResize(byte[] imageBytes, int width, int height)
|
||||
{
|
||||
//Resize image to sign size.
|
||||
|
@ -159,7 +222,10 @@ namespace SignToolsGUI
|
|||
Locations.Items.Clear();
|
||||
SerializedImageData.Clear();
|
||||
ModdedSerializedImageData.Clear();
|
||||
|
||||
SkinLocations.Items.Clear();
|
||||
SerializedSkinData.Clear();
|
||||
ModdedSerializedSkinData.Clear();
|
||||
|
||||
OpenFileDialog openFileDialog1 = new OpenFileDialog
|
||||
{
|
||||
Title = "Rust Map File",
|
||||
|
@ -185,41 +251,66 @@ namespace SignToolsGUI
|
|||
worldSerialization.Load(mapdir.Text);
|
||||
Version = worldSerialization.Version;
|
||||
|
||||
//Check for exsisting
|
||||
for (int i = worldSerialization.world.maps.Count - 1; i >= 0; i--)
|
||||
{
|
||||
MapData mapdata = worldSerialization.world.maps[i];
|
||||
if (mapdata.name == Base64Encode("SerializedImageData"))
|
||||
//Check for exsisting
|
||||
for (int i = worldSerialization.world.maps.Count - 1; i >= 0; i--)
|
||||
{
|
||||
XMLDecode(System.Text.Encoding.ASCII.GetString(mapdata.data));
|
||||
}
|
||||
}
|
||||
|
||||
//Scan all prefab in map file.
|
||||
for (int i = worldSerialization.world.prefabs.Count - 1; i >= 0; i--)
|
||||
{
|
||||
PrefabData prefabdata = worldSerialization.world.prefabs[i];
|
||||
if (isSign(prefabdata))
|
||||
{
|
||||
string location = "(" + prefabdata.position.x.ToString("0.0") + ", " + prefabdata.position.y.ToString("0.0") + ", " + prefabdata.position.z.ToString("0.0") + ")";
|
||||
Locations.Items.Add(location + " " + prefabdata.id.ToString());
|
||||
|
||||
if(SerializedImageData.ContainsKey(location))
|
||||
MapData mapdata = worldSerialization.world.maps[i];
|
||||
if (mapdata.name == Base64Encode("SerializedImageData"))
|
||||
{
|
||||
ModdedSerializedImageData.Add(location, SerializedImageData[location]);
|
||||
XMLDecode(System.Text.Encoding.ASCII.GetString(mapdata.data));
|
||||
}
|
||||
else
|
||||
else if (mapdata.name == Base64Encode("SerializedSkinData"))
|
||||
{
|
||||
ModdedSerializedImageData.Add(location, new byte[0]);
|
||||
XMLDecodeSkin(System.Text.Encoding.ASCII.GetString(mapdata.data));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Locations.Items.Count == 0)
|
||||
{
|
||||
MessageBox.Show("No Signs are on this map");
|
||||
return;
|
||||
}
|
||||
Locations.Text = Locations.Items[0].ToString();
|
||||
|
||||
//Scan all prefab in map file.
|
||||
for (int i = worldSerialization.world.prefabs.Count - 1; i >= 0; i--)
|
||||
{
|
||||
PrefabData prefabdata = worldSerialization.world.prefabs[i];
|
||||
if (isSign(prefabdata))
|
||||
{
|
||||
string location = "(" + prefabdata.position.x.ToString("0.0") + ", " + prefabdata.position.y.ToString("0.0") + ", " + prefabdata.position.z.ToString("0.0") + ")";
|
||||
Locations.Items.Add(location + " " + prefabdata.id.ToString());
|
||||
|
||||
if (SerializedImageData.ContainsKey(location))
|
||||
{
|
||||
ModdedSerializedImageData.Add(location, SerializedImageData[location]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ModdedSerializedImageData.Add(location, new byte[0]);
|
||||
}
|
||||
}
|
||||
else if (isSkinnable(prefabdata))
|
||||
{
|
||||
string location = "(" + prefabdata.position.x.ToString("0.0") + ", " + prefabdata.position.y.ToString("0.0") + ", " + prefabdata.position.z.ToString("0.0") + ")";
|
||||
SkinLocations.Items.Add(location + " " + prefabdata.id.ToString());
|
||||
if (SerializedSkinData.ContainsKey(location))
|
||||
{
|
||||
ModdedSerializedSkinData.Add(location, SerializedSkinData[location]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ModdedSerializedSkinData.Add(location, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Locations.Items.Count != 0)
|
||||
{
|
||||
Locations.Text = Locations.Items[0].ToString();
|
||||
}
|
||||
else if (SkinLocations.Items.Count != 0)
|
||||
{
|
||||
Locations.Text = SkinLocations.Items[0].ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("No signs or skinnable items are on this map");
|
||||
return;
|
||||
}
|
||||
|
||||
SaveMap.Enabled = true;
|
||||
Locations.Enabled = true;
|
||||
|
@ -227,6 +318,9 @@ namespace SignToolsGUI
|
|||
ImagePreview.Enabled = true;
|
||||
SignType.Enabled = true;
|
||||
RemoveImage.Enabled = true;
|
||||
SkinLocations.Enabled = true;
|
||||
AddSkin.Enabled = true;
|
||||
RemoveSkin.Enabled = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -243,7 +337,7 @@ namespace SignToolsGUI
|
|||
name.Text = _Names[SignType.Text];
|
||||
Size size = new Size(_signSizes[SignType.Text].Width, _signSizes[SignType.Text].Height);
|
||||
ImagePreview.Size = size;
|
||||
if (ModdedSerializedImageData.ContainsKey(selected[0]+")"))
|
||||
if (ModdedSerializedImageData.ContainsKey(selected[0] + ")"))
|
||||
{
|
||||
if (ModdedSerializedImageData[selected[0] + ")"].Length != 0)
|
||||
{
|
||||
|
@ -255,6 +349,72 @@ namespace SignToolsGUI
|
|||
}
|
||||
}
|
||||
}
|
||||
private void Selection2(object sender, EventArgs e)
|
||||
{
|
||||
string[] selected = SkinLocations.GetItemText(SkinLocations.SelectedItem).Split(')');
|
||||
SignType.Text = selected[1].Replace(" ", "");
|
||||
name.Text = _Names[SignType.Text];
|
||||
Size size = new Size(1024, 512);
|
||||
ImagePreview.Size = size;
|
||||
try
|
||||
{
|
||||
if (ModdedSerializedSkinData[selected[0] + ")"] != 0)
|
||||
{
|
||||
if (ModdedSerializedSkinData.ContainsKey(selected[0] + ")"))
|
||||
{
|
||||
ImagePreview.Image = GetThumbNail(ModdedSerializedSkinData[selected[0] + ")"]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
ImagePreview.Image = null;
|
||||
}
|
||||
|
||||
private Bitmap GetThumbNail(uint skinid)
|
||||
{
|
||||
try
|
||||
{
|
||||
WebClient wc = new WebClient();
|
||||
string html = wc.DownloadString("https://steamcommunity.com/sharedfiles/filedetails/?id=" + skinid);
|
||||
string[] thumbnailparse = html.Split(new string[] { "workshopItemPreviewImageEnlargeable" }, StringSplitOptions.None);
|
||||
string[] thumbimage = thumbnailparse[2].Split(new string[] { "/>" }, StringSplitOptions.None);
|
||||
string[] imageparse = thumbimage[0].Split(new string[] { "https://" }, StringSplitOptions.None);
|
||||
string image = "";
|
||||
try
|
||||
{
|
||||
image = "https://" + imageparse[3].Replace(@"""", "");
|
||||
}
|
||||
catch
|
||||
{
|
||||
try
|
||||
{
|
||||
image = "https://" + imageparse[2].Replace(@"""", "");
|
||||
}
|
||||
catch
|
||||
{
|
||||
try
|
||||
{
|
||||
image = "https://" + imageparse[1].Replace(@"""", "");
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
byte[] imagedata = wc.DownloadData(image);
|
||||
if (imagedata.Length > 0)
|
||||
{
|
||||
return ByteToImage(imagedata);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
catch { }
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static Bitmap ByteToImage(byte[] blob)
|
||||
{
|
||||
MemoryStream mStream = new MemoryStream();
|
||||
|
@ -299,8 +459,10 @@ namespace SignToolsGUI
|
|||
private void SaveMap_Click(object sender, EventArgs e)
|
||||
{
|
||||
string XMLData = XMLEncode();
|
||||
string XMLDataSkin = XMLEncodeSkin();
|
||||
//Check if mapdata already has image data
|
||||
MapData sd = worldSerialization.GetMap(Base64Encode("SerializedImageData"));
|
||||
MapData ssd = worldSerialization.GetMap(Base64Encode("SerializedSkinData"));
|
||||
if (sd == null)
|
||||
{
|
||||
worldSerialization.AddMap(Base64Encode("SerializedImageData"), Encoding.ASCII.GetBytes(XMLData));
|
||||
|
@ -309,7 +471,15 @@ namespace SignToolsGUI
|
|||
{
|
||||
sd.data = Encoding.ASCII.GetBytes(XMLData);
|
||||
}
|
||||
string mapfile = mapdir.Text.Replace(".map",".signs.map");
|
||||
if (ssd == null)
|
||||
{
|
||||
worldSerialization.AddMap(Base64Encode("SerializedSkinData"), Encoding.ASCII.GetBytes(XMLDataSkin));
|
||||
}
|
||||
else
|
||||
{
|
||||
ssd.data = Encoding.ASCII.GetBytes(XMLDataSkin);
|
||||
}
|
||||
string mapfile = mapdir.Text.Replace(".map",".Mod.map");
|
||||
if (File.Exists(mapfile))
|
||||
{
|
||||
File.Delete(mapfile);
|
||||
|
@ -334,5 +504,87 @@ namespace SignToolsGUI
|
|||
ModdedSerializedImageData[selected[0] + ")"] = new byte[0];
|
||||
ImagePreview.Image = null;
|
||||
}
|
||||
|
||||
private static void NumbersOnly_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
private static DialogResult ShowInputDialog(ref string input)
|
||||
{
|
||||
System.Drawing.Size size = new System.Drawing.Size(200, 70);
|
||||
Form inputBox = new Form();
|
||||
|
||||
inputBox.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
inputBox.ClientSize = size;
|
||||
inputBox.Text = "Skin ID";
|
||||
|
||||
System.Windows.Forms.TextBox textBox = new TextBox();
|
||||
textBox.Size = new System.Drawing.Size(size.Width - 10, 23);
|
||||
textBox.Location = new System.Drawing.Point(5, 5);
|
||||
textBox.Text = input;
|
||||
textBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(NumbersOnly_KeyPress);
|
||||
inputBox.Controls.Add(textBox);
|
||||
|
||||
Button okButton = new Button();
|
||||
okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
okButton.Name = "okButton";
|
||||
okButton.Size = new System.Drawing.Size(75, 23);
|
||||
okButton.Text = "&OK";
|
||||
okButton.Location = new System.Drawing.Point(size.Width - 80 - 80, 39);
|
||||
inputBox.Controls.Add(okButton);
|
||||
|
||||
Button cancelButton = new Button();
|
||||
cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
cancelButton.Name = "cancelButton";
|
||||
cancelButton.Size = new System.Drawing.Size(75, 23);
|
||||
cancelButton.Text = "&Cancel";
|
||||
cancelButton.Location = new System.Drawing.Point(size.Width - 80, 39);
|
||||
inputBox.Controls.Add(cancelButton);
|
||||
|
||||
inputBox.AcceptButton = okButton;
|
||||
inputBox.CancelButton = cancelButton;
|
||||
|
||||
DialogResult result = inputBox.ShowDialog();
|
||||
input = textBox.Text;
|
||||
return result;
|
||||
}
|
||||
|
||||
private void AddSkin_Click(object sender, EventArgs e)
|
||||
{
|
||||
string input = "0";
|
||||
uint skinid = 0;
|
||||
string[] selected = SkinLocations.GetItemText(SkinLocations.SelectedItem).Split(')');
|
||||
if (ModdedSerializedSkinData.ContainsKey(selected[0] + ")"))
|
||||
{
|
||||
|
||||
input = ModdedSerializedSkinData[selected[0] + ")"].ToString();
|
||||
if(ShowInputDialog(ref input) == DialogResult.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
skinid = uint.Parse(input);
|
||||
}
|
||||
catch { }
|
||||
|
||||
if (skinid != 0)
|
||||
{
|
||||
ModdedSerializedSkinData[selected[0] + ")"] = skinid;
|
||||
ImagePreview.Image = GetThumbNail(skinid);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveSkin_Click(object sender, EventArgs e)
|
||||
{
|
||||
string[] selected = SkinLocations.GetItemText(SkinLocations.SelectedItem).Split(')');
|
||||
ModdedSerializedSkinData[selected[0] + ")"] = 0;
|
||||
ImagePreview.Image = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7" />
|
||||
</startup>
|
||||
</configuration>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue