Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_GroupInviteStickyNotificationUIComponent.c
Go to the documentation of this file.
2 {
3  [Attribute("#AR-Notification_Sticky_GroupInvite")]
4  protected LocalizedString m_sGroupInviteText;
5 
6  SCR_GroupsManagerComponent m_GroupManager;
7  SCR_PlayerControllerGroupComponent m_PlayerControllerGroupComponent;
8 
9  //------------------------------------------------------------------------------------------------
10  //Shows the sticky notification including player who invited you and the group callsign
11  protected void ShowGroupInviteNotification(int groupId, bool isInit = false)
12  {
13  SCR_AIGroup playerGroup = m_GroupManager.FindGroup(groupId);
14  if (!playerGroup)
15  {
16  Print(string.Format("SCR_GroupInviteStickyNotificationUIComponent could not find group with ID %1!", groupId.ToString()), LogLevel.ERROR);
17  return;
18  }
19 
20  string company, platoon, squad, character, format;
21  playerGroup.GetCallsigns(company, platoon, squad, character, format);
22 
23  string invitingPlayerName = m_PlayerControllerGroupComponent.GetGroupInviteFromPlayerName();
24 
25  m_Text.SetTextFormat(m_sGroupInviteText, company, platoon, squad, format, invitingPlayerName);
26 
27  SetStickyActive(true, !isInit);
28  }
29 
30  //------------------------------------------------------------------------------------------------
31  protected void OnInviteReceived(int groupId, int fromPlayerId)
32  {
33  ShowGroupInviteNotification(groupId);
34  }
35 
36  //------------------------------------------------------------------------------------------------
37  protected void OnInviteAcceptedOrCancelled(int groupId)
38  {
39  SetStickyActive(false);
40  }
41 
42  //------------------------------------------------------------------------------------------------
43  override void OnInit(SCR_NotificationsLogComponent notificationLog)
44  {
45  super.OnInit(notificationLog);
46 
47  m_GroupManager = SCR_GroupsManagerComponent.GetInstance();
48 
49  if (!m_GroupManager)
50  {
51  //Print("SCR_GroupInviteStickyNotificationUIComponent could not find SCR_GroupsManagerComponent!", LogLevel.ERROR);
52  return;
53  }
54 
55  m_PlayerControllerGroupComponent = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
56  if (!m_PlayerControllerGroupComponent)
57  {
58  Print("SCR_GroupInviteStickyNotificationUIComponent could not find SCR_PlayerControllerGroupComponent!", LogLevel.ERROR);
59  return;
60  }
61 
62  m_PlayerControllerGroupComponent.GetOnInviteReceived().Insert(OnInviteReceived);
63  m_PlayerControllerGroupComponent.GetOnInviteAccepted().Insert(OnInviteAcceptedOrCancelled);
64  m_PlayerControllerGroupComponent.GetOnInviteCancelled().Insert(OnInviteAcceptedOrCancelled);
65 
66  int groupInviteID = m_PlayerControllerGroupComponent.GetGroupInviteID();
67 
68  if (groupInviteID > -1)
69  ShowGroupInviteNotification(groupInviteID, true);
70 
71  SetVisible(groupInviteID > -1);
72  }
73 
74  //------------------------------------------------------------------------------------------------
75  protected override void OnButton()
76  {
77  MenuManager menuManager = GetGame().GetMenuManager();
78  if (menuManager)
79  menuManager.OpenDialog(ChimeraMenuPreset.PlayerListMenu);
80  }
81 
82  //------------------------------------------------------------------------------------------------
83  protected override void OnDestroy()
84  {
85  if (!m_PlayerControllerGroupComponent)
86  return;
87 
88  m_PlayerControllerGroupComponent.GetOnInviteReceived().Remove(OnInviteReceived);
89  m_PlayerControllerGroupComponent.GetOnInviteAccepted().Remove(OnInviteAcceptedOrCancelled);
90  m_PlayerControllerGroupComponent.GetOnInviteCancelled().Remove(OnInviteAcceptedOrCancelled);
91  }
92 }
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_NotificationsLogComponent
Definition: SCR_NotificationsLogUIComponent.c:6
SetVisible
void SetVisible(int layer)
Definition: SCR_ServicePointMapDescriptorComponent.c:95
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_GroupsManagerComponent
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_GroupsManagerComponent.c:1320
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition: ChimeraMenuBase.c:3
SCR_AIGroup
Definition: SCR_AIGroup.c:68
LocalizedString
Definition: LocalizedString.c:21
SCR_StickyNotificationUIComponent
Definition: SCR_StickyNotificationUIComponent.c:1
SCR_GroupInviteStickyNotificationUIComponent
Definition: SCR_GroupInviteStickyNotificationUIComponent.c:1