Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
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;
26  protected ImageWidget m_TextureWidget;
27  protected ref map<Widget, float> m_Labels = new map<Widget, float>;
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 
51  override void HandlerAttachedScripted(Widget w)
52  {
53  MenuRootBase menu = GetMenu();
54  if (!menu) return;
55 
56  m_World = GetGame().GetWorld();
57  if (!m_World) return;
58 
59  m_TextureWidget = ImageWidget.Cast(w.FindAnyWidget(m_sTextureWidgetName));
60  if (!m_TextureWidget) return;
61 
62  m_Labels.Insert(w.FindAnyWidget(m_sEastWidgetName), 0);
63  m_Labels.Insert(w.FindAnyWidget(m_sSouthWidgetName), Math.PI * 0.5);
64  m_Labels.Insert(w.FindAnyWidget(m_sWestWidgetName), Math.PI);
65  m_Labels.Insert(w.FindAnyWidget(m_sNorthWidgetName), Math.PI * 1.5);
66 
67  m_fLabelsDistance *= 0.5 * FrameSlot.GetSizeY(w);
68 
69  menu.GetOnMenuUpdate().Insert(UpdateRotation);
70  }
71  override void HandlerDeattached(Widget w)
72  {
73  MenuRootBase menu = GetMenu();
74  if (menu)
75  {
76  menu.GetOnMenuUpdate().Remove(UpdateRotation);
77  }
78  }
79 };
MenuRootSubComponent
Definition: MenuRootSubComponent.c:5
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_CompassUIComponent
Definition: SCR_CompassUIComponent.c:5
GetMenu
SCR_RadialMenu GetMenu()
Definition: SCR_RadialMenuGameModeComponent.c:41
Attribute
typedef Attribute
Post-process effect of scripted camera.
MenuRootBase
Definition: MenuRootBase.c:6
m_World
protected BaseWorld m_World
Definition: SCR_PreviewEntityEditorUIComponent.c:46
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24