Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_BaseWeaponElevationDisplay.c
Go to the documentation of this file.
2{
3 [Attribute("{EF0A00F789607F39}UI/layouts/HUD/MortarInfo/ScopeElevationSlots.layout", params: "layout")]
5
6 [Attribute("{2BDCF42A2713A90B}UI/layouts/HUD/MortarInfo/ScopeElevationSteps.layout", params: "layout")]
8
9 //------------------------------------------------------------------------------------------------
10 void UpdateElevationInfo(vector aimRotation)
11 {
12 float elevation = aimRotation[1];
13 float elevationMils = elevation * (m_fMils / 360);
14
15 m_iCurrentHeading = elevation;
16
18 m_wMilsTextWidget.SetTextFormat(UIConstants.VALUE_UNIT_MILS, elevationMils.ToString(4, 0));
19
21 m_wDegreesTextWidget.SetTextFormat(UIConstants.VALUE_UNIT_DEGREES, elevation.ToString(3, 1));
22
23 float elevationInPercent = elevation - m_iCurrentHeading;
24 elevationInPercent = Math.Clamp(elevationInPercent, 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_fSliderPosY - (m_fDegreeWidgetSize * elevationInPercent));
31
33 m_wHeadingTableHolderWidget.SetSliderPosPixels(0, newSliderPos);
34 }
35 else
36 {
39 }
40 }
41
42 //------------------------------------------------------------------------------------------------
43 protected void UpdateElevationWidgets()
44 {
45 if (m_aHeadingTextWidgets.IsEmpty())
46 return;
47
48 // Calculate how many numbers we need to go in every direction from the current elevation
49 int elevation = m_iCurrentHeading + ((m_iMaxShownDegrees - 1) * 0.5);
50
51 if (elevation < 0)
52 elevation += 360;
53
55 {
56 // If the next number would be 360, change it to 0 since they are both 0°
57 if (elevation == 360)
58 elevation = 0;
59 else if (elevation == -1)
60 elevation = 359;
61
62 w.SetText(elevation.ToString());
63
64 elevation--;
65 }
66
67 m_wHeadingTableHolderWidget.SetSliderPos(0, 0.5);
69 m_fSliderPosY = GetGame().GetWorkspace().DPIUnscale(m_fSliderPosY);
70 }
71
72 //------------------------------------------------------------------------------------------------
73 override void SetupHeadingWidgets(ResourceName headingHolderLayout = "", ResourceName headingNotchLayout = "")
74 {
77 }
78
79 //------------------------------------------------------------------------------------------------
81 {
82 float w;
83 widget.GetScreenSize(w, m_fDegreeWidgetSize);
84 m_fDegreeWidgetSize = GetGame().GetWorkspace().DPIUnscale(m_fDegreeWidgetSize);
85
86 super.CalculateWidgetScreenSizeUnscaled(widget);
87 }
88
89 //------------------------------------------------------------------------------------------------
90 override void CalculateScreenSize(Widget degreeWidget)
91 {
92 super.CalculateScreenSize(degreeWidget);
94
96 }
97
98 //------------------------------------------------------------------------------------------------
99 override void DisplayUpdate(IEntity owner, float timeSlice)
100 {
101 vector aimRotation = GetMuzzleDirection().VectorToAngles();
102 UpdateElevationInfo(aimRotation);
103
104 if (m_iCurrentHeading == 0)
105 {
106 m_iCurrentHeading = aimRotation[1];
108 }
109
110 super.DisplayUpdate(owner, timeSlice);
111 }
112
113 //------------------------------------------------------------------------------------------------
114 override void DisplayStartDraw(IEntity owner)
115 {
116 super.DisplayStartDraw(owner);
118 }
119}
ArmaReforgerScripted GetGame()
Definition game.c:1398
Definition Math.c:13
ScrollLayoutWidget m_wHeadingTableHolderWidget
ref array< TextWidget > m_aHeadingTextWidgets
override void DisplayUpdate(IEntity owner, float timeSlice)
override void CalculateWidgetScreenSizeUnscaled(Widget widget)
override void CalculateScreenSize(Widget degreeWidget)
override void SetupHeadingWidgets(ResourceName headingHolderLayout="", ResourceName headingNotchLayout="")
override void DisplayStartDraw(IEntity owner)
SCR_FieldOfViewSettings Attribute