Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ChatHud.c
Go to the documentation of this file.
1
6
7class SCR_ChatHud : SCR_InfoDisplayExtended
8{
9 protected static const string CHAT_INPUT_ACTION = "ChatToggle";
10
15
16 protected int m_iHUDPriorityDefault;
17
18 protected const int HEIGHT_DIVIDER = 50;
19 protected const int INPUTFIELD_HEIGHT = 2;
20
21 //------------------------------------------------------------------------------------------------
22 override void DisplayUpdate(IEntity owner, float timeSlice)
23 {
24 if (m_ChatPanel)
25 {
26 m_ChatPanel.OnUpdateChat(timeSlice);
27 }
28
29 if (m_HUDSlotComponent != m_slotHandler.GetSlotUIComponent())
30 {
32 m_HUDSlotComponent.GetOnResize().Remove(OnSlotUIResize);
33
34 m_HUDSlotComponent = m_slotHandler.GetSlotUIComponent();
36 return;
37
38 m_HUDSlotComponent.GetOnResize().Insert(OnSlotUIResize);
39 }
40 }
41
42 //------------------------------------------------------------------------------------------------
43 override void DisplayStartDraw(IEntity owner)
44 {
45 m_InputManager = GetGame().GetInputManager();
46
47 if (!m_InputManager)
48 return;
49
51
52 if (!m_wRoot)
53 return;
54
55 Widget wChatPanel = m_wRoot.FindAnyWidget("ChatPanel");
56
57 if (wChatPanel)
58 m_ChatPanel = SCR_ChatPanel.Cast(wChatPanel.FindHandler(SCR_ChatPanel));
59
61 if(!m_slotHandler)
62 return;
63
64 m_HUDSlotComponent = m_slotHandler.GetSlotUIComponent();
66 return;
67
68 m_HUDSlotComponent.GetOnResize().Insert(OnSlotUIResize);
70 m_ChatPanel.GetOnChatOpen().Insert(OnChatOpen);
71 m_ChatPanel.GetOnChatClosed().Insert(OnChatClose);
72
73 if (!m_HUDManager)
74 return;
75
76 BaseContainer interfaceSettings = GetGame().GetGameUserSettings().GetModule(m_HUDManager.GetInterfaceSettingsClass());
77 if (interfaceSettings)
78 {
79 bool state;
80 interfaceSettings.Get(m_sInterfaceSettingName, state);
82
83 if (!state)
85 }
86 }
87
88 //------------------------------------------------------------------------------------------------
89 override void OnSettingsChanged()
90 {
91 super.OnSettingsChanged();
92
93 bool active = m_InputManager.IsActionActive(CHAT_INPUT_ACTION);
94
95 if (m_bIsEnabledInSettings && !active)
97 else if (!m_bIsEnabledInSettings && active)
99 }
100
101 //------------------------------------------------------------------------------------------------
103 protected void OnSlotUIResize()
104 {
105 // Assign it again in case the SlotUIComponent has changed
106 m_HUDSlotComponent = m_slotHandler.GetSlotUIComponent();
108 return;
109
110 int maxLines = (int)m_HUDSlotComponent.GetHeight() / HEIGHT_DIVIDER;
111 maxLines -= INPUTFIELD_HEIGHT;
112 if (maxLines < 0)
113 maxLines = 0;
114
115 m_ChatPanel.OnHUDResize(maxLines);
116 }
117
118 //------------------------------------------------------------------------------------------------
123
124 //------------------------------------------------------------------------------------------------
127 {
128 //Close all chat panels with delay, so every open chat panel is registered first
130 GetGame().GetCallqueue().Call(CloseAllChatPanels);
131
132 // Assign it again in case the SlotUIComponent has changed
133 m_HUDSlotComponent = m_slotHandler.GetSlotUIComponent();
135 return;
136
138 }
139
140 //------------------------------------------------------------------------------------------------
143 {
144 // Assign it again in case the SlotUIComponent has changed
145 m_HUDSlotComponent = m_slotHandler.GetSlotUIComponent();
147 return;
148
150 }
151
152 //------------------------------------------------------------------------------------------------
153 override void DisplayStopDraw(IEntity owner)
154 {
155 InputManager inputMgr = GetGame().GetInputManager();
156 inputMgr.RemoveActionListener(CHAT_INPUT_ACTION, EActionTrigger.DOWN, Callback_OnToggleAction);
157
158 // Widget does not get destroyed by HUD manager when switching characters, so we unregister the chat panel manually.
160 }
161
162 //------------------------------------------------------------------------------------------------
164 protected void Callback_OnToggleAction()
165 {
166 if (!m_ChatPanel)
167 return;
168
169 if (!m_ChatPanel.IsOpen())
170 {
172 }
173 }
174};
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_HUDManagerComponent m_HUDManager
Definition game.c:39
Widget m_wRoot
SCR_InfoDisplayHandler GetHandler(typename handlerType)
bool m_bIsEnabledInSettings
string m_sInterfaceSettingName
Input management system for user interactions.
SCR_ChatPanel m_ChatPanel
Definition SCR_ChatHud.c:11
int m_iHUDPriorityDefault
Definition SCR_ChatHud.c:16
SCR_HUDSlotUIComponent m_HUDSlotComponent
Definition SCR_ChatHud.c:13
void Callback_OnToggleAction()
Called when Enter key is pressed.
void OnChatOpen()
When the chat is open, increase it's priority to make it easier to read through the chat.
void CloseAllChatPanels()
override void DisplayStopDraw(IEntity owner)
const int HEIGHT_DIVIDER
Definition SCR_ChatHud.c:18
static const string CHAT_INPUT_ACTION
Definition SCR_ChatHud.c:9
SCR_InfoDisplaySlotHandler m_slotHandler
Definition SCR_ChatHud.c:12
void OnChatClose()
When chat is closed reset it's priority back to default.
InputManager m_InputManager
Definition SCR_ChatHud.c:14
void OnSlotUIResize()
Calculate how many Chat line widgets can be shown when HUD resizes.
override void DisplayStartDraw(IEntity owner)
Definition SCR_ChatHud.c:43
const int INPUTFIELD_HEIGHT
Definition SCR_ChatHud.c:19
override void DisplayUpdate(IEntity owner, float timeSlice)
Definition SCR_ChatHud.c:22
override void OnSettingsChanged()
Definition SCR_ChatHud.c:89
void OpenChatPanel(notnull SCR_ChatPanel panel)
Opens the chat panel and ensures that all other panels are closed.
static SCR_ChatPanelManager GetInstance()
Returns SCR_ChatPanelManager instance.
void Unregister(SCR_ChatPanel panel)
Definition int.c:13
EActionTrigger