Sorted dumping fixes

master
1987kostya 4 years ago
parent d91d1c2f28
commit aa549a64e2

@ -56,6 +56,7 @@
this.musicsButton = new System.Windows.Forms.Button(); this.musicsButton = new System.Windows.Forms.Button();
this.musicBar = new System.Windows.Forms.ProgressBar(); this.musicBar = new System.Windows.Forms.ProgressBar();
this.musicLabel = new System.Windows.Forms.Label(); this.musicLabel = new System.Windows.Forms.Label();
this.SortedProgressBar = new System.Windows.Forms.ProgressBar();
this.ChunkCombo.SuspendLayout(); this.ChunkCombo.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -113,7 +114,6 @@
this.listBox1.MaximumSize = new System.Drawing.Size(300, 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.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.listBox1.Size = new System.Drawing.Size(300, 277); this.listBox1.Size = new System.Drawing.Size(300, 277);
this.listBox1.TabIndex = 5; this.listBox1.TabIndex = 5;
// //
@ -404,12 +404,22 @@
this.musicLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.musicLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.musicLabel.Visible = false; this.musicLabel.Visible = false;
// //
// SortedProgressBar
//
this.SortedProgressBar.Location = new System.Drawing.Point(190, 310);
this.SortedProgressBar.Name = "SortedProgressBar";
this.SortedProgressBar.Size = new System.Drawing.Size(209, 41);
this.SortedProgressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
this.SortedProgressBar.TabIndex = 24;
this.SortedProgressBar.Visible = false;
//
// MainForm // MainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Black; this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(943, 507); this.ClientSize = new System.Drawing.Size(943, 507);
this.Controls.Add(this.SortedProgressBar);
this.Controls.Add(this.musicLabel); this.Controls.Add(this.musicLabel);
this.Controls.Add(this.musicBar); this.Controls.Add(this.musicBar);
this.Controls.Add(this.musicsButton); this.Controls.Add(this.musicsButton);
@ -441,6 +451,8 @@
this.PerformLayout(); this.PerformLayout();
} }
private System.Windows.Forms.ProgressBar SortedProgressBar;
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.ContextMenuStrip ChunkCombo; private System.Windows.Forms.ContextMenuStrip ChunkCombo;
private System.Windows.Forms.Button cryptKeyBtn; private System.Windows.Forms.Button cryptKeyBtn;

