Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ActionToolbarItemEditorUIComponent.c
Go to the documentation of this file.
2 {
3  [Attribute()]
4  protected string m_sIconWidgetName;
5 
6  [Attribute()]
7  protected string m_sToggleWidgetName;
8 
9  protected SCR_BaseToggleToolbarAction m_ToggleAction;
10  protected ImageWidget m_IconWidget;
11  protected ImageWidget m_ToggleWidget;
12  protected SCR_LinkTooltipTargetEditorUIComponent m_TooltipTarget;
13 
14  //------------------------------------------------------------------------------------------------
15  protected void OnToggleChange(int value, bool highlight = false)
16  {
17  m_IconWidget.SetVisible(!highlight);
18  m_ToggleWidget.SetVisible(highlight);
19 
20  if (m_TooltipTarget)
21  {
22  if (highlight)
23  m_TooltipTarget.SetInfo(m_ToggleAction.GetInfoToggled(), m_ToggleAction);
24  else
25  m_TooltipTarget.SetInfo(m_ToggleAction.GetInfo(), m_ToggleAction);
26  }
27  }
28 
29  //------------------------------------------------------------------------------------------------
32  void SetAction(SCR_BaseEditorAction action, Widget widget)
33  {
34  SCR_UIInfo info = action.GetInfo();
35  if (!info)
36  return;
37 
38  //--- Assign tooltip
39  m_TooltipTarget = SCR_LinkTooltipTargetEditorUIComponent.Cast(widget.FindHandler(SCR_LinkTooltipTargetEditorUIComponent));
40  if (m_TooltipTarget)
41  m_TooltipTarget.SetInfo(info, action);
42 
43  //---Assign icon (or exit if it's not available)
44  m_IconWidget = ImageWidget.Cast(widget.FindAnyWidget(m_sIconWidgetName));
45  if (!m_IconWidget)
46  return;
47 
48  info.SetIconTo(m_IconWidget);
49 
50  //--- Recolor the icon according to action's UI info
51  SCR_ColorUIInfo colorInfo = SCR_ColorUIInfo.Cast(info);
52  if (colorInfo)
53  m_IconWidget.SetColor(colorInfo.GetColor());
54 
55  //--- Initialize toggling if available
56  m_ToggleWidget = ImageWidget.Cast(widget.FindAnyWidget(m_sToggleWidgetName));
57  if (m_ToggleWidget)
58  {
59  m_ToggleWidget.SetVisible(false);
60 
61  m_ToggleAction = SCR_BaseToggleToolbarAction.Cast(action);
62  if (m_ToggleAction)
63  {
64  if (m_ToggleAction.GetInfoToggled())
65  m_ToggleAction.GetInfoToggled().SetIconTo(m_ToggleWidget);
66  else
67  info.SetIconTo(m_ToggleWidget);
68 
69  m_ToggleAction.GetOnToggleChange().Insert(OnToggleChange);
70  m_ToggleAction.Track();
71  }
72  }
73  }
74 
75  //------------------------------------------------------------------------------------------------
76  override void HandlerDeattached(Widget w)
77  {
78  super.HandlerDeattached(w);
79 
80  if (m_ToggleAction)
81  {
82  m_ToggleAction.GetOnToggleChange().Remove(OnToggleChange);
83  m_ToggleAction.Untrack();
84  }
85  }
86 }
SCR_ColorUIInfo
Definition: SCR_ColorUIInfo.c:2
SCR_BaseEditorAction
Definition: SCR_BaseEditorAction.c:24
m_sIconWidgetName
protected string m_sIconWidgetName
Definition: SCR_GroupEditableEntityUIComponent.c:6
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_BaseToggleToolbarAction
Definition: SCR_BaseToggleToolbarAction.c:3
SCR_UIInfo
Definition: SCR_UIInfo.c:7
SCR_BaseToolbarItemEditorUIComponent
Definition: SCR_BaseToolbarItemEditorUIComponent.c:1
SCR_ActionToolbarItemEditorUIComponent
Definition: SCR_ActionToolbarItemEditorUIComponent.c:1