Update UI, LOCFile, COLFile, add PCKFileReader/Writer, update codebase to use new reader/class objects

This commit is contained in:
miku-666
2022-06-04 21:13:52 +02:00
parent c7b17adfb2
commit 6c65c19de7
43 changed files with 1435 additions and 2072 deletions

View File

@@ -5,10 +5,6 @@ VisualStudioVersion = 17.1.32414.318
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PckStudio", "MinecraftUSkinEditor\PckStudio.csproj", "{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nobleUpdater", "nobleUpdater\nobleUpdater.csproj", "{F77A61F1-0C6F-45DC-A5B5-A7BF38D64322}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSM Visualiser", "CSM Visualiser\CSM Visualiser.csproj", "{3530A9F2-AE0F-44B4-84F9-8FBACB456070}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -31,30 +27,6 @@ Global
{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}.Release|x64.Build.0 = Release|Any CPU
{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}.Release|x86.ActiveCfg = Release|Any CPU
{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}.Release|x86.Build.0 = Release|Any CPU
{F77A61F1-0C6F-45DC-A5B5-A7BF38D64322}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F77A61F1-0C6F-45DC-A5B5-A7BF38D64322}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F77A61F1-0C6F-45DC-A5B5-A7BF38D64322}.Debug|x64.ActiveCfg = Debug|Any CPU
{F77A61F1-0C6F-45DC-A5B5-A7BF38D64322}.Debug|x64.Build.0 = Debug|Any CPU
{F77A61F1-0C6F-45DC-A5B5-A7BF38D64322}.Debug|x86.ActiveCfg = Debug|Any CPU
{F77A61F1-0C6F-45DC-A5B5-A7BF38D64322}.Debug|x86.Build.0 = Debug|Any CPU
{F77A61F1-0C6F-45DC-A5B5-A7BF38D64322}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F77A61F1-0C6F-45DC-A5B5-A7BF38D64322}.Release|Any CPU.Build.0 = Release|Any CPU
{F77A61F1-0C6F-45DC-A5B5-A7BF38D64322}.Release|x64.ActiveCfg = Release|Any CPU
{F77A61F1-0C6F-45DC-A5B5-A7BF38D64322}.Release|x64.Build.0 = Release|Any CPU
{F77A61F1-0C6F-45DC-A5B5-A7BF38D64322}.Release|x86.ActiveCfg = Release|Any CPU
{F77A61F1-0C6F-45DC-A5B5-A7BF38D64322}.Release|x86.Build.0 = Release|Any CPU
{3530A9F2-AE0F-44B4-84F9-8FBACB456070}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3530A9F2-AE0F-44B4-84F9-8FBACB456070}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3530A9F2-AE0F-44B4-84F9-8FBACB456070}.Debug|x64.ActiveCfg = Debug|Any CPU
{3530A9F2-AE0F-44B4-84F9-8FBACB456070}.Debug|x64.Build.0 = Debug|Any CPU
{3530A9F2-AE0F-44B4-84F9-8FBACB456070}.Debug|x86.ActiveCfg = Debug|Any CPU
{3530A9F2-AE0F-44B4-84F9-8FBACB456070}.Debug|x86.Build.0 = Debug|Any CPU
{3530A9F2-AE0F-44B4-84F9-8FBACB456070}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3530A9F2-AE0F-44B4-84F9-8FBACB456070}.Release|Any CPU.Build.0 = Release|Any CPU
{3530A9F2-AE0F-44B4-84F9-8FBACB456070}.Release|x64.ActiveCfg = Release|Any CPU
{3530A9F2-AE0F-44B4-84F9-8FBACB456070}.Release|x64.Build.0 = Release|Any CPU
{3530A9F2-AE0F-44B4-84F9-8FBACB456070}.Release|x86.ActiveCfg = Release|Any CPU
{3530A9F2-AE0F-44B4-84F9-8FBACB456070}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -1,165 +0,0 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PckStudio.Classes
{
static class COL
{
public class COLFile
{
byte[] data;
List<byte> extradata = new List<byte>();
public List<object[]> entries = new List<object[]>();
public List<object[]> waterEntries = new List<object[]>();
public void Open(byte[] filePath)
{
data = filePath;
COL.Open(this, entries, waterEntries, data, extradata);
foreach (object[] obj in entries)
{
Console.WriteLine(obj[0].ToString() + " - #" + obj[1]);
}
}
public byte[] Save()
{
List<byte> SaveData = new List<byte>();
SaveData.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x01 });
Console.WriteLine(entries.Count);
List<byte> ItemAmmount = new List<byte>();
List<byte> WaterItemAmmount = new List<byte>();
ItemAmmount.AddRange(BitConverter.GetBytes(entries.Count));
WaterItemAmmount.AddRange(BitConverter.GetBytes(waterEntries.Count / 3));
ItemAmmount.Reverse();
WaterItemAmmount.Reverse();
byte[] ItemNum = ItemAmmount.ToArray();
byte[] WaterItemNum = WaterItemAmmount.ToArray();
ItemNum.Reverse();
WaterItemNum.Reverse();
Console.WriteLine(BitConverter.ToString(ItemNum));
Console.WriteLine(BitConverter.ToString(WaterItemNum));
SaveData.AddRange(ItemNum);
foreach (object[] obj in entries)
{
//Console.WriteLine(obj[0] + " - #" + obj[1]);
byte[] NameLength = (BitConverter.GetBytes(obj[0].ToString().Length));
SaveData.Add(NameLength[1]);
SaveData.Add(NameLength[0]);
SaveData.AddRange(Encoding.ASCII.GetBytes(obj[0].ToString()));
SaveData.Add(data[SaveData.Count]);
SaveData.AddRange(StringToByteArrayFastest(obj[1].ToString()));
}
SaveData.AddRange(WaterItemNum);
foreach (object[] obj in waterEntries)
{
//Console.WriteLine(obj[0] + " - #" + obj[1]);
string name = obj[0].ToString();
if (!name.EndsWith("(Underwater)") && !name.EndsWith("(Fog)"))
{
byte[] NameLength = (BitConverter.GetBytes(obj[0].ToString().Length));
SaveData.Add(NameLength[1]);
SaveData.Add(NameLength[0]);
SaveData.AddRange(Encoding.ASCII.GetBytes(obj[0].ToString()));
}
SaveData.AddRange(StringToByteArrayFastest(obj[1].ToString()));
}
return SaveData.ToArray();
//File.WriteAllBytes(Path.GetDirectoryName(filePath) + "\\coloursSaved.col", SaveData.ToArray());
}
}
public static void Open(COLFile This, List<object[]> entries, List<object[]> waterEntries, byte[] data, List<byte> extradata)
{
List<byte> MaxEntArrTemp = new List<byte>();
MaxEntArrTemp.AddRange(data.Skip(4).Take(4));
MaxEntArrTemp.Reverse();
int MaxEntries = BitConverter.ToInt32(MaxEntArrTemp.ToArray(), 0);
int i = 1;
int LeftAt = 8;
while (i <= MaxEntries)
{
List<byte> ItemNameLength = new List<byte>();
ItemNameLength.AddRange(data.Skip(LeftAt).Take(2));
ItemNameLength.Reverse();
int EntryLength = BitConverter.ToInt16(ItemNameLength.ToArray(), 0);
//Console.WriteLine(EntryLength);
byte[] ItemName = (data.Skip(LeftAt + 2).Take(EntryLength).ToArray());
byte[] ItemHex = (data.Skip(LeftAt + 3 + EntryLength).Take(3).ToArray());
object[] outentry = { System.Text.Encoding.Default.GetString(ItemName), BitConverter.ToString(ItemHex).Replace("-", "") };
entries.Add(outentry);
LeftAt = LeftAt + 6 + EntryLength;
i++;
}
Console.WriteLine(LeftAt);
Console.WriteLine(data.Length);
Console.WriteLine(data.Length - LeftAt);
extradata.AddRange(data.Skip(LeftAt).Take((data.Length) - LeftAt).ToArray());
try
{
List<byte> MaxEntArrTempB = new List<byte>();
MaxEntArrTempB.AddRange(extradata.Skip(-1).Take(4));
MaxEntArrTempB.Reverse();
int MaxEntriesB = BitConverter.ToInt32(MaxEntArrTempB.ToArray(), 0);
int LeftAtB = 4;
Console.WriteLine("MaxEntries (Extra Data) - " + MaxEntriesB);
for (int j = 0; j < MaxEntriesB; j++)
{
List<byte> ItemNameLength = new List<byte>();
ItemNameLength.AddRange(extradata.Skip(LeftAtB).Take(2));
ItemNameLength.Reverse();
int EntryLength = BitConverter.ToInt16(ItemNameLength.ToArray(), 0);
//Console.WriteLine(EntryLength);
byte[] ItemName = (extradata.Skip(LeftAtB + 2).Take(EntryLength).ToArray());
byte[] ItemHex = (extradata.Skip(LeftAtB + 2 + EntryLength).Take(4).ToArray());
byte[] ItemHexB = (extradata.Skip(LeftAtB + 6 + EntryLength).Take(4).ToArray());
byte[] ItemHexC = (extradata.Skip(LeftAtB + 10 + EntryLength).Take(4).ToArray());
object[] outentry = { System.Text.Encoding.Default.GetString(ItemName), BitConverter.ToString(ItemHex).Replace("-", "") };
object[] outentryB = { System.Text.Encoding.Default.GetString(ItemName) + " (Underwater)", BitConverter.ToString(ItemHexB).Replace("-", "") };
object[] outentryC = { System.Text.Encoding.Default.GetString(ItemName) + " (Fog)", BitConverter.ToString(ItemHexC).Replace("-", "") };
waterEntries.Add(outentry);
waterEntries.Add(outentryB);
waterEntries.Add(outentryC);
LeftAtB = LeftAtB + 14 + EntryLength;
}
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
}
static byte[] StringToByteArrayFastest(string hex)
{
if (hex.Length % 2 == 1)
throw new Exception("The binary key cannot have an odd number of digits");
byte[] arr = new byte[hex.Length >> 1];
for (int i = 0; i < hex.Length >> 1; ++i)
{
arr[i] = (byte)((GetHexVal(hex[i << 1]) << 4) + (GetHexVal(hex[(i << 1) + 1])));
}
return arr;
}
static int GetHexVal(char hex)
{
int val = (int)hex;
//For uppercase A-F letters:
//return val - (val < 58 ? 48 : 55);
//For lowercase a-f letters:
//return val - (val < 58 ? 48 : 87);
//Or the two combined, but a bit slower:
return val - (val < 58 ? 48 : (val < 97 ? 55 : 87));
}
}
}

View File

@@ -0,0 +1,116 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PckStudio.Classes.FileTypes
{
public class COLFile
{
public struct COLEntry
{
public string name;
public uint color;
}
List<byte> extradata = new List<byte>();
public List<COLEntry> entries = new List<COLEntry>();
public List<COLEntry> waterEntries = new List<COLEntry>();
public void Open(Stream stream)
{
byte[] buffer = new byte[8];
stream.Read(buffer, 0, 8);
int has_water_colors = BitConverter.ToInt32(buffer, 0);
int color_entries = BitConverter.ToInt32(buffer, 4);
for (int i = 0; i < color_entries; i++)
{
COLEntry entry = new COLEntry();
entry.name = ReadString(stream);
entry.color = ReadUint(stream);
entries.Add(entry);
}
if (has_water_colors == 1)
{
int water_color_entries = ReadInt(stream);
for (int i = 0; i < water_color_entries; i++)
{
COLEntry entry = new COLEntry();
entry.name = ReadString(stream);
entry.color = ReadUint(stream);
waterEntries.Add(entry);
}
}
}
private string ReadString(Stream stream)
{
byte[] bytes = new byte[2];
stream.Read(bytes, 0, 2);
if (BitConverter.IsLittleEndian)
Array.Reverse(bytes);
int strlen = BitConverter.ToInt16(bytes, 0);
byte[] stringBuffer = new byte[strlen];
stream.Read(stringBuffer, 0, strlen);
return Encoding.UTF8.GetString(stringBuffer, 0, strlen);
}
private int ReadInt(Stream stream)
{
return (int)ReadUint(stream);
}
private uint ReadUint(Stream stream)
{
byte[] bytes = new byte[4];
stream.Read(bytes, 0, 4);
if (BitConverter.IsLittleEndian)
Array.Reverse(bytes);
return BitConverter.ToUInt32(bytes, 0);
}
private void WriteUint(Stream stream, uint value)
{
byte[] bytes = BitConverter.GetBytes(value);
if (BitConverter.IsLittleEndian)
Array.Reverse(bytes);
stream.Write(bytes, 0, 4);
}
private void WriteInt(Stream stream, int value)
{
WriteUint(stream, (uint)value);
}
private void WriteString(Stream stream, string s)
{
byte[] bytes = BitConverter.GetBytes((short)s.Length);
if (BitConverter.IsLittleEndian)
Array.Reverse(bytes);
byte[] stringBuffer = Encoding.UTF8.GetBytes(s);
stream.Write(bytes, 0, 2);
stream.Write(stringBuffer, 0, s.Length);
}
public void Save(Stream stream)
{
WriteInt(stream, Convert.ToInt32(waterEntries.Count > 0));
WriteInt(stream, entries.Count);
foreach (var colorEntry in entries)
{
WriteString(stream, colorEntry.name);
WriteUint(stream, colorEntry.color);
}
if (waterEntries.Count > 0)
{
WriteInt(stream, waterEntries.Count);
foreach (var colorEntry in waterEntries)
{
WriteString(stream, colorEntry.name);
WriteUint(stream, colorEntry.color);
}
}
}
}
}

View File

@@ -1,130 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PckStudio
{
public class LOC
{
public LOC()
{
}
public LOC(byte[] data)
{
Read(data);
}
public string readString(FileData f)
{
int length = f.readShort();
string str = f.readString(f.pos(), length);
f.skip(length);
return str;
}
public class Language
{
public string name;
public int unk1;
public List<string> names = new List<string>();
public string readString(FileData f)
{
int length = f.readShort();
string str = f.readString(f.pos(), length);
f.skip(length);
return str;
}
public Language() { }
public void Read(FileData f)
{
int idCount = f.readInt();
for (int i = 0; i < idCount; i++)
names.Add(readString(f));
}
public byte[] Rebuild()
{
FileOutput f = new FileOutput();
f.Endian = Endianness.Big;
f.writeInt(names.Count);
foreach(string name in names)
{
f.writeShort(name.Length);
f.writeString(name);
}
return f.getBytes();
}
}
public Language ids = new Language();
public List<Language> langs = new List<Language>();
public void Read(byte[] data)
{
FileData f = new FileData(data);
f.Endian = Endianness.Big;
int unk1 = f.readInt();
if (unk1 != 2)
throw new NotImplementedException("Unsupported localization data");
int langCount = f.readInt();
f.skip(1);
ids.Read(f);
for(int i = 0; i < langCount; i++)
{
Language l = new Language();
l.name = readString(f);
l.unk1 = f.readInt();
langs.Add(l);
}
foreach (Language l in langs)
{
f.skip(5);
f.skip(f.readShort());
l.Read(f);
}
}
public byte[] Rebuild()
{
FileOutput f = new FileOutput();
f.Endian = Endianness.Big;
f.writeInt(2);
f.writeInt(langs.Count);
f.writeByte(0);
f.writeBytes(ids.Rebuild());
foreach(Language l in langs)
{
f.writeShort(l.name.Length);
f.writeString(l.name);
f.writeInt(7 + l.name.Length + l.Rebuild().Length);
}
foreach(Language l in langs)
{
f.writeInt(2);
f.writeByte(0);
f.writeShort(l.name.Length);
f.writeString(l.name);
f.writeBytes(l.Rebuild());
}
return f.getBytes();
}
}
}

View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PckStudio.Classes.FileTypes
{
public class LOCFile
{
public Dictionary<string, Dictionary<string, string>> languages { get; set; } = new Dictionary<string, Dictionary<string, string>>();
public void AddEntry(string key, string value)
{
foreach (var language in languages.Values)
{
language.Add(key, value);
}
}
public void ChangeEntry(string keyId, string newValue)
{
foreach (var language in languages.Values)
{
if (!language.ContainsKey(keyId)) throw new Exception("Key not found");
language[keyId] = newValue;
}
}
public void ChangeSingleEntry(string language, string keyId, string newValue)
{
if (!languages.ContainsKey(language)) throw new Exception("Key not found");
if (!languages[language].ContainsKey(keyId)) throw new Exception("Key Id not found");
languages[language][keyId] = newValue;
}
public void RemoveEntry(string keyId)
{
foreach (var language in languages.Values)
{
if (language.ContainsKey(keyId))
language.Remove(keyId);
}
}
}
}

View File

