forked from 1dot13/source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HelpScreen.cpp
2562 lines (1931 loc) · 72.7 KB
/
HelpScreen.cpp
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
#include "sgp.h"
#include "sysutil.h"
#include "vobject_blitters.h"
#include "wcheck.h"
#include "cursors.h"
#include "font control.h"
#include "cursor control.h"
#include "render dirty.h"
#include "Text.h"
#include "Utilities.h"
#include "WordWrap.h"
#include "Font Control.h"
#include "text.h"
#include "HelpScreen.h"
#include "HelpScreenText.h"
#include "Line.h"
#include "Game Clock.h"
#include "GameSettings.h"
#include "laptop.h"
#include "Text Input.h"
#include "english.h"
#include "renderworld.h"
#include "Game Init.h"
#include "Overhead.h"
extern INT16 gsVIEWPORT_END_Y;
extern void PrintDate( void );
extern void PrintNumberOnTeam( void );
extern void PrintBalance( void );
extern BOOLEAN fMapScreenBottomDirty;
extern BOOLEAN fCharacterInfoPanelDirty;
extern BOOLEAN fTeamPanelDirty;
extern BOOLEAN fMapScreenBottomDirty;
extern BOOLEAN fMapPanelDirty;
extern BOOLEAN gfGamePaused;
extern BOOLEAN fShowMapInventoryPool;
extern BOOLEAN BltVSurfaceUsingDD( HVSURFACE hDestVSurface, HVSURFACE hSrcVSurface, UINT32 fBltFlags, INT32 iDestX, INT32 iDestY, RECT *SrcRect );
#define HELP_SCREEN_ACTIVE 0x00000001
//The defualt size and placement of the screen
//#define HELP_SCREEN_DEFUALT_LOC_X 155
//#define HELP_SCREEN_DEFUALT_LOC_Y 105
#define HELP_SCREEN_DEFUALT_LOC_WIDTH HELP_SCREEN_SMALL_LOC_WIDTH + HELP_SCREEN_BUTTON_BORDER_WIDTH
#define HELP_SCREEN_DEFUALT_LOC_HEIGHT 292//300
#define HELP_SCREEN_BUTTON_BORDER_WIDTH 92
#define HELP_SCREEN_SMALL_LOC_WIDTH 320
#define HELP_SCREEN_SMALL_LOC_HEIGHT HELP_SCREEN_DEFUALT_LOC_HEIGHT //224
#define HELP_SCREEN_BTN_OFFSET_X 11
#define HELP_SCREEN_BTN_OFFSET_Y 12//50
#define HELP_SCREEN_BTN_FONT_ON_COLOR 73
#define HELP_SCREEN_BTN_FONT_OFF_COLOR FONT_MCOLOR_WHITE
#define HELP_SCREEN_BTN_FONT_BACK_COLOR 50
#define HELP_SCREEN_BTN_FONT FONT10ARIAL
#define HELP_SCREEN_BTN_WIDTH 77
#define HELP_SCREEN_BTN_HEIGHT 22
#define HELP_SCREEN_GAP_BN_BTNS 8
#define HELP_SCREEN_MARGIN_SIZE 10
#define HELP_SCREEN_TEXT_RIGHT_MARGIN_SPACE 36
#define HELP_SCREEN_TEXT_LEFT_MARGIN_WITH_BTN ( HELP_SCREEN_BUTTON_BORDER_WIDTH + 5 + HELP_SCREEN_MARGIN_SIZE )
#define HELP_SCREEN_TEXT_LEFT_MARGIN ( 5 + HELP_SCREEN_MARGIN_SIZE )
#define HELP_SCREEN_TEXT_OFFSET_Y 48
#define HELP_SCREEN_GAP_BTN_LINES 2
#define HELP_SCREEN_TITLE_BODY_FONT FONT12ARIAL
#define HELP_SCREEN_TITLE_BODY_COLOR FONT_MCOLOR_WHITE//FONT_NEARBLACK
#define HELP_SCREEN_TEXT_BODY_FONT FONT10ARIAL
#define HELP_SCREEN_TEXT_BODY_COLOR FONT_MCOLOR_WHITE//FONT_NEARBLACK
#define HELP_SCREEN_TEXT_BACKGROUND 0//NO_SHADOW//FONT_MCOLOR_WHITE
#define HELP_SCREEN_TITLE_OFFSET_Y 7
#define HELP_SCREEN_HELP_REMINDER_Y HELP_SCREEN_TITLE_OFFSET_Y + 15
#define HELP_SCREEN_NUM_BTNS 8
#define HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_X 4
#define HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_Y 18
#define HELP_SCREEN_SHOW_HELP_AGAIN_REGION_TEXT_OFFSET_X 25 + HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_X
#define HELP_SCREEN_SHOW_HELP_AGAIN_REGION_TEXT_OFFSET_Y ( HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_Y )
#define HELP_SCREEN_EXIT_BTN_OFFSET_X 291
#define HELP_SCREEN_EXIT_BTN_LOC_Y 9
#define HELP_SCREEN_
//the type of help screen
#define HLP_SCRN_DEFAULT_TYPE 9
#define HLP_SCRN_BUTTON_BORDER 8
//this is the size of the text buffer where everything will be blitted.
// 2 ( bytest for char ) * width of buffer * height of 1 line * # of text lines
//#define HLP_SCRN__NUMBER_BYTES_IN_TEXT_BUFFER ( 2 * HLP_SCRN__WIDTH_OF_TEXT_BUFFER * HLP_SCRN__HEIGHT_OF_1_LINE_IN_BUFFER * HLP_SCRN__MAX_NUMBER_OF_LINES_IN_BUFFER )
#define HLP_SCRN__WIDTH_OF_TEXT_BUFFER 280
#define HLP_SCRN__MAX_NUMBER_OF_LINES_IN_BUFFER 170//100
#define HLP_SCRN__HEIGHT_OF_1_LINE_IN_BUFFER ( GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT ) + HELP_SCREEN_GAP_BTN_LINES )
#define HLP_SCRN__MAX_NUMBER_PIXELS_DISPLAYED_IN_TEXT_BUFFER HELP_SCREEN_DEFUALT_LOC_HEIGHT
#define HLP_SCRN__HEIGHT_OF_TEXT_BUFFER ( HLP_SCRN__HEIGHT_OF_1_LINE_IN_BUFFER * HLP_SCRN__MAX_NUMBER_OF_LINES_IN_BUFFER )
#define HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER ( HLP_SCRN__HEIGHT_OF_TEXT_AREA / HLP_SCRN__HEIGHT_OF_1_LINE_IN_BUFFER )
#define HLP_SCRN__HEIGHT_OF_TEXT_AREA 228
#define HLP_SCRN__HEIGHT_OF_SCROLL_AREA 182
#define HLP_SCRN__WIDTH_OF_SCROLL_AREA 20
#define HLP_SCRN__SCROLL_POSX 292
#define HLP_SCRN__SCROLL_POSY ( gHelpScreen.usScreenLocY + 63 )
#define HLP_SCRN__SCROLL_UP_ARROW_X 292
#define HLP_SCRN__SCROLL_UP_ARROW_Y 43
#define HLP_SCRN__SCROLL_DWN_ARROW_X HLP_SCRN__SCROLL_UP_ARROW_X
#define HLP_SCRN__SCROLL_DWN_ARROW_Y HLP_SCRN__SCROLL_UP_ARROW_Y + 202
//enums for the different dirty levels
enum
{
HLP_SCRN_DRTY_LVL_NOT_DIRTY,
HLP_SCRN_DRTY_LVL_REFRESH_TEXT,
HLP_SCRN_DRTY_LVL_REFRESH_ALL,
};
//new screen:
enum
{
HLP_SCRN_MPSCRN_SCTR_OVERVIEW,
};
//mapscreen, welcome to arulco
enum
{
HLP_SCRN_MPSCRN_OVERVIEW,
HLP_SCRN_MPSCRN_ASSIGNMENTS,
HLP_SCRN_MPSCRN_DESTINATIONS,
HLP_SCRN_MPSCRN_MAP,
HLP_SCRN_MPSCRN_MILITIA,
HLP_SCRN_MPSCRN_AIRSPACE,
HLP_SCRN_MPSCRN_ITEMS,
HLP_SCRN_MPSCRN_KEYBOARD,
HLP_SCRN_NUM_MPSCRN_BTNS,
};
//laptop sub pages
enum
{
HLP_SCRN_LPTP_OVERVIEW,
HLP_SCRN_LPTP_EMAIL,
HLP_SCRN_LPTP_WEB,
HLP_SCRN_LPTP_FILES,
HLP_SCRN_LPTP_HISTORY,
HLP_SCRN_LPTP_PERSONNEL,
HLP_SCRN_LPTP_FINANCIAL,
HLP_SCRN_LPTP_MERC_STATS,
HLP_SCRN_LPTP_NUM_PAGES,
};
//Mapscreen no one hired yet pages
enum
{
HLP_SCRN_NO_ONE_HIRED,
HLP_SCRN_NUM_MAPSCREEN_NO_1_HIRED_YET_PAGES,
};
//mapscreen no 1 hired yet pages
enum
{
HLP_SCRN_NOT_IN_ARULCO,
HLP_SCRN_NUM_NOT_IN_ARULCO_PAGES,
};
//Tactical
enum
{
HLP_SCRN_TACTICAL_OVERVIEW,
HLP_SCRN_TACTICAL_MOVEMENT,
HLP_SCRN_TACTICAL_SIGHT,
HLP_SCRN_TACTICAL_ATTACKING,
HLP_SCRN_TACTICAL_ITEMS,
HLP_SCRN_TACTICAL_KEYBOARD,
HLP_SCRN_NUM_TACTICAL_PAGES,
};
//ddd
HELP_SCREEN_STRUCT gHelpScreen;
typedef struct
{
INT32 iButtonTextNum[ HELP_SCREEN_NUM_BTNS ];
} HELP_SCREEN_BTN_TEXT_RECORD;
//An array of record nums for the text on the help buttons
HELP_SCREEN_BTN_TEXT_RECORD gHelpScreenBtnTextRecordNum[ HELP_SCREEN_NUMBER_OF_HELP_SCREENS ] =
{
//new screen:
//Laptop button record nums
// HELP_SCREEN_LAPTOP,
{ HLP_TXT_LAPTOP_BUTTON_1,
HLP_TXT_LAPTOP_BUTTON_2,
HLP_TXT_LAPTOP_BUTTON_3,
HLP_TXT_LAPTOP_BUTTON_4,
HLP_TXT_LAPTOP_BUTTON_5,
HLP_TXT_LAPTOP_BUTTON_6,
HLP_TXT_LAPTOP_BUTTON_7,
HLP_TXT_LAPTOP_BUTTON_8, },
// HELP_SCREEN_MAPSCREEN,
{ HLP_TXT_WELCOM_TO_ARULCO_BUTTON_1,
HLP_TXT_WELCOM_TO_ARULCO_BUTTON_2,
HLP_TXT_WELCOM_TO_ARULCO_BUTTON_3,
HLP_TXT_WELCOM_TO_ARULCO_BUTTON_4,
HLP_TXT_WELCOM_TO_ARULCO_BUTTON_5,
HLP_TXT_WELCOM_TO_ARULCO_BUTTON_6,
HLP_TXT_WELCOM_TO_ARULCO_BUTTON_7,
HLP_TXT_WELCOM_TO_ARULCO_BUTTON_8, },
// HELP_SCREEN_MAPSCREEN_NO_ONE_HIRED,
{ -1, -1, -1, -1, -1, -1, -1, -1, },
// HELP_SCREEN_MAPSCREEN_NOT_IN_ARULCO,
{ -1, -1, -1, -1, -1, -1, -1, -1, },
// HELP_SCREEN_MAPSCREEN_SECTOR_INVENTORY,
{ -1, -1, -1, -1, -1, -1, -1, -1, },
// HELP_SCREEN_TACTICAL,
{ HLP_TXT_TACTICAL_BUTTON_1,
HLP_TXT_TACTICAL_BUTTON_2,
HLP_TXT_TACTICAL_BUTTON_3,
HLP_TXT_TACTICAL_BUTTON_4,
HLP_TXT_TACTICAL_BUTTON_5,
HLP_TXT_TACTICAL_BUTTON_6,
-1, -1, },
// HELP_SCREEN_OPTIONS,
{ -1, -1, -1, -1, -1, -1, -1, -1, },
// HELP_SCREEN_LOAD_GAME,
{ -1, -1, -1, -1, -1, -1, -1, -1, },
};
BOOLEAN gfHelpScreenEntry = TRUE;
BOOLEAN gfHelpScreenExit = FALSE;
UINT32 guiHelpScreenBackGround;
UINT32 guiHelpScreenTextBufferSurface;
BOOLEAN gfScrollBoxIsScrolling = FALSE;
BOOLEAN gfHaveRenderedFirstFrameToSaveBuffer=FALSE;
// must use this cause you have ur cursor over a button when entering the help screen, the button will burn though.
//It does this cause that region loses it focus so it draws the button again.
UINT8 gubRenderHelpScreenTwiceInaRow=0;
//mmm
// region to mask the background
MOUSE_REGION gHelpScreenFullScreenMask;
//void SelectHelpTextFullScreenMaskCallBack(MOUSE_REGION * pRegion, INT32 iReason );
// region to mask the background
MOUSE_REGION gHelpScreenScrollArea;
void SelectHelpScrollAreaMovementCallBack( MOUSE_REGION * pRegion, INT32 iReason );
void SelectHelpScrollAreaCallBack( MOUSE_REGION * pRegion, INT32 iReason );
// region to mask the background
MOUSE_REGION gHelpScreenScrollAreaArrows;
void SelectHelpScrollAreaArrowsCallBack( MOUSE_REGION * pRegion, INT32 iReason );
//checkbox to toggle show help again toggle
UINT32 gHelpScreenDontShowHelpAgainToggle;
void BtnHelpScreenDontShowHelpAgainCallback(GUI_BUTTON *btn,INT32 reason);
//MOUSE_REGION HelpScreenDontShowHelpAgainToggleTextRegion;
//void HelpScreenDontShowHelpAgainToggleTextRegionCallBack(MOUSE_REGION * pRegion, INT32 iReason );
INT32 giHelpScreenButtonsImage[ HELP_SCREEN_NUM_BTNS ];
UINT32 guiHelpScreenBtns[ HELP_SCREEN_NUM_BTNS ];
void BtnHelpScreenBtnsCallback(GUI_BUTTON *btn,INT32 reason);
INT32 giExitBtnImage;
UINT32 guiHelpScreenExitBtn;
void BtnHelpScreenExitCallback(GUI_BUTTON *btn,INT32 reason);
INT32 giHelpScreenScrollArrows[2];
UINT32 guiHelpScreenScrollArrowImage[2];
void BtnHelpScreenScrollArrowsCallback(GUI_BUTTON *btn,INT32 reason);
//ggg
BOOLEAN EnterHelpScreen();
void HandleHelpScreen();
void RenderHelpScreen();
void ExitHelpScreen();
void GetHelpScreenUserInput();
void HelpScreenSpecialExitCode();
void SetSizeAndPropertiesOfHelpScreen();
BOOLEAN DrawHelpScreenBackGround();
void PrepareToExitHelpScreen();
void SpecialHandlerCode();
UINT16 RenderSpecificHelpScreen();
UINT16 RenderLaptopHelpScreen();
UINT16 RenderTacticalHelpScreen();
UINT16 RenderMapScreenHelpScreen();
UINT16 RenderMapScreenNoOneHiredYetHelpScreen();
UINT16 RenderMapScreenNotYetInArulcoHelpScreen();
UINT16 RenderMapScreenSectorInventoryHelpScreen();
void GetHelpScreenTextPositions( UINT16 *pusPosX, UINT16 *pusPosY, UINT16 *pusWidth );
void DisplayCurrentScreenTitleAndFooter();
void GetHelpScreenText( UINT32 uiRecordToGet, STR16 pText );
UINT16 GetAndDisplayHelpScreenText( UINT32 uiRecord, UINT16 usPosX, UINT16 usPosY, UINT16 usWidth );
void CreateHelpScreenButtons();
void RefreshAllHelpScreenButtons();
void RenderTextBufferToScreen();
void RenderCurrentHelpScreenTextToBuffer();
void DestroyHelpScreenTextBuffer();
BOOLEAN CreateHelpScreenTextBuffer();
void ChangeHelpScreenSubPage();
void ClearHelpScreenTextBuffer();
void ChangeTopLineInTextBufferByAmount( INT32 iAmouontToMove );
void DisplayHelpScreenTextBufferScrollBox();
void CalculateHeightAndPositionForHelpScreenScrollBox( INT32 *piHeightOfScrollBox, INT32 *iTopOfScrollBox );
void HelpScreenMouseMoveScrollBox( INT32 usMousePosY );
void CreateScrollAreaButtons();
void DeleteScrollArrowButtons();
void ChangeToHelpScreenSubPage( INT8 bNewPage );
BOOLEAN AreWeClickingOnScrollBar( INT32 usMousePosY );
//ppp
void InitHelpScreenSystem()
{
//set some values
memset( &gHelpScreen, 0, sizeof( gHelpScreen ) );
//set it up so we can enter the screen
gfHelpScreenEntry = TRUE;
gfHelpScreenExit = FALSE;
gHelpScreen.bCurrentHelpScreenActiveSubPage = -1;
gHelpScreen.fHaveAlreadyBeenInHelpScreenSinceEnteringCurrenScreen = FALSE;
}
BOOLEAN ShouldTheHelpScreenComeUp( UINT8 ubScreenID, BOOLEAN fForceHelpScreenToComeUp )
{
//if the screen is being forsced to come up ( user pressed 'h' )
if( fForceHelpScreenToComeUp )
{
//Set thefact that the user broughtthe help screen up
gHelpScreen.fForceHelpScreenToComeUp = TRUE;
goto HELP_SCREEN_SHOULD_COME_UP;
}
//if we are already in the help system, return true
if( gHelpScreen.uiFlags & HELP_SCREEN_ACTIVE )
{
return( TRUE );
}
//has the player been in the screen before
if( ( gHelpScreen.usHasPlayerSeenHelpScreenInCurrentScreen >> ubScreenID ) & 0x01 )
{
goto HELP_SCREEN_WAIT_1_FRAME;
}
//if we have already been in the screen, and the user DIDNT press 'h', leave
if( gHelpScreen.fHaveAlreadyBeenInHelpScreenSinceEnteringCurrenScreen )
{
return( FALSE );
}
//should the screen come up, based on the users choice for it automatically coming up
// if( !( gHelpScreen.fHideHelpInAllScreens ) )
{
// goto HELP_SCREEN_WAIT_1_FRAME;
}
//the help screen shouldnt come up
return( FALSE );
HELP_SCREEN_WAIT_1_FRAME:
// we have to wait 1 frame while the screen renders
if( gHelpScreen.bDelayEnteringHelpScreenBy1FrameCount < 2 )
{
gHelpScreen.bDelayEnteringHelpScreenBy1FrameCount += 1;
UnmarkButtonsDirty( );
return( FALSE );
}
HELP_SCREEN_SHOULD_COME_UP:
//Record which screen it is
//if its mapscreen
if( ubScreenID == HELP_SCREEN_MAPSCREEN )
{
//determine which screen it is ( is any mercs hired, did game just start )
gHelpScreen.bCurrentHelpScreen = HelpScreenDetermineWhichMapScreenHelpToShow();
}
else
{
gHelpScreen.bCurrentHelpScreen = ubScreenID;
}
//mark it that the help screnn is enabled
gHelpScreen.uiFlags |= HELP_SCREEN_ACTIVE;
// reset
gHelpScreen.bDelayEnteringHelpScreenBy1FrameCount = 0;
return( TRUE );
}
void HelpScreenHandler()
{
//if we are just entering the help screen
if( gfHelpScreenEntry )
{
//setup the help screen
EnterHelpScreen();
gfHelpScreenEntry = FALSE;
gfHelpScreenExit = FALSE;
}
RestoreBackgroundRects();
//get the mouse and keyboard inputs
GetHelpScreenUserInput();
//handle the help screen
HandleHelpScreen();
//if the help screen is dirty, re-render it
if( gHelpScreen.ubHelpScreenDirty != HLP_SCRN_DRTY_LVL_NOT_DIRTY )
{
//temp
// gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_REFRESH_ALL;
RenderHelpScreen();
gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_NOT_DIRTY;
}
// render buttons marked dirty
// MarkButtonsDirty( );
RenderButtons( );
SaveBackgroundRects( );
RenderButtonsFastHelp();
ExecuteBaseDirtyRectQueue();
EndFrameBufferRender();
//if we are leaving the help screen
if( gfHelpScreenExit )
{
gfHelpScreenExit = FALSE;
gfHelpScreenEntry = TRUE;
//exit mouse regions etc..
ExitHelpScreen();
//reset the helpscreen id
gHelpScreen.bCurrentHelpScreen = -1;
}
}
BOOLEAN EnterHelpScreen()
{
VOBJECT_DESC VObjectDesc;
UINT16 usPosX, usPosY;//, usWidth, usHeight;
// INT32 iStartLoc;
// CHAR16 zText[1024];
//Clear out all the save background rects
EmptyBackgroundRects( );
UnmarkButtonsDirty( );
// remeber if the game was paused or not ( so when we exit we know what to do )
gHelpScreen.fWasTheGamePausedPriorToEnteringHelpScreen = gfGamePaused;
//pause the game
PauseGame( );
//Determine the help screen size, based off the help screen
SetSizeAndPropertiesOfHelpScreen();
//Create a mouse region 'mask' the entrire screen
MSYS_DefineRegion( &gHelpScreenFullScreenMask, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, MSYS_PRIORITY_HIGHEST,
gHelpScreen.usCursor, MSYS_NO_CALLBACK, MSYS_NO_CALLBACK );
MSYS_AddRegion( &gHelpScreenFullScreenMask );
//Create the exit button
if( gHelpScreen.bNumberOfButtons != 0 )
usPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_EXIT_BTN_OFFSET_X + HELP_SCREEN_BUTTON_BORDER_WIDTH;
else
usPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_EXIT_BTN_OFFSET_X;
usPosY = gHelpScreen.usScreenLocY + HELP_SCREEN_EXIT_BTN_LOC_Y;
//Create the exit buttons
giExitBtnImage = LoadButtonImage("INTERFACE\\HelpScreen.sti", -1,0,4,2,6 );
guiHelpScreenExitBtn = CreateIconAndTextButton( giExitBtnImage, L"", HELP_SCREEN_BTN_FONT,
HELP_SCREEN_BTN_FONT_ON_COLOR, DEFAULT_SHADOW,
HELP_SCREEN_BTN_FONT_OFF_COLOR, DEFAULT_SHADOW,
TEXT_CJUSTIFIED,
usPosX, usPosY, BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
DEFAULT_MOVE_CALLBACK, BtnHelpScreenExitCallback );
SetButtonFastHelpText( guiHelpScreenExitBtn, gzHelpScreenText[HLP_SCRN_TXT__EXIT_SCREEN] );
SetButtonCursor( guiHelpScreenExitBtn, gHelpScreen.usCursor);
//Create the buttons needed for the screen
CreateHelpScreenButtons();
//if there are buttons
if( gHelpScreen.bNumberOfButtons != 0 )
usPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_X + HELP_SCREEN_BUTTON_BORDER_WIDTH;
else
usPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_X;
usPosY = gHelpScreen.usScreenLocY + gHelpScreen.usScreenHeight - HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_Y;
if( !gHelpScreen.fForceHelpScreenToComeUp)
{
gHelpScreenDontShowHelpAgainToggle = CreateCheckBoxButton( usPosX, (UINT16)(usPosY-3),
"INTERFACE\\OptionsCheckBoxes.sti", MSYS_PRIORITY_HIGHEST,
BtnHelpScreenDontShowHelpAgainCallback );
SetButtonCursor( gHelpScreenDontShowHelpAgainToggle, gHelpScreen.usCursor );
// Set the state of the chec box
if( gGameSettings.fHideHelpInAllScreens )
ButtonList[ gHelpScreenDontShowHelpAgainToggle ]->uiFlags |= BUTTON_CLICKED_ON;
else
ButtonList[ gHelpScreenDontShowHelpAgainToggle ]->uiFlags &= ~BUTTON_CLICKED_ON;
}
/*
///creatre a region for the text that says ' [ x ] click to continue seeing ....'
iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_CONSTANT_FOOTER;
LoadEncryptedDataFromFile(HELPSCREEN_FILE, zText, iStartLoc, HELPSCREEN_RECORD_SIZE );
usWidth = StringPixLength( zText, HELP_SCREEN_TEXT_BODY_FONT );
usHeight = GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT );
/*
MSYS_DefineRegion( &HelpScreenDontShowHelpAgainToggleTextRegion, usPosX, usPosY, (UINT16)(usPosX+usWidth), (UINT16)(usPosY+usHeight), MSYS_PRIORITY_HIGHEST-1,
gHelpScreen.usCursor, MSYS_NO_CALLBACK, HelpScreenDontShowHelpAgainToggleTextRegionCallBack );
MSYS_AddRegion( &HelpScreenDontShowHelpAgainToggleTextRegion );
*/
// load the help screen background graphic and add it
VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
FilenameForBPP("INTERFACE\\HelpScreen.sti", VObjectDesc.ImageFile);
CHECKF(AddVideoObject(&VObjectDesc, &guiHelpScreenBackGround));
//create the text buffer
CreateHelpScreenTextBuffer();
//make sure we redraw everything
gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_REFRESH_ALL;
//mark it that we have been in since we enter the current screen
gHelpScreen.fHaveAlreadyBeenInHelpScreenSinceEnteringCurrenScreen = TRUE;
//set the fact that we have been to the screen
gHelpScreen.usHasPlayerSeenHelpScreenInCurrentScreen &= ~( 1 << gHelpScreen.bCurrentHelpScreen );
//always start at the top
gHelpScreen.iLineAtTopOfTextBuffer = 0;
//set it so there was no previous click
gHelpScreen.iLastMouseClickY = -1;
//Create the scroll box, and scroll arrow regions/buttons
CreateScrollAreaButtons();
//render the active page to the text buffer
ChangeHelpScreenSubPage();
//reset scroll box flag
gfScrollBoxIsScrolling = FALSE;
//reset first frame buffer
gfHaveRenderedFirstFrameToSaveBuffer = FALSE;
gubRenderHelpScreenTwiceInaRow = 0;
return( TRUE );
}
void HandleHelpScreen()
{
//if any of the possible screens need to have a some code done every loop.. its done in here
SpecialHandlerCode();
if( gfScrollBoxIsScrolling )
{
if( gfLeftButtonState )
{
HelpScreenMouseMoveScrollBox( gusMouseYPos );
}
else
{
gfScrollBoxIsScrolling = FALSE;
gHelpScreen.iLastMouseClickY = -1;
}
}
if( gubRenderHelpScreenTwiceInaRow < 3 )
{
//test
// gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_REFRESH_ALL;
gubRenderHelpScreenTwiceInaRow++;
UnmarkButtonsDirty( );
}
// refresh all of help screens buttons
RefreshAllHelpScreenButtons();
}
void RenderHelpScreen()
{
//rrr
if( gfHaveRenderedFirstFrameToSaveBuffer )
{
//Restore the background before blitting the text back on
RestoreExternBackgroundRect( gHelpScreen.usScreenLocX, gHelpScreen.usScreenLocY, gHelpScreen.usScreenWidth, gHelpScreen.usScreenHeight );
}
if( gHelpScreen.ubHelpScreenDirty == HLP_SCRN_DRTY_LVL_REFRESH_ALL )
{
//Display the helpscreen background
DrawHelpScreenBackGround();
//Display the current screens title, and footer info
DisplayCurrentScreenTitleAndFooter();
}
if( !gfHaveRenderedFirstFrameToSaveBuffer )
{
gfHaveRenderedFirstFrameToSaveBuffer = TRUE;
//blit everything to the save buffer ( cause the save buffer can bleed through )
BlitBufferToBuffer(guiRENDERBUFFER, guiSAVEBUFFER, gHelpScreen.usScreenLocX, gHelpScreen.usScreenLocY, (UINT16)(gHelpScreen.usScreenWidth), (UINT16)(gHelpScreen.usScreenHeight) );
UnmarkButtonsDirty( );
}
//render the text buffer to the screen
if( gHelpScreen.ubHelpScreenDirty >= HLP_SCRN_DRTY_LVL_REFRESH_TEXT )
{
RenderTextBufferToScreen();
}
}
void ExitHelpScreen()
{
INT32 i;
if( !gHelpScreen.fForceHelpScreenToComeUp )
{
//Get the current value of the checkbox
if( ButtonList[ gHelpScreenDontShowHelpAgainToggle ]->uiFlags & BUTTON_CLICKED_ON )
{
gGameSettings.fHideHelpInAllScreens = TRUE;
gHelpScreen.usHasPlayerSeenHelpScreenInCurrentScreen = 0;
}
else
{
gGameSettings.fHideHelpInAllScreens = FALSE;
}
//remove the mouse region for the '[ ] dont show help...'
RemoveButton( gHelpScreenDontShowHelpAgainToggle );
}
//mark it that the help screen is not active
gHelpScreen.uiFlags &= ~HELP_SCREEN_ACTIVE;
//remove the mouse region that blankets
MSYS_RemoveRegion( &gHelpScreenFullScreenMask );
//checkbox to toggle show help again toggle
// MSYS_RemoveRegion( &HelpScreenDontShowHelpAgainToggleTextRegion );
//remove the hepl graphic
DeleteVideoObjectFromIndex( guiHelpScreenBackGround );
//remove the exit button
RemoveButton( guiHelpScreenExitBtn );
//if there are any buttons, remove them
if( gHelpScreen.bNumberOfButtons != 0 )
{
for( i=0; i< gHelpScreen.bNumberOfButtons; i++ )
{
UnloadButtonImage( giHelpScreenButtonsImage[i] );
RemoveButton( guiHelpScreenBtns[i] );
}
}
//destroy the text buffer for the help screen
DestroyHelpScreenTextBuffer();
//Handles the dirtying of any special screen we are about to reenter
HelpScreenSpecialExitCode();
//if the game was NOT paused
if( gHelpScreen.fWasTheGamePausedPriorToEnteringHelpScreen == FALSE )
{
//un pause the game
UnPauseGame( );
}
//Delete the scroll box, and scroll arrow regions/buttons
DeleteScrollArrowButtons();
//reset
gHelpScreen.fForceHelpScreenToComeUp = FALSE;
SaveGameSettings();
SaveFeatureFlags();
}
BOOLEAN DrawHelpScreenBackGround()
{
HVOBJECT hPixHandle;
UINT16 usPosX;
//Get and display the background image
GetVideoObject(&hPixHandle, guiHelpScreenBackGround );
usPosX = gHelpScreen.usScreenLocX;
//if there are buttons, blit the button border
if( gHelpScreen.bNumberOfButtons != 0 )
{
BltVideoObject(FRAME_BUFFER, hPixHandle, HLP_SCRN_BUTTON_BORDER, usPosX, gHelpScreen.usScreenLocY, VO_BLT_SRCTRANSPARENCY,NULL);
usPosX += HELP_SCREEN_BUTTON_BORDER_WIDTH;
}
BltVideoObject(FRAME_BUFFER, hPixHandle, HLP_SCRN_DEFAULT_TYPE, usPosX, gHelpScreen.usScreenLocY, VO_BLT_SRCTRANSPARENCY,NULL);
InvalidateRegion( gHelpScreen.usScreenLocX, gHelpScreen.usScreenLocY, gHelpScreen.usScreenLocX+gHelpScreen.usScreenWidth, gHelpScreen.usScreenLocY + gHelpScreen.usScreenHeight );
return( TRUE );
}
void SetSizeAndPropertiesOfHelpScreen()
{
//new screen:
gHelpScreen.bNumberOfButtons = 0;
//
//these are the default settings, so if the screen uses different then defualt, set them in the switch
//
{
gHelpScreen.usScreenWidth = HELP_SCREEN_DEFUALT_LOC_WIDTH;
gHelpScreen.usScreenHeight = HELP_SCREEN_DEFUALT_LOC_HEIGHT;
gHelpScreen.usScreenLocX = ( SCREEN_WIDTH - gHelpScreen.usScreenWidth ) / 2;
gHelpScreen.usScreenLocY = ( SCREEN_HEIGHT - gHelpScreen.usScreenHeight ) / 2;
gHelpScreen.bCurrentHelpScreenActiveSubPage = 0;
gHelpScreen.usCursor = CURSOR_NORMAL;
}
switch( gHelpScreen.bCurrentHelpScreen )
{
case HELP_SCREEN_LAPTOP:
gHelpScreen.bNumberOfButtons = HLP_SCRN_LPTP_NUM_PAGES;
gHelpScreen.usCursor = CURSOR_LAPTOP_SCREEN;
//center the screen inside the laptop screen
gHelpScreen.usScreenLocX = LAPTOP_SCREEN_UL_X + ( 502 - gHelpScreen.usScreenWidth ) / 2;
gHelpScreen.usScreenLocY = LAPTOP_SCREEN_UL_Y + ( LAPTOP_SCREEN_HEIGHT - gHelpScreen.usScreenHeight ) / 2;
break;
case HELP_SCREEN_MAPSCREEN:
gHelpScreen.bNumberOfButtons = HLP_SCRN_NUM_MPSCRN_BTNS;
//calc the center position based on the current panel thats being displayed
gHelpScreen.usScreenLocY = ( gsVIEWPORT_END_Y - gHelpScreen.usScreenHeight ) / 2;
break;
case HELP_SCREEN_TACTICAL:
gHelpScreen.bNumberOfButtons = HLP_SCRN_NUM_TACTICAL_PAGES;
//calc the center position based on the current panel thats being displayed
gHelpScreen.usScreenLocY = ( gsVIEWPORT_END_Y - gHelpScreen.usScreenHeight ) / 2;
break;
case HELP_SCREEN_MAPSCREEN_NO_ONE_HIRED:
case HELP_SCREEN_MAPSCREEN_NOT_IN_ARULCO:
case HELP_SCREEN_MAPSCREEN_SECTOR_INVENTORY:
gHelpScreen.usScreenWidth = HELP_SCREEN_SMALL_LOC_WIDTH;
gHelpScreen.usScreenHeight = HELP_SCREEN_SMALL_LOC_HEIGHT;
//calc screen position since we just set the width and height
gHelpScreen.usScreenLocX = ( SCREEN_WIDTH - gHelpScreen.usScreenWidth ) / 2;
//calc the center position based on the current panel thats being displayed
gHelpScreen.usScreenLocY = ( gsVIEWPORT_END_Y - gHelpScreen.usScreenHeight ) / 2;
gHelpScreen.bNumberOfButtons = 0;
gHelpScreen.bCurrentHelpScreenActiveSubPage = 0;
break;
case HELP_SCREEN_OPTIONS:
case HELP_SCREEN_LOAD_GAME:
break;
default:
#ifdef JA2BETAVERSION
AssertMsg( 0, "Error in help screen. DF 0" );
#else
break;
#endif
}
//if there are buttons
if( gHelpScreen.bNumberOfButtons != 0 )
gHelpScreen.usLeftMarginPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_TEXT_LEFT_MARGIN_WITH_BTN;
else
gHelpScreen.usLeftMarginPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_TEXT_LEFT_MARGIN;
}
void CreateHelpScreenButtons()
{
UINT16 usPosX, usPosY;
CHAR16 sText[1024];
INT32 i;
//if there are buttons to create
if( gHelpScreen.bNumberOfButtons != 0 )
{
usPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_BTN_OFFSET_X;
usPosY = HELP_SCREEN_BTN_OFFSET_Y + gHelpScreen.usScreenLocY;
//loop through all the buttons, and create them
for( i=0; i< gHelpScreen.bNumberOfButtons; i++ )
{
//get the text for the button
GetHelpScreenText( gHelpScreenBtnTextRecordNum[ gHelpScreen.bCurrentHelpScreen ].iButtonTextNum[i], sText );
/*
guiHelpScreenBtns[i] = CreateTextButton( sText, HELP_SCREEN_BTN_FONT, HELP_SCREEN_BTN_FONT_COLOR, HELP_SCREEN_BTN_FONT_BACK_COLOR,
BUTTON_USE_DEFAULT, usPosX, usPosY, HELP_SCREEN_BTN_WIDTH, HELP_SCREEN_BTN_HEIGHT,
BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST, BUTTON_NO_CALLBACK, BtnHelpScreenBtnsCallback );
*/
giHelpScreenButtonsImage[i] = UseLoadedButtonImage( giExitBtnImage, -1,1,5,3,7 );
guiHelpScreenBtns[i] = CreateIconAndTextButton( giHelpScreenButtonsImage[i], sText, HELP_SCREEN_BTN_FONT,
HELP_SCREEN_BTN_FONT_ON_COLOR, DEFAULT_SHADOW,
HELP_SCREEN_BTN_FONT_OFF_COLOR, DEFAULT_SHADOW,
TEXT_CJUSTIFIED,
usPosX, usPosY, BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
DEFAULT_MOVE_CALLBACK, BtnHelpScreenBtnsCallback);
SetButtonCursor( guiHelpScreenBtns[i], gHelpScreen.usCursor);
MSYS_SetBtnUserData( guiHelpScreenBtns[i], 0, i);
// SpecifyButtonTextOffsets( guiHelpScreenBtns[i], 19, 9, TRUE );
usPosY += HELP_SCREEN_BTN_HEIGHT + HELP_SCREEN_GAP_BN_BTNS;
}
ButtonList[ guiHelpScreenBtns[0] ]->uiFlags |= BUTTON_CLICKED_ON;
}
}
void GetHelpScreenUserInput()
{
InputAtom Event;
POINT MousePos;
GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
while( DequeueEvent( &Event ) )
{
// HOOK INTO MOUSE HOOKS
switch( Event.usEvent)
{
case LEFT_BUTTON_DOWN:
MouseSystemHook(LEFT_BUTTON_DOWN, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
break;
case LEFT_BUTTON_UP:
MouseSystemHook(LEFT_BUTTON_UP, (INT16)MousePos.x, (INT16)MousePos.y ,_LeftButtonDown, _RightButtonDown);
break;
case RIGHT_BUTTON_DOWN:
MouseSystemHook(RIGHT_BUTTON_DOWN, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
break;
case RIGHT_BUTTON_UP:
MouseSystemHook(RIGHT_BUTTON_UP, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
break;
case RIGHT_BUTTON_REPEAT: