11using System ;
22using System . Drawing ;
3- using System . Drawing . Imaging ;
43using System . IO ;
54using System . Text ;
65using System . Windows . Forms ;
7- using System . Xml ;
8- using System . Drawing . Drawing2D ;
96using System . ComponentModel ;
107using System . Globalization ;
118using System . Threading ;
@@ -241,9 +238,6 @@ private void buttonRom_Click(object sender, EventArgs e)
241238 injector . RomPath = openFileDialog . FileName ;
242239 textBoxRom . Text = Path . GetFileName ( injector . RomPath ) ;
243240
244- if ( injector . Rom != null )
245- injector . Rom . Dispose ( ) ;
246-
247241 injector . Rom = new RomN64 ( injector . RomPath ) ;
248242
249243 if ( injector . Rom . IsValid )
@@ -450,7 +444,7 @@ private void buttonConfigFile_Click(object sender, EventArgs e)
450444 {
451445 openFileDialog . FileName = "" ;
452446 openFileDialog . FilterIndex = 0 ;
453- openFileDialog . Filter = "INI file|*.ini|All files|*.*" ;
447+ openFileDialog . Filter = "INI file|*.ini|TXT file|*.txt| All files|*.*" ;
454448 if ( checkBoxConfigFilesPath . Checked && Directory . Exists ( textBoxConfigFilesPath . Text ) )
455449 openFileDialog . InitialDirectory = textBoxConfigFilesPath . Text ;
456450 else
@@ -460,21 +454,67 @@ private void buttonConfigFile_Click(object sender, EventArgs e)
460454 {
461455 injector . IniPath = openFileDialog . FileName ;
462456
463- if ( ! injector . LoadIni ( injector . IniPath ) )
464- {
457+ injector . Ini = new VCN64ConfigFile ( injector . IniPath ) ;
458+
459+ if ( injector . Ini . IsValid )
460+ textBoxConfigFile . Text = Path . GetFileName ( injector . IniPath ) ;
461+ else
465462 MessageBox . Show ( HelpString . Config_File_Invalid ,
466463 "64Inject" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
467- }
468- else if ( injector . BaseIsLoaded && injector . RomIsLoaded )
469- {
464+
465+ if ( injector . BaseIsLoaded && injector . RomIsLoaded )
470466 labelTitleId . Text = "Title ID: " + injector . TitleId ;
467+ }
468+ }
469+
470+ private void buttonEditConfigFile_Click ( object sender , EventArgs e )
471+ {
472+ if ( ! Directory . Exists ( "resources\\ vcn64configs" ) )
473+ Directory . CreateDirectory ( "resources\\ vcn64configs" ) ;
474+
475+ string input = "" ;
476+ if ( injector . IniIsLoaded )
477+ input = injector . IniPath ;
478+
479+ StringBuilder output = new StringBuilder ( "resources\\ vcn64configs\\ " ) ;
480+ if ( injector . RomIsLoaded )
481+ {
482+ output . Append ( injector . Rom . ProductCodeVersion ) ;
483+ output . Append ( " (" + injector . Rom . Title + ")" ) ;
484+ }
485+ else
486+ output . Append ( "TempConfigFile" ) ;
487+ output . Append ( ".ini" ) ;
488+
489+ StringBuilder desc = new StringBuilder ( ) ;
490+ if ( textBoxShortName . Text . Length > 0 )
491+ desc . Append ( textBoxShortName . Text ) ;
492+ if ( desc . Length > 0 )
493+ desc . Append ( " " ) ;
494+ if ( injector . RomIsLoaded )
495+ desc . Append ( injector . Rom . ProductCodeVersion ) ;
496+
497+ VCN64Config . FormEditor editor = new VCN64Config . FormEditor ( ) ;
498+
499+ if ( editor . ShowDialog ( input , output . ToString ( ) , desc . ToString ( ) ) == DialogResult . OK )
500+ {
501+ injector . IniPath = output . ToString ( ) ;
502+
503+ injector . Ini = new VCN64ConfigFile ( injector . IniPath ) ;
504+
505+ if ( injector . Ini . IsValid )
471506 textBoxConfigFile . Text = Path . GetFileName ( injector . IniPath ) ;
472- }
473507 else
474- textBoxConfigFile . Text = Path . GetFileName ( injector . IniPath ) ;
508+ MessageBox . Show ( HelpString . Config_File_Invalid ,
509+ "64Inject" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
510+
511+ if ( injector . BaseIsLoaded && injector . RomIsLoaded )
512+ labelTitleId . Text = "Title ID: " + injector . TitleId ;
475513 }
514+
515+ editor . Dispose ( ) ;
476516 }
477-
517+
478518 #endregion
479519
480520 #region Images
@@ -1153,6 +1193,12 @@ private void ButtonConfigFile_MouseEnter(object sender, EventArgs e)
11531193 labelHelpText . Text = HelpString . Choose_Config_File_Description ;
11541194 }
11551195
1196+ private void buttonEditConfigFile_MouseEnter ( object sender , EventArgs e )
1197+ {
1198+ groupBoxHelp . Text = HelpString . Edit_Config_File ;
1199+ labelHelpText . Text = HelpString . Edit_Config_File_Description ;
1200+ }
1201+
11561202 private void LabelConfigFile_MouseLeave ( object sender , EventArgs e )
11571203 {
11581204 groupBoxHelp . Text = "" ;
@@ -1171,6 +1217,12 @@ private void ButtonConfigFile_MouseLeave(object sender, EventArgs e)
11711217 labelHelpText . Text = "" ;
11721218 }
11731219
1220+ private void buttonEditConfigFile_MouseLeave ( object sender , EventArgs e )
1221+ {
1222+ groupBoxHelp . Text = "" ;
1223+ labelHelpText . Text = "" ;
1224+ }
1225+
11741226 //********************************************************************************
11751227 private void ButtonIcon_MouseEnter ( object sender , EventArgs e )
11761228 {
@@ -1542,6 +1594,5 @@ private void ButtonConfigFilesPath_MouseLeave(object sender, EventArgs e)
15421594 }
15431595
15441596 #endregion
1545-
15461597 }
15471598}
0 commit comments