Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
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 [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")]
5 protected float m_fActivationDelay;
6
7 [Attribute("{FC855D20AA561819}UI/Textures/Map/ProtractorScale.edds", UIWidgets.ResourcePickerThumbnail, desc: "Image of that will be used as a texture for a protractor.", params: "edds")]
9
10 [Attribute(defvalue: "1994", uiwidget: UIWidgets.EditBox, desc: "[px] Exact length of the ruler that coresponds to 1km of distance")]
11 protected float m_fRulerLength;
12
13 //------------------------------------------------------------------------------------------------
15 {
16 return m_fActivationDelay;
17 }
18
19 //------------------------------------------------------------------------------------------------
24
25 //------------------------------------------------------------------------------------------------
27 {
28 return m_fRulerLength;
29 }
30}
31
33class SCR_MapGadgetComponent : SCR_GadgetComponent
34{
35
36 protected bool m_bIsMapOpen;
37 protected bool m_bIsFirstTimeOpened = true; // whether the map has bene opened since put into a lot
38 protected SCR_MapEntity m_MapEntity; // map instance
40
41//---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
42 //------------------------------------------------------------------------------------------------
45 void SetMapMode(bool state)
46 {
48 return;
49
51 if (!data)
52 return;
53
54 // no delay/fade for forced cancel
56 ECharacterLifeState lifeState = controller.GetLifeState();
57 float delay;
58 if (lifeState != ECharacterLifeState.DEAD)
59 delay = data.GetActivationDelay() * 1000;
60
61 GetGame().GetCallqueue().Remove(ToggleMapGadget);
62
63 if (state)
64 {
65 GetGame().GetCallqueue().CallLater(ToggleMapGadget, delay, false, true);
66
68 m_FadeInOutEffect.FadeOutEffect(true, data.GetActivationDelay()); // fade out after map open
69 }
70 else
71 {
72 GetGame().GetCallqueue().CallLater(ToggleMapGadget, delay, false, false);
73
74 if (lifeState != ECharacterLifeState.DEAD && m_FadeInOutEffect)
75 {
76 if (m_MapEntity.IsOpen())
77 m_FadeInOutEffect.FadeOutEffect(true, data.GetActivationDelay()); // fade out on map close
78 else
79 m_FadeInOutEffect.FadeOutEffect(false, data.GetActivationDelay()); // in case map is closed fast before it opens, fade in from close map wont trigger, so it has to happen here
80 }
81 }
82 }
83//---- REFACTOR NOTE END ----
84
85 //------------------------------------------------------------------------------------------------
88 protected void ToggleMapGadget(bool state)
89 {
90 if (state)
91 {
92 if (m_MapEntity.IsOpen())
93 return;
94
97
98 MenuManager menuManager = g_Game.GetMenuManager();
99 menuManager.OpenMenu(ChimeraMenuPreset.MapMenu);
100 m_bIsMapOpen = true;
101 }
102 else
103 {
104 MenuManager menuManager = g_Game.GetMenuManager();
105 menuManager.CloseMenuByPreset(ChimeraMenuPreset.MapMenu);
106 m_bIsMapOpen = false;
107 }
108 }
109
110 //------------------------------------------------------------------------------------------------
113 protected void OnMapOpen(MapConfiguration config)
114 {
116 SCR_WeaponSwitchingBaseUI.GetWeaponSwitchingBaseUI().CloseQuickSlots(); // force close it as WeaponSelectionContext will obstruct input for MapContext
117
119 if (data && m_FadeInOutEffect)
120 m_FadeInOutEffect.FadeOutEffect(false, data.GetActivationDelay()); // fade in after map open
121
122 // first open
124 return;
125
126 m_bIsFirstTimeOpened = false;
127 m_MapEntity.ZoomOut();
128 }
129
130 //------------------------------------------------------------------------------------------------
133 protected void OnMapClose(MapConfiguration config)
134 {
136 if (data && m_FadeInOutEffect)
137 m_FadeInOutEffect.FadeOutEffect(false, data.GetActivationDelay()); // fade in after map close
138
141 }
142
143 //------------------------------------------------------------------------------------------------
144 override void ModeSwitch(EGadgetMode mode, IEntity charOwner)
145 {
146 super.ModeSwitch(mode, charOwner);
147
148 if (mode == EGadgetMode.ON_GROUND)
150
151 // not current player
153 if ( !controlledEnt || controlledEnt != m_CharacterOwner)
154 return;
155
156 if (mode != EGadgetMode.IN_HAND)
157 return;
158
160 if (!playerController)
161 return;
162
163 SCR_HUDManagerComponent hudManager = SCR_HUDManagerComponent.Cast(playerController.GetHUDManagerComponent());
164 if (hudManager)
166
167 ToggleFocused(true);
168 }
169
170 //------------------------------------------------------------------------------------------------
171 override void ModeClear(EGadgetMode mode)
172 {
173 // not current player
175 if ( !controlledEnt || controlledEnt != m_CharacterOwner )
176 {
177 super.ModeClear(mode);
178 return;
179 }
180
181 if (mode == EGadgetMode.IN_HAND)
182 {
183 if (m_bFocused)
184 ToggleFocused(false);
185 }
186
187 super.ModeClear(mode);
188 }
189
190 //------------------------------------------------------------------------------------------------
191 override void ToggleFocused(bool enable)
192 {
193 super.ToggleFocused(enable);
194
195 SetMapMode(enable);
196 }
197
198 //------------------------------------------------------------------------------------------------
199 override EGadgetType GetType()
200 {
201 return EGadgetType.MAP;
202 }
203
204 //------------------------------------------------------------------------------------------------
205 override void EOnInit(IEntity owner)
206 {
207 if (!m_MapEntity)
209 }
210}
ChimeraMenuPreset
Menu presets.
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_RplTestComponentClass m_CharacterOwner
SCR_BaseGameMode GetGameMode()
void ModeClear(EGadgetMode mode)
override void ModeSwitch(EGadgetMode mode, IEntity charOwner)
override EGadgetType GetType()
void OnMapClose(MapConfiguration config)
void OnMapOpen(MapConfiguration config)
SCR_CharacterSoundComponentClass GetComponentData()
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
Get all prefabs that have the spawner data
void ToggleMapGadget(bool state)
SCR_FadeInOutEffect m_FadeInOutEffect
SCR_MapEntity m_MapEntity
bool m_bIsFirstTimeOpened
SCR_MapGadgetComponentClass m_bIsMapOpen
Map gadget component.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void SetMapMode()
Activate in a map UI mode.
proto external bool CloseMenuByPreset(ScriptMenuPresetEnum preset)
Put menu with given iPresetId into queue for closing (which is processed during next MenuManeger upda...
proto external MenuBase OpenMenu(ScriptMenuPresetEnum preset, int userId=0, bool unique=false, bool hideParentMenu=true)
SCR_InfoDisplay FindInfoDisplay(typename type)
Return hud component of given type.
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapClose()
Get on map close invoker.
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapOpen()
Get on map open invoker.
static SCR_MapEntity GetMapInstance()
Get map entity instance.
static IEntity GetLocalControlledEntity()
static SCR_WeaponSwitchingBaseUI GetWeaponSwitchingBaseUI()
Game g_Game
Game singleton instance.
Definition gameLib.c:13
IEntity GetOwner()
Owner entity of the fuel tank.
override void EOnInit(IEntity owner)
ECharacterLifeState
SCR_FieldOfViewSettings Attribute
proto external PlayerController GetPlayerController()