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_ChatHud.c
Go to the documentation of this file.
1
6
7
class
SCR_ChatHud
: SCR_InfoDisplayExtended
8
{
9
protected
static
const
string
CHAT_INPUT_ACTION
=
"ChatToggle"
;
10
11
protected
SCR_ChatPanel
m_ChatPanel
;
12
protected
SCR_InfoDisplaySlotHandler
m_slotHandler
;
13
protected
SCR_HUDSlotUIComponent
m_HUDSlotComponent
;
14
protected
InputManager
m_InputManager
;
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
{
31
if
(
m_HUDSlotComponent
)
32
m_HUDSlotComponent
.GetOnResize().Remove(
OnSlotUIResize
);
33
34
m_HUDSlotComponent
=
m_slotHandler
.GetSlotUIComponent();
35
if
(!
m_HUDSlotComponent
)
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
50
m_InputManager
.AddActionListener(
CHAT_INPUT_ACTION
,
EActionTrigger
.DOWN,
Callback_OnToggleAction
);
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
60
m_slotHandler
=
SCR_InfoDisplaySlotHandler
.Cast(
GetHandler
(
SCR_InfoDisplaySlotHandler
));
61
if
(!
m_slotHandler
)
62
return
;
63
64
m_HUDSlotComponent
=
m_slotHandler
.GetSlotUIComponent();
65
if
(!
m_HUDSlotComponent
)
66
return
;
67
68
m_HUDSlotComponent
.GetOnResize().Insert(
OnSlotUIResize
);
69
m_iHUDPriorityDefault
=
m_HUDSlotComponent
.GetPriority();
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);
81
m_bIsEnabledInSettings
= state;
82
83
if
(!state)
84
m_InputManager
.RemoveActionListener(
CHAT_INPUT_ACTION
,
EActionTrigger
.DOWN,
Callback_OnToggleAction
);
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)
96
m_InputManager
.AddActionListener(
CHAT_INPUT_ACTION
,
EActionTrigger
.DOWN,
Callback_OnToggleAction
);
97
else
if
(!
m_bIsEnabledInSettings
&& active)
98
m_InputManager
.RemoveActionListener(
CHAT_INPUT_ACTION
,
EActionTrigger
.DOWN,
Callback_OnToggleAction
);
99
}
100
101
//------------------------------------------------------------------------------------------------
103
protected
void
OnSlotUIResize
()
104
{
105
// Assign it again in case the SlotUIComponent has changed
106
m_HUDSlotComponent
=
m_slotHandler
.GetSlotUIComponent();
107
if
(!
m_HUDSlotComponent
)
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
//------------------------------------------------------------------------------------------------
119
protected
void
CloseAllChatPanels
()
120
{
121
SCR_ChatPanelManager
.
GetInstance
().
CloseAllChatPanels
();
122
}
123
124
//------------------------------------------------------------------------------------------------
126
void
OnChatOpen
()
127
{
128
//Close all chat panels with delay, so every open chat panel is registered first
129
if
(!
m_bIsEnabledInSettings
)
130
GetGame
().GetCallqueue().Call(
CloseAllChatPanels
);
131
132
// Assign it again in case the SlotUIComponent has changed
133
m_HUDSlotComponent
=
m_slotHandler
.GetSlotUIComponent();
134
if
(!
m_HUDSlotComponent
)
135
return
;
136
137
m_HUDSlotComponent
.SetPriority(
m_iHUDPriorityDefault
+ 1);
138
}
139
140
//------------------------------------------------------------------------------------------------
142
void
OnChatClose
()
143
{
144
// Assign it again in case the SlotUIComponent has changed
145
m_HUDSlotComponent
=
m_slotHandler
.GetSlotUIComponent();
146
if
(!
m_HUDSlotComponent
)
147
return
;
148
149
m_HUDSlotComponent
.SetPriority(
m_iHUDPriorityDefault
);
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.
159
SCR_ChatPanelManager
.
GetInstance
().
Unregister
(
m_ChatPanel
);
160
}
161
162
//------------------------------------------------------------------------------------------------
164
protected
void
Callback_OnToggleAction
()
165
{
166
if
(!
m_ChatPanel
)
167
return
;
168
169
if
(!
m_ChatPanel
.IsOpen())
170
{
171
SCR_ChatPanelManager
.
GetInstance
().
OpenChatPanel
(
m_ChatPanel
);
172
}
173
}
174
};
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
m_HUDManager
SCR_HUDManagerComponent m_HUDManager
Definition
game.c:39
m_wRoot
Widget m_wRoot
Definition
SCR_GameModeCleanSweep.c:25
GetHandler
SCR_InfoDisplayHandler GetHandler(typename handlerType)
Definition
SCR_InfoDisplay.c:80
m_bIsEnabledInSettings
bool m_bIsEnabledInSettings
Definition
SCR_InfoDisplayExtended.c:42
m_sInterfaceSettingName
string m_sInterfaceSettingName
Definition
SCR_InfoDisplayExtended.c:25
BaseContainer
Definition
BaseContainer.c:13
IEntity
Definition
IEntity.c:13
InputManager
Input management system for user interactions.
Definition
InputManager.c:20
SCR_ChatHud
Definition
SCR_ChatHud.c:8
SCR_ChatHud::m_ChatPanel
SCR_ChatPanel m_ChatPanel
Definition
SCR_ChatHud.c:11
SCR_ChatHud::m_iHUDPriorityDefault
int m_iHUDPriorityDefault
Definition
SCR_ChatHud.c:16
SCR_ChatHud::m_HUDSlotComponent
SCR_HUDSlotUIComponent m_HUDSlotComponent
Definition
SCR_ChatHud.c:13
SCR_ChatHud::Callback_OnToggleAction
void Callback_OnToggleAction()
Called when Enter key is pressed.
Definition
SCR_ChatHud.c:164
SCR_ChatHud::OnChatOpen
void OnChatOpen()
When the chat is open, increase it's priority to make it easier to read through the chat.
Definition
SCR_ChatHud.c:126
SCR_ChatHud::CloseAllChatPanels
void CloseAllChatPanels()
Definition
SCR_ChatHud.c:119
SCR_ChatHud::DisplayStopDraw
override void DisplayStopDraw(IEntity owner)
Definition
SCR_ChatHud.c:153
SCR_ChatHud::HEIGHT_DIVIDER
const int HEIGHT_DIVIDER
Definition
SCR_ChatHud.c:18
SCR_ChatHud::CHAT_INPUT_ACTION
static const string CHAT_INPUT_ACTION
Definition
SCR_ChatHud.c:9
SCR_ChatHud::m_slotHandler
SCR_InfoDisplaySlotHandler m_slotHandler
Definition
SCR_ChatHud.c:12
SCR_ChatHud::OnChatClose
void OnChatClose()
When chat is closed reset it's priority back to default.
Definition
SCR_ChatHud.c:142
SCR_ChatHud::m_InputManager
InputManager m_InputManager
Definition
SCR_ChatHud.c:14
SCR_ChatHud::OnSlotUIResize
void OnSlotUIResize()
Calculate how many Chat line widgets can be shown when HUD resizes.
Definition
SCR_ChatHud.c:103
SCR_ChatHud::DisplayStartDraw
override void DisplayStartDraw(IEntity owner)
Definition
SCR_ChatHud.c:43
SCR_ChatHud::INPUTFIELD_HEIGHT
const int INPUTFIELD_HEIGHT
Definition
SCR_ChatHud.c:19
SCR_ChatHud::DisplayUpdate
override void DisplayUpdate(IEntity owner, float timeSlice)
Definition
SCR_ChatHud.c:22
SCR_ChatHud::OnSettingsChanged
override void OnSettingsChanged()
Definition
SCR_ChatHud.c:89
SCR_ChatPanel
Definition
SCR_ChatPanel.c:7
SCR_ChatPanelManager
Definition
SCR_ChatPanelManager.c:13
SCR_ChatPanelManager::OpenChatPanel
void OpenChatPanel(notnull SCR_ChatPanel panel)
Opens the chat panel and ensures that all other panels are closed.
Definition
SCR_ChatPanelManager.c:41
SCR_ChatPanelManager::CloseAllChatPanels
void CloseAllChatPanels()
Definition
SCR_ChatPanelManager.c:115
SCR_ChatPanelManager::GetInstance
static SCR_ChatPanelManager GetInstance()
Returns SCR_ChatPanelManager instance.
Definition
SCR_ChatPanelManager.c:127
SCR_ChatPanelManager::Unregister
void Unregister(SCR_ChatPanel panel)
Definition
SCR_ChatPanelManager.c:214
SCR_HUDSlotUIComponent
Definition
SCR_HUDSlotUIComponent.c:6
SCR_InfoDisplaySlotHandler
Definition
SCR_InfoDisplaySlotHandler.c:3
Widget
Definition
Widget.c:13
int
Definition
int.c:13
EActionTrigger
EActionTrigger
Definition
EActionTrigger.c:13
scripts
Game
UI
Chat
SCR_ChatHud.c
Generated by
1.17.0