Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_MapSelectionModule.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
4 {
5  [Attribute("{9784E36B47AA068A}UI/Textures/Editor/Cursors/GamepadCursor_MultiSelection.edds", UIWidgets.ResourcePickerThumbnail, desc: "Multiselection texture", params: "edds")]
6  ResourceName m_sMultiselectTexture;
7 
8  [Attribute(defvalue: "100", uiwidget: UIWidgets.EditBox, desc: "Adjust speed of multiselection expansion. Multiplier of frame timeSlice", params: "1 1000")]
9  float m_fMultiselectSpeed;
10 
11  const float MAX_HOLD_TIME = 4; // seconds, after this point circle multi selection no longer expands
12  const float MULTISEL_INIT_SIZE = 0.25; // multiplier of initial selection texture size -> multiplies screen size, so val 0.2 will result in texture being 1/5th of screens y size
13 
14  // arrays
15  protected ref array<ref CanvasWidgetCommand> m_Commands = new array<ref CanvasWidgetCommand>; // Stores all commands that will be drawn on that canvas
16 
18  protected float m_fHoldTimeSlice = 0; // Multiselection hold time slice
19  protected float m_fSelCircleSize = 0; // Multiselection circle size
20  protected ref ImageDrawCommand m_SelectionCircle;
21  protected ref SharedItemRef m_SelCircleSharedItem;
22 
23  // cached objects
24  protected CanvasWidget m_DrawCanvas;
25  protected SCR_MapCursorModule m_CursorModule;
26  protected SCR_MapCursorInfo m_CursorInfo;
27 
28  //------------------------------------------------------------------------------------------------
29  // Get multiselection circle size
30  float GetSelCircleSize()
31  {
32  return m_fSelCircleSize;
33  }
34 
35  //------------------------------------------------------------------------------------------------
37  protected void RenderSelectionCircle(float timeSlice)
38  {
39  if ( (m_CursorModule.GetCursorState() & EMapCursorState.CS_MULTI_SELECTION) && m_CursorModule.m_eMultiSelType == EMapCursorSelectType.CIRCLE)
40  {
41 
42  if (!m_SelCircleSharedItem)
43  {
44  m_SelCircleSharedItem = m_DrawCanvas.LoadTexture(m_sMultiselectTexture);
45  if (!m_SelCircleSharedItem.IsValid())
46  return;
47  }
48 
49  if (m_fHoldTimeSlice < MAX_HOLD_TIME) // max size after set time
50  m_fHoldTimeSlice += timeSlice;
51 
52  m_SelectionCircle = new ImageDrawCommand();
53  if (m_SelectionCircle)
54  {
55  //m_SelectionCircle.m_iColor = 0xffE2A750;
56  m_SelectionCircle.m_pTexture = m_SelCircleSharedItem;
57 
58  AdjustCircleSize();
59  m_SelectionCircle.m_Size = Vector(m_fSelCircleSize, m_fSelCircleSize, 0);
60 
61  m_SelectionCircle.m_Position = Vector(m_CursorInfo.Scale(m_CursorInfo.x) - m_SelectionCircle.m_Size[0]/2, m_CursorInfo.Scale(m_CursorInfo.y) - m_SelectionCircle.m_Size[1]/2, 0);
62  m_SelectionCircle.m_iFlags = (WidgetFlags.STRETCH | WidgetFlags.BLEND);
63 
64  if (m_Commands.Find(m_SelectionCircle) == -1)
65  m_Commands.Insert(m_SelectionCircle);
66  }
67  }
68  else
69  {
70  m_fHoldTimeSlice = 0;
71  m_fSelCircleSize = 0;
72  }
73  }
74 
75  //------------------------------------------------------------------------------------------------
77  protected void AdjustCircleSize()
78  {
79  float sizeX, sizeY;
80  m_DrawCanvas.GetScreenSize(sizeX, sizeY);
81 
82  if (m_fHoldTimeSlice < 0.2)
83  {
84  m_fSelCircleSize = Math.Lerp(0, sizeY * MULTISEL_INIT_SIZE, m_fHoldTimeSlice * 5);
85  }
86  else
87  {
88  m_fSelCircleSize = (sizeY * MULTISEL_INIT_SIZE) + (m_fHoldTimeSlice * m_fMultiselectSpeed);
89  }
90  }
91 
92  //------------------------------------------------------------------------------------------------
94  protected void RenderSelectionRectangle()
95  {
96  if ( (m_CursorModule.GetCursorState() & EMapCursorState.CS_MULTI_SELECTION) && m_CursorModule.m_eMultiSelType == EMapCursorSelectType.RECTANGLE)
97  {
98  m_MapEntity.SetSelection( Vector(m_CursorInfo.Scale(m_CursorInfo.startPosMultiSel[0]),0,m_CursorInfo.Scale(m_CursorInfo.startPosMultiSel[1])), Vector(m_CursorInfo.Scale(m_CursorInfo.x),0,m_CursorInfo.Scale(m_CursorInfo.y)));
99  }
100  else
101  {
102  m_MapEntity.ResetSelection();
103  }
104  }
105 
106  //------------------------------------------------------------------------------------------------
107  override void OnMapOpen(MapConfiguration config)
108  {
110  m_DrawCanvas = CanvasWidget.Cast(config.RootWidgetRef.FindAnyWidget(SCR_MapConstants.DRAWING_WIDGET_NAME));
111  m_CursorInfo = m_CursorModule.GetCursorInfo();
112 
113  m_DrawCanvas.SetZoom(m_MapEntity.GetCurrentZoom() / m_MapEntity.GetMapWidget().PixelPerUnit());
114  m_DrawCanvas.SetOffsetPx(m_MapEntity.GetCurrentPan() * -1);
115 
116  m_MapEntity.ResetSelection();
117  }
118 
119  //------------------------------------------------------------------------------------------------
120  override void Update(float timeSlice)
121  {
122  // cleanup
123  m_SelectionCircle = null;
124  m_Commands.Clear();
125 
126  // only when cursor module is active
127  if (m_CursorModule)
128  {
129  RenderSelectionCircle(timeSlice);
130  RenderSelectionRectangle();
131  }
132 
133  if(m_Commands.Count() > 0)
134  {
135  m_DrawCanvas.SetDrawCommands(m_Commands);
136  }
137  }
138 };
m_MapEntity
protected SCR_MapEntity m_MapEntity
Definition: SCR_MapGadgetComponent.c:14
EMapCursorState
EMapCursorState
Map cursor state.
Definition: SCR_MapConstants.c:39
SCR_MapSelectionModule
Definition: SCR_MapSelectionModule.c:3
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
m_CursorModule
protected SCR_MapCursorModule m_CursorModule
Definition: SCR_MapDrawingUI.c:181
SCR_MapCursorModule
Map cursor behavior and mode setup.
Definition: SCR_MapCursorModule.c:39
Attribute
typedef Attribute
Post-process effect of scripted camera.
EMapCursorSelectType
EMapCursorSelectType
Map cursor multiselection type.
Definition: SCR_MapConstants.c:72
m_CursorInfo
protected SCR_MapCursorInfo m_CursorInfo
Definition: SCR_MapToolInteractionUI.c:38
SCR_MapModuleBase
Map module base class.
Definition: SCR_MapModuleBase.c:4
SCR_MapCursorInfo
Cursor data.
Definition: SCR_MapCursorModule.c:3
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_MapConstants
Definition: SCR_MapConstants.c:2
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468