@@ -1,20 +1,15 @@
using System;
using PckStudio.Classes.IO;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PckStudio.Classes.FileTypes
{
using PCKProperties = Dictionary<string, string>;
public class PCKFile
{
public int type { get; } = -1;
public Dictionary<int, string> meta_data { get; } = new Dictionary<int, string>();
public Dictionary<string, int> meta_data { get; } = new Dictionary<string, int>();
public List<FileData> file_entries { get; set; } = new List<FileData>();
public bool isLittleEndian { get; } = false;
public class FileData
{
@@ -36,112 +31,38 @@ namespace PckStudio.Classes.FileTypes
public string name;
public int type { get; }
public byte[] data { get; set; } = null;
public int size { get; set; }
public byte[] data => _data;
public int size => _size;
public PCKProperties properties { get; set; } = new PCKProperties();
public FileData(string name, int type, int size)
private byte[] _data = new byte[0];
private int _size = 0;
public FileData(string name, int type)
{
this.type = type;
this.name = name;
this.size = size;
}
public FileData(int type)
public FileData(string name, int type, int dataSize)
{
name = "no_name";
this.type = type;
this.name = name;
_size = dataSize;
_data = new byte[dataSize];
}
public void SetData(byte[] data)
{
_data = data;
_size = data.Length;
}
}
public PCKFile(Stream stream, bool isLittleEndian = false)
{
this.isLittleEndian = isLittleEndian;
type = ReadInt(stream);
ReadMetaData(stream);
ReadFileEntries(stream);
}
public PCKFile(int type, bool isLittleEndian = false)
public PCKFile(int type)
{
this.type = type;
this.isLittleEndian = isLittleEndian;
}
internal void ReadMetaData(Stream stream)
{
int meta_entry_count = ReadInt(stream);
bool has_xml_tag = false;
for (; 0 < meta_entry_count; meta_entry_count--)
{
int index = ReadInt(stream);
string value = ReadString(stream);
if (value.Equals("XMLVERSION")) has_xml_tag = true;
meta_data[index] = value;
ReadInt(stream); // padding ????
}
if (has_xml_tag)
Console.WriteLine(ReadInt(stream).ToString("X08"));
}
internal void ReadFileEntries(Stream stream)
{
int file_entry_count = ReadInt(stream);
for (;0 < file_entry_count; file_entry_count--)
{
int file_size = ReadInt(stream);
int file_type = ReadInt(stream);
string name = ReadString(stream);
file_entries.Add(new FileData(name, file_type, file_size));
ReadInt(stream);
}
foreach (var file_entry in file_entries)
{
int property_count = ReadInt(stream);
var properties = new PCKProperties();
for(;0 < property_count; property_count--)
{
int index = ReadInt(stream);
string key = meta_data[index];
string value = ReadString(stream);
ReadInt(stream); // padding ???
properties[key] = value;
}
file_entry.properties = properties;
file_entry.data = new byte[file_entry.size];
stream.Read(file_entry.data, 0, file_entry.size);
}
}
internal string ReadString(Stream stream)
{
int len = ReadInt(stream);
byte[] stringBuffer = new byte[len * 2];
stream.Read(stringBuffer, 0, len * 2);
return Encoding.BigEndianUnicode.GetString(stringBuffer, 0, len * 2);
}
internal int ReadInt(Stream stream)
{
byte[] buffer = new byte[4];
stream.Read(buffer, 0, 4);
if (BitConverter.IsLittleEndian && !isLittleEndian)
Array.Reverse(buffer);
return BitConverter.ToInt32(buffer, 0);
}
internal short ReadShort(Stream stream)
{
byte[] buffer = new byte[2];
stream.Read(buffer, 0, 2);
if (BitConverter.IsLittleEndian && !isLittleEndian)
Array.Reverse(buffer);
return BitConverter.ToInt16(buffer, 0);
}
public override string ToString()
{
return $"type: {type}\nmeta entry count: {meta_data.Count}\nfile entry count: {file_entries.Count}";
}
}
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PckStudio.Classes.FileTypes
{
public class PCKProperties : List<Tuple<string, string>> // class because `using` is file scoped :|
{
}
}

View File

@@ -1,33 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PckStudio
{
public enum Endianness
{
Little = 0,
Big = 1
}
public abstract class FileBase
{
public abstract Endianness Endian { get; set; }
public abstract void Read(string filename);
public abstract byte[] Rebuild();
public void Save(string filename)
{
var Data = Rebuild();
if (Data.Length <= 0)
throw new Exception("Warning: Data was empty!");
File.WriteAllBytes(filename, Data);
}
}
}

View File

@@ -1,294 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
namespace PckStudio
{
public class FileData
{
private byte[] b;
private int p;
public Endianness Endian;
public FileData(string f)
{
b = File.ReadAllBytes(f);
}
public FileData(byte[] b)
{
this.p = 0;
this.b = b;
}
public int eof()
{
return b.Length;
}
public byte[] read(int length)
{
if (length + p > b.Length)
{
throw new IndexOutOfRangeException();
}
byte[] array = new byte[length];
int num = 0;
while (num < length)
{
array[num] = b[p];
num++;
p++;
}
return array;
}
public int readInt()
{
if (Endian == Endianness.Little)
{
return (b[p++] & 0xFF) | ((b[p++] & 0xFF) << 8) | ((b[p++] & 0xFF) << 16) | ((b[p++] & 0xFF) << 24);
}
return ((b[p++] & 0xFF) << 24) | ((b[p++] & 0xFF) << 16) | ((b[p++] & 0xFF) << 8) | (b[p++] & 0xFF);
}
public int readThree()
{
if (Endian == Endianness.Little)
{
return (b[p++] & 0xFF) | ((b[p++] & 0xFF) << 8) | ((b[p++] & 0xFF) << 16);
}
return ((b[p++] & 0xFF) << 16) | ((b[p++] & 0xFF) << 8) | (b[p++] & 0xFF);
}
public int readShort()
{
if (Endian == Endianness.Little)
{
return (b[p++] & 0xFF) | ((b[p++] & 0xFF) << 8);
}
return ((b[p++] & 0xFF) << 8) | (b[p++] & 0xFF);
}
public int readIntVita()
{
if (Endian != Endianness.Little)
{
int d = p;
return (b[p++] & 0xFF) | ((b[p++] & 0xFF) << 8) | ((b[p++] & 0xFF) << 16) | ((b[p++] & 0xFF) << 24);
}
int oot = ((b[p++] & 0xFF) << 24) | ((b[p++] & 0xFF) << 16) | ((b[p++] & 0xFF) << 8) | (b[p++] & 0xFF);
return oot;
}
public int readThreeVita()
{
if (Endian != Endianness.Little)
{
return (b[p++] & 0xFF) | ((b[p++] & 0xFF) << 8) | ((b[p++] & 0xFF) << 16);
}
return ((b[p++] & 0xFF) << 16) | ((b[p++] & 0xFF) << 8) | (b[p++] & 0xFF);
}
public int readShortVita()
{
if (Endian != Endianness.Little)
{
return (b[p++] & 0xFF) | ((b[p++] & 0xFF) << 8);
}
return ((b[p++] & 0xFF) << 8) | (b[p++] & 0xFF);
}
public int readByte()
{
return b[p++] & 0xFF;
}
public byte[] readBytes(int length)
{
List<byte> list = new List<byte>();
for (int i = 0; i < length; i++)
{
list.Add((byte)readByte());
}
return list.ToArray();
}
public float readFloat()
{
byte[] array = new byte[4];
array = ((Endian != 0) ? new byte[4]
{
b[p + 3],
b[p + 2],
b[p + 1],
b[p]
} : new byte[4]
{
b[p],
b[p + 1],
b[p + 2],
b[p + 3]
});
p += 4;
return BitConverter.ToSingle(array, 0);
}
public float readHalfFloat()
{
return toFloat((short)readShort());
}
public static float toFloat(int hbits)
{
int num = hbits & 0x3FF;
int num2 = hbits & 0x7C00;
switch (num2)
{
case 31744:
num2 = 261120;
break;
default:
num2 += 114688;
if (num == 0 && num2 > 115712)
{
return BitConverter.ToSingle(BitConverter.GetBytes(((hbits & 0x8000) << 16) | (num2 << 13) | 0x3FF), 0);
}
break;
case 0:
if (num != 0)
{
num2 = 115712;
do
{
num <<= 1;
num2 -= 1024;
}
while ((num & 0x400) == 0);
num &= 0x3FF;
}
break;
}
return BitConverter.ToSingle(BitConverter.GetBytes(((hbits & 0x8000) << 16) | ((num2 | num) << 13)), 0);
}
public static int fromFloat(float fval, bool littleEndian)
{
int num = FileOutput.SingleToInt32Bits(fval, littleEndian);
int num2 = (num >> 16) & 0x8000;
int num3 = (num & 0x7FFFFFFF) + 4096;
if (num3 >= 1199570944)
{
if ((num & 0x7FFFFFFF) >= 1199570944)
{
if (num3 < 2139095040)
{
return num2 | 0x7C00;
}
return num2 | 0x7C00 | ((num & 0x7FFFFF) >> 13);
}
return num2 | 0x7BFF;
}
if (num3 >= 947912704)
{
return num2 | (num3 - 939524096 >> 13);
}
if (num3 < 855638016)
{
return num2;
}
num3 = (num & 0x7FFFFFFF) >> 23;
return num2 | (((num & 0x7FFFFF) | 0x800000) + (8388608 >> num3 - 102) >> 126 - num3);
}
public static int sign12Bit(int i)
{
if (((i >> 11) & 1) == 1)
{
i = ~i;
i &= 0xFFF;
i++;
i *= -1;
}
return i;
}
public void skip(int i)
{
p += i;
}
public void seek(int i)
{
p = i;
}
public int pos()
{
return p;
}
public int size()
{
return b.Length;
}
public string readString()
{
string text = "";
while (b[p] != 0)
{
string str = text;
char c = (char)b[p];
text = str + c;
p++;
}
return text;
}
public byte[] getSection(int offset, int size)
{
byte[] array = new byte[size];
Array.Copy(b, offset, array, 0, size);
return array;
}
public string readString(int p, int size)
{
if (size == -1)
{
string text = "";
while (p < b.Length && (b[p] & 0xFFu) != 0)
{
text += (char)(b[p] & 0xFFu);
p++;
}
return text;
}
string text2 = "";
for (int i = p; i < p + size; i++)
{
if ((b[i] & 0xFFu) != 0)
{
text2 += (char)(b[i] & 0xFFu);
}
}
return text2;
}
public void align(int i)
{
while (p % i != 0)
{
p++;
}
}
public int readOffset()
{
return p + readInt();
}
}
}

View File

@@ -1,193 +0,0 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
namespace PckStudio
{
public class FileOutput
{
List<byte> data = new List<byte>();
public Endianness Endian;
public byte[] getBytes()
{
return data.ToArray();
}
public void writeString(String s){
char[] c = s.ToCharArray();
for(int i = 0; i < c.Length ; i++)
data.Add((byte)c[i]);
}
public int size(){
return data.Count;
}
public void writeOutput(FileOutput d){
foreach(byte b in d.data)
data.Add(b);
}
private static char[] HexToCharArray(string hex)
{
return Enumerable.Range(0, hex.Length)
.Where(x => x % 2 == 0)
.Select(x => Convert.ToByte(hex.Substring(x, 2), 16))
.Select(x => Convert.ToChar(x))
.ToArray();
}
public void writeHex(string s)
{
char[] c = HexToCharArray(s);
for (int i = 0; i < c.Length; i++)
data.Add((byte)c[i]);
}
public void writeInt(int i){
if(Endian == Endianness.Little){
data.Add((byte)((i)&0xFF));
data.Add((byte)((i>>8)&0xFF));
data.Add((byte)((i>>16)&0xFF));
data.Add((byte)((i>>24)&0xFF));
}else{
data.Add((byte)((i>>24)&0xFF));
data.Add((byte)((i>>16)&0xFF));
data.Add((byte)((i>>8)&0xFF));
data.Add((byte)((i)&0xFF));
}
}
public void writeIntAt(int i, int p){
if(Endian == Endianness.Little){
data[p++] = (byte)((i)&0xFF);
data[p++] = (byte)((i>>8)&0xFF);
data[p++] = (byte)((i>>16)&0xFF);
data[p++] = (byte)((i>>24)&0xFF);
}else{
data[p++] = (byte)((i>>24)&0xFF);
data[p++] = (byte)((i>>16)&0xFF);
data[p++] = (byte)((i>>8)&0xFF);
data[p++] = (byte)((i)&0xFF);
}
}
public void writeShortAt(int i, int p){
if(Endian == Endianness.Little){
data[p++] = (byte)((i)&0xFF);
data[p++] = (byte)((i>>8)&0xFF);
}else{
data[p++] = (byte)((i>>8)&0xFF);
data[p++] = (byte)((i)&0xFF);
}
}
public void writeIntVita(int i)
{
if (Endian != Endianness.Little)
{
data.Add((byte)((i) & 0xFF));
data.Add((byte)((i >> 8) & 0xFF));
data.Add((byte)((i >> 16) & 0xFF));
data.Add((byte)((i >> 24) & 0xFF));
}
else
{
data.Add((byte)((i >> 24) & 0xFF));
data.Add((byte)((i >> 16) & 0xFF));
data.Add((byte)((i >> 8) & 0xFF));
data.Add((byte)((i) & 0xFF));
}
}
public void align(int i){
while(data.Count % i != 0)
writeByte(0);
}
public void align(int i, int v){
while(data.Count % i != 0)
writeByte(v);
}
/*public void align(int i, int value){
while(data.size() % i != 0)
writeByte(value);
}*/
public void writeFloat(float f){
int i = SingleToInt32Bits (f, Endian == Endianness.Big);
data.Add((byte)((i)&0xFF));
data.Add((byte)((i>>8)&0xFF));
data.Add((byte)((i>>16)&0xFF));
data.Add((byte)((i>>24)&0xFF));
}
public static int SingleToInt32Bits(float value, bool littleEndian) {
byte[] b = BitConverter.GetBytes (value);
int p = 0;
if (!littleEndian) {
return (b [p++]&0xFF) | ((b [p++] & 0xFF) << 8) | ((b [p++] & 0xFF) << 16) | ((b [p++] & 0xFF) << 24);
}else
return ((b [p++] & 0xFF) << 24) | ((b [p++] & 0xFF) << 16) | ((b [p++] & 0xFF) << 8) | (b [p++]&0xFF);
}
public void writeHalfFloat(float f){
int i = FileData.fromFloat(f, Endian == Endianness.Little);
data.Add((byte)((i>>8)&0xFF));
data.Add((byte)((i)&0xFF));
}
public void writeShort(int i){
if(Endian == Endianness.Little){
data.Add((byte)((i)&0xFF));
data.Add((byte)((i>>8)&0xFF));
} else {
data.Add((byte)((i>>8)&0xFF));
data.Add((byte)((i)&0xFF));
}
}
public void writeByte(int i){
data.Add((byte)((i)&0xFF));
}
public void writeChars(char[] c)
{
foreach (char ch in c)
writeByte(Convert.ToByte(ch));
}
public void writeBytes(byte[] bytes)
{
foreach(byte b in bytes)
writeByte(b);
}
public void writeFlag(bool b)
{
if (b)
writeByte(1);
else
writeByte(0);
}
public int pos()
{
return data.Count;
}
public void save(String fname)
{
File.WriteAllBytes (fname, data.ToArray());
}
}
}

View File

@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using PckStudio.Classes.FileTypes;
namespace PckStudio.Classes.IO.LOC
{
internal class LOCFileReader
{
internal LOCFile _file;
public static LOCFile Read(Stream stream)
{
return new LOCFileReader().ReadFile(stream);
}
private LOCFileReader()
{
_file = new LOCFile();
}
internal LOCFile ReadFile(Stream stream)
{
int loc_type = ReadInt(stream);
int language_count = ReadInt(stream);
List<string> keys = null;
if (loc_type == 2) keys = ReadKeys(stream);
for (int i = 0; i < language_count; i++)
{
string language = ReadString(stream);
_file.languages[language] = new Dictionary<string, string>();
ReadInt(stream); // padding ???
}
for (int i = 0; i < language_count; i++)
{
stream.ReadByte(); // unknown
ReadInt(stream); // unknown
string language = ReadString(stream);
int count = ReadInt(stream);
for (int j = 0; j < count; j++)
{
string key = loc_type == 2 ? keys[j] : ReadString(stream);
string value = ReadString(stream);
_file.languages[language].Add(key, value);
}
}
return _file;
}
internal List<string> ReadKeys(Stream stream)
{
stream.ReadByte(); // unknown
int keyCount = ReadInt(stream);
List<string> keys = new List<string>();
for (; 0 < keyCount; keyCount--)
{
string key = ReadString(stream);
keys.Add(key);
}
return keys;
}
internal short ReadShort(Stream stream)
{
byte[] bytes = new byte[2];
stream.Read(bytes, 0, bytes.Length);
return BitConverter.ToInt16(bytes, 0);
}
internal int ReadInt(Stream stream)
{
byte[] bytes = new byte[4];
stream.Read(bytes, 0, bytes.Length);
return BitConverter.ToInt32(bytes, 0);
}
internal string ReadString(Stream stream)
{
int length = ReadShort(stream);
byte[] buffer = new byte[length];
stream.Read(buffer, 0, length);
return Encoding.UTF8.GetString(buffer, 0, length);
}
}
}

View File

@@ -0,0 +1,72 @@
using PckStudio.Classes.FileTypes;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace PckStudio.Classes.IO.LOC
{
internal class LOCFileWriter
{
internal LOCFile _file;
public static void Write(Stream stream, LOCFile file, int type = 0)
{
new LOCFileWriter(file).WriteToStream(stream, type);
}
private LOCFileWriter(LOCFile file)
{
_file = file;
}
private void WriteToStream(Stream stream, int type)
{
WriteInt(stream, type);
WriteInt(stream, _file.languages.Count);
if (type == 2) WriteKeys(stream);
WriteLanguages(stream);
}
internal void WriteKeys(Stream stream)
{
stream.WriteByte(0);
// TODO: find all keys and write them
//WriteInt(stream, )
}
internal void WriteLanguages(Stream stream)
{
foreach (var language in _file.languages.Keys)
{
WriteString(stream, language);
WriteInt(stream, 0); // padding ???
}
}
internal void WriteLanguageEntries(Stream stream)
{
}
internal void WriteShort(Stream stream, short value)
{
byte[] bytes = BitConverter.GetBytes(value);
stream.Write(bytes, 0, bytes.Length);
}
internal void WriteInt(Stream stream, int value)
{
byte[] bytes = BitConverter.GetBytes(value);
stream.Write(bytes, 0, bytes.Length);
}
internal void WriteString(Stream stream, string s)
{
WriteShort(stream, (short)s.Length);
byte[] buffer = Encoding.UTF8.GetBytes(s);
stream.Write(buffer, 0, buffer.Length);
}
}
}

View File

@@ -0,0 +1,105 @@
using PckStudio.Classes.FileTypes;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows;
namespace PckStudio.Classes.IO
{
internal class PCKFileReader
{
internal bool isLittleEndian = false;
internal PCKFile _file;
public static PCKFile Read(Stream s, bool isLittleEndian)
{
return new PCKFileReader(isLittleEndian).ReadFileFromStream(s);
}
private PCKFileReader(bool isLittleEndian)
{
this.isLittleEndian = isLittleEndian;
}
private PCKFile ReadFileFromStream(Stream s)
{
_file = new PCKFile(ReadInt(s));
ReadMetaData(s);
ReadFileEntries(s);
return _file;
}
internal void ReadMetaData(Stream stream)
{
int meta_entry_count = ReadInt(stream);
bool has_xml_tag = false;
for (; 0 < meta_entry_count; meta_entry_count--)
{
int index = ReadInt(stream);
string value = ReadString(stream);
if (value.Equals("XMLVERSION")) has_xml_tag = true;
_file.meta_data[value] = index;
ReadInt(stream); // padding ????
}
if (has_xml_tag)
Console.WriteLine(ReadInt(stream).ToString("X08")); // xml version num ??
}
internal void ReadFileEntries(Stream stream)
{
int file_entry_count = ReadInt(stream);
for (; 0 < file_entry_count; file_entry_count--)
{
int file_size = ReadInt(stream);
int file_type = ReadInt(stream);
string name = ReadString(stream);
var entry = new PCKFile.FileData(name, file_type, file_size);
_file.file_entries.Add(entry);
ReadInt(stream);
}
foreach (var file_entry in _file.file_entries)
{
int property_count = ReadInt(stream);
var properties = new PCKProperties();
for (; 0 < property_count; property_count--)
{
int index = ReadInt(stream);
if (!_file.meta_data.ContainsValue(index)) // should never happen with valid pck's
throw new Exception("Value not found");
string key = GetKeyFromValue(_file.meta_data, index);
string value = ReadString(stream);
properties.Add(new Tuple<string, string>(key, value));
ReadInt(stream); // padding ???
}
file_entry.properties = properties;
stream.Read(file_entry.data, 0, file_entry.size); // file data buffer is only allocated when FileData is constructed with `dataSize`
}
}
private static T1 GetKeyFromValue<T1, T2>(Dictionary<T1, T2> dict, T2 value)
{
foreach (KeyValuePair<T1, T2> pair in dict)
if (EqualityComparer<T2>.Default.Equals(pair.Value, value))
return pair.Key;
return default(T1); // should never return unless dict.ContainsValue(value) returns false
}
internal int ReadInt(Stream stream)
{
byte[] buffer = new byte[4];
stream.Read(buffer, 0, 4);
if (BitConverter.IsLittleEndian && !isLittleEndian)
Array.Reverse(buffer);
return BitConverter.ToInt32(buffer, 0);
}
internal string ReadString(Stream stream)
{
int len = ReadInt(stream);
byte[] stringBuffer = new byte[len * 2];
stream.Read(stringBuffer, 0, len * 2);
return Encoding.BigEndianUnicode.GetString(stringBuffer, 0, len * 2);
}
}
}

View File

@@ -0,0 +1,90 @@
using PckStudio.Classes.FileTypes;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PckStudio.Classes.IO
{
internal class PCKFileWriter
{
internal bool isLittleEndian = false;
internal PCKFile _file;
public static void Write(Stream stream, PCKFile file, bool isLittleEndian)
{
new PCKFileWriter(file, isLittleEndian).WriteFileToStream(stream);
}
private PCKFileWriter(PCKFile file, bool isLittleEndian)
{
_file = file;
this.isLittleEndian = isLittleEndian;
}
private void WriteFileToStream(Stream stream)
{
WriteInt(stream, _file.type);
WriteMetaEntries(stream);
WriteFileEntries(stream);
}
internal void WriteInt(Stream stream, int value)
{
byte[] buffer = BitConverter.GetBytes(value);
if (BitConverter.IsLittleEndian && !isLittleEndian)
Array.Reverse(buffer);
stream.Write(buffer, 0, buffer.Length);
}
internal void WriteString(Stream stream, string s)
{
WriteInt(stream, s.Length);
byte[] byteString = Encoding.BigEndianUnicode.GetBytes(s);
stream.Write(byteString, 0, byteString.Length);
}
internal void WriteMetaEntries(Stream stream)
{
WriteInt(stream, _file.meta_data.Count);
bool has_xmlverion_tag = false;
foreach (var metaEntry in _file.meta_data)
{
if (metaEntry.Key == "XMLVERION") has_xmlverion_tag = true;
WriteInt(stream, metaEntry.Value);
WriteString(stream, metaEntry.Key);
WriteInt(stream, 0);
}
if (has_xmlverion_tag)
WriteInt(stream, 0);
}
internal void WriteFileEntries(Stream stream)
{
WriteInt(stream, _file.file_entries.Count);
foreach (var entry in _file.file_entries)
{
WriteInt(stream, entry.size);
WriteInt(stream, entry.type);
WriteString(stream, entry.name);
WriteInt(stream, 0);
}
foreach (var entry in _file.file_entries)
{
WriteInt(stream, entry.properties.Count);
foreach (var property in entry.properties)
{
if (!_file.meta_data.ContainsKey(property.Item1))
throw new Exception("invalid meta type" + property.Item1);
WriteInt(stream, _file.meta_data[property.Item1]);
WriteString(stream, property.Item2);
WriteInt(stream, 0);
}
stream.Write(entry.data, 0, entry.size);
}
}
}
}

View File

@@ -16,14 +16,12 @@ namespace PckStudio
public static string baseurl = "https://www.pckstudio.xyz/studio/PCK/api/";
public static string backurl = "https://raw.githubusercontent.com/PhoenixARC/pckstudio.tk/main/studio/PCK/api/";
public static string Appdata = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/PCK Studio/";
public static bool IsDev;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
IsDev = args.Length > 0 && args[0] == "-dev";
Application.Run(new PckStudio.FormMain());
}
}

