GUI Updates,

Plugin Support
master
1987kostya 4 years ago
parent 70f557bf45
commit 87b30637fb

@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.30517.126
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetCTFDumper", "DotNetCTFDumper\DotNetCTFDumper.csproj", "{86D99F9E-98FB-4E50-AB68-F5C115850C33}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetCTFDumper", "DotNetCTFDumper\DotNetCTFDumper.csproj", "{86D99F9E-98FB-4E50-AB68-F5C115850C33}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExamplePlugin", "ExamplePlugin\ExamplePlugin.csproj", "{9A4499BF-534F-4397-AF0D-C663688A20E5}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -21,6 +23,14 @@ Global
{86D99F9E-98FB-4E50-AB68-F5C115850C33}.Release|Any CPU.Build.0 = Release|Any CPU {86D99F9E-98FB-4E50-AB68-F5C115850C33}.Release|Any CPU.Build.0 = Release|Any CPU
{86D99F9E-98FB-4E50-AB68-F5C115850C33}.Release|x64.ActiveCfg = Release|x64 {86D99F9E-98FB-4E50-AB68-F5C115850C33}.Release|x64.ActiveCfg = Release|x64
{86D99F9E-98FB-4E50-AB68-F5C115850C33}.Release|x64.Build.0 = Release|x64 {86D99F9E-98FB-4E50-AB68-F5C115850C33}.Release|x64.Build.0 = Release|x64
{9A4499BF-534F-4397-AF0D-C663688A20E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A4499BF-534F-4397-AF0D-C663688A20E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A4499BF-534F-4397-AF0D-C663688A20E5}.Debug|x64.ActiveCfg = Debug|Any CPU
{9A4499BF-534F-4397-AF0D-C663688A20E5}.Debug|x64.Build.0 = Debug|Any CPU
{9A4499BF-534F-4397-AF0D-C663688A20E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A4499BF-534F-4397-AF0D-C663688A20E5}.Release|Any CPU.Build.0 = Release|Any CPU
{9A4499BF-534F-4397-AF0D-C663688A20E5}.Release|x64.ActiveCfg = Release|Any CPU
{9A4499BF-534F-4397-AF0D-C663688A20E5}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

