Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CoreMenuHeaderButtonComponent.c
Go to the documentation of this file.
1
3{
4 [Attribute()]
5 string m_sIconName;
6
7 [Attribute("1")]
8 bool m_bShowCount;
9
10 [Attribute("Label")]
11 string m_sLabel;
12
14 protected SCR_ModularButtonComponent m_ButtonComponent;
15
17
20
22
23 protected const string BUTTON = "CoreMenuHeaderButton";
24 protected const string COUNT_ICON_FRAME = "CountIconFrame";
25 protected const string COUNT_TEXT = "CountText";
26 protected const string ICON = "Icon";
27 protected const string LABEL = "ButtonLabel";
28
29 //------------------------------------------------------------------------------------------------
30 override void HandlerAttached(Widget w)
31 {
32 super.HandlerAttached(w);
33
34 m_wButtonWidget = w.FindAnyWidget(BUTTON);
36 m_ButtonComponent = SCR_ModularButtonComponent.FindComponent(m_wButtonWidget);
37
38 m_wCountIconFrame = w.FindAnyWidget(COUNT_ICON_FRAME);
39 m_wCountText = TextWidget.Cast(w.FindAnyWidget(COUNT_TEXT));
40 SetCountVisible(m_bShowCount);
41
42 m_wLabel = TextWidget.Cast(w.FindAnyWidget(LABEL));
43 SetLabelText(m_sLabel);
44
45 m_wIcon = ImageWidget.Cast(w.FindAnyWidget(ICON));
46 SetIcon(m_sIconName);
47 }
48
49 //------------------------------------------------------------------------------------------------
51 void SetIcon(string name)
52 {
53 if (!m_wIcon)
54 return;
55
56 bool show = name != string.Empty;
57 m_wIcon.SetVisible(show);
58
59 if (!show)
60 return;
61
62 m_wIcon.LoadImageFromSet(0, UIConstants.ICONS_IMAGE_SET, name);
63
64 // Resize
65 int x, y;
66 m_wIcon.GetImageSize(0, x, y);
67 m_wIcon.SetSize(x, y);
68 }
69
70 //------------------------------------------------------------------------------------------------
72 void SetCountText(string text)
73 {
74 if (!m_wCountText)
75 return;
76
77 m_wCountText.SetText(text);
78 }
79
80 //------------------------------------------------------------------------------------------------
82 void SetCountVisible(bool visible)
83 {
85 return;
86
87 m_wCountIconFrame.SetVisible(visible);
88 }
89
90 //------------------------------------------------------------------------------------------------
92 void SetLabelText(string text)
93 {
94 if (!m_wLabel)
95 return;
96
97 m_wLabel.SetVisible(!text.IsEmpty());
98
99 if (m_wLabel.IsVisible())
100 m_wLabel.SetText(text);
101 }
102
103 //------------------------------------------------------------------------------------------------
106 {
107 if (!m_wLabel)
108 return string.Empty;
109
110 return m_wLabel.GetText();
111 }
112
113 //------------------------------------------------------------------------------------------------
117 void SetVisible(bool visible, bool animate = false, float rate = UIConstants.FADE_RATE_FAST)
118 {
119 if (!m_wRoot)
120 return;
121
122 if (animate)
123 AnimateWidget.Opacity(m_wRoot, visible, rate, true);
124 else
125 m_wRoot.SetVisible(visible);
126 }
127
128 //------------------------------------------------------------------------------------------------
130 SCR_ModularButtonComponent GetButton()
131 {
132 return m_ButtonComponent;
133 }
134}
static WidgetAnimationOpacity Opacity(Widget widget, float targetValue, float speed, bool toggleVisibility=false)
Helper component for core menu header button prefabs.
void SetVisible(bool visible, bool animate=false, float rate=UIConstants.FADE_RATE_FAST)
SCR_FieldOfViewSettings Attribute