3 [
Attribute(defvalue:
"1994", uiwidget: UIWidgets.EditBox,
desc:
"pix, exact length of the ruler within the provided image, default base length being 1km in world space")]
6 [
Attribute(
"RulerFrame", UIWidgets.EditBox,
desc:
"Root frame widget name")]
7 string m_sRootWidgetName;
9 [
Attribute(
"RulerImage", UIWidgets.EditBox,
desc:
"Ruler image widget name")]
10 string m_sImageWidgetName;
12 [
Attribute(
"ruler", UIWidgets.EditBox,
desc:
"Toolmenu imageset quad name")]
13 string m_sToolMenuIconName;
15 [
Attribute(
"", UIWidgets.Object,
desc:
"Array of sizes, multiplicator values of default base ruler length of 1km")]
16 protected ref array<ref int> m_aSizesArray;
18 protected bool m_bIsVisible;
19 protected bool m_bWantedVisible;
20 protected bool m_bIsDragged;
21 protected bool m_bIsZooming;
22 protected int m_iCurrentSizeIndex;
23 protected int m_iSizesCount;
24 protected float m_fPosX, m_fPosY;
25 protected float m_fWorldX, m_fWorldY;
26 protected float m_fAngle;
27 protected float m_fBaseImageSize[2];
28 protected float m_fSizeCoef;
29 protected vector m_vMapPan;
33 protected Widget m_wFrame;
34 protected ImageWidget m_wImage;
35 protected WorkspaceWidget m_wWorkspace;
39 protected void ToggleVisible()
51 protected void SetVisible(
bool visible,
bool saveState =
false)
60 m_fSizeCoef = 1000 / (m_fRulerLength / m_fBaseImageSize[0]);
61 float sizeVal =
m_wWorkspace.DPIUnscale(zoomVal * m_fSizeCoef);
62 SetSize(sizeVal, sizeVal);
67 m_MapEntity.GetMapWidget().GetScreenSize(sizeX, sizeY);
107 protected void SetSize(
float x,
float y,
bool nextSize =
false)
123 protected void OnMapZoom(
float zoomVal)
125 float sizeVal =
m_wWorkspace.DPIUnscale(zoomVal * m_fSizeCoef);
126 SetSize(sizeVal, sizeVal);
132 protected void OnMapPan(
float x,
float y,
bool adjustedPan)
136 m_bIsZooming =
false;
138 float screenX, screenY, screenSX, screenSY;
139 m_MapEntity.WorldToScreen( m_fWorldX, m_fWorldY, screenX, screenY,
true );
156 protected void OnDragWidget(Widget widget)
166 protected void OnActivateTool(Widget widget)
172 float sizeVal =
m_wWorkspace.DPIUnscale(zoomVal * m_fSizeCoef);
177 SetSize(sizeVal, sizeVal);
181 SetSize(sizeVal, sizeVal,
true);
186 protected void OnInputQuickBind(
float value, EActionTrigger reason)
192 override void OnMapOpen(MapConfiguration config)
194 super.OnMapOpen(config);
202 m_fBaseImageSize[0] = x;
203 m_fBaseImageSize[1] = y;
207 if ( SCR_MapToolInteractionUI.Cast(
m_MapEntity.GetMapUIComponent(SCR_MapToolInteractionUI)) )
209 SCR_MapToolInteractionUI.GetOnDragWidgetInvoker().Insert(OnDragWidget);
210 SCR_MapToolInteractionUI.GetOnActivateToolInvoker().Insert(OnActivateTool);
218 override void OnMapClose(MapConfiguration config)
221 SetVisible(
false,
true);
223 super.OnMapClose(config);
240 GetGame().GetInputManager().AddActionListener(
"MapToolProtractor", EActionTrigger.DOWN, OnInputQuickBind);
245 override void Update(
float timeSlice)
252 m_wFrame.GetScreenSize(sizeX, sizeY);
264 m_bHookToRoot =
true;