Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MapRTWBaseUI.c
Go to the documentation of this file.
3{
4 [Attribute("", UIWidgets.EditBox, desc: "X size")]
5 int m_iSizeX;
6
7 [Attribute("", UIWidgets.EditBox, desc: "Y size")]
8 int m_iSizeY;
9}
10
13{
14 [Attribute("", UIWidgets.Object, desc: "Array of x*y sizes in unscaled pix")]
15 protected ref array<ref ToolSize> m_aSizesArray;
16
17 protected static const string BASE_WORLD_TYPE = "ChimeraWorld";
18 protected static const float CAMERA_VERTICAL_FOV = 43;
19
20 // configuration
21 protected string WIDGET_NAME;
22 protected string RT_WIDGET_NAME;
23 protected string WORLD_RESOURCE = "{88ABCDC0EEC969DF}Prefabs/World/PreviewWorld/MapCompassWorld.et";
24 protected string WORLD_NAME;
28
29 protected bool m_bIsVisible; // visibility flag
30 protected bool m_bWantedVisible; // holds wanted visibility state after close
31 protected bool m_bIsDragged = false; // widget is being dragged
32 protected int m_iCurrentSizeIndex; // current id of m_SizesArray
33 protected int m_iSizesCount; // count of m_SizesArray
34 protected float m_fPosX, m_fPosY; // widget position
35
36 protected EGadgetType m_eGadgetType;
38 protected ref SharedItemRef m_RTWorld;
39 protected SCR_MapToolEntry m_ToolMenuEntry; // tool menu entry
40
41 // Widgets
42 protected Widget m_wFrame; // parent frame
43 protected RenderTargetWidget m_wRenderTarget; // RenderTargetWidget
44
45 //------------------------------------------------------------------------------------------------
47 protected void SetWidgetNames()
48 {
49 WIDGET_NAME = "";
50 RT_WIDGET_NAME = "";
51 WORLD_NAME = "MapUIWorld";
52 }
53
54 //------------------------------------------------------------------------------------------------
56 protected void InitPositionVectors()
57 {
58 m_vPrefabPos = "0 0 0";
59 m_vCameraPos = "0 0.3 0";
60 m_vCameraAngle = "0 -90 0";
61 }
62
63 //------------------------------------------------------------------------------------------------
66 protected string GetPrefabResource()
67 {
68 return string.Empty;
69 }
70
71 //------------------------------------------------------------------------------------------------
75 {
76 IEntity gadget;
77
79 if (gadgetManager)
80 gadget = gadgetManager.GetGadgetByType(m_eGadgetType);
81
82 return gadget;
83 }
84
85 //------------------------------------------------------------------------------------------------
87 protected void ToggleVisible()
88 {
89 if (!m_bIsVisible)
90 SetVisible(true);
91 else
92 {
93 SetVisible(false);
94 }
95 }
96
97 //------------------------------------------------------------------------------------------------
100 protected void SetVisible(bool visible)
101 {
102 if (!m_wFrame)
103 return;
104
105 if (visible)
106 {
107 // RTW preview world
108 if (!SetupRTWorld())
109 return;
110
111 if (!SpawnPrefab())
112 return;
113
114 m_bIsVisible = true;
115 m_wFrame.SetEnabled(true);
116 ScriptCallQueue queue = GetGame().GetCallqueue();
117 if (queue)
118 queue.CallLater(SetFrameVisible, 0, 0); // delayed by frame so the positioning can be initialised
119
121 }
122 else
123 {
124 m_bIsVisible = false;
125 m_wFrame.SetEnabled(false);
126 m_wFrame.SetVisible(false);
127
128 delete m_RTEntity; // proc anims do not work without this not being refreshed atm
129 }
130
131 if (m_ToolMenuEntry)
132 m_ToolMenuEntry.SetActive(visible);
133 }
134
135 //------------------------------------------------------------------------------------------------
138 {
139 m_wFrame.SetVisible(true);
140 }
141
142 //------------------------------------------------------------------------------------------------
145 protected bool SetupRTWorld()
146 {
147 // create new empty base world
148 if (!m_RTWorld || !m_RTWorld.IsValid())
149 {
150 m_RTWorld = BaseWorld.CreateWorld(BASE_WORLD_TYPE, WORLD_NAME);
151 if (!m_RTWorld)
152 return false;
153 World previewRTWorld = m_RTWorld.GetRef();
154 previewRTWorld.ReloadSystems();
155 }
156
157 BaseWorld previewWorld = m_RTWorld.GetRef();
158 if (!previewWorld)
159 return false;
160
161 m_wRenderTarget.SetWorld( previewWorld, 0 );
162
163 // spawn preview GenericWorldEntity
164 Resource rsc = Resource.Load(WORLD_RESOURCE);
165 if (rsc.IsValid())
166 GetGame().SpawnEntityPrefabLocal(rsc, previewWorld);
167
168 // default cam settings
169 previewWorld.SetCameraType(0, CameraType.PERSPECTIVE);
170 previewWorld.SetCameraNearPlane(0, 0.001);
171 previewWorld.SetCameraFarPlane(0, 50);
172 previewWorld.SetCameraVerticalFOV(0, CAMERA_VERTICAL_FOV);
173
174 return true;
175 }
176
177 //------------------------------------------------------------------------------------------------
180 protected bool SpawnPrefab()
181 {
182 string rscStr = GetPrefabResource();
183 if (rscStr == string.Empty)
184 return false;
185
186 Resource rscItem = Resource.Load(rscStr);
187 if (rscItem.IsValid())
188 {
189 BaseWorld world = m_RTWorld.GetRef();
190 if (!world)
191 return false;
192
193 if (!m_RTEntity)
194 {
195 m_RTEntity = GenericEntity.Cast( GetGame().SpawnEntityPrefabLocal(rscItem, world) );
196 if (!m_RTEntity)
197 return false;
198
200
201 m_RTEntity.SetOrigin(m_vPrefabPos);
202 m_RTEntity.SetFixedLOD(0);
203
204 BaseWorld previewWorld = m_RTWorld.GetRef();
205 if (!previewWorld)
206 return false;
207
208 previewWorld.SetCamera(0, m_vCameraPos, m_vCameraAngle);
209
210 SetSize();
211 }
212 }
213
214 return true;
215 }
216
217 //------------------------------------------------------------------------------------------------
220 protected void SetSize(bool nextSize = false)
221 {
222 if (nextSize)
223 {
226 else
228 }
229
230 FrameSlot.SetSize(m_wFrame, m_aSizesArray[m_iCurrentSizeIndex].m_iSizeX, m_aSizesArray[m_iCurrentSizeIndex].m_iSizeY);
231 }
232
233 //------------------------------------------------------------------------------------------------
236 protected void OnDragWidget(Widget widget)
237 {
238 if (widget == m_wFrame)
239 m_bIsDragged = true;
240 else
241 m_bIsDragged = false;
242 }
243
244 //------------------------------------------------------------------------------------------------
246 protected void OnActivateTool(Widget widget)
247 {
248 if (widget != m_wFrame)
249 return;
250
251 SetSize(true);
252 }
253
254 //------------------------------------------------------------------------------------------------
255 // OVERRIDES
256 //------------------------------------------------------------------------------------------------
257
258 //------------------------------------------------------------------------------------------------
259 override void OnMapOpen(MapConfiguration config)
260 {
261 super.OnMapOpen(config);
262
264
265 // refresh widgets
266 m_wFrame = m_RootWidget.FindAnyWidget(WIDGET_NAME);
268 m_iSizesCount = m_aSizesArray.Count();
269
270 if ( SCR_MapToolInteractionUI.Cast(m_MapEntity.GetMapUIComponent(SCR_MapToolInteractionUI)) ) // if dragging available, add callback
271 {
272 SCR_MapToolInteractionUI.GetOnDragWidgetInvoker().Insert(OnDragWidget);
273 SCR_MapToolInteractionUI.GetOnActivateToolInvoker().Insert(OnActivateTool);
274 }
275
276 SetVisible(m_bWantedVisible); // restore last visible state
277
278 if (m_ToolMenuEntry)
279 {
280 if (FindRelatedGadget())
281 m_ToolMenuEntry.SetEnabled(true);
282 else
283 m_ToolMenuEntry.SetEnabled(false);
284 }
285 }
286
287 //------------------------------------------------------------------------------------------------
288 override void OnMapClose(MapConfiguration config)
289 {
290 m_bWantedVisible = m_bIsVisible; // visibility state
291 SetVisible(false);
292
293 delete m_RTEntity;
294
295 super.OnMapClose(config);
296 }
297
298 //------------------------------------------------------------------------------------------------
299 // constructor
301 {
302 m_bHookToRoot = true;
303 }
304}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Widget m_RootWidget
void OnMapClose(MapConfiguration config)
void OnMapOpen(MapConfiguration config)
SCR_MapToolEntry m_ToolMenuEntry
SCR_MapEntity m_MapEntity
string RT_WIDGET_NAME
IEntity FindRelatedGadget()
vector m_vCameraAngle
bool SetupRTWorld()
int m_iSizeX
bool m_bIsVisible
string GetPrefabResource()
RenderTargetWidget m_wRenderTarget
void SetFrameVisible()
TODO Frame is now set through script here instead of directly in callqueue to avoid leak.
int m_iSizesCount
vector m_vPrefabPos
void OnDragWidget(Widget widget)
void ToggleVisible()
Visibility toggle.
vector m_vCameraPos
string WORLD_RESOURCE
string WORLD_NAME
int m_iCurrentSizeIndex
GenericEntity m_RTEntity
bool m_bWantedVisible
void InitPositionVectors()
Initialise RT camera and prefab positon.
float m_fPosY
void SCR_MapRTWBaseUI()
void SetWidgetNames()
Set widget names.
float m_fPosX
string WIDGET_NAME
void OnActivateTool(Widget widget)
SCR_MapToolInteractionUI event.
bool SpawnPrefab()
int m_iSizeY
bool m_bIsDragged
Widget m_wFrame
ref SharedItemRef m_RTWorld
EGadgetType m_eGadgetType
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void SetVisible(int layer)
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
IEntity GetGadgetByType(EGadgetType type)
static SCR_GadgetManagerComponent GetGadgetManager(IEntity entity)
Map tool menu entry data class.
static IEntity GetLocalControlledEntity()
ScriptCallQueue Class provide "lazy" calls - when we don't want to execute function immediately but l...
Definition tools.c:53
Definition World.c:16
VolumeDataProviderComponentClass GenericComponentClass SetSize(vector size)
SCR_FieldOfViewSettings Attribute
CameraType
Definition CameraType.c:14