Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_BaseWeaponAzimuthDisplay.c
Go to the documentation of this file.
2{
3 [Attribute("{CF4D101CDF040CD7}UI/layouts/HUD/MortarInfo/ScopeAzimuthSlots.layout", params: "layout")]
5
6 [Attribute("{0B9BE4C17177DAE5}UI/layouts/HUD/MortarInfo/ScopeAzimuthSteps.layout", params: "layout")]
8
9 //------------------------------------------------------------------------------------------------
10 void UpdateAzimuthInfo(vector aimRotation)
11 {
12 float azimuth = aimRotation[0];
13 float azimuthMils = azimuth * (m_fMils / 360);
14
15 m_iCurrentHeading = azimuth;
16
18 m_wMilsTextWidget.SetTextFormat(UIConstants.VALUE_UNIT_MILS, azimuthMils.ToString(4, 0));
19
21 m_wDegreesTextWidget.SetTextFormat(UIConstants.VALUE_UNIT_DEGREES, azimuth.ToString(3, 1));
22
23 float azimuthInPercent = azimuth - m_iCurrentHeading;
24 azimuthInPercent = Math.Clamp(azimuthInPercent, 0, 1);
25
26 // We didn't move so we don't need to reset
28 {
29 // Since SetSliderPosPixels() works in DPIScaled we need to first upscale our change to make it work in not FullHD resolutions.
30 float newSliderPos = GetGame().GetWorkspace().DPIScale(m_fSliderPosX + (m_fDegreeWidgetSize * azimuthInPercent));
31
33 m_wHeadingTableHolderWidget.SetSliderPosPixels(newSliderPos, 0);
34 }
35 else
36 {
39 }
40 }
41
42 //------------------------------------------------------------------------------------------------
44 {
45 float h;
46 widget.GetScreenSize(m_fDegreeWidgetSize, h);
47 m_fDegreeWidgetSize = GetGame().GetWorkspace().DPIUnscale(m_fDegreeWidgetSize);
48
49 super.CalculateWidgetScreenSizeUnscaled(widget);
50 }
51
52 //------------------------------------------------------------------------------------------------
53 protected void UpdateAzimuthWidgets()
54 {
55 if (m_aHeadingTextWidgets.IsEmpty())
56 return;
57
58 // Calculate how many numbers we need to go in every direction from the current azimuth
59 int azimuth = m_iCurrentHeading - ((m_iMaxShownDegrees - 1) * 0.5);
60
61 if (azimuth < 0)
62 azimuth += 360;
63
65 {
66 // If the next number would be 360, change it to 0 since they are both 0°
67 if (azimuth == 360)
68 azimuth = 0;
69
70 w.SetText(azimuth.ToString());
71
72 azimuth++;
73 }
74
75 m_wHeadingTableHolderWidget.SetSliderPos(0.5, 0);
77 m_fSliderPosX = GetGame().GetWorkspace().DPIUnscale(m_fSliderPosX);
78 }
79
80 //------------------------------------------------------------------------------------------------
81 override void SetupHeadingWidgets(ResourceName headingHolderLayout = "", ResourceName headingNotchLayout = "")
82 {
85 }
86
87 //------------------------------------------------------------------------------------------------
88 override void CalculateScreenSize(Widget degreeWidget)
89 {
90 super.CalculateScreenSize(degreeWidget);
92
94 }
95
96 //------------------------------------------------------------------------------------------------
97 override void DisplayUpdate(IEntity owner, float timeSlice)
98 {
99 vector aimRotation = GetMuzzleDirection().VectorToAngles();
100 UpdateAzimuthInfo(aimRotation);
101
102 super.DisplayUpdate(owner, timeSlice);
103 }
104
105 //------------------------------------------------------------------------------------------------
106 override void DisplayStartDraw(IEntity owner)
107 {
108 super.DisplayStartDraw(owner);
110 }
111}
ArmaReforgerScripted GetGame()
Definition game.c:1398
Definition Math.c:13
ScrollLayoutWidget m_wHeadingTableHolderWidget
ref array< TextWidget > m_aHeadingTextWidgets
override void CalculateWidgetScreenSizeUnscaled(Widget widget)
override void DisplayStartDraw(IEntity owner)
override void SetupHeadingWidgets(ResourceName headingHolderLayout="", ResourceName headingNotchLayout="")
override void CalculateScreenSize(Widget degreeWidget)
override void DisplayUpdate(IEntity owner, float timeSlice)
SCR_FieldOfViewSettings Attribute