Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ButtonSplitComponent.c
Go to the documentation of this file.
1
3
4//------------------------------------------------------------------------------------------------
6{
7 protected ref array<ref Widget> m_aWidgetCells = new array<ref Widget>();
8 protected ref array<bool> m_aPreventContentChange = new array<bool>;
9
10 protected ref array<SCR_ButtonComponent> m_aInnerButtons = new array<SCR_ButtonComponent>;
11
13
14 protected ref Widget m_wHoverWidget;
15
16 [Attribute(defvalue: "0")]
17 protected int m_iButtonPaddingLeft;
18 [Attribute(defvalue: "0")]
19 protected int m_iButtonPaddingTop;
20 [Attribute(defvalue: "0")]
21 protected int m_iButtonPaddingRigh;
22 [Attribute(defvalue: "0")]
24
25 protected bool m_bColorizeFocusLost = true;
26
27 //------------------------------------------------------------------------------------------------
28 void SetColorizeFocusLost(bool colorize) { m_bColorizeFocusLost = colorize; }
29
30 //------------------------------------------------------------------------------------------------
37
38 //------------------------------------------------------------------------------------------------
39 override bool OnMouseEnter(Widget w, int x, int y)
40 {
42 return false;
43
44 super.OnMouseEnter(w, x, y);
46
47 return false;
48 }
49
50 //------------------------------------------------------------------------------------------------
51 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
52 {
53 super.OnMouseLeave(w, enterW, x, y);
54
56 {
57 m_OnHoverLeave.Invoke();
58 return false;
59 }
60
61 return false;
62 }
63
64 //------------------------------------------------------------------------------------------------
65 override protected void ColorizeWidgets(Color colorBackground, Color colorContent, float speed = -1)
66 {
67 if (speed < 0)
68 speed = m_fAnimationRate;
69
70 m_cColorContent = colorContent;
71 ColorizeCellPart("Background", colorBackground, speed, false);
72 ColorizeCellPart("Content", m_cColorContent, speed, true);
73 }
74
75 //------------------------------------------------------------------------------------------------
76 void InsertWidgetCells(array<string> cellNames)
77 {
78 Widget w;
79 foreach (string cellName : cellNames)
80 {
81 w = m_wRoot.FindAnyWidget(cellName);
82 if (w)
83 {
84 m_aWidgetCells.Insert(w);
85 m_aPreventContentChange.Insert(false);
86 }
87 }
88 }
89
90 //------------------------------------------------------------------------------------------------
92 void SetupInnerButton(string widgetName)
93 {
94 Widget w = m_wRoot.FindAnyWidget(widgetName);
95 if(!w)
96 return;
97
98 // Has this cell a button?
100 if(!button)
101 return;
102
103 // Insert on click to focus root
104 button.m_OnFocus.Insert(OnInnerButtonFocus);
105 }
106
107 //------------------------------------------------------------------------------------------------
109 protected void OnInnerButtonFocus(Widget w)
110 {
111 if(!m_wHoverWidget)
112 return;
113 GetGame().GetWorkspace().SetFocusedWidget(m_wHoverWidget);
114
115 if(!m_wRoot)
116 return;
117 GetGame().GetWorkspace().SetFocusedWidget(m_wRoot);
118 }
119
120 //------------------------------------------------------------------------------------------------
122 protected void ColorizeCellPart(string partName, Color c, float speed, float prevent)
123 {
124 for (int i = 0; i < m_aWidgetCells.Count(); i++)
125 {
126 if (i > m_aPreventContentChange.Count())
127 break;
128
129 if (prevent && m_aPreventContentChange[i])
130 {
131 continue;
132 }
133
134 Widget w = m_aWidgetCells[i];
135 Widget wPart = null;
136 string name = w.GetName();
137 if (!w)
138 continue;
139
140 wPart = w.FindAnyWidget(partName);
141
142 if (!wPart)
143 wPart = w.FindAnyWidget("Overlay");
144
145 if (wPart)
146 AnimateWidget.Color(wPart, c, speed);
147 }
148 }
149
150 //------------------------------------------------------------------------------------------------
152 void ColorizeCellPart(string partName, Color c, float speed, float prevent, int id)
153 {
154 if (prevent)
155 return;
156
158 Widget wPart = null;
159
160 if (w)
161 wPart = w.FindAnyWidget(partName);
162
163 if (!wPart)
164 wPart = w.FindAnyWidget("Overlay");
165
166 if (wPart)
167 AnimateWidget.Color(wPart, c, speed);
168 }
169
170 //------------------------------------------------------------------------------------------------
171 void PreventContentColoringOn(int iCellId, bool bPrevent)
172 {
173 m_aPreventContentChange[iCellId] = bPrevent;
174 }
175
176 //------------------------------------------------------------------------------------------------
178 {
179 return Color.FromInt(m_cColorContent.PackToInt());
180 }
181};
AddonBuildInfoTool id
ArmaReforgerScripted GetGame()
Definition game.c:1398
Widget m_wRoot
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...
ref ScriptInvoker< Widget > m_OnHoverLeave
ref array< bool > m_aPreventContentChange
void ColorizeCellPart(string partName, Color c, float speed, float prevent, int id)
Set color of one specific cell.
ref array< ref Widget > m_aWidgetCells
void ColorizeCellPart(string partName, Color c, float speed, float prevent)
Set color of every cell.
override bool OnMouseEnter(Widget w, int x, int y)
void ColorizeWidgets(Color colorBackground, Color colorContent, float speed=-1)
void InsertWidgetCells(array< string > cellNames)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
void OnInnerButtonFocus(Widget w)
Focus button root.
ref array< SCR_ButtonComponent > m_aInnerButtons
void PreventContentColoringOn(int iCellId, bool bPrevent)
void SetColorizeFocusLost(bool colorize)
void SetupInnerButton(string widgetName)
Find and setup focusing on root for every inner widget.
SCR_FieldOfViewSettings Attribute