12 private ref array<ref SCR_CursorEditor> m_Cursors;
15 private SCR_CursorEditor m_CurrentCursor;
16 private vector m_vGamepadCursorSize;
17 private float m_fGamepadCursorRadius;
18 private float m_fGamepadCursorRadiusSq;
30 private vector m_vCursorPos;
31 private vector m_vCursorPosWorld;
32 private vector m_vCursorPosWorldNormalized;
33 private int m_iCursorPosX;
34 private int m_iCursorPosY;
35 private bool m_bCanFocus =
true;
36 private int m_iFrameIndex;
37 private int m_iFrameUpdate;
38 private int m_iFrameUpdateWorld;
39 private float m_fTargetAlpha = 1;
40 private float m_fTargetAlphaStrength;
50 if (!m_InputManager || !m_InputManager.IsUsingMouseAndKeyboard())
61 float mouseX = pos[0];
62 float mouseY = pos[1];
65 mouseX = workspace.DPIScale(mouseX);
66 mouseY = workspace.DPIScale(mouseY);
69 m_InputManager.SetCursorPosition(mouseX, mouseY);
71 m_iCursorPosX = mouseX;
72 m_iCursorPosY = mouseY;
73 m_vCursorPos =
Vector(m_wWorkspace.DPIUnscale(m_iCursorPosX), m_wWorkspace.DPIUnscale(m_iCursorPosY), 0);
74 m_iFrameUpdate = m_iFrameIndex + 1;
83 if (m_iFrameUpdate == m_iFrameIndex)
86 m_iFrameUpdate = m_iFrameIndex;
89 if (m_InputManager && m_InputManager.IsUsingMouseAndKeyboard())
92 m_vCursorPos =
Vector(m_wWorkspace.DPIUnscale(m_iCursorPosX), m_wWorkspace.DPIUnscale(m_iCursorPosY), 0);
96 float cursorX, cursorY;
98 if (m_CurrentCursor && m_CurrentCursor.GetWidget())
99 m_CurrentCursor.GetWidget().GetScreenPos(cursorX, cursorY);
101 m_vCursorPos =
Vector(m_wWorkspace.DPIUnscale(cursorX), m_wWorkspace.DPIUnscale(cursorY), 0) + m_vGamepadCursorSize;
102 m_iCursorPosX = cursorX;
103 m_iCursorPosY = cursorY;
115 posX = m_iCursorPosX;
116 posY = m_iCursorPosY;
131 worldPos = m_vCursorPosWorldNormalized;
133 worldPos = m_vCursorPosWorld;
137 m_iFrameUpdateWorld = m_iFrameIndex;
153 if (mapEntity && mapEntity.
IsOpen())
155 float worldX, worldY;
157 worldPos[0] = worldX;
158 worldPos[2] = worldY;
159 worldPos[1] = world.GetSurfaceY(worldPos[0], worldPos[2]);
161 m_vCursorPosWorld = worldPos;
162 m_vCursorPosWorldNormalized = worldPos;
168 vector startPos = workspace.ProjScreenToWorld(cursorPos[0], cursorPos[1], outDir, world, -1);
176 if (startPos[1] < world.GetOceanBaseHeight())
180 trace.Start = startPos;
181 trace.End = startPos + outDir;
184 float traceDis = world.TraceMove(trace, null);
187 m_vCursorPosWorldNormalized = startPos + outDir * traceDis;
190 worldPos = m_vCursorPosWorldNormalized;
196 worldPos = startPos + outDir * traceDis;
200 m_vCursorPosWorld = worldPos;
201 m_vCursorPosWorldNormalized = worldPos;
210 return m_TraceEntity;
216 SCR_CursorEditor cursor;
217 if (!m_CursorsMap.Find(
type, cursor))
228 if (m_CurrentCursor && m_CurrentCursor.GetWidget())
230 opacity = m_CurrentCursor.GetWidget().GetOpacity();
231 m_CurrentCursor.GetWidget().SetOpacity(0);
234 if (cursor.GetWidget())
235 cursor.GetWidget().SetOpacity(opacity);
237 m_CurrentCursor = cursor;
250 return m_fGamepadCursorRadius;
257 return m_fGamepadCursorRadiusSq;
265 m_fTargetAlpha = alpha;
266 m_fTargetAlphaStrength = strength;
280 if (m_MapEntity && m_MapEntity.IsOpen())
285 editorState = m_StatesManager.GetState();
287 bool isEditing = m_PreviewManager && m_PreviewManager.IsEditing();
295 case (m_StatesManager && m_EditorManager && (m_StatesManager.IsWaiting() || m_EditorManager.IsModeChangeRequested())):
301 case (isEditing && !m_PreviewManager.IsChange()):
307 case (isEditing && m_PreviewManager.IsRotating()):
313 case (isEditing && (m_PreviewManager.GetTarget() || m_PreviewManager.IsFixedPosition())):
322 case (isEditing && !m_PreviewManager.CanMoveInRoot()):
330 if (m_PreviewManager.GetVerticalMode() ==
EEditorTransformVertical.GEOMETRY && m_PreviewManager.GetVerticalMode() == m_PreviewManager.GetVerticalModeReal())
339 if (m_PreviewManager.GetVerticalMode() ==
EEditorTransformVertical.GEOMETRY && m_PreviewManager.GetVerticalMode() == m_PreviewManager.GetVerticalModeReal())
358 case (editorState ==
EEditorState.SELECTING && m_HoverManager && m_HoverManager.GetInteractiveEntityUnderCursor()):
391 vector camPos = m_wWorkspace.ProjScreenToWorld(cursorPos[0], cursorPos[1], outDir,
GetGame().GetWorld(), -1);
395 trace.Start = camPos;
398 float coefTrace =
GetGame().GetWorld().TraceMove(trace, null);
400 m_TraceEntity = trace.TraceEnt;
403 if (!trace.TraceEnt || trace.TraceEnt.Type() == GenericTerrainEntity || !m_MouseArea.IsMouseOn())
408 while (genericEntity)
433 if ((!m_MouseArea || m_MouseArea.IsMouseOn()) && (!m_MapEntity || !m_MapEntity.IsOpen()))
435 m_InputManager.ActivateContext(
"EditorMouseAreaContext");
438 if (m_HoverManager && !m_HoverManager.GetEntityUnderCursorCandidate())
439 m_HoverManager.SetEntityUnderCursor(entityUnderCursor);
442 if (!m_CurrentCursor)
445 Widget currentCursorWidget = m_CurrentCursor.GetWidget();
446 if (!currentCursorWidget)
449 float currentAlpha = currentCursorWidget.GetOpacity();
450 if (currentAlpha != m_fTargetAlpha)
451 currentCursorWidget.SetOpacity(
Math.Lerp(currentAlpha, m_fTargetAlpha, m_fTargetAlphaStrength * tDelta));
464 super.HandlerAttachedScripted(w);
471 m_wWorkspace =
GetGame().GetWorkspace();
472 m_InputManager =
GetGame().GetInputManager();
490 m_EditorManager.GetOnModeChangeRequest().Insert(
UpdateCursor);
495 m_StatesManager.GetOnStateChange().Insert(
UpdateCursor);
496 m_StatesManager.GetOnIsWaitingChange().Insert(
UpdateCursor);
500 if (m_PreviewManager)
502 m_PreviewManager.GetOnPreviewCreate().Insert(
UpdateCursor);
503 m_PreviewManager.GetOnPreviewChange().Insert(
UpdateCursor);
504 m_PreviewManager.GetOnPreviewDelete().Insert(
UpdateCursor);
505 m_PreviewManager.GetOnTargetChange().Insert(
UpdateCursor);
519 if (m_CommandManager)
525 foreach (SCR_CursorEditor cursor: m_Cursors)
527 cursor.InitWidget(w);
528 m_CursorsMap.Insert(cursor.GetType(), cursor);
532 SCR_CursorEditor defaultCursor;
536 if (defaultCursor.GetWidget())
539 m_vGamepadCursorSize =
FrameSlot.GetSize(defaultCursor.GetWidget());
540 m_vGamepadCursorSize[0] = m_vGamepadCursorSize[0] * alignment[0];
541 m_vGamepadCursorSize[1] = m_vGamepadCursorSize[1] * alignment[1];
542 m_fGamepadCursorRadius =
Math.Max(m_vGamepadCursorSize[0], m_vGamepadCursorSize[1]);
543 m_fGamepadCursorRadiusSq =
Math.Pow(m_fGamepadCursorRadius, 2);
560 super.HandlerDeattached(w);
579 m_EditorManager.GetOnModeChangeRequest().Remove(
UpdateCursor);
584 if (m_PreviewManager)
586 m_PreviewManager.GetOnPreviewCreate().Remove(
UpdateCursor);
587 m_PreviewManager.GetOnPreviewChange().Remove(
UpdateCursor);
588 m_PreviewManager.GetOnPreviewDelete().Remove(
UpdateCursor);
589 m_PreviewManager.GetOnTargetChange().Remove(
UpdateCursor);
594 m_StatesManager.GetOnStateChange().Remove(
UpdateCursor);
595 m_StatesManager.GetOnIsWaitingChange().Remove(
UpdateCursor);
599 if (transformingManager)
602 if (m_CommandManager)
603 m_CommandManager.GetOnCommandStateChange().Remove(
UpdateCursor);
616class SCR_CursorEditor
657 void InitWidget(
Widget root)
SCR_EAIThreatSectorFlags flags
ArmaReforgerScripted GetGame()
ScriptInvoker OnInputDeviceIsGamepadInvoker()
override string GetID(string fileName, string varName, array< BaseContainer > objects, array< int > indexes)
void OnMenuUpdate(float tDelta)
SCR_CursorEditorUIComponent SCR_BaseEditorUIComponent SCR_BaseContainerCustomTitleEnum(EEditorCursor, "m_Type")
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
Super root of all classes in Enforce script.
proto external Managed FindComponent(typename typeName)
proto external IEntity GetParent()
ScriptInvoker GetOnCommandStateChange()
TraceFlags m_DefaultWorldTraceFlags
bool GetCursorWorldPos(out vector worldPos, bool isNormalized=false, TraceFlags flags=-1)
bool TraceFilter(Class target)
const float TRACE_DIS_REPEATED
void SetCursorPos(vector pos, bool DPIScale=false)
override void HandlerAttachedScripted(Widget w)
const float TRACE_DIS_SINGLE
void GetCursorPos(out int posX, out int posY)
void SetCursorAlpha(float alpha, float strength=1)
float GetCursorRadiusSq()
SCR_EditableEntityComponent TraceEntity(vector cursorPos)
override void HandlerDeattached(Widget w)
void OnMenuUpdate(float tDelta)
void OnMapToggled(MapConfiguration config)
void OnFilterChange(EEditableEntityState state, set< SCR_EditableEntityComponent > entitiesInsert, set< SCR_EditableEntityComponent > entitiesRemove)
void SetCursorType(EEditorCursor type)
void OnInputDeviceIsGamepad(bool isGamepad)
SCR_BaseEditableEntityFilter GetFilter(EEditableEntityState state, bool showError=false)
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapClose()
Get on map close invoker.
void GetMapCursorWorldPosition(out float worldX, out float worldY)
bool IsOpen()
Check if the map is opened.
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapOpen()
Get on map open invoker.
static SCR_MapEntity GetMapInstance()
Get map entity instance.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
SCR_FieldOfViewSettings Attribute
EEditorTransformVertical
Vertical transformation mode.
EEditorState
Unique editor state.
EEditableEntityInteraction
Type of suggested interaction when hovering edited entity on top of another entity.
EEditorCommandActionFlags
Simplified action conditions.
SCR_CursorEditorUIComponent SCR_BaseEditorUIComponent BaseContainerProps()
EEditorCursor
Editor cursor type. Values must match cursor IDs in gproj!
proto native vector Vector(float x, float y, float z)