4 protected static const int HUD_DURATION = 15000;
5 protected static const int SIZE_NORMAL = 20;
6 protected static const int SIZE_WINNER = 24;
8 protected bool m_bInitDone;
9 protected bool m_bPeriodicRefresh;
13 protected Widget m_wCountdownOverlay;
15 protected ImageWidget m_wLeftFlag;
16 protected ImageWidget m_wRightFlag;
17 protected ImageWidget m_wWinScoreSideLeft;
18 protected ImageWidget m_wWinScoreSideRight;
20 protected RichTextWidget m_wLeftScore;
21 protected RichTextWidget m_wRightScore;
22 protected RichTextWidget m_wWinScore;
23 protected RichTextWidget m_wCountdown;
24 protected RichTextWidget m_wFlavour;
27 override bool DisplayStartDrawInit(IEntity owner)
32 m_Campaign.GetOnMatchSituationChanged().Insert(UpdateHUD);
34 return (m_Campaign !=
null);
38 override void DisplayStartDraw(IEntity owner)
45 if (m_Campaign.IsTutorial())
49 m_wLeftFlag = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"FlagSideBlue"));
50 m_wRightFlag = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"FlagSideRed"));
51 m_wLeftScore = RichTextWidget.Cast(
m_wRoot.FindAnyWidget(
"ScoreBlue"));
52 m_wRightScore = RichTextWidget.Cast(
m_wRoot.FindAnyWidget(
"ScoreRed"));
53 m_wWinScore = RichTextWidget.Cast(
m_wRoot.FindAnyWidget(
"TargetScore"));
56 m_wWinScoreSideLeft = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"ObjectiveLeft"));
57 m_wWinScoreSideRight = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"ObjectiveRight"));
62 m_wLeftFlag.LoadImageTexture(0, factionBLUFOR.GetFactionFlag());
63 m_wRightFlag.LoadImageTexture(0, factionOPFOR.GetFactionFlag());
69 override void DisplayUpdate(IEntity owner,
float timeSlice)
71 if (!m_bPeriodicRefresh)
78 protected void HideHUD()
84 protected void UpdateHUDValues()
86 int winningFactionId = m_Campaign.GetWinningFactionId();
87 int controlPointsBLUFOR = m_Campaign.GetFactionByEnum(
SCR_ECampaignFaction.BLUFOR).GetControlPointsHeld();
88 int controlPointsOPFOR = m_Campaign.GetFactionByEnum(
SCR_ECampaignFaction.OPFOR).GetControlPointsHeld();
89 int controlPointsThreshold = m_Campaign.GetControlPointTreshold();
91 m_wLeftScore.SetText(controlPointsBLUFOR.ToString());
92 m_wRightScore.SetText(controlPointsOPFOR.ToString());
93 m_wWinScore.SetText(controlPointsThreshold.ToString());
95 if (winningFactionId == -1)
99 m_wLeftScore.SetDesiredFontSize(SIZE_NORMAL);
100 m_wRightScore.SetDesiredFontSize(SIZE_NORMAL);
101 m_wWinScoreSideRight.SetColor(Color.FromInt(Color.WHITE));
102 m_wWinScoreSideLeft.SetColor(Color.FromInt(Color.WHITE));
103 m_wRightScore.SetColor(Color.FromInt(Color.WHITE));
104 m_wLeftScore.SetColor(Color.FromInt(Color.WHITE));
105 m_wWinScore.SetColor(Color.FromInt(Color.WHITE));
110 WorldTimestamp victoryTimestamp = m_Campaign.GetVictoryTimestamp();
111 WorldTimestamp pauseTimestamp = m_Campaign.GetVictoryPauseTimestamp();
112 bool isPaused = (pauseTimestamp != 0);
119 winCountdown = victoryTimestamp.DiffMilliseconds(pauseTimestamp);
125 winCountdown = victoryTimestamp.DiffMilliseconds(world.GetServerTimestamp());
127 m_bPeriodicRefresh =
true;
130 winCountdown = Math.Max(0, Math.Ceil(winCountdown / 1000));
131 Faction winner =
GetGame().GetFactionManager().GetFactionByIndex(winningFactionId);
136 m_wFlavour.SetTextFormat(
"#AR-ConflictHUD_FlavourText_IsWinning", winner.GetFactionName());
137 m_wWinScore.SetColor(Color.FromInt(
UIColors.CONTRAST_COLOR.PackToInt()));
138 m_wWinScoreSideRight.SetColor(Color.FromInt(
UIColors.CONTRAST_COLOR.PackToInt()));
139 m_wWinScoreSideLeft.SetColor(Color.FromInt(
UIColors.CONTRAST_COLOR.PackToInt()));
141 if (winner == factionOPFOR)
143 m_wRightScore.SetColor(Color.FromInt(
UIColors.CONTRAST_COLOR.PackToInt()));
144 m_wLeftScore.SetColor(Color.FromInt(Color.WHITE));
145 m_wRightScore.SetDesiredFontSize(SIZE_WINNER);
146 m_wLeftScore.SetDesiredFontSize(SIZE_NORMAL);
150 m_wLeftScore.SetColor(Color.FromInt(
UIColors.CONTRAST_COLOR.PackToInt()));
151 m_wRightScore.SetColor(Color.FromInt(Color.WHITE));
152 m_wLeftScore.SetDesiredFontSize(SIZE_WINNER);
153 m_wRightScore.SetDesiredFontSize(SIZE_NORMAL);
162 protected void UpdateHUD()
164 m_bPeriodicRefresh =
false;
169 GetGame().GetCallqueue().Remove(HideHUD);
171 if (m_Campaign.IsTutorial())
176 if (m_Campaign.GetIsMatchOver())
184 if (!m_bPeriodicRefresh && !m_Campaign.GetVictoryTimestamp())
185 GetGame().GetCallqueue().CallLater(HideHUD, HUD_DURATION);