@ -71,6 +71,9 @@
this.advDumpTab = new System.Windows.Forms.TabPage(); this.advDumpTab = new System.Windows.Forms.TabPage();
this.advancedPictureBox = new System.Windows.Forms.PictureBox(); this.advancedPictureBox = new System.Windows.Forms.PictureBox();
this.advancedTreeView = new System.Windows.Forms.TreeView(); this.advancedTreeView = new System.Windows.Forms.TreeView();
this.pluginTab = new System.Windows.Forms.TabPage();
this.activatePluginBtn = new System.Windows.Forms.Button();
this.pluginsList = new System.Windows.Forms.ListBox();
this.packDataDialog = new System.Windows.Forms.SaveFileDialog(); this.packDataDialog = new System.Windows.Forms.SaveFileDialog();
this.ChunkCombo.SuspendLayout(); this.ChunkCombo.SuspendLayout();
this.tabControl1.SuspendLayout(); this.tabControl1.SuspendLayout();
@ -80,6 +83,7 @@
this.cryptKeyTab.SuspendLayout(); this.cryptKeyTab.SuspendLayout();
this.advDumpTab.SuspendLayout(); this.advDumpTab.SuspendLayout();
((System.ComponentModel.ISupportInitialize) (this.advancedPictureBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize) (this.advancedPictureBox)).BeginInit();
this.pluginTab.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// button1 // button1
@ -380,6 +384,7 @@
this.tabControl1.Controls.Add(this.packDataTab); this.tabControl1.Controls.Add(this.packDataTab);
this.tabControl1.Controls.Add(this.cryptKeyTab); this.tabControl1.Controls.Add(this.cryptKeyTab);
this.tabControl1.Controls.Add(this.advDumpTab); this.tabControl1.Controls.Add(this.advDumpTab);
this.tabControl1.Controls.Add(this.pluginTab);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.tabControl1.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.tabControl1.HotTrack = true; this.tabControl1.HotTrack = true;
@ -456,6 +461,7 @@
this.mfaLogBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.mfaLogBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.mfaLogBox.Size = new System.Drawing.Size(405, 479); this.mfaLogBox.Size = new System.Drawing.Size(405, 479);
this.mfaLogBox.TabIndex = 0; this.mfaLogBox.TabIndex = 0;
this.mfaLogBox.Text = "MFA Generation is currently unstable\r\nUSE AT YOUR OWN RISK";
// //
// packDataTab // packDataTab
// //
@ -596,7 +602,7 @@
// //
// advancedPictureBox // advancedPictureBox
// //
this.advancedPictureBox.BackColor = System.Drawing.Color.DimGray; this.advancedPictureBox.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64)))));
this.advancedPictureBox.Dock = System.Windows.Forms.DockStyle.Fill; this.advancedPictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.advancedPictureBox.Location = new System.Drawing.Point(170, 3); this.advancedPictureBox.Location = new System.Drawing.Point(170, 3);
this.advancedPictureBox.Name = "advancedPictureBox"; this.advancedPictureBox.Name = "advancedPictureBox";
@ -614,6 +620,40 @@
this.advancedTreeView.TabIndex = 0; this.advancedTreeView.TabIndex = 0;
this.advancedTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.advancedTreeView_AfterSelect); this.advancedTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.advancedTreeView_AfterSelect);
// //
// pluginTab
//
this.pluginTab.BackColor = System.Drawing.Color.Black;
this.pluginTab.Controls.Add(this.activatePluginBtn);
this.pluginTab.Controls.Add(this.pluginsList);
this.pluginTab.Location = new System.Drawing.Point(4, 24);
this.pluginTab.Name = "pluginTab";
this.pluginTab.Size = new System.Drawing.Size(935, 479);
this.pluginTab.TabIndex = 5;
this.pluginTab.Text = "Plugins";
//
// activatePluginBtn
//
this.activatePluginBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.activatePluginBtn.Font = new System.Drawing.Font("Feast of Flesh BB", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte) (77)));
this.activatePluginBtn.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.activatePluginBtn.Location = new System.Drawing.Point(258, 3);
this.activatePluginBtn.Name = "activatePluginBtn";
this.activatePluginBtn.Size = new System.Drawing.Size(140, 67);
this.activatePluginBtn.TabIndex = 1;
this.activatePluginBtn.Text = "Activate";
this.activatePluginBtn.UseVisualStyleBackColor = true;
this.activatePluginBtn.Click += new System.EventHandler(this.activatePluginBtn_Click);
//
// pluginsList
//
this.pluginsList.Dock = System.Windows.Forms.DockStyle.Left;
this.pluginsList.FormattingEnabled = true;
this.pluginsList.ItemHeight = 15;
this.pluginsList.Location = new System.Drawing.Point(0, 0);
this.pluginsList.Name = "pluginsList";
this.pluginsList.Size = new System.Drawing.Size(252, 479);
this.pluginsList.TabIndex = 0;
//
// packDataDialog // packDataDialog
// //
this.packDataDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.packDataDialog_FileOk); this.packDataDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.packDataDialog_FileOk);
@ -641,9 +681,15 @@
this.cryptKeyTab.PerformLayout(); this.cryptKeyTab.PerformLayout();
this.advDumpTab.ResumeLayout(false); this.advDumpTab.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize) (this.advancedPictureBox)).EndInit(); ((System.ComponentModel.ISupportInitialize) (this.advancedPictureBox)).EndInit();
this.pluginTab.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
} }
private System.Windows.Forms.Button activatePluginBtn;
private System.Windows.Forms.ListBox pluginsList;
private System.Windows.Forms.TabPage pluginTab;
private System.Windows.Forms.PictureBox advancedPictureBox; private System.Windows.Forms.PictureBox advancedPictureBox;
private System.Windows.Forms.TreeView advancedTreeView; private System.Windows.Forms.TreeView advancedTreeView;

