Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ChatHud.c
Go to the documentation of this file.
1 
7 class SCR_ChatHud : SCR_InfoDisplayExtended
8 {
9  protected SCR_ChatPanel m_ChatPanel;
10  protected SCR_InfoDisplaySlotHandler m_slotHandler;
11  protected SCR_HUDSlotUIComponent m_HUDSlotComponent;
12 
13  protected int m_iHUDPriorityDefault;
14 
15  protected const int HEIGHT_DIVIDER = 50;
16  protected const int INPUTFIELD_HEIGHT = 2;
17 
18  //------------------------------------------------------------------------------------------------
19  override void DisplayUpdate(IEntity owner, float timeSlice)
20  {
21  if (m_ChatPanel)
22  {
23  m_ChatPanel.OnUpdateChat(timeSlice);
24  }
25 
26  if (m_HUDSlotComponent != m_slotHandler.GetSlotUIComponent())
27  {
29  m_HUDSlotComponent.GetOnResize().Remove(OnSlotUIResize);
30 
31  m_HUDSlotComponent = m_slotHandler.GetSlotUIComponent();
32  if (!m_HUDSlotComponent)
33  return;
34 
35  m_HUDSlotComponent.GetOnResize().Insert(OnSlotUIResize);
36  }
37  }
38 
39  //------------------------------------------------------------------------------------------------
40  override void DisplayStartDraw(IEntity owner)
41  {
42  InputManager inputMgr = GetGame().GetInputManager();
43  inputMgr.AddActionListener("ChatToggle", EActionTrigger.DOWN, Callback_OnToggleAction);
44 
45  if (!m_wRoot)
46  return;
47 
48  Widget wChatPanel = m_wRoot.FindAnyWidget("ChatPanel");
49 
50  if (wChatPanel)
51  m_ChatPanel = SCR_ChatPanel.Cast(wChatPanel.FindHandler(SCR_ChatPanel));
52 
54  if(!m_slotHandler)
55  return;
56 
57  m_HUDSlotComponent = m_slotHandler.GetSlotUIComponent();
58  if (!m_HUDSlotComponent)
59  return;
60 
61  m_HUDSlotComponent.GetOnResize().Insert(OnSlotUIResize);
62  m_iHUDPriorityDefault = m_HUDSlotComponent.GetPriority();
63  m_ChatPanel.GetOnChatOpen().Insert(OnChatOpen);
64  m_ChatPanel.GetOnChatClosed().Insert(OnChatClose);
65 
66  }
67 
68  //------------------------------------------------------------------------------------------------
70  protected void OnSlotUIResize()
71  {
72  // Assign it again in case the SlotUIComponent has changed
73  m_HUDSlotComponent = m_slotHandler.GetSlotUIComponent();
74  if (!m_HUDSlotComponent)
75  return;
76 
77  int maxLines = (int)m_HUDSlotComponent.GetHeight() / HEIGHT_DIVIDER;
78  maxLines -= INPUTFIELD_HEIGHT;
79  if (maxLines < 0)
80  maxLines = 0;
81 
82  m_ChatPanel.OnHUDResize(maxLines);
83  }
84 
85  //------------------------------------------------------------------------------------------------
87  void OnChatOpen()
88  {
89  // Assign it again in case the SlotUIComponent has changed
90  m_HUDSlotComponent = m_slotHandler.GetSlotUIComponent();
91  if (!m_HUDSlotComponent)
92  return;
93 
94  m_HUDSlotComponent.SetPriority(m_iHUDPriorityDefault + 1);
95  }
96 
97  //------------------------------------------------------------------------------------------------
99  void OnChatClose()
100  {
101  // Assign it again in case the SlotUIComponent has changed
102  m_HUDSlotComponent = m_slotHandler.GetSlotUIComponent();
103  if (!m_HUDSlotComponent)
104  return;
105 
106  m_HUDSlotComponent.SetPriority(m_iHUDPriorityDefault);
107  }
108 
109  //------------------------------------------------------------------------------------------------
110  override void DisplayStopDraw(IEntity owner)
111  {
112  InputManager inputMgr = GetGame().GetInputManager();
113  inputMgr.RemoveActionListener("ChatToggle", EActionTrigger.DOWN, Callback_OnToggleAction);
114 
115  // Widget does not get destroyed by HUD manager when switching characters, so we unregister the chat panel manually.
116  SCR_ChatPanelManager.GetInstance().Unregister(m_ChatPanel);
117  }
118 
119 
120  //------------------------------------------------------------------------------------------------
122  protected void Callback_OnToggleAction()
123  {
124  if (!m_ChatPanel)
125  return;
126 
127  if (!m_ChatPanel.IsOpen())
128  {
129  SCR_ChatPanelManager.GetInstance().OpenChatPanel(m_ChatPanel);
130  }
131  }
132 };
GetHandler
SCR_InfoDisplayHandler GetHandler(typename handlerType)
Definition: SCR_InfoDisplay.c:80
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_ChatPanelManager
Definition: SCR_ChatPanelManager.c:12
SCR_ChatHud
Definition: SCR_ChatHud.c:7
HEIGHT_DIVIDER
const int HEIGHT_DIVIDER
Definition: SCR_VonDisplay.c:87
SCR_ChatPanel
Definition: SCR_ChatPanel.c:6
SCR_InfoDisplaySlotHandler
Definition: SCR_InfoDisplaySlotHandler.c:2
m_HUDSlotComponent
protected SCR_HUDSlotUIComponent m_HUDSlotComponent
Definition: SCR_VonDisplay.c:103
int
SCR_PossessingManagerComponentClass int
SCR_HUDSlotUIComponent
Definition: SCR_HUDSlotUIComponent.c:5