Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AutotuneRadioStickyNotificationUIComponent.c
Go to the documentation of this file.
2{
3 SCR_PlayerControllerGroupComponent m_PlayerControllerGroupComponent;
4
5 SCR_EAutotuneReason m_eAutotuneReason;
6
7 //------------------------------------------------------------------------------------------------
8 //Shows the sticky notification
9 protected void ShowAutotuneRadioNotification(bool isInit = false)
10 {
11 GetGame().OnUserSettingsChangedInvoker().Insert(OnUserSettingsChanged);
12 string notificationText;
13 switch (m_eAutotuneReason)
14 {
15 case SCR_EAutotuneReason.GROUP_CHANGED:
16 {
17 notificationText = "#AR-Notification_Radio_New_Group";
18 break;
19 }
20 case SCR_EAutotuneReason.TASK_ASSIGNED:
21 {
22 notificationText = "#AR-Notification_Radio_New_Task";
23 break;
24 }
25 case SCR_EAutotuneReason.BECAME_LEADER:
26 {
27 notificationText = "#AR-Notification_Radio_Squad_Leader";
28 break;
29 }
30 case SCR_EAutotuneReason.BECAME_COMMANDER:
31 {
32 notificationText = "#AR-Notification_commander";
33 break;
34 }
35 }
36
37 m_Text.SetTextFormat(notificationText);
38
39 SetStickyActive(true, !isInit);
40
41 GetGame().GetInputManager().AddActionListener("AutotuneRadio", EActionTrigger.DOWN, TuneRadio);
42
43 //call later to hide the notification in case it is still there
44 GetGame().GetCallqueue().CallLater(DisableSticky, 10000);
45 }
46
47 //------------------------------------------------------------------------------------------------
48 void TuneRadio()
49 {
51 if (!controller)
52 return;
53
54 SCR_VONController vonController = SCR_VONController.Cast(controller.FindComponent(SCR_VONController));
55 if (!vonController)
56 return;
57
58 SCR_VONAutoTune autotune = vonController.GetAutoTune();
59 if (!autotune)
60 return;
61
62 //if we want more control over specific channels which to change, we could go this way, but for now lets let SetRadios to handle it
63 /*
64 switch (m_eAutotuneReason)
65 {
66 case SCR_EAutotuneReason.GROUP_CHANGED:
67 {
68 autotune.SetRadios(controller.GetLocalMainEntity(), SCR_EVONAutoTuneFrequency.SQUAD);
69 break;
70 }
71 case SCR_EAutotuneReason.TASK_ASSIGNED:
72 {
73 autotune.SetRadios(controller.GetLocalMainEntity(), SCR_EVONAutoTuneFrequency.OBJECTIVE_PLATOON);
74 break;
75 }
76 case SCR_EAutotuneReason.BECAME_LEADER:
77 {
78 autotune.SetRadios(controller.GetLocalMainEntity(), SCR_EVONAutoTuneFrequency.COMMANDER);
79 autotune.SetRadios(controller.GetLocalMainEntity(), SCR_EVONAutoTuneFrequency.SQUAD);
80 break;
81 }
82 case SCR_EAutotuneReason.BECAME_COMMANDER:
83 {
84 //get what to tune from config
85 autotune.SetRadios(controller.GetLocalMainEntity(), SCR_EVONAutoTuneFrequency.COMMANDER);
86 break;
87 }
88
89 default:
90 break;
91
92 }
93 */
94
95 autotune.SetRadios(controller.GetLocalMainEntity());
96
98 }
99
100 //------------------------------------------------------------------------------------------------
102 {
103 m_eAutotuneReason = SCR_EAutotuneReason.UNKNOWN;
104 GetGame().OnUserSettingsChangedInvoker().Remove(OnUserSettingsChanged);
105 GetGame().GetInputManager().RemoveActionListener("AutotuneRadio", EActionTrigger.DOWN, TuneRadio);
106 SetStickyActive(false);
107 }
108
109 //------------------------------------------------------------------------------------------------
110 protected void OnGroupChanged()
111 {
112 //we dont care if the player doesnt have entity as there is no radio to tune
113 IEntity controlled = GetGame().GetPlayerManager().GetPlayerControlledEntity(SCR_PlayerController.GetLocalPlayerId());
114 if (!controlled)
115 return;
116
117 m_eAutotuneReason = SCR_EAutotuneReason.GROUP_CHANGED;
118
120 }
121
122 //------------------------------------------------------------------------------------------------
123 override void OnInit(SCR_NotificationsLogComponent notificationLog)
124 {
125 super.OnInit(notificationLog);
126
127 return;// disabled showing auto tune notification
128
130 if (!mode)
131 return;
132
133 if (!mode.GetAutotuneEnabled())
134 return;
135
136 m_PlayerControllerGroupComponent = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
137 if (!m_PlayerControllerGroupComponent)
138 {
139 Print("SCR_GroupInviteStickyNotificationUIComponent could not find SCR_PlayerControllerGroupComponent!", LogLevel.ERROR);
140 return;
141 }
142
143 m_PlayerControllerGroupComponent.GetOnGroupChanged().Insert(OnGroupChanged);
144 SCR_Task.GetOnTaskAssigneeAdded().Insert(OnTaskAssigneeChanged);
146
147 SetVisible(false);
148 }
149
150 //------------------------------------------------------------------------------------------------
151 void OnTaskAssigneeChanged(SCR_Task task, SCR_TaskExecutor executor, int requesterID)
152 {
153 if (!task || !executor || m_PlayerControllerGroupComponent.IsPlayerLeaderOwnGroup())
154 return;
155
156 SCR_TaskExecutorGroup groupExecutor = SCR_TaskExecutorGroup.Cast(executor);
157 if (!groupExecutor || groupExecutor.GetGroupID() != m_PlayerControllerGroupComponent.GetGroupID())
158 return;
159
160 //we dont care if the player doesnt have entity as there is no radio to tune
161 IEntity controlled = GetGame().GetPlayerManager().GetPlayerControlledEntity(SCR_PlayerController.GetLocalPlayerId());
162 if (!controlled)
163 return;
164
165 m_eAutotuneReason = SCR_EAutotuneReason.TASK_ASSIGNED;
167 }
168
169 //------------------------------------------------------------------------------------------------
170 void OnGroupLeaderChanged(int groupId, int playerId)
171 {
172 if (!m_PlayerControllerGroupComponent || m_PlayerControllerGroupComponent.GetGroupID() != groupId || !m_PlayerControllerGroupComponent.IsPlayerLeaderOwnGroup())
173 return;
174
175 //becoming leader notification overrides previous ones as its important
176 if (m_eAutotuneReason != SCR_EAutotuneReason.UNKNOWN && m_eAutotuneReason != SCR_EAutotuneReason.BECAME_COMMANDER)
178
179 IEntity controlled = GetGame().GetPlayerManager().GetPlayerControlledEntity(SCR_PlayerController.GetLocalPlayerId());
180 if (!controlled)
181 return;
182
183 SCR_Faction faction = SCR_Faction.Cast(SCR_Faction.GetEntityFaction(controlled));
184 if (!faction)
185 return;
186
188 m_eAutotuneReason = SCR_EAutotuneReason.BECAME_COMMANDER;
189 else
190 m_eAutotuneReason = SCR_EAutotuneReason.BECAME_LEADER;
191
193 }
194
195 //------------------------------------------------------------------------------------------------
196 protected override void OnDestroy()
197 {
198 GetGame().OnUserSettingsChangedInvoker().Remove(OnUserSettingsChanged);
199 if (!m_PlayerControllerGroupComponent)
200 return;
201
202 m_PlayerControllerGroupComponent.GetOnGroupChanged().Remove(OnGroupChanged);
203 SCR_Task.GetOnTaskAssigneeAdded().Remove(OnTaskAssigneeChanged);
205 }
206
207 //------------------------------------------------------------------------------------------------
209 protected void OnUserSettingsChanged()
210 {
211 SCR_EAutotuneReason autotuneReasonTemp = m_eAutotuneReason;
213 m_eAutotuneReason = autotuneReasonTemp;
215 }
216}
217
218enum SCR_EAutotuneReason
219{
224 BECAME_COMMANDER
225}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AutotuneStickyNotificationUIComponent TASK_ASSIGNED
SCR_AutotuneStickyNotificationUIComponent GROUP_CHANGED
SCR_AutotuneStickyNotificationUIComponent BECAME_LEADER
SCR_BaseGameMode GetGameMode()
void SCR_Task(IEntitySource src, IEntity parent)
Definition SCR_Task.c:1938
static ScriptInvoker GetOnPlayerLeaderChanged()
void OnTaskAssigneeChanged(SCR_Task task, SCR_TaskExecutor executor, int requesterID)
void OnUserSettingsChanged()
Callback used to reload the text of the notification in case that language changes.
override void OnInit(SCR_NotificationsLogComponent notificationLog)
static Faction GetEntityFaction(notnull IEntity entity)
bool IsPlayerCommander(int playerId)
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
static IEntity GetLocalMainEntity()
void SetStickyActive(bool newActive, bool fade=true)
void SetRadios(IEntity entity, SCR_EVONAutoTuneFrequency tuneSpecificFrequency=SCR_EVONAutoTuneFrequency.NONE)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
proto external PlayerController GetPlayerController()
EActionTrigger
@ UNKNOWN
Definition EPlatform.c:24