@ -11,6 +11,8 @@ 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;
using DotNetCTFDumper.MMFParser.EXE.Loaders.Objects;
using DotNetCTFDumper.MMFParser.MFA.Loaders.mfachunks;
using DotNetCTFDumper.MMFParser.Translation; using DotNetCTFDumper.MMFParser.Translation;
using DotNetCTFDumper.Utils; using DotNetCTFDumper.Utils;
@ -41,7 +43,8 @@ namespace DotNetCTFDumper.GUI
foreach (Control item in Controls) foreach (Control item in Controls)
{ {
item.ForeColor = ColorTheme; item.ForeColor = ColorTheme;
item.BackColor=Color.Black; if(!(item is PictureBox)&&!(item is TabPage))item.BackColor=Color.Black;
if(item is Button) item.BackColor=Color.FromArgb(30,30,30); if(item is Button) item.BackColor=Color.FromArgb(30,30,30);
if (item is Label) if (item is Label)
@ -56,7 +59,7 @@ namespace DotNetCTFDumper.GUI
foreach (Control item in tabPage.Controls) foreach (Control item in tabPage.Controls)
{ {
item.ForeColor = ColorTheme; item.ForeColor = ColorTheme;
item.BackColor=Color.Black; if(!(item is PictureBox)&&!(item is TabPage))item.BackColor=Color.Black;
if(item is Button) item.BackColor=Color.FromArgb(30,30,30); if(item is Button) item.BackColor=Color.FromArgb(30,30,30);
if (item is Label) if (item is Label)
@ -278,6 +281,7 @@ namespace DotNetCTFDumper.GUI
InitKeyTab(); InitKeyTab();
InitPackDataTab(); InitPackDataTab();
InitAdvancedDump(); InitAdvancedDump();
InitPlugins();
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";
@ -576,20 +580,78 @@ namespace DotNetCTFDumper.GUI
var bank = Exe.Instance.GameData.GameChunks.GetChunk<ImageBank>(); var bank = Exe.Instance.GameData.GameChunks.GetChunk<ImageBank>();
var items = bank.Images.ToList(); var items = bank.Images.ToList();
var filtered = items.OrderBy(x=>x.Value.Handle); var filtered = items.OrderBy(x=>x.Value.Handle);
foreach (var keypair in filtered) foreach (Frame frame in Exe.Instance.GameData.Frames)
{
var frameNode = new ChunkNode(frame.Name,frame);
advancedTreeView.Nodes.Add(frameNode);
if (frame.Objects != null)
{
foreach (ObjectInstance objInst in frame.Objects.Items)
{
var objInstNode = new ChunkNode(objInst.FrameItem.Name, objInst);
frameNode.Nodes.Add(objInstNode);
var loader = objInst.FrameItem.Properties.Loader;
if (loader is ObjectCommon common)
{
if (common.Animations != null)
{
foreach (var pair in common.Animations.AnimationDict)
{
var animNode = new ChunkNode($"Animation {pair.Key}", pair.Value);
objInstNode.Nodes.Add(animNode);
foreach (var dir in pair.Value.DirectionDict)
{
for (int a = 0; a < dir.Value.Frames.Count; a++)
{
var animFrame = dir.Value.Frames[a];
bank.Images.TryGetValue(animFrame, out var img);
var animFrameNode = new ChunkNode(a.ToString(), img);
animNode.Nodes.Add(animFrameNode);
}
}
}
}
}
else if (loader is Backdrop backdrop)
{
var backdropNode = new ChunkNode("Image", bank.Images[backdrop.Image]);
objInstNode.Nodes.Add(backdropNode);
}
}
}
}
}
public void InitPlugins()
{
PluginAPI.PluginAPI.InitializePlugins();
foreach (var plugin in PluginAPI.PluginAPI.Plugins)
{ {
advancedTreeView.Nodes.Add(new ChunkNode(keypair.Key.ToString(),keypair.Value)); pluginsList.Items.Add(plugin.Name);
} }
} }
private void advancedTreeView_AfterSelect(object sender, TreeViewEventArgs e) private void advancedTreeView_AfterSelect(object sender, TreeViewEventArgs e)
{ {
var node = e.Node; var node = e.Node;
var img = ((ImageItem) ((ChunkNode) node).loader); if (!(((ChunkNode) node).loader is ImageItem))
if(img.Bitmap==null)img.Load(); {
advancedPictureBox.Image = advancedPictureBox.ErrorImage;
}
else
{
var img = ((ImageItem) ((ChunkNode) node).loader);
advancedPictureBox.Image = img.Bitmap;
}
advancedPictureBox.Image = img.Bitmap; }
private void activatePluginBtn_Click(object sender, EventArgs e)
{
PluginAPI.PluginAPI.Plugins[pluginsList.SelectedIndex].pluginClass.Activate(null);
} }
} }
} }