@ -1,4 +1,5 @@
using System; using System;
using System.CodeDom;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
@ -25,6 +26,11 @@ namespace DotNetCTFDumper.GUI
public PackDataForm PackForm; public PackDataForm PackForm;
public delegate void SaveHandler(int index, int all); public delegate void SaveHandler(int index, int all);
public delegate void IncrementSortedProgressBar(int all);
public MainForm() public MainForm()
{ {
//Buttons //Buttons
@ -89,11 +95,11 @@ namespace DotNetCTFDumper.GUI
private void StartReading() private void StartReading()
{ {
var path = openFileDialog1.FileName; var path = openFileDialog1.FileName;
loadingLabel.Visible = true;
Program.ReadFile(path, Settings.Verbose, Settings.DumpImages, Settings.DumpSounds); Program.ReadFile(path, Settings.Verbose, Settings.DumpImages, Settings.DumpSounds);
imageBar.Value = 0; imageBar.Value = 0;
soundBar.Value = 0; soundBar.Value = 0;
GameInfo.Text = ""; GameInfo.Text = "";
loadingLabel.Visible = true;
imageLabel.Text = "Using nonGUI mode"; imageLabel.Text = "Using nonGUI mode";
soundLabel.Text = "Using nonGUI mode"; soundLabel.Text = "Using nonGUI mode";
@ -196,6 +202,7 @@ namespace DotNetCTFDumper.GUI
treeView1.Nodes.Clear(); treeView1.Nodes.Clear();
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);
@ -263,6 +270,8 @@ namespace DotNetCTFDumper.GUI
Exe.Instance.GameData.GameChunks.GetChunk<SoundBank>().OnSoundSaved += UpdateSoundBar; Exe.Instance.GameData.GameChunks.GetChunk<SoundBank>().OnSoundSaved += UpdateSoundBar;
if (Exe.Instance.GameData.GameChunks.GetChunk<MusicBank>() != null) if (Exe.Instance.GameData.GameChunks.GetChunk<MusicBank>() != null)
Exe.Instance.GameData.GameChunks.GetChunk<MusicBank>().OnMusicSaved += UpdateMusicBar; Exe.Instance.GameData.GameChunks.GetChunk<MusicBank>().OnMusicSaved += UpdateMusicBar;
ImageDumper.SortedImageSaved += IncrementSortedBar;
GameInfo.Text = toLog; GameInfo.Text = toLog;
} }
@ -290,6 +299,17 @@ namespace DotNetCTFDumper.GUI
musicLabel.Text = $"{index}/{all}"; musicLabel.Text = $"{index}/{all}";
} }
public void IncrementSortedBar(int all)
{
SortedProgressBar.Visible = true;
SortedProgressBar.Maximum = all;
SortedProgressBar.Value += 1;
if (SortedProgressBar.Value >= SortedProgressBar.Maximum)
{
SortedProgressBar.Visible = false;
}
}
private void FolderBTN_Click(object sender, EventArgs e) private void FolderBTN_Click(object sender, EventArgs e)
{ {

@ -53,7 +53,7 @@ namespace DotNetCTFDumper.MMFParser.EXE.Loaders
foreach (var infoChunk in infoChunks.Chunks) foreach (var infoChunk in infoChunks.Chunks)
{ {
infoChunk.Verbose = false; infoChunk.Verbose = false;
var loader = infoChunk.Loader; var loader = infoChunk.Loader;
if (loader != null) if (loader != null)

@ -1,7 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using DotNetCTFDumper.GUI;
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;
@ -13,14 +15,26 @@ namespace DotNetCTFDumper.Utils
{ {
public static void DumpImages() public static void DumpImages()
{ {
Dump(); using (var worker = new BackgroundWorker())
{
worker.DoWork += (senderA, eA) => { Dump(); };
worker.RunWorkerCompleted += (senderA, eA) =>
{
};
worker.RunWorkerAsync();
}
} }
public static MainForm.IncrementSortedProgressBar SortedImageSaved;
public static void Dump() public static void Dump()
{ {
var rootFolder = $"{Settings.DumpPath}\\ImageBank\\Sorted"; var rootFolder = $"{Settings.ImagePath}\\Sorted";
var Bank = Exe.Instance.GameData.GameChunks.GetChunk<ImageBank>(); var Bank = Exe.Instance.GameData.GameChunks.GetChunk<ImageBank>();
var NumberOfImgFrames = CalculateFrameCount();
foreach (var frame in Exe.Instance.GameData.Frames) foreach (var frame in Exe.Instance.GameData.Frames)
{ {
if (frame.Objects != null) if (frame.Objects != null)
@ -31,7 +45,7 @@ namespace DotNetCTFDumper.Utils
{ {
var currentObjPath = currentFramePath + "\\" + Helper.CleanInput(item.Name); var currentObjPath = currentFramePath + "\\" + Helper.CleanInput(item.Name);
Directory.CreateDirectory(currentObjPath); //Directory.CreateDirectory(currentObjPath);
var frames = item.FrameItem.GetFrames(); var frames = item.FrameItem.GetFrames();
foreach (var key in frames.Keys) foreach (var key in frames.Keys)
{ {
@ -43,9 +57,12 @@ namespace DotNetCTFDumper.Utils
var path = var path =
$"{Settings.ImagePath}\\Sorted\\{frame.Name}\\{Helper.CleanInput(item.Name)}\\{name}"; $"{Settings.ImagePath}\\Sorted\\{frame.Name}\\{Helper.CleanInput(item.Name)}\\{name}";
Directory.CreateDirectory(Path.GetDirectoryName(path)); Directory.CreateDirectory(Path.GetDirectoryName(path));
Logger.Log("Saving Image: "+path); //Logger.Log("Saving Image: "+path);
actualFrame.Save(path); actualFrame.Save(path);
SortedImageSaved.Invoke(NumberOfImgFrames);
} }
catch (Exception e) catch (Exception e)
{ {
@ -60,6 +77,19 @@ namespace DotNetCTFDumper.Utils
} }
Logger.Log("Sorted Images Done",true,ConsoleColor.Yellow); Logger.Log("Sorted Images Done",true,ConsoleColor.Yellow);
} }
public static int CalculateFrameCount()
{
int count = 0;
foreach (var frame in Exe.Instance.GameData.Frames)
{
foreach (ObjectInstance objectInstance in frame.Objects.Items)
{
count += objectInstance.FrameItem.GetFrames().Count;
}
}
return count;
}

Loading…
Cancel
Save