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_GroupInviteStickyNotificationUIComponent.c
Go to the documentation of this file.
1
class
SCR_GroupInviteStickyNotificationUIComponent
:
SCR_StickyNotificationUIComponent
2
{
3
[
Attribute
(
"#AR-Notification_GROUPS_PLAYER_INVITED_GROUP_NAME"
)]
4
protected
LocalizedString
m_sGroupInviteText
;
5
6
SCR_GroupsManagerComponent
m_GroupManager
;
7
SCR_PlayerControllerGroupComponent
m_PlayerControllerGroupComponent
;
8
9
//How long the group invite notification exists before it gets deleted, Time in seconds
10
static
const
int
NOTIFICATION_DELETE_TIME
= 20;
11
12
protected
static
const
float
PLATFORM_ICON_SIZE
= 2;
13
14
protected
ref array<int>
m_aGroupIdQueue
= {};
15
protected
int
m_iGroupId
= -1;
16
17
//------------------------------------------------------------------------------------------------
18
//Shows the sticky notification including player who invited you and the group callsign
19
protected
void
ShowGroupInviteNotification
(
int
groupId,
bool
isInit =
false
)
20
{
21
if
(
m_iGroupId
> -1 &&
m_iGroupId
!= groupId)
22
{
23
//Add the invite to the queue if another invite is currently being displayed
24
if
(!
m_aGroupIdQueue
.Contains(groupId))
25
m_aGroupIdQueue
.Insert(groupId);
26
27
return
;
28
}
29
30
m_iGroupId
= groupId;
31
SCR_AIGroup
playerGroup =
m_GroupManager
.FindGroup(groupId);
32
if
(!playerGroup)
33
{
34
Print
(
string
.Format(
"SCR_GroupInviteStickyNotificationUIComponent could not find group with ID %1!"
, groupId.ToString()),
LogLevel
.ERROR);
35
return
;
36
}
37
38
string
company, platoon, squad, character, format;
39
playerGroup.
GetCallsigns
(company, platoon, squad, character, format);
40
41
//string invitingPlayerName = m_PlayerControllerGroupComponent.GetGroupInviteFromPlayerName();
42
43
string
playerName =
m_PlayerControllerGroupComponent
.GetGroupInviteFromPlayerName();
44
45
if
(
GetGame
().GetPlatformService().GetLocalPlatformKind() ==
PlatformKind
.PSN)
46
{
47
if
(
GetGame
().GetPlayerManager().GetPlatformKind(
m_PlayerControllerGroupComponent
.GetPlayerIdFromGroupInvite(groupId)) ==
PlatformKind
.PSN)
48
playerName =
string
.Format(
"<color rgba=%1><image set='%2' name='%3' scale='%4'/></color>"
,
UIColors
.FormatColor(GUIColors.ENABLED),
UIConstants
.ICONS_IMAGE_SET,
UIConstants
.PLATFROM_PLAYSTATION_ICON_NAME,
PLATFORM_ICON_SIZE
) + playerName;
49
else
50
playerName =
string
.Format(
"<color rgba=%1><image set='%2' name='%3' scale='%4'/></color>"
,
UIColors
.FormatColor(GUIColors.ENABLED),
UIConstants
.ICONS_IMAGE_SET,
UIConstants
.PLATFROM_GENERIC_ICON_NAME,
PLATFORM_ICON_SIZE
) + playerName;
51
}
52
53
string
squadName =
WidgetManager
.Translate(format, company, platoon, squad);
54
m_Text
.SetTextFormat(
m_sGroupInviteText
, company, platoon, squad, squadName, playerName);
55
56
SetStickyActive
(
true
, !isInit);
57
58
//Hiding the notification after a certain amount of time has passed
59
GetGame
().GetCallqueue().Remove(
RemoveInvite
);
60
GetGame
().GetCallqueue().CallLater(
RemoveInvite
,
NOTIFICATION_DELETE_TIME
* 1000,
false
, groupId);
61
}
62
63
//------------------------------------------------------------------------------------------------
64
protected
void
OnInviteReceived
(
int
groupId,
int
fromPlayerId)
65
{
66
ShowGroupInviteNotification
(groupId);
67
GetGame
().OnUserSettingsChangedInvoker().Insert(
OnUserSettingsChanged
);
68
}
69
70
//------------------------------------------------------------------------------------------------
71
protected
void
RemoveInvite
(
int
groupId)
72
{
73
//Remove the invite from the queue
74
m_aGroupIdQueue
.RemoveItem(groupId);
75
76
// If the invite to be removed is the notification currently being displayed, deactivate it and show the next notification in queue (if valid)
77
if
(
m_iGroupId
== groupId)
78
{
79
GetGame
().GetCallqueue().Remove(
RemoveInvite
);
80
SetStickyActive
(
false
);
81
m_FadeUIComponent
.GetOnFadeDone().Insert(
ShowNextInviteInQueue
);
82
}
83
84
GetGame
().OnUserSettingsChangedInvoker().Remove(
OnUserSettingsChanged
);
85
}
86
87
//------------------------------------------------------------------------------------------------
88
protected
void
ShowNextInviteInQueue
()
89
{
90
m_FadeUIComponent
.GetOnFadeDone().Remove(
ShowNextInviteInQueue
);
91
92
m_iGroupId
= -1;
93
94
//If there are invites in the queue, show the next one
95
if
(!
m_aGroupIdQueue
.IsEmpty())
96
ShowGroupInviteNotification
(
m_aGroupIdQueue
.Get(0));
97
}
98
99
//------------------------------------------------------------------------------------------------
100
override
void
OnInit
(
SCR_NotificationsLogComponent
notificationLog)
101
{
102
super.OnInit(notificationLog);
103
104
m_GroupManager
=
SCR_GroupsManagerComponent
.GetInstance();
105
106
if
(!
m_GroupManager
)
107
{
108
//Print("SCR_GroupInviteStickyNotificationUIComponent could not find SCR_GroupsManagerComponent!", LogLevel.ERROR);
109
return
;
110
}
111
112
m_PlayerControllerGroupComponent
= SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
113
if
(!
m_PlayerControllerGroupComponent
)
114
{
115
Print
(
"SCR_GroupInviteStickyNotificationUIComponent could not find SCR_PlayerControllerGroupComponent!"
,
LogLevel
.ERROR);
116
return
;
117
}
118
119
m_PlayerControllerGroupComponent
.GetOnInviteReceived().Insert(
OnInviteReceived
);
120
m_PlayerControllerGroupComponent
.GetOnInviteAccepted().Insert(
RemoveInvite
);
121
m_PlayerControllerGroupComponent
.GetOnInviteCancelled().Insert(
RemoveInvite
);
122
123
bool
shouldShowInvite =
m_PlayerControllerGroupComponent
.HasGroupInvites();
124
125
if
(shouldShowInvite)
126
ShowGroupInviteNotification
(
m_PlayerControllerGroupComponent
.GetGroupInviteIdFromIndex(0),
true
);
127
128
SetVisible
(shouldShowInvite);
129
}
130
131
//------------------------------------------------------------------------------------------------
132
protected
override
void
OnButton
()
133
{
134
MenuManager
menuManager =
GetGame
().GetMenuManager();
135
if
(menuManager)
136
menuManager.
OpenDialog
(
ChimeraMenuPreset
.PlayerListMenu);
137
}
138
139
//------------------------------------------------------------------------------------------------
140
protected
override
void
OnDestroy
()
141
{
142
GetGame
().OnUserSettingsChangedInvoker().Remove(
OnUserSettingsChanged
);
143
if
(!
m_PlayerControllerGroupComponent
)
144
return
;
145
146
m_PlayerControllerGroupComponent
.GetOnInviteReceived().Remove(
OnInviteReceived
);
147
m_PlayerControllerGroupComponent
.GetOnInviteAccepted().Remove(
RemoveInvite
);
148
m_PlayerControllerGroupComponent
.GetOnInviteCancelled().Remove(
RemoveInvite
);
149
}
150
151
//------------------------------------------------------------------------------------------------
153
protected
void
OnUserSettingsChanged
()
154
{
155
if
(
m_iGroupId
< 0)
156
return
;
157
158
ShowGroupInviteNotification
(
m_iGroupId
);
159
}
160
}
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition
ChimeraMenuBase.c:4
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
PlatformKind
PlatformKind
Definition
PlatformKind.c:8
SCR_GroupsManagerComponent
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition
SCR_GroupsManagerComponent.c:1747
LocalizedString
Definition
LocalizedString.c:22
MenuManager
Definition
MenuManager.c:13
MenuManager::OpenDialog
proto external MenuBase OpenDialog(ScriptMenuPresetEnum preset, int priority=DialogPriority.INFORMATIVE, int iUserData=0, bool unique=false)
SCR_AIGroup
Definition
SCR_AIGroup.c:75
SCR_AIGroup::GetCallsigns
void GetCallsigns(out string company, out string platoon, out string squad, out string character, out string format)
Definition
SCR_AIGroup.c:1546
SCR_GroupInviteStickyNotificationUIComponent
Definition
SCR_GroupInviteStickyNotificationUIComponent.c:2
SCR_GroupInviteStickyNotificationUIComponent::m_sGroupInviteText
LocalizedString m_sGroupInviteText
Definition
SCR_GroupInviteStickyNotificationUIComponent.c:4
SCR_GroupInviteStickyNotificationUIComponent::PLATFORM_ICON_SIZE
static const float PLATFORM_ICON_SIZE
Definition
SCR_GroupInviteStickyNotificationUIComponent.c:12
SCR_GroupInviteStickyNotificationUIComponent::NOTIFICATION_DELETE_TIME
static const int NOTIFICATION_DELETE_TIME
Definition
SCR_GroupInviteStickyNotificationUIComponent.c:10
SCR_GroupInviteStickyNotificationUIComponent::OnDestroy
override void OnDestroy()
Definition
SCR_GroupInviteStickyNotificationUIComponent.c:140
SCR_GroupInviteStickyNotificationUIComponent::m_iGroupId
int m_iGroupId
Definition
SCR_GroupInviteStickyNotificationUIComponent.c:15
SCR_GroupInviteStickyNotificationUIComponent::ShowNextInviteInQueue
void ShowNextInviteInQueue()
Definition
SCR_GroupInviteStickyNotificationUIComponent.c:88
SCR_GroupInviteStickyNotificationUIComponent::m_PlayerControllerGroupComponent
SCR_PlayerControllerGroupComponent m_PlayerControllerGroupComponent
Definition
SCR_GroupInviteStickyNotificationUIComponent.c:7
SCR_GroupInviteStickyNotificationUIComponent::m_aGroupIdQueue
ref array< int > m_aGroupIdQueue
Definition
SCR_GroupInviteStickyNotificationUIComponent.c:14
SCR_GroupInviteStickyNotificationUIComponent::OnInit
override void OnInit(SCR_NotificationsLogComponent notificationLog)
Definition
SCR_GroupInviteStickyNotificationUIComponent.c:100
SCR_GroupInviteStickyNotificationUIComponent::OnUserSettingsChanged
void OnUserSettingsChanged()
Callback used to reload the text of the notification in case that language changes.
Definition
SCR_GroupInviteStickyNotificationUIComponent.c:153
SCR_GroupInviteStickyNotificationUIComponent::OnButton
override void OnButton()
Definition
SCR_GroupInviteStickyNotificationUIComponent.c:132
SCR_GroupInviteStickyNotificationUIComponent::RemoveInvite
void RemoveInvite(int groupId)
Definition
SCR_GroupInviteStickyNotificationUIComponent.c:71
SCR_GroupInviteStickyNotificationUIComponent::OnInviteReceived
void OnInviteReceived(int groupId, int fromPlayerId)
Definition
SCR_GroupInviteStickyNotificationUIComponent.c:64
SCR_GroupInviteStickyNotificationUIComponent::ShowGroupInviteNotification
void ShowGroupInviteNotification(int groupId, bool isInit=false)
Definition
SCR_GroupInviteStickyNotificationUIComponent.c:19
SCR_GroupInviteStickyNotificationUIComponent::m_GroupManager
SCR_GroupsManagerComponent m_GroupManager
Definition
SCR_GroupInviteStickyNotificationUIComponent.c:6
SCR_NotificationsLogComponent
Definition
SCR_NotificationsLogUIComponent.c:7
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::m_FadeUIComponent
SCR_FadeUIComponent m_FadeUIComponent
Definition
SCR_StickyNotificationUIComponent.c:12
SCR_StickyNotificationUIComponent::SetStickyActive
void SetStickyActive(bool newActive, bool fade=true)
Definition
SCR_StickyNotificationUIComponent.c:24
UIColors
Definition
Constants.c:17
UIConstants
Definition
Constants.c:151
WidgetManager
Definition
WidgetManager.c:16
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
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
scripts
Game
UI
Components
Notification
SCR_GroupInviteStickyNotificationUIComponent.c
Generated by
1.17.0