New object name system in MainForm

master
1987kostya 4 years ago
parent 8617712de7
commit d91d1c2f28

@ -100,7 +100,7 @@
// //
// listBox1 // listBox1
// //
this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right))); this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.listBox1.BackColor = System.Drawing.Color.Black; this.listBox1.BackColor = System.Drawing.Color.Black;
this.listBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; this.listBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.listBox1.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.listBox1.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
@ -108,12 +108,13 @@
this.listBox1.FormattingEnabled = true; this.listBox1.FormattingEnabled = true;
this.listBox1.IntegralHeight = false; this.listBox1.IntegralHeight = false;
this.listBox1.ItemHeight = 14; this.listBox1.ItemHeight = 14;
this.listBox1.Location = new System.Drawing.Point(459, 12); this.listBox1.Location = new System.Drawing.Point(342, 9);
this.listBox1.Margin = new System.Windows.Forms.Padding(0); this.listBox1.Margin = new System.Windows.Forms.Padding(0);
this.listBox1.MaximumSize = new System.Drawing.Size(180, 50000); this.listBox1.MaximumSize = new System.Drawing.Size(300, 50000);
this.listBox1.MinimumSize = new System.Drawing.Size(180, 234); this.listBox1.MinimumSize = new System.Drawing.Size(180, 234);
this.listBox1.Name = "listBox1"; this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(180, 281); this.listBox1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.listBox1.Size = new System.Drawing.Size(300, 277);
this.listBox1.TabIndex = 5; this.listBox1.TabIndex = 5;
// //
// GameInfo // GameInfo
@ -268,7 +269,7 @@
this.loadingLabel.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); this.loadingLabel.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.loadingLabel.Location = new System.Drawing.Point(119, 12); this.loadingLabel.Location = new System.Drawing.Point(119, 12);
this.loadingLabel.Name = "loadingLabel"; this.loadingLabel.Name = "loadingLabel";
this.loadingLabel.Size = new System.Drawing.Size(335, 91); this.loadingLabel.Size = new System.Drawing.Size(197, 91);
this.loadingLabel.TabIndex = 16; this.loadingLabel.TabIndex = 16;
this.loadingLabel.Text = "Loading..."; this.loadingLabel.Text = "Loading...";
// //

@ -4,6 +4,7 @@ using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using DotNetCTFDumper.MMFParser;
using DotNetCTFDumper.MMFParser.EXE; using DotNetCTFDumper.MMFParser.EXE;
using DotNetCTFDumper.MMFParser.EXE.Loaders; using DotNetCTFDumper.MMFParser.EXE.Loaders;
using DotNetCTFDumper.MMFParser.EXE.Loaders.Banks; using DotNetCTFDumper.MMFParser.EXE.Loaders.Banks;
@ -196,16 +197,13 @@ namespace DotNetCTFDumper.GUI
foreach (var item in gameData.GameChunks.Chunks) foreach (var item in gameData.GameChunks.Chunks)
{ {
string ActualName = item.Name; string ActualName = item.Name;
if (item.Loader is Frame frm) ActualName = ActualName + " "+frm.Name; if (item.Loader is Frame frm) ActualName = ActualName + " " + frm.Name;
ChunkNode newNode = Helper.GetChunkNode(item,ActualName); ChunkNode newNode = Helper.GetChunkNode(item, ActualName);
//if (item.Loader != null) newNode = new ChunkNode(ActualName, item.Loader); //if (item.Loader != null) newNode = new ChunkNode(ActualName, item.Loader);
//else newNode = new ChunkNode(ActualName, item); //else newNode = new ChunkNode(ActualName, item);
treeView1.Nodes.Add(newNode); treeView1.Nodes.Add(newNode);
if (item.Loader is Frame frame) if (item.Loader is Frame frame)
{
foreach (var frmChunk in frame.Chunks.Chunks) foreach (var frmChunk in frame.Chunks.Chunks)
{ {
var frameNode = Helper.GetChunkNode(frmChunk); var frameNode = Helper.GetChunkNode(frmChunk);
@ -223,8 +221,18 @@ namespace DotNetCTFDumper.GUI
} }
} }
} }
} }
else if (item.Loader is FrameItems items)
{
foreach (var key in items.ItemDict.Keys)
{
var frameItem = items.ItemDict[key];
var objNode = new ChunkNode($"{(Constants.ObjectType)frameItem.ObjectType} - {frameItem.Name}", frameItem);
newNode.Nodes.Add(objNode);
}
}
}
MFABtn.Visible = true; MFABtn.Visible = true;
FolderBTN.Visible = true; FolderBTN.Visible = true;
@ -239,8 +247,8 @@ namespace DotNetCTFDumper.GUI
loadingLabel.Visible = false; loadingLabel.Visible = false;
var toLog = ""; var toLog = "";
toLog += $"Title:{Exe.Instance.GameData.Name}\n"; toLog += $"Title:{Exe.Instance.GameData.Name}\n";
toLog += $"Copyright:{Exe.Instance.GameData.Copyright}\n"; toLog += $"Copyright:{Exe.Instance.GameData.Copyright}\n";
toLog += $"Editor Filename: {Exe.Instance.GameData.EditorFilename}\n"; //toLog += $"Editor Filename: {Exe.Instance.GameData.EditorFilename}\n";
toLog += $"Product Version: {Exe.Instance.GameData.ProductVersion}\n"; toLog += $"Product Version: {Exe.Instance.GameData.ProductVersion}\n";
toLog += $"Build: {Exe.Instance.GameData.Build}\n"; toLog += $"Build: {Exe.Instance.GameData.Build}\n";
toLog += $"Runtime Version: {Exe.Instance.GameData.RuntimeVersion}\n"; toLog += $"Runtime Version: {Exe.Instance.GameData.RuntimeVersion}\n";

