@ -1,4 +1,5 @@
using System ;
using System ;
using System.Collections.Generic ;
using System.ComponentModel ;
using System.ComponentModel ;
using System.Diagnostics ;
using System.Diagnostics ;
using System.Drawing ;
using System.Drawing ;
@ -15,6 +16,8 @@ using DotNetCTFDumper.MMFParser.EXE.Loaders.Objects;
using DotNetCTFDumper.MMFParser.MFA.Loaders.mfachunks ;
using DotNetCTFDumper.MMFParser.MFA.Loaders.mfachunks ;
using DotNetCTFDumper.MMFParser.Translation ;
using DotNetCTFDumper.MMFParser.Translation ;
using DotNetCTFDumper.Utils ;
using DotNetCTFDumper.Utils ;
using Animation = DotNetCTFDumper . MMFParser . EXE . Loaders . Objects . Animation ;
using AnimationDirection = DotNetCTFDumper . MMFParser . EXE . Loaders . Objects . AnimationDirection ;
namespace DotNetCTFDumper.GUI
namespace DotNetCTFDumper.GUI
{
{
@ -49,7 +52,7 @@ namespace DotNetCTFDumper.GUI
if ( item is Label )
if ( item is Label )
{
{
item . BackColor = Color . Transparent ;
//item.BackColor = Color.Transparent ;
item . Refresh ( ) ;
item . Refresh ( ) ;
}
}
}
}
@ -59,12 +62,12 @@ namespace DotNetCTFDumper.GUI
foreach ( Control item in tabPage . Controls )
foreach ( Control item in tabPage . Controls )
{
{
item . ForeColor = ColorTheme ;
item . ForeColor = ColorTheme ;
if ( ! ( item is PictureBox ) & & ! ( item is TabPage ) )item . BackColor = Color . Black ;
if ( ! ( item is PictureBox ) & & ! ( item is TabPage ) && ! ( item is Label )) 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 )
{
{
item . BackColor = Color . Transparent ;
//item.BackColor = Color.Transparent ;
item . Refresh ( ) ;
item . Refresh ( ) ;
}
}
@ -76,6 +79,7 @@ namespace DotNetCTFDumper.GUI
( ( ToolStripItem ) item ) . ForeColor = ColorTheme ;
( ( ToolStripItem ) item ) . ForeColor = ColorTheme ;
( ( ToolStripItem ) item ) . BackColor = Color . Black ;
( ( ToolStripItem ) item ) . BackColor = Color . Black ;
}
}
hexBox1 . ForeColor = ColorTheme ;
hexBox1 . ForeColor = ColorTheme ;
hexBox1 . InfoForeColor = Color . FromArgb ( ColorTheme . R / 2 , ColorTheme . G / 2 , ColorTheme . B / 2 ) ;
hexBox1 . InfoForeColor = Color . FromArgb ( ColorTheme . R / 2 , ColorTheme . G / 2 , ColorTheme . B / 2 ) ;
hexBox1 . SelectionForeColor = Color . FromArgb ( ColorTheme . R , ColorTheme . G , ColorTheme . B ) ;
hexBox1 . SelectionForeColor = Color . FromArgb ( ColorTheme . R , ColorTheme . G , ColorTheme . B ) ;
@ -153,6 +157,7 @@ namespace DotNetCTFDumper.GUI
ChunkCombo . Show ( Cursor . Position ) ;
ChunkCombo . Show ( Cursor . Position ) ;
}
}
private void treeView1_RightClick ( object sender , MouseEventArgs e )
private void treeView1_RightClick ( object sender , MouseEventArgs e )
{
{
if ( ( e . Button & MouseButtons . Right ) ! = 0 )
if ( ( e . Button & MouseButtons . Right ) ! = 0 )
@ -161,6 +166,7 @@ namespace DotNetCTFDumper.GUI
}
}
}
}
private void ChunkCombo_ItemSelected ( object sender , ToolStripItemClickedEventArgs e )
private void ChunkCombo_ItemSelected ( object sender , ToolStripItemClickedEventArgs e )
{
{
switch ( e . ClickedItem . Name )
switch ( e . ClickedItem . Name )
@ -171,6 +177,7 @@ namespace DotNetCTFDumper.GUI
{
{
chunk . Save ( ) ;
chunk . Save ( ) ;
}
}
break ;
break ;
case "viewHexBtn" :
case "viewHexBtn" :
ShowHex ( ) ;
ShowHex ( ) ;
@ -200,7 +207,8 @@ namespace DotNetCTFDumper.GUI
listBox1 . Items . Add ( $"Id: {nodeChunk.Id}" ) ;
listBox1 . Items . Add ( $"Id: {nodeChunk.Id}" ) ;
listBox1 . Items . Add ( $"Flag: {nodeChunk.Flag}" ) ;
listBox1 . Items . Add ( $"Flag: {nodeChunk.Flag}" ) ;
listBox1 . Items . Add ( $"Size: {nodeChunk.Size.ToPrettySize()}" ) ;
listBox1 . Items . Add ( $"Size: {nodeChunk.Size.ToPrettySize()}" ) ;
if ( nodeChunk . DecompressedSize > - 1 ) listBox1 . Items . Add ( $"Decompressed Size: {nodeChunk.DecompressedSize.ToPrettySize()}" ) ;
if ( nodeChunk . DecompressedSize > - 1 )
listBox1 . Items . Add ( $"Decompressed Size: {nodeChunk.DecompressedSize.ToPrettySize()}" ) ;
}
}
if ( nodeLoader ! = null )
if ( nodeLoader ! = null )
@ -218,6 +226,7 @@ namespace DotNetCTFDumper.GUI
}
}
}
}
}
}
GameInfo . BackColor = Color . Transparent ;
GameInfo . BackColor = Color . Transparent ;
GameInfo . Refresh ( ) ;
GameInfo . Refresh ( ) ;
@ -263,7 +272,8 @@ namespace DotNetCTFDumper.GUI
foreach ( var key in items . ItemDict . Keys )
foreach ( var key in items . ItemDict . Keys )
{
{
var frameItem = items . ItemDict [ key ] ;
var frameItem = items . ItemDict [ key ] ;
var objNode = new ChunkNode ( $"{(Constants.ObjectType)frameItem.ObjectType} - {frameItem.Name}" , frameItem ) ;
var objNode = new ChunkNode ( $"{(Constants.ObjectType) frameItem.ObjectType} - {frameItem.Name}" ,
frameItem ) ;
newNode . Nodes . Add ( objNode ) ;
newNode . Nodes . Add ( objNode ) ;
}
}
@ -323,6 +333,7 @@ namespace DotNetCTFDumper.GUI
soundBar . Value = ( int ) ( index / ( float ) all * 100 ) ;
soundBar . Value = ( int ) ( index / ( float ) all * 100 ) ;
soundLabel . Text = $"{index}/{all}" ;
soundLabel . Text = $"{index}/{all}" ;
}
}
public void UpdateMusicBar ( int index , int all )
public void UpdateMusicBar ( int index , int all )
{
{
all - = 1 ;
all - = 1 ;
@ -366,6 +377,7 @@ namespace DotNetCTFDumper.GUI
SetSoundElements ( false ) ;
SetSoundElements ( false ) ;
}
}
}
}
private void imagesButton_Click ( object sender , EventArgs e )
private void imagesButton_Click ( object sender , EventArgs e )
{
{
if ( Exe . Instance . GameData . GameChunks . GetChunk < ImageBank > ( ) = = null ) return ;
if ( Exe . Instance . GameData . GameChunks . GetChunk < ImageBank > ( ) = = null ) return ;
@ -384,6 +396,7 @@ namespace DotNetCTFDumper.GUI
SetImageElements ( false ) ;
SetImageElements ( false ) ;
}
}
}
}
private void musicsButton_Click ( object sender , EventArgs e )
private void musicsButton_Click ( object sender , EventArgs e )
{
{
if ( Exe . Instance . GameData . GameChunks . GetChunk < MusicBank > ( ) = = null ) return ;
if ( Exe . Instance . GameData . GameChunks . GetChunk < MusicBank > ( ) = = null ) return ;
@ -410,6 +423,7 @@ namespace DotNetCTFDumper.GUI
soundsButton . Text = state ? "Cancel" : "Dump Sounds" ;
soundsButton . Text = state ? "Cancel" : "Dump Sounds" ;
soundBar . Value = 0 ;
soundBar . Value = 0 ;
}
}
public void SetImageElements ( bool state )
public void SetImageElements ( bool state )
{
{
imageBar . Visible = state ;
imageBar . Visible = state ;
@ -417,6 +431,7 @@ namespace DotNetCTFDumper.GUI
imagesButton . Text = state ? "Cancel" : "Dump Images" ;
imagesButton . Text = state ? "Cancel" : "Dump Images" ;
imageBar . Value = 0 ;
imageBar . Value = 0 ;
}
}
public void SetMusicElements ( bool state )
public void SetMusicElements ( bool state )
{
{
musicBar . Visible = state ;
musicBar . Visible = state ;
@ -487,6 +502,7 @@ namespace DotNetCTFDumper.GUI
}
}
}
}
Process . Start ( $"{Settings.DumpPath}" ) ;
Process . Start ( $"{Settings.DumpPath}" ) ;
} ;
} ;
@ -510,6 +526,7 @@ namespace DotNetCTFDumper.GUI
rawData + = Settings . AppName ;
rawData + = Settings . AppName ;
rawData + = Settings . Copyright ;
rawData + = Settings . Copyright ;
}
}
try
try
{
{
var previewKey = Decryption . MakeKeyFromBytes ( rawData , ( byte ) int . Parse ( ( charBox . Text ) ) ) ;
var previewKey = Decryption . MakeKeyFromBytes ( rawData , ( byte ) int . Parse ( ( charBox . Text ) ) ) ;
@ -529,6 +546,7 @@ namespace DotNetCTFDumper.GUI
{
{
packDataListBox . Items . Add ( item . PackFilename ) ;
packDataListBox . Items . Add ( item . PackFilename ) ;
}
}
UpdatePackInfo ( 0 ) ;
UpdatePackInfo ( 0 ) ;
}
}
@ -537,6 +555,7 @@ namespace DotNetCTFDumper.GUI
var item = Exe . Instance . PackData . Items [ index ] ;
var item = Exe . Instance . PackData . Items [ index ] ;
infoLabel . Text = $"Name: {item.PackFilename}\nSize: {item.Data.Length.ToPrettySize()}" ;
infoLabel . Text = $"Name: {item.PackFilename}\nSize: {item.Data.Length.ToPrettySize()}" ;
}
}
private void dumpPackButton_Click ( object sender , EventArgs e )
private void dumpPackButton_Click ( object sender , EventArgs e )
{
{
var item = Exe . Instance . PackData . Items [ packDataListBox . SelectedIndex ] ;
var item = Exe . Instance . PackData . Items [ packDataListBox . SelectedIndex ] ;
@ -557,18 +576,28 @@ namespace DotNetCTFDumper.GUI
item . Dump ( ) ;
item . Dump ( ) ;
}
}
}
}
private void packDataDialog_FileOk ( object sender , CancelEventArgs e )
private void packDataDialog_FileOk ( object sender , CancelEventArgs e )
{
{
var item = Exe . Instance . PackData . Items [ packDataListBox . SelectedIndex ] ;
var item = Exe . Instance . PackData . Items [ packDataListBox . SelectedIndex ] ;
item . Dump ( packDataDialog . FileName ) ;
item . Dump ( packDataDialog . FileName ) ;
}
}
private void packDataListBox_SelectedIndexChanged ( object sender , EventArgs e ) = > UpdatePackInfo ( packDataListBox . SelectedIndex ) ;
private void packDataListBox_SelectedIndexChanged ( object sender , EventArgs e ) = >
UpdatePackInfo ( packDataListBox . SelectedIndex ) ;
private void plusCharBtn_Click ( object sender , EventArgs e ) { charBox . Text = ( byte . Parse ( charBox . Text ) + 1 ) . ToString ( ) ; InitKeyTab ( ) ; }
private void plusCharBtn_Click ( object sender , EventArgs e )
{
charBox . Text = ( byte . Parse ( charBox . Text ) + 1 ) . ToString ( ) ;
InitKeyTab ( ) ;
}
private void minusCharButton_Click ( object sender , EventArgs e ) { charBox . Text = ( byte . Parse ( charBox . Text ) - 1 ) . ToString ( ) ; InitKeyTab ( ) ; }
private void minusCharButton_Click ( object sender , EventArgs e )
{
charBox . Text = ( byte . Parse ( charBox . Text ) - 1 ) . ToString ( ) ;
InitKeyTab ( ) ;
}
private void charBox_TextChanged ( object sender , EventArgs e ) = > InitKeyTab ( ) ;
private void charBox_TextChanged ( object sender , EventArgs e ) = > InitKeyTab ( ) ;
@ -621,27 +650,44 @@ namespace DotNetCTFDumper.GUI
}
}
}
}
}
}
private void advancedPlayAnimation_Click ( object sender , EventArgs e )
public void InitPlugins ( )
{
{
PluginAPI . PluginAPI . InitializePlugins ( ) ;
if ( ( ( ChunkNode ) advancedTreeView . SelectedNode ) . loader is Animation anim )
foreach ( var plugin in PluginAPI . PluginAPI . Plugins )
{
{
pluginsList . Items . Add ( plugin . Name ) ;
var animThread = new Thread ( PlayAnimation ) ;
List < Bitmap > frames = new List < Bitmap > ( ) ;
foreach ( var dir in anim . DirectionDict )
{
foreach ( var frame in dir . Value . Frames )
{
frames . Add ( Exe . Instance . GameData . GameChunks . GetChunk < ImageBank > ( ) . Images [ frame ] . Bitmap ) ;
}
animThread . Start ( new Tuple < List < Bitmap > , AnimationDirection > ( frames , dir . Value ) ) ;
}
}
}
}
}
public void PlayAnimation ( object o )
{
var ( frames , anim ) = ( Tuple < List < Bitmap > , AnimationDirection > ) o ;
var fps = ( float ) anim . MaxSpeed ;
float delay = 1f / fps ;
Console . WriteLine ( ( int ) ( delay * 1200 ) ) ;
foreach ( Bitmap frame in frames )
{
advancedPictureBox . Image = frame ;
advancedInfoLabel . Text = $"Current frame: {frames.IndexOf(frame)}\nAnimation Speed: {fps}" ;
Thread . Sleep ( ( int ) ( delay * 1500 ) ) ;
}
}
private void advancedTreeView_AfterSelect ( object sender , TreeViewEventArgs e )
private void advancedTreeView_AfterSelect ( object sender , TreeViewEventArgs e )
{
{
var node = e . Node ;
var node = e . Node ;
if ( ! ( ( ( ChunkNode ) node ) . loader is ImageItem ) )
if ( ( ( ChunkNode ) node ) . loader is ImageItem )
{
advancedPictureBox . Image = advancedPictureBox . ErrorImage ;
}
else
{
{
var img = ( ( ImageItem ) ( ( ChunkNode ) node ) . loader ) ;
var img = ( ( ImageItem ) ( ( ChunkNode ) node ) . loader ) ;
advancedPictureBox . Image = img . Bitmap ;
advancedPictureBox . Image = img . Bitmap ;
@ -649,9 +695,29 @@ namespace DotNetCTFDumper.GUI
}
}
public void InitPlugins ( )
{
PluginAPI . PluginAPI . InitializePlugins ( ) ;
foreach ( var plugin in PluginAPI . PluginAPI . Plugins )
{
pluginsList . Items . Add ( plugin . Name ) ;
}
}
private void activatePluginBtn_Click ( object sender , EventArgs e )
private void activatePluginBtn_Click ( object sender , EventArgs e )
{
{
PluginAPI . PluginAPI . Plugins [ pluginsList . SelectedIndex ] . pluginClass . Activate ( null ) ;
PluginAPI . PluginAPI . ActivatePlugin( PluginAPI . PluginAPI . Plugins [ pluginsList . SelectedIndex ] ) ;
}
}
}
}
}
}