Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SelectableButtonComponent.c
Go to the documentation of this file.
1
3
4//------------------------------------------------------------------------------------------------
6{
7 [Attribute(params: "edds imageset")]
9
10 [Attribute(defvalue: "", desc: "When the texture is an image set, define the quad name here")]
11 private string m_sImageName;
12
13 [Attribute(defvalue: "4", UIWidgets.EditBox, "How ,uch of spaceis between image and text - work if both are visible")]
14 protected float m_fContentPadding;
15
16 //protected string WIDGET_CHECKER = "Checker";
17 protected string WIDGET_CONTET_HLAYOUT = "hLayoutContent";
18 protected string WIDGET_IMAGE = "ImageContent";
19
21 protected bool m_bIsSelected = false;
22 protected bool m_bIsTriggered = true;
23
24 //protected Widget m_wChecked;
27
28 protected ref Color COLOR_CHECKED_TRUE = UIColors.CONTRAST_COLOR;
29 protected ref Color COLOR_CHECKED_FALSE = UIColors.WHITE_DEFAULT;
30
31 //------------------------------------------------------------------------------------------------
32 override void HandlerAttached(Widget w)
33 {
34 super.HandlerAttached(w);
35
36 //m_wChecked = m_wRoot.FindAnyWidget(WIDGET_CHECKER);
38 m_wImageContent = ImageWidget.Cast(m_wRoot.FindAnyWidget(WIDGET_IMAGE));
39
40 // Set image
41 SetImage(m_sImageResource, m_sImageName);
42
43 // Set checcker color
44 if (m_wOverlay)
45 {
46 if (m_bIsSelected)
48 else
50 }
51
52 // Image - Text padding
54 return;
55
56 if (m_wImageContent.IsVisible() && m_wContent.IsVisible())
57 {
59 }
60 }
61
62 //------------------------------------------------------------------------------------------------
63 void SetImage(ResourceName sResource, string sImageName)
64 {
65 if (!m_wImageContent)
66 return;
67
68 m_wImageContent.SetVisible(!sResource.IsEmpty());
69
70 if(sResource.IsEmpty())
71 return;
72
73 if (sResource.EndsWith("imageset"))
74 m_wImageContent.LoadImageFromSet(0, sResource, sImageName);
75 else
76 m_wImageContent.LoadImageTexture(0, sResource);
77 }
78
79 //------------------------------------------------------------------------------------------------
80 override bool OnClick(Widget w, int x, int y, int button)
81 {
82 super.OnClick(w, x, y, button);
83 if (button != 0)
84 return false;
85
87 return false;
88 }
89
90 //------------------------------------------------------------------------------------------------
91 override bool OnMouseEnter(Widget w, int x, int y)
92 {
94 GetGame().GetWorkspace().SetFocusedWidget(w);
95
97
98 if (GetGame().GetWorkspace().GetFocusedWidget() != w)
100
101 return false;
102 }
103
104 //------------------------------------------------------------------------------------------------
105 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
106 {
107 if (GetGame().GetWorkspace().GetFocusedWidget() != w)
109
110 return false;
111 }
112
113 //------------------------------------------------------------------------------------------------
114 override bool OnFocus(Widget w, int x, int y)
115 {
119 return false;
120 }
121
122 //------------------------------------------------------------------------------------------------
123 override bool OnFocusLost(Widget w, int x, int y)
124 {
125
126 if (WidgetManager.GetWidgetUnderCursor() == w)
128 else
130
132
133 return false;
134 }
135
136 //------------------------------------------------------------------------------------------------
137 override protected void OnMenuSelect()
138 {
139 if (!m_wRoot.IsEnabled())
140 return;
141
142 super.OnMenuSelect();
144 }
145
146 //------------------------------------------------------------------------------------------------
147 override protected void ColorizeWidgets(Color colorBackground, Color colorContent, float speed = -1)
148 {
149 if (speed < 0)
150 speed = m_fAnimationRate;
151
152 AnimateWidget.Color(m_wBackground, colorBackground, speed);
153 }
154
155 //------------------------------------------------------------------------------------------------
164
165 // User API
166 //------------------------------------------------------------------------------------------------
168 {
169 return m_bIsSelected;
170 }
171
172 //------------------------------------------------------------------------------------------------
173 void SetSelected(bool selected, bool notify = true)
174 {
175 if (m_bIsSelected == selected)
176 return;
177
178 m_bIsSelected = selected;
179
181
182 if (notify)
183 m_OnChanged.Invoke(this, m_wRoot, m_bIsSelected);
184 }
185
186 //------------------------------------------------------------------------------------------------
189 static SCR_SelectableButtonComponent GetSelectableButtonComponent(string name, Widget parent, bool searchAllChildren = true)
190 {
191 auto comp = SCR_SelectableButtonComponent.Cast(
192 SCR_WLibComponentBase.GetComponent(SCR_SelectableButtonComponent, name, parent, searchAllChildren)
193 );
194 return comp;
195 }
196};
ArmaReforgerScripted GetGame()
Definition game.c:1398
Widget m_wRoot
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
static WidgetAnimationColor Color(Widget widget, Color color, float speed)
Definition Color.c:13
Deprecated button component. Still used in many prefabs, so it works, it's just stripped of most of t...
void SetSelected(bool selected, bool notify=true)
void ColorizeWidgets(Color colorBackground, Color colorContent, float speed=-1)
void ColorizeCheckWidget()
Set color of checked line.
override bool OnClick(Widget w, int x, int y, int button)
override bool OnFocus(Widget w, int x, int y)
override bool OnFocusLost(Widget w, int x, int y)
static SCR_SelectableButtonComponent GetSelectableButtonComponent(string name, Widget parent, bool searchAllChildren=true)
override bool OnMouseEnter(Widget w, int x, int y)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
void SetImage(ResourceName sResource, string sImageName)
Base class for all final Reforger interactive elements.
SCR_FieldOfViewSettings Attribute
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134