Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MapDescriptorManualCameraComponent.c
Go to the documentation of this file.
1
2
4[BaseContainerProps(), SCR_BaseManualCameraComponentTitle()]
6{
7 [Attribute("0", UIWidgets.SearchComboBox, "Descriptor type.", enums: ParamEnumArray.FromEnum(EMapDescriptorType))]
9
10 [Attribute(desc: "Quad name from imageset defined on MapWidget.")]
11 protected string m_sImageDef;
12
13 [Attribute("0 0 0 1", desc: "Color of camera icon.")]
14 protected ref Color m_IconColor;
15
16 [Attribute("0 0 0 0.2", desc: "Color of the view cone.")]
17 protected ref Color m_ViewConeColor;
18
19 [Attribute("0.375", uiwidget: UIWidgets.Slider, "Icon size coefficient.", params: "0 1 0.125")]
20 protected float m_fIconScale;
21
22 [Attribute("1000", desc: "Maximum length of the view cone (and also maximum distance of tracing method).")]
23 protected float m_fMaxViewConeLength;
24
25 [Attribute("ManualCamera", desc: "Name of canvas widget in which view cone will be rendered.")]
26 protected string m_sMapCanvasWidgetName;
27
29 protected ref MapItem m_MapItem;
31 protected ref PolygonDrawCommand m_DrawLine = new PolygonDrawCommand();
32 protected ref array<ref CanvasWidgetCommand> m_MapDrawCommands = { m_DrawLine };
33
35 protected BaseWorld m_World;
36 protected ref TraceParam m_Trace = new TraceParam();
37
38 //------------------------------------------------------------------------------------------------
44 void TraceScreenPos(float width, float height, out vector dir, out float traceCoef)
45 {
46 vector pos = m_Workspace.ProjScreenToWorldNative(width, height, dir, m_World);
48
49 TraceParam trace = new TraceParam();
50 m_Trace.Start = pos;
51 m_Trace.End = pos + dir;
52
53 traceCoef = Math.Max(m_World.TraceMove(m_Trace, null), traceCoef);
54 }
55
56 //------------------------------------------------------------------------------------------------
58 {
59 if (!m_MapEntity.IsOpen())
60 return;
61
62 //--- Update icon position
63 m_MapItem.SetPos(param.transform[3][0], param.transform[3][2]);
64 m_MapItem.SetAngle(param.rotOriginal[0] + param.rotDelta[0]);
65
66 //--- Initialize view cone canvas (must be done after the map was opened)
67 if (!m_MapCanvas && m_MapEntity.GetMapMenuRoot())
68 m_MapCanvas = CanvasWidget.Cast(m_MapEntity.GetMapMenuRoot().FindWidget(m_sMapCanvasWidgetName));
69
70 if (!m_MapCanvas)
71 return;
72
73 //--- Trace left and right side of the screen
74 const int widthLeft = 0; // TODO: check for good const usage
75 int widthRight = m_Workspace.GetWidth();
76 float height = m_Workspace.GetHeight() / 2;
77 float traceCoef;
78 vector dirLeft, dirRight;
79 TraceScreenPos(widthLeft, height, dirLeft, traceCoef);
80 TraceScreenPos(widthRight, height, dirRight, traceCoef);
81
82 //--- Convert positions to map space
83 vector posCam = param.transform[3];
84 vector posLeft = posCam + dirLeft * traceCoef;
85 vector posRight = posCam + dirRight * traceCoef;
86
87 int posCamX, posCamY, posLeftX, posLeftY, posRightX, posRightY;
88 float mapZoom = m_MapEntity.GetCurrentZoom();
89 m_MapEntity.WorldToScreenCustom(posCam[0], posCam[2], posCamX, posCamY, mapZoom, true);
90 m_MapEntity.WorldToScreenCustom(posLeft[0], posLeft[2], posLeftX, posLeftY, mapZoom, true);
91 m_MapEntity.WorldToScreenCustom(posRight[0], posRight[2], posRightX, posRightY, mapZoom, true);
92
93 //--- Draw the view cone
94 m_DrawLine.m_Vertices = {posCamX, posCamY, posLeftX, posLeftY, posRightX, posRightY};
95 m_MapCanvas.SetDrawCommands(m_MapDrawCommands);
96 }
97
98 //------------------------------------------------------------------------------------------------
99 override bool EOnCameraInit()
100 {
102 if (!m_MapEntity)
103 return false;
104
105 m_MapItem = m_MapEntity.CreateCustomMapItem();
106 m_MapItem.SetBaseType(m_iBaseType);
107 m_MapItem.SetImageDef(m_sImageDef);
108
109 MapDescriptorProps props = m_MapItem.GetProps();
110 props.SetFrontColor(m_IconColor);
111 props.SetOutlineColor(Color.FromInt(Color.BLACK));
112 props.SetIconSize(1, m_fIconScale, m_fIconScale);
113 props.Activate(true);
114 m_MapItem.SetProps(props);
115
116 m_DrawLine.m_iColor = m_ViewConeColor.PackToInt();
117
118 m_Workspace = GetGame().GetWorkspace();
119 m_World = GetCameraEntity().GetWorld();
120 m_Trace = new TraceParam();
121 m_Trace.Flags = TraceFlags.WORLD | TraceFlags.OCEAN;
122
123 return true;
124 }
125
126 //------------------------------------------------------------------------------------------------
127 override void EOnCameraExit()
128 {
129 if (m_MapItem)
130 m_MapItem.Recycle();
131 }
132}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition Color.c:13
Definition Math.c:13
Parent class from which all SCR_ManualCamera components inherit.
Parameter for carrying information between individual camera components.
override void EOnCameraFrame(SCR_ManualCameraParam param)
void TraceScreenPos(float width, float height, out vector dir, out float traceCoef)
static SCR_MapEntity GetMapInstance()
Get map entity instance.
SCR_FieldOfViewSettings Attribute
EMapDescriptorType
TraceFlags
Definition TraceFlags.c:13