Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ButtonComponent.c
Go to the documentation of this file.
1
2
3//------------------------------------------------------------------------------------------------
5{
6 [Attribute(uiwidget: UIWidgets.LocaleEditBox)]
8
9 protected Widget m_wOverlay;
10 protected Widget m_wContent;
11
12 protected ref Color COLOR_BACKGROUND_DEFAULT = UIColors.BACKGROUND_DEFAULT;
13 protected ref Color COLOR_BACKGROUND_HOVERED = UIColors.BACKGROUND_HOVERED;
14 protected ref Color COLOR_BACKGROUND_FOCUSED = UIColors.BACKGROUND_HOVERED;
15 protected ref Color COLOR_BACKGROUND_CLICKED = UIColors.BACKGROUND_HOVERED;
16
17 protected ref Color COLOR_CONTENT_DEFAULT = Color.White;
18 protected ref Color COLOR_CONTENT_HOVERED = Color.White;
19 protected ref Color COLOR_CONTENT_FOCUSED = Color.White;
20 protected ref Color COLOR_CONTENT_CLICKED = Color.White;
21
22 //ref ScriptInvoker m_OnClicked = new ScriptInvoker();
25
26 //------------------------------------------------------------------------------------------------
27 override void HandlerAttached(Widget w)
28 {
29 super.HandlerAttached(w);
30 m_wOverlay = w.FindAnyWidget("Overlay");
31 m_wBackground = w.FindAnyWidget("Background");
32
33 m_wContent = w.FindAnyWidget("Content");
34 if (m_wContent && m_sContent != string.Empty)
36
37 if (m_wBackground)
39
40 if (m_wOverlay)
42 }
43
44 /*
45 //------------------------------------------------------------------------------------------------
46 override bool OnClick(Widget w, int x, int y, int button)
47 {
48 super.OnClick(w, x, y, button);
49 if (button != 0)
50 return false;
51
52 m_OnClicked.Invoke(w);
53 return false;
54 }
55 */
56
57 /*
58 //------------------------------------------------------------------------------------------------
59 override protected void OnMenuSelect()
60 {
61 super.OnMenuSelect();
62 if (!m_wRoot.IsEnabled())
63 return;
64
65 //ColorizeWidgets(COLOR_BACKGROUND_CLICKED, COLOR_CONTENT_CLICKED, m_fAnimationRate * 2);
66 //GetGame().GetCallqueue().CallLater(ResetPadding, m_fAnimationTime * 500 + 1, false);
67 }
68 */
69
70 /*
71 //------------------------------------------------------------------------------------------------
72 override bool OnMouseButtonDown(Widget w, int x, int y, int button)
73 {
74 if (GetGame().GetWorkspace().GetFocusedWidget() == w)
75 ColorizeWidgets(COLOR_BACKGROUND_CLICKED, COLOR_CONTENT_CLICKED);
76 return false;
77 }
78
79 //------------------------------------------------------------------------------------------------
80 override bool OnMouseButtonUp(Widget w, int x, int y, int button)
81 {
82 if (GetGame().GetWorkspace().GetFocusedWidget() == w)
83 ColorizeWidgets(COLOR_BACKGROUND_FOCUSED, COLOR_CONTENT_FOCUSED);
84 else
85 ColorizeWidgets(COLOR_BACKGROUND_HOVERED, COLOR_CONTENT_HOVERED);
86
87 return false;
88 }
89 */
90
91 //------------------------------------------------------------------------------------------------
92 override bool OnMouseEnter(Widget w, int x, int y)
93 {
94 super.OnMouseEnter(w, x, y);
95 m_OnHover.Invoke();
96 //if (GetGame().GetWorkspace().GetFocusedWidget() != w)
97 //ColorizeWidgets(COLOR_BACKGROUND_HOVERED, COLOR_CONTENT_HOVERED);
98
99 return false;
100 }
101
102 //------------------------------------------------------------------------------------------------
103 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
104 {
105 super.OnMouseLeave(w, enterW, x, y);
106 m_OnHoverLeave.Invoke(w);
107 //if (GetGame().GetWorkspace().GetFocusedWidget() != w)
108 //ColorizeWidgets(COLOR_BACKGROUND_DEFAULT, COLOR_CONTENT_DEFAULT);
109
110 return false;
111 }
112
113 //------------------------------------------------------------------------------------------------
114 override bool OnFocus(Widget w, int x, int y)
115 {
116 super.OnFocus(w, x, y);
117 m_OnFocus.Invoke(w);
118 return false;
119 }
120
121 //------------------------------------------------------------------------------------------------
122 override bool OnFocusLost(Widget w, int x, int y)
123 {
124 super.OnFocusLost(w, x, y);
125 return false;
126 }
127
128 //------------------------------------------------------------------------------------------------
129 void ColorizeWidgets(Color colorBackground, Color colorContent, float speed = -1)
130 {
131 if (speed < 0)
132 speed = m_fAnimationRate;
133
134 AnimateWidget.Color(m_wBackground, colorBackground, speed);
135 AnimateWidget.Color(m_wOverlay, colorContent, speed);
136 }
137
138 //------------------------------------------------------------------------------------------------
140 {
141 if (!m_wContent)
142 return;
143
145 if (content)
146 AlignableSlot.SetHorizontalAlign(content, horizontalAlign);
147 }
148
149 //------------------------------------------------------------------------------------------------
150 void SetContent(string text)
151 {
152 if (!m_wContent)
153 return;
154
156 if (content)
157 {
158 content.SetText(text);
159 return;
160 }
161
163 if (img)
164 {
165 img.LoadImageTexture(0, text);
166 return;
167 }
168 }
169
170 //------------------------------------------------------------------------------------------------
172 {
173 if (!m_wContent)
174 return;
175
176 if (!info.SetNameTo(TextWidget.Cast(m_wContent)))
177 info.SetIconTo(ImageWidget.Cast(m_wContent));
178 }
179
180 //------------------------------------------------------------------------------------------------
181 string GetContent()
182 {
183 return m_sContent;
184 }
185
186 //------------------------------------------------------------------------------------------------
189 static SCR_ButtonComponent GetButtonComponent(string name, Widget parent, bool searchAllChildren = true)
190 {
191 auto comp = SCR_ButtonComponent.Cast(
192 SCR_WLibComponentBase.GetComponent(SCR_ButtonComponent, name, parent, searchAllChildren)
193 );
194 return comp;
195 }
196};
class RestAPIHelper< JsonApiStruct T > content
static WidgetAnimationColor Color(Widget widget, Color color, float speed)
Definition Color.c:13
Base class for any button, regardless its own content.
ref ScriptInvoker< Widget > m_OnFocus
Deprecated button component. Still used in many prefabs, so it works, it's just stripped of most of t...
override bool OnFocusLost(Widget w, int x, int y)
void SetHorizontalAlign(LayoutHorizontalAlign horizontalAlign)
static SCR_ButtonComponent GetButtonComponent(string name, Widget parent, bool searchAllChildren=true)
override void HandlerAttached(Widget w)
override bool OnMouseEnter(Widget w, int x, int y)
LocalizedString m_sContent
override bool OnFocus(Widget w, int x, int y)
void ColorizeWidgets(Color colorBackground, Color colorContent, float speed=-1)
void SetContentFromUIInfo(SCR_UIInfo info)
void SetContent(string text)
ref ScriptInvoker< Widget > m_OnHoverLeave
ref ScriptInvoker m_OnHover
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
bool SetIconTo(ImageWidget imageWidget)
Definition SCR_UIInfo.c:102
Base class for all final Reforger interactive elements.
SCR_FieldOfViewSettings Attribute
LayoutHorizontalAlign
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134