Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MapEditorUIComponent.c
Go to the documentation of this file.
2{
5
7
11
12 protected ref Color m_CameraIconColor = Color.White;
14
17 protected bool m_bIsFirstTimeOpened = true;
18
19 //------------------------------------------------------------------------------------------------
23 void ToggleMap(bool show, ResourceName mapConfigPrefab)
24 {
25 if (mapConfigPrefab.IsEmpty())
26 return;
27
28 if (show)
29 {
30 m_MapConfigEditor = m_MapEntity.SetupMapConfig(EMapEntityMode.EDITOR, mapConfigPrefab, m_MapWidget);
32 }
33 else if (m_MapEntity.IsOpen())
34 {
35 m_MapEntity.CloseMap();
36 }
37
39 m_EditorCamera.SetInputEnabled(!show);
40 }
41
42 //------------------------------------------------------------------------------------------------
43 protected void OnMapInit(MapConfiguration config)
44 {
45 if (IsConfigEditor(config))
46 {
47 m_MapWidget.SetVisible(true);
48 }
49 }
50
51 //------------------------------------------------------------------------------------------------
52 protected void OnMapOpen(MapConfiguration config)
53 {
54 if (IsConfigEditor(config))
55 {
57 {
59 m_MapEntity.ZoomOut();
60 }
61 }
62 }
63
64 //------------------------------------------------------------------------------------------------
65 protected void OnMapClose(MapConfiguration config)
66 {
67 if (IsConfigEditor(config))
68 m_MapWidget.SetVisible(false);
69 }
70
71 //------------------------------------------------------------------------------------------------
75 {
76 return m_MapEntity && m_MapEntity.IsOpen() && IsConfigEditor(m_MapEntity.GetMapConfig());
77 }
78
79 //------------------------------------------------------------------------------------------------
80 protected bool IsConfigEditor(MapConfiguration config)
81 {
82 return config && config.MapEntityMode == EMapEntityMode.EDITOR;
83 }
84
85 //------------------------------------------------------------------------------------------------
86 protected void OnEditorModeChange(SCR_EditorModeEntity newModeEntity, SCR_EditorModeEntity oldModeEntity)
87 {
88 SCR_CameraEditorComponent cameraComponent;
89 if (oldModeEntity)
90 {
91 cameraComponent = SCR_CameraEditorComponent.Cast(oldModeEntity.FindComponent(SCR_CameraEditorComponent));
92 if (cameraComponent)
93 cameraComponent.GetOnCameraCreate().Remove(OnEditorCameraCreate);
94 }
95
96 if (newModeEntity)
97 {
98 cameraComponent = SCR_CameraEditorComponent.Cast(newModeEntity.FindComponent(SCR_CameraEditorComponent));
99 if (cameraComponent)
100 {
101 cameraComponent.GetOnCameraCreate().Insert(OnEditorCameraCreate);
102 OnEditorCameraCreate(cameraComponent.GetCamera());
103 }
104
105 SetCameraIconColor(newModeEntity.GetModeType());
106 }
107 }
108
109 //------------------------------------------------------------------------------------------------
110 protected void SetCameraIconColor(EEditorMode mode)
111 {
112 if (!m_EditorCore)
113 return;
114
115 SCR_EditorModeUIInfo modeUiInfo = m_EditorCore.GetDefaultModeInfo(mode);
116 if (modeUiInfo)
117 m_CameraIconColor = modeUiInfo.GetModeColor();
118 else if (m_EditorCore.GetDefaultModeInfo(EEditorMode.EDIT))
119 m_CameraIconColor = m_EditorCore.GetDefaultModeInfo(EEditorMode.EDIT).GetModeColor();
120 }
121
122 //------------------------------------------------------------------------------------------------
123 protected void OnEditorCameraCreate(SCR_ManualCamera editorCamera)
124 {
125 if (!m_MapEntity || !editorCamera)
126 return;
127
128 m_EditorCamera = editorCamera;
129
130 if (m_EditorCamera)
131 m_EditorCamera.SetInputEnabled(!IsEditorMapOpen());
132 }
133
134 //------------------------------------------------------------------------------------------------
135 protected void OnMenuUpdate()
136 {
137 if (IsEditorMapOpen())
138 m_InputManager.ActivateContext("MapContext");
139 }
140
141 //------------------------------------------------------------------------------------------------
143 {
144 super.HandlerAttachedScripted(w);
145
147 return;
148
149 m_InputManager = GetGame().GetInputManager();
150 if (!m_InputManager)
151 return;
152
154 if (!m_MapEntity)
155 return;
156
157 m_MapEntity.GetOnMapInit().Insert(OnMapInit);
158 m_MapEntity.GetOnMapOpen().Insert(OnMapOpen);
159 m_MapEntity.GetOnMapClose().Insert(OnMapClose);
160
162 if (!m_EditorManager)
163 return;
164
165 m_EditorManager.GetOnModeChange().Insert(OnEditorModeChange);
166
169 return;
170
171 m_MapWidget = w;
172
173 m_EditorMapManager.SetMapHandler(this);
174 m_EditorMapConfigPrefab = m_EditorMapManager.GetMapConfigPrefab();
175
177
178 GetMenu().GetOnMenuUpdate().Insert(OnMenuUpdate);
179
180 OnEditorModeChange(m_EditorManager.GetCurrentModeEntity(), null);
181 }
182
183 //------------------------------------------------------------------------------------------------
184 override void HandlerDeattached(Widget w)
185 {
187 return;
188
189 super.HandlerDeattached(w);
190
191 if (IsEditorMapOpen())
193
194 if (GetMenu())
195 GetMenu().GetOnMenuUpdate().Remove(OnMenuUpdate);
196 }
197}
ArmaReforgerScripted GetGame()
Definition game.c:1398
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
EMapEntityMode
Mode of the map.
SCR_RadialMenu GetMenu()
Definition Color.c:13
Input management system for user interactions.
ScriptInvokerBase< SCR_CameraEditorComponent_OnCameraCreated > GetOnCameraCreate()
Core component to manage SCR_EditorManagerEntity.
static bool IsEditMode()
Definition Functions.c:1566
void OnMapClose(MapConfiguration config)
bool IsConfigEditor(MapConfiguration config)
void OnMapOpen(MapConfiguration config)
void OnEditorModeChange(SCR_EditorModeEntity newModeEntity, SCR_EditorModeEntity oldModeEntity)
void OnEditorCameraCreate(SCR_ManualCamera editorCamera)
SCR_EditorManagerEntity m_EditorManager
override void HandlerAttachedScripted(Widget w)
SCR_EditorManagerCore m_EditorCore
void ToggleMap(bool show, ResourceName mapConfigPrefab)
void SetCameraIconColor(EEditorMode mode)
void OnMapInit(MapConfiguration config)
SCR_MapEditorComponent m_EditorMapManager
override void HandlerDeattached(Widget w)
ref MapConfiguration m_MapConfigEditor
static SCR_MapEntity GetMapInstance()
Get map entity instance.
EEditorMode
Editor mode that defines overall functionality.
Definition EEditorMode.c:6