-
Notifications
You must be signed in to change notification settings - Fork 0
/
Defcmnd.c
1383 lines (1209 loc) · 37.5 KB
/
Defcmnd.c
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
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/***************************************************************************
* *
* FILE : DEFCMND.C *
* *
* DATE : March 94 *
* *
* NAME : Paul Stanley *
* *
* This file contains the dialog procedures for all of the system dialog *
* boxes. *
* *
***************************************************************************/
/*********************
Included files
*********************/
#include "def.h"
#include "defid.h"
#include "defproto.h"
#include "deftypes.h"
#include "defgbls.h"
#include "defmacro.h"
#include "scancode.h"
#define SLOW_LABEL "Slow"
#define FAST_LABEL "Fast"
#define TINY_LABEL "Tiny"
#define HUGE_LABEL "Huge"
#define NORMAL_LABEL "Normal"
#define HISCORE_TEXT " HIGH SCORE %d\n \n" \
" Name:\t%s\n Score:\t%06d\n Date:\t%s" \
"\n Nasties:\t%d\n Hit rate:\t%d%%\n Wave:\t%d" \
"\n \n" \
" Subs:\t%d\n S. Bombs:\t%d\n Bullets:\t%s"
#define CHECK_RECORD "Recording a demo will overwrite the previously " \
"recorded game. Do you wish to continue?"
/* Crude encryption scheme for password checking */
#define ENCODE(c) (((c - 'A' + 13) % 26) + 'A')
/* Typedef used for unregistration screen */
typedef struct
{
ULONG ulID;
BOOL fClicked;
} CBOXES;
VOID CenterDialog (HWND hwnd);
MRESULT EXPENTRY ProcessKeyDialog (HWND hwnd,
ULONG msg,
MPARAM mp1,
MPARAM mp2);
MRESULT EXPENTRY ProcessSpeedDialog (HWND hwnd,
ULONG msg,
MPARAM mp1,
MPARAM mp2);
MRESULT EXPENTRY ProcessSizeDialog (HWND hwnd,
ULONG msg,
MPARAM mp1,
MPARAM mp2);
MRESULT EXPENTRY ProcessProdInfoDialog (HWND hwnd,
ULONG msg,
MPARAM mp1,
MPARAM mp2);
MRESULT EXPENTRY ProcessHiScoreDialog (HWND hwnd,
ULONG msg,
MPARAM mp1,
MPARAM mp2);
MRESULT EXPENTRY ProcessRegisterDialog (HWND hwnd,
ULONG msg,
MPARAM mp1,
MPARAM mp2);
VOID HideFrameControls (VOID);
VOID ShowFrameControls (VOID);
BOOL CheckPassword (PCHAR szName, PCHAR szID);
/* Handle to the help instance */
HWND hwndHelpInstance;
/**************************************************************************
*
* FUNCTION NAME: HandleCommand
*
* DESCRIPTION:
*
*
* INPUT PARAMETERS:
* None.
*
* OUTPUT PARAMETERS:
* None.
*
**************************************************************************/
MRESULT EXPENTRY HandleCommand (HWND hwnd,
ULONG msg,
MPARAM mp1,
MPARAM mp2)
{
HWND hwndDlg;
MCI_GENERIC_PARMS mciGenericParms;
switch (SHORT1FROMMP (mp1))
{
/*
** Game menu items...
*/
case MENU_START_ID :
eDemoMode = DEMO_NONE;
if (gAction != PAUSED)
{
gAction = START;
}
break;
case MENU_STOP_ID :
eDemoMode = DEMO_NONE;
gAction = STOP;
break;
case MENU_EXIT_ID :
gAction = EXIT;
break;
case MENU_PAUSE_ID :
/* Toggle the pause action */
if ((gAction = (gAction == PAUSED) ? NONE : PAUSED) == PAUSED)
{
PauseGame ();
}
else
{
ResumeGame ();
}
break;
case MENU_DEMO_PLAY_ID :
eDemoMode = DEMO_PLAY;
if (gAction != PAUSED)
{
gAction = START;
}
break;
case MENU_DEMO_RECORD_ID :
/* Display a message box to verify they really want to do this */
if (!gfDemoLoaded ||
WinMessageBox (HWND_DESKTOP, HWND_DESKTOP, CHECK_RECORD,
"Demo Record", 0,
MB_YESNO | MB_WARNING | MB_MOVEABLE) == MBID_YES)
{
eDemoMode = DEMO_RECORD;
if (gAction != PAUSED)
{
gAction = START;
}
}
WinSetFocus (HWND_DESKTOP, hwndDefClient);
break;
/*
** Options menu items...
*/
case MENU_KEY_ID :
hwndDlg = WinLoadDlg (HWND_DESKTOP,
hwndDefClient,
(PFNWP) ProcessKeyDialog,
0L,
KEY_DLG_ID,
NULL);
/* Process the dialog and then destroy it */
WinProcessDlg (hwndDlg);
WinDestroyWindow (hwndDlg);
break;
case MENU_SPEED_ID :
hwndDlg = WinLoadDlg (HWND_DESKTOP,
hwndDefClient,
(PFNWP) ProcessSpeedDialog,
0L,
SPEED_DLG_ID,
NULL);
/* Process the dialog and then destroy it */
WinProcessDlg (hwndDlg);
WinDestroyWindow (hwndDlg);
break;
case MENU_OBJECT_SIZE_ID :
hwndDlg = WinLoadDlg (HWND_DESKTOP,
hwndDefClient,
(PFNWP) ProcessSizeDialog,
0L,
SIZE_DLG_ID,
NULL);
/* Process the dialog and then destroy it */
WinProcessDlg (hwndDlg);
WinDestroyWindow (hwndDlg);
break;
case MENU_HISCORE_ID :
hwndDlg = WinLoadDlg (HWND_DESKTOP,
hwndDefClient,
(PFNWP) ProcessHiScoreDialog,
0L,
HISCORE_DLG_ID,
NULL);
/* Process the dialog and then destroy it */
WinProcessDlg (hwndDlg);
WinDestroyWindow (hwndDlg);
break;
case MENU_REGISTER_ID :
hwndDlg = WinLoadDlg (HWND_DESKTOP,
hwndDefClient,
(PFNWP) ProcessRegisterDialog,
0L,
REG_DLG_ID,
NULL);
/* Process the dialog and then destroy it */
WinProcessDlg (hwndDlg);
WinDestroyWindow (hwndDlg);
break;
case MENU_BULLET_ID :
/* Toggle the bullet menu item */
gfBullets = gfBullets ? FALSE : TRUE;
WinCheckMenuItem (hwndMenu, MENU_BULLET_ID, gfBullets);
break;
case MENU_BUBBLES_ID :
/* Toggle the bubbles menu item */
gfBubbles = gfBubbles ? FALSE : TRUE;
WinCheckMenuItem (hwndMenu, MENU_BUBBLES_ID, gfBubbles);
break;
case MENU_SOUND_ID :
/* Toggle the sound menu item */
if (gfSoundEnabled)
{
gfSoundOn = gfSoundOn ? FALSE : TRUE;
WinCheckMenuItem (hwndMenu, MENU_SOUND_ID, gfSoundOn);
if (gfSoundOn)
{
mciGenericParms.hwndCallback = hwnd;
(*stMMPMFn[MCI_SENDCOMMAND_FN].pFn) (gusWaveDeviceID,
MCI_ACQUIREDEVICE,
(ULONG) MCI_NOTIFY,
(PVOID) &mciGenericParms,
(USHORT) 0);
}
}
break;
case MENU_MUSIC_ID :
/* Toggle the menu menu item */
gfMusicEnabled = gfMusicEnabled ? FALSE : TRUE;
WinCheckMenuItem (hwndMenu, MENU_MUSIC_ID, gfMusicEnabled);
if (gfMusicEnabled)
{
(*stMMPMFn[MCI_SENDCOMMAND_FN].pFn) (gusMidiDeviceID,
MCI_ACQUIREDEVICE,
(ULONG) MCI_NOTIFY,
(PVOID) &mciGenericParms,
(USHORT) 0);
}
if (gsGameOn)
{
/* Play or stop the music */
gsMusicAction = gfMusicEnabled ? START : STOP;
DosPostEventSem (hSoundEventSem);
}
break;
case MENU_MOUSE_ID :
/* Toggle the mouse menu item */
gfMouseEnabled = gfMouseEnabled ? FALSE : TRUE;
WinCheckMenuItem (hwndMenu, MENU_MOUSE_ID, gfMouseEnabled);
EnableMouse (gfMouseEnabled);
break;
case MENU_3SHIPS_ID :
gsStartShips = 3;
WinCheckMenuItem (hwndMenu, MENU_3SHIPS_ID, TRUE);
WinCheckMenuItem (hwndMenu, MENU_4SHIPS_ID, FALSE);
WinCheckMenuItem (hwndMenu, MENU_5SHIPS_ID, FALSE);
break;
case MENU_4SHIPS_ID :
gsStartShips = 4;
WinCheckMenuItem (hwndMenu, MENU_3SHIPS_ID, FALSE);
WinCheckMenuItem (hwndMenu, MENU_4SHIPS_ID, TRUE);
WinCheckMenuItem (hwndMenu, MENU_5SHIPS_ID, FALSE);
break;
case MENU_5SHIPS_ID :
gsStartShips = 5;
WinCheckMenuItem (hwndMenu, MENU_3SHIPS_ID, FALSE);
WinCheckMenuItem (hwndMenu, MENU_4SHIPS_ID, FALSE);
WinCheckMenuItem (hwndMenu, MENU_5SHIPS_ID, TRUE);
break;
case MENU_3SMARTS_ID :
gsStartSmarts = 3;
WinCheckMenuItem (hwndMenu, MENU_3SMARTS_ID, TRUE);
WinCheckMenuItem (hwndMenu, MENU_5SMARTS_ID, FALSE);
WinCheckMenuItem (hwndMenu, MENU_7SMARTS_ID, FALSE);
break;
case MENU_5SMARTS_ID :
gsStartSmarts = 5;
WinCheckMenuItem (hwndMenu, MENU_3SMARTS_ID, FALSE);
WinCheckMenuItem (hwndMenu, MENU_5SMARTS_ID, TRUE);
WinCheckMenuItem (hwndMenu, MENU_7SMARTS_ID, FALSE);
break;
case MENU_7SMARTS_ID :
gsStartSmarts = 7;
WinCheckMenuItem (hwndMenu, MENU_3SMARTS_ID, FALSE);
WinCheckMenuItem (hwndMenu, MENU_5SMARTS_ID, FALSE);
WinCheckMenuItem (hwndMenu, MENU_7SMARTS_ID, TRUE);
break;
case MENU_SONAR_FADE_ID :
stScanner.sMode = SCANNER_SWEEP;
WinCheckMenuItem (hwndMenu, MENU_SONAR_FADE_ID, TRUE);
WinCheckMenuItem (hwndMenu, MENU_SONAR_PERSIST_ID, FALSE);
WinCheckMenuItem (hwndMenu, MENU_SONAR_NO_ID, FALSE);
break;
case MENU_SONAR_PERSIST_ID :
stScanner.sMode = SCANNER_ON;
WinCheckMenuItem (hwndMenu, MENU_SONAR_FADE_ID, FALSE);
WinCheckMenuItem (hwndMenu, MENU_SONAR_PERSIST_ID, TRUE);
WinCheckMenuItem (hwndMenu, MENU_SONAR_NO_ID, FALSE);
break;
case MENU_SONAR_NO_ID :
stScanner.sMode = SCANNER_OFF;
WinCheckMenuItem (hwndMenu, MENU_SONAR_FADE_ID, FALSE);
WinCheckMenuItem (hwndMenu, MENU_SONAR_PERSIST_ID, FALSE);
WinCheckMenuItem (hwndMenu, MENU_SONAR_NO_ID, TRUE);
break;
case MENU_FRAME_CONTROLS_ID :
if (gfShowFrame)
{
HideFrameControls ();
}
else
{
ShowFrameControls ();
}
gfShowFrame = gfShowFrame ? FALSE : TRUE;
WinCheckMenuItem (hwndMenu, MENU_FRAME_CONTROLS_ID, gfShowFrame);
break;
/*
** Help menu items...
*/
case MENU_HELPINDEX_ID :
WinSendMsg (hwndHelpInstance, HM_HELP_INDEX, NULL, NULL);
break;
case MENU_HELPEXTENDED_ID :
WinSendMsg(hwndHelpInstance, HM_EXT_HELP, NULL, NULL);
break;
case MENU_HELPHELPFORHELP_ID :
WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP, NULL, NULL);
break;
case MENU_HELPKEYSHELP_ID :
WinSendMsg (hwndHelpInstance, HM_KEYS_HELP, NULL, NULL);
break;
case MENU_HELPABOUT_ID :
hwndDlg = WinLoadDlg (HWND_DESKTOP,
hwndDefClient,
(PFNWP) ProcessProdInfoDialog,
0L,
PROD_INFO_DLG_ID,
NULL);
/* Process the dialog and then destroy it */
WinProcessDlg (hwndDlg);
WinDestroyWindow (hwndDlg);
break;
default :
return (WinDefWindowProc (hwnd, msg, mp1, mp2));
}
}
/**************************************************************************
*
* FUNCTION NAME: ProcessKeyDialog
*
* DESCRIPTION:
*
*
* INPUT PARAMETERS:
* None.
*
* OUTPUT PARAMETERS:
* None.
*
**************************************************************************/
MRESULT EXPENTRY ProcessKeyDialog (HWND hwnd,
ULONG msg,
MPARAM mp1,
MPARAM mp2)
{
USHORT usScanCode;
static ULONG ulButton = UP_TEXT_ID;
static KEYDEFS stLocalDefs;
static PUSHORT pusKeyDef;
switch (msg)
{
case WM_INITDLG :
/* Store the current key settings */
stLocalDefs = gstKeyDefs;
pusKeyDef = &(stLocalDefs.usUpKey);
/* Set the text for each field in the dialog box */
WinSetDlgItemText (hwnd, UP_TEXT_ID,
szScanCode[stLocalDefs.usUpKey]);
WinSetDlgItemText (hwnd, DOWN_TEXT_ID,
szScanCode[stLocalDefs.usDownKey]);
WinSetDlgItemText (hwnd, TURN_TEXT_ID,
szScanCode[stLocalDefs.usTurnKey]);
WinSetDlgItemText (hwnd, THRUST_TEXT_ID,
szScanCode[stLocalDefs.usThrustKey]);
WinSetDlgItemText (hwnd, FIRE_TEXT_ID,
szScanCode[stLocalDefs.usFireKey]);
WinSetDlgItemText (hwnd, SMART_TEXT_ID,
szScanCode[stLocalDefs.usSmartKey]);
WinSetDlgItemText (hwnd, HYPER_TEXT_ID,
szScanCode[stLocalDefs.usHyperKey]);
/* Set the UP button to the clicked state */
WinPostMsg (WinWindowFromID (hwnd , UP_ID), BM_CLICK,
MPFROMSHORT (TRUE), MPVOID);
/* Set the appropriate button toggle */
if (stLocalDefs.fTurnThrust)
{
WinPostMsg (WinWindowFromID (hwnd , TURN_THRUST_ID), BM_CLICK,
MPFROMSHORT (TRUE), MPVOID);
WinSetDlgItemText (hwnd, TURN_ID, "Turn");
WinSetDlgItemText (hwnd, THRUST_ID, "Thrust");
}
else
{
WinPostMsg (WinWindowFromID (hwnd , LEFT_RIGHT_ID), BM_CLICK,
MPFROMSHORT (TRUE), MPVOID);
WinSetDlgItemText (hwnd, TURN_ID, "Left");
WinSetDlgItemText (hwnd, THRUST_ID, "Right");
}
/* Center the dialog box in the frame window of the parent */
CenterDialog (hwnd);
return (0);
case WM_COMMAND :
switch (SHORT1FROMMP (mp1))
{
case DID_OK:
/* Save the key selections in the global list and save them */
gstKeyDefs = stLocalDefs;
WinDismissDlg (hwnd, DID_OK);
return (0);
case DID_CANCEL:
/* Dismiss the dialog without saving the values */
WinDismissDlg (hwnd, DID_CANCEL);
return (0);
case DID_HELP:
/* Display the keys help panel */
WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP,
MPFROM2SHORT(PANEL_KEYS, NULL),
MPFROMSHORT(HM_RESOURCEID));
return (0);
}
break;
case WM_CONTROL :
switch (SHORT1FROMMP (mp1))
{
case UP_ID:
ulButton = UP_TEXT_ID;
pusKeyDef = &(stLocalDefs.usUpKey);
break;
case DOWN_ID:
ulButton = DOWN_TEXT_ID;
pusKeyDef = &(stLocalDefs.usDownKey);
break;
case TURN_ID:
ulButton = TURN_TEXT_ID;
pusKeyDef = &(stLocalDefs.usTurnKey);
break;
case THRUST_ID:
ulButton = THRUST_TEXT_ID;
pusKeyDef = &(stLocalDefs.usThrustKey);
break;
case FIRE_ID:
ulButton = FIRE_TEXT_ID;
pusKeyDef = &(stLocalDefs.usFireKey);
break;
case SMART_ID:
ulButton = SMART_TEXT_ID;
pusKeyDef = &(stLocalDefs.usSmartKey);
break;
case HYPER_ID:
ulButton = HYPER_TEXT_ID;
pusKeyDef = &(stLocalDefs.usHyperKey);
break;
case TURN_THRUST_ID:
WinSetDlgItemText (hwnd, TURN_ID, "Turn");
WinSetDlgItemText (hwnd, THRUST_ID, "Thrust");
stLocalDefs.fTurnThrust = TRUE;
break;
case LEFT_RIGHT_ID:
WinSetDlgItemText (hwnd, TURN_ID, "Left");
WinSetDlgItemText (hwnd, THRUST_ID, "Right");
stLocalDefs.fTurnThrust = FALSE;
break;
default:
break;
}
/* Take the focus away from the radiobuttons */
WinSetFocus (HWND_DESKTOP, WinWindowFromID (hwnd, UP_TEXT_ID));
break;
case WM_CHAR :
/* Get the scancode and store it in the appropriate place in array */
if (!(SHORT1FROMMP(mp1) & KC_KEYUP))
{
usScanCode = CHAR4FROMMP(mp1);
WinSetDlgItemText (hwnd, ulButton, szScanCode[usScanCode]);
*pusKeyDef = usScanCode;
}
return (0);
default:
break;
}
return (WinDefDlgProc (hwnd, msg, mp1, mp2));
}
/**************************************************************************
*
* FUNCTION NAME: ProcessSpeedDialog
*
* DESCRIPTION:
*
*
* INPUT PARAMETERS:
* None.
*
* OUTPUT PARAMETERS:
* None.
*
**************************************************************************/
MRESULT EXPENTRY ProcessSpeedDialog (HWND hwnd,
ULONG msg,
MPARAM mp1,
MPARAM mp2)
{
USHORT i;
static USHORT usPosition;
switch (msg)
{
case WM_INITDLG :
/* Set the marks on the slider */
for (i = 0; i < 10; i++)
{
WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETTICKSIZE,
MPFROM2SHORT(i, 2), NULL);
}
/* Label the ends of the slider */
WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETTICKSIZE,
MPFROM2SHORT(0, 5), NULL);
WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETTICKSIZE,
MPFROM2SHORT(9, 5), NULL);
WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETSCALETEXT,
MPFROMSHORT(0), MPFROMP(SLOW_LABEL));
WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETSCALETEXT,
MPFROMSHORT(9), MPFROMP(FAST_LABEL));
/* Set the slider position */
usPosition = (gFramesPerSec / 5) - 1;
WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETSLIDERINFO,
MPFROM2SHORT(SMA_SLIDERARMPOSITION,
SMA_INCREMENTVALUE),
MPFROMSHORT(usPosition));
/* Center the dialog box in the frame window of the parent */
CenterDialog (hwnd);
return (0);
case WM_COMMAND :
switch (SHORT1FROMMP (mp1))
{
case DID_OK:
/* Calculate the frame rate from the position of the arm */
gFramesPerSec = (usPosition + 1) * 5;
/* Reset the timer to tick at this rate */
WinStartTimer (hab,
hwndDefClient,
TIMER_ID,
1000/gFramesPerSec);
WinDismissDlg (hwnd, DID_OK);
return (0);
case DID_CANCEL:
/* Dismiss the dialog without saving the values */
WinDismissDlg (hwnd, DID_CANCEL);
return (0);
case DID_HELP:
/* Display the keys help panel */
WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP,
MPFROM2SHORT(PANEL_GAMESPEED, NULL),
MPFROMSHORT(HM_RESOURCEID));
return (0);
default:
break;
}
break;
case WM_CONTROL :
switch (SHORT1FROMMP(mp1))
{
case SLIDER_ID:
if (SHORT2FROMMP(mp1) == SLN_CHANGE)
{
usPosition = (USHORT) WinSendDlgItemMsg (hwnd,
SLIDER_ID,
SLM_QUERYSLIDERINFO,
MPFROM2SHORT (SMA_SLIDERARMPOSITION,
SMA_INCREMENTVALUE),
NULL);
}
break;
default:
break;
}
break;
default:
break;
}
return (WinDefDlgProc (hwnd, msg, mp1, mp2));
}
/**************************************************************************
*
* FUNCTION NAME: ProcessSizeDialog
*
* DESCRIPTION:
*
*
* INPUT PARAMETERS:
* None.
*
* OUTPUT PARAMETERS:
* None.
*
**************************************************************************/
MRESULT EXPENTRY ProcessSizeDialog (HWND hwnd,
ULONG msg,
MPARAM mp1,
MPARAM mp2)
{
USHORT i;
BITMAPINFOHEADER bmpData;
static USHORT usPosition;
switch (msg)
{
case WM_INITDLG :
/* Set the marks on the slider */
for (i = 0; i < 10; i++)
{
WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETTICKSIZE,
MPFROM2SHORT(i, 2), NULL);
}
/* Label the ends and default position of the slider */
WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETTICKSIZE,
MPFROM2SHORT(0, 5), NULL);
WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETTICKSIZE,
MPFROM2SHORT(5, 5), NULL);
WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETTICKSIZE,
MPFROM2SHORT(9, 5), NULL);
WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETSCALETEXT,
MPFROMSHORT(0), MPFROMP(TINY_LABEL));
WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETSCALETEXT,
MPFROMSHORT(5), MPFROMP(NORMAL_LABEL));
WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETSCALETEXT,
MPFROMSHORT(9), MPFROMP(HUGE_LABEL));
/* Set the slider position */
usPosition = gsObjectSize - 1;
WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETSLIDERINFO,
MPFROM2SHORT(SMA_SLIDERARMPOSITION,
SMA_INCREMENTVALUE),
MPFROMSHORT(usPosition));
/* Center the dialog box in the frame window of the parent */
CenterDialog (hwnd);
return (0);
case WM_COMMAND :
switch (SHORT1FROMMP (mp1))
{
case DID_OK:
/* Scale the bitmaps according to the set size */
gsObjectSize = usPosition + 1;
for (i = 0; i < NUM_BMPS; i++)
{
LoadAndStretchBitmap (i);
}
/* Redraw the screen */
WinInvalidateRect (hwndDefClient, NULL, FALSE);
WinDismissDlg (hwnd, DID_OK);
return (0);
case DID_CANCEL:
/* Dismiss the dialog without saving the values */
WinDismissDlg (hwnd, DID_CANCEL);
return (0);
case DID_HELP:
/* Display the keys help panel */
WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP,
MPFROM2SHORT(PANEL_OBJECTSIZE, NULL),
MPFROMSHORT(HM_RESOURCEID));
return (0);
default:
break;
}
break;
case WM_CONTROL :
switch (SHORT1FROMMP(mp1))
{
case SLIDER_ID:
if (SHORT2FROMMP(mp1) == SLN_CHANGE)
{
usPosition = (USHORT) WinSendDlgItemMsg (hwnd,
SLIDER_ID,
SLM_QUERYSLIDERINFO,
MPFROM2SHORT (SMA_SLIDERARMPOSITION,
SMA_INCREMENTVALUE),
NULL);
}
break;
default:
break;
}
break;
default:
break;
}
return (WinDefDlgProc (hwnd, msg, mp1, mp2));
}
/**************************************************************************
*
* FUNCTION NAME: ProcessRegisterDialog
*
* DESCRIPTION:
*
*
* INPUT PARAMETERS:
* None.
*
* OUTPUT PARAMETERS:
* None.
*
**************************************************************************/
MRESULT EXPENTRY ProcessRegisterDialog (HWND hwnd,
ULONG msg,
MPARAM mp1,
MPARAM mp2)
{
CHAR szID[50];
switch (msg)
{
case WM_INITDLG :
/* Center the dialog box in the frame window of the parent */
CenterDialog (hwnd);
return (0);
case WM_COMMAND :
switch (SHORT1FROMMP (mp1))
{
case DID_OK:
WinQueryDlgItemText (hwnd, REG_NAME_ID,
REGISTER_NAME_LEN, gszRegName);
WinQueryDlgItemText (hwnd, REG_ID_ID, sizeof(szID), szID);
if (CheckPassword (gszRegName, szID))
{
/* The password is cool! Save the settings now */
WinDlgBox (HWND_DESKTOP, hwndDefClient,
(PFNWP) ProcessProdInfoDialog,
0L, CONGRATS_DLG_ID, NULL);
gfRegistered = TRUE;
WriteIniFile ();
/* Disable the register menu item now we're registered */
WinEnableMenuItem (hwndMenu, MENU_REGISTER_ID, !gfRegistered);
WinDismissDlg (hwnd, DID_OK);
}
else
{
WinDlgBox (HWND_DESKTOP, hwndDefClient,
(PFNWP) ProcessProdInfoDialog,
0L, SORRY_DLG_ID, NULL);
}
return (0);
case DID_CANCEL:
/* Dismiss the dialog without saving the values */
WinDismissDlg (hwnd, DID_CANCEL);
return (0);
case DID_HELP:
/* Display the keys help panel */
WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP,
MPFROM2SHORT(PANEL_REGISTER, NULL),
MPFROMSHORT(HM_RESOURCEID));
return (0);
default:
break;
}
break;
default:
break;
}
return (WinDefDlgProc (hwnd, msg, mp1, mp2));
}
/**************************************************************************
*
* FUNCTION NAME: ProcessProdInfoDialog
*
* DESCRIPTION:
*
*
* INPUT PARAMETERS:
* None.
*
* OUTPUT PARAMETERS:
* None.
*
**************************************************************************/
MRESULT EXPENTRY ProcessProdInfoDialog (HWND hwnd,
ULONG msg,
MPARAM mp1,
MPARAM mp2)
{
switch (msg)
{
case WM_INITDLG:
CenterDialog (hwnd);
if (gfRegistered)
{
WinSetDlgItemText (hwnd, PROD_REG_NAME_ID, gszRegName);
}
else
{
WinSetDlgItemText (hwnd, PROD_REG_TO_ID, "Unregistered");
WinSetDlgItemText (hwnd, PROD_REG_NAME_ID, "Please register the game.");
}
return (0);
case WM_COMMAND :
switch (SHORT1FROMMP (mp1))
{
case DID_OK:
WinDismissDlg (hwnd, DID_OK);
return (0);
default:
break;
}
break;
default:
break;
}
return (WinDefDlgProc (hwnd, msg, mp1, mp2));
}
/**************************************************************************
*
* FUNCTION NAME: ProcessUnregisteredDialog
*
* DESCRIPTION:
*
*
* INPUT PARAMETERS:
* None.
*
* OUTPUT PARAMETERS:
* None.
*
**************************************************************************/
MRESULT EXPENTRY ProcessUnregisteredDialog (HWND hwnd,
ULONG msg,
MPARAM mp1,
MPARAM mp2)
{
/* Array to track the click boxes */
static CBOXES aCBoxes[] = {{UNREG_CB0, FALSE},
{UNREG_CB1, FALSE},
{UNREG_CB2, FALSE},
{UNREG_CB3, FALSE},
{UNREG_CB4, FALSE},
{UNREG_CB5, FALSE},
{UNREG_CB6, FALSE},
{UNREG_CB7, FALSE},
{UNREG_CB8, FALSE},
{UNREG_CB9, FALSE}};
#define NUM_CBOXES (sizeof(aCBoxes)/sizeof(CBOXES))
static USHORT usClicked = 0;
INT i;
switch (msg)
{
case WM_INITDLG:
CenterDialog (hwnd);
return (0);
case WM_CONTROL :
switch (SHORT1FROMMP (mp1))
{
case UNREG_CB0:
case UNREG_CB1:
case UNREG_CB2:
case UNREG_CB3:
case UNREG_CB4:
case UNREG_CB5:
case UNREG_CB6:
case UNREG_CB7:
case UNREG_CB8:
case UNREG_CB9:
/* Find the entry in the array for this cbox */
for (i = 0; i < NUM_CBOXES; i++)