Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
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;
22
23 // cached objects
25 protected SCR_MapCursorModule m_CursorModule;
27
28 //------------------------------------------------------------------------------------------------
29 // Get multiselection circle size
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
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();
54 {
55 //m_SelectionCircle.m_iColor = 0xffE2A750;
57
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)
66 }
67 }
68 else
69 {
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 {
109 m_CursorModule = SCR_MapCursorModule.Cast(m_MapEntity.GetMapModule(SCR_MapCursorModule));
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);
131 }
132
133 if(m_Commands.Count() > 0)
134 {
135 m_DrawCanvas.SetDrawCommands(m_Commands);
136 }
137 }
138};
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
EMapCursorState
Map cursor state.
EMapCursorSelectType
Map cursor multiselection type.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition Math.c:13
void SCR_MapModuleBase()
Dont use arguments in the contructor for this class or its children.
SCR_MapEntity m_MapEntity
ref array< ref CanvasWidgetCommand > m_Commands
ref ImageDrawCommand m_SelectionCircle
SCR_MapCursorModule m_CursorModule
float m_fHoldTimeSlice
controller multi selection
override void OnMapOpen(MapConfiguration config)
void RenderSelectionCircle(float timeSlice)
Render multiselection circle.
ref SharedItemRef m_SelCircleSharedItem
void RenderSelectionRectangle()
Render multiselection rectangle.
void AdjustCircleSize()
Adjust multiselection circle size based on hold time.
override void Update(float timeSlice)
SCR_FieldOfViewSettings Attribute
proto native vector Vector(float x, float y, float z)
WidgetFlags
Widget flags. See enf::Widget::SetFlags().
Definition WidgetFlags.c:14