@@ -11,20 +11,45 @@ namespace AtlusScriptGUI
11
11
public partial class MainForm : MetroSetForm
12
12
{
13
13
public static Version version = new Version ( 3 , 0 ) ;
14
- public static string CompilerPath = "AtlusScriptCompiler.exe" ;
14
+ public Config settings = new Config ( ) ;
15
15
16
16
public MainForm ( string [ ] args )
17
17
{
18
18
InitializeComponent ( ) ;
19
+ settings = settings . LoadJson ( ) ;
20
+ if ( ! settings . DarkMode )
21
+ Theme . ThemeStyle = MetroSet_UI . Enums . Style . Light ;
19
22
Theme . ApplyToForm ( this ) ;
20
- //MenuStripHelper.SetMenuStripIcons(MenuStripHelper.GetMenuStripIconPairs("Icons.txt"), this);
23
+ MenuStripHelper . SetMenuStripIcons ( MenuStripHelper . GetMenuStripIconPairs ( "Icons.txt" ) , this ) ;
24
+
25
+ ApplyCheckboxStates ( ) ;
21
26
SetCompilerPath ( args ) ;
22
27
SetGamesDropDown ( ) ;
23
28
SetLogging ( ) ;
24
29
25
30
this . Text += $ " v{ version . Major } .{ version . Minor } ";
26
31
}
27
32
33
+ private void ApplyCheckboxStates ( )
34
+ {
35
+ chk_DeleteHeader . Checked = settings . DeleteHeader ;
36
+ chk_Disassemble . Checked = settings . Disassemble ;
37
+ chk_Hook . Checked = settings . Hook ;
38
+ chk_Overwrite . Checked = settings . Overwrite ;
39
+ chk_SumBits . Checked = settings . SumBits ;
40
+
41
+ EnableCheckboxes ( ) ;
42
+ }
43
+
44
+ private void EnableCheckboxes ( )
45
+ {
46
+ chk_DeleteHeader . Enabled = true ;
47
+ chk_Disassemble . Enabled = true ;
48
+ chk_Hook . Enabled = true ;
49
+ chk_Overwrite . Enabled = true ;
50
+ chk_SumBits . Enabled = true ;
51
+ }
52
+
28
53
private void SetLogging ( )
29
54
{
30
55
Output . Logging = true ;
@@ -34,17 +59,15 @@ private void SetLogging()
34
59
private void SetCompilerPath ( string [ ] args )
35
60
{
36
61
if ( args . Length > 0 && File . Exists ( args [ 0 ] ) )
37
- CompilerPath = args [ 0 ] ;
62
+ settings . CompilerPath = args [ 0 ] ;
38
63
}
39
64
40
65
private void SetGamesDropDown ( )
41
66
{
42
67
foreach ( var game in GamesList )
43
68
comboBox_Game . Items . Add ( game ) ;
44
69
45
- comboBox_Game . SelectedIndex = 10 ;
46
- if ( File . Exists ( "Game.txt" ) )
47
- try { comboBox_Game . SelectedIndex = GamesList . IndexOf ( File . ReadAllLines ( "Game.txt" ) [ 0 ] ) ; } catch { }
70
+ comboBox_Game . SelectedIndex = comboBox_Game . Items . IndexOf ( settings . Game ) ;
48
71
}
49
72
50
73
private void Btn_Click ( object sender , EventArgs e )
@@ -57,26 +80,20 @@ private void Btn_Click(object sender, EventArgs e)
57
80
browseWindowTitle = "Choose .BMD/.BF to Decompile" ;
58
81
59
82
var files = WinFormsDialogs . SelectFile ( browseWindowTitle , true ) ;
60
- new Thread ( ( ) =>
61
- {
62
- Compile ( files . ToArray ( ) , decompile ) ;
63
- } ) . Start ( ) ;
83
+ Compile ( files . ToArray ( ) , decompile ) ;
64
84
}
65
85
66
86
private void Btn_DragDrop ( object sender , DragEventArgs e )
67
87
{
68
88
var btn = ( Button ) sender ;
69
89
70
90
string [ ] fileList = ( string [ ] ) e . Data . GetData ( DataFormats . FileDrop , false ) ;
71
- new Thread ( ( ) =>
72
- {
73
- if ( File . Exists ( CompilerPath ) )
74
- Compile ( fileList , btn . Name . Contains ( "Decompile" ) ) ;
75
- else
76
- MessageBox . Show ( "Could not find AtlusScriptCompiler.exe. " +
77
- "Put this program in the same folder and try running it again!" ,
78
- "Critical Error" , MessageBoxButtons . OK , MessageBoxIcon . Exclamation ) ;
79
- } ) . Start ( ) ;
91
+ if ( File . Exists ( settings . CompilerPath ) )
92
+ Compile ( fileList , btn . Name . Contains ( "Decompile" ) ) ;
93
+ else
94
+ MessageBox . Show ( "Could not find AtlusScriptCompiler.exe. " +
95
+ "Put this program in the same folder and try running it again!" ,
96
+ "Critical Error" , MessageBoxButtons . OK , MessageBoxIcon . Exclamation ) ;
80
97
81
98
}
82
99
@@ -92,8 +109,8 @@ private void OpenLog_Click(object sender, EventArgs e)
92
109
93
110
private void Game_Changed ( object sender , EventArgs e )
94
111
{
95
- if ( comboBox_Game . SelectedIndex != 0 )
96
- File . WriteAllText ( "Game.txt" , comboBox_Game . SelectedItem . ToString ( ) ) ;
112
+ settings . Game = comboBox_Game . SelectedItem . ToString ( ) ;
113
+ settings . SaveJson ( settings ) ;
97
114
}
98
115
99
116
private void VanillaText_Changed ( object sender , EventArgs e )
@@ -127,5 +144,20 @@ private void RoyalText_Changed(object sender, EventArgs e)
127
144
txtBox_Vanilla . Text = "Out of Range" ;
128
145
}
129
146
}
147
+
148
+ private void Check_Changed ( object sender , EventArgs e )
149
+ {
150
+ var item = ( ToolStripMenuItem ) sender ;
151
+ if ( ! item . Enabled )
152
+ return ;
153
+
154
+ settings . DeleteHeader = chk_DeleteHeader . Checked ;
155
+ settings . Disassemble = chk_Disassemble . Checked ;
156
+ settings . Hook = chk_Hook . Checked ;
157
+ settings . Overwrite = chk_Overwrite . Checked ;
158
+ settings . SumBits = chk_SumBits . Checked ;
159
+
160
+ settings . SaveJson ( settings ) ;
161
+ }
130
162
}
131
163
}
0 commit comments