Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SelectionMenuEntryComponent.c
Go to the documentation of this file.
1 
5 //------------------------------------------------------------------------------------------------
7 {
8  [Attribute("0.4")]
9  protected float m_fDisabledOpacity;
10 
11  [Attribute("Size")]
12  protected string m_sSizeLayout;
13 
14  protected SCR_SelectionMenuEntry m_Entry;
15 
16  protected bool m_bEnabled = true;
17  protected float m_fOriginalSize;
18  protected float m_fAdjustedSize;
19 
20  protected Widget m_wSizeLayout;
21 
22  // Invokers
23  protected ref ScriptInvoker<SCR_SelectionMenuEntryComponent> m_OnMouseEnter;
24  protected ref ScriptInvoker<SCR_SelectionMenuEntryComponent> m_OnMouseLeave;
25 
26  //------------------------------------------------------------------------------------------------
27  protected void InvokeOnMouseEnter()
28  {
29  if (m_OnMouseEnter)
30  m_OnMouseEnter.Invoke(this);
31  }
32 
33  //------------------------------------------------------------------------------------------------
34  ScriptInvoker GetOnMouseEnter()
35  {
36  if (!m_OnMouseEnter)
37  m_OnMouseEnter = new ScriptInvoker();
38 
39  return m_OnMouseEnter;
40  }
41 
42  //------------------------------------------------------------------------------------------------
43  protected void InvokeOnMouseLeave()
44  {
45  if (m_OnMouseLeave)
46  m_OnMouseLeave.Invoke(this);
47  }
48 
49  //------------------------------------------------------------------------------------------------
50  ScriptInvoker GetOnMouseLeave()
51  {
52  if (!m_OnMouseLeave)
53  m_OnMouseLeave = new ScriptInvoker();
54 
55  return m_OnMouseLeave;
56  }
57 
58  //------------------------------------------------------------------------------------------------
59  protected void InvokeOnClick()
60  {
61  if (m_OnClick)
62  m_OnClick.Invoke(this);
63  }
64 
65  //------------------------------------------------------------------------------------------------
66  ScriptInvoker GetOnClick()
67  {
68  if (!m_OnClick)
69  m_OnClick = new ScriptInvoker();
70 
71  return m_OnClick;
72  }
73 
74  //------------------------------------------------------------------------------------------------
75  // Override
76  //------------------------------------------------------------------------------------------------
77 
78  //------------------------------------------------------------------------------------------------
79  override void HandlerAttached(Widget w)
80  {
81  super.HandlerAttached(w);
82 
83  SetEnabled(m_bEnabled);
84 
85  m_wSizeLayout = m_wRoot.FindAnyWidget(m_sSizeLayout);
86  m_fOriginalSize = GetLayoutSize();
87  m_fAdjustedSize = m_fOriginalSize;
88  }
89 
90  //------------------------------------------------------------------------------------------------
91  override bool OnMouseEnter(Widget w, int x, int y)
92  {
93  InvokeOnMouseEnter();
94  return false;
95  }
96 
97  //------------------------------------------------------------------------------------------------
98  override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
99  {
100  InvokeOnMouseLeave();
101  return false;
102  }
103 
104  //------------------------------------------------------------------------------------------------
105  override bool OnClick(Widget w, int x, int y, int button)
106  {
107  if (button == 0)
108  InvokeOnClick();
109 
110  return false;
111  }
112 
113  //------------------------------------------------------------------------------------------------
114  // Custom
115  //------------------------------------------------------------------------------------------------
116 
117  //------------------------------------------------------------------------------------------------
118  void SetEnabled(bool enabled)
119  {
120  m_bEnabled = enabled;
121 
122  if (!m_wRoot)
123  return;
124 
125  // Set visuals
126  if (m_bEnabled)
127  m_wRoot.SetOpacity(1);
128  else
129  m_wRoot.SetOpacity(m_fDisabledOpacity);
130  }
131 
132  //------------------------------------------------------------------------------------------------
133  float GetLayoutSize()
134  {
135  if (!m_wSizeLayout)
136  return -1;
137 
138  return FrameSlot.GetSize(m_wSizeLayout)[0];
139  }
140 
141  //------------------------------------------------------------------------------------------------
143  void SetEntry(SCR_SelectionMenuEntry entry)
144  {
145  m_Entry = entry;
146  }
147 
148  //------------------------------------------------------------------------------------------------
149  float GetOriginalSize()
150  {
151  return m_fOriginalSize;
152  }
153 
154  //------------------------------------------------------------------------------------------------
155  float GetAdjustedSize()
156  {
157  return m_fAdjustedSize;
158  }
159 }
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
m_OnMouseEnter
ref ScriptInvoker m_OnMouseEnter
Definition: SCR_ModularButtonComponent.c:65
m_Entry
SCR_MapJournalUI m_Entry
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_SelectionMenuEntryComponent
Definition: SCR_SelectionMenuEntryComponent.c:6
m_bEnabled
private bool m_bEnabled
Definition: SCR_BaseManualCameraComponent.c:3
SCR_SelectionMenuEntry
Definition: SCR_SelectionMenuEntry.c:7
SCR_ScriptedWidgetComponent
Definition: SCR_ScriptedWidgetComponent.c:7
m_OnMouseLeave
ref ScriptInvoker m_OnMouseLeave
Definition: SCR_ModularButtonComponent.c:66
m_OnClick
ref ScriptInvoker m_OnClick
Definition: SCR_MapToolMenuUI.c:13