You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Please note that file comments had no purpose in nearly all cases and just added visual clutter. The two files that had meaningful file comments had their comments moved into the corresponding classes. There are still hundreds of file comments left in other files that will be removed over time. Also cleaned up some random stuff along the way: - relative paths to public headers within the same module are no longer necessary (automatically discovered by UBT now) - header guards are deprecated, use #pragma once instead (all compilers support it now) - space between multiple template brackets is no longer required (all compilers support >> now) - NULL to nullptr, OVERRIDE to override - spelling errors, whitespace, line breaks [CL 2104067 by Max Preussner in Main branch]
151 lines
4.0 KiB
C++
151 lines
4.0 KiB
C++
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "SessionFrontendPrivatePCH.h"
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "SSessionConsoleCommandBar"
|
|
|
|
|
|
/* SSessionConsoleCommandBar interface
|
|
*****************************************************************************/
|
|
|
|
void SSessionConsoleCommandBar::Construct( const FArguments& InArgs )
|
|
{
|
|
OnCommandSubmitted = InArgs._OnCommandSubmitted;
|
|
OnPromoteToShortcutClicked = InArgs._OnPromoteToShortcutClicked;
|
|
|
|
ChildSlot
|
|
[
|
|
SNew(SHorizontalBox)
|
|
|
|
+ SHorizontalBox::Slot()
|
|
.FillWidth(1.0f)
|
|
[
|
|
// command input
|
|
SAssignNew(InputTextBox, SSuggestionTextBox)
|
|
.ClearKeyboardFocusOnCommit(false)
|
|
.OnShowingHistory(this, &SSessionConsoleCommandBar::HandleInputTextShowingHistory)
|
|
.OnShowingSuggestions(this, &SSessionConsoleCommandBar::HandleInputTextShowingSuggestions)
|
|
.OnTextChanged(this, &SSessionConsoleCommandBar::HandleInputTextChanged)
|
|
.OnTextCommitted(this, &SSessionConsoleCommandBar::HandleInputTextCommitted)
|
|
]
|
|
|
|
+ SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
.Padding(4.0f, 0.0f, 0.0f, 0.0f)
|
|
[
|
|
// send button
|
|
SAssignNew(SendButton, SButton)
|
|
.ContentPadding(FMargin(6.0f, 2.0f))
|
|
.IsEnabled(false)
|
|
.OnClicked(this, &SSessionConsoleCommandBar::HandleSendButtonClicked)
|
|
.ToolTipText(LOCTEXT("SendButtonTooltip", "Send the command"))
|
|
[
|
|
SNew(STextBlock)
|
|
.Text(LOCTEXT("SendButtonLabel", "Send Command"))
|
|
]
|
|
]
|
|
|
|
+ SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
.Padding(4.0f, 0.0f, 0.0f, 0.0f)
|
|
[
|
|
// send button
|
|
SAssignNew(PromoteToShortcutButton, SButton)
|
|
.ContentPadding(FMargin(6.0f, 2.0f))
|
|
.IsEnabled(false)
|
|
.OnClicked(this, &SSessionConsoleCommandBar::HandlePromoteToShortcutButtonClicked)
|
|
.ToolTipText(LOCTEXT("PromoteConsoleCommandButtonTooltip", "Promote Command to Shortcut"))
|
|
[
|
|
SNew(STextBlock)
|
|
.Text(LOCTEXT("PromoteConsoleCommandButtonLabel", "Promote to Shortcut"))
|
|
]
|
|
]
|
|
];
|
|
}
|
|
|
|
|
|
void SSessionConsoleCommandBar::SetNumSelectedInstances( int Count )
|
|
{
|
|
FString CommandString = InputTextBox->GetText().ToString();
|
|
CommandString.Trim();
|
|
|
|
bool bEnableButtons = (Count > 0) && !CommandString.IsEmpty();
|
|
|
|
InputTextBox->SetEnabled(Count > 0);
|
|
SendButton->SetEnabled(bEnableButtons);
|
|
PromoteToShortcutButton->SetEnabled(bEnableButtons);
|
|
}
|
|
|
|
|
|
/* SSessionConsoleCommandBar implementation
|
|
*****************************************************************************/
|
|
|
|
void SSessionConsoleCommandBar::SubmitCommand( const FString& Command )
|
|
{
|
|
OnCommandSubmitted.ExecuteIfBound(Command);
|
|
|
|
CommandHistory.Remove(Command);
|
|
CommandHistory.Add(Command);
|
|
|
|
InputTextBox->SetText(FText::GetEmpty());
|
|
}
|
|
|
|
|
|
/* SSessionConsoleCommandBar event handlers
|
|
*****************************************************************************/
|
|
|
|
void SSessionConsoleCommandBar::HandleInputTextChanged( const FText& InText )
|
|
{
|
|
FString CommandString = InputTextBox->GetText().ToString();
|
|
CommandString.Trim();
|
|
|
|
SendButton->SetEnabled(!CommandString.IsEmpty());
|
|
PromoteToShortcutButton->SetEnabled(!CommandString.IsEmpty());
|
|
}
|
|
|
|
|
|
void SSessionConsoleCommandBar::HandleInputTextCommitted( const FText& InText, ETextCommit::Type CommitInfo )
|
|
{
|
|
if (CommitInfo == ETextCommit::OnEnter)
|
|
{
|
|
SubmitCommand(InText.ToString());
|
|
}
|
|
}
|
|
|
|
|
|
void SSessionConsoleCommandBar::HandleInputTextShowingHistory( TArray<FString>& OutHistory )
|
|
{
|
|
OutHistory = CommandHistory;
|
|
}
|
|
|
|
|
|
void SSessionConsoleCommandBar::HandleInputTextShowingSuggestions( const FString& Text, TArray<FString>& OutSuggestions )
|
|
{
|
|
// @todo gmp: implement remote auto-complete
|
|
}
|
|
|
|
|
|
FReply SSessionConsoleCommandBar::HandlePromoteToShortcutButtonClicked( )
|
|
{
|
|
if (OnPromoteToShortcutClicked.IsBound())
|
|
{
|
|
FString CommandString = InputTextBox->GetText().ToString();
|
|
CommandString.Trim();
|
|
OnPromoteToShortcutClicked.Execute(CommandString);
|
|
}
|
|
|
|
return FReply::Handled();
|
|
}
|
|
|
|
|
|
FReply SSessionConsoleCommandBar::HandleSendButtonClicked( )
|
|
{
|
|
SubmitCommand(InputTextBox->GetText().ToString());
|
|
|
|
return FReply::Handled();
|
|
}
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|