Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_MapEditorComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/Editor", description: "", icon: "WBData/ComponentEditorProps/componentEditor.png")]
3 {
4 };
5 
10 {
11  [Attribute(SCR_SoundEvent.SOUND_HUD_MAP_OPEN, UIWidgets.EditBox)]
12  protected string m_sOpeningEditorMapSfx;
13 
14  [Attribute(SCR_SoundEvent.SOUND_HUD_MAP_CLOSE, UIWidgets.EditBox)]
15  protected string m_sClosingEditorMapSfx;
16 
17  protected ResourceName m_sMapConfigEditorPrefab;
18  protected SCR_MapEntity m_MapEntity;
19  protected SCR_EditorManagerEntity m_EditorManager;
20  protected MapItem m_CameraIcon;
21  protected bool m_bWasMapOpened;
22  protected bool m_bIsInit;
23 
24  protected SCR_MapEditorUIComponent m_MapHandler;
25 
26  protected ref Color m_CameraIconColor = Color.White;
27 
28  bool GetMapAvailable()
29  {
30  return m_bIsInit;
31  }
32 
33  void SetMapHandler(SCR_MapEditorUIComponent mapHandler)
34  {
35  m_MapHandler = mapHandler;
36  ShowMap(m_bWasMapOpened);
37  }
38 
39  ResourceName GetMapConfigPrefab()
40  {
41  return m_sMapConfigEditorPrefab;
42  }
43 
44  void ToggleMap()
45  {
46  ShowMap(!IsEditorMapOpen());
47  }
48 
49  void ShowMap(bool show)
50  {
51  if (!m_MapHandler)
52  {
53  return;
54  }
55 
56  //--- In limited editor, map can be opened only if map gadget is in player's inventory
57  if (show && GetManager().IsLimited())
58  {
59  IEntity playerEntity = SCR_PlayerController.GetLocalControlledEntity();
60  if (!playerEntity)
61  return; //--- Limited editor works only if player has an entity, so this should never happen.
62 
63  SCR_GadgetManagerComponent gadgetManager = SCR_GadgetManagerComponent.Cast(playerEntity.FindComponent(SCR_GadgetManagerComponent));
64  if (gadgetManager && !gadgetManager.GetGadgetByType(EGadgetType.MAP))
65  return;
66  }
67 
68  if (show)
69  SCR_UISoundEntity.SoundEvent(m_sOpeningEditorMapSfx, true);
70  else
71  SCR_UISoundEntity.SoundEvent(m_sClosingEditorMapSfx, true);
72 
73  m_MapHandler.ToggleMap(show, m_sMapConfigEditorPrefab);
74  m_bWasMapOpened = show;
75  }
76 
77  void OnPlacingPreviewCreate()
78  {
79  if (IsEditorMapOpen())
80  {
81  ShowMap(false);
82  }
83  }
84 
85  protected bool IsEditorMapOpen()
86  {
87  if (m_MapHandler)
88  {
89  return m_MapHandler.IsEditorMapOpen();
90  }
91  return false;
92  }
93 
94  protected void OnLimitedChange(bool isLimited)
95  {
96  //--- Close the map when the editor became limited
97  if (isLimited && IsEditorMapOpen())
98  {
99  ShowMap(false);
100  }
101  }
102  protected SCR_MapEditorUIComponent FindMapHandler()
103  {
105  if (!menuComponent || !menuComponent.GetMenu())
106  return null;
107 
108  SCR_MapEditorUIComponent mapEditorComponent = SCR_MapEditorUIComponent.Cast(menuComponent.GetMenu().GetRootComponent().FindComponent(SCR_MapEditorUIComponent, true));
109  return mapEditorComponent;
110  }
111 
112  override void OnPostInit(IEntity owner)
113  {
114  if (SCR_Global.IsEditMode())
115  return;
116  super.OnPostInit(owner);
117 
118  m_MapEntity = SCR_MapEntity.GetMapInstance();
119  if (!m_MapEntity)
120  return;
121 
122  BaseGameMode gameMode = GetGame().GetGameMode();
123  if (!gameMode)
124  return;
125 
126  SCR_MapConfigComponent configComp = SCR_MapConfigComponent.Cast(gameMode.FindComponent(SCR_MapConfigComponent));
127  if (configComp)
128  m_sMapConfigEditorPrefab = configComp.GetEditorMapConfig();
129 
131  if (!m_EditorManager)
132  return;
133 
134  m_EditorManager.GetOnLimitedChange().Insert(OnLimitedChange);
135 
137  if (previewEntityComponent)
138  {
139  previewEntityComponent.GetOnPreviewCreate().Insert(OnPlacingPreviewCreate);
140  }
141 
142  m_bIsInit = true;
143  }
144 
145  override void EOnDeactivate(IEntity owner)
146  {
147  if (SCR_Global.IsEditMode())
148  return;
149 
150  if (m_CameraIcon)
151  {
152  delete m_CameraIcon;
153  }
154  }
155 };
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
m_MapEntity
protected SCR_MapEntity m_MapEntity
Definition: SCR_MapGadgetComponent.c:14
SCR_PlayerController
Definition: SCR_PlayerController.c:31
SCR_MapEditorUIComponent
Definition: SCR_MapEditorUIComponent.c:1
SCR_UISoundEntity
Definition: SCR_UISoundEntity.c:7
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_GadgetManagerComponent
Definition: SCR_GadgetManagerComponent.c:138
SCR_SoundEvent
Definition: SCR_SoundEvent.c:1
m_bWasMapOpened
protected bool m_bWasMapOpened
Definition: SCR_CampaignFeedbackComponent.c:31
SCR_BaseEditorComponent
Definition: SCR_BaseEditorComponent.c:119
Attribute
typedef Attribute
Post-process effect of scripted camera.
MapItem
Definition: MapItem.c:12
SCR_MapEditorComponent
Definition: SCR_MapEditorComponent.c:9
SCR_MapEntity
Map entity.
Definition: SCR_MapEntity.c:20
m_EditorManager
protected SCR_EditorManagerEntity m_EditorManager
Definition: SCR_VotingEditor.c:5
SCR_BaseEditorComponentClass
Definition: SCR_BaseEditorComponent.c:2
SCR_MapEditorComponentClass
Definition: SCR_MapEditorComponent.c:2
SCR_Global
Definition: Functions.c:6
SCR_MenuEditorComponent
Definition: SCR_MenuEditorComponent.c:8
SCR_PreviewEntityEditorComponent
Definition: SCR_PreviewEntityEditorComponent.c:12
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
SCR_EditorManagerEntity
Definition: SCR_EditorManagerEntity.c:26