forked from Warzone2100/warzone2100
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintelmap.cpp
1517 lines (1296 loc) · 38 KB
/
intelmap.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
/*
This file is part of Warzone 2100.
Copyright (C) 1999-2004 Eidos Interactive
Copyright (C) 2005-2012 Warzone 2100 Project
Warzone 2100 is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Warzone 2100 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Warzone 2100; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* IntelMap.c (Intelligence Map)
*
* Functions for the display of the Intelligence Map
*
*/
#include <string.h>
#include "lib/framework/frame.h"
#include "lib/framework/strres.h"
#include "lib/widget/widget.h"
#include "lib/widget/button.h"
/* Includes direct access to render library */
#include "lib/ivis_opengl/pieblitfunc.h"
#include "lib/ivis_opengl/piedef.h"
#include "lib/ivis_opengl/piestate.h"
#include "lib/ivis_opengl/piepalette.h"
#include "lib/ivis_opengl/screen.h"
#include "lib/ivis_opengl/piemode.h"
#include "display3d.h"
#include "lib/framework/cursors.h"
#include "map.h"
#include "intdisplay.h"
#include "objects.h"
#include "display.h"
#include "design.h"
#include "message.h"
#include "hci.h"
#include "intelmap.h"
#include "mapdisplay.h"
#include "lib/sound/audio.h"
#include "console.h"
#include "research.h"
#include "lib/gamelib/gtime.h"
#include "loop.h"
#include "lib/script/script.h"
#include "scripttabs.h"
#include "warzoneconfig.h"
#include "seqdisp.h"
#include "mission.h"
#include "multiplay.h"
#include "lib/sound/cdaudio.h"
#include "lib/sequence/sequence.h"
#include "lib/sound/track.h"
#include "scriptextern.h"
#include "multimenu.h"
//#define NO_VIDEO
/* Intelligence Map screen IDs */
#define IDINTMAP_MSGFORM 6001 //The intelligence map tabbed form
#define IDINTMAP_CLOSE 6004 //The close button icon for the 3D view
#define IDINTMAP_PAUSELABEL 6005 //The paused message
#define IDINITMAP_TITLEVIEW 6006 //The Title view part of MSGVIEW
#define IDINITMAP_PIEVIEW 6007 //The PIE view part of MSGVIEW
#define IDINTMAP_FLICVIEW 6008 //The Flic View part of MSGVIEW
#define IDINTMAP_TEXTVIEW 6009 //The Text area of MSGVIEW
#define IDINTMAP_TITLELABEL 6010 //The title text
#define IDINTMAP_SEQTEXT 6011 //Sequence subtitle text
#define IDINTMAP_MSGSTART 6100 //The first button on the intelligence form
#define IDINTMAP_MSGEND 6139 //The last button on the intelligence form (40 MAX)
#define IDINTMAP_SEQTEXTSTART 6200 //Sequence subtitle text tabs
/* Intelligence Map screen positions */
#define INTMAP_X OBJ_BACKX
#define INTMAP_Y OBJ_BACKY
#define INTMAP_WIDTH OBJ_BACKWIDTH
#define INTMAP_HEIGHT OBJ_BACKHEIGHT
#define INTMAP_LABELX RET_X
#define INTMAP_LABELY 10
#define INTMAP_LABELWIDTH 60
#define INTMAP_LABELHEIGHT 20
/*tabbed message form screen positions */
#define INTMAP_MSGX OBJ_TABX
#define INTMAP_MSGY OBJ_TABY
#define INTMAP_MSGWIDTH OBJ_WIDTH
#define INTMAP_MSGHEIGHT OBJ_HEIGHT
//define the 3D View sizes and positions that are required - relative to INTMAP_FORM
#define INTMAP_RESEARCHX (100 + D_W)
#define INTMAP_RESEARCHY (30 + D_H)
#define INTMAP_RESEARCHWIDTH 440
#define INTMAP_RESEARCHHEIGHT 288
/*dimensions for Title view section relative to IDINTMAP_MSGVIEW*/
/*dimensions for PIE view section relative to IDINTMAP_MSGVIEW*/
#define INTMAP_TITLEX 0
#define INTMAP_TITLEY 0
#define INTMAP_TITLEWIDTH INTMAP_RESEARCHWIDTH
#define INTMAP_TITLEHEIGHT 18
#define INTMAP_PIEX 3
#define INTMAP_PIEY 24
/*dimensions for FLIC view section relative to IDINTMAP_MSGVIEW*/
#define INTMAP_FLICX 245
#define INTMAP_FLICY 24
#define INTMAP_FLICWIDTH 192
#define INTMAP_FLICHEIGHT 170
/*dimensions for TEXT view section relative to IDINTMAP_MSGVIEW*/
#define INTMAP_TEXTX 0
#define INTMAP_TEXTY 200
#define INTMAP_TEXTWIDTH INTMAP_RESEARCHWIDTH
#define INTMAP_TEXTHEIGHT 88
#define TEXT_XINDENT 5
#define TEXT_YINDENT 5
/*dimensions for SEQTEXT view relative to IDINTMAP_MSGVIEW*/
#define INTMAP_SEQTEXTX 0
#define INTMAP_SEQTEXTY 0
#define INTMAP_SEQTEXTWIDTH INTMAP_RESEARCHWIDTH
#define INTMAP_SEQTEXTHEIGHT INTMAP_RESEARCHHEIGHT
/*dimensions for SEQTEXT tab view relative to IDINTMAP_SEQTEXT*/
#define INTMAP_SEQTEXTTABX 0
#define INTMAP_SEQTEXTTABY 0
#define INTMAP_SEQTEXTTABWIDTH INTMAP_SEQTEXTWIDTH
#define INTMAP_SEQTEXTTABHEIGHT INTMAP_SEQTEXTHEIGHT
//position for text on full screen video
#define VIDEO_TEXT_TOP_X 20
#define VIDEO_TEXT_TOP_Y 20
#define VIDEO_TEXT_BOTTOM_X 20
#define VIDEO_TEXT_BOTTOM_Y 444
#define TEXT_START_FRAME 0
#define TEXT_END_FRAME 9999
/* the widget screen */
extern W_SCREEN *psWScreen;
static UDWORD messageID;
static bool immediateMessage = false;
//flags whether to open the Intel Screen with a message
static bool playCurrent;
/* functions declarations ****************/
static bool intAddMessageForm(bool playCurrent);
/*Displays the buttons used on the intelligence map */
static void intDisplayMessageButton(WIDGET *psWidget, UDWORD xOffset,
UDWORD yOffset, PIELIGHT *pColours);
/*deal with the actual button press - proxMsg is set to true if a proximity
button has been pressed*/
static void intIntelButtonPressed(bool proxMsg, UDWORD id);
static void intDisplayPIEView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
#ifndef NO_VIDEO
static void intDisplayFLICView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
#endif
static void intDisplayTEXTView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
static void addVideoText(SEQ_DISPLAY *psSeqDisplay, UDWORD sequence);
static void intDisplaySeqTextView(WIDGET *psWidget,
UDWORD xOffset, UDWORD yOffset,
PIELIGHT *pColours);
static bool intDisplaySeqTextViewPage(VIEW_REPLAY *psViewReplay,
UDWORD x0, UDWORD y0,
UDWORD width, UDWORD height,
bool render,
size_t *major, size_t *minor);
/*********************** VARIABLES ****************************/
// The current message being displayed
MESSAGE *psCurrentMsg = NULL;
#define PAUSE_DISPLAY_CONDITION (!bMultiPlayer)
#define PAUSEMESSAGE_YOFFSET (0)
/* Add the Intelligence Map widgets to the widget screen */
bool intAddIntelMap(void)
{
bool Animate = true;
//check playCurrent with psCurrentMsg
if (psCurrentMsg == NULL)
{
playCurrent = false;
}
else
{
playCurrent = true;
}
// Is the form already up?
if(widgGetFromID(psWScreen,IDINTMAP_FORM) != NULL)
{
intRemoveIntelMapNoAnim();
Animate = false;
}
else
{
audio_StopAll();
}
cdAudio_Pause();
//add message to indicate game is paused - single player mode
if(PAUSE_DISPLAY_CONDITION)
{
if(widgGetFromID(psWScreen,IDINTMAP_PAUSELABEL) == NULL)
{
W_LABINIT sLabInit;
sLabInit.id = IDINTMAP_PAUSELABEL;
sLabInit.formID = 0;
sLabInit.x = INTMAP_LABELX;
sLabInit.y = INTMAP_LABELY+PAUSEMESSAGE_YOFFSET;
sLabInit.width = INTMAP_LABELWIDTH;
sLabInit.height = INTMAP_LABELHEIGHT;
sLabInit.pText = _("PAUSED");
if (!widgAddLabel(psWScreen, &sLabInit))
{
return false;
}
}
}
//set pause states before putting the interface up
setIntelligencePauseState();
W_FORMINIT sFormInit;
// Add the main Intelligence Map form
sFormInit.formID = 0;
sFormInit.id = IDINTMAP_FORM;
sFormInit.style = WFORM_PLAIN;
sFormInit.x = (SWORD)INTMAP_X;
sFormInit.y = (SWORD)INTMAP_Y;
sFormInit.width = INTMAP_WIDTH;
sFormInit.height = INTMAP_HEIGHT;
// If the window was closed then do open animation.
if(Animate)
{
sFormInit.pDisplay = intOpenPlainForm;
sFormInit.disableChildren = true;
}
else
{
// otherwise just recreate it.
sFormInit.pDisplay = intDisplayPlainForm;
}
//sFormInit.pDisplay = intDisplayPlainForm;
if (!widgAddForm(psWScreen, &sFormInit))
{
return false;
}
if (!intAddMessageForm(playCurrent))
{
return false;
}
if (bMultiPlayer && !MultiMenuUp && !playCurrent)
{
intAddMultiMenu();
}
return true;
}
/* Add the Message sub form */
static bool intAddMessageForm(bool playCurrent)
{
UDWORD numButtons, i;
MESSAGE *psMessage;
RESEARCH *psResearch;
SDWORD BufferID;
/* Add the Message form */
W_FORMINIT sFormInit;
sFormInit.formID = IDINTMAP_FORM;
sFormInit.id = IDINTMAP_MSGFORM;
sFormInit.style = WFORM_TABBED;
sFormInit.width = INTMAP_MSGWIDTH;
sFormInit.height = INTMAP_MSGHEIGHT;
sFormInit.x = INTMAP_MSGX;
sFormInit.y = INTMAP_MSGY;
sFormInit.majorPos = WFORM_TABTOP;
sFormInit.minorPos = WFORM_TABNONE;
sFormInit.majorSize = OBJ_TABWIDTH;
sFormInit.majorOffset = OBJ_TABOFFSET;
sFormInit.tabVertOffset = (OBJ_TABHEIGHT/2);
sFormInit.tabMajorThickness = OBJ_TABHEIGHT;
numButtons = 0;
/*work out the number of buttons */
for(psMessage = apsMessages[selectedPlayer]; psMessage; psMessage =
psMessage->psNext)
{
//ignore proximity messages here
if (psMessage->type != MSG_PROXIMITY)
{
numButtons++;
}
// stop adding the buttons once max has been reached
if (numButtons > (IDINTMAP_MSGEND - IDINTMAP_MSGSTART))
{
break;
}
}
//set the number of tabs required
sFormInit.numMajor = numForms((OBJ_BUTWIDTH + OBJ_GAP) * numButtons,
(OBJ_WIDTH - OBJ_GAP)*2);
sFormInit.pUserData = &StandardTab;
sFormInit.pTabDisplay = intDisplayTab;
if (sFormInit.numMajor > MAX_TAB_STD_SHOWN)
{ // we do NOT use smallTab icons here, so be safe and only display max # of
// standard sized tab icons.
sFormInit.numMajor = MAX_TAB_STD_SHOWN;
}
//set minor tabs to 1
for (i=0; i< sFormInit.numMajor; i++)
{
sFormInit.aNumMinors[i] = 1;
}
if (!widgAddForm(psWScreen, &sFormInit))
{
return false;
}
/* Add the message buttons */
W_FORMINIT sBFormInit;
sBFormInit.formID = IDINTMAP_MSGFORM;
sBFormInit.id = IDINTMAP_MSGSTART;
sBFormInit.majorID = 0;
sBFormInit.minorID = 0;
sBFormInit.style = WFORM_CLICKABLE;
sBFormInit.x = OBJ_STARTX;
sBFormInit.y = OBJ_STATSTARTY;
sBFormInit.width = OBJ_BUTWIDTH;
sBFormInit.height = OBJ_BUTHEIGHT;
ClearObjectBuffers();
//add each button
messageID = 0;
for(psMessage = apsMessages[selectedPlayer]; psMessage; psMessage =
psMessage->psNext)
{
/*if (psMessage->type == MSG_TUTORIAL)
{
//tutorial cases should never happen
ASSERT( false, "Tutorial message in Intelligence screen!" );
continue;
}*/
if (psMessage->type == MSG_PROXIMITY)
{
//ignore proximity messages here
continue;
}
/* Set the tip and add the button */
switch (psMessage->type)
{
case MSG_RESEARCH:
psResearch = getResearchForMsg((VIEWDATA *)psMessage->pViewData);
if (psResearch)
{
sBFormInit.pTip = getStatName(psResearch);;
}
else
{
sBFormInit.pTip = _("Research Update");
}
break;
case MSG_CAMPAIGN:
sBFormInit.pTip = _("Project Goals");
break;
case MSG_MISSION:
sBFormInit.pTip = _("Current Objective");
break;
default:
break;
}
BufferID = GetObjectBuffer();
ASSERT( BufferID >= 0,"Unable to acquire object buffer." );
RENDERBUTTON_INUSE(&ObjectBuffers[BufferID]);
ObjectBuffers[BufferID].Data = (void*)psMessage;
sBFormInit.pUserData = &ObjectBuffers[BufferID];
sBFormInit.pDisplay = intDisplayMessageButton;
if (!widgAddForm(psWScreen, &sBFormInit))
{
return false;
}
/* if the current message matches psSelected lock the button */
if (psMessage == psCurrentMsg)
{
messageID = sBFormInit.id;
widgSetButtonState(psWScreen, messageID, WBUT_LOCK);
widgSetTabs(psWScreen, IDINTMAP_MSGFORM, sBFormInit.majorID, 0);
}
/* Update the init struct for the next button */
sBFormInit.id += 1;
// stop adding the buttons when at max
if (sBFormInit.id > IDINTMAP_MSGEND)
{
break;
}
ASSERT( sBFormInit.id < (IDINTMAP_MSGEND+1),"Too many message buttons" );
sBFormInit.x += OBJ_BUTWIDTH + OBJ_GAP;
if (sBFormInit.x + OBJ_BUTWIDTH + OBJ_GAP > INTMAP_MSGWIDTH)
{
sBFormInit.x = OBJ_STARTX;
sBFormInit.y += OBJ_BUTHEIGHT + OBJ_GAP;
}
if (sBFormInit.y + OBJ_BUTHEIGHT + OBJ_GAP > INTMAP_MSGHEIGHT)
{
sBFormInit.y = OBJ_STATSTARTY;
sBFormInit.majorID += 1;
}
}
//check to play current message instantly
if (playCurrent)
{
//is it a proximity message?
if (psCurrentMsg->type == MSG_PROXIMITY)
{
//intIntelButtonPressed(true, messageID);
}
else
{
intIntelButtonPressed(false, messageID);
}
}
return true;
}
/*Add the 3D world view for the particular message (only research nmessages now) */
bool intAddMessageView(MESSAGE * psMessage)
{
bool Animate = true;
RESEARCH *psResearch;
// Is the form already up?
if(widgGetFromID(psWScreen,IDINTMAP_MSGVIEW) != NULL)
{
intRemoveMessageView(false);
Animate = false;
}
if (MultiMenuUp)
{
intCloseMultiMenuNoAnim();
}
/* Add the base form */
W_FORMINIT sFormInit;
sFormInit.formID = 0;
sFormInit.id = IDINTMAP_MSGVIEW;
sFormInit.style = WFORM_PLAIN;
//size and position depends on the type of message - ONLY RESEARCH now
sFormInit.width = INTMAP_RESEARCHWIDTH;
sFormInit.height = INTMAP_RESEARCHHEIGHT;
sFormInit.x = (SWORD)INTMAP_RESEARCHX;
sFormInit.y = (SWORD)INTMAP_RESEARCHY;
// If the window was closed then do open animation.
if(Animate)
{
sFormInit.pDisplay = intOpenPlainForm;
sFormInit.disableChildren = true;
}
else
{
// otherwise just display it.
sFormInit.pDisplay = intDisplayPlainForm;
}
if (!widgAddForm(psWScreen, &sFormInit))
{
return false;
}
/* Add the close box */
W_BUTINIT sButInit;
sButInit.formID = IDINTMAP_MSGVIEW;
sButInit.id = IDINTMAP_CLOSE;
sButInit.x = (SWORD)(sFormInit.width - OPT_GAP - CLOSE_SIZE);
sButInit.y = OPT_GAP;
sButInit.width = CLOSE_SIZE;
sButInit.height = CLOSE_SIZE;
sButInit.pTip = _("Close");
sButInit.pDisplay = intDisplayImageHilight;
sButInit.UserData = PACKDWORD_TRI(0,IMAGE_CLOSEHILIGHT , IMAGE_CLOSE);
if (!widgAddButton(psWScreen, &sButInit))
{
return false;
}
if (psMessage->type != MSG_RESEARCH &&
((VIEWDATA*)psMessage->pViewData)->type == VIEW_RPL)
{
VIEW_REPLAY *psViewReplay;
size_t i, cur_seq, cur_seqpage;
psViewReplay = (VIEW_REPLAY *)((VIEWDATA *)psMessage->pViewData)->pData;
/* Add a big tabbed text box for the subtitle text */
sFormInit = W_FORMINIT();
sFormInit.id = IDINTMAP_SEQTEXT;
sFormInit.formID = IDINTMAP_MSGVIEW;
sFormInit.style = WFORM_TABBED;
sFormInit.x = INTMAP_SEQTEXTX;
sFormInit.y = INTMAP_SEQTEXTY;
sFormInit.width = INTMAP_SEQTEXTWIDTH;
sFormInit.height = INTMAP_SEQTEXTHEIGHT;
sFormInit.majorPos = WFORM_TABBOTTOM;
sFormInit.minorPos = WFORM_TABNONE;
sFormInit.majorSize = OBJ_TABWIDTH;
sFormInit.majorOffset = OBJ_TABOFFSET;
sFormInit.tabVertOffset = (OBJ_TABHEIGHT/2);
sFormInit.tabMajorThickness = OBJ_TABHEIGHT;
sFormInit.numMajor = 0;
cur_seq = cur_seqpage = 0;
do {
sFormInit.aNumMinors[sFormInit.numMajor] = 1;
sFormInit.numMajor++;
}
while (!intDisplaySeqTextViewPage(psViewReplay, 0, 0,
sFormInit.width, sFormInit.height,
false, &cur_seq, &cur_seqpage));
sFormInit.pUserData = &StandardTab;
sFormInit.pTabDisplay = intDisplayTab;
if (!widgAddForm(psWScreen, &sFormInit))
{
return false;
}
W_FORMINIT sTabForm;
sTabForm.formID = IDINTMAP_SEQTEXT;
sTabForm.id = IDINTMAP_SEQTEXTSTART;
sTabForm.majorID = 0;
sTabForm.minorID = 0;
sTabForm.style = WFORM_PLAIN;
sTabForm.x = INTMAP_SEQTEXTTABX;
sTabForm.y = INTMAP_SEQTEXTTABY;
sTabForm.width = INTMAP_SEQTEXTTABWIDTH;
sTabForm.height = INTMAP_SEQTEXTTABHEIGHT;
sTabForm.pDisplay = intDisplaySeqTextView;
sTabForm.pUserData = psViewReplay;
for (i = 0; i < sFormInit.numMajor; i++)
{
sTabForm.id = IDINTMAP_SEQTEXTSTART + i;
sTabForm.majorID = i;
if (!widgAddForm(psWScreen, &sTabForm))
{
return false;
}
}
return true;
}
/*add the Label for the title box*/
W_LABINIT sLabInit;
sLabInit.id = IDINTMAP_TITLELABEL;
sLabInit.formID = IDINTMAP_MSGVIEW;
sLabInit.x = INTMAP_TITLEX + TEXT_XINDENT;
sLabInit.y = INTMAP_TITLEY + TEXT_YINDENT;
sLabInit.width = INTMAP_TITLEWIDTH;
sLabInit.height = INTMAP_TITLEHEIGHT;
//print research name in title bar
ASSERT( psMessage->type != MSG_PROXIMITY,
"intAddMessageView:Invalid message type for research" );
psResearch = getResearchForMsg((VIEWDATA *)psMessage->pViewData);
ASSERT( psResearch!=NULL,"Research not found" );
//sLabInit.pText=psResearch->pName;
sLabInit.pText = getStatName(psResearch);
sLabInit.FontID = font_regular;
if (!widgAddLabel(psWScreen, &sLabInit))
{
return false;
}
/*Add the PIE box*/
sFormInit = W_FORMINIT();
sFormInit.formID = IDINTMAP_MSGVIEW;
sFormInit.id = IDINITMAP_PIEVIEW;
sFormInit.style = WFORM_PLAIN;
sFormInit.x = INTMAP_PIEX;
sFormInit.y = INTMAP_PIEY;
sFormInit.width = INTMAP_PIEWIDTH;
sFormInit.height = INTMAP_PIEHEIGHT;
sFormInit.pDisplay = intDisplayPIEView;
sFormInit.pUserData = psMessage;
if (!widgAddForm(psWScreen, &sFormInit))
{
return false;
}
#ifndef NO_VIDEO
/*Add the Flic box */
sFormInit = W_FORMINIT();
sFormInit.formID = IDINTMAP_MSGVIEW;
sFormInit.id = IDINTMAP_FLICVIEW;
sFormInit.style = WFORM_PLAIN;
sFormInit.x = INTMAP_FLICX;
sFormInit.y = INTMAP_FLICY;
sFormInit.width = INTMAP_FLICWIDTH;
sFormInit.height = INTMAP_FLICHEIGHT;
sFormInit.pDisplay = intDisplayFLICView;
sFormInit.pUserData = psMessage;
if (!widgAddForm(psWScreen, &sFormInit))
{
return false;
}
#endif
/*Add the text box*/
sFormInit = W_FORMINIT();
sFormInit.formID = IDINTMAP_MSGVIEW;
sFormInit.id = IDINTMAP_TEXTVIEW;
sFormInit.style = WFORM_PLAIN;
sFormInit.x = INTMAP_TEXTX;
sFormInit.y = INTMAP_TEXTY;
sFormInit.width = INTMAP_TEXTWIDTH;
sFormInit.height = INTMAP_TEXTHEIGHT;
sFormInit.pDisplay = intDisplayTEXTView;
sFormInit.pUserData = psMessage;
if (!widgAddForm(psWScreen, &sFormInit))
{
return false;
}
return true;
}
/* Process return codes from the Intelligence Map */
void intProcessIntelMap(UDWORD id)
{
if (id >= IDINTMAP_MSGSTART && id <= IDINTMAP_MSGEND)
{
intIntelButtonPressed(false, id);
}
else if (id == IDINTMAP_CLOSE)
{
//if close button pressed on 3D View then close the view only
psCurrentMsg = NULL;
intRemoveMessageView(true);
if (bMultiPlayer && !MultiMenuUp)
{
intAddMultiMenu();
}
}
else if (MultiMenuUp)
{
intProcessMultiMenu(id);
}
}
/**
* Draws the text for the intelligence display window.
*/
static bool intDisplaySeqTextViewPage(VIEW_REPLAY *psViewReplay,
UDWORD x0, UDWORD y0,
UDWORD width, UDWORD height,
bool render,
size_t *cur_seq, size_t *cur_seqpage)
{
UDWORD i, cur_y;
UDWORD sequence;
if (!psViewReplay)
{
return true; /* nothing to do */
}
iV_SetFont(font_regular);
iV_SetTextColour(WZCOL_TEXT_BRIGHT);
cur_y = y0 + iV_GetTextLineSize()/2 + 2*TEXT_YINDENT;
/* add each message */
for (sequence = *cur_seq, i = *cur_seqpage; sequence < psViewReplay->numSeq; sequence++)
{
SEQ_DISPLAY *psSeqDisplay = &psViewReplay->pSeqList[sequence];
for (; i < psSeqDisplay->textMsg.size(); i++)
{
if (render)
{
cur_y = iV_DrawFormattedText(psSeqDisplay->textMsg[i].toUtf8().constData(),
x0 + TEXT_XINDENT,
cur_y, width, false);
}
else
{
cur_y += iV_GetTextLineSize();
}
if (cur_y > y0 + height)
{
/* run out of room - need to make new tab */
*cur_seq = sequence;
*cur_seqpage = i;
return false;
}
}
i = 0;
}
return true; /* done */
}
/**
* Draw the text window for the intelligence display
*/
static void intDisplaySeqTextView(WIDGET *psWidget,
UDWORD xOffset, UDWORD yOffset,
WZ_DECL_UNUSED PIELIGHT *pColours)
{
W_TABFORM *Form = (W_TABFORM*)psWidget;
VIEW_REPLAY *psViewReplay = (VIEW_REPLAY*)Form->pUserData;
size_t cur_seq, cur_seqpage;
UDWORD x0, y0, page;
x0 = xOffset + Form->x;
y0 = yOffset + Form->y;
RenderWindowFrame(FRAME_NORMAL, x0, y0, Form->width, Form->height);
/* work out where we're up to in the text */
cur_seq = cur_seqpage = 0;
if(Form->style & WFORM_TABBED)
{
// Gerard 2007-04-07: dead code?
ASSERT(!"the form is tabbed", "intDisplaySeqTextView: the form is tabbed");
for (page = 0; page < Form->majorT; page++)
{
intDisplaySeqTextViewPage(psViewReplay, x0, y0,
Form->width, Form->height,
false, &cur_seq, &cur_seqpage);
}
}
intDisplaySeqTextViewPage(psViewReplay, x0, y0,
Form->width-40, Form->height,
true, &cur_seq, &cur_seqpage);
}
// Add all the Video Sequences for a message
static void StartMessageSequences(MESSAGE *psMessage, bool Start)
{
bool bLoop = false;
debug(LOG_GUI, "StartMessageSequences: start message sequence");
//should never have a proximity message here
if (psMessage->type == MSG_PROXIMITY)
{
return;
}
ASSERT( psMessage->pViewData != NULL,
"StartMessageSequences: invalid ViewData pointer" );
if (((VIEWDATA *)psMessage->pViewData)->type == VIEW_RPL)
{
VIEW_REPLAY *psViewReplay;
UDWORD Sequence;
// Surely we don't need to set up psCurrentMsg when we pass the message into this routine ... tim
psViewReplay = (VIEW_REPLAY *)((VIEWDATA *)psMessage->pViewData)->pData;
seq_ClearSeqList();
//add any sequences to the list to be played when the first one is finished
for (Sequence = 0; Sequence < psViewReplay->numSeq; Sequence++)
{
if (psViewReplay->pSeqList[Sequence].flag == 1)
{
bLoop = true;
}
else
{
bLoop = false;
}
seq_AddSeqToList(psViewReplay->pSeqList[Sequence].sequenceName, psViewReplay->pSeqList[Sequence].pAudio, NULL, bLoop);
debug(LOG_GUI, "StartMessageSequences: sequence=%d", Sequence);
addVideoText(&psViewReplay->pSeqList[Sequence],Sequence);
}
//play first full screen video
if (Start==true)
{
seq_StartNextFullScreenVideo();
}
}
else if (((VIEWDATA *)psMessage->pViewData)->type == VIEW_RES)
{
VIEW_RESEARCH *psViewReplay;
//UDWORD Sequence;
psViewReplay = (VIEW_RESEARCH *)((VIEWDATA *)psCurrentMsg->pViewData)->pData;
seq_ClearSeqList();
seq_AddSeqToList(psViewReplay->sequenceName, psViewReplay->pAudio, NULL, false);
//play first full screen video
if (Start==true)
{
seq_StartNextFullScreenVideo();
}
}
}
/*
deal with the actual button press - proxMsg is set to true if a proximity
button has been pressed
*/
void intIntelButtonPressed(bool proxMsg, UDWORD id)
{
MESSAGE *psMessage;
UDWORD currID;//, i;
RESEARCH *psResearch;
ASSERT( proxMsg != true,
"intIntelButtonPressed: Shouldn't be able to get a proximity message!" );
if(id == 0)
{
intRemoveIntelMap();
return;
}
/* message button has been pressed - clear the old button and messageView*/
if (messageID != 0)
{
widgSetButtonState(psWScreen, messageID, 0);
intRemoveMessageView(false);
psCurrentMsg = NULL;
}
/* Lock the new button */
// This means we can't click on the same movie button twice.
widgSetButtonState(psWScreen, id, WBUT_CLICKLOCK);
messageID = id;
//Find the message for the new button */
currID = IDINTMAP_MSGSTART;
for(psMessage = apsMessages[selectedPlayer]; psMessage; psMessage =
psMessage->psNext)
{
if (psMessage->type != MSG_PROXIMITY)
{
if (currID == id)
{
break;
}
currID++;
}
}
//deal with the message if one
if (psMessage)
{
//set the current message
psCurrentMsg = psMessage;
//set the read flag
psCurrentMsg->read = true;
debug(LOG_GUI, "intIntelButtonPressed: Dealing with a new message type=%d",
psMessage->type);
//should never have a proximity message
if (psMessage->type == MSG_PROXIMITY)
{
return;
}
// If its a video sequence then play it anyway
if (((VIEWDATA *)psMessage->pViewData)->type == VIEW_RPL)
{
if (psMessage->pViewData)
{
intAddMessageView(psMessage);
}
StartMessageSequences(psMessage,true);
}
else if (((VIEWDATA *)psMessage->pViewData)->type == VIEW_RES)
{
psResearch = getResearchForMsg((VIEWDATA *)psMessage->pViewData);
if (psResearch != NULL)
{
static const float maxVolume = 1.f;
static AUDIO_STREAM *playing = NULL;
// only play the sample once, otherwise, they tend to overlap each other
if (sound_isStreamPlaying(playing))
{
sound_StopStream(playing);
}
switch(psResearch->iconID)
{
case IMAGE_RES_DROIDTECH:
playing = audio_PlayStream("sequenceaudio/res_droid.ogg", maxVolume, NULL, NULL);
break;
case IMAGE_RES_WEAPONTECH:
playing = audio_PlayStream("sequenceaudio/res_weapons.ogg", maxVolume, NULL, NULL);
break;
case IMAGE_RES_COMPUTERTECH:
playing = audio_PlayStream("sequenceaudio/res_com.ogg", maxVolume, NULL, NULL);
break;
case IMAGE_RES_POWERTECH:
playing = audio_PlayStream("sequenceaudio/res_pow.ogg", maxVolume, NULL, NULL);
break;
case IMAGE_RES_SYSTEMTECH:
playing = audio_PlayStream("sequenceaudio/res_systech.ogg", maxVolume, NULL, NULL);
break;
case IMAGE_RES_STRUCTURETECH:
playing = audio_PlayStream("sequenceaudio/res_strutech.ogg", maxVolume, NULL, NULL);
break;
case IMAGE_RES_CYBORGTECH:
playing = audio_PlayStream("sequenceaudio/res_droid.ogg", maxVolume, NULL, NULL);
break;
case IMAGE_RES_DEFENCE:
playing = audio_PlayStream("sequenceaudio/res_strutech.ogg", maxVolume, NULL, NULL);
break;
}
}
//and finally for the dumb?
if (psMessage->pViewData)
{
intAddMessageView(psMessage);
}
}
}