Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
UISelectableGroup Class Reference
Inheritance diagram for UISelectableGroup:
IUISkin

Public Types

enum  ColorType { General = 0 , Tab = 5 , DontChange = 99 }
 

Public Member Functions

void ApplySkin ()
 
UIButton AddButton (UIButton mold, string text)
 
void RemoveButton (UIButton button)
 
void SetButton (UIButton button)
 
void SetGroup (int id)
 
virtual void Init (int index=0, UnityAction< int > action=null, bool directChildren=false)
 
void SetLoop ()
 
void Select (UIButton button, bool check=true)
 
void Select (int id)
 
void Select (string id)
 
void Select (Func< UIButton, bool > func)
 
void RefreshButtons ()
 
void ForceDefaultColor (bool useNoSelection=false)
 
void ToggleInteractable (bool enable)
 
void SetColors ()
 
void ApplySkin ()
 

Public Attributes

ColorType colorType
 
LayoutGroup layoutButtons
 
int selectOnInitialize
 
bool colorWhenSelected
 
bool checkbox
 
bool loopNavigation
 
bool autoInitialize = true
 
bool selectOnClick = true
 
bool useIcon
 
bool useTransition = true
 
bool fixRefreshButtons
 
bool colorWhenDisabled
 
Color colorDefault
 
Color colorSelected
 
Color colorNoSelection
 
Color colorDisabled
 
SkinRootStatic rootSkin
 
UIButton selected
 
List< UIButtonlist = new List<UIButton>()
 
UnityAction< int > onClick
 

Properties

SkinRootStatic Skin [get]
 

Private Member Functions

void Awake ()
 
void OnDisable ()
 
void LateUpdate ()
 

Private Attributes

SkinColorProfileEx.GroupColors colors
 
bool refreshButtons
 

Detailed Description

Definition at line 7 of file UISelectableGroup.cs.

Member Enumeration Documentation

◆ ColorType

Enumerator
General 
Tab 
DontChange 

Definition at line 9 of file UISelectableGroup.cs.

Member Function Documentation

◆ AddButton()

UIButton UISelectableGroup.AddButton ( UIButton  mold,
string  text 
)
inline

Definition at line 105 of file UISelectableGroup.cs.

106 {
107 UIButton uIButton = Util.Instantiate(mold, layoutButtons);
108 uIButton.mainText.text = text;
109 return uIButton;
110 }
LayoutGroup layoutButtons
Definition: Util.cs:10
static Transform Instantiate(string path, Component parent=null)
Definition: Util.cs:67

References layoutButtons, and Util.

◆ ApplySkin()

void UISelectableGroup.ApplySkin ( )
inline

Implements IUISkin.

Definition at line 91 of file UISelectableGroup.cs.

92 {
93 SetColors();
95 }

References RefreshButtons(), and SetColors().

◆ Awake()

void UISelectableGroup.Awake ( )
inlineprivate

Definition at line 74 of file UISelectableGroup.cs.

75 {
76 SetColors();
77 if (!layoutButtons)
78 {
79 layoutButtons = GetComponent<LayoutGroup>();
80 }
82 {
84 }
86 {
87 refreshButtons = true;
88 }
89 }
virtual void Init(int index=0, UnityAction< int > action=null, bool directChildren=false)

References autoInitialize, fixRefreshButtons, Init(), layoutButtons, refreshButtons, selectOnInitialize, and SetColors().

◆ ForceDefaultColor()

void UISelectableGroup.ForceDefaultColor ( bool  useNoSelection = false)
inline

Definition at line 309 of file UISelectableGroup.cs.

310 {
311 selected = null;
312 foreach (UIButton item in list)
313 {
314 item.SetCheck(check: false);
315 if (useNoSelection)
316 {
317 if (useIcon)
318 {
319 item.icon.color = colorNoSelection;
320 }
321 else
322 {
323 item.image.color = colorNoSelection;
324 }
325 }
326 else if (useIcon)
327 {
328 item.icon.color = colorDefault;
329 }
330 else
331 {
332 item.image.color = colorDefault;
333 }
334 }
335 }
List< UIButton > list

References colorDefault, colorNoSelection, item, list, selected, and useIcon.

◆ Init()

virtual void UISelectableGroup.Init ( int  index = 0,
UnityAction< int >  action = null,
bool  directChildren = false 
)
inlinevirtual

Definition at line 147 of file UISelectableGroup.cs.

148 {
149 list.Clear();
150 if (action != null)
151 {
152 onClick = action;
153 }
154 UIButton[] array = (directChildren ? base.transform.GetComponentsInDirectChildren<UIButton>().ToArray() : base.transform.GetComponentsInChildren<UIButton>(includeInactive: true));
155 foreach (UIButton uIButton in array)
156 {
157 if (!uIButton.tag.Contains("IgnoreSelectable") && uIButton.gameObject.activeSelf)
158 {
159 SetButton(uIButton);
160 }
161 }
162 if (checkbox)
163 {
164 selected = null;
166 }
167 else
168 {
169 Select(index);
170 }
171 }
void Select(UIButton button, bool check=true)
void SetButton(UIButton button)
UnityAction< int > onClick

References checkbox, list, onClick, RefreshButtons(), Select(), selected, and SetButton().

Referenced by Awake(), Window.BuildTabs(), BuildMenu.Init(), UIMagicChest.Init(), ContentPopulation.OnSwitchContent(), ActionHint.Refresh(), UIRecipeInfo.Refresh(), UIList.Refresh(), ContentConfigGame.SetGroup(), LayerConfig.SetGroup(), and TerrainMenu.Show().

◆ LateUpdate()

void UISelectableGroup.LateUpdate ( )
inlineprivate

Definition at line 364 of file UISelectableGroup.cs.

365 {
366 if (refreshButtons)
367 {
368 refreshButtons = false;
370 }
371 }

References refreshButtons, and RefreshButtons().

◆ OnDisable()

void UISelectableGroup.OnDisable ( )
inlineprivate

Definition at line 97 of file UISelectableGroup.cs.

98 {
100 {
101 refreshButtons = true;
102 }
103 }

References fixRefreshButtons, and refreshButtons.

◆ RefreshButtons()

void UISelectableGroup.RefreshButtons ( )
inline

Definition at line 230 of file UISelectableGroup.cs.

231 {
232 foreach (UIButton item in list)
233 {
234 if (!item || item.gameObject == null)
235 {
236 continue;
237 }
238 if (colorWhenDisabled && !item.interactable)
239 {
240 item.image.color = colorDisabled;
241 continue;
242 }
243 if (checkbox)
244 {
245 if (useIcon)
246 {
247 item.icon.color = colorDefault;
248 }
249 else
250 {
251 item.image.color = colorDefault;
252 }
253 if (useTransition)
254 {
255 item.selected = false;
256 item.DoNormalTransition();
257 }
258 break;
259 }
261 {
262 item.SetCheck(check: false);
263 if (useIcon)
264 {
265 item.icon.color = colorNoSelection;
266 }
267 else
268 {
269 item.image.color = colorNoSelection;
270 }
271 }
272 else if ((bool)selected && item == selected)
273 {
274 item.SetCheck(check: true);
275 if (useIcon)
276 {
277 item.icon.color = colorSelected;
278 }
279 else
280 {
281 item.image.color = colorSelected;
282 }
283 if (useTransition)
284 {
285 item.selected = true;
286 item.DoNormalTransition();
287 }
288 }
289 else
290 {
291 item.SetCheck(check: false);
292 if (useIcon)
293 {
294 item.icon.color = colorDefault;
295 }
296 else
297 {
298 item.image.color = colorDefault;
299 }
300 if (useTransition)
301 {
302 item.selected = false;
303 item.DoNormalTransition();
304 }
305 }
306 }
307 }

References checkbox, colorDefault, colorDisabled, colorNoSelection, colorSelected, colorWhenDisabled, colorWhenSelected, item, list, selected, useIcon, and useTransition.

Referenced by ApplySkin(), Init(), LateUpdate(), LayerCraft.OnCompleteCraft(), BuildMenu.Refresh(), and Select().

◆ RemoveButton()

void UISelectableGroup.RemoveButton ( UIButton  button)
inline

Definition at line 112 of file UISelectableGroup.cs.

113 {
114 list.Remove(button);
115 }

References list.

◆ Select() [1/4]

void UISelectableGroup.Select ( Func< UIButton, bool >  func)
inline

