-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmGameProperties.cs
793 lines (715 loc) · 30.2 KB
/
frmGameProperties.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WinAGI.Engine;
using static WinAGI.Editor.Base;
using static WinAGI.Common.Base;
using System.IO;
using System.Diagnostics;
namespace WinAGI.Editor {
public partial class frmGameProperties : Form {
public string NewPlatformFile = "";
public int NewCodePage;
public string DisplayDir;
public bool UseSierraSyntax;
public frmGameProperties(GameSettingFunction mode, string starttab = "", string startprop = "") {
InitializeComponent();
// load code pages
cmbCodePage.Items.Add("437 - U.S. English (Default)");
cmbCodePage.Items.Add("737 - Greek II");
cmbCodePage.Items.Add("775 - Baltic Rim");
cmbCodePage.Items.Add("850 - MultiLingual (Latin I");
cmbCodePage.Items.Add("858 - MultiLingual (Latin I) with Euro Sign");
cmbCodePage.Items.Add("852 - Slavic/Eastern Europe (Latin II)");
cmbCodePage.Items.Add("855 - Cyrillic I");
cmbCodePage.Items.Add("857 - Turkish");
cmbCodePage.Items.Add("860 - Portuguese");
cmbCodePage.Items.Add("861 - Icelandic");
cmbCodePage.Items.Add("862 - Hebrew");
cmbCodePage.Items.Add("863 - Canadian-French");
cmbCodePage.Items.Add("865 - Nordic");
cmbCodePage.Items.Add("866 - Russian (Cyrillic II)");
cmbCodePage.Items.Add("869 - Greek");
// load versions
cmbVersion.Items.Add("2.089");
cmbVersion.Items.Add("2.272");
cmbVersion.Items.Add("2.411");
cmbVersion.Items.Add("2.425");
cmbVersion.Items.Add("2.426");
cmbVersion.Items.Add("2.435");
cmbVersion.Items.Add("2.439");
cmbVersion.Items.Add("2.440");
cmbVersion.Items.Add("2.903");
cmbVersion.Items.Add("2.911");
cmbVersion.Items.Add("2.912");
cmbVersion.Items.Add("2.915");
cmbVersion.Items.Add("2.917");
cmbVersion.Items.Add("2.936");
cmbVersion.Items.Add("3.002086");
cmbVersion.Items.Add("3.002098");
cmbVersion.Items.Add("3.002102");
cmbVersion.Items.Add("3.002107");
cmbVersion.Items.Add("3.002149");
// make sure form uses same font settings as the text boxes
this.Font = txtGameDir.Font;
SetForm(mode);
if (starttab.Length > 0) {
try {
tabControl1.SelectedTab = tabControl1.TabPages[starttab];
}
catch {
// ignore errors
Debug.Assert(false);
}
}
if (startprop.Length > 0) {
try {
tabControl1.SelectedTab.Controls[startprop].Select();
}
catch {
// ignore errors
Debug.Assert(false);
}
}
}
#region Event Handlers
#region Form and Button Event Handlers
private void frmGameProperties_HelpRequested(object sender, HelpEventArgs hlpevent) {
string strTopic = @"htm\winagi\Properties.htm" + (string)((Control)sender).Tag;
Help.ShowHelp(HelpParent, WinAGIHelp, HelpNavigator.Topic, strTopic);
hlpevent.Handled = true;
}
private void btnOK_Click(object sender, EventArgs e) {
// validate input
// must select a directory
if (DisplayDir.Length == 0) {
MessageBox.Show(MDIMain, "Choose a directory for this new game.", "New Game", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
this.DialogResult = DialogResult.OK;
this.Hide();
}
#endregion
#region General Tab Event Handlers
private void txtGameID_TextChanged(object sender, EventArgs e) {
// during setup, form is not visible, so don't need to validate the ID
if (!this.Visible) {
return;
}
ValidateIDText();
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
private void txtGameID_KeyPress(object sender, KeyPressEventArgs e) {
// allow alpha numeric only, limit of five characters
switch ((int)e.KeyChar) {
case 8:
// backspace is OK
return;
case 13:
// enter is same as tabbing to next control
e.Handled = true;
cmbVersion.Select();
return;
//case >= 97 and <= 122:
// e.KeyChar = (char)((int)e.KeyChar - 32);
// return;
case <= 7:
case >= 9 and <= 47:
case >= 91 and <= 96:
case >= 123:
// not allowed
e.Handled = true;
return;
}
if (txtGameID.Text.Length >= 5) {
e.Handled = true;
}
}
private void txtGameID_Validating(object sender, CancelEventArgs e) {
// enforce character limits- 5 char max, only basic ascii,
// no file/folder prohibited characters
ValidateIDText();
}
private void cmbVersion_SelectionChangeCommitted(object sender, EventArgs e) {
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
private void txtGameDir_DoubleClick(object sender, EventArgs e) {
// same as clicking button
ChangeDisplayGameDir();
}
private void btnGameDir_Click(object sender, EventArgs e) {
// change/create directory that is displayed (doesn't change actual game directory)
ChangeDisplayGameDir();
}
private void txtResDir_TextChanged(object sender, EventArgs e) {
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
private void txtResDir_Validating(object sender, CancelEventArgs e) {
// no file/folder prohibited characters, only standard ascii
string dirtext = "";
foreach (char c in txtResDir.Text) {
if (c > 32 && c < 127) {
//no invalid path chars
if (!(Path.GetInvalidFileNameChars()).Contains(c)) {
dirtext += c;
}
}
}
txtResDir.Text = dirtext;
}
private void txtResDir_KeyPress(object sender, KeyPressEventArgs e) {
// validate- can't have "\/:*?<>|
switch ((int)e.KeyChar) {
case 13:
// enter is same as tabbing to next control
e.Handled = true;
txtSrcExt.Select();
break;
case <= 7:
case >= 9 and <= 32:
case 34 or 42 or 47 or 58 or 60 or 62 or 63 or 92 or 124:
case > 126:
// not allowed
e.Handled = true;
break;
}
}
private void txtSrcExt_TextChanged(object sender, EventArgs e) {
// only 4 characters
// TODO: add validation checks to all text fields
if (txtSrcExt.TextLength > 4) {
txtSrcExt.Text = txtSrcExt.Text[..4];
}
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
private void txtSrcExt_KeyPress(object sender, KeyPressEventArgs e) {
// validate- can't have "\/:*?<>|
switch ((int)e.KeyChar) {
case 13:
// enter is same as tabbing to next control
e.Handled = true;
chkResourceIDs.Select();
break;
case <= 7:
case >= 9 and <= 32:
case 34 or 42 or 47 or 58 or 60 or 62 or 63 or 92 or 124:
case > 126:
// not allowed
e.Handled = true;
break;
}
}
private void txtSrcExt_Leave(object sender, EventArgs e) {
if (txtSrcExt.Text == "") {
txtSrcExt.Text = "lgc";
}
}
private void txtSrcExt_Validating(object sender, CancelEventArgs e) {
// all versions limit to five characters
if (txtSrcExt.TextLength > 5) {
txtSrcExt.Text = txtSrcExt.Text[..5];
}
// no file/folder prohibited characters, only standard ascii
string exttext = "";
foreach (char c in txtSrcExt.Text) {
if (c > 32 && c < 127) {
//no invalid path chars
if (!(Path.GetInvalidFileNameChars()).Contains(c)) {
exttext += c;
}
}
}
if (txtSrcExt.Text == "") {
txtSrcExt.Text = "lgc";
}
txtSrcExt.Text = exttext;
}
private void chkUseLE_CheckedChanged(object sender, EventArgs e) {
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
private void chkResourceIDs_CheckedChanged(object sender, EventArgs e) {
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
private void chkUseReserved_CheckedChanged(object sender, EventArgs e) {
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
private void chkGlobals_CheckedChanged(object sender, EventArgs e) {
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
#endregion
#region Version Tab Event Handlers
private void txtGameAuthor_TextChanged(object sender, EventArgs e) {
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
private void txtGameAuthor_KeyPress(object sender, KeyPressEventArgs e) {
// enter is same as tabbing to next control
if (e.KeyChar == 13) {
e.Handled = true;
txtGameDescription.Select();
}
}
private void txtGameDescription_TextChanged(object sender, EventArgs e) {
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
private void txtGameDescription_KeyPress(object sender, KeyPressEventArgs e) {
// enter is same as tabbing to next control
if (e.KeyChar == 13) {
e.Handled = true;
txtGameAbout.Select();
}
}
private void txtGameAbout_TextChanged(object sender, EventArgs e) {
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
private void txtGameAbout_KeyPress(object sender, KeyPressEventArgs e) {
// enter is same as tabbing to next control
if (e.KeyChar == 13) {
e.Handled = true;
txtGameVersion.Select();
}
}
private void txtGameVersion_TextChanged(object sender, EventArgs e) {
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
private void txtGameVersion_KeyPress(object sender, KeyPressEventArgs e) {
// enter is same as tabbing to next control
if (e.KeyChar == 13) {
e.Handled = true;
btnOK.Select();
}
}
#endregion
#region Platform Tab Event Handlers
private void optNone_CheckedChanged(object sender, EventArgs e) {
if (optNone.Checked) {
// clear all platform properties
lblPlatformFile.Enabled = false;
btnPlatformFile.Enabled = false;
txtPlatformFile.Enabled = false;
txtPlatformFile.Text = "";
lblOptions.Enabled = false;
lblOptions.Text = "";
lblExec.Enabled = false;
txtExec.Enabled = false;
txtExec.Text = "";
NewPlatformFile = "";
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
}
private void optDosBox_CheckedChanged(object sender, EventArgs e) {
if (optDosBox.Checked) {
// dir and options are allowed for dosbox
lblPlatformFile.Enabled = true;
btnPlatformFile.Enabled = true;
txtPlatformFile.Enabled = true;
lblOptions.Enabled = true;
txtOptions.Enabled = true;
lblExec.Enabled = true;
txtExec.Enabled = true;
// clear the dir and options boxes
txtOptions.Text = "";
NewPlatformFile = "";
txtPlatformFile.Text = "";
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
}
private void optScummVM_CheckedChanged(object sender, EventArgs e) {
if (optScummVM.Checked) {
// dir and options are allowed for scummvm
lblPlatformFile.Enabled = true;
btnPlatformFile.Enabled = true;
txtPlatformFile.Enabled = true;
lblOptions.Enabled = true;
txtOptions.Enabled = true;
// dos executable is NA
lblExec.Enabled = false;
txtExec.Enabled = false;
// clear the dir and options boxes
txtOptions.Text = "";
NewPlatformFile = "";
txtPlatformFile.Text = "";
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
}
private void optNAGI_CheckedChanged(object sender, EventArgs e) {
if (optNAGI.Checked) {
// platform dir is automatically the game dir
lblPlatformFile.Enabled = false;
btnPlatformFile.Enabled = false;
// dos executable is NA
lblExec.Enabled = false;
txtExec.Enabled = false;
// save this directory/filename combo
NewPlatformFile = EditGame.GameDir + "n.exe";
txtPlatformFile.Text = NewPlatformFile;
txtPlatformFile.Enabled = false;
btnPlatformFile.Enabled = false;
// no options for nagi
lblOptions.Enabled = false;
txtOptions.Enabled = false;
txtOptions.Text = "";
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
}
private void optOther_CheckedChanged(object sender, EventArgs e) {
if (optOther.Checked) {
// dir and options are allowed for dosbox
lblPlatformFile.Enabled = true;
btnPlatformFile.Enabled = true;
txtPlatformFile.Enabled = true;
lblOptions.Enabled = true;
txtOptions.Enabled = true;
// dos executable is NA
lblExec.Enabled = false;
txtExec.Enabled = false;
// clear everything; this is easiest way to 'reset'
txtPlatformFile.Text = "";
txtOptions.Text = "";
txtExec.Text = "";
NewPlatformFile = "";
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
}
private void btnPlatformFile_Click(object sender, EventArgs e) {
ChangePlatformApp();
}
private void txtExec_TextChanged(object sender, EventArgs e) {
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
private void txtExec_KeyPress(object sender, KeyPressEventArgs e) {
// enter is same as tabbing to next control
if (e.KeyChar == 13) {
e.Handled = true;
txtPlatformFile.Select();
}
}
private void txtOptions_TextChanged(object sender, EventArgs e) {
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
private void txtOptions_KeyPress(object sender, KeyPressEventArgs e) {
// enter is same as tabbing to next control
if (e.KeyChar == 13) {
e.Handled = true;
btnOK.Select();
}
}
private void txtPlatformFile_DoubleClick(object sender, EventArgs e) {
ChangePlatformApp();
}
private void txtPlatformFile_KeyPress(object sender, KeyPressEventArgs e) {
// enter is same as tabbing to next control
if (e.KeyChar == 13) {
e.Handled = true;
txtOptions.Select();
}
}
private void txtPlatformFile_TextChanged(object sender, EventArgs e) {
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
private void txtPlatformFile_Validating(object sender, CancelEventArgs e) {
NewPlatformFile = txtPlatformFile.Text;
}
#endregion
#region Advanced Tab Event Handlers
private void chkSierraSyntax_Click(object sender, EventArgs e) {
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
private void cmbCodePage_SelectionChangeCommitted(object sender, EventArgs e) {
// change codepage
try {
NewCodePage = int.Parse(((string)cmbCodePage.SelectedItem)[..3]);
}
catch {
MessageBox.Show("NOPE");
}
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
#endregion
#endregion
private void SetForm(GameSettingFunction mode) {
switch (mode) {
case GameSettingFunction.Edit:
// get values from open game
txtGameAuthor.Text = EditGame.GameAuthor;
txtGameVersion.Text = EditGame.GameVersion;
txtGameAbout.Text = EditGame.GameAbout;
txtGameDescription.Text = EditGame.GameDescription;
// version
for (int i = 0; i < cmbVersion.Items.Count; i++) {
if ((string)cmbVersion.Items[i] == EditGame.InterpreterVersion) {
cmbVersion.SelectedIndex = i;
break;
}
}
// assign gameid
txtGameID.Text = EditGame.GameID;
DisplayDir = EditGame.GameDir;
txtGameDir.Text = DisplayDir;
// game dir is read only when editing
txtGameDir.Enabled = false;
btnGameDir.Enabled = false;
// resdir is just the directory by itself, not entire path
txtResDir.Text = EditGame.ResDirName;
txtSrcExt.Text = EditGame.SourceExt;
// select the button for platform
switch (EditGame.PlatformType) {
case Engine.PlatformType.None:
// None - do nothing; form is already correct
break;
case Engine.PlatformType.DosBox:
optDosBox.Checked = true;
lblExec.Enabled = true;
btnPlatformFile.Enabled = true;
txtPlatformFile.Enabled = true;
lblOptions.Enabled = true;
txtOptions.Enabled = true;
lblExec.Enabled = true;
txtExec.Enabled = true;
break;
case Engine.PlatformType.ScummVM:
optScummVM.Checked = true;
lblExec.Enabled = true;
btnPlatformFile.Enabled = true;
txtPlatformFile.Enabled = true;
lblOptions.Enabled = true;
txtOptions.Enabled = true;
break;
case Engine.PlatformType.NAGI:
optNAGI.Checked = true;
// no options for NAGI
// and platform file is always "n.exe" in game dir
break;
case Engine.PlatformType.Other:
optOther.Checked = true;
lblExec.Enabled = true;
btnPlatformFile.Enabled = true;
txtPlatformFile.Enabled = true;
lblOptions.Enabled = true;
txtOptions.Enabled = true;
break;
}
// if platform is nothing, skip directory
if (txtPlatformFile.Enabled) {
NewPlatformFile = EditGame.Platform;
txtPlatformFile.Text = NewPlatformFile;
}
else {
NewPlatformFile = "";
}
if (txtOptions.Enabled) {
txtOptions.Text = EditGame.PlatformOpts;
}
if (txtExec.Enabled) {
txtExec.Text = EditGame.DOSExec;
}
// include options
chkResourceIDs.Checked = EditGame.IncludeIDs;
chkResDefs.Checked = EditGame.IncludeReserved;
chkGlobals.Checked = EditGame.IncludeGlobals;
// layout editor
chkUseLE.Checked = EditGame.UseLE;
// code page
for (int i = 0; i < cmbCodePage.Items.Count; i++) {
if (((string)cmbCodePage.Items[i])[..3] == EditGame.CodePage.CodePage.ToString()) {
cmbCodePage.SelectedIndex = i;
break;
}
}
NewCodePage = EditGame.CodePage.CodePage;
// sierra syntax option
if (EditGame.SierraSyntax) {
chkSierraSyntax.Checked = true;
}
// set caption
Text = "Edit Game Properties";
break;
case GameSettingFunction.New:
// default values
txtGameAuthor.Text = "";
txtGameVersion.Text = "AGI Game version 0.0";
txtGameAbout.Text = "AGI Game by <author>";
txtGameDescription.Text = "new agi game";
cmbVersion.SelectedItem = "2.917";
txtGameID.Text = "AGI";
// game dir is editable when creating new
txtGameDir.Enabled = true;
btnGameDir.Enabled = true;
DisplayDir = "";
txtGameDir.Text = "";
txtResDir.Text = WinAGI.Engine.Base.DefResDir;
txtSrcExt.Text = LogicDecoder.DefaultSrcExt;
// include options
chkResourceIDs.Checked = WinAGISettings.DefIncludeIDs.Value;
chkResDefs.Checked = WinAGISettings.DefIncludeReserved.Value;
chkGlobals.Checked = WinAGISettings.DefIncludeGlobals.Value;
// layout editor
chkUseLE.Checked = WinAGISettings.DefUseLE.Value;
// platform- check for autofill platform property
if (WinAGISettings.AutoFill.Value) {
switch (WinAGISettings.PlatformType.Value) {
case 1:
// DOSBox
optDosBox.Checked = true;
txtExec.Text = WinAGISettings.DOSExec.Value;
break;
case 2:
// ScummVM
optScummVM.Checked = true;
break;
case 3:
// NAGI
optNAGI.Checked = true;
break;
case 4:
// Other
optOther.Checked = true;
break;
}
txtPlatformFile.Text = WinAGISettings.PlatformFile.Value;
txtOptions.Text = WinAGISettings.PlatformOpts.Value;
}
// code page starts at default
for (int i = 0; i < cmbCodePage.Items.Count; i++) {
if (int.Parse(((string)cmbCodePage.Items[i])[..3]) == Engine.Base.CodePage.CodePage) {
cmbCodePage.SelectedIndex = i;
break;
}
}
NewCodePage = Engine.Base.CodePage.CodePage;
// sierra syntax is off by default
chkSierraSyntax.Checked = false;
// set caption
Text = "New Game Properties";
break;
}
// disable OK until a change is made
btnOK.Enabled = false;
}
private void ChangePlatformApp() {
// get a platform executable that will run a game
if (NewPlatformFile.Length == 0) {
MDIMain.OpenDlg.FileName = "";
MDIMain.OpenDlg.InitialDirectory = EditGame.GameDir;
}
else {
MDIMain.OpenDlg.FileName = Path.GetFileName(NewPlatformFile);
MDIMain.OpenDlg.InitialDirectory = Path.GetDirectoryName(EditGame.GameDir);
}
MDIMain.OpenDlg.Title = "Choose Platform Application";
MDIMain.OpenDlg.ShowReadOnly = false;
MDIMain.OpenDlg.RestoreDirectory = true;
MDIMain.OpenDlg.Filter = "Executables (*.exe; *.com)|*.exe;*.com|All files (*.*)|*.*";
MDIMain.OpenDlg.FilterIndex = 1;
if (MDIMain.OpenDlg.ShowDialog(MDIMain) == DialogResult.OK) {
// save this directory/filename combo
NewPlatformFile = MDIMain.OpenDlg.FileName;
txtPlatformFile.Text = NewPlatformFile;
}
// enable ok if an ID and directory have been chosen
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
private void ValidateIDText() {
int selpos = txtGameID.SelectionStart;
if (selpos > 5) {
selpos = 5;
}
// all versions limit to five characters
if (txtGameID.TextLength > 5) {
txtGameID.Text = txtGameID.Text[..5];
}
// no file/folder prohibited characters, only standard ascii
string idtext = "";
foreach (char c in txtGameID.Text) {
if (c > 32 && c < 127) {
//no invalid path chars
if (!(Path.GetInvalidFileNameChars()).Contains(c)) {
idtext += c;
}
}
}
txtGameID.Text = idtext;
if (selpos >= txtGameID.Text.Length) {
selpos = txtGameID.Text.Length;
}
txtGameID.SelectionStart = selpos;
}
private void ChangeDisplayGameDir() {
if (DisplayDir.Length > 0) {
BrowserStartDir = DisplayDir;
}
// get a directory from which to load a game
MDIMain.FolderDlg.Description = "Select a directory for this new game:";
MDIMain.FolderDlg.AddToRecent = false;
MDIMain.FolderDlg.InitialDirectory = BrowserStartDir;
MDIMain.FolderDlg.SelectedPath = "";
//MDIMain.FolderDlg.OkRequiresInteraction = true;
MDIMain.FolderDlg.ShowNewFolderButton = true;
if (MDIMain.FolderDlg.ShowDialog() == DialogResult.OK) {
DisplayDir = FullDir(MDIMain.FolderDlg.SelectedPath);
txtGameDir.Text = DisplayDir;
BrowserStartDir = DisplayDir;
}
btnOK.Enabled = (txtGameID.TextLength > 0 && DisplayDir.Length > 0);
}
/*
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
// TODO: add help
Dim strTopic As String
'check for help key
If Shift = 0 And KeyCode = vbKeyF1 Then
'help with game properties
strTopic =
Select Case ActiveControl.Name
Case "cmbVersion"
strTopic = strTopic & "#intversion"
Case "picGameDir", "txtGameDir"
strTopic = strTopic & "#gamedir"
Case "picPlatformFile", "txtPlatformFile", "txtExec", "txtOptions", "optOther", "optDosBox", "optScummVM", "optNAGI"
strTopic = strTopic & "#executable"
Case "txtGameAbout"
strTopic = strTopic & "#about"
Case "txtGameAuthor"
strTopic = strTopic & "#author"
Case "txtGameDescription"
strTopic = strTopic & "#description"
Case "txtGameID"
strTopic = strTopic & "#gameid"
Case "txtGameVersion"
strTopic = strTopic & "#gameversion"
Case "txtResDir"
strTopic = strTopic & "#resdir"
Case "cmbCodePage"
strTopic = strTopic & "#codepage"
End Select
HtmlHelpS HelpParent, WinAGIHelp, HH_DISPLAY_TOPIC, strTopic
KeyCode = 0
End If
End Sub
*/
}
}