5 [
Attribute(
"{9784E36B47AA068A}UI/Textures/Editor/Cursors/GamepadCursor_MultiSelection.edds", UIWidgets.ResourcePickerThumbnail,
desc:
"Multiselection texture",
params:
"edds")]
6 ResourceName m_sMultiselectTexture;
8 [
Attribute(defvalue:
"100", uiwidget: UIWidgets.EditBox,
desc:
"Adjust speed of multiselection expansion. Multiplier of frame timeSlice",
params:
"1 1000")]
9 float m_fMultiselectSpeed;
11 const float MAX_HOLD_TIME = 4;
12 const float MULTISEL_INIT_SIZE = 0.25;
15 protected ref array<ref CanvasWidgetCommand> m_Commands =
new array<ref CanvasWidgetCommand>;
18 protected float m_fHoldTimeSlice = 0;
19 protected float m_fSelCircleSize = 0;
20 protected ref ImageDrawCommand m_SelectionCircle;
21 protected ref SharedItemRef m_SelCircleSharedItem;
24 protected CanvasWidget m_DrawCanvas;
30 float GetSelCircleSize()
32 return m_fSelCircleSize;
37 protected void RenderSelectionCircle(
float timeSlice)
42 if (!m_SelCircleSharedItem)
44 m_SelCircleSharedItem = m_DrawCanvas.LoadTexture(m_sMultiselectTexture);
45 if (!m_SelCircleSharedItem.IsValid())
49 if (m_fHoldTimeSlice < MAX_HOLD_TIME)
50 m_fHoldTimeSlice += timeSlice;
52 m_SelectionCircle =
new ImageDrawCommand();
53 if (m_SelectionCircle)
56 m_SelectionCircle.m_pTexture = m_SelCircleSharedItem;
59 m_SelectionCircle.m_Size = Vector(m_fSelCircleSize, m_fSelCircleSize, 0);
62 m_SelectionCircle.m_iFlags = (WidgetFlags.STRETCH | WidgetFlags.BLEND);
64 if (m_Commands.Find(m_SelectionCircle) == -1)
65 m_Commands.Insert(m_SelectionCircle);
77 protected void AdjustCircleSize()
80 m_DrawCanvas.GetScreenSize(sizeX, sizeY);
82 if (m_fHoldTimeSlice < 0.2)
84 m_fSelCircleSize = Math.Lerp(0, sizeY * MULTISEL_INIT_SIZE, m_fHoldTimeSlice * 5);
88 m_fSelCircleSize = (sizeY * MULTISEL_INIT_SIZE) + (m_fHoldTimeSlice * m_fMultiselectSpeed);
94 protected void RenderSelectionRectangle()
107 override void OnMapOpen(MapConfiguration config)
110 m_DrawCanvas = CanvasWidget.Cast(config.RootWidgetRef.FindAnyWidget(
SCR_MapConstants.DRAWING_WIDGET_NAME));
114 m_DrawCanvas.SetOffsetPx(
m_MapEntity.GetCurrentPan() * -1);
120 override void Update(
float timeSlice)
123 m_SelectionCircle =
null;
129 RenderSelectionCircle(timeSlice);
130 RenderSelectionRectangle();
133 if(m_Commands.Count() > 0)
135 m_DrawCanvas.SetDrawCommands(m_Commands);