@ -114,11 +114,16 @@ namespace DotNetCTFDumper.MMFParser.EXE.Loaders
bmp = images.Images[firstFrameHandle]; bmp = images.Images[firstFrameHandle];
} }
} }
else if (ObjectType == 1) else if (ObjectType == 1)//Backdrop
{ {
images.Images.TryGetValue(((Backdrop) Properties.Loader).Image, out var img); images.Images.TryGetValue(((Backdrop) Properties.Loader).Image, out var img);
bmp = img; bmp = img;
} }
else if (ObjectType==0)//QuickBackdrop
{
}
return bmp; return bmp;
} }
@ -152,7 +157,12 @@ namespace DotNetCTFDumper.MMFParser.EXE.Loaders
{ {
//TODO: Fix shit //TODO: Fix shit
if (ObjectType == 1)//Backdrop if(ObjectType==0)//QuickBackdrop
{
}
else if (ObjectType == 1)//Backdrop
{ {
Loader = new Backdrop(Reader); Loader = new Backdrop(Reader);
} }

@ -2,7 +2,7 @@
{ {
public interface IPlugin public interface IPlugin
{ {
object Activate(object input);
} }
} }

@ -1,7 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using DotNetCTFDumper.MMFParser.EXE.Loaders; using DotNetCTFDumper.MMFParser.EXE.Loaders;
using DotNetCTFDumper.MMFParser.MFA; using DotNetCTFDumper.MMFParser.MFA;
using DotNetCTFDumper.MMFParser.MFA.Loaders; using DotNetCTFDumper.MMFParser.MFA.Loaders;
@ -10,33 +12,56 @@ using Layer = DotNetCTFDumper.MMFParser.MFA.Loaders.Layer;
namespace DotNetCTFDumper.PluginAPI namespace DotNetCTFDumper.PluginAPI
{ {
public class PluginAPI public static class PluginAPI
{ {
public static Frame GetEmptyFrame(List<Color> palette, int handle = 0, int x = 640, int y = 480, public static string PluginPath = System.IO.Path.Combine(
string name = "New Frame") Directory.GetCurrentDirectory(),
"Plugins");
public static List<Plugin> Plugins = new List<Plugin>();
public static void InitializePlugins()
{ {
var frame = new Frame(null) Plugins.Clear();
DirectoryInfo pluginDirectory = new DirectoryInfo(PluginPath);
if (!pluginDirectory.Exists)
pluginDirectory.Create();
var pluginFiles = Directory.GetFiles(PluginPath, "*.dll");
foreach (var file in pluginFiles)
{ {
Handle = 0, Assembly asm = Assembly.LoadFrom(file);
Name = name, var types = asm.GetTypes().Where(t =>
Password = "", t.GetInterfaces().Where(i => i.FullName == typeof(IPlugin).FullName).Any());
SizeX = x, foreach (var type in types)
SizeY = y, {
Background = Color.Green, var pluginClass = asm.CreateInstance(type.FullName) as IPlugin;
Palette = palette, var plugin = new Plugin(type.Name,"Kostya",pluginClass);
Layers = new List<Layer>(), Plugins.Add(plugin);
Folders = new List<ItemFolder>(), }
Items = new List<FrameItem>(), }
Events = MFA.emptyEvents,
Chunks = MFA.emptyFrameChunks
};
frame.Flags.flag = 260;
//frame.Instances = template.Frames[0].Instances;
var testLayer = new Layer(null) {Name = "New Super Layer"};
frame.Layers.Add(testLayer);
return frame;
} }
} }
public class Plugin
{
public string Name;
public Plugin(string name, string author, IPlugin pluginClass)
{
Name = name;
Author = author;
this.pluginClass = pluginClass;
}
public string Author;
public IPlugin pluginClass;
}
} }

@ -56,7 +56,7 @@ namespace DotNetCTFDumper
ConsoleColor.Green); ConsoleColor.Green);
Logger.Log(" DumpSounds - Dump sounds to 'DUMP\\[your game]\\SoundBank'(default:true)\n", true, Logger.Log(" DumpSounds - Dump sounds to 'DUMP\\[your game]\\SoundBank'(default:true)\n", true,
ConsoleColor.Green); ConsoleColor.Green);
Logger.Log("Exaple: DotNetCTFDumper.exe E:\\SisterLocation.exe true true false true", true, Logger.Log("Example: DotNetCTFDumper.exe E:\\SisterLocation.exe true true false true", true,
ConsoleColor.Green); ConsoleColor.Green);
Console.ReadKey(); Console.ReadKey();
Environment.Exit(0); Environment.Exit(0);
@ -113,8 +113,8 @@ namespace DotNetCTFDumper
Directory.CreateDirectory($"{Settings.SoundPath}"); Directory.CreateDirectory($"{Settings.SoundPath}");
Directory.CreateDirectory($"{Settings.MusicPath}"); Directory.CreateDirectory($"{Settings.MusicPath}");
Directory.CreateDirectory($"{Settings.ChunkPath}"); Directory.CreateDirectory($"{Settings.ChunkPath}");
Directory.CreateDirectory($"{Settings.ExtensionPath}"); Directory.CreateDirectory($"{Settings.ExtensionPath}");
Directory.CreateDirectory($"{PluginAPI.PluginAPI.PluginPath}");
} }
public static void InitNativeLibrary() public static void InitNativeLibrary()
{ {

Loading…
Cancel
Save