Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_QuickPlacingEditorUIComponent.c
Go to the documentation of this file.
1 
4 {
5  protected static const float ANIMATION_THRESHOLD = 0.01;
6 
7  [Attribute()]
8  private string m_sActiveWidgetName;
9 
10  [Attribute()]
11  private string m_sExpandWidgetName;
12 
13  [Attribute(defvalue: "0.2", uiwidget: UIWidgets.Slider, params: "0 1 0.01")]
14  private float m_fHideCoef;
15 
16  [Attribute(defvalue: "0.1")]
17  private float m_fAnimationStrength;
18 
19  private Widget m_wExpandWidget;
20  private float m_fDefaultOffset;
21  private float m_fCurrentCoef;
22  private bool m_bShown;
23 
24  //------------------------------------------------------------------------------------------------
25  protected void Show(bool show)
26  {
27  if (show == m_bShown)
28  return;
29 
30  m_bShown = show;
31  if (show)
32  SetCoef(1);
33  else
34  SetCoef(m_fHideCoef);
35  }
36 
37  //------------------------------------------------------------------------------------------------
38  protected void SetCoef(float coef, bool instant = false)
39  {
40  m_fCurrentCoef = coef;
41  if (instant)
42  {
43  SetOffsets(1);
44  }
45  else
46  {
47  MenuRootBase menu = GetMenu();
48  if (menu)
49  menu.GetOnMenuUpdate().Insert(OnMenuUpdate);
50  }
51  }
52 
53  //------------------------------------------------------------------------------------------------
54  protected bool SetOffsets(float progress)
55  {
56  float offsetLeft, offsetTop, offsetRight, offsetBottom;
57  FrameSlot.GetOffsets(m_wExpandWidget, offsetLeft, offsetTop, offsetRight, offsetBottom);
58 
59  offsetTop = Math.Lerp(offsetTop, m_fDefaultOffset * m_fCurrentCoef, progress);
60  offsetBottom = Math.Lerp(offsetBottom, m_fDefaultOffset * (1 - m_fCurrentCoef), progress);
61 
62  FrameSlot.SetOffsets(m_wExpandWidget, offsetLeft, offsetTop, offsetRight, offsetBottom);
63 
64  return Math.AbsFloat(offsetTop - m_fDefaultOffset * m_fCurrentCoef) < ANIMATION_THRESHOLD;
65  }
66 
67  //------------------------------------------------------------------------------------------------
68  protected void OnMenuUpdate(float tDelta)
69  {
70  if (SetOffsets(tDelta / m_fAnimationStrength))
71  {
72  MenuRootBase menu = GetMenu();
73  if (menu)
74  menu.GetOnMenuUpdate().Remove(OnMenuUpdate);
75  }
76  }
77 
78  //------------------------------------------------------------------------------------------------
79  protected void OnShortcut(Widget w)
80  {
81  Show(!m_bShown);
82  }
83 
84  //------------------------------------------------------------------------------------------------
85  override bool OnMouseEnter(Widget w, int x, int y)
86  {
87  if (w.GetName() == m_sActiveWidgetName && m_wExpandWidget)
88  Show(true);
89 
90  return false;
91  }
92 
93  //------------------------------------------------------------------------------------------------
94  override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
95  {
96  if (w.GetName() == m_sActiveWidgetName && m_wExpandWidget)
97  Show(false);
98 
99  return false;
100  }
101 
102  //------------------------------------------------------------------------------------------------
103  override void HandlerAttachedScripted(Widget w)
104  {
105  m_wExpandWidget = w.FindAnyWidget(m_sExpandWidgetName);
106  if (!m_wExpandWidget)
107  return;
108 
109  float offsetLeft, offsetTop, offsetRight, offsetBottom;
110  FrameSlot.GetOffsets(m_wExpandWidget, offsetLeft, m_fDefaultOffset, offsetRight, offsetBottom);
111 
112  SetCoef(m_fHideCoef, true);
113 
114  ScriptInvoker onToggle = ButtonActionComponent.GetOnAction(w);
115  if (onToggle)
116  onToggle.Insert(OnShortcut);
117  }
118 
119  //------------------------------------------------------------------------------------------------
120  override void HandlerDeattached(Widget w)
121  {
122  // do nothing
123  }
124 }
m_bShown
protected bool m_bShown
Definition: SCR_InfoDisplay.c:61
GetMenu
SCR_RadialMenu GetMenu()
Definition: SCR_RadialMenuGameModeComponent.c:41
Attribute
typedef Attribute
Post-process effect of scripted camera.
MenuRootBase
Definition: MenuRootBase.c:6
ButtonActionComponent
Component to execute action when the button or its shortcut is pressed.
Definition: ButtonActionComponent.c:2
SCR_BaseEditorUIComponent
Definition: SCR_BaseEditorUIComponent.c:3
SCR_QuickPlacingEditorUIComponent
Definition: SCR_QuickPlacingEditorUIComponent.c:3
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24