View File

@@ -25,7 +25,7 @@ namespace PckStudio.Forms
private void buttonUnlocked_Click(object sender, EventArgs e)
{
file.properties.Add("LOCK", MD5(textBoxPass.Text));
file.properties.Add(new Tuple<string, string>("LOCK", MD5(textBoxPass.Text)));
Close();
}

View File

@@ -27,12 +27,13 @@ namespace PckStudio
private void button1_Click(object sender, EventArgs e)
{
if (currentPCK.meta_data.ContainsValue(textBox1.Text))
if (currentPCK.meta_data.ContainsKey(textBox1.Text))
{
MessageBox.Show("This metatag already exits");
return;
}
currentPCK.meta_data.Add(currentPCK.meta_data.Count, textBox1.Text);
if (!currentPCK.meta_data.ContainsValue(currentPCK.meta_data.Count))
currentPCK.meta_data.Add(textBox1.Text, currentPCK.meta_data.Count);
Close();
}
}

View File

@@ -34,7 +34,7 @@ namespace PckStudio
try
{
treeView1.Nodes.Clear();
foreach (string key in currentPCK.meta_data.Values)
foreach (string key in currentPCK.meta_data.Keys)
{
treeView1.Nodes.Add(key);
}

View File

@@ -89,7 +89,7 @@ namespace PckStudio
}
else
{
file.properties.Add(entryName, entryValue);
file.properties.Add(new Tuple<string, string>(entryName, entryValue ));
entryName = "";
entryValue = "";
entryStart = true;

View File

@@ -15,6 +15,7 @@ using System.Drawing.Imaging;
using RichPresenceClient;
using PckStudio.Classes.FileTypes;
using PckStudio.Classes.IO;
using PckStudio.Classes.IO.LOC;
namespace PckStudio
{
@@ -26,19 +27,14 @@ namespace PckStudio
PCKFile.FileData mf;//Template minefile variable
PCKFile currentPCK;//currently opened pck
LOC l; //Locdata
PCKFile.FileData mfLoc; //LOC minefile
PCKFile.FileData file; //template for a selected minefile
bool needsUpdate = false;
LOCFile l; //Locdata
PCKFile.FileData mfLoc = new PCKFile.FileData("CURRENTLOCDATA", 6); //LOC minefile
PCKFile.FileData file; //template for a selected minefile
bool needsUpdate = false;
bool saved = true;
bool isTemplateFile = false;
string appData = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/PCK Studio/";
public class displayId
{
public string id;
public string defaultName;
}
public FormMain()
{
InitializeComponent();
@@ -146,10 +142,15 @@ namespace PckStudio
{
fileEntryCountLabel.Text = "Files:" + currentPCK.file_entries.Count;
treeMeta.Enabled = true;
buttonEdit.Visible = false;
//Sets preview image to "NO IMAGE" if selected file data isn't image data
pictureBoxImagePreview.Image = (Image)Resources.NoImageFound;
int pictureBoxMaxHeight = (tabPage1.Height / 2) - (tabPage1.Height / 10);
if (treeViewMain.SelectedNode.Tag != null) //"Selects" node if it has data/isn't a folder
pictureBoxImagePreview.Size = new Size(pictureBoxMaxHeight, pictureBoxMaxHeight);
labelImageSize.Text = "";//Resets image size display if theres no image
if (treeViewMain.SelectedNode.Tag != null && treeViewMain.SelectedNode.Tag is PCKFile.FileData) //"Selects" node if it has data/isn't a folder
{
PCKFile.FileData file = (PCKFile.FileData)e.Node.Tag; //Sets current minefile being read
PCKFile.FileData file = e.Node.Tag as PCKFile.FileData;
treeMeta.Nodes.Clear(); //clears minefile metadata treeview
@@ -318,14 +319,6 @@ namespace PckStudio
labelImageSize.Text = "";
}
}
else
{
buttonEdit.Visible = false;
//Sets preview image to "NO IMAGE" if selected file data isn't image data
pictureBoxImagePreview.Image = (Image)Resources.NoImageFound;
pictureBoxImagePreview.Size = new Size(pictureBoxMaxHeight, pictureBoxMaxHeight);
}
labelImageSize.Text = "";//Resets image size display if theres no image
}
#region Parses boxes and opens model generator
@@ -475,193 +468,42 @@ namespace PckStudio
}
#endregion
#region saves pck
private void save(string saveType)
private void save()
{
TreeView saveStructure = new TreeView();//Temporary new treeview to properly store minefiles in writable form
//structures minefile data based on wether it has parent nodes or not and with its proper minefile data
foreach (TreeNode item in treeViewMain.Nodes)
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "PCK (Minecraft Console Package)|*.pck";
saveFileDialog.DefaultExt = ".pck";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
TreeNode add = new TreeNode();
if (item.Parent != null)
using (var fs = File.OpenWrite(saveFileDialog.FileName))
{
string itemPath = "";//item path template
List<TreeNode> path = new List<TreeNode>();//directory template
GetPathToRoot(treeViewMain.SelectedNode, path);//gets all parents nodes
//generates minefile directory to properly store in minedata
foreach (TreeNode dire in path)
{
itemPath += dire.Text + "/";
}
add.Text = itemPath + item.Text;
}
else
{
add.Text = item.Text;
}
add.Tag = item.Tag;
saveStructure.Nodes.Add(add);
add.Remove();
}
//Reassignes each node with its minefile data to make sure everything is synced
foreach (TreeNode item in saveStructure.Nodes)
{
currentPCK.file_entries[item.Index] = (PCKFile.FileData)item.Tag;
}
//Syncs minefile name with nodes name
for (int i = 0; i < saveStructure.Nodes.Count; i++)
currentPCK.file_entries[i].name = saveStructure.Nodes[i].Text;
if (saveLocation == appData + @"\templates\UntitledSkinPCK.pck")
{
//writes pck data if pck is actually opened
using (var ofd = new SaveFileDialog())
{
ofd.Filter = "PCK (Minecraft Console Package)|*.pck";
if (ofd.ShowDialog() == DialogResult.OK)
{
try
{
MessageBox.Show("TODO!!!!");
//Console.WriteLine(currentPCK.isLittleEndian.ToString() + "--");
//if (LittleEndianCheckBox.Checked)
//{
// byte[] oouput = currentPCK.RebuildVita();
// oouput[0] = 0x03;
// File.WriteAllBytes(ofd.FileName, currentPCK.RebuildVita());
//}
//else
//{
// byte[] oouput = currentPCK.Rebuild();
// File.WriteAllBytes(ofd.FileName, currentPCK.Rebuild());
//}
//saveLocation = ofd.FileName;
//openedPCKS.SelectedTab.Text = Path.GetFileName(ofd.FileName);
//saved = true;
//MessageBox.Show("PCK Saved!");
//PCKFilePath = Path.GetFileName(ofd.FileName);
}
catch (Exception)
{
MessageBox.Show("No PCK loaded");
}
}
PCKFileWriter.Write(fs, currentPCK, LittleEndianCheckBox.Checked);
}
}
else if (saveType == "Save As")
{
//writes pck data if pck is actually opened
using (var ofd = new SaveFileDialog())
{
ofd.Filter = "PCK (Minecraft Console Package)|*.pck";
if (ofd.ShowDialog() == DialogResult.OK)
{
try
{
MessageBox.Show("TODO!!");
//Console.WriteLine(currentPCK.isLittleEndian.ToString() + "--");
//if (LittleEndianCheckBox.Checked)
//{
// byte[] oouput = currentPCK.RebuildVita();
// oouput[0] = 0x03;
// File.WriteAllBytes(ofd.FileName, currentPCK.RebuildVita());
//}
//else
//{
// byte[] oouput = currentPCK.Rebuild();
// File.WriteAllBytes(ofd.FileName, currentPCK.Rebuild());
//}
//saveLocation = ofd.FileName;
//openedPCKS.SelectedTab.Text = Path.GetFileName(ofd.FileName);
//saved = true;
//MessageBox.Show("PCK Saved!");
}
catch (Exception)
{
MessageBox.Show("No PCK loaded");
}
}
}
}
else
{
MessageBox.Show("TODO!!!");
//if (MessageBox.Show("Are you sure you wanna save?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
//{
// try
// {
// Console.WriteLine(currentPCK.isLittleEndian.ToString() + "--");
// if (LittleEndianCheckBox.Checked)
// {
// byte[] oouput = currentPCK.RebuildVita();
// oouput[0] = 0x03;
// File.WriteAllBytes(saveLocation, currentPCK.RebuildVita());
// }
// else
// {
// byte[] oouput = currentPCK.Rebuild();
// File.WriteAllBytes(saveLocation, currentPCK.Rebuild());
// }
// }
// catch (Exception)
// {
// for (int i = 0; i < saveStructure.Nodes.Count; i++)
// currentPCK.file_entries[i].name = saveStructure.Nodes[i].Text;
// using (var ofd = new SaveFileDialog())
// {
// ofd.Filter = "PCK (Minecraft Console Package)|*.pck";
// if (ofd.ShowDialog() == DialogResult.OK)
// {
// try
// {
// File.WriteAllBytes(ofd.FileName, currentPCK.Rebuild());
// saved = true;
// MessageBox.Show("PCK Saved!");
// }
// catch (Exception)
// {
// MessageBox.Show("No PCK loaded");
// }
// }
// }
// }
//}
}
saveStructure.Dispose();//disposes temporarily made treeview
}
#endregion
#region replaces pck entry with selected file
private void replaceToolStripMenuItem_Click(object sender, EventArgs e)
{
if (treeViewMain.SelectedNode.Tag is PCKFile.FileData)//Makes sure file being replaced is an actual minefile or not null
if (treeViewMain.SelectedNode.Tag is PCKFile.FileData) //Makes sure file being replaced is an actual minefile or not null
{
PCKFile.FileData mf = (PCKFile.FileData)treeViewMain.SelectedNode.Tag; //backups minefile data for node
PCKFile.FileData mf = treeViewMain.SelectedNode.Tag as PCKFile.FileData; //backups minefile data for node
using (var ofd = new OpenFileDialog())
{
if (ofd.ShowDialog() == DialogResult.OK)
{
mf.data = File.ReadAllBytes(ofd.FileName);//overwrites minefile data with chosen files data
mf.SetData(File.ReadAllBytes(ofd.FileName)); //overwrites minefile data with chosen files data
}
}
}
saved = false;
}
#endregion
#region deletes pck entry from treeview and PCKFile.FileDatas
private void deleteFileToolStripMenuItem_Click(object sender, EventArgs e)
{
//Removes selected from current pcks minefiles list and nodes
if (treeViewMain.SelectedNode.Tag is PCKFile.FileData)
{
PCKFile.FileData mf = (PCKFile.FileData)treeViewMain.SelectedNode.Tag;
PCKFile.FileData mf = treeViewMain.SelectedNode.Tag as PCKFile.FileData;
treeViewMain.Nodes.Remove(treeViewMain.SelectedNode);
currentPCK.file_entries.Remove(mf);
}
@@ -690,13 +532,12 @@ namespace PckStudio
}
saved = false;
}
#endregion
#region renames pck entry from treeview and PCKFile.FileDatas
private void renameFileToolStripMenuItem_Click(object sender, EventArgs e)
{
TreeNode node = treeViewMain.SelectedNode;
PckStudio.rename diag = new PckStudio.rename(node);
rename diag = new rename(node);
diag.ShowDialog(this);
diag.Dispose();//diposes generated metadata adding dialog data
treeViewMain.SelectedNode.Text = Path.GetFileName(node.Name);
@@ -759,7 +600,7 @@ namespace PckStudio
if (ofd.ShowDialog() == DialogResult.OK)
{
PCKFile.FileData mf = new PCKFile.FileData(Path.GetFileName(ofd.FileName), 0);//Creates new minefile template
mf.data = File.ReadAllBytes(ofd.FileName);
mf.SetData(File.ReadAllBytes(ofd.FileName));
TreeNode add = new TreeNode(mf.name) { Tag = mf };
//Gets proper file icon for minefile
@@ -832,7 +673,7 @@ namespace PckStudio
private void createSkinToolStripMenuItem_Click(object sender, EventArgs e)
{
int i = treeViewMain.Nodes.Count - 1;//Gets index of last item in treeview
int tempIDD;//sets variables for a temporary skin/cape id
int tempIDD; //sets variables for a temporary skin/cape id
try
{
@@ -850,7 +691,10 @@ namespace PckStudio
try
{
l = new LOC(mf.data);//sets loc data
using (var stream = new MemoryStream(mf.data))
{
l = LOCFileReader.Read(stream);//sets loc data
}
}
catch
{
@@ -860,13 +704,16 @@ namespace PckStudio
}
PckStudio.addnewskin add = new PckStudio.addnewskin(currentPCK, treeViewMain, tempIDD.ToString(), l);//Sets dialog data for skin creator
add.ShowDialog();//opens skin creator
mf.data = l.Rebuild();//rebuilds loc data
using (var stream = new MemoryStream())
{
LOCFileWriter.Write(stream, l);
mf.SetData(stream.ToArray());
}
add.Dispose();//disposes generated skin creator data
saved = false;
}
#endregion
#region adds a new Audio.pck to the project
private void audiopckToolStripMenuItem_Click(object sender, EventArgs e)
{
@@ -881,7 +728,6 @@ namespace PckStudio
for (int i = 0; i < 3; i++)
{
PCKFile.FileData mf = new PCKFile.FileData("", i);
mf.data = new byte[0];
//audioPCKFile.file_entries.Add(mf);
}
PCKFile.FileData audioMF = new PCKFile.FileData("audio.pck", 8);
@@ -944,7 +790,6 @@ namespace PckStudio
treeViewToMineFiles(treeViewMain, currentPCK);
diag.Dispose();
}
#endregion
#region starts up form to create and add a animated texture
private void createAnimatedTextureToolStripMenuItem_Click(object sender, EventArgs e)
@@ -998,10 +843,13 @@ namespace PckStudio
mf = treeViewMain.SelectedNode.Tag as PCKFile.FileData;
if (mf.type == 6)
{
LOC l;
LOCFile l;
try
{
l = new LOC(mf.data);
using (var stream = new MemoryStream(mf.data))
{
l = LOCFileReader.Read(stream);//sets loc data
}
}
catch
{
@@ -1009,8 +857,12 @@ namespace PckStudio
MessageBoxIcon.Error);
return;
}
(new LOCEditor(l)).ShowDialog(); //Opens LOC Editor
mf.data = l.Rebuild(); //Rebuilds loc file with locdata in grid view after closing dialog
(new LOCEditor(l)).ShowDialog();
using (var stream = new MemoryStream())
{
LOCFileWriter.Write(stream, l);
mf.SetData(stream.ToArray());
}
}
}
@@ -1074,11 +926,11 @@ namespace PckStudio
private void treeMeta_AfterSelect(object sender, TreeViewEventArgs e)
{
comboBox1.Items.Clear(); //Resets metadata combobox of selectable entry names
var strings = (KeyValuePair<string, List<string>>)e.Node.Tag;
var strings = (Tuple<string,string>)e.Node.Tag;
foreach (var type in currentPCK.meta_data.Keys)
comboBox1.Items.Add(type);
comboBox1.Text = strings.Key;
textBox1.Text = strings.Value[0];
comboBox1.Text = strings.Item1;
textBox1.Text = strings.Item2;
}
#endregion
@@ -1386,13 +1238,11 @@ namespace PckStudio
{
Console.WriteLine("ERROR WITH RPC");
}
Directory.CreateDirectory(appData + "\\template");
if (!File.Exists(appData + "\\template\\UntitledSkinPCK.pck"))
File.WriteAllBytes(appData + "\\template\\UntitledSkinPCK.pck", Resources.UntitledSkinPCK);
DBGLabel.Visible = Program.IsDev;
#if DEBUG
DBGLabel.Visible = true;
#else
DBGLabel.Visible = false;
#endif
//Makes sure appdata exists
if (!Directory.Exists(appData))
{
@@ -1404,16 +1254,13 @@ namespace PckStudio
Directory.CreateDirectory(appData + "\\cache\\mods\\");
}
}
#endregion
#region deletes pck entires through the del key
private void treeViewMain_KeyDown(object sender, KeyEventArgs e)
{
}
#endregion
#region extracts a selected pck without opening the pck
private void treeViewMain_KeyDown(object sender, KeyEventArgs e)
{
// TODO
}
private void extractToolStripMenuItem1_Click(object sender, EventArgs e)
{
try
@@ -1424,37 +1271,34 @@ namespace PckStudio
ofd.CheckFileExists = true;
ofd.Filter = "PCK (Minecraft Wii U Package)|*.pck";
if (ofd.ShowDialog() == DialogResult.OK)
if (ofd.ShowDialog() == DialogResult.OK && sfd.ShowDialog() == DialogResult.OK)
{
if (sfd.ShowDialog() == DialogResult.OK)
PCKFile pckfile = null;
using (var fs = File.OpenRead(ofd.FileName))
{
pckfile = PCKFileReader.Read(fs, LittleEndianCheckBox.Checked);
}
foreach (PCKFile.FileData mf in pckfile.file_entries)
{
PCKFile pckfile = null;
using (var fs = File.OpenRead(ofd.FileName))
{
pckfile = PCKFileReader.Read(fs, LittleEndianCheckBox.Checked);
}
foreach (PCKFile.FileData mf in pckfile.file_entries)
foreach (var entry in mf.properties)
{
foreach (var entry in mf.properties)
if (entry.Item1 == "LOCK" && new pckLocked(entry.Item2).ShowDialog() != DialogResult.OK) // Check for lock on PCK File
{
if (entry.Item1 == "LOCK" && new pckLocked(entry.Item2).ShowDialog() != DialogResult.OK) // Check for lock on PCK File
{
return; // cancel extraction if password not provided
}
return; // cancel extraction if password not provided
}
FileInfo file = new FileInfo(sfd.SelectedPath + @"\" + mf.name);
file.Directory.Create(); // If the directory already exists, this method does nothing.
File.WriteAllBytes(sfd.SelectedPath + @"\" + mf.name, mf.data); //writes minefile to file
//attempts to generate reimportable metadata file out of minefiles metadata
string metaData = "";
foreach (var entry in mf.properties)
{
metaData += entry.Item1 + ":" + entry.Item2 + Environment.NewLine;
}
File.WriteAllText(sfd.SelectedPath + @"\" + mf.name + ".txt", metaData);
}
FileInfo file = new FileInfo(sfd.SelectedPath + @"\" + mf.name);
file.Directory.Create(); // If the directory already exists, this method does nothing.
File.WriteAllBytes(sfd.SelectedPath + @"\" + mf.name, mf.data); //writes minefile to file
//attempts to generate reimportable metadata file out of minefiles metadata
string metaData = "";
foreach (var entry in mf.properties)
{
metaData += $"{entry.Item1}: {entry.Item2}{Environment.NewLine}";
}
File.WriteAllText(sfd.SelectedPath + @"\" + mf.name + ".txt", metaData);
}
}
} catch (Exception)
@@ -1462,37 +1306,33 @@ namespace PckStudio
MessageBox.Show("Unsupported PCK");
}
}
#endregion
#region deletes metadata entries through the del key
#region deletes metadata entries through the del key
private void treeMeta_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Delete)//makes sure pressed key was del
if (e.KeyData == Keys.Delete && treeMeta.SelectedNode != null)//makes sure pressed key was del
{
if (treeMeta.SelectedNode != null)//makes sure selected node is a minefile
//removes selected treemeta entry
file.properties.Remove((Tuple<string, string>)treeMeta.SelectedNode.Tag);
treeMeta.Nodes.Remove(treeMeta.SelectedNode);
//reloads treemeta data
treeMeta.Nodes.Clear();
foreach (var type in currentPCK.meta_data.Keys)
comboBox1.Items.Add(type);
foreach (var entry in file.properties)
{
//removes selected treemeta entry
file.properties.Remove((Tuple<string, string>)treeMeta.SelectedNode.Tag);
treeMeta.Nodes.Remove(treeMeta.SelectedNode);
//reloads treemeta data
treeMeta.Nodes.Clear();
foreach (var type in currentPCK.meta_data.Keys)
comboBox1.Items.Add(type);
foreach (var entry in file.properties)
{
TreeNode meta = new TreeNode(entry.Item1);
meta.Tag = entry;
treeMeta.Nodes.Add(meta);
}
TreeNode meta = new TreeNode(entry.Item1);
meta.Tag = entry;
treeMeta.Nodes.Add(meta);
}
saved = false;
}
saved = false;
}
#endregion
#endregion
#region imports a folder of skins to pck
#region imports a folder of skins to pck
private void importExtractedSkinsFolder(object sender, EventArgs e)
{
FolderBrowserDialog contents = new FolderBrowserDialog();//Creates folder browser instance
@@ -1535,7 +1375,7 @@ namespace PckStudio
type = 1;
}
PCKFile.FileData mfNew = new PCKFile.FileData("", type); //new minefile template
mfNew.data = File.ReadAllBytes(contents.SelectedPath + @"\" + file.Name.Remove(file.Name.Length - 4, 4) + ".png");//sets minefile data to image data of current skin
mfNew.SetData(File.ReadAllBytes(contents.SelectedPath + @"\" + file.Name.Remove(file.Name.Length - 4, 4) + ".png"));//sets minefile data to image data of current skin
TreeNode skin = new TreeNode(); //create template treenode for minefile
@@ -1606,11 +1446,14 @@ namespace PckStudio
//creates displayname id in loc file
if (locNameId != "" && locName != "")
{
LOC l;
LOCFile l;
try
{
l = new LOC(mfLoc.data);
using (var stream = new MemoryStream(mf.data))
{
l = LOCFileReader.Read(stream);//sets loc data
}
}
catch
{
@@ -1618,15 +1461,13 @@ namespace PckStudio
return;
}
displayId dis = new displayId();
dis.id = locNameId;
dis.defaultName = locName;
l.AddEntry(locThemeId, locTheme);
l.ids.names.Add(dis.id);
foreach (LOC.Language lo in l.langs)
lo.names.Add(dis.defaultName);
mfLoc.data = l.Rebuild();
using (var stream = new MemoryStream())
{
LOCFileWriter.Write(stream, l);
mfLoc.SetData(stream.ToArray());
}
locNameId = "";
locName = "";
}
@@ -1634,11 +1475,14 @@ namespace PckStudio
//creates metadata id in loc file
if (locThemeId != "" && locTheme != "")
{
LOC l;
LOCFile l;
try
{
l = new LOC(mfLoc.data);
using (var stream = new MemoryStream(mfLoc.data))
{
l = LOCFileReader.Read(stream);//sets loc data
}
}
catch
{
@@ -1646,16 +1490,12 @@ namespace PckStudio
return;
}
displayId b = new displayId();
b.id = locThemeId;
b.defaultName = locTheme;
l.ids.names.Add(b.id);
foreach (LOC.Language lo in l.langs)
lo.names.Add(b.defaultName);
mfLoc.data = l.Rebuild();
l.AddEntry(locThemeId, locTheme);
using (var stream = new MemoryStream(mf.data))
{
LOCFileWriter.Write(stream, l);
mfLoc.SetData(stream.ToArray());
}
locThemeId = "";
locTheme = "";
}
@@ -1681,9 +1521,9 @@ namespace PckStudio
contents.Dispose();//disposes temporary data
saved = false;
}
#endregion
#endregion
#region imports individual skin to pck
#region imports individual skin to pck
private void importSkin(object sender, EventArgs e)
{
OpenFileDialog contents = new OpenFileDialog();
@@ -1699,7 +1539,7 @@ namespace PckStudio
Import.Text = skinNameImport.Remove(skinNameImport.Length - 4, 4); //gets file name without extension
byte[] data = File.ReadAllBytes(contents.FileName.Remove(contents.FileName.Length - 4, 4));
PCKFile.FileData mfNew = new PCKFile.FileData("no_name", 0);
mfNew.data = data;//sets minefile data to image data of current skin
mfNew.SetData(data); //sets minefile data to image data of current skin
bool mashupStructure = false;//creates variable to indicate wether current pck skin structure is mashup or regular skin
int skinsFolder = 0;//temporary index for skins folder for if structure is mashup
@@ -1781,27 +1621,26 @@ namespace PckStudio
//creates displayname id in loc file
if (locNameId != "" && locName != "")
{
LOC l;
LOCFile l;
try
{
l = new LOC(mfLoc.data);
using (var stream = new MemoryStream(mf.data))
{
l = LOCFileReader.Read(stream);//sets loc data
}
}
catch
{
MessageBox.Show("No localization data found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
displayId dis = new displayId();
dis.id = locNameId;
dis.defaultName = locName;
l.ids.names.Add(dis.id);
foreach (LOC.Language lo in l.langs)
lo.names.Add(dis.defaultName);
mfLoc.data = l.Rebuild();
l.AddEntry(locThemeId, locTheme);
using (var stream = new MemoryStream())
{
LOCFileWriter.Write(stream, l);
mfLoc.SetData(stream.ToArray());
}
locNameId = "";
locName = "";
}
@@ -1809,28 +1648,27 @@ namespace PckStudio
//creates metadata id in loc file
if (locThemeId != "" && locTheme != "")
{
LOC l;
LOCFile l;
try
{
l = new LOC(mfLoc.data);
using (var stream = new MemoryStream(mf.data))
{
l = LOCFileReader.Read(stream);//sets loc data
}
}
catch
{
MessageBox.Show("No localization data found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
l.AddEntry(locThemeId, locTheme);
displayId b = new displayId();
b.id = locThemeId;
b.defaultName = locTheme;
l.ids.names.Add(b.id);
foreach (LOC.Language lo in l.langs)
lo.names.Add(b.defaultName);
mfLoc.data = l.Rebuild();
using (var stream = new MemoryStream())
{
LOCFileWriter.Write(stream, l);//sets loc data
mfLoc.SetData(stream.ToArray());
}
locThemeId = "";
locTheme = "";
}
@@ -1859,9 +1697,9 @@ namespace PckStudio
contents.Dispose();//disposes temporary data
saved = false;
}
#endregion
#endregion
#region adds folder/directory entry to pck
#region adds folder/directory entry to pck
private void folderToolStripMenuItem_Click(object sender, EventArgs e)
{
TreeNode NEW = new TreeNode();
@@ -1878,44 +1716,43 @@ namespace PckStudio
}
saved = false;
}
#endregion
#endregion
#region opens pck installation page
#region opens pck installation page
private void installationToolStripMenuItem_Click(object sender, EventArgs e)
{
//System.Diagnostics.Process.Start(hosturl + "pckStudio#install");
}
#endregion
#endregion
#region opens pck binka tutorial video
#region opens pck binka tutorial video
private void binkaConversionToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("https://www.youtube.com/watch?v=v6EYr4zc7rI");
}
#endregion
#endregion
#region opens pck donation page
#region opens pck donation page
private void donateToolStripMenuItem_Click(object sender, EventArgs e)
{
}
#endregion
#endregion
#region opens pck faq page
#region opens pck faq page
private void fAQToolStripMenuItem1_Click(object sender, EventArgs e)
{
//System.Diagnostics.Process.Start(hosturl + "pckStudio#faq");
}
#endregion
#endregion
#region items class for use in bedrock skin conversion
#region converts and ports all skins in pck to mc bedrock format
// items class for use in bedrock skin conversion
public class Item
{
public string Id { get; set; }
public string Name { get; set; }
}
#endregion
#region converts and ports all skins in pck to mc bedrock format
private void convertToBedrockToolStripMenuItem_Click(object sender, EventArgs e)
{
if (openedPCKS.Visible == true && MessageBox.Show("Convert " + openedPCKS.SelectedTab.Text + " to a Bedrock Edition format?", "Convert", MessageBoxButtons.YesNo, MessageBoxIcon.None) == DialogResult.Yes)
@@ -2910,9 +2747,9 @@ namespace PckStudio
return destImage;
}
#endregion
#endregion
#region 3ds feature in testing
#region 3ds feature in testing
private struct loadedTexture
{
@@ -3148,9 +2985,9 @@ namespace PckStudio
}
}
#endregion
#endregion
#region Tool/MenuStrips
#region Tool/MenuStrips
private void openToolStripMenuItem1_Click(object sender, EventArgs e)
{
@@ -3287,7 +3124,8 @@ namespace PckStudio
private void buttonEditModel_Click(object sender, EventArgs e)
{
PCKFile.FileData file = (PCKFile.FileData)treeViewMain.SelectedNode.Tag;
if (treeViewMain.SelectedNode.Tag == null || !(treeViewMain.SelectedNode.Tag is PCKFile.FileData)) return;
PCKFile.FileData file = treeViewMain.SelectedNode.Tag as PCKFile.FileData;
if (Path.GetExtension(file.name) == ".png")
{
@@ -3355,12 +3193,15 @@ namespace PckStudio
}
}
if (Path.GetExtension(file.name) == ".loc")
if (file.type == 6) // .loc file
{
LOC l;
LOCFile l;
try
{
l = new LOC(file.data);
using (var stream = new MemoryStream(file.data))
{
l = LOCFileReader.Read(stream);//sets loc data
}
}
catch
{
@@ -3368,12 +3209,17 @@ namespace PckStudio
MessageBoxIcon.Error);
return;
}
(new LOCEditor(l)).ShowDialog();//Opens LOC Editor
//mf.data = l.Rebuild();//Rebuilds loc file with locdata in grid view after closing dialog
var locEditor = new LOCEditor(l); //Opens LOC Editor
locEditor.ShowDialog();
using (var stream = new MemoryStream())
{
LOCFileWriter.Write(stream, l);
mf.SetData(stream.ToArray());
}
}
//Checks to see if selected minefile is a col file
if (Path.GetExtension(file.name) == ".col")
if (file.type == 9) // .col file
{
//MessageBox.Show(".COL Editor Coming Soon!");
@@ -3408,26 +3254,26 @@ namespace PckStudio
private void FormMain_FormClosed(object sender, FormClosedEventArgs e)
{
if (saved == false)
if (!saved)
{
if (MessageBox.Show("Save PCK?", "Unsaved PCK", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
if (saveLocation == appData + @"\templates\UntitledSkinPCK.pck")
if (isTemplateFile)
{
save("Save As");
save();
}
else
{
save("Save");
save();
}
}
}
if (needsUpdate)
{
Process UPDATE = new Process();//sets up updater
UPDATE.StartInfo.FileName = appData + @"\nobleUpdater.exe";//updater program path
UPDATE.Start();//starts updater
Application.Exit();//closes PCK Studio to let updatear finish the job
Process UPDATE = new Process(); //sets up updater
UPDATE.StartInfo.FileName = appData + @"\nobleUpdater.exe"; //updater program path
UPDATE.Start(); //starts updater
Application.Exit(); //closes PCK Studio to let updatear finish the job
}
}
@@ -3462,12 +3308,12 @@ namespace PckStudio
private void savePCK(object sender, EventArgs e)
{
save("Save");
save();
}
private void saveAsPCK(object sender, EventArgs e)
{
save("Save As");
save();
}
private void timer1_Tick(object sender, EventArgs e)

View File

@@ -53,15 +53,14 @@ namespace PckStudio
{
if (comboBox1.Text == "All")
{
MessageBox.Show("TODO!!!!");
//foreach (var node in treeMeta.Nodes)
//{
// foreach (PCKFile.FileData mf in currentPCK.file_entries)
// {
// mf.properties.Add(node.Text, node.Tag);
// }
//}
//MessageBox.Show("Data Added to All Entries");
foreach (TreeNode node in treeMeta.Nodes)
{
foreach (PCKFile.FileData mf in currentPCK.file_entries)
{
mf.properties.Add(new Tuple<string, string>(node.Text, node.Tag.ToString()));
}
}
MessageBox.Show("Data Added to All Entries");
}
else if (comboBox1.Text == "64x64")
{
@@ -76,7 +75,7 @@ namespace PckStudio
{
if (Image.FromStream(png).Size.Height == Image.FromStream(png).Size.Width)
{
mf.properties.Add(treeMeta.Nodes[i].Text, treeMeta.Nodes[i].Tag.ToString());
mf.properties.Add(new Tuple<string, string>(treeMeta.Nodes[i].Text, treeMeta.Nodes[i].Tag.ToString()));
}
}
}
@@ -99,7 +98,7 @@ namespace PckStudio
{
if (Image.FromStream(png).Size.Height == Image.FromStream(png).Size.Width / 2)
{
mf.properties.Add(treeMeta.Nodes[i].Text, treeMeta.Nodes[i].Tag.ToString());
mf.properties.Add(new Tuple<string, string>(treeMeta.Nodes[i].Text, treeMeta.Nodes[i].Tag.ToString() ));
}
}
}
@@ -119,7 +118,7 @@ namespace PckStudio
{
if (Path.GetExtension(mf.name) == ".png")
{
mf.properties.Add(treeMeta.Nodes[i].Text, treeMeta.Nodes[i].Tag.ToString());
mf.properties.Add(new Tuple<string, string>(treeMeta.Nodes[i].Text, treeMeta.Nodes[i].Tag.ToString() ));
}
}
i += 1;

View File

@@ -121,7 +121,7 @@
<data name="addEntryToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vgAADr4B6kKxwAAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMkMEa+wAAABSSURBVDhP5c0x
vQAADr0BR/uQrQAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMkMEa+wAAABSSURBVDhP5c0x
DsAgDENRxt7/wmkNSpRGf0CCCZAegxNMM7MlGMp3dIU6dxhKf/QMNxRogeQC8ivw5Vn7C0heJlFA+kL5
jWAohxRkde4wnGftBS90axNmphIGAAAAAElFTkSuQmCC
</value>
@@ -135,7 +135,7 @@
<data name="deleteEntryToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vgAADr4B6kKxwAAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMkMEa+wAAACESURBVDhPlY0B
vQAADr0BR/uQrQAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMkMEa+wAAACESURBVDhPlY0B
DoAgDAP3Dj7r09WTkqGUgJfUxtrOmHFEnL0U76FBqW8PZXmk/9uONEsIb3gsNRzoL/+R5hWC759mGsbQ
DnzdZbhmiSvhLsM1S1wJdxmuWeJKuMtwzRJXwl2Ga5a4Eu4yXLPElXCX4Zol/WCl6YGdI62n2Zv2cSXV
byIunLh7mD2ySLcAAAAASUVORK5CYII=

View File

@@ -117,13 +117,182 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="&gt;&gt;button1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="comboBox2.Size" type="System.Drawing.Size, System.Drawing">
<value>141, 21</value>
</data>
<data name="&gt;&gt;label2.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="label1.Text" xml:space="preserve">
<value>Apply to</value>
</data>
<data name="&gt;&gt;label3.ZOrder" xml:space="preserve">
<data name="&gt;&gt;label1.Name" xml:space="preserve">
<value>label1</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>315, 283</value>
</data>
<data name="&gt;&gt;comboBox1.Name" xml:space="preserve">
<value>comboBox1</value>
</data>
<data name="&gt;&gt;comboBox2.Name" xml:space="preserve">
<value>comboBox2</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>MetroFramework.Forms.MetroForm, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a</value>
</data>
<data name="label3.Location" type="System.Drawing.Point, System.Drawing">
<value>52, 212</value>
</data>
<data name="&gt;&gt;textBox1.Name" xml:space="preserve">
<value>textBox1</value>
</data>
<data name="addEntryToolStripMenuItem.Text" xml:space="preserve">
<value>Add Entry</value>
</data>
<data name="deleteEntryToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vQAADr0BR/uQrQAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMkMEa+wAAACESURBVDhPlY0B
DoAgDAP3Dj7r09WTkqGUgJfUxtrOmHFEnL0U76FBqW8PZXmk/9uONEsIb3gsNRzoL/+R5hWC759mGsbQ
DnzdZbhmiSvhLsM1S1wJdxmuWeJKuMtwzRJXwl2Ga5a4Eu4yXLPElXCX4Zol/WCl6YGdI62n2Zv2cSXV
byIunLh7mD2ySLcAAAAASUVORK5CYII=
</value>
</data>
<data name="$this.Text" xml:space="preserve">
<value>Advanced</value>
</data>
<data name="deleteEntryToolStripMenuItem.Text" xml:space="preserve">
<value>Delete Entry</value>
</data>
<data name="&gt;&gt;addEntryToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="button1.FlatStyle" type="System.Windows.Forms.FlatStyle, System.Windows.Forms">
<value>Popup</value>
</data>
<data name="&gt;&gt;label2.Name" xml:space="preserve">
<value>label2</value>
</data>
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
<value>CenterParent</value>
</data>
<data name="&gt;&gt;label3.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;label2.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="label1.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label1.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="&gt;&gt;deleteEntryToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="comboBox1.Items2" xml:space="preserve">
<value>64x32</value>
</data>
<data name="label2.Size" type="System.Drawing.Size, System.Drawing">
<value>57, 13</value>
</data>
<data name="label2.Text" xml:space="preserve">
<value>Entry Data</value>
</data>
<data name="label2.Location" type="System.Drawing.Point, System.Drawing">
<value>208, 212</value>
</data>
<data name="&gt;&gt;comboBox2.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="label3.TabIndex" type="System.Int32, mscorlib">
<value>11</value>
</data>
<data name="&gt;&gt;button1.ZOrder" xml:space="preserve">
<value>5</value>
</data>
<data name="&gt;&gt;comboBox1.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="addEntryToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vQAADr0BR/uQrQAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMkMEa+wAAABSSURBVDhP5c0x
DsAgDENRxt7/wmkNSpRGf0CCCZAegxNMM7MlGMp3dIU6dxhKf/QMNxRogeQC8ivw5Vn7C0heJlFA+kL5
jWAohxRkde4wnGftBS90axNmphIGAAAAAElFTkSuQmCC
</value>
</data>
<data name="&gt;&gt;treeMeta.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
<value>45, 13</value>
</data>
<data name="contextMenuStrip2.Size" type="System.Drawing.Size, System.Drawing">
<value>138, 48</value>
</data>
<data name="&gt;&gt;contextMenuStrip2.Type" xml:space="preserve">
<value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;addEntryToolStripMenuItem.Name" xml:space="preserve">
<value>addEntryToolStripMenuItem</value>
</data>
<data name="&gt;&gt;button1.Name" xml:space="preserve">
<value>button1</value>
</data>
<data name="&gt;&gt;textBox1.Type" xml:space="preserve">
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;button1.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;treeMeta.Type" xml:space="preserve">
<value>System.Windows.Forms.TreeView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;comboBox2.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="label1.Location" type="System.Drawing.Point, System.Drawing">
<value>20, 259</value>
</data>
<data name="&gt;&gt;deleteEntryToolStripMenuItem.Name" xml:space="preserve">
<value>deleteEntryToolStripMenuItem</value>
</data>
<data name="label3.Size" type="System.Drawing.Size, System.Drawing">
<value>58, 13</value>
</data>
<data name="button1.Text" xml:space="preserve">
<value>Apply</value>
</data>
<data name="&gt;&gt;comboBox1.ZOrder" xml:space="preserve">
<value>7</value>
</data>
<data name="button1.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<data name="comboBox1.Items" xml:space="preserve">
<value>All</value>
</data>
<data name="button1.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="treeMeta.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="comboBox1.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="&gt;&gt;comboBox2.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAYAEBAAAAEAIABoBAAAZgAAACAgAAABACAAqBAAAM4EAAAwMAAAAQAgAKglAAB2FQAAQEAAAAEA
@@ -1849,273 +2018,104 @@
AABJRU5ErkJggg==
</value>
</data>
<data name="&gt;&gt;comboBox1.Name" xml:space="preserve">
<value>comboBox1</value>
</data>
<data name="textBox1.Location" type="System.Drawing.Point, System.Drawing">
<value>164, 228</value>
</data>
<data name="&gt;&gt;treeMeta.ZOrder" xml:space="preserve">
<value>8</value>
</data>
<data name="&gt;&gt;button1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;button1.ZOrder" xml:space="preserve">
<value>5</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="button1.FlatStyle" type="System.Windows.Forms.FlatStyle, System.Windows.Forms">
<value>Popup</value>
</data>
<data name="button1.Text" xml:space="preserve">
<value>Apply</value>
</data>
<data name="&gt;&gt;label1.Name" xml:space="preserve">
<value>label1</value>
</data>
<data name="&gt;&gt;textBox1.Type" xml:space="preserve">
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;contextMenuStrip2.Type" xml:space="preserve">
<value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;label3.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;addEntryToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="addEntryToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vgAADr4B6kKxwAAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMkMEa+wAAABSSURBVDhP5c0x
DsAgDENRxt7/wmkNSpRGf0CCCZAegxNMM7MlGMp3dIU6dxhKf/QMNxRogeQC8ivw5Vn7C0heJlFA+kL5
jWAohxRkde4wnGftBS90axNmphIGAAAAAElFTkSuQmCC
</value>
</data>
<data name="label3.Size" type="System.Drawing.Size, System.Drawing">
<value>58, 13</value>
</data>
<data name="&gt;&gt;deleteEntryToolStripMenuItem.Name" xml:space="preserve">
<value>deleteEntryToolStripMenuItem</value>
</data>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>6, 13</value>
</data>
<data name="&gt;&gt;label3.Name" xml:space="preserve">
<value>label3</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="label3.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
<value>CenterParent</value>
</data>
<data name="&gt;&gt;label1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;comboBox2.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="label3.Location" type="System.Drawing.Point, System.Drawing">
<value>52, 212</value>
</data>
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="&gt;&gt;label1.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="button1.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<data name="label1.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="label2.TabIndex" type="System.Int32, mscorlib">
<value>12</value>
</data>
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
<value>45, 13</value>
</data>
<data name="textBox1.Size" type="System.Drawing.Size, System.Drawing">
<value>139, 20</value>
</data>
<data name="&gt;&gt;deleteEntryToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;textBox1.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="comboBox2.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 227</value>
</data>
<data name="comboBox1.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="&gt;&gt;comboBox1.ZOrder" xml:space="preserve">
<value>7</value>
</data>
<data name="&gt;&gt;label2.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="comboBox2.Size" type="System.Drawing.Size, System.Drawing">
<value>141, 21</value>
</data>
<data name="button1.Location" type="System.Drawing.Point, System.Drawing">
<value>228, 254</value>
</data>
<data name="&gt;&gt;label2.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="deleteEntryToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>137, 22</value>
</data>
<data name="label2.Size" type="System.Drawing.Size, System.Drawing">
<value>57, 13</value>
</data>
<data name="&gt;&gt;textBox1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;button1.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;textBox1.Name" xml:space="preserve">
<value>textBox1</value>
</data>
<data name="button1.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="contextMenuStrip2.Size" type="System.Drawing.Size, System.Drawing">
<value>138, 48</value>
</data>
<data name="&gt;&gt;treeMeta.Name" xml:space="preserve">
<value>treeMeta</value>
</data>
<data name="addEntryToolStripMenuItem.Text" xml:space="preserve">
<value>Add Entry</value>
</data>
<data name="&gt;&gt;contextMenuStrip2.Name" xml:space="preserve">
<value>contextMenuStrip2</value>
</data>
<data name="label3.Text" xml:space="preserve">
<value>Entry Type</value>
</data>
<data name="deleteEntryToolStripMenuItem.Text" xml:space="preserve">
<value>Delete Entry</value>
</data>
<data name="&gt;&gt;comboBox2.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;comboBox2.Name" xml:space="preserve">
<value>comboBox2</value>
</data>
<data name="comboBox1.Size" type="System.Drawing.Size, System.Drawing">
<value>82, 21</value>
</data>
<data name="treeMeta.Size" type="System.Drawing.Size, System.Drawing">
<value>291, 142</value>
</data>
<data name="&gt;&gt;label2.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="comboBox1.Items3" xml:space="preserve">
<value>PNG Files</value>
</data>
<data name="&gt;&gt;button1.Name" xml:space="preserve">
<value>button1</value>
</data>
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="treeMeta.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="comboBox1.Location" type="System.Drawing.Point, System.Drawing">
<value>71, 256</value>
</data>
<data name="label1.AutoSize" type="System.Boolean, mscorlib">
<data name="&gt;&gt;label1.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="comboBox2.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 227</value>
</data>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>6, 13</value>
</data>
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="button1.Location" type="System.Drawing.Point, System.Drawing">
<value>228, 254</value>
</data>
<data name="label2.TabIndex" type="System.Int32, mscorlib">
<value>12</value>
</data>
<data name="label3.Text" xml:space="preserve">
<value>Entry Type</value>
</data>
<data name="&gt;&gt;label3.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;textBox1.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="textBox1.Size" type="System.Drawing.Size, System.Drawing">
<value>139, 20</value>
</data>
<data name="&gt;&gt;textBox1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="&gt;&gt;label2.Name" xml:space="preserve">
<value>label2</value>
<data name="&gt;&gt;contextMenuStrip2.Name" xml:space="preserve">
<value>contextMenuStrip2</value>
</data>
<data name="textBox1.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="deleteEntryToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vgAADr4B6kKxwAAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMkMEa+wAAACESURBVDhPlY0B
DoAgDAP3Dj7r09WTkqGUgJfUxtrOmHFEnL0U76FBqW8PZXmk/9uONEsIb3gsNRzoL/+R5hWC759mGsbQ
DnzdZbhmiSvhLsM1S1wJdxmuWeJKuMtwzRJXwl2Ga5a4Eu4yXLPElXCX4Zol/WCl6YGdI62n2Zv2cSXV
byIunLh7mD2ySLcAAAAASUVORK5CYII=
</value>
</data>
<data name="comboBox1.Items2" xml:space="preserve">
<value>64x32</value>
<data name="treeMeta.Size" type="System.Drawing.Size, System.Drawing">
<value>291, 142</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>AdvancedOptions</value>
</data>
<data name="label1.Location" type="System.Drawing.Point, System.Drawing">
<value>20, 259</value>
<data name="deleteEntryToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>137, 22</value>
</data>
<data name="$this.Text" xml:space="preserve">
<value>Advanced</value>
<data name="&gt;&gt;label3.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="addEntryToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>137, 22</value>
</data>
<data name="label2.Text" xml:space="preserve">
<value>Entry Data</value>
<data name="comboBox1.Items1" xml:space="preserve">
<value>64x64</value>
</data>
<data name="label3.TabIndex" type="System.Int32, mscorlib">
<value>11</value>
<data name="label3.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="&gt;&gt;comboBox2.ZOrder" xml:space="preserve">
<value>3</value>
<data name="&gt;&gt;label1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="label2.Location" type="System.Drawing.Point, System.Drawing">
<value>208, 212</value>
<data name="&gt;&gt;label2.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;treeMeta.Name" xml:space="preserve">
<value>treeMeta</value>
</data>
<data name="comboBox2.TabIndex" type="System.Int32, mscorlib">
<value>10</value>
</data>
<data name="&gt;&gt;comboBox1.Parent" xml:space="preserve">
<value>$this</value>
<data name="comboBox1.Items3" xml:space="preserve">
<value>PNG Files</value>
</data>
<data name="comboBox1.Items" xml:space="preserve">
<value>All</value>
<data name="&gt;&gt;label3.Name" xml:space="preserve">
<value>label3</value>
</data>
<data name="&gt;&gt;comboBox1.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;addEntryToolStripMenuItem.Name" xml:space="preserve">
<value>addEntryToolStripMenuItem</value>
</data>
<data name="&gt;&gt;treeMeta.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>315, 283</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>MetroFramework.Forms.MetroForm, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a</value>
</data>
<data name="&gt;&gt;treeMeta.Type" xml:space="preserve">
<value>System.Windows.Forms.TreeView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="&gt;&gt;treeMeta.ZOrder" xml:space="preserve">
<value>8</value>
</data>
<data name="treeMeta.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 63</value>
</data>
<data name="comboBox1.Items1" xml:space="preserve">
<value>64x64</value>
<data name="&gt;&gt;comboBox1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;label3.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="textBox1.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="comboBox1.Size" type="System.Drawing.Size, System.Drawing">
<value>82, 21</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
@@ -2123,7 +2123,4 @@
<metadata name="contextMenuStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>ja</value>
</metadata>
</root>

View File

@@ -35,7 +35,7 @@ namespace PckStudio
foreach (var entry in file.properties)
{
TreeNode meta = new TreeNode(entry.Key);
TreeNode meta = new TreeNode(entry.Item1);
meta.Tag = entry;
treeView1.Nodes.Add(meta);
@@ -70,7 +70,7 @@ namespace PckStudio
private void addEntryToolStripMenuItem_Click(object sender, EventArgs e)
{
file.properties.Add("Replace me", "Or it won't save");
file.properties.Add(new Tuple<string, string>("Replace me", "Or it won't save"));
TreeNode t = new TreeNode("temp name");
treeView1.Nodes.Add(t);
renameProperly();
@@ -82,7 +82,7 @@ namespace PckStudio
if (treeView1.SelectedNode != null)
{
var temp = (string)treeView1.SelectedNode.Tag;
file.properties.Remove(temp);
//file.properties.Remove(temp);
treeView1.Nodes.Remove(treeView1.SelectedNode);
}
}

View File

@@ -24,7 +24,7 @@ namespace PckStudio
private void button1_Click(object sender, EventArgs e)
{
file.properties.Add(textBox1.Text, textBox2.Text);
file.properties.Add(new Tuple<string, string>(textBox1.Text, textBox2.Text ));
Close();
}
}

View File

@@ -29,7 +29,7 @@ namespace PckStudio
add.Tag = textBox2.Text;
treeMeta.Nodes.Add(add);
this.Close();
Close();
}
private void addMetaAdvanced_Load(object sender, EventArgs e)

View File

@@ -20,7 +20,7 @@ namespace PckStudio
{
PCKFile currentPCK;
DataTable tbl;
LOC currentLoc;
LOCFile currentLoc;
PCKFile.FileData mf = null;
PCKFile.FileData mfc = null;
TreeView treeView1;
@@ -44,12 +44,12 @@ namespace PckStudio
string skinid;
List<object[]> generatedModel = new List<object[]>();
public addnewskin(PCKFile currentPCKIn, TreeView treeView1In, string tempIDIn, LOC loc)
public addnewskin(PCKFile currentPCKIn, TreeView treeView1In, string tempIDIn, LOCFile loc)
{
InitializeComponent();
mf = new PCKFile.FileData(0);
mfc = new PCKFile.FileData(0);
mf = new PCKFile.FileData("", 0);
mfc = new PCKFile.FileData("", 0);
currentLoc = loc;
tbl = new DataTable();
tbl.Columns.Add(new DataColumn("Language") { ReadOnly = true });
@@ -149,7 +149,7 @@ namespace PckStudio
buttonDone.Enabled = true;
labelSelectTexture.Visible = false;
mf.data = File.ReadAllBytes(ofd);
mf.SetData(File.ReadAllBytes(ofd));
}
public class displayId
@@ -297,7 +297,7 @@ namespace PckStudio
pictureBoxWithInterpolationMode1.InterpolationMode = InterpolationMode.NearestNeighbor;
pictureBoxWithInterpolationMode1.Image = Image.FromFile(ofd1.FileName);
mfc.data = File.ReadAllBytes(ofd1.FileName);
mfc.SetData(File.ReadAllBytes(ofd1.FileName));
contextMenuCape.Items[0].Text = "Replace";
}
@@ -334,11 +334,11 @@ namespace PckStudio
capePath.Text = "CAPEPATH";
capePath.Tag = "dlccape" + textSkinID.Text + ".png";
mf.properties.Add(capePath.Text, capePath.Tag.ToString());
mf.properties.Add(new Tuple<string, string>(capePath.Text, capePath.Tag.ToString()));
currentPCK.file_entries.Add(mfc);
mfc.size = mf.data.Length; if (mashupStructure == true)
if (mashupStructure == true)
{
mfc.name = "Skins/" + "dlccape" + textSkinID.Text + ".png";
}
@@ -381,9 +381,9 @@ namespace PckStudio
skinName.Tag = textSkinName.Text;
anim.Text = "ANIM";
mf.properties.Add(skinName.Text, textSkinName.Text);
mf.properties.Add(new Tuple<string, string>(skinName.Text, textSkinName.Text));
mf.properties.Add(displayNameId.Text, "IDS_dlcskin" + textSkinID.Text + "_DISPLAYNAME");
mf.properties.Add(new Tuple<string, string>(displayNameId.Text, "IDS_dlcskin" + textSkinID.Text + "_DISPLAYNAME" ));
if (comboBoxSkinType.Text == "Default (64x32)")
@@ -395,11 +395,11 @@ namespace PckStudio
anim.Tag = "0x80000";
object[] ANIM = { anim.Text, anim.Tag };
mf.properties.Add("ANIM", "0x80000");
mf.properties.Add(new Tuple<string, string>("ANIM", "0x80000"));
}
else if (comboBoxSkinType.Text == "Steve (64x64)" && skinType != "64x32")
{
mf.properties.Add("ANIM", "0x40000");
mf.properties.Add(new Tuple<string, string>("ANIM", "0x40000"));
}
else if (comboBoxSkinType.Text == "Custom")
{
@@ -408,7 +408,7 @@ namespace PckStudio
//{
// mf.properties.Add((object[])item);
//}
mf.properties.Add("ANIM", "0x7ff5fc10");
mf.properties.Add(new Tuple<string, string>("ANIM", "0x7ff5fc10"));
}
if (generatedModel != null)
{
@@ -417,13 +417,12 @@ namespace PckStudio
if (themeName.Tag.ToString() != "")
{
mf.properties.Add(themeName.Text, themeName.Tag.ToString());
mf.properties.Add(new Tuple<string, string>(themeName.Text, themeName.Tag.ToString() ));
}
mf.properties.Add("GAME_FLAGS", "0x18");
mf.properties.Add("FREE", "1");
mf.properties.Add(new Tuple<string, string>("GAME_FLAGS", "0x18"));
mf.properties.Add(new Tuple<string, string>("FREE", "1"));
mf.size = mf.data.Length;
if (mashupStructure == true)
{
mf.name = "Skins/" + "dlcskin" + textSkinID.Text + ".png";
@@ -453,20 +452,20 @@ namespace PckStudio
d.id = "IDS_dlcskin" + textSkinID.Text + "_DISPLAYNAME";
d.defaultName = textSkinName.Text;
currentLoc.ids.names.Add(d.id);
//currentLoc.ids.names.Add(d.id);
foreach (LOC.Language l in currentLoc.langs)
l.names.Add(d.defaultName);
//foreach (LOC.Language l in currentLoc.langs)
// l.names.Add(d.defaultName);
displayId b = new displayId();
b.id = "IDS_dlcskin" + textSkinID.Text + "_THEMENAME";
b.defaultName = textThemeName.Text;
currentLoc.ids.names.Add(b.id);
//currentLoc.ids.names.Add(b.id);
foreach (LOC.Language l in currentLoc.langs)
l.names.Add(b.defaultName);
this.Close();
//foreach (LOC.Language l in currentLoc.langs)
// l.names.Add(b.defaultName);
Close();
}
else
{
@@ -559,7 +558,7 @@ namespace PckStudio
skinType = "64x64";
}
mf.data = File.ReadAllBytes(ofd);
mf.SetData(File.ReadAllBytes(ofd));
}
catch (Exception ex)
{

View File

@@ -29,9 +29,6 @@ namespace PckStudio
bool autoTexture = true;
int textureW = 0;
int textureH = 0;
Color backgroundColor = Color.Black;
ListViewItem selected;
@@ -40,117 +37,87 @@ namespace PckStudio
private void checkSelect()
{
//Deciphers wether to enable/disable things based on wether an item is selected or not
if (listViewBoxes.SelectedItems.Count != 0)
if (listViewBoxes.SelectedItems.Count != 0 && listViewBoxes.SelectedItems[0] != null)
{
selected = listViewBoxes.SelectedItems[0];
if (selected == null)
{
this.textXc.Enabled = false;
this.textYc.Enabled = false;
this.textZc.Enabled = false;
this.textXf.Enabled = false;
this.textYf.Enabled = false;
this.textZf.Enabled = false;
this.textTextureX.Enabled = false;
this.textTextureY.Enabled = false;
this.buttonXcminus.Enabled = false;
this.buttonYcminus.Enabled = false;
this.buttonZcminus.Enabled = false;
this.buttonXcplus.Enabled = false;
this.buttonYcplus.Enabled = false;
this.buttonZcplus.Enabled = false;
this.buttonXfminus.Enabled = false;
this.buttonYfminus.Enabled = false;
this.buttonZfminus.Enabled = false;
this.buttonXfplus.Enabled = false;
this.buttonYfplus.Enabled = false;
this.buttonZfplus.Enabled = false;
}
else
{
this.textXc.Enabled = true;
this.textYc.Enabled = true;
this.textZc.Enabled = true;
this.textXf.Enabled = true;
this.textYf.Enabled = true;
this.textZf.Enabled = true;
this.textTextureX.Enabled = true;
this.textTextureY.Enabled = true;
this.buttonXcminus.Enabled = true;
this.buttonYcminus.Enabled = true;
this.buttonZcminus.Enabled = true;
this.buttonXcplus.Enabled = true;
this.buttonYcplus.Enabled = true;
this.buttonZcplus.Enabled = true;
this.buttonXfminus.Enabled = true;
this.buttonYfminus.Enabled = true;
this.buttonZfminus.Enabled = true;
this.buttonXfplus.Enabled = true;
this.buttonYfplus.Enabled = true;
this.buttonZfplus.Enabled = true;
comboParent.Enabled = true;
}
}
else
{
this.textXc.Enabled = false;
this.textYc.Enabled = false;
this.textZc.Enabled = false;
this.textXf.Enabled = false;
this.textYf.Enabled = false;
this.textZf.Enabled = false;
this.textTextureX.Enabled = false;
this.textTextureY.Enabled = false;
this.buttonXcminus.Enabled = false;
this.buttonYcminus.Enabled = false;
this.buttonZcminus.Enabled = false;
this.buttonXcplus.Enabled = false;
this.buttonYcplus.Enabled = false;
this.buttonZcplus.Enabled = false;
this.buttonXfminus.Enabled = false;
this.buttonYfminus.Enabled = false;
this.buttonZfminus.Enabled = false;
this.buttonXfplus.Enabled = false;
this.buttonYfplus.Enabled = false;
this.buttonZfplus.Enabled = false;
comboParent.Enabled = false;
textXc.Enabled = true;
textYc.Enabled = true;
textZc.Enabled = true;
textXf.Enabled = true;
textYf.Enabled = true;
textZf.Enabled = true;
textTextureX.Enabled = true;
textTextureY.Enabled = true;
buttonXcminus.Enabled = true;
buttonYcminus.Enabled = true;
buttonZcminus.Enabled = true;
buttonXcplus.Enabled = true;
buttonYcplus.Enabled = true;
buttonZcplus.Enabled = true;
buttonXfminus.Enabled = true;
buttonYfminus.Enabled = true;
buttonZfminus.Enabled = true;
buttonXfplus.Enabled = true;
buttonYfplus.Enabled = true;
buttonZfplus.Enabled = true;
comboParent.Enabled = true;
return;
}
textXc.Enabled = false;
textYc.Enabled = false;
textZc.Enabled = false;
textXf.Enabled = false;
textYf.Enabled = false;
textZf.Enabled = false;
textTextureX.Enabled = false;
textTextureY.Enabled = false;
buttonXcminus.Enabled = false;
buttonYcminus.Enabled = false;
buttonZcminus.Enabled = false;
buttonXcplus.Enabled = false;
buttonYcplus.Enabled = false;
buttonZcplus.Enabled = false;
buttonXfminus.Enabled = false;
buttonYfminus.Enabled = false;
buttonZfminus.Enabled = false;
buttonXfplus.Enabled = false;
buttonYfplus.Enabled = false;
buttonZfplus.Enabled = false;
comboParent.Enabled = false;
}
//Initialization
public generateModel(List<object[]> boxesIn, PictureBox preview)
{
this.InitializeComponent();
InitializeComponent();
boxes = new List<object[]>();
boxes = boxesIn;
this.skinPreview = preview;
this.direction = "front";
this.bg = new Bitmap(this.displayBox.Image);
this.buttonIMPORT.Enabled = false;
this.buttonEXPORT.Enabled = false;
this.textXc.Enabled = false;
this.textYc.Enabled = false;
this.textZc.Enabled = false;
this.textXf.Enabled = false;
this.textYf.Enabled = false;
this.textZf.Enabled = false;
this.textTextureX.Enabled = false;
this.textTextureY.Enabled = false;
this.buttonXcminus.Enabled = false;
this.buttonYcminus.Enabled = false;
this.buttonZcminus.Enabled = false;
this.buttonXcplus.Enabled = false;
this.buttonYcplus.Enabled = false;
this.buttonZcplus.Enabled = false;
this.buttonXfminus.Enabled = false;
this.buttonYfminus.Enabled = false;
this.buttonZfminus.Enabled = false;
this.buttonXfplus.Enabled = false;
this.buttonYfplus.Enabled = false;
this.buttonZfplus.Enabled = false;
this.comboParent.Enabled = false;
skinPreview = preview;
direction = "front";
bg = new Bitmap(this.displayBox.Image);
buttonIMPORT.Enabled = false;
buttonEXPORT.Enabled = false;
textXc.Enabled = false;
textYc.Enabled = false;
textZc.Enabled = false;
textXf.Enabled = false;
textYf.Enabled = false;
textZf.Enabled = false;
textTextureX.Enabled = false;
textTextureY.Enabled = false;
buttonXcminus.Enabled = false;
buttonYcminus.Enabled = false;
buttonZcminus.Enabled = false;
buttonXcplus.Enabled = false;
buttonYcplus.Enabled = false;
buttonZcplus.Enabled = false;
buttonXfminus.Enabled = false;
buttonYfminus.Enabled = false;
buttonZfminus.Enabled = false;
buttonXfplus.Enabled = false;
buttonYfplus.Enabled = false;
buttonZfplus.Enabled = false;
comboParent.Enabled = false;
loadData();
}
@@ -246,10 +213,7 @@ namespace PckStudio
private void render()
{
//Disables template option if model parts exist
if (this.listViewBoxes.Items.Count == 0)
this.buttonTemplate.Enabled = true;
else
this.buttonTemplate.Enabled = false;
buttonTemplate.Enabled = listViewBoxes.Items.Count == 0;
setZ(); //Organizes Z layers

View File

@@ -55,10 +55,9 @@ namespace PckStudio
else
{
create = true;
PCKFile.FileData newMf = new PCKFile.FileData("", 2, 0);
newMf.properties.Add("ANIM", "");
newMf.data = File.ReadAllBytes(createdFileName);
newMf.size = newMf.data.Length;//gets filesize for minefile
PCKFile.FileData newMf = new PCKFile.FileData("", 2);
newMf.properties.Add(new Tuple<string, string>("ANIM", ""));
newMf.SetData(File.ReadAllBytes(createdFileName));
mf = newMf;
Forms.Utilities.AnimationEditor.ChangeTile diag = new Forms.Utilities.AnimationEditor.ChangeTile();
diag.ShowDialog(this);
@@ -74,9 +73,9 @@ namespace PckStudio
foreach (var entry in mf.properties) //object = metadata entry(name:value)
{
TreeNode meta = new TreeNode();
strEntries.Add(entry.Value);
strEntryData.Add(entry.Value);
//TreeNode meta = new TreeNode(entry.Item1);
strEntries.Add(entry.Item2);
strEntryData.Add(entry.Item2);
}
//if (strEntries.Find(entry => entry == "ANIM") == null) throw new System.Exception("ANIM tag is missing. No animation code is present.");
@@ -412,8 +411,7 @@ namespace PckStudio
using (MemoryStream m = new MemoryStream())
{
texture.Save(m, texture.RawFormat);
mf.data = m.ToArray();
mf.size = mf.data.Length;
mf.SetData(m.ToArray());
}
if (metroCheckBox2.Checked)
@@ -430,9 +428,20 @@ namespace PckStudio
Tuple<string, string> frameData = node.Tag as Tuple<string, string>;
animationData += frameData.Item1 + "*" + frameData.Item2 + ",";
}
animationData.TrimEnd(',');
if (mf.properties.ContainsKey("ANIM")) mf.properties["ANIM"] = animationData;
else mf.properties.Add("ANIM", animationData);
animationData.TrimEnd(',');
foreach (var pair in mf.properties)
{
if (pair.Item1 == "ANIM")
{
//pair.Item2 = animationData; // TODO
break;
}
else
{
mf.properties.Add(new Tuple<string, string>("ANIM", animationData));
break;
}
};
if (create)
{

View File

@@ -11,6 +11,7 @@ using System.Windows.Forms;
using MetroFramework.Forms;
using PckStudio;
using PckStudio.Classes.FileTypes;
using PckStudio.Classes.IO;
// Audio Editor by MattNL
@@ -19,7 +20,7 @@ namespace PckStudio.Forms.Utilities
public partial class AudioEditor : MetroForm
{
public bool saved = false;
public string defaultType;
public string defaultType = "yes";
public string cat;
public List<int> cats = new List<int>();
public List<int> totalCats = new List<int>();
@@ -91,14 +92,13 @@ namespace PckStudio.Forms.Utilities
mf = MineFile;
using (var stream = new MemoryStream(mf.data))
{
if (isVita) audioPCK = new PCKFile(stream, true);
else audioPCK = new PCKFile(stream);
audioPCK = PCKFileReader.Read(stream, isVita);
}
defaultType = audioPCK.meta_data[0];
if (!audioPCK.meta_data.ContainsValue("CUENAME"))
if (!audioPCK.meta_data.ContainsKey("CUENAME"))
{
throw new Exception("This is not a valid audio.pck file");
}
//defaultType = audioPCK.meta_data["CUENAME"];
int index = 0;
List<PCKFile.FileData> tempMineFiles = audioPCK.file_entries;
foreach (PCKFile.FileData mineFile in tempMineFiles)
@@ -131,19 +131,18 @@ namespace PckStudio.Forms.Utilities
private void treeView2_AfterSelect(object sender, TreeViewEventArgs e)
{
comboBox1.Items.Clear();//Resets metadata combobox of selectable entry names
comboBox1.Items.Clear(); //Resets metadata combobox of selectable entry names
if (e.Node.Tag == null) return;
var strings = (KeyValuePair<string, string>)e.Node.Tag;
string type = audioPCK.meta_data[0];
defaultType = type;
string value = "";
type = (string)strings.Key;
value = (string)strings.Value;
//string type = audioPCK.meta_data[0];
//defaultType = type;
//type = strings.Key;
string value = strings.Value;
foreach (int metaType in audioPCK.meta_data.Keys)
comboBox1.Items.Add(audioPCK.meta_data[metaType]);//fills combobox with metadata from the main metadatabase
comboBox1.Text = type;//Sets currently selected metadata type to type selected in selected metadata node
foreach (var metaType in audioPCK.meta_data)
comboBox1.Items.Add(metaType.Key);
comboBox1.Text = "TODO";//Sets currently selected metadata type to type selected in selected metadata node
textBox1.Text = value;//Sets currently selected metadata value to value selected in selected metadata node
}
@@ -151,10 +150,10 @@ namespace PckStudio.Forms.Utilities
{
treeView2.Nodes.Clear();
PCKFile.FileData mineFile = (PCKFile.FileData)e.Node.Tag;
foreach (var entry in mineFile.properties) //object = metadata entry(name:value)
foreach (var entry in mineFile.properties)
{
TreeNode meta = new TreeNode();
meta.Text = entry.Key;
meta.Text = entry.Item1;
meta.Tag = entry;
treeView2.Nodes.Add(meta);
}
@@ -193,9 +192,7 @@ namespace PckStudio.Forms.Utilities
add.Dispose();//diposes generated metadata adding dialog data
if (!cats.Contains(getCatID(cat))) cats.Add(getCatID(cat));
else return;
PCKFile.FileData mf = new PCKFile.FileData(cat, getCatID(cat), 0); //Creates new minefile template
mf.data = new byte[0]; //adds file data to minefile
PCKFile.FileData mf = new PCKFile.FileData(cat, getCatID(cat)); //Creates new minefile template
TreeNode addNode = new TreeNode(mf.name) { Tag = mf };//creates node for minefile
//addNode.ImageIndex = mf.type;
//addNode.SelectedImageIndex = mf.type;
@@ -217,14 +214,14 @@ namespace PckStudio.Forms.Utilities
TreeNode meta = new TreeNode("New Entry");
//meta.Tag = obj;
treeView2.Nodes.Add(meta);
((PCKFile.FileData)treeView1.SelectedNode.Tag).properties.Add(defaultType, "New Entry");
//((PCKFile.FileData)treeView1.SelectedNode.Tag).properties.Add(defaultType, new List<string> { "New Entry" });
}
public void treeView2_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete && treeView2.SelectedNode != null)
{
if (treeView1.SelectedNode == null) return; // makes sure you don't run this if there is nothing to delete
((PCKFile.FileData)treeView1.SelectedNode.Tag).properties.Remove((string)treeView2.SelectedNode.Tag);
//((PCKFile.FileData)treeView1.SelectedNode.Tag).properties.Remove((string)treeView2.SelectedNode.Tag);
treeView2.SelectedNode.Remove();
}
}
@@ -241,7 +238,7 @@ namespace PckStudio.Forms.Utilities
PCKFile.FileData mineFile = (PCKFile.FileData)treeView1.SelectedNode.Tag;
foreach (var entry in mineFile.properties)
{
TreeNode meta = new TreeNode(entry.Key);
TreeNode meta = new TreeNode(entry.Item1);
meta.Tag = entry;
treeView2.Nodes.Add(meta);
}
@@ -270,40 +267,40 @@ namespace PckStudio.Forms.Utilities
meta.Text = "CUENAME";
meta.Tag = obj;
treeView2.Nodes.Add(meta);
((PCKFile.FileData)treeView1.SelectedNode.Tag).properties.Add("CUENAME", System.IO.Path.GetFileNameWithoutExtension(binka));
}
((PCKFile.FileData)treeView1.SelectedNode.Tag).properties.Add(new Tuple<string, string>("CUENAME", Path.GetFileNameWithoutExtension(binka)));
}
}
}
}
private static void writeMinecraftString(FileOutput f, string str)
{
byte[] d = Encoding.BigEndianUnicode.GetBytes(str);
f.writeInt(d.Length / 2);
f.writeBytes(d);
f.writeInt(0);
}
//private static void writeMinecraftString(FileOutput f, string str)
//{
// byte[] d = Encoding.BigEndianUnicode.GetBytes(str);
// f.writeInt(d.Length / 2);
// f.writeBytes(d);
// f.writeInt(0);
//}
private static void writeMinecraftStringVita(FileOutput f, string str)
{
Console.WriteLine("WriteVita -- " + str);
byte[] bytes = Encoding.Unicode.GetBytes(str);
f.writeIntVita(bytes.Length / 2);
f.writeBytes((bytes));
f.writeIntVita(0);
}
//private static void writeMinecraftStringVita(FileOutput f, string str)
//{
// Console.WriteLine("WriteVita -- " + str);
// byte[] bytes = Encoding.Unicode.GetBytes(str);
// f.writeIntVita(bytes.Length / 2);
// f.writeBytes((bytes));
// f.writeIntVita(0);
//}
public static byte[] buildAudioPCKVita(PCKFile pck)
{
FileOutput fileOutput = new FileOutput();
fileOutput.Endian = Endianness.Big;
fileOutput.writeIntVita(1);
fileOutput.writeIntVita(pck.meta_data.Count);
foreach (int num in pck.meta_data.Keys)
{
fileOutput.writeIntVita(num);
writeMinecraftStringVita(fileOutput, pck.meta_data[num]);
}
//public static byte[] buildAudioPCKVita(PCKFile pck)
//{
// FileOutput fileOutput = new FileOutput();
// fileOutput.Endian = Endianness.Big;
// fileOutput.writeIntVita(1);
// fileOutput.writeIntVita(pck.meta_data.Count);
//foreach (int num in pck.meta_data.Keys)
//{
// fileOutput.writeIntVita(num);
// writeMinecraftStringVita(fileOutput, pck.meta_data[num]);
//}
//fileOutput.writeIntVita(PCKFile.FileDatas.Count);
//foreach (PCKFile.FileData mineFile in PCKFile.FileDatas)
//{
@@ -332,21 +329,21 @@ namespace PckStudio.Forms.Utilities
// break;
// }
//}
return fileOutput.getBytes();
}
// return fileOutput.getBytes();
//}
public static byte[] buildAudioPCK(PCKFile pck)
{
FileOutput f = new FileOutput();
f.Endian = pck.isLittleEndian ? Endianness.Little : Endianness.Big;
//FileOutput f = new FileOutput();
//f.Endian = pck.isLittleEndian ? Endianness.Little : Endianness.Big;
f.writeInt(1);
f.writeInt(pck.meta_data.Count);
foreach (int type in pck.meta_data.Keys)
{
f.writeInt(type);
writeMinecraftString(f, pck.meta_data[type]);
}
//f.writeInt(1);
//f.writeInt(pck.meta_data.Count);
//foreach (int type in pck.meta_data.Keys)
//{
// f.writeInt(type);
// writeMinecraftString(f, pck.meta_data[type]);
//}
//f.writeInt(PCKFile.FileDatas.Count);
//Console.WriteLine(PCKFile.FileDatas.Count);
@@ -379,7 +376,8 @@ namespace PckStudio.Forms.Utilities
// break;
// }
//}
return f.getBytes();
//return f.getBytes();
return new byte[0];
}
private void saveToolStripMenuItem1_Click(object sender, EventArgs e)

View File

@@ -1,4 +1,6 @@

using System.Windows.Forms;
namespace PckStudio.Forms.Utilities
{
partial class COLEditor
@@ -247,6 +249,14 @@ namespace PckStudio.Forms.Utilities
this.waterTab.BackColor = System.Drawing.SystemColors.WindowFrame;
resources.ApplyResources(this.waterTab, "waterTab");
this.waterTab.Name = "waterTab";
//this.treeView1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
//this.treeView1.ForeColor = System.Drawing.Color.White;
//this.treeView1.LabelEdit = false;
//this.treeView1.LineColor = System.Drawing.Color.White;
//this.treeView1.Name = "treeView1";
//this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeViews_AfterSelect);
//this.treeView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeViews_KeyDown);
//this.treeView1.Dock = DockStyle.Fill;
//
// COLEditor
//

View File

@@ -3,68 +3,47 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MetroFramework.Forms;
using PckStudio;
using PckStudio.Classes.FileTypes;
namespace PckStudio.Forms.Utilities
{
public partial class COLEditor : MetroForm
{
Classes.COL.COLFile cf = new Classes.COL.COLFile();
COLFile cf = new COLFile();
PCKFile.FileData mf;
TreeView treeView1 = new TreeView(); // Normal Color Table
TreeView treeView2 = new TreeView(); // Water Color Table
public COLEditor(byte[] data, PCKFile.FileData MineFile)
public COLEditor(PCKFile.FileData MineFile)
{
InitializeComponent();
metroLabel6.Visible = false;
numericUpDown2.Visible = false;
cf.Open(data);
mf = MineFile;
#region TreeView Controls Setup
treeView1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
treeView1.ForeColor = System.Drawing.Color.White;
treeView1.LabelEdit = false;
treeView1.LineColor = System.Drawing.Color.White;
treeView1.Name = "treeView1";
treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeViews_AfterSelect);
treeView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeViews_KeyDown);
treeView1.Dock = DockStyle.Fill;
treeView2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
treeView2.ForeColor = System.Drawing.Color.White;
treeView2.LabelEdit = false;
treeView2.LineColor = System.Drawing.Color.White;
treeView2.Name = "treeView2";
treeView2.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeViews_AfterSelect);
treeView2.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeViews_KeyDown);
treeView2.Dock = DockStyle.Fill;
#endregion
using (var stream = new MemoryStream(mf.data))
{
cf.Open(stream);
}
colorsTab.Controls.Add(treeView1);
waterTab.Controls.Add(treeView2);
tabControl.TabStop = true;
foreach (object[] obj in cf.entries)
foreach (var obj in cf.entries)
{
TreeNode tn = new TreeNode();
tn.Text = obj[0].ToString();
tn.Tag = obj[1].ToString();
TreeNode tn = new TreeNode(obj.name);
tn.Tag = obj.color;
treeView1.Nodes.Add(tn);
}
foreach (object[] obj in cf.waterEntries)
foreach (var obj in cf.waterEntries)
{
TreeNode tn = new TreeNode();
tn.Text = obj[0].ToString();
tn.Tag = obj[1].ToString();
TreeNode tn = new TreeNode(obj.name);
tn.Tag = obj.color;
treeView2.Nodes.Add(tn);
}
}
@@ -102,13 +81,17 @@ namespace PckStudio.Forms.Utilities
cf.waterEntries.Clear();
foreach (TreeNode tn in treeView1.Nodes)
{
cf.entries.Add(new object[] {tn.Text, tn.Tag.ToString() });
cf.entries.Add(new COLFile.COLEntry(){ name = tn.Text, color = (uint)tn.Tag });
}
foreach (TreeNode tn in treeView2.Nodes)
{
cf.waterEntries.Add(new object[] { tn.Text, tn.Tag.ToString() });
cf.waterEntries.Add(new COLFile.COLEntry() { name = tn.Text, color = (uint)tn.Tag });
}
using (var stream = new MemoryStream())
{
cf.Save(stream);
mf.SetData(stream.ToArray());
}
mf.data = cf.Save();
}
static byte[] StringToByteArrayFastest(string hex)

