Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PagingButtonComponent.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
3{
4 [Attribute()]
5 protected bool m_bIsPositive;
6
7 [Attribute("false", UIWidgets.Auto, "Use action hint instead of an image")]
9
10 [Attribute("MenuSearch")]
12
13 protected string m_sBackgroundImageName = "BackgroundImage";
14 protected string m_sFrontImageName = "Panel";
15 protected string m_sActionTextName = "ActionText";
16
20
21 ref ScriptInvoker m_OnActivated = new ScriptInvoker(); // Returns -1 if negative, 1 if positive
22
23 //------------------------------------------------------------------------------------------------
24 override void HandlerAttached(Widget w)
25 {
26 super.HandlerAttached(w);
27
29 m_wPanel = ImageWidget.Cast(w.FindAnyWidget(m_sFrontImageName));
30 m_wText = TextWidget.Cast(w.FindAnyWidget(m_sActionTextName));
31
32 if (m_wPanel)
33 m_wPanel.SetVisible(!m_bUseActionHint);
34
36 {
39 }
40
41 if (m_wText)
42 {
43 m_wText.SetVisible(m_bUseActionHint);
45 {
46 m_wText.SetTextFormat("<action name='%1' scale='1.5'/>", m_sActionName);
47 }
48 }
49
51
53 }
54
55 //------------------------------------------------------------------------------------------------
56 override bool OnClick(Widget w, int x, int y, int button)
57 {
58 super.OnClick(w, x, y, button);
59
60 if (button != 0)
61 return false;
62
63 if (m_bIsPositive)
64 m_OnActivated.Invoke(m_wRoot, 1);
65 else
66 m_OnActivated.Invoke(m_wRoot, -1);
67
68 return false;
69 }
70
71 //------------------------------------------------------------------------------------------------
72 protected void FlipImage(bool flip)
73 {
75 return;
76
77 if (flip)
78 {
79 m_wPanel.SetFlags(WidgetFlags.FLIPU);
80 m_wBackgroundImage.SetFlags(WidgetFlags.FLIPU);
81 }
82 else
83 {
84 m_wPanel.ClearFlags(WidgetFlags.FLIPU);
85 m_wBackgroundImage.ClearFlags(WidgetFlags.FLIPU);
86 }
87 }
88
89 //------------------------------------------------------------------------------------------------
90 override protected void OnMenuSelect()
91 {
93 if (!m_wRoot.IsEnabled())
94 return;
95
96 // Bail if attached to menu but menu is not focused
98 return;
99
100 if (m_bIsPositive)
101 m_OnActivated.Invoke(m_wRoot, 1);
102 else
103 m_OnActivated.Invoke(m_wRoot, -1);
104 }
105
106 //------------------------------------------------------------------------------------------------
107 override void SetEnabled(bool enabled, bool animate = true)
108 {
109 super.SetEnabled(enabled, animate);
111 m_wBackgroundImage.SetVisible(enabled);
112 }
113
114 // User API
115 //------------------------------------------------------------------------------------------------
117 {
118 return m_bIsPositive;
119 }
120
121 //------------------------------------------------------------------------------------------------
122 void SetPositive(bool positive)
123 {
124 m_bIsPositive = positive;
125 }
126
127 //------------------------------------------------------------------------------------------------
128 void SetAction(string name)
129 {
130 if (!m_wText)
131 return;
132
133 GetGame().GetInputManager().RemoveActionListener(m_sActionName, EActionTrigger.DOWN, OnMenuSelect);
134 m_sActionName = name;
135
136 // Handle case of empty action
137 name = name.Trim();
138 if (name == string.Empty)
139 {
140 if (m_wText)
141 m_wText.SetText(" ");
142 }
143 else
144 {
145 GetGame().GetInputManager().AddActionListener(m_sActionName, EActionTrigger.DOWN, OnMenuSelect);
146
147//---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
148// Hardcoded scale. Baaaaaaaaaad
149
150 m_wText.SetTextFormat("<action name='%1' scale='1.5'/>", m_sActionName);
151
152//---- REFACTOR NOTE END ----
153 }
154 }
155
156 //------------------------------------------------------------------------------------------------
157 override bool OnMouseEnter(Widget w, int x, int y)
158 {
159 super.OnMouseEnter(w, x, y);
160
162 return false;
163
165
168 else
170
171 return false;
172 }
173
174 //------------------------------------------------------------------------------------------------
175 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
176 {
177 super.OnMouseLeave(w, enterW, x, y);
178
180 return false;
181
184 else
186
187 return false;
188 }
189
190 //------------------------------------------------------------------------------------------------
191 string GetAction()
192 {
193 return m_sActionName;
194 }
195
196 //------------------------------------------------------------------------------------------------
197 static SCR_PagingButtonComponent GetPagingButtonComponent(string name, Widget parent, bool searchAllChildren = true)
198 {
199 return SCR_PagingButtonComponent.Cast(SCR_PagingButtonComponent.GetComponent(SCR_ButtonBaseComponent, name, parent, searchAllChildren));
200 }
201};
ArmaReforgerScripted GetGame()
Definition game.c:1398
static WidgetAnimationColor Color(Widget widget, Color color, float speed)
Base class for any button, regardless its own content.
bool IsParentMenuFocused()
Returns true if parent menu is focused, or if there is no parent menu.
override bool OnClick(Widget w, int x, int y, int button)
override void HandlerAttached(Widget w)
override void SetEnabled(bool enabled, bool animate=true)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
override bool OnMouseEnter(Widget w, int x, int y)
static SCR_PagingButtonComponent GetPagingButtonComponent(string name, Widget parent, bool searchAllChildren=true)
SCR_FieldOfViewSettings Attribute
EActionTrigger
WidgetFlags
Widget flags. See enf::Widget::SetFlags().
Definition WidgetFlags.c:14
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134