Definition at line 218 of file UISelectableGroup.cs.

219 {
220 foreach (UIButton item in list)
221 {
222 if (func(item))
223 {
224 Select(item);
225 break;
226 }
227 }
228 }

References item, list, and Select().

◆ Select() [2/4]

void UISelectableGroup.Select ( int  id)
inline

Definition at line 202 of file UISelectableGroup.cs.

203 {
204 Select((id == -1 || id >= list.Count) ? null : list[id]);
205 }

References list, and Select().

◆ Select() [3/4]

void UISelectableGroup.Select ( string  id)
inline

Definition at line 207 of file UISelectableGroup.cs.

208 {
209 foreach (UIButton item in list)
210 {
211 if (item.name == id)
212 {
213 Select(item);
214 }
215 }
216 }

References item, list, and Select().

◆ Select() [4/4]

void UISelectableGroup.Select ( UIButton  button,
bool  check = true 
)
inline

◆ SetButton()

void UISelectableGroup.SetButton ( UIButton  button)
inline

Definition at line 117 of file UISelectableGroup.cs.

118 {
119 list.Add(button);
120 SetGroup(list.Count - 1);
121 if (checkbox)
122 {
123 button.selected = false;
124 button.DoNormalTransition();
125 }
126 }
void DoNormalTransition(bool instant=true)
Definition: UIButton.cs:531

References checkbox, UIButton.DoNormalTransition(), list, and SetGroup().

Referenced by Init().

◆ SetColors()

void UISelectableGroup.SetColors ( )
inline

Definition at line 345 of file UISelectableGroup.cs.

346 {
347 if (colorType != ColorType.DontChange)
348 {
350 if (colorType == ColorType.Tab)
351 {
352 colors = colorsEx.tab;
353 }
354 else
355 {
356 colors = colorsEx.general;
357 }
358 colorDefault = colors.colorDefault;
359 colorSelected = colors.colorSelected;
360 colorNoSelection = colors.colorNoSelection;
361 }
362 }
override SkinColorProfileEx ColorsEx
SkinRootStatic Skin
SkinColorProfileEx.GroupColors colors

References colorDefault, colorNoSelection, colors, colorSelected, SkinRootStatic.ColorsEx, colorType, SkinColorProfileEx.general, Skin, and SkinColorProfileEx.tab.

Referenced by ApplySkin(), and Awake().

◆ SetGroup()

void UISelectableGroup.SetGroup ( int  id)
inline

Definition at line 128 of file UISelectableGroup.cs.

129 {
130 UIButton uIButton = list[id];
131 uIButton.group = this;
132 if (onClick != null)
133 {
134 uIButton.onClick.RemoveAllListeners();
135 uIButton.onClick.AddListener(delegate
136 {
137 onClick(id);
138 });
139 }
140 if (selectOnClick)
141 {
142 uIButton.onClick.RemoveListener(uIButton.Toggle);
143 uIButton.onClick.AddListener(uIButton.Toggle);
144 }
145 }
void Toggle()
Definition: UIButton.cs:322

References list, onClick, selectOnClick, and UIButton.Toggle().

Referenced by SetButton().

◆ SetLoop()

void UISelectableGroup.SetLoop ( )
inline

Definition at line 173 of file UISelectableGroup.cs.

174 {
175 if (loopNavigation)
176 {
177 for (int i = 0; i < list.Count; i++)
178 {
179 Navigation navigation = list[i].navigation;
180 navigation.mode = Navigation.Mode.Explicit;
181 navigation.selectOnLeft = ((i == 0) ? list[list.Count - 1] : list[i - 1]);
182 navigation.selectOnRight = ((i + 1 == list.Count) ? list[0] : list[i + 1]);
183 list[i].navigation = navigation;
184 }
185 }
186 }

References list, and loopNavigation.

◆ ToggleInteractable()

void UISelectableGroup.ToggleInteractable ( bool  enable)
inline

Definition at line 337 of file UISelectableGroup.cs.

338 {
339 foreach (UIButton item in list)
340 {
341 item.interactable = enable;
342 }
343 }

References item, and list.

Referenced by AM_Dig.OnSelectEnd(), AM_Dig.OnSelectStart(), and ActionHint.Refresh().

Member Data Documentation

◆ autoInitialize

