4 protected RichTextWidget m_wSpecializationTitle;
5 protected RichTextWidget m_wSpecializationValue;
8 protected const float m_fMinValue = 0;
9 protected const float m_fMaxValue = 100;
11 protected int m_ibuttonId;
14 protected bool m_bIsActive;
16 [
Attribute(
"1 1 1 1", UIWidgets.ColorPicker)]
17 protected ref Color m_ColorInactive;
19 [
Attribute(
"1 1 1 0.3", UIWidgets.ColorPicker)]
20 protected ref Color m_ColorInactiveHovered;
22 [
Attribute(
"0.898 0.541 0.184 1", UIWidgets.ColorPicker)]
23 protected ref Color m_ColorActive;
26 protected ref ScriptInvoker m_OnClicked =
new ScriptInvoker();
29 protected ref ScriptInvoker m_OnMouseEnter =
new ScriptInvoker();
30 protected ref ScriptInvoker m_OnMouseLeave =
new ScriptInvoker();
33 protected override void HandlerAttached(Widget w)
35 super.HandlerAttached(w);
37 m_wSpecializationTitle = RichTextWidget.Cast(w.FindAnyWidget(
"SpecializationTitle"));
38 if (!m_wSpecializationTitle)
41 m_wSpecializationValue = RichTextWidget.Cast(w.FindAnyWidget(
"SpecializationValue"));
42 if (!m_wSpecializationValue)
45 m_wSpecializationTitle.SetText(
"");
46 m_wSpecializationTitle.SetColor(m_ColorInactive);
47 m_wSpecializationValue.SetText(
"");
48 m_wSpecializationValue.SetColor(m_ColorInactive);
51 if (!m_SpecializationBar)
54 m_SpecializationBar.SetMin(m_fMinValue);
55 m_SpecializationBar.SetMax(m_fMaxValue);
56 m_SpecializationBar.SetActive(
false);
60 ScriptInvoker GetOnClicked()
66 protected override bool OnClick(Widget w,
int x,
int y,
int button)
68 super.OnClick(w, x, y, button);
78 void Activate(
bool animate =
true)
88 AnimateWidget.Color(m_wSpecializationValue, m_ColorActive, m_fAnimationRate);
89 AnimateWidget.Color(m_wSpecializationTitle, m_ColorActive, m_fAnimationRate);
90 m_SpecializationBar.SetActive(
true);
94 AnimateWidget.StopAnimation(m_wSpecializationValue, WidgetAnimationColor);
95 m_wSpecializationValue.SetColor(m_ColorActive);
97 AnimateWidget.StopAnimation(m_wSpecializationTitle, WidgetAnimationColor);
98 m_wSpecializationTitle.SetColor(m_ColorActive);
100 m_SpecializationBar.SetActive(
true);
105 void Deactivate(
bool animate =
true)
115 AnimateWidget.Color(m_wSpecializationValue, m_ColorInactive, m_fAnimationRate);
116 AnimateWidget.Color(m_wSpecializationTitle, m_ColorInactive, m_fAnimationRate);
117 m_SpecializationBar.SetActive(
false);
121 AnimateWidget.StopAnimation(m_wSpecializationValue, WidgetAnimationColor);
122 m_wSpecializationValue.SetColor(m_ColorInactive);
124 AnimateWidget.StopAnimation(m_wSpecializationTitle, WidgetAnimationColor);
125 m_wSpecializationValue.SetColor(m_ColorInactive);
127 m_SpecializationBar.SetActive(
false);
132 protected override bool OnMouseEnter(Widget w,
int x,
int y)
134 super.OnMouseEnter(w, x, y);
140 protected override bool OnMouseLeave(Widget w, Widget enterW,
int x,
int y)
142 super.OnMouseLeave(w, enterW, x, y);
151 m_wSpecializationValue.SetOpacity(0);
152 m_wSpecializationTitle.SetOpacity(0);
153 m_SpecializationBar.Hide();
159 m_wSpecializationValue.SetOpacity(255);
160 m_wSpecializationTitle.SetOpacity(255);
161 m_SpecializationBar.Unhide();
165 void SetOnHover(
bool OnHover =
true)
172 AnimateWidget.Color(m_wSpecializationValue, m_ColorInactiveHovered, m_fAnimationRate);
173 AnimateWidget.Color(m_wSpecializationTitle, m_ColorInactiveHovered, m_fAnimationRate);
174 GetGame().GetCallqueue().CallLater(m_SpecializationBar.SetOnHover, m_fAnimationRate,
false,
true);
178 AnimateWidget.Color(m_wSpecializationValue, m_ColorInactive, m_fAnimationRate);
179 AnimateWidget.Color(m_wSpecializationTitle, m_ColorInactive, m_fAnimationRate);
180 GetGame().GetCallqueue().CallLater(m_SpecializationBar.SetOnHover, m_fAnimationRate,
false,
false);
184 ScriptInvoker GetOnMouseEnter()
190 ScriptInvoker GetOnMouseLeave()
196 void SetTitle(
string text)
198 if (!m_wSpecializationTitle)
201 m_wSpecializationTitle.SetText(text);
205 void SetValue(
float num)
207 if (!m_wSpecializationValue || !m_SpecializationBar)
210 m_wSpecializationValue.SetText(
""+num.ToString(-1, 2)+
"%");
212 m_SpecializationBar.SetValue(num);
216 void SetButtonId(
int n)
220 Print (
"SCR_ButtonSpecializationProgress: Trying to create a Specialization Progress button for a non-valid specialization id", LogLevel.ERROR);
225 SetTitle(
""+(n+1)+
". "+
"#AR-CareerProfile_Specialization"+(n+1));
231 WorkspaceWidget workspace =
GetGame().GetWorkspace();
235 GetGame().GetCallqueue().CallLater(workspace.SetFocusedWidget, 1000,
false,
m_wRoot,
true);