forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 179
Expand file tree
/
Copy pathInGameUI.cpp
More file actions
6370 lines (5410 loc) · 215 KB
/
InGameUI.cpp
File metadata and controls
6370 lines (5410 loc) · 215 KB
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
/*
** Command & Conquer Generals Zero Hour(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program 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 3 of the License, or
** (at your option) any later version.
**
** This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// InGameUI.cpp ///////////////////////////////////////////////////////////////////////////////////
// Implementation of in-game user interface singleton
// Author: Michael S. Booth, March 2001
///////////////////////////////////////////////////////////////////////////////////////////////////
#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine
#define DEFINE_SHADOW_NAMES
#include "Common/ActionManager.h"
#include "Common/FramePacer.h"
#include "Common/GameAudio.h"
#include "Common/GameType.h"
#include "Common/GameUtility.h"
#include "Common/MessageStream.h"
#include "Common/NameKeyGenerator.h"
#include "Common/PerfTimer.h"
#include "Common/Player.h"
#include "Common/PlayerList.h"
#include "Common/Radar.h"
#include "Common/Team.h"
#include "Common/ThingFactory.h"
#include "Common/ThingTemplate.h"
#include "Common/BuildAssistant.h"
#include "Common/Recorder.h"
#include "Common/SpecialPower.h"
#include "GameClient/Anim2D.h"
#include "GameClient/ControlBar.h"
#include "GameClient/DisplayStringManager.h"
#include "GameClient/Diplomacy.h"
#include "GameClient/Eva.h"
#include "GameClient/GameText.h"
#include "GameClient/GameWindowManager.h"
#include "GameClient/Drawable.h"
#include "GameClient/GadgetPushButton.h"
#include "GameClient/GameClient.h"
#include "GameClient/GameWindowGlobal.h"
#include "GameClient/GameWindowID.h"
#include "GameClient/GUICallbacks.h"
#include "GameClient/InGameUI.h"
#include "GameClient/VideoPlayer.h"
#include "GameClient/Mouse.h"
#include "GameClient/GadgetStaticText.h"
#include "GameClient/View.h"
#include "GameClient/TerrainVisual.h"
#include "GameClient/Display.h"
#include "GameClient/WindowLayout.h"
#include "GameClient/LookAtXlat.h"
#include "GameClient/SelectionXlat.h"
#include "GameClient/Shadow.h"
#include "GameClient/GlobalLanguage.h"
#include "GameLogic/AIGuard.h"
#include "GameLogic/Weapon.h"
#include "GameLogic/Object.h"
#include "GameLogic/GameLogic.h"
#include "GameLogic/PartitionManager.h"
#include "GameLogic/ScriptEngine.h"
#include "GameLogic/Module/ContainModule.h"
#include "GameLogic/Module/ProductionUpdate.h"
#include "GameLogic/Module/SpecialPowerModule.h"
#include "GameLogic/Module/StealthUpdate.h"
#include "GameLogic/Module/SupplyWarehouseDockUpdate.h"
#include "GameLogic/Module/MobMemberSlavedUpdate.h"//ML
#include "GameNetwork/GameInfo.h"
#include "GameNetwork/NetworkInterface.h"
#include "Common/UnitTimings.h" //Contains the DO_UNIT_TIMINGS define jba.
// ------------------------------------------------------------------------------------------------
static const RGBColor IllegalBuildColor = { 1.0, 0.0, 0.0 };
// ------------------------------------------------------------------------------------------------
static UnicodeString formatMoneyValue(UnsignedInt amount)
{
UnicodeString result;
if (amount >= 100000)
{
result.format(L"%uk", amount / 1000);
}
else
{
result.format(L"%u", amount);
}
return result;
}
static UnicodeString formatIncomeValue(UnsignedInt cashPerMin)
{
UnicodeString result;
if (cashPerMin >= 10000)
{
result.format(L"%uk", cashPerMin / 1000);
}
else if (cashPerMin >= 1000)
{
result.format(L"%u", (cashPerMin / 100) * 100);
}
else
{
result.format(L"%u", (cashPerMin / 10) * 10);
}
return result;
}
//-------------------------------------------------------------------------------------------------
/// The InGameUI singleton instance.
InGameUI *TheInGameUI = nullptr;
GameWindow *m_replayWindow = nullptr;
// ------------------------------------------------------------------------------------------------
struct KindOfSelectionData
{
KindOfMaskType m_mustbeSet;
KindOfMaskType m_mustbeClear;
DrawableList newlySelectedDrawables;
};
// ------------------------------------------------------------------------------------------------
static Bool kindOfUnitSelection( Drawable *test, void *userData )
{
KindOfSelectionData *data = (KindOfSelectionData *) userData;
if( test )
{
const Object *object = test->getObject();
// Only things with objects can be selected, and the code below isn't
// safe unless you've verified that there is a valid object.
if (!object)
return FALSE;
Bool isKindOfMatch = object->isKindOfMulti(data->m_mustbeSet, data->m_mustbeClear);
// only select objects if not already selected
if( object && isKindOfMatch
&& object->isLocallyControlled()
&& !object->isContained()
&& !object->getDrawable()->isSelected()
&& !object->isEffectivelyDead()
&& object->isMassSelectable()
&& !object->isOffMap()
)
{
// enforce optional unit cap
if (TheInGameUI->getMaxSelectCount() > 0 && TheInGameUI->getSelectCount() >= TheInGameUI->getMaxSelectCount())
{
if ( !TheInGameUI->getDisplayedMaxWarning() )
{
TheInGameUI->setDisplayedMaxWarning( TRUE );
UnicodeString msg;
msg.format(TheGameText->fetch("GUI:MaxSelectionSize").str(), TheInGameUI->getMaxSelectCount());
TheInGameUI->message(msg);
}
}
else
{
TheInGameUI->selectDrawable( test );
TheInGameUI->setDisplayedMaxWarning( FALSE );
data->newlySelectedDrawables.push_back(test);
return TRUE;
}
}
}
return FALSE;
}
// ------------------------------------------------------------------------------------------------
struct MatchingUnitSelectionData
{
const ThingTemplate *templateToSelect;
DrawableList newlySelectedDrawables;
Bool isCarBomb;
};
// ------------------------------------------------------------------------------------------------
static Bool similarUnitSelection( Drawable *test, void *userData )
{
MatchingUnitSelectionData *data = (MatchingUnitSelectionData *) userData;
const ThingTemplate *selectedType = data->templateToSelect;
if( test )
{
const Object *object = test->getObject();
// Only things with objects can be selected, and the code below isn't
// safe unless you've verified that there is a valid object.
if (!object)
return FALSE;
Bool isEquivalent = object->getTemplate()->isEquivalentTo( selectedType );
if( data->isCarBomb && !isEquivalent && object->testStatus( OBJECT_STATUS_IS_CARBOMB ) )
{
isEquivalent = TRUE;
}
// only select objects if not already selected
if( object && isEquivalent
&& object->isLocallyControlled()
&& !object->isContained()
&& !( object->getDrawable()->isSelected() )
&& object->isMassSelectable() // And only if they can be multiply selected. (otherwise the drawable will be, but the object will not be)
&& !object->isOffMap()
)
{
// enforce optional unit cap
if (TheInGameUI->getMaxSelectCount() > 0 && TheInGameUI->getSelectCount() >= TheInGameUI->getMaxSelectCount())
{
if ( !TheInGameUI->getDisplayedMaxWarning() )
{
TheInGameUI->setDisplayedMaxWarning( TRUE );
UnicodeString msg;
msg.format(TheGameText->fetch("GUI:MaxSelectionSize").str(), TheInGameUI->getMaxSelectCount());
TheInGameUI->message(msg);
}
}
else
{
TheInGameUI->selectDrawable( test );
TheInGameUI->setDisplayedMaxWarning( FALSE );
data->newlySelectedDrawables.push_back(test);
return TRUE;
}
}
}
return FALSE;
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
void showReplayControls()
{
if (m_replayWindow)
{
Bool show = TheGameLogic->isInReplayGame();
m_replayWindow->winHide(!show);
}
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
void hideReplayControls()
{
if (m_replayWindow)
{
m_replayWindow->winHide(TRUE);
}
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
void toggleReplayControls()
{
if (m_replayWindow)
{
Bool show = TheGameLogic->isInReplayGame() && m_replayWindow->winIsHidden();
m_replayWindow->winHide(!show);
}
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
SuperweaponInfo::SuperweaponInfo(
ObjectID id,
UnsignedInt timestamp,
Bool hiddenByScript,
Bool hiddenByScience,
Bool ready,
Bool evaReadyPlayed,
const AsciiString& superweaponNormalFont,
Int superweaponNormalPointSize,
Bool superweaponNormalBold,
Color c,
const SpecialPowerTemplate* spt
) :
m_id(id),
m_timestamp(timestamp),
m_hiddenByScript(hiddenByScript),
m_hiddenByScience(hiddenByScience),
m_ready(ready),
m_evaReadyPlayed( evaReadyPlayed ),
m_forceUpdateText(false),
m_nameDisplayString(nullptr),
m_timeDisplayString(nullptr),
m_color(c),
m_powerTemplate(spt)
{
m_nameDisplayString = TheDisplayStringManager->newDisplayString();
m_nameDisplayString->reset();
m_nameDisplayString->setText( UnicodeString::TheEmptyString );
m_timeDisplayString = TheDisplayStringManager->newDisplayString();
m_timeDisplayString->reset();
m_timeDisplayString->setText( UnicodeString::TheEmptyString );
setFont( superweaponNormalFont, superweaponNormalPointSize, superweaponNormalBold );
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
SuperweaponInfo::~SuperweaponInfo()
{
if (m_nameDisplayString)
TheDisplayStringManager->freeDisplayString( m_nameDisplayString );
m_nameDisplayString = nullptr;
if (m_timeDisplayString)
TheDisplayStringManager->freeDisplayString( m_timeDisplayString );
m_timeDisplayString = nullptr;
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
void SuperweaponInfo::setFont(const AsciiString& superweaponNormalFont, Int superweaponNormalPointSize, Bool superweaponNormalBold)
{
m_nameDisplayString->setFont( TheFontLibrary->getFont( superweaponNormalFont,
TheGlobalLanguageData->adjustFontSize(superweaponNormalPointSize), superweaponNormalBold ) );
m_timeDisplayString->setFont( TheFontLibrary->getFont( superweaponNormalFont,
TheGlobalLanguageData->adjustFontSize(superweaponNormalPointSize), superweaponNormalBold ) );
}
// ------------------------------------------------------------------------------------------------
void SuperweaponInfo::setText(const UnicodeString& name, const UnicodeString& time)
{
m_nameDisplayString->setText(name);
m_timeDisplayString->setText(time);
}
// ------------------------------------------------------------------------------------------------
void SuperweaponInfo::drawName(Int x, Int y, Color color, Color dropColor)
{
if (color == 0)
color = m_color;
m_nameDisplayString->draw(x - m_nameDisplayString->getWidth(), y, color, dropColor);
}
// ------------------------------------------------------------------------------------------------
void SuperweaponInfo::drawTime(Int x, Int y, Color color, Color dropColor)
{
if (color == 0)
color = m_color;
m_timeDisplayString->draw(x, y, color, dropColor);
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
Real SuperweaponInfo::getHeight() const
{
return m_nameDisplayString->getFont()->height;
}
// ------------------------------------------------------------------------------------------------
/** CRC */
// ------------------------------------------------------------------------------------------------
void InGameUI::crc( Xfer *xfer )
{
}
// ------------------------------------------------------------------------------------------------
/** Xfer method
* Version Info:
* 1: Initial version
* 2: Save NamedTimers, but not specifically their Info structs. We'll recreate them.
* 3: Added m_evaReadyPlayed boolean to transfer
*/
// ------------------------------------------------------------------------------------------------
void InGameUI::xfer( Xfer *xfer )
{
// version
const XferVersion currentVersion = 3;
XferVersion version = currentVersion;
xfer->xferVersion( &version, currentVersion );
if( version >= 2 )
{
// Saving the named timer infos and their friends so we get script timers back after we load
xfer->xferInt(&m_namedTimerLastFlashFrame);
xfer->xferBool(&m_namedTimerUsedFlashColor);
xfer->xferBool(&m_showNamedTimers);
// For the timers themselves, all I need to save is the things that are used in the call to addNamedTimer.
// It is okay to do this, because SuperweaponInfos pushes things on to a map; addNamedTimer is just a more
// organized way to push things on the namedTimer Map.
// addNamedTimer needs (const AsciiString& timerName, const UnicodeString& text, Bool isCountdown)
if (xfer->getXferMode() == XFER_SAVE)
{
Int timerCount = m_namedTimers.size();
xfer->xferInt( &timerCount );
for( NamedTimerMapIt timerIter = m_namedTimers.begin(); timerIter != m_namedTimers.end(); ++timerIter )
{
xfer->xferAsciiString( &(timerIter->second->m_timerName) );
xfer->xferUnicodeString( &(timerIter->second->timerText) );
xfer->xferBool( &(timerIter->second->isCountdown) );
}
}
else // iz a Load
{
Int timerCount;
xfer->xferInt( &timerCount );
for( Int timerIndex = 0; timerIndex < timerCount; ++timerIndex )
{
AsciiString timerName;
UnicodeString timerText;
Bool isCountdown;
xfer->xferAsciiString( &timerName );
xfer->xferUnicodeString( &timerText );
xfer->xferBool( &isCountdown );
addNamedTimer( timerName, timerText, isCountdown );
}
}
}
xfer->xferBool(&m_superweaponHiddenByScript);
//xfer->xferBool(&m_inputEnabled); // no, don't save this yet. somewhat problematic.
if (xfer->getXferMode() == XFER_SAVE)
{
for (Int playerIndex = 0; playerIndex < MAX_PLAYER_COUNT; ++playerIndex)
{
for (SuperweaponMap::iterator mapIt = m_superweapons[playerIndex].begin(); mapIt != m_superweapons[playerIndex].end(); ++mapIt)
{
AsciiString powerName = mapIt->first;
SuperweaponList& swList = mapIt->second;
for (SuperweaponList::iterator listIt = swList.begin(); listIt != swList.end(); ++listIt)
{
SuperweaponInfo* swInfo = *listIt;
// since this list tends to be somewhat sparse, we write stuff out pretty explicitly.
xfer->xferInt(&playerIndex);
AsciiString templateName = swInfo->getSpecialPowerTemplate()->getName();
xfer->xferAsciiString(&templateName);
xfer->xferAsciiString(&powerName);
xfer->xferObjectID(&swInfo->m_id);
xfer->xferUnsignedInt(&swInfo->m_timestamp);
xfer->xferBool(&swInfo->m_hiddenByScript);
xfer->xferBool(&swInfo->m_hiddenByScience);
xfer->xferBool(&swInfo->m_ready);
if ( currentVersion >= 3 )
{
xfer->xferBool( &swInfo->m_evaReadyPlayed );
}
}
}
}
Int noMorePlayers = -1; // our "done" sentinel
xfer->xferInt(&noMorePlayers);
}
else if (xfer->getXferMode() == XFER_LOAD)
{
for (;;)
{
Int playerIndex;
xfer->xferInt(&playerIndex);
if (playerIndex == -1)
{
break; // our "done" sentinel
}
else if (playerIndex < 0 || playerIndex >= MAX_PLAYER_COUNT)
{
DEBUG_CRASH(("SWInfo bad plyrindex"));
throw INI_INVALID_DATA;
}
AsciiString templateName;
xfer->xferAsciiString(&templateName);
const SpecialPowerTemplate* powerTemplate = TheSpecialPowerStore->findSpecialPowerTemplate(templateName);
if (powerTemplate == nullptr)
{
DEBUG_CRASH(("power %s not found",templateName.str()));
throw INI_INVALID_DATA;
}
AsciiString powerName;
ObjectID id;
UnsignedInt timestamp;
Bool hiddenByScript, hiddenByScience, ready, evaReadyPlayed;
xfer->xferAsciiString(&powerName);
xfer->xferObjectID(&id);
xfer->xferUnsignedInt(×tamp);
xfer->xferBool(&hiddenByScript);
xfer->xferBool(&hiddenByScience);
xfer->xferBool(&ready);
if ( currentVersion >= 3 )
{
xfer->xferBool( &evaReadyPlayed );
}
else
{
evaReadyPlayed = ready;
}
// srj sez: due to order-of-operation stuff, sometimes these will already exist,
// sometimes not. not sure why. so handle both cases.
SuperweaponInfo* swInfo = findSWInfo(playerIndex, powerName, id, powerTemplate);
if (swInfo == nullptr)
{
const Player* player = ThePlayerList->getNthPlayer(playerIndex);
swInfo = newInstance(SuperweaponInfo)(
id,
timestamp,
hiddenByScript,
hiddenByScience,
ready,
evaReadyPlayed,
m_superweaponNormalFont,
m_superweaponNormalPointSize,
m_superweaponNormalBold,
player->getPlayerColor(),
powerTemplate);
m_superweapons[playerIndex][powerName].push_back(swInfo);
}
else
{
// swInfo->m_id = id; // redundant, already matches
swInfo->m_timestamp = timestamp;
swInfo->m_hiddenByScript = hiddenByScript;
swInfo->m_hiddenByScience = hiddenByScience;
swInfo->m_ready = ready;
swInfo->m_evaReadyPlayed = evaReadyPlayed;
}
swInfo->m_forceUpdateText = true;
}
}
}
// ------------------------------------------------------------------------------------------------
/** Load post process */
// ------------------------------------------------------------------------------------------------
void InGameUI::loadPostProcess()
{
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
void InGameUI::setMouseCursor(Mouse::MouseCursor c)
{
if (!TheMouse)
return;
TheMouse->setCursor(c);
if (m_mouseMode == MOUSEMODE_GUI_COMMAND && c != Mouse::ARROW && c != Mouse::SCROLL)
m_mouseModeCursor = c;
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
SuperweaponInfo* InGameUI::findSWInfo(Int playerIndex, const AsciiString& powerName, ObjectID id, const SpecialPowerTemplate *powerTemplate)
{
SuperweaponMap::iterator mapIt = m_superweapons[playerIndex].find(powerName);
if (mapIt != m_superweapons[playerIndex].end())
{
for (SuperweaponList::iterator listIt = mapIt->second.begin(); listIt != mapIt->second.end(); ++listIt)
{
if ((*listIt)->m_id == id)
{
return *listIt;
}
}
}
return nullptr;
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
void InGameUI::addSuperweapon(Int playerIndex, const AsciiString& powerName, ObjectID id, const SpecialPowerTemplate *powerTemplate)
{
if (powerTemplate == nullptr)
return;
// srj sez: don't allow adding the same superweapon more than once. it can happen. not sure how. (srj)
SuperweaponInfo* swInfo = findSWInfo(playerIndex, powerName, id, powerTemplate);
if (swInfo != nullptr)
return;
const Player* player = ThePlayerList->getNthPlayer(playerIndex);
Bool hiddenByScience = (powerTemplate->getRequiredScience() != SCIENCE_INVALID) && (player->hasScience(powerTemplate->getRequiredScience()) == false);
#ifndef DO_UNIT_TIMINGS
DEBUG_LOG(("Adding superweapon UI timer"));
#endif
SuperweaponInfo *info = newInstance(SuperweaponInfo)(
id,
-1, // timestamp
FALSE, // hiddenByScript
hiddenByScience,//Aaayeeee! This is meaningless and just clogs up the works, sez srj, nuke or repair or SHIP WITH(tm), ASAP
// THe trouble is: There is no mechanism to clear this bit when the science is granted, thus,
// the timer never, ever, ever get drawn.... unless the owning object is post-science constructed.
FALSE, // ready
FALSE, // evaReadyPlayed
m_superweaponNormalFont,
m_superweaponNormalPointSize,
m_superweaponNormalBold,
player->getPlayerColor(),
powerTemplate);
m_superweapons[playerIndex][powerName].push_back(info);
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
Bool InGameUI::removeSuperweapon(Int playerIndex, const AsciiString& powerName, ObjectID id, const SpecialPowerTemplate *powerTemplate)
{
DEBUG_LOG(("Removing superweapon UI timer"));
SuperweaponMap::iterator mapIt = m_superweapons[playerIndex].find(powerName);
if (mapIt != m_superweapons[playerIndex].end())
{
SuperweaponList& swList = mapIt->second;
for (SuperweaponList::iterator listIt = swList.begin(); listIt != swList.end(); ++listIt)
{
if ((*listIt)->m_id == id)
{
SuperweaponInfo *info = *listIt;
swList.erase(listIt);
deleteInstance(info);
if (swList.empty())
{
m_superweapons[playerIndex].erase(mapIt);
}
return TRUE;
}
}
}
return FALSE;
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
void InGameUI::objectChangedTeam(const Object *obj, Int oldPlayerIndex, Int newPlayerIndex)
{
// if we already had it listed, remove and re-add it
if (obj && oldPlayerIndex >= 0 && newPlayerIndex >= 0)
{
ObjectID id = obj->getID();
AsciiString powerName;
for (BehaviorModule** m = obj->getBehaviorModules(); *m; ++m)
{
SpecialPowerModuleInterface* sp = (*m)->getSpecialPower();
if (!sp)
continue;
const SpecialPowerTemplate *powerTemplate = sp->getSpecialPowerTemplate();
powerName = powerTemplate->getName();
SuperweaponMap::iterator mapIt = m_superweapons[oldPlayerIndex].find(powerName);
Bool found = false;
if (mapIt != m_superweapons[oldPlayerIndex].end())
{
for (SuperweaponList::iterator listIt = mapIt->second.begin(); listIt != mapIt->second.end(); ++listIt)
{
if ((*listIt)->m_id == id)
{
removeSuperweapon(oldPlayerIndex, powerName, id, powerTemplate);
addSuperweapon(newPlayerIndex, powerName, id, powerTemplate);
found = true;
break;
}
}
}
if (!found)
{
if( TheGameLogic->getFrame() == 0 && !obj->getStatusBits().test( OBJECT_STATUS_UNDER_CONSTRUCTION ) &&
obj->isKindOf( KINDOF_COMMANDCENTER ) == FALSE )
addSuperweapon(newPlayerIndex, powerName, id, powerTemplate);
}
}
}
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
void InGameUI::hideObjectSuperweaponDisplayByScript(const Object *obj)
{
ObjectID objID = obj->getID();
for (Int playerIndex = 0; playerIndex < MAX_PLAYER_COUNT; ++playerIndex)
{
for (SuperweaponMap::iterator mapIt = m_superweapons[playerIndex].begin(); mapIt != m_superweapons[playerIndex].end(); ++mapIt)
{
for (SuperweaponList::iterator listIt = mapIt->second.begin(); listIt != mapIt->second.end(); ++listIt)
{
if ((*listIt)->m_id == objID)
{
(*listIt)->m_hiddenByScript = TRUE;
}
}
}
}
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
void InGameUI::showObjectSuperweaponDisplayByScript(const Object *obj)
{
ObjectID objID = obj->getID();
for (Int playerIndex = 0; playerIndex < MAX_PLAYER_COUNT; ++playerIndex)
{
for (SuperweaponMap::iterator mapIt = m_superweapons[playerIndex].begin(); mapIt != m_superweapons[playerIndex].end(); ++mapIt)
{
for (SuperweaponList::iterator listIt = mapIt->second.begin(); listIt != mapIt->second.end(); ++listIt)
{
if ((*listIt)->m_id == objID)
{
(*listIt)->m_hiddenByScript = FALSE;
}
}
}
}
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
void InGameUI::setSuperweaponDisplayEnabledByScript(Bool enable)
{
m_superweaponHiddenByScript = !enable;
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
Bool InGameUI::getSuperweaponDisplayEnabledByScript() const
{
return !m_superweaponHiddenByScript;
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
void InGameUI::addNamedTimer( const AsciiString& timerName, const UnicodeString& text, Bool isCountdown )
{
NamedTimerInfo *info = newInstance( NamedTimerInfo );
info->m_timerName = timerName;
info->color = m_namedTimerNormalColor;
info->timerText = text;
info->displayString = TheDisplayStringManager->newDisplayString();
info->displayString->reset();
info->displayString->setFont( TheFontLibrary->getFont( m_namedTimerNormalFont,
TheGlobalLanguageData->adjustFontSize(m_namedTimerNormalPointSize), m_namedTimerNormalBold ) );
info->displayString->setText( UnicodeString::TheEmptyString );
info->timestamp = -1;
info->isCountdown = isCountdown;
// GameFont *font = info->displayString->getFont();
removeNamedTimer(timerName);
m_namedTimers[timerName] = info;
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
void InGameUI::removeNamedTimer( const AsciiString& timerName )
{
NamedTimerMapIt mapIt = m_namedTimers.find(timerName);
if (mapIt != m_namedTimers.end())
{
TheDisplayStringManager->freeDisplayString( mapIt->second->displayString );
deleteInstance(mapIt->second);
m_namedTimers.erase(mapIt);
return;
}
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
void InGameUI::showNamedTimerDisplay( Bool show )
{
m_showNamedTimers = show;
}
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
const FieldParse InGameUI::s_fieldParseTable[] =
{
{ "MaxSelectionSize", INI::parseInt, nullptr, offsetof( InGameUI, m_maxSelectCount ) },
{ "MessageColor1", INI::parseColorInt, nullptr, offsetof( InGameUI, m_messageColor1 ) },
{ "MessageColor2", INI::parseColorInt, nullptr, offsetof( InGameUI, m_messageColor2 ) },
{ "MessagePosition", INI::parseICoord2D, nullptr, offsetof( InGameUI, m_messagePosition ) },
{ "MessageFont", INI::parseAsciiString, nullptr, offsetof( InGameUI, m_messageFont ) },
{ "MessagePointSize", INI::parseInt, nullptr, offsetof( InGameUI, m_messagePointSize ) },
{ "MessageBold", INI::parseBool, nullptr, offsetof( InGameUI, m_messageBold ) },
{ "MessageDelayMS", INI::parseInt, nullptr, offsetof( InGameUI, m_messageDelayMS ) },
{ "MilitaryCaptionColor", INI::parseRGBAColorInt, nullptr, offsetof( InGameUI, m_militaryCaptionColor ) },
{ "MilitaryCaptionPosition", INI::parseICoord2D, nullptr, offsetof( InGameUI, m_militaryCaptionPosition ) },
{ "MilitaryCaptionTitleFont", INI::parseAsciiString, nullptr, offsetof( InGameUI, m_militaryCaptionTitleFont ) },
{ "MilitaryCaptionTitlePointSize", INI::parseInt, nullptr, offsetof( InGameUI, m_militaryCaptionTitlePointSize ) },
{ "MilitaryCaptionTitleBold", INI::parseBool, nullptr, offsetof( InGameUI, m_militaryCaptionTitleBold ) },
{ "MilitaryCaptionFont", INI::parseAsciiString, nullptr, offsetof( InGameUI, m_militaryCaptionFont ) },
{ "MilitaryCaptionPointSize", INI::parseInt, nullptr, offsetof( InGameUI, m_militaryCaptionPointSize ) },
{ "MilitaryCaptionBold", INI::parseBool, nullptr, offsetof( InGameUI, m_militaryCaptionBold ) },
{ "MilitaryCaptionRandomizeTyping", INI::parseBool, nullptr, offsetof( InGameUI, m_militaryCaptionRandomizeTyping ) },
{ "MilitaryCaptionSpeed", INI::parseInt, nullptr, offsetof( InGameUI, m_militaryCaptionSpeed ) },
{ "MilitaryCaptionPosition", INI::parseICoord2D, nullptr, offsetof( InGameUI, m_militaryCaptionPosition ) },
{ "SuperweaponCountdownPosition", INI::parseCoord2D, nullptr, offsetof( InGameUI, m_superweaponPosition ) },
{ "SuperweaponCountdownFlashDuration", INI::parseDurationReal, nullptr, offsetof( InGameUI, m_superweaponFlashDuration ) },
{ "SuperweaponCountdownFlashColor", INI::parseColorInt, nullptr, offsetof( InGameUI, m_superweaponFlashColor ) },
{ "SuperweaponCountdownNormalFont", INI::parseAsciiString, nullptr, offsetof( InGameUI, m_superweaponNormalFont ) },
{ "SuperweaponCountdownNormalPointSize", INI::parseInt, nullptr, offsetof( InGameUI, m_superweaponNormalPointSize ) },
{ "SuperweaponCountdownNormalBold", INI::parseBool, nullptr, offsetof( InGameUI, m_superweaponNormalBold ) },
{ "SuperweaponCountdownReadyFont", INI::parseAsciiString, nullptr, offsetof( InGameUI, m_superweaponReadyFont ) },
{ "SuperweaponCountdownReadyPointSize", INI::parseInt, nullptr, offsetof( InGameUI, m_superweaponReadyPointSize ) },
{ "SuperweaponCountdownReadyBold", INI::parseBool, nullptr, offsetof( InGameUI, m_superweaponReadyBold ) },
{ "NamedTimerCountdownPosition", INI::parseCoord2D, nullptr, offsetof( InGameUI, m_namedTimerPosition ) },
{ "NamedTimerCountdownFlashDuration", INI::parseDurationReal, nullptr, offsetof( InGameUI, m_namedTimerFlashDuration ) },
{ "NamedTimerCountdownFlashColor", INI::parseColorInt, nullptr, offsetof( InGameUI, m_namedTimerFlashColor ) },
{ "NamedTimerCountdownNormalFont", INI::parseAsciiString, nullptr, offsetof( InGameUI, m_namedTimerNormalFont ) },
{ "NamedTimerCountdownNormalPointSize", INI::parseInt, nullptr, offsetof( InGameUI, m_namedTimerNormalPointSize ) },
{ "NamedTimerCountdownNormalBold", INI::parseBool, nullptr, offsetof( InGameUI, m_namedTimerNormalBold ) },
{ "NamedTimerCountdownNormalColor", INI::parseColorInt, nullptr, offsetof( InGameUI, m_namedTimerNormalColor ) },
{ "NamedTimerCountdownReadyFont", INI::parseAsciiString, nullptr, offsetof( InGameUI, m_namedTimerReadyFont ) },
{ "NamedTimerCountdownReadyPointSize", INI::parseInt, nullptr, offsetof( InGameUI, m_namedTimerReadyPointSize ) },
{ "NamedTimerCountdownReadyBold", INI::parseBool, nullptr, offsetof( InGameUI, m_namedTimerReadyBold ) },
{ "NamedTimerCountdownReadyColor", INI::parseColorInt, nullptr, offsetof( InGameUI, m_namedTimerReadyColor ) },
{ "FloatingTextTimeOut", INI::parseDurationUnsignedInt, nullptr, offsetof( InGameUI, m_floatingTextTimeOut ) },
{ "FloatingTextMoveUpSpeed", INI::parseVelocityReal, nullptr, offsetof( InGameUI, m_floatingTextMoveUpSpeed ) },
{ "FloatingTextVanishRate", INI::parseVelocityReal, nullptr, offsetof( InGameUI, m_floatingTextMoveVanishRate ) },
{ "PopupMessageColor", INI::parseColorInt, nullptr, offsetof( InGameUI, m_popupMessageColor ) },
{ "DrawableCaptionFont", INI::parseAsciiString, nullptr, offsetof( InGameUI, m_drawableCaptionFont ) },
{ "DrawableCaptionPointSize", INI::parseInt, nullptr, offsetof( InGameUI, m_drawableCaptionPointSize ) },
{ "DrawableCaptionBold", INI::parseBool, nullptr, offsetof( InGameUI, m_drawableCaptionBold ) },
{ "DrawableCaptionColor", INI::parseColorInt, nullptr, offsetof( InGameUI, m_drawableCaptionColor ) },
{ "DrawRMBScrollAnchor", INI::parseBool, nullptr, offsetof( InGameUI, m_drawRMBScrollAnchor ) },
{ "MoveRMBScrollAnchor", INI::parseBool, nullptr, offsetof( InGameUI, m_moveRMBScrollAnchor ) },
{ "AttackDamageAreaRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[RADIUSCURSOR_ATTACK_DAMAGE_AREA] ) },
{ "AttackScatterAreaRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[RADIUSCURSOR_ATTACK_SCATTER_AREA] ) },
{ "AttackContinueAreaRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[RADIUSCURSOR_ATTACK_CONTINUE_AREA] ) },
{ "FriendlySpecialPowerRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[RADIUSCURSOR_FRIENDLY_SPECIALPOWER] ) },
{ "OffensiveSpecialPowerRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[RADIUSCURSOR_OFFENSIVE_SPECIALPOWER] ) },
{ "SuperweaponScatterAreaRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[RADIUSCURSOR_SUPERWEAPON_SCATTER_AREA] ) },
{ "GuardAreaRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[RADIUSCURSOR_GUARD_AREA] ) },
{ "EmergencyRepairRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[RADIUSCURSOR_EMERGENCY_REPAIR] ) },
{ "ParticleCannonRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_PARTICLECANNON] ) },
{ "A10StrikeRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_A10STRIKE] ) },
{ "CarpetBombRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_CARPETBOMB] ) },
{ "DaisyCutterRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_DAISYCUTTER] ) },
{ "ParadropRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_PARADROP] ) },
{ "SpySatelliteRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_SPYSATELLITE] ) },
{ "SpectreGunshipRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_SPECTREGUNSHIP] ) },
{ "HelixNapalmBombRadiusCursor",RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_HELIX_NAPALM_BOMB] ) },
{ "NuclearMissileRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_NUCLEARMISSILE] ) },
{ "EMPPulseRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_EMPPULSE] ) },
{ "ArtilleryRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_ARTILLERYBARRAGE] ) },
{ "FrenzyRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_FRENZY] ) },
{ "NapalmStrikeRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_NAPALMSTRIKE] ) },
{ "ClusterMinesRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_CLUSTERMINES] ) },
{ "ScudStormRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_SCUDSTORM] ) },
{ "AnthraxBombRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_ANTHRAXBOMB] ) },
{ "AmbushRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_AMBUSH] ) },
{ "RadarRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_RADAR] ) },
{ "SpyDroneRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_SPYDRONE] ) },
{ "ClearMinesRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_CLEARMINES] ) },
{ "AmbulanceRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_AMBULANCE] ) },
// TheSuperHackers @info ui enhancement configuration
{ "NetworkLatencyFont", INI::parseAsciiString, nullptr, offsetof( InGameUI, m_networkLatencyFont ) },
{ "NetworkLatencyBold", INI::parseBool, nullptr, offsetof( InGameUI, m_networkLatencyBold ) },
{ "NetworkLatencyPosition", INI::parseCoord2D, nullptr, offsetof( InGameUI, m_networkLatencyPosition ) },
{ "NetworkLatencyColor", INI::parseColorInt, nullptr, offsetof( InGameUI, m_networkLatencyColor ) },
{ "NetworkLatencyDropColor", INI::parseColorInt, nullptr, offsetof( InGameUI, m_networkLatencyDropColor ) },
{ "RenderFpsFont", INI::parseAsciiString, nullptr, offsetof( InGameUI, m_renderFpsFont ) },
{ "RenderFpsBold", INI::parseBool, nullptr, offsetof( InGameUI, m_renderFpsBold ) },
{ "RenderFpsPosition", INI::parseCoord2D, nullptr, offsetof( InGameUI, m_renderFpsPosition ) },
{ "RenderFpsColor", INI::parseColorInt, nullptr, offsetof( InGameUI, m_renderFpsColor ) },
{ "RenderFpsLimitColor", INI::parseColorInt, nullptr, offsetof( InGameUI, m_renderFpsLimitColor ) },
{ "RenderFpsDropColor", INI::parseColorInt, nullptr, offsetof( InGameUI, m_renderFpsDropColor ) },
{ "RenderFpsRefreshMs", INI::parseUnsignedInt, nullptr, offsetof( InGameUI, m_renderFpsRefreshMs ) },
{ "SystemTimeFont", INI::parseAsciiString, nullptr, offsetof( InGameUI, m_systemTimeFont ) },
{ "SystemTimeBold", INI::parseBool, nullptr, offsetof( InGameUI, m_systemTimeBold ) },
{ "SystemTimePosition", INI::parseCoord2D, nullptr, offsetof( InGameUI, m_systemTimePosition ) },
{ "SystemTimeColor", INI::parseColorInt, nullptr, offsetof( InGameUI, m_systemTimeColor ) },
{ "SystemTimeDropColor", INI::parseColorInt, nullptr, offsetof( InGameUI, m_systemTimeDropColor ) },
{ "GameTimeFont", INI::parseAsciiString, nullptr, offsetof( InGameUI, m_gameTimeFont ) },
{ "GameTimeBold", INI::parseBool, nullptr, offsetof( InGameUI, m_gameTimeBold ) },
{ "GameTimePosition", INI::parseCoord2D, nullptr, offsetof( InGameUI, m_gameTimePosition ) },
{ "GameTimeColor", INI::parseColorInt, nullptr, offsetof( InGameUI, m_gameTimeColor ) },
{ "GameTimeDropColor", INI::parseColorInt, nullptr, offsetof( InGameUI, m_gameTimeDropColor ) },
{ "PlayerInfoListFont", INI::parseAsciiString, nullptr, offsetof( InGameUI, m_playerInfoListFont ) },
{ "PlayerInfoListBold", INI::parseBool, nullptr, offsetof( InGameUI, m_playerInfoListBold ) },
{ "PlayerInfoListPosition", INI::parseCoord2D, nullptr, offsetof( InGameUI, m_playerInfoListPosition ) },
{ "PlayerInfoListLabelColor", INI::parseColorInt, nullptr, offsetof( InGameUI, m_playerInfoListLabelColor ) },
{ "PlayerInfoListValueColor", INI::parseColorInt, nullptr, offsetof( InGameUI, m_playerInfoListValueColor ) },
{ "PlayerInfoListDropColor", INI::parseColorInt, nullptr, offsetof( InGameUI, m_playerInfoListDropColor ) },
{ "PlayerInfoListBackgroundAlpha", INI::parseUnsignedInt , nullptr, offsetof( InGameUI, m_playerInfoListBackgroundAlpha ) },
{ nullptr, nullptr, nullptr, 0 }
};
//-------------------------------------------------------------------------------------------------
/** Parse MouseCursor entry */
//-------------------------------------------------------------------------------------------------
void INI::parseInGameUIDefinition( INI* ini )
{
if( TheInGameUI )
{
// parse the ini weapon definition
ini->initFromINI( TheInGameUI, TheInGameUI->getFieldParse() );
}
}
//-------------------------------------------------------------------------------------------------
namespace
{
// helpers for inline counters
constexpr const Int kHudAnchorX = 3;
constexpr const Int kHudAnchorY = -1;
constexpr const Int kHudGapPx = 6;
inline Bool isAtHudAnchorPos(const Coord2D &p) { return p.x == kHudAnchorX && p.y == kHudAnchorY; }
}
//-------------------------------------------------------------------------------------------------
InGameUI::PlayerInfoList::PlayerInfoList()
{
std::fill(labels, labels + ARRAY_SIZE(labels), static_cast<DisplayString*>(nullptr));
for (Int column = 0; column < ARRAY_SIZE(values); ++column)
{
std::fill(values[column], values[column] + ARRAY_SIZE(values[column]), static_cast<DisplayString*>(nullptr));
}
}
//-------------------------------------------------------------------------------------------------
void InGameUI::PlayerInfoList::init(const AsciiString &fontName, Int pointSize, Bool bold)
{
Int i;
GameFont *listFont = TheWindowManager->winFindFont(fontName, pointSize, bold);
for (i = 0; i < ARRAY_SIZE(labels); ++i)
{
if (!labels[i])
{
labels[i] = TheDisplayStringManager->newDisplayString();
}
labels[i]->setFont(listFont);
}
for (i = 0; i < ARRAY_SIZE(values); ++i)
{
for (Int j = 0; j < MAX_PLAYER_COUNT; ++j)
{
if (!values[i][j])
{
values[i][j] = TheDisplayStringManager->newDisplayString();