View File

@@ -28,104 +28,104 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LOCEditor));
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.addDisplayIDToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.renameDisplayIDToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.deleteDisplayIDToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.locSort = new PckStudio.Forms.MyTablePanel();
this.buttonReplaceAll = new System.Windows.Forms.Button();
this.dataGridViewLocEntryData = new System.Windows.Forms.DataGridView();
this.textBoxReplaceAll = new System.Windows.Forms.TextBox();
this.treeViewLocEntries = new System.Windows.Forms.TreeView();
this.contextMenuStrip1.SuspendLayout();
this.locSort.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridViewLocEntryData)).BeginInit();
this.SuspendLayout();
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LOCEditor));
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.addDisplayIDToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.renameDisplayIDToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.deleteDisplayIDToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.locSort = new PckStudio.Forms.MyTablePanel();
this.buttonReplaceAll = new System.Windows.Forms.Button();
this.dataGridViewLocEntryData = new System.Windows.Forms.DataGridView();
this.textBoxReplaceAll = new System.Windows.Forms.TextBox();
this.treeViewLocEntries = new System.Windows.Forms.TreeView();
this.contextMenuStrip1.SuspendLayout();
this.locSort.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridViewLocEntryData)).BeginInit();
this.SuspendLayout();
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.addDisplayIDToolStripMenuItem,
this.renameDisplayIDToolStripMenuItem,
this.deleteDisplayIDToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
resources.ApplyResources(this.contextMenuStrip1, "contextMenuStrip1");
//
// addDisplayIDToolStripMenuItem
//
this.addDisplayIDToolStripMenuItem.Name = "addDisplayIDToolStripMenuItem";
resources.ApplyResources(this.addDisplayIDToolStripMenuItem, "addDisplayIDToolStripMenuItem");
this.addDisplayIDToolStripMenuItem.Click += new System.EventHandler(this.addDisplayIDToolStripMenuItem_Click);
//
// renameDisplayIDToolStripMenuItem
//
this.renameDisplayIDToolStripMenuItem.Name = "renameDisplayIDToolStripMenuItem";
resources.ApplyResources(this.renameDisplayIDToolStripMenuItem, "renameDisplayIDToolStripMenuItem");
this.renameDisplayIDToolStripMenuItem.Click += new System.EventHandler(this.renameDisplayIDToolStripMenuItem_Click);
//
// deleteDisplayIDToolStripMenuItem
//
this.deleteDisplayIDToolStripMenuItem.Name = "deleteDisplayIDToolStripMenuItem";
resources.ApplyResources(this.deleteDisplayIDToolStripMenuItem, "deleteDisplayIDToolStripMenuItem");
this.deleteDisplayIDToolStripMenuItem.Click += new System.EventHandler(this.deleteDisplayIDToolStripMenuItem_Click);
//
// locSort
//
this.locSort.AccessibleRole = System.Windows.Forms.AccessibleRole.Table;
resources.ApplyResources(this.locSort, "locSort");
this.locSort.Controls.Add(this.buttonReplaceAll, 2, 0);
this.locSort.Controls.Add(this.dataGridViewLocEntryData, 1, 1);
this.locSort.Controls.Add(this.textBoxReplaceAll, 1, 0);
this.locSort.Controls.Add(this.treeViewLocEntries, 0, 0);
this.locSort.Name = "locSort";
//
// buttonReplaceAll
//
resources.ApplyResources(this.buttonReplaceAll, "buttonReplaceAll");
this.buttonReplaceAll.ForeColor = System.Drawing.Color.White;
this.buttonReplaceAll.Name = "buttonReplaceAll";
this.buttonReplaceAll.UseVisualStyleBackColor = true;
this.buttonReplaceAll.Click += new System.EventHandler(this.buttonReplaceAll_Click);
//
// dataGridViewLocEntryData
//
this.dataGridViewLocEntryData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.locSort.SetColumnSpan(this.dataGridViewLocEntryData, 2);
resources.ApplyResources(this.dataGridViewLocEntryData, "dataGridViewLocEntryData");
this.dataGridViewLocEntryData.Name = "dataGridViewLocEntryData";
this.dataGridViewLocEntryData.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellEndEdit);
//
// textBoxReplaceAll
//
resources.ApplyResources(this.textBoxReplaceAll, "textBoxReplaceAll");
this.textBoxReplaceAll.Name = "textBoxReplaceAll";
//
// treeViewLocEntries
//
this.treeViewLocEntries.ContextMenuStrip = this.contextMenuStrip1;
resources.ApplyResources(this.treeViewLocEntries, "treeViewLocEntries");
this.treeViewLocEntries.LabelEdit = true;
this.treeViewLocEntries.Name = "treeViewLocEntries";
this.locSort.SetRowSpan(this.treeViewLocEntries, 2);
this.treeViewLocEntries.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
this.treeViewLocEntries.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeView1_KeyDown);
//
// LOCEditor
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.locSort);
this.Name = "LOCEditor";
this.Style = MetroFramework.MetroColorStyle.Silver;
this.Theme = MetroFramework.MetroThemeStyle.Dark;
this.Load += new System.EventHandler(this.LOCEditor_Load);
this.contextMenuStrip1.ResumeLayout(false);
this.locSort.ResumeLayout(false);
this.locSort.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridViewLocEntryData)).EndInit();
this.ResumeLayout(false);
this.contextMenuStrip1.Name = "contextMenuStrip1";
resources.ApplyResources(this.contextMenuStrip1, "contextMenuStrip1");
//
// addDisplayIDToolStripMenuItem
//
this.addDisplayIDToolStripMenuItem.Name = "addDisplayIDToolStripMenuItem";
resources.ApplyResources(this.addDisplayIDToolStripMenuItem, "addDisplayIDToolStripMenuItem");
this.addDisplayIDToolStripMenuItem.Click += new System.EventHandler(this.addDisplayIDToolStripMenuItem_Click);
//
// renameDisplayIDToolStripMenuItem
//
this.renameDisplayIDToolStripMenuItem.Name = "renameDisplayIDToolStripMenuItem";
resources.ApplyResources(this.renameDisplayIDToolStripMenuItem, "renameDisplayIDToolStripMenuItem");
this.renameDisplayIDToolStripMenuItem.Click += new System.EventHandler(this.renameDisplayIDToolStripMenuItem_Click);
//
// deleteDisplayIDToolStripMenuItem
//
this.deleteDisplayIDToolStripMenuItem.Name = "deleteDisplayIDToolStripMenuItem";
resources.ApplyResources(this.deleteDisplayIDToolStripMenuItem, "deleteDisplayIDToolStripMenuItem");
this.deleteDisplayIDToolStripMenuItem.Click += new System.EventHandler(this.deleteDisplayIDToolStripMenuItem_Click);
//
// locSort
//
this.locSort.AccessibleRole = System.Windows.Forms.AccessibleRole.Table;
resources.ApplyResources(this.locSort, "locSort");
this.locSort.Controls.Add(this.buttonReplaceAll, 2, 0);
this.locSort.Controls.Add(this.dataGridViewLocEntryData, 1, 1);
this.locSort.Controls.Add(this.textBoxReplaceAll, 1, 0);
this.locSort.Controls.Add(this.treeViewLocEntries, 0, 0);
this.locSort.Name = "locSort";
//
// buttonReplaceAll
//
resources.ApplyResources(this.buttonReplaceAll, "buttonReplaceAll");
this.buttonReplaceAll.ForeColor = System.Drawing.Color.White;
this.buttonReplaceAll.Name = "buttonReplaceAll";
this.buttonReplaceAll.UseVisualStyleBackColor = true;
this.buttonReplaceAll.Click += new System.EventHandler(this.buttonReplaceAll_Click);
//
// dataGridViewLocEntryData
//
this.dataGridViewLocEntryData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.locSort.SetColumnSpan(this.dataGridViewLocEntryData, 2);
resources.ApplyResources(this.dataGridViewLocEntryData, "dataGridViewLocEntryData");
this.dataGridViewLocEntryData.Name = "dataGridViewLocEntryData";
this.dataGridViewLocEntryData.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellEndEdit);
//
// textBoxReplaceAll
//
resources.ApplyResources(this.textBoxReplaceAll, "textBoxReplaceAll");
this.textBoxReplaceAll.Name = "textBoxReplaceAll";
//
// treeViewLocEntries
//
this.treeViewLocEntries.ContextMenuStrip = this.contextMenuStrip1;
resources.ApplyResources(this.treeViewLocEntries, "treeViewLocEntries");
this.treeViewLocEntries.LabelEdit = true;
this.treeViewLocEntries.Name = "treeViewLocEntries";
this.locSort.SetRowSpan(this.treeViewLocEntries, 2);
this.treeViewLocEntries.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
this.treeViewLocEntries.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeView1_KeyDown);
//
// LOCEditor
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.locSort);
this.Name = "LOCEditor";
this.Style = MetroFramework.MetroColorStyle.Silver;
this.Theme = MetroFramework.MetroThemeStyle.Dark;
this.Load += new System.EventHandler(this.LOCEditor_Load);
this.contextMenuStrip1.ResumeLayout(false);
this.locSort.ResumeLayout(false);
this.locSort.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridViewLocEntryData)).EndInit();
this.ResumeLayout(false);
}
@@ -140,5 +140,5 @@
private PckStudio.Forms.MyTablePanel locSort;
private System.Windows.Forms.Button buttonReplaceAll;
private System.Windows.Forms.ToolStripMenuItem renameDisplayIDToolStripMenuItem;
}
}
}

