Skip to content

Commit

Permalink
Fix #191 by switching chat command Usage to FText.
Browse files Browse the repository at this point in the history
#332 revealed that UE will preserve data in BP assets when making this switch
BP commands auto-update but C++ needs switching to LOCTEXT/NSLOCTEXT
  • Loading branch information
budak7273 committed Jan 24, 2025
1 parent 7c4aa22 commit 04218de
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ void AChatCommandInstance::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>&
}

void AChatCommandInstance::PrintCommandUsage(UCommandSender* Player) const {
Player->SendChatMessage(FString::Printf(TEXT("Usage: %s"), *Usage), FLinearColor::Red);
Player->SendChatMessage(FString::Printf(TEXT("Usage: %s"), *Usage.ToString()), FLinearColor::Red);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

AHelpCommandInstance::AHelpCommandInstance() {
CommandName = TEXT("help");
Usage = TEXT("/help - Command help");
Usage = NSLOCTEXT("SML", "ChatCommand.Help.Usage", "/help - Command help");
Aliases.Add(TEXT("?"));
}

Expand All @@ -18,12 +18,12 @@ EExecutionStatus AHelpCommandInstance::ExecuteCommand_Implementation(UCommandSen
Sender->SendChatMessage(FString(TEXT("Command not found: ")) += TargetCommandName, FLinearColor::Red);
return EExecutionStatus::BAD_ARGUMENTS;
}
Sender->SendChatMessage(CommandEntry->Usage);
Sender->SendChatMessage(CommandEntry->Usage.ToString());
return EExecutionStatus::COMPLETED;
}
Sender->SendChatMessage(TEXT("Command List:"));
for (const AChatCommandInstance* CommandEntry : CommandSubsystem->GetRegisteredCommands()) {
Sender->SendChatMessage(CommandEntry->Usage);
Sender->SendChatMessage(CommandEntry->Usage.ToString());
}
return EExecutionStatus::COMPLETED;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

AInfoCommandInstance::AInfoCommandInstance() {
CommandName = TEXT("info");
Usage = TEXT("/info - Information about the modded environment");
Usage = NSLOCTEXT("SML", "ChatCommand.Info.Usage", "/info - Information about the modded environment");
Aliases.Add(TEXT("version"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

APlayerListCommandInstance::APlayerListCommandInstance() {
CommandName = TEXT("list");
Usage = TEXT("/list - List players online");
Usage = NSLOCTEXT("SML", "ChatCommand.List.Usage", "/list - List players online");
Aliases.Add(TEXT("players"));
}

Expand Down
2 changes: 1 addition & 1 deletion Mods/SML/Source/SML/Public/Command/ChatCommandInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class SML_API AChatCommandInstance : public AInfo {
* give <username> <item> [amount] [extra_data]
*/
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
FString Usage;
FText Usage;

void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;

Expand Down

0 comments on commit 04218de

Please sign in to comment.