add support for reading PS3 Theme Files .p3t

This commit is contained in:
Li 2022-08-08 13:04:52 +12:00
parent 486fe98cca
commit 3a5e794736
4 changed files with 353 additions and 351 deletions

View File

@ -351,21 +351,17 @@ namespace CXMLDecompiler
Console.WriteLine("AttributeType: " + Type.ToString());
switch (Type)
{
case AttributeType.TYPE_NONE:
Console.WriteLine("UNSUPPORTED TYPE @ " + TreeTable.Position);
Console.ReadKey();
break;
case AttributeType.TYPE_INT:
int intWrite = Int32.Parse(attribute.Value, CultureInfo.InvariantCulture);
tools.WriteInt32(WorkRam, intWrite);
tools.WriteInt32(WorkRam, 0x00);
Console.WriteLine("Int - Value: " + intWrite.ToString());
Console.WriteLine("Int: " + intWrite.ToString());
break;
case AttributeType.TYPE_FLOAT:
float FloatValue = Single.Parse(attribute.Value.Replace("f", ""), CultureInfo.InvariantCulture);
tools.WriteSingle(WorkRam, FloatValue);
tools.WriteInt32(WorkRam, 0x00);
Console.WriteLine("Float - Value: " + FloatValue.ToString());
Console.WriteLine("Float: " + FloatValue.ToString());
break;
case AttributeType.TYPE_STRING:
int StringOffset = AddGetStringTable(attribute.Value);
@ -391,7 +387,7 @@ namespace CXMLDecompiler
int HashTableSize = 4;
tools.WriteInt32(WorkRam, HashTableOffset);
tools.WriteInt32(WorkRam, HashTableSize);
Console.WriteLine("Hash ID Offset:" + HashTableOffset.ToString() + " size: " + HashTableSize);
Console.WriteLine("Hash Offset:" + HashTableOffset.ToString() + " size: " + HashTableSize);
break;
case AttributeType.TYPE_INTEGER_ARRAY:
string[] arr = attribute.Value.Replace("[", "").Replace("]", "").Replace(" ", "").Split(',');
@ -432,38 +428,39 @@ namespace CXMLDecompiler
int IdTableOffset = AddGetIdTable(attribute.Value, Convert.ToInt32(TreeTable.Position));
tools.WriteInt32(WorkRam, IdTableOffset);
tools.WriteInt32(WorkRam, 0x00);
Console.WriteLine("String Loopback: " + ElementName + " " + TreeTable.Position.ToString("X") + " (" + TreeTable.Position.ToString("X") + ")");
Console.WriteLine("Loopback ID String: " + IdTableOffset + " sz: 0");
Console.WriteLine("ID Ref: " + ElementName + " " + TreeTable.Position.ToString("X") + " (" + TreeTable.Position.ToString("X") + ")");
Console.WriteLine("ID Ref Offset: " + IdTableOffset + " sz: 0");
break;
case AttributeType.TYPE_ID:
IdTableOffset = AddGetIdTable(attribute.Value, -1);
tools.WriteInt32(WorkRam, IdTableOffset);
tools.WriteInt32(WorkRam, 0x00);
Console.WriteLine("ID String: " + IdTableOffset + " sz: 0");
Console.WriteLine("ID : " + IdTableOffset + " sz: 0");
break;
case AttributeType.TYPE_ID_HASH_REF:
int hash = Int32.Parse(attribute.Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
if (HashStrings)
hash = Int32.Parse(Tools.GenerateShortHash(Encoding.UTF8.GetBytes(attribute.Value)), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int IntIdTableOffset = AddGetHashIdTable(hash, Convert.ToInt32(TreeTable.Position));
tools.WriteInt32(WorkRam, IntIdTableOffset);
int HashIdTableOffset = AddGetHashIdTable(hash, Convert.ToInt32(TreeTable.Position));
tools.WriteInt32(WorkRam, HashIdTableOffset);
tools.WriteInt32(WorkRam, 0x00);
Console.WriteLine("Int Loopback: " + ElementName + " " + TreeTable.Position.ToString("X") + " (" + TreeTable.Position.ToString("X") + ")");
Console.WriteLine("Loopback ID Int: " + IntIdTableOffset + " sz: 0");
Console.WriteLine("Hash ID Ref: " + ElementName + " " + TreeTable.Position.ToString("X") + " (" + TreeTable.Position.ToString("X") + ")");
Console.WriteLine("Hash ID REF offset: " + HashIdTableOffset + " sz: 0");
break;
case AttributeType.TYPE_ID_HASH:
hash = Int32.Parse(attribute.Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
if (HashStrings)
hash = Int32.Parse(Tools.GenerateShortHash(Encoding.UTF8.GetBytes(attribute.Value)), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
IntIdTableOffset = AddGetHashIdTable(hash, -1);
HashIdTableOffset = AddGetHashIdTable(hash, -1);
tools.WriteInt32(WorkRam, IntIdTableOffset);
tools.WriteInt32(WorkRam, HashIdTableOffset);
tools.WriteInt32(WorkRam, 0x00);
Console.WriteLine("Int Id: " + IntIdTableOffset + " sz: 0");
Console.WriteLine("Hash ID: " + HashIdTableOffset + " sz: 0");
break;
case AttributeType.TYPE_NONE:
break;
default:
Console.WriteLine("UNKNOWN TYPE @ " + TreeTable.Position);
Console.ReadKey();
throw new NotImplementedException("UNKNOWN TYPE @ " + TreeTable.Position);
break;
}
Console.WriteLine(attribute.Name + "=" + attribute.Value);

View File

@ -2,6 +2,6 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<StartArguments>PvrResource.cxml -ps3 -le -f -d</StartArguments>
<StartWorkingDirectory>C:\Users\User\Documents\git\cxml-decompiler\CXMLCli\bin\x64\Debug</StartWorkingDirectory>
<StartWorkingDirectory>C:\Users\Li\Documents\git\cxml-decompiler\CXMLCli\bin\x64\Debug</StartWorkingDirectory>
</PropertyGroup>
</Project>

View File

@ -32,6 +32,10 @@ namespace CXMLDecompiler
{
return true;
}
else if (Magic.StartsWith("P3TF")) // ps3 theme file
{
return true;
}
else if (Magic.StartsWith("CXML")) // cxml.py default
{
return true;
@ -679,6 +683,7 @@ namespace CXMLDecompiler
{
case AttributeType.TYPE_INT:
AttributeValue = tools.ReadInt32(TreeTable);
int sz = tools.ReadInt32(TreeTable);
Console.WriteLine("Int - Value: " + AttributeValue.ToString() + " sz:" + sz);
break;

View File

@ -166,7 +166,7 @@ namespace General
{
MemoryStream Data = ByteToStream(Bytes);
String header = ReadString(Data, 4);
if (header.StartsWith("MIG"))
if (header.StartsWith("MIG") || header.EndsWith("GIM"))
{
return true;
}