Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_AutotuneRadioStickyNotificationUIComponent.c
Go to the documentation of this file.
1
class
SCR_AutotuneStickyNotificationUIComponent
:
SCR_StickyNotificationUIComponent
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
{
50
SCR_PlayerController
controller =
SCR_PlayerController
.Cast(
GetGame
().
GetPlayerController
());
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
97
DisableSticky
();
98
}
99
100
//------------------------------------------------------------------------------------------------
101
void
DisableSticky
()
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
119
ShowAutotuneRadioNotification
();
120
}
121
122
//------------------------------------------------------------------------------------------------
123
override
void
OnInit
(
SCR_NotificationsLogComponent
notificationLog)
124
{
125
super.OnInit(notificationLog);
126
127
return
;
// disabled showing auto tune notification
128
129
SCR_BaseGameMode
mode =
SCR_BaseGameMode
.Cast(
GetGame
().
GetGameMode
());
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
);
145
SCR_AIGroup
.
GetOnPlayerLeaderChanged
().Insert(
OnGroupLeaderChanged
);
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;
166
ShowAutotuneRadioNotification
();
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)
177
DisableSticky
();
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
187
if
(faction.
IsPlayerCommander
(
SCR_PlayerController
.
GetLocalPlayerId
()))
188
m_eAutotuneReason = SCR_EAutotuneReason.BECAME_COMMANDER;
189
else
190
m_eAutotuneReason = SCR_EAutotuneReason.BECAME_LEADER;
191
192
ShowAutotuneRadioNotification
();
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
);
204
SCR_AIGroup
.
GetOnPlayerLeaderChanged
().Remove(
OnGroupLeaderChanged
);
205
}
206
207
//------------------------------------------------------------------------------------------------
209
protected
void
OnUserSettingsChanged
()
210
{
211
SCR_EAutotuneReason autotuneReasonTemp = m_eAutotuneReason;
212
DisableSticky
();
213
m_eAutotuneReason = autotuneReasonTemp;
214
ShowAutotuneRadioNotification
();
215
}
216
}
217
218
enum
SCR_EAutotuneReason
219
{
220
UNKNOWN
,
221
GROUP_CHANGED
,
222
BECAME_LEADER
,
223
TASK_ASSIGNED
,
224
BECAME_COMMANDER
225
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
TASK_ASSIGNED
SCR_AutotuneStickyNotificationUIComponent TASK_ASSIGNED
GROUP_CHANGED
SCR_AutotuneStickyNotificationUIComponent GROUP_CHANGED
BECAME_LEADER
SCR_AutotuneStickyNotificationUIComponent BECAME_LEADER
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition
SCR_BaseGameModeComponent.c:15
SCR_Task
void SCR_Task(IEntitySource src, IEntity parent)
Definition
SCR_Task.c:1938
task
from task
Definition
SCR_TaskNotificationConfigs.c:12
IEntity
Definition
IEntity.c:13
SCR_AIGroup
Definition
SCR_AIGroup.c:75
SCR_AIGroup::GetOnPlayerLeaderChanged
static ScriptInvoker GetOnPlayerLeaderChanged()
Definition
SCR_AIGroup.c:1084
SCR_AutotuneStickyNotificationUIComponent
Definition
SCR_AutotuneRadioStickyNotificationUIComponent.c:2
SCR_AutotuneStickyNotificationUIComponent::OnTaskAssigneeChanged
void OnTaskAssigneeChanged(SCR_Task task, SCR_TaskExecutor executor, int requesterID)
Definition
SCR_AutotuneRadioStickyNotificationUIComponent.c:151
SCR_AutotuneStickyNotificationUIComponent::OnGroupLeaderChanged
void OnGroupLeaderChanged(int groupId, int playerId)
Definition
SCR_AutotuneRadioStickyNotificationUIComponent.c:170
SCR_AutotuneStickyNotificationUIComponent::TuneRadio
void TuneRadio()
Definition
SCR_AutotuneRadioStickyNotificationUIComponent.c:48
SCR_AutotuneStickyNotificationUIComponent::DisableSticky
void DisableSticky()
Definition
SCR_AutotuneRadioStickyNotificationUIComponent.c:101
SCR_AutotuneStickyNotificationUIComponent::OnGroupChanged
void OnGroupChanged()
Definition
SCR_AutotuneRadioStickyNotificationUIComponent.c:110
SCR_AutotuneStickyNotificationUIComponent::OnUserSettingsChanged
void OnUserSettingsChanged()
Callback used to reload the text of the notification in case that language changes.
Definition
SCR_AutotuneRadioStickyNotificationUIComponent.c:209
SCR_AutotuneStickyNotificationUIComponent::OnDestroy
override void OnDestroy()
Definition
SCR_AutotuneRadioStickyNotificationUIComponent.c:196
SCR_AutotuneStickyNotificationUIComponent::OnInit
override void OnInit(SCR_NotificationsLogComponent notificationLog)
Definition
SCR_AutotuneRadioStickyNotificationUIComponent.c:123
SCR_AutotuneStickyNotificationUIComponent::ShowAutotuneRadioNotification
void ShowAutotuneRadioNotification(bool isInit=false)
Definition
SCR_AutotuneRadioStickyNotificationUIComponent.c:9
SCR_BaseGameMode
Definition
SCR_BaseGameMode.c:139
SCR_BaseGameMode::GetAutotuneEnabled
bool GetAutotuneEnabled()
Definition
SCR_BaseGameMode.c:2273
SCR_Faction
Definition
SCR_Faction.c:6
SCR_Faction::GetEntityFaction
static Faction GetEntityFaction(notnull IEntity entity)
Definition
SCR_Faction.c:810
SCR_Faction::IsPlayerCommander
bool IsPlayerCommander(int playerId)
Definition
SCR_Faction.c:881
SCR_NotificationsLogComponent
Definition
SCR_NotificationsLogUIComponent.c:7
SCR_PlayerController
Definition
SCR_PlayerController.c:31
SCR_PlayerController::GetLocalPlayerId
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
Definition
SCR_PlayerController.c:481
SCR_PlayerController::GetLocalMainEntity
static IEntity GetLocalMainEntity()
Definition
SCR_PlayerController.c:511
SCR_StickyNotificationUIComponent
Definition
SCR_StickyNotificationUIComponent.c:2
SCR_StickyNotificationUIComponent::SetVisible
void SetVisible(bool visible)
Definition
SCR_StickyNotificationUIComponent.c:73
SCR_StickyNotificationUIComponent::m_Text
TextWidget m_Text
Definition
SCR_StickyNotificationUIComponent.c:19
SCR_StickyNotificationUIComponent::SetStickyActive
void SetStickyActive(bool newActive, bool fade=true)
Definition
SCR_StickyNotificationUIComponent.c:24
SCR_TaskExecutorGroup
Definition
SCR_TaskExecutorGroup.c:2
SCR_TaskExecutorGroup::GetGroupID
override int GetGroupID()
Definition
SCR_TaskExecutorGroup.c:37
SCR_TaskExecutor
Definition
SCR_TaskExecutor.c:2
SCR_VONAutoTune
Definition
SCR_VONAutoTune.c:3
SCR_VONAutoTune::SetRadios
void SetRadios(IEntity entity, SCR_EVONAutoTuneFrequency tuneSpecificFrequency=SCR_EVONAutoTuneFrequency.NONE)
Definition
SCR_VONAutoTune.c:33
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
GetPlayerController
proto external PlayerController GetPlayerController()
Definition
SCR_PlayerDeployMenuHandlerComponent.c:307
EActionTrigger
EActionTrigger
Definition
EActionTrigger.c:13
UNKNOWN
@ UNKNOWN
Definition
EPlatform.c:24
scripts
Game
UI
Components
Notification
SCR_AutotuneRadioStickyNotificationUIComponent.c
Generated by
1.17.0