50 [
Attribute(
"20",
UIWidgets.EditBox,
"Amount of time till whole chat fades out, seconds")]
53 [
Attribute(
"false",
UIWidgets.CheckBox,
"When true, chat is always visible. When false, chat will fade out if msg box is hidden for more than m_fFadeOutThreshold_s time")]
56 [
Attribute(
"{973C90F6B6135A50}UI/layouts/HUD/Chat/ChatMessage.layout",
UIWidgets.ResourceNamePicker,
params:
"layout")]
90 GetGame().GetInputManager().ActivateContext(
"ChatContext", 1);
95 m_Widgets.m_WarningChannelMessage.SetVisible(
true);
99 m_Widgets.m_WarningChannelMessage.SetVisible(
false);
194 Color colorStart =
Color.FromSRGBA(226, 167, 79, 255);
195 Color colorEnd =
Color.FromSRGBA(0, 0, 0, 140);
196 m_Widgets.m_EditBackgroundImage.SetColor(colorStart);
199 m_Widgets.m_MessageEditBox.SetEnabled(
true);
208 m_Widgets.m_MessageEditBox.ActivateWriteMode();
221 m_Widgets.m_ChannelTagOverlay.SetVisible(
true);
225 m_Widgets.m_WarningChannelMessage.SetVisible(
false);
238 if (workspace.GetFocusedWidget() ==
m_Widgets.m_MessageEditBox)
240 workspace.SetFocusedWidget(null);
249 m_Widgets.m_MessageEditBox.SetText(
string.Empty);
250 m_Widgets.m_MessageEditBox.SetEnabled(
false);
256 m_Widgets.m_WarningChannelMessage.SetVisible(
false);
299 Print(
"[Chat] SCR_ChatPanelManager is not found. Chat will not work.",
LogLevel.ERROR);
309 m_Widgets.m_MessageEditBox.SetEnabled(
false);
393 int messageCount = messages.Count();
395 if (messageCount > 0)
401 lastMessageId =
Math.ClampInt(lastMessageId, 0, messageCount - 1);
404 for (
int i = 0; i < currentMessageCount; i++)
406 int messageId = lastMessageId - i;
414 if (messageId >= 0 && messageId <= lastMessageId)
459 message =
m_Widgets.m_MessageEditBox.GetText();
472 message = message.Substring(cmd.Length() + 1, message.Length() - cmd.Length() - 1);
473 message.TrimInPlace();
495 message = message.Substring(1, message.Length() - 1);
497 chatComponent.SendPrivateMessage(message, playerId);
503 chatComponent.SendMessage(message, channelId);
530 while (nTries < channelCount)
535 if (
id == channelCount)
542 id = channelCount - 1;
562 if (Chatchannel && message ==
string.Empty)
565 m_Widgets.m_WarningText.SetText(message);
567 m_Widgets.m_WarningChannelMessage.SetVisible(
true);
580 int cmdEnd = s.IndexOf(
" ");
586 string ret = s.Substring(1, cmdEnd - 1);
605 for (
int j = 0; j <
m_ChatEntity.GetChannelsCount(); j++)
607 if (chatComponent.GetChannelState(j))
616 if (style.m_bColoredIcon)
617 imageColor = style.m_Color;
619 string tagImage =
string.Format(
"<image set=\"%1\" name=\"%2\" scale=\"1\"/>",
620 style.m_IconImageset,
625 help_message +=
string.Format(
"\n /%1 %2 %3",
648 while (!found && i < channelCount)
655 if (style.m_sPrefix == prefix)
675 pm.GetAllPlayers(players);
677 for (
int i = pm.GetAllPlayerCount() - 1; i >= 0; --i)
679 if (pm.GetPlayerName(i) == name)
698 m_Widgets.m_WarningChannelMessage.SetVisible(
false);
709 if (style.m_bColoredIcon)
711 color = style.m_Color;
713 m_Widgets.m_ChannelTypeImage.SetColor(color);
714 m_Widgets.m_ChannelTagEditor.SetColor(color);
715 string chatTypeImageName = style.m_sIconName;
716 if (!chatTypeImageName.IsEmpty())
717 m_Widgets.m_ChannelTypeImage.LoadImageFromSet(0, style.m_IconImageset, chatTypeImageName);
719 string channelName = style.m_sName;
723 if (ReceiverName !=
string.Empty)
725 m_Widgets.m_ChannelTagEditor.SetText(channelName +
" " + ReceiverName);
726 m_Widgets.m_ChannelTagOverlay.SetText(channelName +
" " + ReceiverName);
729 else if (chatComponent.GetChannelState(channel))
735 m_Widgets.m_ChannelTagEditor.SetText(channelName);
737 m_Widgets.m_ChannelTagOverlay.SetTextFormat(
"#AR-Chat_SendToChannel", style.m_sNameLower);
758 array<Managed> styles = {
768 foreach (Managed style : styles)
776 string s =
string.Format(
"[Chat] %1 chat channel styles are not configured.", n);
791 switch (channel.Type())
795 if (channel.GetName() ==
"Global")
836 if (generalMsg.m_Channel)
851 PlayerController pc =
GetGame().GetPlayerController();
856 return SCR_ChatComponent.Cast(pc.FindComponent(SCR_ChatComponent));
913 message =
m_Widgets.m_MessageEditBox.GetText();
918 if (cmd.IsEmpty() || cmd.Length() != 1 || !(
"0123456789".Contains(cmd)))
930 message = message.Substring(cmd.Length() + 1, message.Length() - cmd.Length() - 1);
931 message.TrimInPlace();
936 m_Widgets.m_MessageEditBox.SetText(message);
963 if (!
m_Widgets.m_MessageEditBox.GetText().IsEmpty())
980 Widget wFocused =
GetGame().GetWorkspace().GetFocusedWidget();
981 if (wFocused !=
m_Widgets.m_MessageEditBox)
984 if (!
m_Widgets.m_MessageEditBox.IsInWriteMode())
985 m_Widgets.m_MessageEditBox.ActivateWriteMode();
1004 array<ref SCR_ChatMessage> messages = mgr.
GetMessages();
1005 int messagesCount = messages.Count();
1009 if (messagesCount < minHistoryOffset)
1019 int lastMessageId = messagesCount - 1;
1024 bool increasing =
true;
1039 hadToIncrease =
true;
1083 int textLen =
m_Widgets.m_MessageEditBox.GetText().Length();
1084 m_Widgets.m_ChannelTagOverlay.SetVisible(textLen == 0);
ArmaReforgerScripted GetGame()
InputManager GetInputManager()
event bool IsAvailable(BaseChatComponent sender)
Returns true if the message can be sent to this channel.
void SetMessage(notnull SCR_ChatMessage msg, notnull SCR_ChatMessageStyle style)
void SetVisible(bool visible)
void Callback_OnGamepadConfirmAction()
override void HandlerAttached(Widget w)
void VerifyChannelStyles()
ref SCR_ChatMessageStyle m_RadioProtocolStyle
ref SCR_ChatPanelWidgets m_Widgets
ScriptInvoker GetOnChatOpen()
void CycleChannels(bool next)
next: true - cycle up, false - cycle down
ref SCR_ChatMessageStyle m_GlobalChannelStyle
EditBoxFilterComponent m_MessageEditBoxComponent
string Internal_GetChannelListHelpMessage()
Returns string with help message about available channels.
ref ScriptInvoker m_OnChatClosed
SCR_ChatMessageStyle GetChannelStyle(BaseChatChannel channel)
Returns style of this channel. If not resolved, returns system style.
void Callback_OnSwitchChannelAction(float value, EActionTrigger reason)
Channel switching.
void Callback_OnEditBoxChange()
Called when text in the edit box changes.
SCR_FadeInOutAnimator GetFadeInOutAnimator()
void Callback_OnCloseAction()
Called when Esc is pressed.
ref SCR_ChatMessageStyle m_GroupChannelStyle
SCR_ChatComponent GetChatComponent()
const string STR_CHANNEL_DISABLED
float m_fFadeOutThreshold_s
void Internal_Close()
Don't call it yourself, use SCR_ChatPanelManager instead.
bool GetFadeIn()
True when fading out or has faded out already.
override void HandlerDeattached(Widget w)
int GetPlayerIdByName(string name)
ref SCR_ChatMessageStyle m_VehicleChannelStyle
ScriptInvoker GetOnChatClosed()
notnull Widget GetWidget()
const string STR_AVAILABLE_CHANNELS
BaseChatChannel m_ActiveChannel
void Internal_OnNewMessage(SCR_ChatMessage msg)
void Callback_OnPressSpaceAfterCommand()
Called by space bar when we change channel by tag.
void OnHUDResize(int newMessageLineCount)
Adjust the amount of messages shown when the size of the HUD changes.
ref SCR_ChatMessageStyle m_SystemChannelStyle
void Callback_OnSendMessageAction()
Called when chat toggle key is pressed.
int GetChannelId(notnull BaseChatChannel channel)
const string STR_CHANNEL_UNKNOWN
void OnUpdateChat(float timeSlice)
This must be called for chat to work. Typically it should be called from HUD Manager or from Menu.
ref SCR_FadeInOutAnimator m_MessageHistoryAnimator
ref SCR_ChatMessageStyle m_FactionChannelStyle
ref SCR_ChatMessageStyle m_DirectChannelStyle
void Internal_Open()
Don't call it yourself, use SCR_ChatPanelManager instead.
ref ScriptInvoker m_OnChatOpen
BaseChatChannel FindChannelByPrefix(string prefix)
const string STR_MESSAGE_LIMIT_REACHED
SCR_ChatMessageStyle GetMessageStyle(notnull SCR_ChatMessage msg)
string GetCommand(string s)
void ShowChannelWarning(BaseChatChannel Chatchannel=null, string message="")
void SetActiveChannel(notnull BaseChatChannel channel, string ReceiverName=string.Empty)
Switches channels and replaces the channel tag.
bool GetFadeOut()
True when fading in or when has faded in already.
int m_iHistoryIdLowestMessage
ref SCR_ChatMessageStyle m_LocalChannelStyle
void UpdateChatMessages()
ResourceName m_sChatMessageLineLayout
void Callback_OnHistoryAction(float value)
History scrolling.
ref array< SCR_ChatMessageLineComponent > m_aMessageLines
ScriptedChatEntity m_ChatEntity
void ShowHelpMessage(string msg)
void Register(SCR_ChatPanel panel)
Registration of chat panels. These are called when a chat panel is created and destroyed.
void Internal_EnableAllChannels()
Enables all channels.
array< ref SCR_ChatMessage > GetMessages()
Returns the array of messages. Array is not a copy, so be careful.
void Internal_OnChatCommand(SCR_ChatPanel panel, string command, string otherData)
OTHER.
static SCR_ChatPanelManager GetInstance()
Returns SCR_ChatPanelManager instance.
bool GetAnyPanelFadedIn()
Returns true when there is any chat panel faded in.
void Unregister(SCR_ChatPanel panel)
const string CHAT_COMMAND_CHARACTER
const int STATE_FADE_OUT_WAIT
const int STATE_FADING_DONE
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
SCR_FieldOfViewSettings Attribute