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;
8 protected bool m_HasCompass
9 protected bool m_HasGPS
51 Widget mapToolsContainer = layoutRoot.FindAnyWidget(
"Map_Tools_Container");
52 mapToolsContainer.GetScript(m_LegendResizer);
54 m_MapWidgetInstance =
MapWidget.Cast(layoutRoot.FindAnyWidget(
"Map"));
55 m_GPSMarker = layoutRoot.FindAnyWidget(
"GPSMarkerCircle");
56 m_GPSMarkerArrow = ImageWidget.Cast(layoutRoot.FindAnyWidget(
"GPSMarkerArrow"));
57 m_UpperLegendContainer = layoutRoot.FindAnyWidget(
"Tools_Extra");
59 m_ToolsCompassBase = layoutRoot.FindAnyWidget(
"Tools_Compass_Base");
60 m_ToolsCompassArrow = ImageWidget.Cast(layoutRoot.FindAnyWidget(
"Tools_Compass_Arrow"));
61 m_ToolsCompassAzimuth =
TextWidget.Cast(layoutRoot.FindAnyWidget(
"Tools_Compass_Azimuth"));
62 m_ToolsGPSXText =
TextWidget.Cast(layoutRoot.FindAnyWidget(
"Tools_GPS_X_Value"));
63 m_ToolsGPSYText =
TextWidget.Cast(layoutRoot.FindAnyWidget(
"Tools_GPS_Y_Value"));
64 m_ToolsGPSElevationText =
TextWidget.Cast(layoutRoot.FindAnyWidget(
"Tools_GPS_Elevation_Value"));
65 m_ToolsScaleContourText =
TextWidget.Cast(layoutRoot.FindAnyWidget(
"Tools_Scale_Contour_Value"));
66 m_ToolsScaleCellSizeText =
TextWidget.Cast(layoutRoot.FindAnyWidget(
"Tools_Scale_CellSize_Value"));
67 m_ToolsScaleCellSizeCanvas = CanvasWidget.Cast(layoutRoot.FindAnyWidget(
"Tools_Scale_CellSize_Canvas"));
69 float canvasHeight = 0;
70 m_ToolsScaleCellSizeCanvas.GetSize(m_ToolScaleCellSizeCanvasWidth, canvasHeight);
72 if (m_MapWidgetInstance)
77 if (player && !player.GetLastMapInfo(scale, mapPosition))
81 mapPosition =
Vector(tempPosition[0], tempPosition[1], tempPosition[2]);
84 m_MapWidgetInstance.SetScale(scale);
85 m_MapWidgetInstance.SetMapPos(mapPosition);
97 m_MapNavigationBehaviour = player.GetMapNavigationBehaviour();
98 if (m_MapNavigationBehaviour)
113 m_MapWidgetInstance.SetMapPos(m_MapNavigationBehaviour.GetPositionReal());
135 m_MapMenuHandler =
new MapHandler(m_MapWidgetInstance);
149 super.InitMapItem(item);
158 super.OnClick(w,
x,
y, button);
160 switch (w.GetUserID())
172 super.OnKeyPress(w,
x,
y, key);
201 super.Update(timeslice);
202 m_ToolsScaleCellSizeCanvas.Clear();
206 if (m_MapWidgetInstance)
210 m_MapWidgetInstance.RemoveChild(m_Images);
215 m_ToolsScaleContourText.SetText(
string.Format(
"%1 m", m_MapWidgetInstance.GetContourInterval()));
217 float rulerMaxDistance;
219 ProcessDistanceAndUnits(m_MapWidgetInstance.GetCellSize(m_ToolScaleCellSizeCanvasWidth), rulerMaxDistance, rulerUnits);
220 m_ToolsScaleCellSizeText.SetText(
string.Format(
"%1%2", rulerMaxDistance, rulerUnits));
222 if (m_MapNavigationBehaviour)
224 vector mapPos = m_MapWidgetInstance.MapToScreen(m_MapNavigationBehaviour.GetPositionReal());
225 float scale = 1 - m_MapWidgetInstance.GetScale();
229 vector rot = player.GetYawPitchRoll();
236 m_GPSMarkerArrow.SetRotation(0, 0, angle);
237 m_ToolsCompassArrow.SetRotation(0, 0, angle);
238 m_ToolsCompassAzimuth.SetText(
string.Format(
"%1°", angle));
244 m_GPSMarker.SetSize(scale * 100, scale * 100);
245 m_GPSMarkerArrow.SetSize(scale * 100, scale * 100);
247 m_GPSMarker.GetSize(sizeX, sizeY);
250 m_GPSMarker.SetPos(mapPos[0] - sizeX/2, mapPos[1] - sizeY/2);
251 m_GPSMarkerArrow.SetPos(mapPos[0] - sizeX/2, mapPos[1] - sizeY/2);
253 if (coords.Count() == m_MapNavigationBehaviour.DISPLAY_GRID_POS_MAX_CHARS_COUNT * 2 && coords[0] >= 0)
255 m_ToolsGPSXText.SetText(
string.Format(COORD_FORMAT, coords[0], coords[1], coords[2]));
256 m_ToolsGPSYText.SetText(
string.Format(COORD_FORMAT, coords[3], coords[4], coords[5]));
260 m_ToolsGPSXText.SetText(
"-.--");
261 m_ToolsGPSYText.SetText(
"-.--");
264 m_ToolsGPSElevationText.SetText(
string.Format(
"%1m",
Math.
Round(player.GetPosition()[1])));
268 m_ToolsGPSXText.SetText(
"-.--");
269 m_ToolsGPSYText.SetText(
"-.--");
270 m_ToolsGPSElevationText.SetText(
"----m");
276 if (!m_IsOpenning && (
GetUApi().GetInputByID(UAUIBack).LocalPress() || isClosedWithShortcut))
280 player.SetLastMapInfo(m_MapWidgetInstance.GetScale(), m_MapWidgetInstance.GetMapPos());
286 m_IsOpenning =
false;
292 m_Map.InsertMarker(pos,
"",color,icon);
305 for (
int i = 0; i < m_Map.GetMarkerArray().
Count(); i++)
307 marker = m_Map.GetMarkerArray().Get(i);
316 m_Map.SyncMapMarkers();
317 m_WasChanged =
false;
323 player.SetMapClosingSyncSet(
false);
351 if (m_ToolsCompassArrow)
353 m_ToolsCompassArrow.Show(pState);
356 if (m_ToolsCompassAzimuth)
358 m_ToolsCompassAzimuth.Show(pState);
366 m_GPSMarker.Show(pState);
372 if (m_GPSMarkerArrow)
374 m_GPSMarkerArrow.Show(pState);
380 if (m_UpperLegendContainer)
382 m_UpperLegendContainer.Show(pState);
387 m_LegendResizer.ResizeParentToChild();
393 float sizeYShift = 8;
395 int lineColor = FadeColors.BLACK;
399 lineColor = FadeColors.BLACK;
402 lineColor = FadeColors.LIGHT_GREY;
407 m_ToolsScaleCellSizeCanvas.DrawLine(0, sizeYShift, segmentLength, sizeYShift, SCALE_RULER_LINE_WIDTH, lineColor);
409 else if (i == SCALE_RULER_NUM_SEGMENTS)
411 m_ToolsScaleCellSizeCanvas.DrawLine(segmentLength * (SCALE_RULER_NUM_SEGMENTS - 1), sizeYShift, segmentLength * SCALE_RULER_NUM_SEGMENTS, sizeYShift, SCALE_RULER_LINE_WIDTH, lineColor);
415 m_ToolsScaleCellSizeCanvas.DrawLine(segmentLength * (i - 1), sizeYShift, segmentLength * i, sizeYShift, SCALE_RULER_LINE_WIDTH, lineColor);
429 else if (num >= 100 && num <= 900)
void MapNavigationBehaviour(PlayerBase pPlayer, EMapNavigationType pNavigationType=EMapNavigationType.BASIC)
proto native vector ConfigGetVector(string path)
Get vector value from config on path.
proto native Mission GetMission()
proto native WorkspaceWidget GetWorkspace()
static bool GetMapDisplayNavigationInfo()
static bool GetMapIgnoreMapOwnership()
static bool GetMapIgnoreNavItemsOwnership()
static bool GetUse3DMap()
static bool GetMapDisplayPlayerPosition()
void ShowHudUI(bool show)
void ShowQuickbarUI(bool show)
static string GetMarkerTypeFromID(int id)
void RemoveActiveInputRestriction(int restrictor)
void RemoveActiveInputExcludes(array< string > excludes, bool bForceSupress=false)
deprecated
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float Round(float f)
Returns mathematical round of value.
static proto float Ceil(float f)
Returns ceil of value.
static proto float Floor(float f)
Returns floor of value.