4 protected static const int XP_INFO_DURATION = 10000;
5 protected static const ResourceName RANK_ICON_IMAGESET =
"{5D7F0C1AB551F610}UI/Textures/MilitaryIcons/MilitaryIcons.imageset";
7 protected bool m_bNegativeXP;
8 protected bool m_bInitDone;
9 protected bool m_bIsInfoAllowed =
true;
11 protected SCR_XPHandlerComponent m_PlayerXPComponent;
13 protected TextWidget m_wTitle;
14 protected TextWidget m_wRank;
15 protected TextWidget m_wRankNoIcon;
16 protected TextWidget m_wSkill;
17 protected ImageWidget m_wRankIcon;
18 protected ProgressBarWidget m_wProgress;
19 protected ProgressBarWidget m_wProgressDiff;
22 override void DisplayInit(IEntity owner)
24 super.DisplayInit(owner);
26 BaseGameMode gameMode =
GetGame().GetGameMode();
31 m_PlayerXPComponent = SCR_XPHandlerComponent.Cast(gameMode.FindComponent(SCR_XPHandlerComponent));
35 override bool DisplayStartDrawInit(IEntity owner)
37 return (m_PlayerXPComponent !=
null);
41 override void DisplayStartDraw(IEntity owner)
48 SCR_PlayerXPHandlerComponent comp = SCR_PlayerXPHandlerComponent.Cast(owner.FindComponent(SCR_PlayerXPHandlerComponent));
51 comp.GetOnXPChanged().Insert(ShowXPInfo);
55 m_wTitle = TextWidget.Cast(
m_wRoot.FindWidget(
"Title"));
56 m_wRank = TextWidget.Cast(
m_wRoot.FindWidget(
"Rank"));
57 m_wRankNoIcon = TextWidget.Cast(
m_wRoot.FindWidget(
"RankNoIcon"));
58 m_wRankIcon = ImageWidget.Cast(
m_wRoot.FindWidget(
"RankIcon"));
59 m_wSkill = TextWidget.Cast(
m_wRoot.FindWidget(
"Skill"));
60 m_wProgress = ProgressBarWidget.Cast(
m_wRoot.FindWidget(
"Progress"));
61 m_wProgressDiff = ProgressBarWidget.Cast(
m_wRoot.FindWidget(
"ProgressDiff"));
63 m_wProgress.SetColor(Color.FromInt(
UIColors.CONTRAST_COLOR.PackToInt()));
67 protected void RecolorXPBar()
69 AnimateWidget.Color(m_wProgressDiff, Color.FromInt(
UIColors.CONTRAST_COLOR.PackToInt()),
UIConstants.FADE_RATE_SLOW);
73 void AllowShowingInfo(
bool allow)
75 m_bIsInfoAllowed = allow;
79 protected void HideHUD()
85 protected void ShowXPInfo(
int totalXP,
SCR_EXPRewards rewardID,
int XP,
bool volunteer,
bool profileUsed,
int skillLevel)
87 if (!m_bIsInfoAllowed)
90 bool toggled = (XP == 0);
92 bool notify = !nonSpecific && m_PlayerXPComponent.AllowNotification(rewardID);
95 if (nonSpecific && !toggled)
110 string rankText = faction.GetRankName(curRank);
111 string rankIconName = faction.GetRankInsignia(curRank);
113 if (rankIconName.IsEmpty())
115 m_wRankNoIcon.SetTextFormat(rankText);
116 m_wRankIcon.SetVisible(
false);
117 m_wRank.SetTextFormat(
string.Empty);
121 m_wRankNoIcon.SetText(
string.Empty);
122 m_wRankIcon.LoadImageFromSet(0, RANK_ICON_IMAGESET, rankIconName);
123 m_wRankIcon.SetColor(Color.FromInt(
UIColors.CONTRAST_COLOR.PackToInt()));
124 m_wRankIcon.SetVisible(
true);
125 m_wRank.SetTextFormat(rankText);
129 m_bNegativeXP =
false;
131 if (toggled || !notify)
134 m_wTitle.SetText(
string.Empty);
139 m_wTitle.SetTextFormat(
"#AR-Campaign_RewardBonus_Volunteer", m_PlayerXPComponent.GetXPRewardName(rewardID));
141 m_wTitle.SetTextFormat(m_PlayerXPComponent.GetXPRewardName(rewardID));
146 m_wTitle.SetColor(Color.FromInt(
UIColors.CONFIRM.PackToInt()));
147 m_wProgressDiff.SetColor(Color.FromInt(
UIColors.CONFIRM.PackToInt()));
151 m_wTitle.SetColor(Color.FromInt(
UIColors.WARNING.PackToInt()));
152 m_wProgressDiff.SetColor(Color.FromInt(
UIColors.WARNING.PackToInt()));
153 m_bNegativeXP =
true;
157 UpdateXPProgressBar(factionManager, curRank, prevRank, XP, totalXP, notify);
179 if (!notify && !toggled)
188 GetGame().GetCallqueue().Remove(HideHUD);
189 GetGame().GetCallqueue().Remove(RecolorXPBar);
190 GetGame().GetCallqueue().CallLater(HideHUD, XP_INFO_DURATION);
191 GetGame().GetCallqueue().CallLater(RecolorXPBar, XP_INFO_DURATION * 0.7);
201 m_wProgress.SetMin(0);
202 m_wProgress.SetMax(1);
203 m_wProgress.SetCurrent(1);
204 m_wProgressDiff.SetMin(0);
205 m_wProgressDiff.SetMax(1);
206 m_wProgressDiff.SetCurrent(0);
213 m_wProgress.SetMin(0);
214 m_wProgress.SetMax(1);
215 m_wProgress.SetCurrent(0);
216 m_wProgressDiff.SetMin(0);
217 m_wProgressDiff.SetMax(1);
218 m_wProgressDiff.SetCurrent(1);
222 int XPCurRank = factionManager.GetRequiredRankXP(curRank);
223 int XPNextRank = factionManager.GetRequiredRankXP(factionManager.GetRankNext(curRank));
225 if (curRank == prevRank)
230 m_wProgress.SetMin(XPCurRank);
231 m_wProgress.SetMax(XPNextRank);
232 m_wProgressDiff.SetMin(XPCurRank);
233 m_wProgressDiff.SetMax(XPNextRank);
238 m_wProgress.SetMin(totalXP - XP);
239 m_wProgress.SetMax(totalXP - XP + 1);
240 m_wProgressDiff.SetMin(totalXP - XP);
241 m_wProgressDiff.SetMax(XPNextRank);
249 m_wProgress.SetCurrent(totalXP - XP);
250 m_wProgressDiff.SetCurrent(totalXP);
254 m_wProgress.SetCurrent(totalXP);
255 m_wProgressDiff.SetCurrent(totalXP - XP);
260 m_wProgress.SetCurrent(totalXP);
265 if (curRank > prevRank)
268 m_wProgress.SetMin(0);
269 m_wProgress.SetMax(1);
270 m_wProgress.SetCurrent(0);
271 m_wProgressDiff.SetMin(XPCurRank);
272 m_wProgressDiff.SetMax(XPNextRank);
273 m_wProgressDiff.SetCurrent(totalXP);
278 m_wProgress.SetMin(XPCurRank);
279 m_wProgress.SetMax(XPNextRank);
280 m_wProgress.SetCurrent(totalXP);
281 m_wProgressDiff.SetMin(0);
282 m_wProgressDiff.SetMax(1);
283 m_wProgressDiff.SetCurrent(1);
291 void ToggleXPInfo(
bool visible)
294 GetGame().GetCallqueue().Remove(HideHUD);
298 SCR_PlayerXPHandlerComponent comp = SCR_PlayerXPHandlerComponent.Cast(
m_PlayerController.FindComponent(SCR_PlayerXPHandlerComponent));
303 int totalXP = comp.GetPlayerXP();
305 ShowXPInfo(totalXP,
SCR_EXPRewards.UNDEFINED, 0,
false,
false, 0);