View File

@@ -1,4 +1,5 @@
using System;
using PckStudio.Classes.FileTypes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@@ -12,151 +13,124 @@ namespace PckStudio
{
public partial class LOCEditor : MetroFramework.Forms.MetroForm
{
#region Variables
DataTable tbl;
LOC currentLoc;
DataTable tbl = new DataTable();
LOCFile currentLoc;
public class displayId
{
public string id;
public string defaultName;
}
#endregion
public LOCEditor(LOC loc)
public LOCEditor(LOCFile loc)
{
InitializeComponent();
tbl = new DataTable();
currentLoc = loc;
tbl.Columns.Add(new DataColumn("Language") { ReadOnly = true });
tbl.Columns.Add("Display Name");
dataGridViewLocEntryData.DataSource = tbl;
DataGridViewColumn column = dataGridViewLocEntryData.Columns[1];
column.Width = 600;
}
private void LOCEditor_Load(object sender, EventArgs e)
{
foreach(string id in currentLoc.ids.names)
foreach(string id in currentLoc.languages.Keys)
treeViewLocEntries.Nodes.Add(id);
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
tbl.Rows.Clear();
foreach (LOC.Language l in currentLoc.langs)
if (treeViewLocEntries.SelectedNode == null ||
!currentLoc.languages.ContainsKey(treeViewLocEntries.SelectedNode.Text))
{
string utf8str = l.names[e.Node.Index];
byte[] utf8Data = new byte[utf8str.Length];
for (int i = 0; i < utf8str.Length; ++i)
{
utf8Data[i] = (byte)utf8str[i];
}
tbl.Rows.Add(l.name, Encoding.UTF8.GetString(utf8Data, 0, utf8Data.Length));
MessageBox.Show("Selected Node does not seem to be in the loc file");
return;
}
try
buttonReplaceAll.Enabled = true;
foreach (var l in currentLoc.languages[treeViewLocEntries.SelectedNode.Text])
{
if (treeViewLocEntries.SelectedNode != null)
{
buttonReplaceAll.Enabled = true;
}
else
{
buttonReplaceAll.Enabled = false;
}
}catch (Exception)
{
buttonReplaceAll.Enabled = false;
tbl.Rows.Add(l.Key, l.Value);
}
}
private void renameDisplayIDToolStripMenuItem_Click(object sender, EventArgs e)
{
TreeNode node = treeViewLocEntries.SelectedNode;
int index = currentLoc.ids.names.FindIndex(name => name == node.Text);
PckStudio.renameLoc diag = new PckStudio.renameLoc(node);
renameLoc diag = new renameLoc(node.Text);
diag.ShowDialog(this);
if (diag.DialogResult == DialogResult.OK)
currentLoc.ChangeEntry("TODO", diag.NewText);
diag.Dispose(); //diposes generated metadata adding dialog data
currentLoc.ids.names[index] = node.Text;
}
private void addDisplayIDToolStripMenuItem_Click(object sender, EventArgs e)
{
int index = treeViewLocEntries.SelectedNode.Index;
MessageBox.Show("TODO");
//int index = treeViewLocEntries.SelectedNode.Index;
if(index == -1) index = currentLoc.ids.names.Count;
//if(index == -1) index = currentLoc.ids.names.Count;
currentLoc.ids.names.Insert(index, "NewItem");
//currentLoc.ids.names.Insert(index, "NewItem");
foreach (LOC.Language l in currentLoc.langs)
l.names.Insert(index, "NewString");
//foreach (LOCFile.Language l in currentLoc.langs)
// l.names.Insert(index, "NewString");
treeViewLocEntries.Nodes.Insert(index, "NewItem");
//treeViewLocEntries.Nodes.Insert(index, "NewItem");
}
private void deleteDisplayIDToolStripMenuItem_Click(object sender, EventArgs e)
{
if(treeViewLocEntries.SelectedNode != null)
{
int index = treeViewLocEntries.SelectedNode.Index;
MessageBox.Show("TODO");
//int index = treeViewLocEntries.SelectedNode.Index;
currentLoc.ids.names.RemoveAt(index);
//currentLoc.ids.names.RemoveAt(index);
foreach (LOC.Language l in currentLoc.langs)
l.names.RemoveAt(index);
//foreach (LOCFile.Language l in currentLoc.langs)
// l.names.RemoveAt(index);
treeViewLocEntries.Nodes.RemoveAt(index);
//treeViewLocEntries.Nodes.RemoveAt(index);
}
}
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
for (int i = 0; i < tbl.Rows.Count; i++)
{
byte[] data = Encoding.UTF8.GetBytes((string)tbl.Rows[i][1]);
MessageBox.Show("TODO");
//for (int i = 0; i < tbl.Rows.Count; i++)
//{
// byte[] data = Encoding.UTF8.GetBytes((string)tbl.Rows[i][1]);
string final = string.Empty;
// string final = string.Empty;
foreach (byte b in data)
final += (Char)b;
// foreach (byte b in data)
// final += (char)b;
currentLoc.langs[i].names[treeViewLocEntries.SelectedNode.Index] = final;
}
// currentLoc.langs[i].names[treeViewLocEntries.SelectedNode.Index] = final;
//}
}
private void treeView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Delete) //checks to make sure pressed key was del
if (e.KeyData == Keys.Delete && treeViewLocEntries.SelectedNode != null) //checks to make sure pressed key was del
{
if (treeViewLocEntries.SelectedNode != null)
{
int index = treeViewLocEntries.SelectedNode.Index;
int index = treeViewLocEntries.SelectedNode.Index;
MessageBox.Show("TODO");
//currentLoc.languages..RemoveAt(index);
currentLoc.ids.names.RemoveAt(index);
foreach (LOC.Language l in currentLoc.langs)
l.names.RemoveAt(index);
treeViewLocEntries.Nodes.RemoveAt(index);
}
//foreach (var l in currentLoc.languages)
// l.names.RemoveAt(index);
//treeViewLocEntries.Nodes.RemoveAt(index);
}
}
private void buttonReplaceAll_Click(object sender, EventArgs e)
{
for (int i = 0; i < tbl.Rows.Count; i++)
{
tbl.Rows[i][1] = textBoxReplaceAll.Text;
}
for (int i = 0; i < tbl.Rows.Count; i++)
{
currentLoc.langs[i].names[treeViewLocEntries.SelectedNode.Index] = (string)tbl.Rows[i][1];
}
MessageBox.Show("TODO");
//for (int i = 0; i < tbl.Rows.Count; i++)
//{
// tbl.Rows[i][1] = ;
//}
//for (int i = 0; i < tbl.Rows.Count; i++)
//{
// currentLoc.langs[i].names[treeViewLocEntries.SelectedNode.Index] = (string)tbl.Rows[i][1];
//}
}
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)

