Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_NTIconBase.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
5{
6 [Attribute("{70E828A2F6EBE7D0}UI/Textures/Nametags/nametagicons.imageset", UIWidgets.ResourceNamePicker, desc: "Imageset selection", params: "imageset")]
7 ResourceName m_sImageset;
8
9 [Attribute("64", UIWidgets.CheckBox, "Scaled icon size at the beginning of the zone \n pix*pix")]
10 protected float m_iImageSizeMax;
11
12 [Attribute("64", UIWidgets.CheckBox, "Scaled icon size at the end of the zone \n pix*pix")]
13 protected float m_iImageSizeMin;
14
15 //------------------------------------------------------------------------------------------------
16 override protected void ScaleElement(SCR_NameTagData data, int index)
17 {
18 ImageWidget widget = ImageWidget.Cast( data.m_aNametagElements[index] );
19 if (!widget)
20 return;
21
22 //At least one zone always need to be defined
24 if (!zone)
25 return;
26
27 float diff = m_iImageSizeMax - m_iImageSizeMin;
28
29 // avoid 0 as a starting point
30 int zoneStart = zone.GetZoneStart();
31 if ( zoneStart < 1 )
32 zoneStart = 1;
33
34 float lerp = Math.InverseLerp(zoneStart, zone.m_iZoneEnd, data.m_fDistance);
35 diff = diff * lerp;
36 // final size
37 diff = ( m_iImageSizeMax - diff );
38
39 widget.SetSize(diff, diff);
40 }
41
42 //------------------------------------------------------------------------------------------------
44 {
45 ImageWidget iWidget = ImageWidget.Cast( data.m_aNametagElements[index] );
46 if (!iWidget)
47 return;
48
50 if (!stateConf)
51 return;
52
53 if (!m_sImageset.IsEmpty() && !stateConf.m_sImagesetQuad.IsEmpty())
54 iWidget.LoadImageFromSet(0, m_sImageset, stateConf.m_sImagesetQuad);
55
56 if (!m_bScaleElement)
57 FrameSlot.SetSize(iWidget, m_iImageSizeMin, m_iImageSizeMin);
58
59 iWidget.SetColor(stateConf.m_vColor);
60
61 data.SetVisibility(iWidget, stateConf.m_fOpacityDefault != 0, stateConf.m_fOpacityDefault, stateConf.m_bAnimateTransition); // transitions
62 }
63};
64
65//------------------------------------------------------------------------------------------------
69{
70 [Attribute("0", UIWidgets.CheckBox, "Whether this element should use defined faction rank icons in default state")]
71 protected bool m_bUseRanks;
72
73 //------------------------------------------------------------------------------------------------
75 {
76 super.SetDefaults(data, index);
77
78 // if using ranks
79 if (!m_bUseRanks)
80 return;
81
82 ImageWidget iWidget = ImageWidget.Cast( data.m_aNametagElements[index] );
83 if (iWidget)
84 {
86 if (stateConf)
87 {
88 if (stateConf.m_eEntityState == ENameTagEntityState.DEFAULT)
89 {
90 ResourceName rankIcon = SCR_CharacterRankComponent.GetCharacterRankInsignia(data.m_Entity);
91 if (rankIcon)
92 iWidget.LoadImageTexture(0, rankIcon);
93 }
94 }
95 }
96 }
97};
98
99
102{
103 BaseContainer m_GameplaySettings;
104
105 //------------------------------------------------------------------------------------------------
106 override void SetDefaults(SCR_NameTagData data, int index)
107 {
108 ImageWidget iWidget = ImageWidget.Cast( data.m_aNametagElements[index] );
109 if (!iWidget)
110 return;
111
112 if (!m_GameplaySettings)
113 m_GameplaySettings = GetGame().GetGameUserSettings().GetModule("SCR_GameplaySettings");
114
115 data.SetVisibility(iWidget, false, 0, false);
116
117 if (!m_bScaleElement)
118 FrameSlot.SetSize(iWidget, m_iImageSizeMin, m_iImageSizeMin);
119
120 if (data.m_eType != ENameTagEntityType.PLAYER && data.m_eType != ENameTagEntityType.VEHICLE)
121 return;
122
124 if (!playerController)
125 return;
126
127 bool showOnPC;
128 if (m_GameplaySettings)
129 m_GameplaySettings.Get("m_bPlatformIconNametag", showOnPC);
130
131 if (data.m_eType == ENameTagEntityType.PLAYER)
132 {
133 if (playerController.SetPlatformImageTo(data.m_iPlayerID, iWidget, showOnPC : showOnPC))
134 data.SetVisibility(iWidget, true, 100, false);
135 }
136 else if (data.m_eType == ENameTagEntityType.VEHICLE)
137 {
139 if (!data)
140 return;
141
142 if (playerController.SetPlatformImageTo(tagData.GetMainPlayerID(), iWidget, showOnPC : showOnPC))
143 data.SetVisibility(iWidget, true, 100, false);
144 }
145 }
146
147 //------------------------------------------------------------------------------------------------
148 override void UpdateElement(SCR_NameTagData data, int index)
149 {
150 super.UpdateElement(data, index);
151
152 if (!data.m_aNametagElements[index])
153 return;
154
155 if (data.m_eType != ENameTagEntityType.PLAYER && data.m_eType != ENameTagEntityType.VEHICLE)
156 return;
157
158 ImageWidget image = ImageWidget.Cast(data.m_aNametagElements[index]);
159 if (!image)
160 return;
161
163 if (!playerController)
164 return;
165
166 bool showOnPC;
167 if (m_GameplaySettings)
168 m_GameplaySettings.Get("m_bPlatformIconNametag", showOnPC);
169
170 if (data.m_eType == ENameTagEntityType.PLAYER)
171 {
172 if (playerController.SetPlatformImageTo(data.m_iPlayerID, image, showOnPC : showOnPC))
173 data.SetVisibility(image, true, 100, false);
174 }
175 else if (data.m_eType == ENameTagEntityType.VEHICLE)
176 {
178 if (!tagData)
179 return;
180
181 if (playerController.SetPlatformImageTo(tagData.GetMainPlayerID(), image, showOnPC : showOnPC))
182 tagData.SetVisibility(image, true, 100, false);
183 }
184 }
185}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
void SCR_CharacterRankComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Get all prefabs that have the spawner data
it takes to automatically cancel a task when no enemy has been killed in the zone
ENameTagEntityType
Tag entity type.
ENameTagEntityState
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition Math.c:13
SCR_NTStateConfigBase GetEntityStateConfig(SCR_NameTagData data)
Base zone element widget for icons/images.
override void SetDefaults(SCR_NameTagData data, int index)
void ScaleElement(SCR_NameTagData data, int index)
Zone element for state icon.
override void SetDefaults(SCR_NameTagData data, int index)
Nametag icon element state config.
Nametag data.
static array< ref SCR_NameTagZone > GetNametagZones()
Custom names nametag element config.
Nametag zone config setup.
SCR_FieldOfViewSettings Attribute
proto external PlayerController GetPlayerController()