Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_GroupInviteStickyNotificationUIComponent.c
Go to the documentation of this file.
2{
3 [Attribute("#AR-Notification_GROUPS_PLAYER_INVITED_GROUP_NAME")]
5
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 {
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())
97 }
98
99 //------------------------------------------------------------------------------------------------
100 override void OnInit(SCR_NotificationsLogComponent notificationLog)
101 {
102 super.OnInit(notificationLog);
103
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();
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);
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
159 }
160}
ChimeraMenuPreset
Menu presets.
ArmaReforgerScripted GetGame()
Definition game.c:1398
PlatformKind
Definition PlatformKind.c:8
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
proto external MenuBase OpenDialog(ScriptMenuPresetEnum preset, int priority=DialogPriority.INFORMATIVE, int iUserData=0, bool unique=false)
void GetCallsigns(out string company, out string platoon, out string squad, out string character, out string format)
override void OnInit(SCR_NotificationsLogComponent notificationLog)
void OnUserSettingsChanged()
Callback used to reload the text of the notification in case that language changes.
void SetStickyActive(bool newActive, bool fade=true)
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
SCR_FieldOfViewSettings Attribute