Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_MapGadgetComponent.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/Gadgets", description: "Map gadget", color: "0 0 255 255")]
3 {
4 }
5 
7 class SCR_MapGadgetComponent : SCR_GadgetComponent
8 {
9  [Attribute("0.3", UIWidgets.EditBox, desc: "seconds, delay before map gets activated giving time for the animation to be visible", params: "1 1000", category: "Map")]
10  protected float m_fActivationDelay;
11 
12  protected bool m_bIsMapOpen;
13  protected bool m_bIsFirstTimeOpened = true; // whether the map has bene opened since put into a lot
14  protected SCR_MapEntity m_MapEntity; // map instance
16 
17  //------------------------------------------------------------------------------------------------
20  void SetMapMode(bool state)
21  {
23  return;
24 
25  // no delay/fade for forced cancel
27  ECharacterLifeState lifeState = controller.GetLifeState();
28  float delay;
29  if (lifeState != ECharacterLifeState.DEAD)
30  delay = m_fActivationDelay * 1000;
31 
32  GetGame().GetCallqueue().Remove(ToggleMapGadget);
33 
34  if (state)
35  {
36  GetGame().GetCallqueue().CallLater(ToggleMapGadget, delay, false, true);
37 
39  m_FadeInOutEffect.FadeOutEffect(true, m_fActivationDelay); // fade out after map open
40  }
41  else
42  {
43  GetGame().GetCallqueue().CallLater(ToggleMapGadget, delay, false, false);
44 
45  if (lifeState != ECharacterLifeState.DEAD && m_FadeInOutEffect)
46  {
47  if (m_MapEntity.IsOpen())
48  m_FadeInOutEffect.FadeOutEffect(true, m_fActivationDelay); // fade out on map close
49  else
50  m_FadeInOutEffect.FadeOutEffect(false, m_fActivationDelay); // in case map is closed fast before it opens, fade in from close map wont trigger, so it has to happen here
51  }
52  }
53  }
54 
55  //------------------------------------------------------------------------------------------------
58  protected void ToggleMapGadget(bool state)
59  {
60  if (state)
61  {
62  SCR_MapEntity.GetOnMapOpen().Insert(OnMapOpen);
63  SCR_MapEntity.GetOnMapClose().Insert(OnMapClose);
64 
65  MenuManager menuManager = g_Game.GetMenuManager();
66  menuManager.OpenMenu(ChimeraMenuPreset.MapMenu);
67  m_bIsMapOpen = true;
68  }
69  else
70  {
71  MenuManager menuManager = g_Game.GetMenuManager();
72  menuManager.CloseMenuByPreset(ChimeraMenuPreset.MapMenu);
73  m_bIsMapOpen = false;
74  }
75  }
76 
77  //------------------------------------------------------------------------------------------------
80  protected void OnMapOpen(MapConfiguration config)
81  {
83  m_FadeInOutEffect.FadeOutEffect(false, m_fActivationDelay); // fade in after map open
84 
85  // first open
87  return;
88 
89  m_bIsFirstTimeOpened = false;
90  m_MapEntity.ZoomOut();
91  }
92 
93  //------------------------------------------------------------------------------------------------
96  protected void OnMapClose(MapConfiguration config)
97  {
99  m_FadeInOutEffect.FadeOutEffect(false, m_fActivationDelay); // fade in after map close
100 
101  SCR_MapEntity.GetOnMapOpen().Remove(OnMapOpen);
102  SCR_MapEntity.GetOnMapClose().Remove(OnMapClose);
103  }
104 
105  //------------------------------------------------------------------------------------------------
106  override void ModeSwitch(EGadgetMode mode, IEntity charOwner)
107  {
108  super.ModeSwitch(mode, charOwner);
109 
110  if (mode == EGadgetMode.ON_GROUND)
111  m_bIsFirstTimeOpened = true;
112 
113  // not current player
114  IEntity controlledEnt = SCR_PlayerController.GetLocalControlledEntity();
115  if ( !controlledEnt || controlledEnt != m_CharacterOwner)
116  return;
117 
118  if (mode != EGadgetMode.IN_HAND)
119  return;
120 
122  if (!playerController)
123  return;
124 
125  SCR_HUDManagerComponent hudManager = SCR_HUDManagerComponent.Cast(playerController.GetHUDManagerComponent());
126  if (hudManager)
127  m_FadeInOutEffect = SCR_FadeInOutEffect.Cast(hudManager.FindInfoDisplay(SCR_FadeInOutEffect));
128 
129  ToggleFocused(true);
130  }
131 
132  //------------------------------------------------------------------------------------------------
133  override void ModeClear(EGadgetMode mode)
134  {
135  // not current player
136  IEntity controlledEnt = SCR_PlayerController.GetLocalControlledEntity();
137  if ( !controlledEnt || controlledEnt != m_CharacterOwner )
138  {
139  super.ModeClear(mode);
140  return;
141  }
142 
143  if (mode == EGadgetMode.IN_HAND)
144  {
145  if (m_bFocused)
146  ToggleFocused(false);
147  }
148 
149  super.ModeClear(mode);
150  }
151 
152  //------------------------------------------------------------------------------------------------
153  override void ToggleFocused(bool enable)
154  {
155  super.ToggleFocused(enable);
156 
157  SetMapMode(enable);
158  }
159 
160  //------------------------------------------------------------------------------------------------
161  override EGadgetType GetType()
162  {
163  return EGadgetType.MAP;
164  }
165 
166  //------------------------------------------------------------------------------------------------
167  override void EOnInit(IEntity owner)
168  {
169  if (!m_MapEntity)
170  m_MapEntity = SCR_MapEntity.GetMapInstance();
171  }
172 }
SCR_HUDManagerComponent
Definition: SCR_HUDManagerComponent.c:23
m_MapEntity
protected SCR_MapEntity m_MapEntity
Definition: SCR_MapGadgetComponent.c:14
SCR_PlayerController
Definition: SCR_PlayerController.c:31
m_bIsFirstTimeOpened
protected bool m_bIsFirstTimeOpened
Definition: SCR_MapGadgetComponent.c:13
ModeClear
override void ModeClear(EGadgetMode mode)
Definition: SCR_MapGadgetComponent.c:133
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
ECharacterLifeState
ECharacterLifeState
Definition: ECharacterLifeState.c:12
SCR_FadeInOutEffect
Definition: SCR_FadeInOutEffect.c:1
Attribute
SCR_MapGadgetComponentClass SCR_GadgetComponentClass Attribute("0.3", UIWidgets.EditBox, desc:"seconds, delay before map gets activated giving time for the animation to be visible", params:"1 1000", category:"Map")] protected float m_fActivationDelay
Map gadget component.
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_GadgetComponentClass
Definition: SCR_GadgetComponent.c:2
ToggleFocused
override void ToggleFocused(bool enable)
Definition: SCR_MapGadgetComponent.c:153
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_CharacterControllerComponent
Definition: SCR_CharacterControllerComponent.c:35
GetPlayerController
proto external PlayerController GetPlayerController()
Definition: SCR_PlayerDeployMenuHandlerComponent.c:307
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
ToggleMapGadget
protected void ToggleMapGadget(bool state)
Definition: SCR_MapGadgetComponent.c:58
ModeSwitch
override void ModeSwitch(EGadgetMode mode, IEntity charOwner)
Definition: SCR_MapGadgetComponent.c:106
m_FadeInOutEffect
protected SCR_FadeInOutEffect m_FadeInOutEffect
Definition: SCR_MapGadgetComponent.c:15
m_CharacterOwner
SCR_RplTestComponentClass m_CharacterOwner
SCR_MapGadgetComponentClass
Definition: SCR_MapGadgetComponent.c:2
OnMapClose
protected void OnMapClose(MapConfiguration config)
Definition: SCR_MapGadgetComponent.c:96
SetMapMode
void SetMapMode(bool state)
Definition: SCR_MapGadgetComponent.c:20
SCR_MapEntity
Map entity.
Definition: SCR_MapEntity.c:20
EOnInit
override void EOnInit(IEntity owner)
Definition: SCR_MapGadgetComponent.c:167
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition: ChimeraMenuBase.c:3
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
GetType
override EGadgetType GetType()
Definition: SCR_MapGadgetComponent.c:161
m_bIsMapOpen
protected bool m_bIsMapOpen
Definition: SCR_MapGadgetComponent.c:12
OnMapOpen
protected void OnMapOpen(MapConfiguration config)
Definition: SCR_MapGadgetComponent.c:80
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180