bool UISelectableGroup.autoInitialize = true

Definition at line 28 of file UISelectableGroup.cs.

Referenced by Awake().

◆ checkbox

bool UISelectableGroup.checkbox

Definition at line 24 of file UISelectableGroup.cs.

Referenced by Init(), RefreshButtons(), Select(), and SetButton().

◆ colorDefault

Color UISelectableGroup.colorDefault

Definition at line 40 of file UISelectableGroup.cs.

Referenced by ForceDefaultColor(), RefreshButtons(), and SetColors().

◆ colorDisabled

Color UISelectableGroup.colorDisabled

Definition at line 46 of file UISelectableGroup.cs.

Referenced by RefreshButtons().

◆ colorNoSelection

Color UISelectableGroup.colorNoSelection

Definition at line 44 of file UISelectableGroup.cs.

Referenced by ForceDefaultColor(), RefreshButtons(), and SetColors().

◆ colors

SkinColorProfileEx.GroupColors UISelectableGroup.colors
private

Definition at line 50 of file UISelectableGroup.cs.

Referenced by SetColors().

◆ colorSelected

Color UISelectableGroup.colorSelected

Definition at line 42 of file UISelectableGroup.cs.

Referenced by RefreshButtons(), and SetColors().

◆ colorType

ColorType UISelectableGroup.colorType

Definition at line 16 of file UISelectableGroup.cs.

Referenced by SetColors().

◆ colorWhenDisabled

bool UISelectableGroup.colorWhenDisabled

Definition at line 38 of file UISelectableGroup.cs.

Referenced by RefreshButtons().

◆ colorWhenSelected

bool UISelectableGroup.colorWhenSelected

Definition at line 22 of file UISelectableGroup.cs.

Referenced by RefreshButtons().

◆ fixRefreshButtons

bool UISelectableGroup.fixRefreshButtons

Definition at line 36 of file UISelectableGroup.cs.

Referenced by Awake(), and OnDisable().

◆ layoutButtons

LayoutGroup UISelectableGroup.layoutButtons

Definition at line 18 of file UISelectableGroup.cs.

Referenced by AddButton(), and Awake().

◆ list

List<UIButton> UISelectableGroup.list = new List<UIButton>()

◆ loopNavigation

bool UISelectableGroup.loopNavigation

Definition at line 26 of file UISelectableGroup.cs.

Referenced by SetLoop().

◆ onClick

UnityAction<int> UISelectableGroup.onClick

Definition at line 58 of file UISelectableGroup.cs.

Referenced by Init(), and SetGroup().

◆ refreshButtons

bool UISelectableGroup.refreshButtons
private

Definition at line 60 of file UISelectableGroup.cs.

Referenced by Awake(), LateUpdate(), and OnDisable().

◆ rootSkin

SkinRootStatic UISelectableGroup.rootSkin

Definition at line 48 of file UISelectableGroup.cs.

◆ selected

UIButton UISelectableGroup.selected

Definition at line 53 of file UISelectableGroup.cs.

Referenced by ForceDefaultColor(), Init(), RefreshButtons(), and Select().

◆ selectOnClick

bool UISelectableGroup.selectOnClick = true

Definition at line 30 of file UISelectableGroup.cs.

Referenced by SetGroup().

◆ selectOnInitialize

int UISelectableGroup.selectOnInitialize

Definition at line 20 of file UISelectableGroup.cs.

Referenced by Awake().

◆ useIcon

bool UISelectableGroup.useIcon

Definition at line 32 of file UISelectableGroup.cs.

Referenced by ForceDefaultColor(), and RefreshButtons().

◆ useTransition

bool UISelectableGroup.useTransition = true

Definition at line 34 of file UISelectableGroup.cs.

Referenced by RefreshButtons().

Property Documentation

◆ Skin

SkinRootStatic UISelectableGroup.Skin
get

Definition at line 62 of file UISelectableGroup.cs.

63 {
64 get
65 {
66 if (!(rootSkin != null))
67 {
69 }
70 return rootSkin;
71 }
72 }
SkinRootStatic currentSkin
Definition: SkinManager.cs:53
static SkinManager Instance
Definition: SkinManager.cs:78
SkinRootStatic rootSkin

Referenced by SetColors().


The documentation for this class was generated from the following file: