DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
MapMenu.c
См. документацию.
1class MapMenu extends UIScriptedMenu
2{
3 protected const string COORD_FORMAT = "%1.%2%3";
4 protected const int SCALE_RULER_LINE_WIDTH = 8;
5 protected const int SCALE_RULER_NUM_SEGMENTS = 10;
6
7 protected bool m_WasChanged;
8 protected bool m_HasCompass
9 protected bool m_HasGPS
10 protected bool m_IsOpenning;
11
13 protected float m_ToolsContainerPos0[2];
14
15 protected ref IngameHud m_Hud ;
18 protected ref SizeToChild m_LegendResizer;
19
21 protected ImageWidget m_Images;
23 protected ImageWidget m_GPSMarkerArrow;
26 protected ImageWidget m_ToolsCompassArrow;
33 protected CanvasWidget m_ToolsScaleCellSizeCanvas;
34 protected ItemMap m_Map;
35 protected Widget m_ToolbarPanel;
36 //int m_MarkerCount;
37
39
48
49 override Widget Init()
50 {
51 layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/day_z_map.layout");
52 m_Hud = IngameHud.Cast(GetGame().GetMission().GetHud());
53 m_IsOpenning = true;
54
55 /*MapWidget m = MapWidget.Cast(layoutRoot.FindAnyWidget("Map"));
56 if (m)
57 {
58 m.AddUserMark("2681 4.7 1751", "Lalal", ARGB(255,255,0,0), "\\dz\\gear\\navigation\\data\\map_tree_ca.paa");
59 m.AddUserMark("2683 4.7 1851", "Lala2", ARGB(255,0,255,0), "\\dz\\gear\\navigation\\data\\map_bunker_ca.paa");
60 m.AddUserMark("2670 4.7 1651", "Lala3", ARGB(255,0,0,255), "\\dz\\gear\\navigation\\data\\map_busstop_ca.paa");
61 }*/
62
63 m_MapToolsContainer = layoutRoot.FindAnyWidget("Map_Tools_Container");
65
66 m_MapWidgetInstance = MapWidget.Cast(layoutRoot.FindAnyWidget("Map"));
67 m_GPSMarker = layoutRoot.FindAnyWidget("GPSMarkerCircle");
68 m_GPSMarkerArrow = ImageWidget.Cast(layoutRoot.FindAnyWidget("GPSMarkerArrow"));
69 m_UpperLegendContainer = layoutRoot.FindAnyWidget("Tools_Extra");
70 layoutRoot.Update();
71 m_ToolsCompassBase = layoutRoot.FindAnyWidget("Tools_Compass_Base");
72 m_ToolsCompassArrow = ImageWidget.Cast(layoutRoot.FindAnyWidget("Tools_Compass_Arrow"));
73 m_ToolsCompassAzimuth = TextWidget.Cast(layoutRoot.FindAnyWidget("Tools_Compass_Azimuth"));
74 m_ToolsGPSXText = TextWidget.Cast(layoutRoot.FindAnyWidget("Tools_GPS_X_Value"));
75 m_ToolsGPSYText = TextWidget.Cast(layoutRoot.FindAnyWidget("Tools_GPS_Y_Value"));
76 m_ToolsGPSElevationText = TextWidget.Cast(layoutRoot.FindAnyWidget("Tools_GPS_Elevation_Value"));
77 m_ToolsScaleContourText = TextWidget.Cast(layoutRoot.FindAnyWidget("Tools_Scale_Contour_Value"));
78 m_ToolsScaleCellSizeText = TextWidget.Cast(layoutRoot.FindAnyWidget("Tools_Scale_CellSize_Value"));
79 m_ToolsScaleCellSizeCanvas = CanvasWidget.Cast(layoutRoot.FindAnyWidget("Tools_Scale_CellSize_Canvas"));
80 m_ToolbarPanel = layoutRoot.FindAnyWidget("toolbar_bg");
81
82 float canvasHeight = 0;
84
86 {
87 float scale;
88 vector mapPosition;
89 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
90 if (player && !player.GetLastMapInfo(scale, mapPosition))
91 {
92 vector tempPosition = GetGame().ConfigGetVector(string.Format("CfgWorlds %1 centerPosition", GetGame().GetWorldName()));
93 scale = 0.33;
94 mapPosition = Vector(tempPosition[0], tempPosition[1], tempPosition[2]);
95 }
96
97 m_MapWidgetInstance.SetScale(scale);
98 m_MapWidgetInstance.SetMapPos(mapPosition);
99
100 m_HasCompass = false;
101 m_HasGPS = false;
102
107
108 if (player)
109 {
110 m_MapNavigationBehaviour = player.GetMapNavigationBehaviour();
112 {
113 m_HasGPS = (m_MapNavigationBehaviour.GetNavigationType() & EMapNavigationType.GPS|EMapNavigationType.ALL == 0);
114 m_HasCompass = (m_MapNavigationBehaviour.GetNavigationType() & EMapNavigationType.COMPASS|EMapNavigationType.ALL == 0);
115
117 m_HasGPS = CfgGameplayHandler.GetMapIgnoreNavItemsOwnership() || m_HasGPS;
118 m_HasCompass = CfgGameplayHandler.GetMapIgnoreNavItemsOwnership() || m_HasCompass;
119
120 if (m_HasGPS)
121 {
124 {
126 m_MapWidgetInstance.SetMapPos(m_MapNavigationBehaviour.GetPositionReal());
127 }
128 }
129
130 if (m_HasCompass)
131 {
135 {
137 }
138 }
139
141 if ((!m_HasGPS && !m_HasCompass) || !CfgGameplayHandler.GetMapDisplayNavigationInfo())
142 {
144 }
145 }
146 }
147
149
150 if (m_Hud)
151 {
152 m_Hud.ShowHudUI(false);
153 m_Hud.ShowQuickbarUI(false);
154 }
155 }
156
157 float x,y;
158 m_MapToolsContainer.GetScreenPos(x,y);
161
164
165 return layoutRoot;
166 }
167
168 override void InitMapItem(EntityAI item)
169 {
170 super.InitMapItem(item);
171
172 m_Map = ItemMap.Cast(item);
173 //m_Map.SyncMapMarkers();
174 //m_MarkerCount = m_Map.GetMarkerArray().Count();
175 }
176
177 override void OnShow()
178 {
179 super.OnShow();
180
183 }
184
185 override bool OnClick(Widget w, int x, int y, int button)
186 {
187 super.OnClick(w, x, y, button);
188
189 switch (w.GetUserID())
190 {
191 case IDC_CANCEL:
192 CloseMapMenu();
193 return true;
194 }
195
196 return false;
197 }
198
199 override bool OnKeyPress(Widget w, int x, int y, int key)
200 {
201 super.OnKeyPress(w, x, y, key);
202
203 return false;
204 }
205
206 protected void OnInputPresetChanged()
207 {
208 #ifdef PLATFORM_CONSOLE
210 #endif
211 }
212
213 protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
214 {
217 }
218
219 override void Update(float timeslice)
220 {
221 super.Update(timeslice);
223
224 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
225
227 {
228 if (m_Images)
229 {
230 m_MapWidgetInstance.RemoveChild(m_Images);
231 }
232
233 if (player)
234 {
235 m_ToolsScaleContourText.SetText(string.Format("%1 m", m_MapWidgetInstance.GetContourInterval()));
237 float rulerMaxDistance;
238 string rulerUnits;
239 ProcessDistanceAndUnits(m_MapWidgetInstance.GetCellSize(m_ToolScaleCellSizeCanvasWidth), rulerMaxDistance, rulerUnits);
240 m_ToolsScaleCellSizeText.SetText(string.Format("%1%2", rulerMaxDistance, rulerUnits));
241
243 {
244 vector mapPos = m_MapWidgetInstance.MapToScreen(m_MapNavigationBehaviour.GetPositionReal());
245 float scale = 1 - m_MapWidgetInstance.GetScale();
246
247 if (m_HasCompass)
248 {
249 vector rot = player.GetYawPitchRoll();
250 float angle = Math.Round(rot[0]);
251 if (angle < 0)
252 {
253 angle = 360 + angle;
254 }
255
256 m_GPSMarkerArrow.SetRotation(0, 0, angle);
257 m_ToolsCompassArrow.SetRotation(0, 0, angle);
258 m_ToolsCompassAzimuth.SetText(string.Format("%1°", angle));
259 }
260
261 array<int> coords = MapNavigationBehaviour.OrderedPositionNumbersFromGridCoords(player);
263 {
264 m_GPSMarker.SetSize(scale * 100, scale * 100);
265 m_GPSMarkerArrow.SetSize(scale * 100, scale * 100);
266 float sizeX, sizeY;
267 m_GPSMarker.GetSize(sizeX, sizeY);
268 sizeX = Math.Round(sizeX);
269 sizeY = Math.Round(sizeY);
270 m_GPSMarker.SetPos(mapPos[0] - sizeX/2, mapPos[1] - sizeY/2);
271 m_GPSMarkerArrow.SetPos(mapPos[0] - sizeX/2, mapPos[1] - sizeY/2);
272
273 if (coords.Count() == m_MapNavigationBehaviour.DISPLAY_GRID_POS_MAX_CHARS_COUNT * 2 && coords[0] >= 0)
274 {
275 m_ToolsGPSXText.SetText(string.Format(COORD_FORMAT, coords[0], coords[1], coords[2]));
276 m_ToolsGPSYText.SetText(string.Format(COORD_FORMAT, coords[3], coords[4], coords[5]));
277 }
278 else
279 {
280 m_ToolsGPSXText.SetText("-.--");
281 m_ToolsGPSYText.SetText("-.--");
282 }
283
284 m_ToolsGPSElevationText.SetText(string.Format("%1m", Math.Round(player.GetPosition()[1])));
285 }
286 else
287 {
288 m_ToolsGPSXText.SetText("-.--");
289 m_ToolsGPSYText.SetText("-.--");
290 m_ToolsGPSElevationText.SetText("----m");
291 }
292 }
293 }
294
295 bool isClosedWithShortcut = CfgGameplayHandler.GetMapIgnoreMapOwnership() && GetUApi().GetInputByID(UAMapToggle).LocalPress();
296 if (!m_IsOpenning && (GetUApi().GetInputByID(UAUIBack).LocalPress() || isClosedWithShortcut))
297 {
298 if (player)
299 {
300 player.SetLastMapInfo(m_MapWidgetInstance.GetScale(), m_MapWidgetInstance.GetMapPos());
301 }
302
303 CloseMapMenu();
304 }
305
306 m_IsOpenning = false;
307 }
308 }
309
310 void AddMarker(vector pos, int color, int icon = 0)
311 {
312 m_Map.InsertMarker(pos,"",color,icon);
313 m_MapWidgetInstance.AddUserMark(pos, "", color, MapMarkerTypes.GetMarkerTypeFromID(icon));
314 m_WasChanged = true;
315 }
316
318 {
319 m_WasChanged = true;
320 }
321
322 override void LoadMapMarkers()
323 {
324 MapMarker marker;
325 for (int i = 0; i < m_Map.GetMarkerArray().Count(); i++)
326 {
327 marker = m_Map.GetMarkerArray().Get(i);
328 m_MapWidgetInstance.AddUserMark(marker.GetMarkerPos(),marker.GetMarkerText(),marker.GetMarkerColor(),MapMarkerTypes.GetMarkerTypeFromID(marker.GetMarkerIcon())/*"\\dz\\gear\\navigation\\data\\map_tree_ca.paa"*/);
329 }
330 }
331
333 {
334 if (m_WasChanged)
335 {
336 m_Map.SyncMapMarkers();
337 m_WasChanged = false;
338 }
339
340 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
341 if (player)
342 {
343 player.SetMapClosingSyncSet(false); //map is closing, server needs to be notified - once
344 }
345
346 if (m_Hud)
347 {
348 m_Hud.ShowHudUI(true);
349 m_Hud.ShowQuickbarUI(true);
350 }
351
353 {
355 {
357 }
358 else
359 {
360 GetGame().GetMission().RemoveActiveInputExcludes({"loopedactions"});
361 }
362
363 GetGame().GetMission().RemoveActiveInputRestriction(EInputRestrictors.MAP);
364 }
365
366 Close();
367 }
368
369 protected void SetCompassUIVisibility(bool pState)
370 {
372 {
373 m_ToolsCompassArrow.Show(pState);
374 }
375
377 {
378 m_ToolsCompassAzimuth.Show(pState);
379 }
380 }
381
382 protected void SetGPSMarkerVisibility(bool pState)
383 {
384 if (m_GPSMarker)
385 {
386 m_GPSMarker.Show(pState);
387 }
388 }
389
390 protected void SetGPSDirectionVisibility(bool pState)
391 {
393 {
394 m_GPSMarkerArrow.Show(pState);
395 }
396 }
397
398 protected void SetUpperLegendVisibility(bool pState)
399 {
401 {
402 m_UpperLegendContainer.Show(pState);
403 }
404
405 if (m_LegendResizer)
406 {
407 m_LegendResizer.ResizeParentToChild();
408 }
409 }
410
411 protected void RenderScaleRuler()
412 {
413 float sizeYShift = 8;
415 int lineColor = FadeColors.BLACK;
416
417 for (int i = 1; i <= SCALE_RULER_NUM_SEGMENTS; i++)
418 {
419 lineColor = FadeColors.BLACK;
420 if (i % 2 == 0)
421 {
422 lineColor = FadeColors.LIGHT_GREY;
423 }
424
425 if (i == 1)
426 {
427 m_ToolsScaleCellSizeCanvas.DrawLine(0, sizeYShift, segmentLength, sizeYShift, SCALE_RULER_LINE_WIDTH, lineColor);
428 }
429 else if (i == SCALE_RULER_NUM_SEGMENTS)
430 {
431 m_ToolsScaleCellSizeCanvas.DrawLine(segmentLength * (SCALE_RULER_NUM_SEGMENTS - 1), sizeYShift, segmentLength * SCALE_RULER_NUM_SEGMENTS, sizeYShift, SCALE_RULER_LINE_WIDTH, lineColor);
432 }
433 else
434 {
435 m_ToolsScaleCellSizeCanvas.DrawLine(segmentLength * (i - 1), sizeYShift, segmentLength * i, sizeYShift, SCALE_RULER_LINE_WIDTH, lineColor);
436 }
437 }
438 }
439
440 protected void ProcessDistanceAndUnits(float num, out float dist, out string units)
441 {
442 if (num >= 901)
443 {
444 num *= 0.001;
445 num = Math.Round(num * 10) * 0.1;
446 dist = num;
447 units = "km";
448 }
449 else if (num >= 100 && num <= 900)
450 {
451 num = Math.Ceil(num * 0.1) * 10;
452 dist = num;
453 units = "m";
454 }
455 else if (num >= 1)
456 {
457 num = Math.Floor(num);
458 dist = num;
459 units = "m";
460 }
461 else
462 {
463 num = Math.Ceil(num * 10);
464 dist = num;
465 units = "cm";
466 }
467 }
468
469 protected void UpdateControlsElements()
470 {
471 RichTextWidget toolbarText = RichTextWidget.Cast(layoutRoot.FindAnyWidget("ContextToolbarText"));
472 string text = string.Empty;
473
474 text += string.Format(" <image set=\"xbox_buttons\" name=\"LS\" scale=\"%1\" /> %2 ", InputUtils.ICON_SCALE_TOOLBAR, "#layout_map_navigate");
475 text += string.Format(" <image set=\"xbox_buttons\" name=\"RS\" scale=\"%1\" /> %2 ", InputUtils.ICON_SCALE_TOOLBAR, "#STR_Controls_Zoom");
476 text += string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUIBack", "#close", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
477
478 toolbarText.SetText(text);
479 }
480
482 {
483 bool toolbarShow = false;
484 #ifdef PLATFORM_CONSOLE
486 #endif
487
488 m_ToolbarPanel.Show(toolbarShow);
490 }
491
492 protected void ShiftMapToolsContainer()
493 {
494 if (m_ToolbarPanel.IsVisible())
495 {
496 float sizeX,sizeY;
497 m_ToolbarPanel.GetScreenSize(sizeX,sizeY);
499 }
500 else
502 }
503}
DayZGame g_Game
Определения DayZGame.c:3868
Icon x
Icon y
void Close()
EMapNavigationType
Определения MapNavigationBehaviour.c:2
void MapNavigationBehaviour(PlayerBase pPlayer, EMapNavigationType pNavigationType=EMapNavigationType.BASIC)
Определения MapNavigationBehaviour.c:27
@ Count
Определения RandomGeneratorSyncManager.c:8
proto native UAInputAPI GetUApi()
proto native vector ConfigGetVector(string path)
Get vector value from config on path.
proto native WorkspaceWidget GetWorkspace()
proto native Input GetInput()
proto native Mission GetMission()
static bool GetUse3DMap()
Определения CfgGameplayHandler.c:382
static bool GetMapDisplayPlayerPosition()
Определения CfgGameplayHandler.c:413
static bool GetMapDisplayNavigationInfo()
Определения CfgGameplayHandler.c:418
static bool GetMapIgnoreMapOwnership()
Определения CfgGameplayHandler.c:403
static bool GetMapIgnoreNavItemsOwnership()
Определения CfgGameplayHandler.c:408
Определения Building.c:6
proto native EInputDeviceType GetCurrentInputDevice()
proto native bool IsEnabledMouseAndKeyboard()
static string GetRichtextButtonIconFromInputAction(notnull UAInput pInput, string pLocalizedDescription, int pInputDeviceType=EUAINPUT_DEVICE_CONTROLLER, float pScale=ICON_SCALE_NORMAL, bool pVertical=false)
Определения InputUtils.c:167
static const float ICON_SCALE_TOOLBAR
Определения InputUtils.c:15
Определения InputUtils.c:2
Определения ChernarusMap_Open.c:2
Определения MapHandler.c:2
vector GetMarkerPos()
Определения InventoryItem.c:1177
int GetMarkerColor()
Определения InventoryItem.c:1187
string GetMarkerText()
Определения InventoryItem.c:1182
int GetMarkerIcon()
Определения InventoryItem.c:1192
Определения InventoryItem.c:1163
static string GetMarkerTypeFromID(int id)
Определения MapMarkersInfo.c:36
Определения MapMarkersInfo.c:2
Определения gameplay.c:323
Определения EnMath.c:7
void RemoveActiveInputRestriction(int restrictor)
ScriptInvoker GetOnInputDeviceChanged()
Определения gameplay.c:851
ScriptInvoker GetOnInputPresetChanged()
Определения gameplay.c:859
void RemoveActiveInputExcludes(array< string > excludes, bool bForceSupress=false)
deprecated
Определения PlayerBaseClient.c:2
Определения gameplay.c:317
proto bool Remove(func fn, int flags=EScriptInvokerRemoveFlags.ALL)
remove specific call from list
proto bool Insert(func fn, int flags=EScriptInvokerInsertFlags.IMMEDIATE)
insert method to list
Определения EnWidgets.c:220
proto native UAInput GetInputByID(int iID)
returns list of all bindable (i.e. visible) inputs from the active group ('core' by default)
proto native bool LocalPress()
void UpdateControlsElementVisibility()
Определения ControlsXboxNew.c:540
override void OnShow()
Определения MapMenu.c:177
void SetGPSMarkerVisibility(bool pState)
Определения MapMenu.c:382
ImageWidget m_Images
Определения MapMenu.c:21
override void Update(float timeslice)
Определения MapMenu.c:219
override void LoadMapMarkers()
Определения MapMenu.c:322
ref MapWidget m_MapWidgetInstance
Определения MapMenu.c:17
void AddMarker(vector pos, int color, int icon=0)
Определения MapMenu.c:310
Widget m_UpperLegendContainer
Определения MapMenu.c:24
const int SCALE_RULER_NUM_SEGMENTS
Определения MapMenu.c:5
void SetUpperLegendVisibility(bool pState)
Определения MapMenu.c:398
TextWidget m_ToolsGPSElevationText
Определения MapMenu.c:29
TextWidget m_ToolsGPSYText
Определения MapMenu.c:31
ItemMap m_Map
Определения MapMenu.c:34
void CloseMapMenu()
Определения MapMenu.c:332
void RenderScaleRuler()
Определения MapMenu.c:411
override void InitMapItem(EntityAI item)
Определения MapMenu.c:168
TextWidget m_ToolsScaleCellSizeText
Определения MapMenu.c:32
Widget m_ToolsCompassBase
Определения MapMenu.c:25
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
Определения ControlsXboxNew.c:71
bool m_IsOpenning
Определения MapMenu.c:10
ImageWidget m_GPSMarkerArrow
Определения MapMenu.c:23
ref IngameHud m_Hud
Определения MapMenu.c:15
CanvasWidget m_ToolsScaleCellSizeCanvas
Определения MapMenu.c:33
override bool OnKeyPress(Widget w, int x, int y, int key)
Определения MapMenu.c:199
void SetCompassUIVisibility(bool pState)
Определения MapMenu.c:369
ref MapHandler m_MapMenuHandler
Определения MapMenu.c:16
void ~MapMenu()
Определения MapMenu.c:40
ref MapNavigationBehaviour m_MapNavigationBehaviour
Определения MapMenu.c:38
TextWidget m_ToolsGPSXText
Определения MapMenu.c:30
float m_ToolScaleCellSizeCanvasWidth
Определения MapMenu.c:12
void SetGPSDirectionVisibility(bool pState)
Определения MapMenu.c:390
void UpdateControlsElements()
Определения ControlsXboxNew.c:527
bool m_WasChanged
Определения MapMenu.c:7
const string COORD_FORMAT
Определения MapMenu.c:3
ImageWidget m_ToolsCompassArrow
Определения MapMenu.c:26
Widget m_GPSMarker
Определения MapMenu.c:22
void RemoveMarker()
Определения MapMenu.c:317
override Widget Init()
Определения MapMenu.c:49
override bool OnClick(Widget w, int x, int y, int button)
Определения MapMenu.c:185
TextWidget m_ToolsCompassAzimuth
Определения MapMenu.c:27
void ProcessDistanceAndUnits(float num, out float dist, out string units)
Определения MapMenu.c:440
ref SizeToChild m_LegendResizer
Определения MapMenu.c:18
void ShiftMapToolsContainer()
Определения MapMenu.c:492
TextWidget m_ToolsScaleContourText
Определения MapMenu.c:28
float m_ToolsContainerPos0[2]
Определения MapMenu.c:13
Widget m_ToolbarPanel
Определения GesturesMenu.c:110
Widget m_MapToolsContainer
Определения MapMenu.c:20
const int SCALE_RULER_LINE_WIDTH
Определения MapMenu.c:4
void OnInputPresetChanged()
Определения ControlsXboxNew.c:63
Определения DayZGame.c:64
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения EnConvert.c:106
proto native CGame GetGame()
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float Floor(float f)
Returns floor of value.
static proto float Round(float f)
Returns mathematical round of value.
static proto float Ceil(float f)
Returns ceil of value.
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
const int IDC_CANCEL
Определения constants.c:136
proto native external Widget CreateWidgets(string layout, Widget parentWidget=NULL, bool immedUpdate=true)
Create widgets from *.layout file.
EInputDeviceType
Определения input.c:3