View File

@@ -283,7 +283,7 @@
<value>1</value>
</data>
<data name="locSort.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="buttonReplaceAll" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="dataGridViewLocEntryData" Row="1" RowSpan="1" Column="1" ColumnSpan="2" /&gt;&lt;Control Name="textBoxReplaceAll" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="treeViewLocEntries" Row="0" RowSpan="2" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Absolute,300,Percent,100,AutoSize,0" /&gt;&lt;Rows Styles="AutoSize,0,Percent,100" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="buttonReplaceAll" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="dataGridViewLocEntryData" Row="1" RowSpan="1" Column="1" ColumnSpan="2" /&gt;&lt;Control Name="textBoxReplaceAll" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="treeViewLocEntries" Row="0" RowSpan="2" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Absolute,300,Percent,100,AutoSize,0" /&gt;&lt;Rows Styles="AutoSize,0,Percent,100,Absolute,20" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>

View File

@@ -17,6 +17,7 @@ using PckStudio;
using System.IO.Compression;
using static PckStudio.FormMain;
using PckStudio.Classes.FileTypes;
using PckStudio.Classes.IO;
namespace PckStudio.Forms
{
@@ -139,7 +140,7 @@ namespace PckStudio.Forms
PCKFile pck = null;
using (var stream = File.OpenRead(appData + "/PCK Center/myPcks/" + mod + ".pck"))
{
pck = new PCKFile(stream); //sets opened pck
pck = PCKFileReader.Read(stream, false); //sets opened pck
}
PCKFile currentPCK = pck; //sets opened pck
foreach (PCKFile.FileData skin in currentPCK.file_entries)
@@ -185,15 +186,15 @@ namespace PckStudio.Forms
foreach (var entry in newSkin.properties)
{
if (entry.Key.ToString() == "DISPLAYNAME")
if (entry.Item1 == "DISPLAYNAME")
{
skinName = entry.Value.ToString();
skinDisplayNames.Add(new Item() { Id = newSkin.name.Remove(15, 4), Name = entry.Value.ToString() });
skinName = entry.Item2;
skinDisplayNames.Add(new Item() { Id = newSkin.name.Remove(15, 4), Name = entry.Item2 });
}
if (entry.Key.ToString() == "CAPEPATH")
if (entry.Item1 == "CAPEPATH")
{
hasCape = true;
capePath = entry.Value.ToString();
capePath = entry.Item2;
}
}
@@ -267,11 +268,11 @@ namespace PckStudio.Forms
//determines skin type based on image dimensions, existence of BOX tags, and the ANIM value
foreach (var entry in newSkin.properties)
{
if (entry.Key.ToString() == "BOX")
if (entry.Item1.ToString() == "BOX")
{
string mClass = "";
string mData = "";
foreach (char dCheck in entry.Value.ToString())
foreach (char dCheck in entry.Item2)
{
if (dCheck.ToString() != " ")
{
@@ -279,7 +280,7 @@ namespace PckStudio.Forms
}
else
{
mData = entry.Value.ToString().Remove(0, mClass.Count() + 1);
mData = entry.Item2.Remove(0, mClass.Count() + 1);
break;
}
}
@@ -316,13 +317,13 @@ namespace PckStudio.Forms
}
}
if (entry.Key.ToString() == "OFFSET")
if (entry.Item1 == "OFFSET")
{
string oClass = "";
string oData = "";
foreach (char oCheck in entry.Value.ToString())
foreach (char oCheck in entry.Item2)
{
oData = entry.Value.ToString();
oData = entry.Item2;
if (oCheck.ToString() != " ")
{
oClass += oCheck.ToString();
@@ -351,13 +352,13 @@ namespace PckStudio.Forms
}
}
if (entry.Key.ToString() == "ANIM")
if (entry.Item1 == "ANIM")
{
if (entry.Value.ToString() == "0x40000")
if (entry.Item2 == "0x40000")
{
}
else if (entry.Value.ToString() == "0x80000")
else if (entry.Item2 == "0x80000")
{
skinType = "alex";
}

View File

@@ -28,50 +28,49 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(rename));
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// label2
//
resources.ApplyResources(this.label2, "label2");
this.label2.ForeColor = System.Drawing.Color.White;
this.label2.Name = "label2";
//
// button1
//
resources.ApplyResources(this.button1, "button1");
this.button1.ForeColor = System.Drawing.Color.White;
this.button1.Name = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
resources.ApplyResources(this.textBox1, "textBox1");
this.textBox1.Name = "textBox1";
//
// rename
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ControlBox = false;
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.label2);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "rename";
this.Resizable = false;
this.ShadowType = MetroFramework.Forms.MetroFormShadowType.DropShadow;
this.Style = MetroFramework.MetroColorStyle.Silver;
this.Theme = MetroFramework.MetroThemeStyle.Dark;
this.Load += new System.EventHandler(this.addCategory_Load);
this.ResumeLayout(false);
this.PerformLayout();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(renameLoc));
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// label2
//
resources.ApplyResources(this.label2, "label2");
this.label2.ForeColor = System.Drawing.Color.White;
this.label2.Name = "label2";
//
// button1
//
resources.ApplyResources(this.button1, "button1");
this.button1.ForeColor = System.Drawing.Color.White;
this.button1.Name = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
resources.ApplyResources(this.textBox1, "textBox1");
this.textBox1.Name = "textBox1";
//
// renameLoc
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ControlBox = false;
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.label2);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "renameLoc";
this.Resizable = false;
this.ShadowType = MetroFramework.Forms.MetroFormShadowType.DropShadow;
this.Style = MetroFramework.MetroColorStyle.Silver;
this.Theme = MetroFramework.MetroThemeStyle.Dark;
this.ResumeLayout(false);
this.PerformLayout();
}

