5 const string LABEL_FREQUENCY_UNITS =
"#AR-VON_FrequencyUnits_MHz";
7 protected int m_iFrequency;
8 protected int m_iTransceiverNumber;
9 protected string m_sChannelText;
12 protected SCR_GadgetComponent m_GadgetComp;
23 int GetTransceiverNumber()
25 return m_iTransceiverNumber;
30 int GetEntryFrequency()
37 SCR_GadgetComponent GetGadget()
49 return itemComponent.GetUIInfo();
56 return m_GadgetComp.GetType() == EGadgetType.RADIO_BACKPACK;
60 void SetRadioEntry(notnull
BaseTransceiver transceiver,
int number, SCR_GadgetComponent gadgetComp)
63 m_iTransceiverNumber = number;
64 m_GadgetComp = gadgetComp;
68 void SetChannelText(
string channel)
70 m_sChannelText = channel;
74 override void InitEntry()
76 SetCustomLayout(
"{033302D7C8158EF8}UI/layouts/HUD/VON/VONEntry.layout");
86 override void AdjustEntryModif(
int modifier)
88 if (!IsUsable() && modifier != 0)
100 if ( (modifier > 0 && m_iFrequency == maxFreq) || (modifier < 0 && m_iFrequency == minFreq) )
102 else if (modifier != 0)
105 m_iFrequency = m_iFrequency + (modifier *
m_RadioTransceiver.GetFrequencyResolution());
106 m_iFrequency = Math.ClampInt(m_iFrequency, minFreq, maxFreq);
108 RadioHandlerComponent rhc = RadioHandlerComponent.Cast(
GetGame().GetPlayerController().FindComponent(RadioHandlerComponent));
114 float fFrequency = Math.Round(m_iFrequency * 0.1) * 0.01;
119 override void AdjustEntry(
int modifier)
133 int factionFreq = playerFaction.GetFactionRadioFrequency();
136 array<SCR_AIGroup> groups = groupManager.GetPlayableGroupsByFaction(playerFaction);
137 if (!groups || groups.IsEmpty())
142 if (currentFreq == factionFreq)
145 newFreq = groups[0].GetRadioFrequency();
151 int count = groups.Count();
152 if (modifier == 1 && currentFreq == groups[0].GetRadioFrequency())
154 if (factionFreq != 0)
155 newFreq = factionFreq;
159 else if (modifier == -1 && currentFreq == groups[count - 1].GetRadioFrequency())
167 for (
int i = 0; i < count; i++)
169 if (currentFreq == groups[i].GetRadioFrequency())
172 newFreq = groups[i-1].GetRadioFrequency();
174 newFreq = groups[i+1].GetRadioFrequency();
182 newFreq = groups[0].GetRadioFrequency();
186 m_iFrequency = newFreq;
194 float fFrequency = Math.Round(m_iFrequency / 10);
195 fFrequency = fFrequency / 100;
202 override void ToggleEntry()
210 SetUsable(!radio.IsPowered());
211 radio.SetPower(IsUsable());
222 override string GetIconResource()
232 if (!pInvItemComponent)
236 if (!pInvItemAttributes)
239 UIInfo uiInfo = pInvItemAttributes.GetUIInfo();
243 return uiInfo.GetIconPath();
254 override void Update()
266 vonContr.RemoveEntry(
this);
271 entryComp.SetTransceiverText(
"CH" + m_iTransceiverNumber.ToString());
272 entryComp.SetFrequencyText(
m_sText);
273 entryComp.SetChannelText(m_sChannelText);
277 SetUsable(radio.IsPowered());
278 entryComp.SetPowerIcon(IsUsable());
282 entryComp.SetTransceiverOpacity(1);
285 entryComp.SetFrequencyColor(Color.FromInt(GUIColors.ORANGE_BRIGHT.PackToInt()));
287 entryComp.SetFrequencyColor(Color.FromInt(GUIColors.ORANGE.PackToInt()));
291 entryComp.SetTransceiverOpacity(0.5);
294 entryComp.SetFrequencyColor(Color.FromInt(GUIColors.ORANGE_BRIGHT.PackToInt()));
296 entryComp.SetFrequencyColor(Color.FromInt(Color.WHITE));