Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_QuickPlacingEditorUIComponent.c
Go to the documentation of this file.
1
2
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 //------------------------------------------------------------------------------------------------
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}
SCR_RadialMenu GetMenu()
Component to execute action when the button or its shortcut is pressed.
Definition Math.c:13
ScriptInvoker GetOnMenuUpdate()
override bool OnMouseEnter(Widget w, int x, int y)
void SetCoef(float coef, bool instant=false)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
override void Show()
Definition gameLib.c:262
SCR_FieldOfViewSettings Attribute
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134