@@ -154,33 +154,7 @@ private void Form1_Load(object sender, EventArgs e) {
154
154
string rawFile = File . ReadAllText ( "games.js" ) ;
155
155
_gamesDictionary = JsonConvert . DeserializeObject < Dictionary < string , string > > ( rawFile ) ;
156
156
157
- PopulatePatchList ( ) ;
158
- PopulateGames ( ) ;
159
-
160
- #endregion
161
-
162
- #region Create constants for resizing
163
-
164
- _resizeConstants = new int [ 6 ] ;
165
- _resizeConstants [ 0 ] = Size . Width - startButton . Width ;
166
- _resizeConstants [ 1 ] = Size . Width - splitContainer1 . Width ;
167
- _resizeConstants [ 2 ] = Size . Height - splitContainer1 . Height ;
168
- _resizeConstants [ 3 ] = splitContainer1 . Location . Y - btn_sortAZ1 . Location . Y ;
169
- _resizeConstants [ 4 ] = btn_sortAZ2 . Location . X - patchListBox . Size . Width ;
170
- _resizeConstants [ 5 ] = btn_filterFav1 . Location . X - btn_sortAZ1 . Location . X ;
171
-
172
157
#endregion
173
-
174
- #region Display
175
-
176
- SetDefaultSettings ( ) ;
177
-
178
- //Change Form settings
179
- SetDesktopLocation ( Configuration1 . Window . Location [ 0 ] , Configuration1 . Window . Location [ 1 ] ) ;
180
- Size = new Size ( Configuration1 . Window . Size [ 0 ] , Configuration1 . Window . Size [ 1 ] ) ;
181
-
182
- #endregion
183
-
184
158
if ( menuStrip1 == null ) return ;
185
159
menuStrip1 . Items . OfType < ToolStripMenuItem > ( ) . ToList ( ) . ForEach ( x =>
186
160
x . MouseHover +=
@@ -198,14 +172,23 @@ private void Form1_Load(object sender, EventArgs e) {
198
172
Trace . WriteLine ( $ "[{ DateTime . Now . ToShortTimeString ( ) } ] Couldn't connect to GitHub for language update.\n Reason: { ex } ") ;
199
173
}
200
174
201
- UpdateLanguage ( ) ;
175
+ GetPatchList ( ) ;
176
+ SetDefaultSettings ( ) ;
202
177
203
- Trace . WriteLine ( $ "[{ DateTime . Now . ToLongTimeString ( ) } ] MainForm Loaded with the following Configuration:") ;
204
- Trace . WriteLine ( $ "\t ExitAfterStartup: { Configuration1 . ExitAfterStartup } \n \t LastConfig: { Configuration1 . LastConfig } \n \t LastGame: { Configuration1 . LastGame } \n \t FilterExeType: { Configuration1 . FilterExeType } \n \t HidePatchExtension: { Configuration1 . HidePatchExtension } \n \t Lang: { Configuration . Lang } ") ;
205
- Trace . WriteLine ( $ "\t IsDescending: { Configuration1 . IsDescending [ 0 ] } | { Configuration1 . IsDescending [ 1 ] } \n \t OnlyFavorites: { Configuration1 . OnlyFavorites [ 0 ] } | { Configuration1 . OnlyFavorites [ 1 ] } \n \t Window:\n \t \t Location: { Configuration1 . Window . Location [ 0 ] } , { Configuration1 . Window . Location [ 1 ] } \n \t \t Size: { Configuration1 . Window . Size [ 0 ] } , { Configuration1 . Window . Size [ 1 ] } ") ;
178
+ UpdateLanguage ( ) ;
179
+ Debug . WriteLine ( $ "[{ DateTime . Now . ToLongTimeString ( ) } ] MainForm Loaded with the following Configuration:") ;
180
+ Trace . WriteLine ( $ "\t LastConfig: { Configuration1 . LastConfig } ") ;
181
+ Trace . WriteLine ( $ "\t LastGame: { Configuration1 . LastGame } ") ;
182
+ Trace . WriteLine ( $ "\t FilterExeType: { Configuration1 . FilterExeType } ") ;
183
+ Trace . WriteLine ( $ "\t HidePatchExtension: { Configuration1 . HidePatchExtension } ") ;
184
+ Trace . WriteLine ( $ "\t Lang: { Configuration . Lang } ") ;
185
+ Trace . WriteLine ( $ "\t ExitAfterStartup: { Configuration1 . ExitAfterStartup } ") ;
186
+ Trace . WriteLine ( $ "\t IsDescending: { Configuration1 . IsDescending [ 0 ] } | { Configuration1 . IsDescending [ 1 ] } ") ;
187
+ Trace . WriteLine ( $ "\t OnlyFavorites: { Configuration1 . OnlyFavorites [ 0 ] } | { Configuration1 . OnlyFavorites [ 1 ] } ") ;
188
+ Trace . WriteLine ( $ "\t Window:\n \t \t Location: { Configuration1 . Window . Location [ 0 ] } , { Configuration1 . Window . Location [ 1 ] } ") ;
189
+ Trace . WriteLine ( $ "\t \t Size: { Configuration1 . Window . Size [ 0 ] } , { Configuration1 . Window . Size [ 1 ] } ") ;
206
190
}
207
191
208
-
209
192
private void MainForm_KeyUp ( object sender , KeyEventArgs e ) {
210
193
if ( ModifierKeys != Keys . None ) {
211
194
patchListBox . SelectedItem = Configuration1 . LastConfig ;
@@ -280,12 +263,31 @@ private void MainForm_Closing(object sender, FormClosingEventArgs e) {
280
263
}
281
264
282
265
private void Form1_Shown ( object sender , EventArgs e ) {
283
- ReadConfig ( ) ;
266
+ #region Create constants for resizing
284
267
285
- //Set default selection index
286
- if ( patchListBox . SelectedIndex == - 1 && patchListBox . Items . Count > 0 ) patchListBox . SelectedIndex = 0 ;
268
+ _resizeConstants = new int [ 6 ] ;
269
+ _resizeConstants [ 0 ] = Size . Width - startButton . Width ;
270
+ _resizeConstants [ 1 ] = Size . Width - splitContainer1 . Width ;
271
+ _resizeConstants [ 2 ] = Size . Height - splitContainer1 . Height ;
272
+ _resizeConstants [ 3 ] = splitContainer1 . Location . Y - btn_sortAZ1 . Location . Y ;
273
+ _resizeConstants [ 4 ] = btn_sortAZ2 . Location . X - patchListBox . Size . Width ;
274
+ _resizeConstants [ 5 ] = btn_filterFav1 . Location . X - btn_sortAZ1 . Location . X ;
287
275
288
- if ( gameListBox . SelectedIndex == - 1 && gameListBox . Items . Count > 0 ) gameListBox . SelectedIndex = 0 ;
276
+ #endregion
277
+
278
+
279
+ #region Display
280
+
281
+ //Change Form settings
282
+ SetDesktopLocation ( Configuration1 . Window . Location [ 0 ] , Configuration1 . Window . Location [ 1 ] ) ;
283
+ Size = new Size ( Configuration1 . Window . Size [ 0 ] , Configuration1 . Window . Size [ 1 ] ) ;
284
+
285
+ #endregion
286
+
287
+ ReadConfig ( ) ;
288
+
289
+ PopulatePatchList ( ) ;
290
+ PopulateGames ( ) ;
289
291
290
292
UpdateConfigFile ( ) ;
291
293
}
@@ -498,13 +500,15 @@ private void settingsTS_Click(object sender, EventArgs e) {
498
500
private void SetDefaultSettings ( ) {
499
501
//Default Configuration setting
500
502
try {
503
+ if ( Configuration1 == null ) Configuration1 = new Configuration ( ) ;
504
+
501
505
if ( Configuration . Lang == null ) {
502
506
Configuration . Lang = "en.json" ;
503
507
Trace . WriteLine ( $ "[{ DateTime . Now . ToShortTimeString ( ) } ] Configuration.Lang has been set to { Configuration . Lang } ") ;
504
508
}
505
509
506
510
if ( Configuration1 . LastGame == null ) {
507
- Configuration1 . LastGame = _displayNameToThxxDictionary . Keys . ElementAt ( 0 ) ;
511
+ Configuration1 . LastGame = _displayNameToThxxDictionary . Count != 0 ? _displayNameToThxxDictionary . Keys . ElementAt ( 0 ) : _gamesDictionary . Keys . ElementAt ( 0 ) ;
508
512
Trace . WriteLine (
509
513
$ "[{ DateTime . Now . ToShortTimeString ( ) } ] Configuration1.LastGame has been set to { Configuration1 . LastGame } ") ;
510
514
}
@@ -601,6 +605,9 @@ private void SetDefaultSettings() {
601
605
Trace . WriteLine ( $ "[{ DateTime . Now . ToShortTimeString ( ) } ] Configuration1.FilterExeType") ;
602
606
filterByType_button_Click ( "DefaultSettings" , new EventArgs ( ) ) ;
603
607
}
608
+
609
+ if ( Favourites1 . Games == null ) Favourites1 . Games = new List < string > ( ) ;
610
+ if ( Favourites1 . Patches == null ) Favourites1 . Patches = new List < string > ( ) ;
604
611
}
605
612
catch ( Exception e ) {
606
613
MessageBox . Show ( $@ "1. If you're a developer: Don't forget to set the working directory to thcrap's directory. Your current working directory is: { Environment . CurrentDirectory }
@@ -751,13 +758,13 @@ public void PopulateGames() {
751
758
if ( gameListBox . SelectedIndex == - 1 && gameListBox . Items . Count > 0 ) gameListBox . SelectedIndex = 0 ;
752
759
}
753
760
754
- public void PopulatePatchList ( ) {
761
+ private void GetPatchList ( ) {
755
762
_jsFiles . Clear ( ) ;
756
763
_thcrapFiles . Clear ( ) ;
757
764
patchListBox . Items . Clear ( ) ;
758
765
759
766
//Load patch stacks
760
- _jsFiles = Directory . GetFiles ( Directory . GetCurrentDirectory ( ) , "*.js" ) . ToList ( ) ;
767
+ _jsFiles = Directory . GetFiles ( Directory . GetCurrentDirectory ( ) , "*.js" ) . ToList ( ) ;
761
768
_thcrapFiles = Directory . GetFiles ( Directory . GetCurrentDirectory ( ) , "*.thcrap" ) . ToList ( ) ;
762
769
763
770
//Give error if there are no patch configurations
@@ -780,6 +787,10 @@ public void PopulatePatchList() {
780
787
781
788
}
782
789
#endregion
790
+ }
791
+
792
+ public void PopulatePatchList ( ) {
793
+ GetPatchList ( ) ;
783
794
784
795
//Display patch stacks
785
796
if ( Configuration1 . ShowVanilla ) patchListBox . Items . Add ( $ "[{ I18N . LangResource . mainForm . vanilla } ]") ;
@@ -1214,8 +1225,8 @@ public Favourites(List<string> patches, List<string> games) {
1214
1225
Games = games ;
1215
1226
}
1216
1227
1217
- public List < string > Patches { get ; }
1218
- public List < string > Games { get ; }
1228
+ public List < string > Patches { get ; set ; }
1229
+ public List < string > Games { get ; set ; }
1219
1230
}
1220
1231
1221
1232
public sealed class JumpListElement : ToolStripMenuItem {
0 commit comments