Space Plunder
Loading...
Searching...
No Matches
UChatBoxWidget Class Reference

#include <ChatBoxWidget.h>

Inheritance diagram for UChatBoxWidget:

Public Member Functions

virtual void NativeConstruct () override
 
void SetHintChatText (FString HintText)
 
void OnSentChatMessage (const FString &Text)
 
void ToggleChat (bool bOpen)
 
void MessageReceived ()
 

Public Attributes

FOnChatToggled OnChatToggled
 
FOnExecuteCommand OnExecuteCommand
 
FOnSendMessage OnSendMessage
 
EChatSystemCategory ChatSystemCategory = EChatSystemCategory::All
 
FString CommandsPrefix = "/"
 
TArray< FString > AllChatCommands
 
FString CleanCommandString
 
FString RawCommandString
 
class UScrollBox * ChatScrollBox
 
class UChatTextFieldWidgetChatTextFieldWidget
 

Protected Member Functions

bool GetCommandAndArguments (const FString &Text, EChatSystemCommandType &Command, FString &Arguments)
 

Member Function Documentation

◆ GetCommandAndArguments()

bool UChatBoxWidget::GetCommandAndArguments ( const FString & Text,
EChatSystemCommandType & Command,
FString & Arguments )
protected
49{
50 if(UKismetStringLibrary::ParseIntoArray(Text).IsEmpty()){return false;}
51 RawCommandString = UKismetStringLibrary::ParseIntoArray(Text)[0];
52 CleanCommandString = UKismetStringLibrary::Replace(RawCommandString, CommandsPrefix, "").ToLower();
54 {
55 uint8 EnumByte = UKismetMathLibrary::Conv_IntToByte(AllChatCommands.Find(CleanCommandString));
56 Command = static_cast<EChatSystemCommandType>(EnumByte);
57 Arguments = UKismetStringLibrary::Trim(UKismetStringLibrary::Replace(Text, RawCommandString, ""));
58 return true;
59 }
60 return false;
61}
EChatSystemCommandType
Definition ChatData.h:37
TArray< FString > AllChatCommands
Definition ChatBoxWidget.h:48
FString CommandsPrefix
Definition ChatBoxWidget.h:46
FString RawCommandString
Definition ChatBoxWidget.h:52
FString CleanCommandString
Definition ChatBoxWidget.h:50

◆ MessageReceived()

void UChatBoxWidget::MessageReceived ( )

◆ NativeConstruct()

void UChatBoxWidget::NativeConstruct ( )
overridevirtual
11{
12 Super::NativeConstruct();
13 ToggleChat(false);
14 if(ChatScrollBox != nullptr)
15 {
16 ChatScrollBox->ScrollToEnd();
17 }
18
19 //- Fill the Array with all Chat Commands //
20 const UEnum* ChatSystemCommandsEnum = StaticEnum<EChatSystemCommandType>();
21 if(ChatSystemCommandsEnum == nullptr){return;}
22 for(int32 i = 0; i < ChatSystemCommandsEnum->NumEnums() -1; ++i)
23 {
24 //- Convert the enum value to a string //
25 FString ChatSystemCommand = ChatSystemCommandsEnum->GetDisplayNameTextByIndex(i).ToString();
26 AllChatCommands.Add(ChatSystemCommand.ToLower());
27 }
28}
void ToggleChat(bool bOpen)
Definition ChatBoxWidget.cpp:38
class UScrollBox * ChatScrollBox
Definition ChatBoxWidget.h:56

◆ OnSentChatMessage()

void UChatBoxWidget::OnSentChatMessage ( const FString & Text)
64{
65 EChatSystemCommandType CommandType;
66 FString CommandArguments;
67 if(GetCommandAndArguments(Text, CommandType, CommandArguments))
68 {
69 OnExecuteCommand.Broadcast(CommandType, CommandArguments);
70 }
71 else
72 {
73 if(!Text.IsEmpty())
74 {
76 }
77 else
78 {
79 OnChatToggled.Broadcast(false);
80 }
81 }
82}
EChatSystemCategory ChatSystemCategory
Definition ChatBoxWidget.h:43
FOnChatToggled OnChatToggled
Definition ChatBoxWidget.h:23
FOnSendMessage OnSendMessage
Definition ChatBoxWidget.h:27
FOnExecuteCommand OnExecuteCommand
Definition ChatBoxWidget.h:25
bool GetCommandAndArguments(const FString &Text, EChatSystemCommandType &Command, FString &Arguments)
Definition ChatBoxWidget.cpp:48

◆ SetHintChatText()

void UChatBoxWidget::SetHintChatText ( FString HintText)
31{
32 if(ChatTextFieldWidget != nullptr)
33 {
35 }
36}
class UChatTextFieldWidget * ChatTextFieldWidget
Definition ChatBoxWidget.h:58
void SetHintChatText(FString HintText)
Definition ChatTextFieldWidget.cpp:26

◆ ToggleChat()

void UChatBoxWidget::ToggleChat ( bool bOpen)
39{
40 if(ChatTextFieldWidget != nullptr)
41 {
43 }
44 OnChatToggled.Broadcast(bOpen);
45}
void ToggleChat(bool bOpen)

Member Data Documentation

◆ AllChatCommands

TArray<FString> UChatBoxWidget::AllChatCommands

◆ ChatScrollBox

class UScrollBox* UChatBoxWidget::ChatScrollBox

◆ ChatSystemCategory

EChatSystemCategory UChatBoxWidget::ChatSystemCategory = EChatSystemCategory::All

◆ ChatTextFieldWidget

class UChatTextFieldWidget* UChatBoxWidget::ChatTextFieldWidget

◆ CleanCommandString

FString UChatBoxWidget::CleanCommandString

◆ CommandsPrefix

FString UChatBoxWidget::CommandsPrefix = "/"

◆ OnChatToggled

FOnChatToggled UChatBoxWidget::OnChatToggled

◆ OnExecuteCommand

FOnExecuteCommand UChatBoxWidget::OnExecuteCommand

◆ OnSendMessage

FOnSendMessage UChatBoxWidget::OnSendMessage

◆ RawCommandString

FString UChatBoxWidget::RawCommandString

The documentation for this class was generated from the following files: