forked from patrickTingen/DataDigger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wAbout.w
1421 lines (1103 loc) · 42.8 KB
/
wAbout.w
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
&ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 GUI
&ANALYZE-RESUME
&Scoped-define WINDOW-NAME wAbout
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS wAbout
/*------------------------------------------------------------------------
File:
Description:
Input Parameters:
<none>
Output Parameters:
<none>
Author:
Created:
------------------------------------------------------------------------*/
/* This .W file was created with the Progress AppBuilder. */
/*----------------------------------------------------------------------*/
/* Create an unnamed pool to store all the widgets created
by this procedure. This is a good default which assures
that this procedure's triggers and internal procedures
will execute in this procedure's storage, and that proper
cleanup will occur on deletion of the procedure. */
CREATE WIDGET-POOL.
/* *************************** Definitions ************************** */
{ datadigger.i }
DEFINE TEMP-TABLE ttBrick NO-UNDO
FIELD cBlockId AS CHARACTER
FIELD hBrick AS HANDLE
FIELD iLine AS INTEGER
FIELD x1 AS INTEGER
FIELD x2 AS INTEGER
FIELD y1 AS INTEGER
FIELD y2 AS INTEGER
INDEX iPrim IS PRIMARY cBlockId
INDEX iPos x1 x2 y1 y2
.
DEFINE TEMP-TABLE ttScores NO-UNDO
FIELD iRank AS INTEGER
FIELD cName AS CHARACTER
FIELD cTime AS CHARACTER
INDEX iPrim IS PRIMARY iRank
.
/* For debugging in the UIB */
/*&IF DEFINED(UIB_is_Running) <> 0 &THEN*/
RUN startDiggerLib.
PROCEDURE startDiggerLib :
/* Start DiggerLib if it has not already been started
*/
DEFINE VARIABLE hDiggerLib AS HANDLE NO-UNDO.
DEFINE VARIABLE cDiggerLib AS CHARACTER NO-UNDO.
/* Call out to see if the lib has been started */
PUBLISH 'DataDiggerLib' (OUTPUT hDiggerLib).
IF NOT VALID-HANDLE(hDiggerLib) THEN
DO:
/* gcProgramDir = SUBSTRING(THIS-PROCEDURE:FILE-NAME,1,R-INDEX(THIS-PROCEDURE:FILE-NAME,'\')). */
cDiggerLib = THIS-PROCEDURE:FILE-NAME.
cDiggerLib = REPLACE(cDiggerLib,"\","/").
cDiggerLib = SUBSTRING(cDiggerLib,1,R-INDEX(cDiggerLib,'/')) + 'DataDiggerLib.p'.
IF SEARCH(cDiggerLib) = ? THEN cDiggerLib = 'd:\data\progress\DataDigger\DataDiggerLib.p'.
IF SEARCH(cDiggerLib) = ? THEN cDiggerLib = 'd:\data\dropbox\DataDigger\src\DataDiggerLib.p'.
IF SEARCH(cDiggerLib) = ? THEN cDiggerLib = 'c:\data\dropbox\DataDigger\src\DataDiggerLib.p'.
RUN VALUE(cDiggerLib) PERSISTENT SET hDiggerLib.
SESSION:ADD-SUPER-PROCEDURE(hDiggerLib,SEARCH-TARGET).
END.
END PROCEDURE. /* startDiggerLib */
/*&ENDIF*/
DEFINE VARIABLE giBallX AS INTEGER NO-UNDO INITIAL -5.
DEFINE VARIABLE giBallY AS INTEGER NO-UNDO INITIAL -5.
DEFINE VARIABLE giGameStarted AS INTEGER NO-UNDO INITIAL ?.
DEFINE VARIABLE giOldMouseX AS INTEGER NO-UNDO.
DEFINE VARIABLE gcGameStatus AS CHARACTER NO-UNDO.
DEFINE VARIABLE glDebugRun AS LOGICAL NO-UNDO INITIAL NO.
DEFINE VARIABLE giNumLives AS INTEGER NO-UNDO INITIAL 3.
DEFINE VARIABLE giNumTicks AS INTEGER NO-UNDO.
DEFINE VARIABLE glUseTimer AS LOGICAL NO-UNDO.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
/* ******************** Preprocessor Definitions ******************** */
&Scoped-define PROCEDURE-TYPE Window
&Scoped-define DB-AWARE no
/* Name of designated FRAME-NAME and/or first browse and/or first query */
&Scoped-define FRAME-NAME DEFAULT-FRAME
/* Standard List Definitions */
&Scoped-Define ENABLED-OBJECTS btnDataDigger BtnOK edChangelog fiWebsite
&Scoped-Define DISPLAYED-OBJECTS edChangelog fiDataDigger-1 fiDataDigger-2 ~
fiWebsite
/* Custom List Definitions */
/* List-1,List-2,List-3,List-4,List-5,List-6 */
/* _UIB-PREPROCESSOR-BLOCK-END */
&ANALYZE-RESUME
/* *********************** Control Definitions ********************** */
/* Define the widget handle for the window */
DEFINE VAR wAbout AS WIDGET-HANDLE NO-UNDO.
/* Definitions of handles for OCX Containers */
DEFINE VARIABLE CtrlFrame AS WIDGET-HANDLE NO-UNDO.
DEFINE VARIABLE chCtrlFrame AS COMPONENT-HANDLE NO-UNDO.
/* Definitions of the field level widgets */
DEFINE BUTTON btnDataDigger NO-FOCUS
LABEL "D"
SIZE-PIXELS 30 BY 30.
DEFINE BUTTON BtnOK AUTO-GO DEFAULT
LABEL "OK"
SIZE-PIXELS 75 BY 24
BGCOLOR 8 .
DEFINE VARIABLE edChangelog AS CHARACTER
VIEW-AS EDITOR NO-WORD-WRAP SCROLLBAR-VERTICAL LARGE
SIZE-PIXELS 625 BY 335
FONT 0 NO-UNDO.
DEFINE VARIABLE fiDataDigger-1 AS CHARACTER FORMAT "X(256)":U INITIAL "DataDigger ~{&&version} - ~{&&edition}"
VIEW-AS TEXT
SIZE-PIXELS 275 BY 13
FONT 0 NO-UNDO.
DEFINE VARIABLE fiDataDigger-2 AS CHARACTER FORMAT "X(256)":U INITIAL "Build ~{&&build}"
VIEW-AS TEXT
SIZE-PIXELS 155 BY 13
FONT 0 NO-UNDO.
DEFINE VARIABLE fiMsg AS CHARACTER FORMAT "X(256)":U INITIAL "(Click to close window)"
VIEW-AS TEXT
SIZE-PIXELS 170 BY 20
BGCOLOR 14 FGCOLOR 9 NO-UNDO.
DEFINE VARIABLE fiWebsite AS CHARACTER FORMAT "X(256)":U INITIAL "https://datadigger.wordpress.com/"
VIEW-AS TEXT
SIZE-PIXELS 210 BY 20
FGCOLOR 9 NO-UNDO.
DEFINE IMAGE imgBall
FILENAME "adeicon/blank":U TRANSPARENT
SIZE-PIXELS 15 BY 15.
DEFINE IMAGE imgPaddle
FILENAME "adeicon/blank":U TRANSPARENT
SIZE-PIXELS 70 BY 15.
DEFINE IMAGE imgPaddle-2
FILENAME "adeicon/blank":U
STRETCH-TO-FIT TRANSPARENT
SIZE-PIXELS 20 BY 10.
DEFINE IMAGE imgPaddle-3
FILENAME "adeicon/blank":U
STRETCH-TO-FIT TRANSPARENT
SIZE-PIXELS 20 BY 10.
DEFINE IMAGE imgPaddle-4
FILENAME "adeicon/blank":U
STRETCH-TO-FIT TRANSPARENT
SIZE-PIXELS 20 BY 10.
DEFINE IMAGE imgTitle
FILENAME "adeicon/blank":U
STRETCH-TO-FIT TRANSPARENT
SIZE-PIXELS 64 BY 64.
/* ************************ Frame Definitions *********************** */
DEFINE FRAME DEFAULT-FRAME
btnDataDigger AT Y 5 X 5 WIDGET-ID 82
BtnOK AT Y 5 X 545 WIDGET-ID 48
edChangelog AT Y 70 X 0 NO-LABEL WIDGET-ID 72
fiDataDigger-1 AT Y 5 X 35 COLON-ALIGNED NO-LABEL WIDGET-ID 74
fiDataDigger-2 AT Y 20 X 35 COLON-ALIGNED NO-LABEL WIDGET-ID 76
fiMsg AT Y 190 X 190 COLON-ALIGNED NO-LABEL WIDGET-ID 320
fiWebsite AT Y 415 X 190 COLON-ALIGNED NO-LABEL WIDGET-ID 298
imgPaddle AT Y 15 X 325 WIDGET-ID 300
imgBall AT Y 15 X 305 WIDGET-ID 302
imgPaddle-2 AT Y 35 X 325 WIDGET-ID 308
imgPaddle-3 AT Y 35 X 350 WIDGET-ID 310
imgTitle AT Y 45 X 101 WIDGET-ID 314
imgPaddle-4 AT Y 35 X 375 WIDGET-ID 312
WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
SIDE-LABELS NO-UNDERLINE THREE-D
AT COL 1 ROW 1
SIZE 126.6 BY 21.71 WIDGET-ID 100.
/* *********************** Procedure Settings ************************ */
&ANALYZE-SUSPEND _PROCEDURE-SETTINGS
/* Settings for THIS-PROCEDURE
Type: Window
Allow: Basic,Browse,DB-Fields,Window,Query
Other Settings: COMPILE
*/
&ANALYZE-RESUME _END-PROCEDURE-SETTINGS
/* ************************* Create Window ************************** */
&ANALYZE-SUSPEND _CREATE-WINDOW
IF SESSION:DISPLAY-TYPE = "GUI":U THEN
CREATE WINDOW wAbout ASSIGN
HIDDEN = YES
TITLE = "About the DataDigger"
HEIGHT = 21.71
WIDTH = 126.6
MAX-HEIGHT = 54
MAX-WIDTH = 384
VIRTUAL-HEIGHT = 54
VIRTUAL-WIDTH = 384
MIN-BUTTON = no
MAX-BUTTON = no
RESIZE = no
SCROLL-BARS = no
STATUS-AREA = no
BGCOLOR = ?
FGCOLOR = ?
KEEP-FRAME-Z-ORDER = yes
THREE-D = yes
MESSAGE-AREA = no
SENSITIVE = yes.
ELSE {&WINDOW-NAME} = CURRENT-WINDOW.
/* END WINDOW DEFINITION */
&ANALYZE-RESUME
/* *********** Runtime Attributes and AppBuilder Settings *********** */
&ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
/* SETTINGS FOR WINDOW wAbout
NOT-VISIBLE,,RUN-PERSISTENT */
/* SETTINGS FOR FRAME DEFAULT-FRAME
FRAME-NAME */
ASSIGN
FRAME DEFAULT-FRAME:HIDDEN = TRUE.
ASSIGN
edChangelog:READ-ONLY IN FRAME DEFAULT-FRAME = TRUE.
/* SETTINGS FOR FILL-IN fiDataDigger-1 IN FRAME DEFAULT-FRAME
NO-ENABLE */
/* SETTINGS FOR FILL-IN fiDataDigger-2 IN FRAME DEFAULT-FRAME
NO-ENABLE */
/* SETTINGS FOR FILL-IN fiMsg IN FRAME DEFAULT-FRAME
NO-DISPLAY NO-ENABLE */
ASSIGN
fiMsg:HIDDEN IN FRAME DEFAULT-FRAME = TRUE
fiMsg:READ-ONLY IN FRAME DEFAULT-FRAME = TRUE.
/* SETTINGS FOR IMAGE imgBall IN FRAME DEFAULT-FRAME
NO-ENABLE */
ASSIGN
imgBall:HIDDEN IN FRAME DEFAULT-FRAME = TRUE.
/* SETTINGS FOR IMAGE imgPaddle IN FRAME DEFAULT-FRAME
NO-ENABLE */
ASSIGN
imgPaddle:HIDDEN IN FRAME DEFAULT-FRAME = TRUE.
/* SETTINGS FOR IMAGE imgPaddle-2 IN FRAME DEFAULT-FRAME
NO-ENABLE */
ASSIGN
imgPaddle-2:HIDDEN IN FRAME DEFAULT-FRAME = TRUE.
/* SETTINGS FOR IMAGE imgPaddle-3 IN FRAME DEFAULT-FRAME
NO-ENABLE */
ASSIGN
imgPaddle-3:HIDDEN IN FRAME DEFAULT-FRAME = TRUE.
/* SETTINGS FOR IMAGE imgPaddle-4 IN FRAME DEFAULT-FRAME
NO-ENABLE */
ASSIGN
imgPaddle-4:HIDDEN IN FRAME DEFAULT-FRAME = TRUE.
/* SETTINGS FOR IMAGE imgTitle IN FRAME DEFAULT-FRAME
NO-ENABLE */
ASSIGN
imgTitle:HIDDEN IN FRAME DEFAULT-FRAME = TRUE.
IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(wAbout)
THEN wAbout:HIDDEN = yes.
/* _RUN-TIME-ATTRIBUTES-END */
&ANALYZE-RESUME
/* ********************** Create OCX Containers ********************** */
&ANALYZE-SUSPEND _CREATE-DYNAMIC
&IF "{&OPSYS}" = "WIN32":U AND "{&WINDOW-SYSTEM}" NE "TTY":U &THEN
CREATE CONTROL-FRAME CtrlFrame ASSIGN
FRAME = FRAME DEFAULT-FRAME:HANDLE
ROW = 1.95
COLUMN = 82.8
HEIGHT = 1.43
WIDTH = 6
WIDGET-ID = 292
HIDDEN = yes
SENSITIVE = yes.
/* CtrlFrame OCXINFO:CREATE-CONTROL from: {F0B88A90-F5DA-11CF-B545-0020AF6ED35A} type: BallTimer */
CtrlFrame:MOVE-AFTER(BtnOK:HANDLE IN FRAME DEFAULT-FRAME).
&ENDIF
&ANALYZE-RESUME /* End of _CREATE-DYNAMIC */
/* ************************ Control Triggers ************************ */
&Scoped-define SELF-NAME wAbout
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wAbout wAbout
ON END-ERROR OF wAbout /* About the DataDigger */
OR ENDKEY OF {&WINDOW-NAME} ANYWHERE DO:
APPLY 'CLOSE' TO THIS-PROCEDURE.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wAbout wAbout
ON WINDOW-CLOSE OF wAbout /* About the DataDigger */
DO:
/* This event will close the window and terminate the procedure. */
APPLY "CLOSE":U TO THIS-PROCEDURE.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME DEFAULT-FRAME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL DEFAULT-FRAME wAbout
ON F12 OF FRAME DEFAULT-FRAME
ANYWHERE DO:
RUN gameOver(YES).
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnDataDigger
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnDataDigger wAbout
ON CHOOSE OF btnDataDigger IN FRAME DEFAULT-FRAME /* D */
DO:
IF glUseTimer THEN RUN showLog.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME BtnOK
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL BtnOK wAbout
ON CHOOSE OF BtnOK IN FRAME DEFAULT-FRAME /* OK */
DO:
APPLY 'CLOSE' TO THIS-PROCEDURE.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME CtrlFrame
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL CtrlFrame wAbout OCX.Tick
PROCEDURE CtrlFrame.BallTimer.Tick .
/*------------------------------------------------------------------------------
Name : BallTimer.ocx.tick
Desc : Move the ball
------------------------------------------------------------------------------*/
/* set paddle only once every few ticks */
IF giNumTicks MODULO 2 = 0 THEN RUN setPaddle.
giNumTicks = giNumTicks + 1.
RUN moveBall.
END PROCEDURE. /* OCX.Tick */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME fiWebsite
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fiWebsite wAbout
ON MOUSE-SELECT-CLICK OF fiWebsite IN FRAME DEFAULT-FRAME
DO:
OS-COMMAND NO-WAIT START VALUE(SELF:SCREEN-VALUE).
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&UNDEFINE SELF-NAME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK wAbout
/* *************************** Main Block *************************** */
/* Set CURRENT-WINDOW: this will parent dialog-boxes and frames. */
ASSIGN CURRENT-WINDOW = {&WINDOW-NAME}
THIS-PROCEDURE:CURRENT-WINDOW = {&WINDOW-NAME}.
/* The CLOSE event can be used from inside or outside the procedure to */
/* terminate it. */
ON CLOSE OF THIS-PROCEDURE
RUN disable_UI.
/* Best default for GUI applications is... */
PAUSE 0 BEFORE-HIDE.
/* Now enable the interface and wait for the exit condition. */
/* (NOTE: handle ERROR and END-KEY so cleanup code will always fire. */
MAIN-BLOCK:
DO ON ERROR UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK
ON END-KEY UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK:
FRAME {&FRAME-NAME}:HIDDEN = YES.
RUN initializeUi.
RUN initializeObject.
FRAME {&FRAME-NAME}:HIDDEN = NO.
RUN blinkLogo.
WAIT-FOR CLOSE OF THIS-PROCEDURE FOCUS edChangelog.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
/* ********************** Internal Procedures *********************** */
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE blinkLogo wAbout
PROCEDURE blinkLogo :
/* Blink the DD logo
*/
DEFINE VARIABLE ii AS INTEGER NO-UNDO.
DEFINE VARIABLE xx AS DECIMAL NO-UNDO.
DEFINE VARIABLE yy AS DECIMAL NO-UNDO.
DEFINE VARIABLE dx AS DECIMAL NO-UNDO INIT -5. /* hor speed */
DEFINE VARIABLE dy AS DECIMAL NO-UNDO INIT 0. /* ver speed */
DEFINE VARIABLE grav AS DECIMAL NO-UNDO INIT .2. /* gravity acceleration */
/* debug */
IF glDebugRun OR NOT glUseTimer THEN
DO WITH FRAME {&FRAME-NAME}:
btnDataDigger:X = 5.
btnDataDigger:Y = 5.
RETURN.
END.
DO WITH FRAME {&FRAME-NAME}:
btnDataDigger:MOVE-TO-TOP().
btnDataDigger:X = 600.
btnDataDigger:Y = 0.
btnDataDigger:VISIBLE = FALSE.
yy = btnDataDigger:Y.
xx = btnDataDigger:X.
RUN justWait(1000).
btnDataDigger:VISIBLE = TRUE.
END.
REPEAT:
/* Normal flow */
dy = dy + grav.
xx = xx + dx.
yy = yy + dy.
/* Bounce at bottom of frame */
IF yy > (FRAME {&FRAME-NAME}:HEIGHT-PIXELS - btnDataDigger:HEIGHT-PIXELS) THEN
DO:
yy = FRAME {&FRAME-NAME}:HEIGHT-PIXELS - btnDataDigger:HEIGHT-PIXELS.
dy = -1 * dy.
END.
IF xx <= 5 THEN LEAVE.
btnDataDigger:X = xx.
btnDataDigger:Y = yy.
RUN justWait(10).
END.
btnDataDigger:X = 5.
btnDataDigger:Y = 5.
DO ii = 1 TO 3:
btnDataDigger:SENSITIVE = NO.
RUN justWait(300).
btnDataDigger:SENSITIVE = YES.
RUN justWait(300).
END.
END PROCEDURE. /* blinkLogo */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE control_load wAbout _CONTROL-LOAD
PROCEDURE control_load :
/*------------------------------------------------------------------------------
Purpose: Load the OCXs
Parameters: <none>
Notes: Here we load, initialize and make visible the
OCXs in the interface.
------------------------------------------------------------------------------*/
&IF "{&OPSYS}" = "WIN32":U AND "{&WINDOW-SYSTEM}" NE "TTY":U &THEN
DEFINE VARIABLE UIB_S AS LOGICAL NO-UNDO.
DEFINE VARIABLE OCXFile AS CHARACTER NO-UNDO.
OCXFile = SEARCH( "wAbout.wrx":U ).
IF OCXFile = ? THEN
OCXFile = SEARCH(SUBSTRING(THIS-PROCEDURE:FILE-NAME, 1,
R-INDEX(THIS-PROCEDURE:FILE-NAME, ".":U), "CHARACTER":U) + "wrx":U).
IF OCXFile <> ? THEN
DO:
ASSIGN
chCtrlFrame = CtrlFrame:COM-HANDLE
UIB_S = chCtrlFrame:LoadControls( OCXFile, "CtrlFrame":U)
CtrlFrame:NAME = "CtrlFrame":U
.
RUN initialize-controls IN THIS-PROCEDURE NO-ERROR.
END.
ELSE MESSAGE "wAbout.wrx":U SKIP(1)
"The binary control file could not be found. The controls cannot be loaded."
VIEW-AS ALERT-BOX TITLE "Controls Not Loaded".
&ENDIF
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE createBricks wAbout
PROCEDURE createBricks :
/* Build blocks on the screen via button widgets
*/
DEFINE BUFFER bfBrick FOR ttBrick.
FOR EACH bfBrick:
CREATE FILL-IN bfBrick.hBrick
ASSIGN
X = 1
Y = 1
FONT = getFont('fixed')
FRAME = FRAME {&FRAME-NAME}:HANDLE
SENSITIVE = TRUE
VISIBLE = FALSE
WIDTH-PIXELS = FONT-TABLE:GET-TEXT-WIDTH-PIXELS(bfBrick.cBlockId, getFont('fixed')) + 15
HEIGHT-PIXELS = FONT-TABLE:GET-TEXT-HEIGHT-PIXELS(getFont('fixed')) + 8
FORMAT = 'X(100)'
.
END.
END PROCEDURE. /* createBricks */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI wAbout _DEFAULT-DISABLE
PROCEDURE disable_UI :
/*------------------------------------------------------------------------------
Purpose: DISABLE the User Interface
Parameters: <none>
Notes: Here we clean-up the user-interface by deleting
dynamic widgets we have created and/or hide
frames. This procedure is usually called when
we are ready to "clean-up" after running.
------------------------------------------------------------------------------*/
/* Delete the WINDOW we created */
IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(wAbout)
THEN DELETE WIDGET wAbout.
IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE gameOver wAbout
PROCEDURE gameOver :
/* Game over
**/
DEFINE INPUT PARAMETER plPlayerLost AS LOGICAL NO-UNDO.
DO WITH FRAME {&FRAME-NAME}:
gcGameStatus = 'Game Over'.
/* Disable ball mover */
chCtrlFrame:BallTimer:ENABLED = FALSE.
/* Load proper image: 'Game Over' or 'Good Job' */
IF plPlayerLost THEN
imgTitle:LOAD-IMAGE(getImagePath('AboutTitle2.gif')).
ELSE
imgTitle:LOAD-IMAGE(getImagePath('AboutTitle3.gif')).
imgTitle:WIDTH-PIXELS = 600.
imgTitle:HEIGHT-PIXELS = 100.
imgTitle:X = 250.
imgTitle:Y = 300.
imgTitle:VISIBLE = TRUE.
/* Show 'Click to close' message */
RUN justWait(1000).
ASSIGN
fiMsg:FONT = getFont('fixed')
fiMsg:SCREEN-VALUE = '(Click to close window)'
fiMsg:WIDTH-PIXELS = FONT-TABLE:GET-TEXT-WIDTH-PIXELS(fiMsg:SCREEN-VALUE, getFont('fixed')) + 10
fiMsg:HEIGHT-PIXELS = FONT-TABLE:GET-TEXT-HEIGHT-PIXELS(getFont('fixed'))
fiMsg:X = (FRAME {&FRAME-NAME}:WIDTH-PIXELS - fiMsg:WIDTH-PIXELS) / 2
fiMsg:Y = 450
fiMsg:VISIBLE = YES.
fiMsg:SENSITIVE = YES
.
END.
END PROCEDURE. /* gameOver */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE hitBottom wAbout
PROCEDURE hitBottom :
/*------------------------------------------------------------------------------
Purpose:
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/
DEFINE VARIABLE ii AS INTEGER NO-UNDO.
DO ii = 1 TO 3:
RUN justWait(100).
FRAME {&FRAME-NAME}:BGCOLOR = 14.
RUN justWait(100).
FRAME {&FRAME-NAME}:BGCOLOR = ?.
END.
giNumLives = giNumLives - 1.
IF giNumLives = 0 THEN
DO:
RUN gameOver(YES).
END.
ELSE
DO:
RUN setBall(NO).
END.
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE initializeObject wAbout
PROCEDURE initializeObject :
/* Init frame
*/
DEFINE BUFFER bQuery FOR ttQuery.
DO WITH FRAME {&FRAME-NAME}:
wAbout:VISIBLE = FALSE.
/* Position frame relative to main window */
wAbout:X = MAXIMUM(0, INTEGER(getRegistry('DataDigger', 'Window:x' )) - 50).
wAbout:Y = MAXIMUM(0, INTEGER(getRegistry('DataDigger', 'Window:y' )) - 20).
/* Prepare frame */
FRAME {&FRAME-NAME}:FONT = getFont('Default').
fiDataDigger-1:FONT = getFont('Fixed').
fiDataDigger-2:FONT = getFont('Fixed').
edChangelog:FONT = getFont('Fixed').
btnDataDigger:LOAD-IMAGE(getImagePath('DataDigger24x24.gif')).
imgBall:LOAD-IMAGE(getImagePath('Ball.gif')).
imgPaddle:LOAD-IMAGE(getImagePath('Paddle.gif')).
imgPaddle-2:LOAD-IMAGE(getImagePath('Paddle.gif')).
imgPaddle-3:LOAD-IMAGE(getImagePath('Paddle.gif')).
imgPaddle-4:LOAD-IMAGE(getImagePath('Paddle.gif')).
/* DiggerNoid title */
imgTitle:LOAD-IMAGE(getImagePath('AboutTitle.gif')).
imgTitle:VISIBLE = FALSE.
/* Disable ball mover */
IF glUseTimer THEN
chCtrlFrame:BallTimer:ENABLED = TRUE.
/* Set version name */
fiDataDigger-1:SCREEN-VALUE = "DataDigger {&version} - {&edition}".
fiDataDigger-2:SCREEN-VALUE = 'Build {&build}'.
/* Load changelog */
edChangeLog:INSERT-FILE(getProgramDir() + 'DataDigger.txt').
edChangeLog:CURSOR-OFFSET = 1.
RUN setTransparency(INPUT FRAME {&FRAME-NAME}:HANDLE, 1).
/* For some reasons, these #*$&# scrollbars keep coming back */
RUN showScrollBars(FRAME {&FRAME-NAME}:HANDLE, NO, NO). /* KILL KILL KILL */
wAbout:VISIBLE = TRUE.
END.
END PROCEDURE. /* initializeObject. */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE initializeUi wAbout
PROCEDURE initializeUi :
/* Enable the user interface
*/
DEFINE VARIABLE UIB_S AS LOGICAL NO-UNDO.
DEFINE VARIABLE OCXFile AS CHARACTER NO-UNDO.
/* Load wrx file if possible */
OCXFile = SEARCH( "wAbout.wrx":U ).
IF OCXFile = ? THEN
OCXFile = SEARCH(SUBSTRING(THIS-PROCEDURE:FILE-NAME, 1,
R-INDEX(THIS-PROCEDURE:FILE-NAME, ".":U), "CHARACTER":U) + "wrx":U).
IF OCXFile <> ? THEN
DO:
ASSIGN
chCtrlFrame = CtrlFrame:COM-HANDLE
CtrlFrame:NAME = "CtrlFrame":U
UIB_S = chCtrlFrame:LoadControls( OCXFile, "CtrlFrame":U) NO-ERROR
.
/* Check for message 6087:
* Specified ActiveX control is not registered or the .ocx file was moved from where it was registered.
* Error occurred in procedure: <procedure name> (6087)
* This error occurred while trying to load an ActiveX control.
* It is possible that the control was not properly installed or that the .ocx file was moved or deleted.
*/
IF ERROR-STATUS:GET-NUMBER(1) = 6087 THEN
glUseTimer = NO.
ELSE
glUseTimer = YES.
END.
/* From enable_ui */
DISPLAY edChangelog fiDataDigger-1 fiDataDigger-2 fiWebsite
WITH FRAME DEFAULT-FRAME IN WINDOW wAbout.
ENABLE btnDataDigger BtnOK edChangelog fiWebsite
WITH FRAME DEFAULT-FRAME IN WINDOW wAbout.
VIEW FRAME DEFAULT-FRAME IN WINDOW wAbout.
{&OPEN-BROWSERS-IN-QUERY-DEFAULT-FRAME}
END PROCEDURE. /* initializeUi */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE justWait wAbout
PROCEDURE justWait :
/* Wait a few miliseconds
*/
DEFINE INPUT PARAMETER piWait AS INTEGER NO-UNDO.
DEFINE VARIABLE iStart AS INTEGER NO-UNDO.
DEFINE VARIABLE lUseTimer AS LOGICAL NO-UNDO.
iStart = ETIME.
/* For the duration of the wait, switch off
* the timer to avoid deep loops */
lUseTimer = chCtrlFrame:BallTimer:ENABLED.
chCtrlFrame:BallTimer:ENABLED = FALSE.
DO WHILE ETIME < iStart + piWait:
PROCESS EVENTS.
END.
chCtrlFrame:BallTimer:ENABLED = lUseTimer.
END PROCEDURE. /* justWait */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE moveBall wAbout
PROCEDURE moveBall :
/* Move the ball and detect collisions
*/
DEFINE VARIABLE iNewX AS INTEGER NO-UNDO.
DEFINE VARIABLE iNewY AS INTEGER NO-UNDO.
DEFINE VARIABLE iMinY AS INTEGER NO-UNDO INITIAL 7.
DEFINE VARIABLE iMaxY AS INTEGER NO-UNDO.
DEFINE VARIABLE iMinX AS INTEGER NO-UNDO INITIAL 7.
DEFINE VARIABLE iMaxX AS INTEGER NO-UNDO.
DEFINE VARIABLE iPaddleX AS INTEGER NO-UNDO.
DEFINE VARIABLE iPaddleY AS INTEGER NO-UNDO.
DEFINE BUFFER bfBrick FOR ttBrick.
/* Turn off events when we're running */
IF gcGameStatus <> 'running' THEN RETURN.
DO WITH FRAME {&FRAME-NAME}:
iNewX = imgBall:X + 7.
iNewY = imgBall:Y + 7.
iMaxY = FRAME {&FRAME-NAME}:HEIGHT-PIXELS - 7.
iMaxX = FRAME {&FRAME-NAME}:WIDTH-PIXELS - 7.
/* New X-pos for the ball */
iNewX = iNewX + giBallX.
/* Gonna hit the wall? */
IF iNewX <= iMinX OR iNewX >= iMaxX THEN
DO:
giBallX = giBallX * -1.
RETURN.
END.
ELSE
DO:
FIND FIRST bfBrick
WHERE iNewX > bfBrick.x1 AND iNewX < bfBrick.x2
AND iNewY > bfBrick.y1 AND iNewY < bfBrick.y2 NO-ERROR.
IF AVAILABLE bfBrick THEN
DO:
giBallX = giBallX * -1.
DELETE OBJECT bfBrick.hBrick.
DELETE bfBrick.
IF NOT CAN-FIND(FIRST bfBrick) THEN RUN gameOver(NO).
RETURN.
END.
END.
/* new Y-pos for the ball */
iNewY = iNewY + giBallY.
/* Hit top or bottom? */
IF iNewY <= iMinY OR iNewY >= iMaxY THEN
DO:
/* flash when bottom is hit */
IF iNewY >= iMaxY THEN RUN hitBottom.
giBallY = giBallY * -1.
RETURN.
END.
ELSE
DO:
FIND FIRST bfBrick
WHERE iNewX > bfBrick.x1 AND iNewX < bfBrick.x2
AND iNewY > bfBrick.y1 AND iNewY < bfBrick.y2 NO-ERROR.
IF AVAILABLE bfBrick THEN
DO:
giBallY = giBallY * -1.
DELETE OBJECT bfBrick.hBrick.
DELETE bfBrick.
IF NOT CAN-FIND(FIRST bfBrick) THEN RUN gameOver(NO).
RETURN.
END.
END.
/* hit the paddle? */
ASSIGN
iPaddleX = imgPaddle:X
iPaddleY = imgPaddle:Y.
IF iNewY >= iPaddleY - 10
AND iNewY <= iPaddleY + imgBall:HEIGHT-PIXELS
AND iNewX >= iPaddleX
AND iNewX <= iPaddleX + 70 THEN
DO:
/* Right side ball hits left side of paddle */
IF iNewX >= iPaddleX
AND iNewX <= iPaddleX + 20 THEN
ASSIGN
giBallY = giBallY * -1
giBallX = -3 - (RANDOM(1,3) * 2).
ELSE
/* Ball hits center of paddle */
IF iNewX >= iPaddleX + 20
AND iNewX <= iPaddleX + 50 THEN
ASSIGN
giBallY = giBallY * -1.
ELSE
/* Left side of ball hits right side of paddle */
IF iNewX >= iPaddleX + 50
AND iNewX <= iPaddleX + 70 THEN
ASSIGN
giBallY = giBallY * -1
giBallX = 3 + (RANDOM(1,3) * 2).
END.
imgBall:X = iNewX - 7.
imgBall:Y = iNewY - 7.
END.
END PROCEDURE. /* moveBall */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE movePaddle wAbout
PROCEDURE movePaddle :
/*------------------------------------------------------------------------------
Purpose:
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/
DEFINE INPUT PARAMETER piMove AS INTEGER NO-UNDO.
DO WITH FRAME {&FRAME-NAME}:
IF imgPaddle:X + piMove > 0
AND imgPaddle:X + piMove < (FRAME {&FRAME-NAME}:WIDTH-PIXELS - imgPaddle:WIDTH-PIXELS - 10) THEN
imgPaddle:X = imgPaddle:X + piMove.
END.
END PROCEDURE. /* movePaddle */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE prepareWindow wAbout
PROCEDURE prepareWindow :
/* Grow window to desired size and position
*/
DEFINE VARIABLE iStep AS INTEGER NO-UNDO.
DEFINE VARIABLE iStartH AS INTEGER NO-UNDO.
DEFINE VARIABLE iStartW AS INTEGER NO-UNDO.
DEFINE VARIABLE iStartX AS INTEGER NO-UNDO.
DEFINE VARIABLE iStartY AS INTEGER NO-UNDO.
DEFINE VARIABLE iStartEdH AS INTEGER NO-UNDO.
DEFINE VARIABLE iStartEdW AS INTEGER NO-UNDO.
DEFINE VARIABLE iEndH AS INTEGER NO-UNDO.
DEFINE VARIABLE iEndW AS INTEGER NO-UNDO.
DEFINE VARIABLE iEndY AS INTEGER NO-UNDO.
DEFINE VARIABLE iEndX AS INTEGER NO-UNDO.
DEFINE VARIABLE iEndEdH AS INTEGER NO-UNDO.
DEFINE VARIABLE iEndEdW AS INTEGER NO-UNDO.
DEFINE VARIABLE iNumSteps AS INTEGER NO-UNDO INITIAL 50.