Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_MapWatchUI.c
Go to the documentation of this file.
2 {
3  protected static const string ICON_NAME = "watch";
4 
5  protected SCR_WristwatchComponent m_WristwatchComp;
6  protected string m_sPrefabResource;
7 
8  //------------------------------------------------------------------------------------------------
9  override void SetWidgetNames()
10  {
11  WIDGET_NAME = "WatchFrame";
12  RT_WIDGET_NAME = "WatchRTW";
13  WORLD_NAME = "WatchUIWorld";
14  }
15 
16  //------------------------------------------------------------------------------------------------
17  override void InitPositionVectors()
18  {
19  m_WristwatchComp = SCR_WristwatchComponent.Cast( m_RTEntity.FindComponent(SCR_WristwatchComponent) );
20 
21  m_vPrefabPos = "0 0 0";
22  m_vCameraPos = "0 0.14 0";
23  m_vCameraAngle = "0 -90 0";
24  }
25 
26  //------------------------------------------------------------------------------------------------
28  protected void UpdatePreviewEntity()
29  {
30  if (m_WristwatchComp)
31  {
32  // activate, apply proc anims
33  if (m_WristwatchComp.GetMode() != EGadgetMode.IN_HAND)
34  m_WristwatchComp.SetMapMode();
35 
36  // tick the frame
37  m_WristwatchComp.UpdateTime();
38  }
39 
40  // update
41  BaseWorld previewWorld = m_RTWorld.GetRef();
42  previewWorld.UpdateEntities();
43  }
44 
45  //------------------------------------------------------------------------------------------------
46  protected void OnInputQuickBind(float value, EActionTrigger reason)
47  {
48  SetVisible(!m_bIsVisible);
49  }
50 
51  //------------------------------------------------------------------------------------------------
52  protected override string GetPrefabResource()
53  {
54  return m_sPrefabResource;
55  }
56 
57  //------------------------------------------------------------------------------------------------
60  override void SetVisible(bool visible)
61  {
62  if (visible)
63  {
64  IEntity wristwatch = FindRelatedGadget();
65  if (!wristwatch)
66  {
67  super.SetVisible(false);
68  return;
69  }
70 
71  SCR_WristwatchComponent watchComp = SCR_WristwatchComponent.Cast(wristwatch.FindComponent(SCR_WristwatchComponent));
72  if (!watchComp)
73  return;
74 
75  m_sPrefabResource = watchComp.GetMapPrefabResource();
76 
77  super.SetVisible(visible);
78  if (!m_RTWorld || !m_RTEntity)
79  return;
80 
81  // Start anim
82  ScriptCallQueue queue = GetGame().GetCallqueue();
83  if (queue)
84  queue.CallLater(UpdatePreviewEntity, 0, true);
85  }
86  else
87  {
88  ScriptCallQueue queue = GetGame().GetCallqueue();
89  if (queue)
90  queue.Remove(UpdatePreviewEntity);
91 
92  super.SetVisible(visible);
93  }
94  }
95 
96  //------------------------------------------------------------------------------------------------
97  override void Init()
98  {
99  SCR_MapToolMenuUI toolMenu = SCR_MapToolMenuUI.Cast(m_MapEntity.GetMapUIComponent(SCR_MapToolMenuUI));
100  if (toolMenu)
101  {
102  m_ToolMenuEntry = toolMenu.RegisterToolMenuEntry(SCR_MapToolMenuUI.s_sToolMenuIcons, ICON_NAME, 12); // add to menu
103  m_ToolMenuEntry.m_OnClick.Insert(ToggleVisible);
104 
105  GetGame().GetInputManager().AddActionListener("MapToolWatch", EActionTrigger.DOWN, OnInputQuickBind);
106  }
107  }
108 
109  //------------------------------------------------------------------------------------------------
110  override void Update(float timeSlice)
111  {
112  // Drag watch
113  if (m_bIsVisible && m_bIsDragged)
114  {
115  // save position for map reopen
116  WorkspaceWidget workspace = g_Game.GetWorkspace();
117  m_wFrame.GetScreenPos(m_fPosX, m_fPosY);
118  m_fPosX = workspace.DPIUnscale(m_fPosX);
119  m_fPosY = workspace.DPIUnscale(m_fPosY);
120  }
121  }
122 
123  //------------------------------------------------------------------------------------------------
124  // constructor
125  void SCR_MapWatchUI()
126  {
127  m_eGadgetType = EGadgetType.WRISTWATCH;
128  }
129 }
ToggleVisible
protected void ToggleVisible()
Visibility toggle.
Definition: SCR_MapRTWBaseUI.c:87
m_MapEntity
protected SCR_MapEntity m_MapEntity
Definition: SCR_MapGadgetComponent.c:14
WIDGET_NAME
protected string WIDGET_NAME
Definition: SCR_MapRTWBaseUI.c:21
SCR_MapRTWBaseUI
void SCR_MapRTWBaseUI()
Definition: SCR_MapRTWBaseUI.c:300
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_ToolMenuEntry
protected SCR_MapToolEntry m_ToolMenuEntry
Definition: SCR_MapDrawingUI.c:182
FindRelatedGadget
IEntity FindRelatedGadget()
Definition: SCR_MapRTWBaseUI.c:74
m_fPosX
protected float m_fPosX
Definition: SCR_MapRTWBaseUI.c:34
m_vCameraPos
protected vector m_vCameraPos
Definition: SCR_MapRTWBaseUI.c:26
m_RTWorld
protected ref SharedItemRef m_RTWorld
Definition: SCR_MapRTWBaseUI.c:38
m_bIsDragged
protected bool m_bIsDragged
Definition: SCR_MapRTWBaseUI.c:31
RT_WIDGET_NAME
protected string RT_WIDGET_NAME
Definition: SCR_MapRTWBaseUI.c:22
m_vPrefabPos
protected vector m_vPrefabPos
Definition: SCR_MapRTWBaseUI.c:25
m_RTEntity
protected GenericEntity m_RTEntity
Definition: SCR_MapRTWBaseUI.c:37
SCR_MapWatchUI
Definition: SCR_MapWatchUI.c:1
m_vCameraAngle
protected vector m_vCameraAngle
Definition: SCR_MapRTWBaseUI.c:27
WORLD_NAME
protected string WORLD_NAME
Definition: SCR_MapRTWBaseUI.c:24
m_bIsVisible
protected bool m_bIsVisible
Definition: SCR_MapRTWBaseUI.c:29
m_fPosY
protected float m_fPosY
Definition: SCR_MapRTWBaseUI.c:34
m_eGadgetType
protected EGadgetType m_eGadgetType
Definition: SCR_MapRTWBaseUI.c:36
SCR_MapToolMenuUI
void SCR_MapToolMenuUI()
Definition: SCR_MapToolMenuUI.c:389
m_wFrame
protected Widget m_wFrame
Definition: SCR_MapRTWBaseUI.c:42