Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CheckboxEditorAttributeUIComponent.c
Go to the documentation of this file.
1 
4 {
5  protected SCR_SelectionWidgetComponent m_SelectionBoxComponent;
6 
7  override void Init(Widget w, SCR_BaseEditorAttribute attribute)
8  {
9  Widget checkboxWidget = w.FindAnyWidget(m_sUiComponentName);
10  if (!checkboxWidget)
11  return;
12 
13  m_SelectionBoxComponent = SCR_SelectionWidgetComponent.Cast(checkboxWidget.FindHandler(SCR_SelectionWidgetComponent));
14  if (!m_SelectionBoxComponent)
15  return;
16 
17  m_SelectionBoxComponent.m_OnChanged.Insert(OnChangeCheckbox);
18 
19  super.Init(w, attribute);
20  }
21 
22  //Sets a default state for the UI and var value if conflicting attribute
23  override void SetVariableToDefaultValue(SCR_BaseEditorAttributeVar var)
24  {
25  m_SelectionBoxComponent.SetCurrentItem(0);
26 
27  if (var)
28  var.SetBool(false);
29  }
30 
31  override void SetFromVar(SCR_BaseEditorAttributeVar var)
32  {
33  super.SetFromVar(var);
34 
35  if (!var)
36  return;
37 
38  m_SelectionBoxComponent.SetCurrentItem((int)var.GetBool(), false, false);
39  }
40 
41  protected void OnChangeCheckbox(SCR_SelectionWidgetComponent selectionBox, bool value)
42  {
43  OnChange(selectionBox.GetRootWidget(), value, 0, false);
44  }
45 
46  override bool OnChange(Widget w, int x, int y, bool finished)
47  {
48  if (!m_SelectionBoxComponent)
49  return false;
50 
51  SCR_BaseEditorAttribute attribute = GetAttribute();
52  if (!attribute) return false;
53 
54  SCR_BaseEditorAttributeVar var = attribute.GetVariable(true);
55 
56  if (var.GetBool() == x)
57  return false;
58 
59  var.SetBool(x);
60  super.OnChange(w, x, y, finished);
61  return false;
62  }
63 
64  override void HandlerDeattached(Widget w)
65  {
66  if (m_SelectionBoxComponent)
67  m_SelectionBoxComponent.m_OnChanged.Remove(OnChangeCheckbox);
68  }
69 };
SCR_CheckboxEditorAttributeUIComponent
Definition: SCR_CheckboxEditorAttributeUIComponent.c:3
SCR_BaseEditorAttributeVar
Definition: SCR_BaseEditorAttributeVar.c:1
SCR_BaseEditorAttribute
Base Attribute Script for other attributes to inherent from to get and set varriables in Editor Attri...
Definition: SCR_BaseEditorAttribute.c:3
SCR_BaseEditorAttributeUIComponent
Definition: SCR_BaseEditorAttributeUIComponent.c:3
SCR_SelectionWidgetComponent
Definition: SCR_SelectionWidgetComponent.c:1