@ -62,7 +62,7 @@ namespace DotNetCTFDumper.MMFParser.EXE
{ {
Id = exeReader.ReadInt16(); Id = exeReader.ReadInt16();
Name = this.ActualName(); Name = _chunkList.GetNameByID(Id);
Flag = (ChunkFlags) exeReader.ReadInt16(); Flag = (ChunkFlags) exeReader.ReadInt16();
Size = exeReader.ReadInt32(); Size = exeReader.ReadInt32();
@ -317,9 +317,89 @@ namespace DotNetCTFDumper.MMFParser.EXE
} }
} }
//Logger.Log($"ChunkLoader {typeof(T).Name} not found", true, ConsoleColor.Red);
return null; return null;
} }
public string GetNameByID(int id)
{
switch (id)
{
case 4386: return "PREVIEW";
case 8738: return "Mini Header";
case 8739: return "Header";
case 8740: return "Title";
case 8741: return "Author";
case 8742: return "Menu";
case 8743: return "Extra Path";
case 8744: return "Extensions";
case 8745: return "Object Bank";
case 8746: return "Global Events";
case 8747: return "Frame Handles";
case 8748: return "Extra Data";
case 8749: return "Additional Extensions";
case 8750: return "Project Path";
case 8751: return "Output Path";
case 8752: return "App Doc";
case 8753: return "Other Extensions";
case 8754: return "Global Values";
case 8755: return "Global Strings";
case 8756: return "Extensions List";
case 8757: return "Icon";
case 8758: return "Demo Version";
case 8759: return "Security Number";
case 8760: return "Binary Files";
case 8761: return "Menu Images";
case 8762: return "About";
case 8763: return "Copyright";
case 8764: return "Global Value Names";
case 8765: return "Global String Names";
case 8766: return "Movement Extensions";
case 8767: return "Object Bank 2";
case 8768: return "EXE Only";
case 8770: return "Protection";
case 8771: return "Shaders";
case 8773: return "Extended Header";
case 13107:return "Frame";
case 13108:return "Frame Header";
case 13109:return "Frame Name";
case 13110:return "Frame Password";
case 13111:return "Frame Palette";
case 13112:return "Frame Objects";
case 13113:return "Frame Fade In Frame";
case 13114:return "Frame Fade Out Frame";
case 13115:return "Frame Fade In";
case 13116:return "Frame Fade Out";
case 13117:return "Frame Events";
case 13118:return "Frame Play Header";
case 13119:return "Additional Frame Item";
case 13120:return "Additional Object Instance";
case 13121:return "Frame Layers";
case 13122:return "Frame Virtual Rect";
case 13123:return "Demo File Path";
case 13124:return "Random Seed";
case 13125:return "Frame Layer Effects";
case 13126:return "Bluray Options";
case 13127:return "MVTimer Base";
case 13128:return "Mosaic Image Table";
case 13129:return "Frame Effects";
case 13130:return "Frame Iphone Options";
case 17476:return "Object Header";
case 17477:return "Object Name";
case 17478:return "Object Common";
case 17479:return "Object Unknown";
case 17480:return "Object Effects";
case 21845:return "Image Offsets";
case 21846:return "Font Offsets";
case 21847:return "Sound Offsets";
case 21848:return "Music Offsets";
case 26214:return "Image Bank";
case 26215:return "Font Bank";
case 26216:return "Sound Bank";
case 26217:return "Music Bank";
case 32639:return "Last";
default: return $"Unknown-{id}";
}
}
} }
} }

@ -1,4 +1,5 @@
using System; using System;
using System.Data.OleDb;
using System.IO; using System.IO;
using DotNetCTFDumper.Utils; using DotNetCTFDumper.Utils;
@ -66,18 +67,25 @@ namespace DotNetCTFDumper.MMFParser.EXE
exeReader.Seek((int)possition); exeReader.Seek((int)possition);
UInt16 firstShort = exeReader.PeekUInt16(); UInt16 firstShort = exeReader.PeekUInt16();
Logger.Log("First Short: " + firstShort.ToString("X2"), true, ConsoleColor.Yellow); Logger.Log("First Short: " + firstShort.ToString("X2"), true, ConsoleColor.Yellow);
if (firstShort == 0x7777) Settings.Old = false;
if (firstShort == 0x7777) else Settings.Old = true;
if (!Settings.Old)
{ {
Logger.Log("Found PackData header!\nReading PackData header.", true, ConsoleColor.Blue);
PackData = new PackData(); PackData = new PackData();
PackData.Read(exeReader); PackData.Read(exeReader);
GameData = new GameData(); GameData = new GameData();
GameData.Read(exeReader); GameData.Read(exeReader);
Console.ForegroundColor = ConsoleColor.DarkGreen; Console.ForegroundColor = ConsoleColor.DarkGreen;
Logger.Log("Found PackData header!\nReading PackData header.", true, ConsoleColor.Blue);
} }
else else
{ {
var oldData = new ChunkList();
oldData.Read(exeReader);
GameData = new GameData();
GameData.Read(exeReader);
Console.ForegroundColor = ConsoleColor.DarkGreen;
Logger.Log("Failed to find PackData header!\n", true, ConsoleColor.Red); Logger.Log("Failed to find PackData header!\n", true, ConsoleColor.Red);
} }

@ -149,9 +149,9 @@ namespace DotNetCTFDumper.MMFParser.EXE.Loaders.Banks
_bitmap = null; _bitmap = null;
Reader.Seek(Position); Reader.Seek(Position);
ByteReader imageReader; ByteReader imageReader;
// imageReader = Debug ? Reader : Decompressor.DecompressAsReader(Reader, out var a);
imageReader = Debug ? Reader : Decompressor.DecompressAsReader(Reader, out var a); imageReader = Debug ? Reader : Decompressor.DecompressAsReader(Reader, out var a);
long start = imageReader.Tell(); long start = imageReader.Tell();
_checksum = imageReader.ReadInt32(); _checksum = imageReader.ReadInt32();

@ -37,7 +37,12 @@ namespace DotNetCTFDumper.MMFParser.EXE.Loaders
public override string[] GetReadableData() public override string[] GetReadableData()
{ {
throw new NotImplementedException(); return new string[]
{
$"Name: {this.Name}",
$"Type: {(Constants.ObjectType)this.ObjectType}"
};
} }
public override void Read() public override void Read()

@ -27,7 +27,7 @@ namespace DotNetCTFDumper
var path = ""; var path = "";
var verbose = false; var verbose = false;
var dumpImages = false; var dumpImages = true;
var dumpSounds = true; var dumpSounds = true;
if (args.Length == 0) if (args.Length == 0)

@ -10,6 +10,7 @@ namespace DotNetCTFDumper
public static bool DumpMusic; public static bool DumpMusic;
public static bool SaveChunks; public static bool SaveChunks;
public static bool Verbose; public static bool Verbose;
public static bool Old;
public static string GamePath; public static string GamePath;
public static string GameName => Path.GetFileNameWithoutExtension(GamePath); public static string GameName => Path.GetFileNameWithoutExtension(GamePath);

@ -37,6 +37,10 @@ namespace DotNetCTFDumper.Utils
{ {
flag |= (uint) Math.Pow(2,Array.IndexOf(Keys,key)); flag |= (uint) Math.Pow(2,Array.IndexOf(Keys,key));
} }
else
{
flag &= (uint) Math.Pow(~2,Array.IndexOf(Keys,key));
}
} }

@ -40,6 +40,7 @@ namespace DotNetCTFDumper.Utils
Array.Resize<byte>(ref decompressedData, decompSize); Array.Resize<byte>(ref decompressedData, decompSize);
return decompressedData; return decompressedData;
} }
public static byte[] compress_block(byte[] data) public static byte[] compress_block(byte[] data)
{ {

@ -217,6 +217,7 @@ namespace DotNetCTFDumper.Utils
public static string ActualName(this ChunkList.Chunk chunk) public static string ActualName(this ChunkList.Chunk chunk)
{ {
return "Placeholder";
var constName = ((Constants.ChunkNames) chunk.Id).ToString(); var constName = ((Constants.ChunkNames) chunk.Id).ToString();
int tempId = 0; int tempId = 0;
int.TryParse(constName, out tempId); int.TryParse(constName, out tempId);

Loading…
Cancel
Save