View File

@@ -13,27 +13,20 @@ namespace PckStudio
{
public partial class renameLoc : MetroFramework.Forms.MetroForm
{
TreeNode node;
public string NewText = string.Empty;
public renameLoc(TreeNode nodeIn)
public renameLoc(string initialText)
{
InitializeComponent();
node = nodeIn;
textBox1.Text = nodeIn.Text;
textBox1.Text = initialText;
FormBorderStyle = FormBorderStyle.None;
}
private void button1_Click(object sender, EventArgs e)
{
node.Name = textBox1.Text;
node.Text = textBox1.Text;
this.Close();
NewText = textBox1.Text;
DialogResult = DialogResult.OK;
Close();
}
private void addCategory_Load(object sender, EventArgs e)
{
}
}
}
}

View File

@@ -2428,7 +2428,7 @@
<value>CenterParent</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>rename</value>
<value>renameLoc</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>MetroFramework.Forms.MetroForm, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a</value>

View File

@@ -137,10 +137,15 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Classes\FileTypes\Bink.cs" />
<Compile Include="Classes\FileTypes\COL.cs" />
<Compile Include="Classes\FileTypes\COLFile.cs" />
<Compile Include="Classes\FileTypes\CSM.cs" />
<Compile Include="Classes\FileTypes\PCKProperties.cs" />
<Compile Include="Classes\FileTypes\PCKFile.cs" />
<Compile Include="Classes\IO\LOC\LOCFileReader.cs" />
<Compile Include="Classes\IO\LOC\LOCFileWriter.cs" />
<Compile Include="Classes\IO\PCKCollectionsLocal.cs" />
<Compile Include="Classes\IO\PCK\PCKFileReader.cs" />
<Compile Include="Classes\IO\PCK\PCKFileWriter.cs" />
<Compile Include="Classes\Models\DefaultModels\CharacterModel.cs" />
<Compile Include="Classes\Models\DefaultModels\ModelBase.cs" />
<Compile Include="Classes\Models\DefaultModels\Texture.cs" />
@@ -243,9 +248,6 @@
<Compile Include="Forms\Skins-And-Textures\EntryEditor.Designer.cs">
<DependentUpon>EntryEditor.cs</DependentUpon>
</Compile>
<Compile Include="Classes\IO\FileBase.cs" />
<Compile Include="Classes\IO\FileData.cs" />
<Compile Include="Classes\IO\FileOutput.cs" />
<Compile Include="Forms\Form1.cs">
<SubType>Form</SubType>
</Compile>
@@ -380,7 +382,7 @@
<Compile Include="Classes\ToolboxItems\InterpolationPictureBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Classes\FileTypes\LOC.cs" />
<Compile Include="Classes\FileTypes\LOCFile.cs" />
<Compile Include="Forms\Utilities\LOCEditor.cs">
<SubType>Form</SubType>
</Compile>
@@ -627,7 +629,6 @@
<None Include="Resources\binka\binkawin.asi" />
<None Include="Resources\settings.ini" />
<None Include="Resources\tileData.json" />
<None Include="Resources\UntitledSkinPCK.pck" />
<None Include="Resources\Del.png" />
<None Include="Resources\ExportFile.png" />
<None Include="Resources\power3.png" />
@@ -668,8 +669,6 @@
<None Include="Resources\binka\mss32.dll" />
<Content Include="Sin_titulo991.ico" />
<None Include="Resources\bg1.png" />
<Content Include="favicon %285%29.ico" />
<Content Include="favicon %286%29.ico" />
<Content Include="Resources\NoImageFound.png" />
</ItemGroup>
<ItemGroup>

View File

@@ -500,16 +500,6 @@ namespace PckStudio.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
public static byte[] UntitledSkinPCK {
get {
object obj = ResourceManager.GetObject("UntitledSkinPCK", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@@ -190,9 +190,6 @@
<data name="pckClosed" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\pckClosed.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="UntitledSkinPCK" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\UntitledSkinPCK.pck;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="apps" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\apps.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>