Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CompassUIComponent.c
Go to the documentation of this file.
1
6{
7 [Attribute(defvalue: "0.8", uiwidget: UIWidgets.Slider, params: "0 1 0.01")]
8 protected float m_fLabelsDistance;
9
10 [Attribute()]
11 protected string m_sTextureWidgetName;
12
13 [Attribute()]
14 protected string m_sEastWidgetName;
15
16 [Attribute()]
17 protected string m_sSouthWidgetName;
18
19 [Attribute()]
20 protected string m_sWestWidgetName;
21
22 [Attribute()]
23 protected string m_sNorthWidgetName;
24
25 protected BaseWorld m_World;
28
33 void UpdateRotation(float timeSlice)
34 {
35 vector transform[4];
36 m_World.GetCurrentCamera(transform);
37 float yaw = -Math3D.MatrixToAngles(transform)[0];
38 m_TextureWidget.SetRotation(yaw);
39
40 float yawRad = yaw * Math.DEG2RAD;
41 foreach (Widget label, float angle: m_Labels)
42 {
43 FrameSlot.SetPos(
44 label,
45 m_fLabelsDistance * Math.Cos(yawRad + angle),
46 m_fLabelsDistance * Math.Sin(yawRad + angle)
47 );
48 }
49 }
50
52 {
53 MenuRootBase menu = GetMenu();
54 if (!menu)
55 return;
56
57 m_World = GetGame().GetWorld();
58 if (!m_World)
59 return;
60
61 m_TextureWidget = ImageWidget.Cast(w.FindAnyWidget(m_sTextureWidgetName));
62 if (!m_TextureWidget)
63 return;
64
65 m_Labels.Insert(w.FindAnyWidget(m_sEastWidgetName), 0);
66 m_Labels.Insert(w.FindAnyWidget(m_sSouthWidgetName), Math.PI * 0.5);
67 m_Labels.Insert(w.FindAnyWidget(m_sWestWidgetName), Math.PI);
68 m_Labels.Insert(w.FindAnyWidget(m_sNorthWidgetName), Math.PI * 1.5);
69
70 m_fLabelsDistance *= 0.5 * FrameSlot.GetSizeY(w);
71
72 menu.GetOnMenuUpdate().Insert(UpdateRotation);
73 }
74 override void HandlerDeattached(Widget w)
75 {
76 MenuRootBase menu = GetMenu();
77 if (menu)
78 {
79 menu.GetOnMenuUpdate().Remove(UpdateRotation);
80 }
81 }
82};
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_RadialMenu GetMenu()
Definition Math.c:13
ScriptInvoker GetOnMenuUpdate()
override void HandlerDeattached(Widget w)
override void HandlerAttachedScripted(Widget w)
ref map< Widget, float > m_Labels
void UpdateRotation(float timeSlice)
Definition Types.c:486
SCR_FieldOfViewSettings Attribute