Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MapCompassUI.c
Go to the documentation of this file.
1
3{
4 protected static const string ICON_NAME = "compass";
5
7 protected string m_sPrefabResource;
8
9 //------------------------------------------------------------------------------------------------
10 override void SetWidgetNames()
11 {
12 WIDGET_NAME = "CompassFrame";
13 RT_WIDGET_NAME = "CompRTW";
14 WORLD_NAME = "CompassUIWorld";
15 }
16
17 //------------------------------------------------------------------------------------------------
18 override void InitPositionVectors()
19 {
21
22 m_vPrefabPos = "0 0 0";
23 m_vCameraPos = m_CompassComp.GetMapCamPosition();
24 m_vCameraAngle = "0 -90 0";
25 }
26
27 //------------------------------------------------------------------------------------------------
29 protected void UpdateCompassEntity()
30 {
31 if (m_CompassComp)
32 {
34 if (!player || !player.GetCharacterController())
35 return;
36
37 vector anglesCompass = vector.Zero;
38 anglesCompass[1] = player.GetCharacterController().GetInputContext().GetHeadingAngle() * Math.RAD2DEG;
39
40 // if player is inside the vehicle - check for the vehicle rotation instead
41 // GetHeadingAngle returns the wrong value when in vehicle and map is opened
42 if (player.IsInVehicle())
43 {
44 anglesCompass[1] = player.GetAngles()[1];
45 }
46
47 m_RTEntity.SetAngles(anglesCompass);
48
49 // activate, apply proc anims
50 if (m_CompassComp.GetMode() != EGadgetMode.IN_HAND)
51 m_CompassComp.SetMapMode();
52
53 // tick the frame
54 float tick = System.GetFrameTimeS();
55 m_CompassComp.Update( tick );
56 }
57
58 // update
59 BaseWorld previewWorld = m_RTWorld.GetRef();
60 previewWorld.UpdateEntities();
61 }
62
63 //------------------------------------------------------------------------------------------------
64 protected void OnInputQuickBind(float value, EActionTrigger reason)
65 {
66 if (!GetGame().GetInputManager().IsUsingMouseAndKeyboard() && IsToolMenuFocused())
67 return;
69 }
70
71 //------------------------------------------------------------------------------------------------
72 protected override string GetPrefabResource()
73 {
74 return m_sPrefabResource;
75 }
76
77 //------------------------------------------------------------------------------------------------
78 override void SetVisible(bool visible)
79 {
80 if (visible)
81 {
82 IEntity compass = FindRelatedGadget();
83 if (!compass)
84 {
85 super.SetVisible(false);
86 return;
87 }
88
90 if (!compassComp)
91 return;
92
94
95 super.SetVisible(visible);
96 if (!m_RTWorld || !m_RTEntity)
97 return;
98
99 // Start anim
100 ScriptCallQueue queue = GetGame().GetCallqueue();
101 if (queue)
102 queue.CallLater(UpdateCompassEntity, 0, true);
103
105 m_CompassComp.Init2DMapCompass();
106 }
107 else
108 {
109 // stop anim
110 ScriptCallQueue queue = GetGame().GetCallqueue();
111 if (queue)
112 queue.Remove(UpdateCompassEntity);
113
114 super.SetVisible(visible);
115 }
116 }
117
118 //------------------------------------------------------------------------------------------------
119 override void Init()
120 {
121 SCR_MapToolMenuUI toolMenu = SCR_MapToolMenuUI.Cast(m_MapEntity.GetMapUIComponent(SCR_MapToolMenuUI));
122 if (toolMenu)
123 {
124 m_ToolMenuEntry = toolMenu.RegisterToolMenuEntry(SCR_MapToolMenuUI.s_sToolMenuIcons, ICON_NAME, 11, m_bIsExclusive);
125 m_ToolMenuEntry.m_OnClick.Insert(ToggleVisible);
126
127 GetGame().GetInputManager().AddActionListener("MapToolCompass", EActionTrigger.DOWN, OnInputQuickBind);
128 }
129 }
130
131 //------------------------------------------------------------------------------------------------
132 override void Update(float timeSlice)
133 {
134 // Drag compass
136 {
137 // apply shake
138 m_CompassComp.DragMapCompass();
139
140 // save compass position for map reopen
141 WorkspaceWidget workspace = g_Game.GetWorkspace();
142 m_wFrame.GetScreenPos(m_fPosX, m_fPosY);
143 m_fPosX = workspace.DPIUnscale(m_fPosX);
144 m_fPosY = workspace.DPIUnscale(m_fPosY);
145 }
146 }
147
148 //------------------------------------------------------------------------------------------------
149 // constructor
151 {
152 m_eGadgetType = EGadgetType.COMPASS;
153 }
154}
ArmaReforgerScripted GetGame()
Definition game.c:1398
InputManager GetInputManager()
SCR_MapToolEntry m_ToolMenuEntry
SCR_MapEntity m_MapEntity
string RT_WIDGET_NAME
IEntity FindRelatedGadget()
vector m_vCameraAngle
bool m_bIsVisible
vector m_vPrefabPos
void ToggleVisible()
Visibility toggle.
vector m_vCameraPos
string WORLD_NAME
GenericEntity m_RTEntity
float m_fPosY
void SCR_MapRTWBaseUI()
float m_fPosX
string WIDGET_NAME
bool m_bIsDragged
Widget m_wFrame
ref SharedItemRef m_RTWorld
EGadgetType m_eGadgetType
void SCR_MapToolMenuUI()
proto external Managed FindComponent(typename typeName)
Definition Math.c:13
ResourceName GetMapPrefabResource()
override void SetVisible(bool visible)
override string GetPrefabResource()
static const string ICON_NAME
SCR_CompassComponent m_CompassComp
void OnInputQuickBind(float value, EActionTrigger reason)
override void Update(float timeSlice)
override void Init()
void UpdateCompassEntity()
Update for the compass entity within preview world.
override void SetWidgetNames()
override void InitPositionVectors()
static IEntity GetLocalControlledEntity()
ScriptCallQueue Class provide "lazy" calls - when we don't want to execute function immediately but l...
Definition tools.c:53
Game g_Game
Game singleton instance.
Definition gameLib.c:13
EActionTrigger