Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/20tab/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	Source/UnrealEnginePython/Private/UEPyEngine.cpp
#	Source/UnrealEnginePython/Private/UEPyModule.cpp
#	Source/UnrealEnginePython/UnrealEnginePython.Build.cs
  • Loading branch information
getnamo committed Nov 3, 2017
2 parents 8a8a770 + c80b720 commit 3319e0a
Show file tree
Hide file tree
Showing 81 changed files with 5,082 additions and 1,091 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Once the plugin is installed and enabled, you get access to the 'PythonConsole'

All of the exposed engine features are under the 'unreal_engine' virtual module (it is completely coded in c into the plugin, so do not expect to run 'import unreal_engine' from a standard python shell)

The currently supported Unreal Engine versions are 4.12, 4.13, 4.14, 4.15, 4.16 and 4.17.
The currently supported Unreal Engine versions are 4.12, 4.13, 4.14, 4.15, 4.16, 4.17 and 4.18.

We support official python.org releases as well as IntelPython and Anaconda distributions.

Expand Down
60 changes: 38 additions & 22 deletions Source/PythonConsole/Private/SPythonLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Engine/LocalPlayer.h"
#include "GameFramework/GameState.h"
#include "SSearchBox.h"
#include "Runtime/Launch/Resources/Version.h"
//#include "UnrealEnginePython.h"
#define LOCTEXT_NAMESPACE "PythonConsole"

Expand Down Expand Up @@ -46,7 +47,8 @@ class SPythonConsoleEditableTextBox : public SEditableTextBox
]);
}

void SetPythonBox(SPythonConsoleInputBox *box) {
void SetPythonBox(SPythonConsoleInputBox *box)
{
SPythonConsoleEditableText *PythonEditableText = (SPythonConsoleEditableText *)EditableText.Get();
box->HistoryPosition = 0;
PythonEditableText->PythonConsoleInputBox = box;
Expand All @@ -72,15 +74,15 @@ class SPythonConsoleEditableTextBox : public SEditableTextBox
void Construct(const FArguments& InArgs)
{
SEditableText::Construct
(
SEditableText::FArguments()
.HintText(InArgs._HintText)
.OnTextChanged(InArgs._OnTextChanged)
.OnTextCommitted(InArgs._OnTextCommitted)
.ClearKeyboardFocusOnCommit(false)
.IsCaretMovedWhenGainFocus(false)
.MinDesiredWidth(400.0f)
);
(
SEditableText::FArguments()
.HintText(InArgs._HintText)
.OnTextChanged(InArgs._OnTextChanged)
.OnTextCommitted(InArgs._OnTextCommitted)
.ClearKeyboardFocusOnCommit(false)
.IsCaretMovedWhenGainFocus(false)
.MinDesiredWidth(400.0f)
);
}

virtual FReply OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent)
Expand All @@ -90,16 +92,20 @@ class SPythonConsoleEditableTextBox : public SEditableTextBox
{
return FReply::Unhandled();
}
else if (InKeyEvent.GetKey() == EKeys::Up) {
if (PythonConsoleInputBox->HistoryPosition > 0) {
else if (InKeyEvent.GetKey() == EKeys::Up)
{
if (PythonConsoleInputBox->HistoryPosition > 0)
{
PythonConsoleInputBox->HistoryPosition--;
this->SetText(FText::FromString(PythonConsoleInputBox->History[PythonConsoleInputBox->HistoryPosition]));
}

return FReply::Handled();
}
else if (InKeyEvent.GetKey() == EKeys::Down) {
if (PythonConsoleInputBox->HistoryPosition < PythonConsoleInputBox->History.Num() - 1) {
else if (InKeyEvent.GetKey() == EKeys::Down)
{
if (PythonConsoleInputBox->HistoryPosition < PythonConsoleInputBox->History.Num() - 1)
{
PythonConsoleInputBox->HistoryPosition++;
this->SetText(FText::FromString(PythonConsoleInputBox->History[PythonConsoleInputBox->HistoryPosition]));
}
Expand Down Expand Up @@ -213,25 +219,31 @@ void SPythonConsoleInputBox::OnTextCommitted(const FText& InText, ETextCommit::T
//
FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked<FUnrealEnginePythonModule>("UnrealEnginePython");

if (IsMultiline) {
if (ExecString.StartsWith(" ")) {
if (IsMultiline)
{
if (ExecString.StartsWith(" "))
{
MultilineString += FString("\n") + ExecString;
}
else {
else
{
IsMultiline = false;
PythonModule.RunString(TCHAR_TO_UTF8(*MultilineString));
}
}
else if (ExecString.EndsWith(":")) {
else if (ExecString.EndsWith(":"))
{
IsMultiline = true;
MultilineString = ExecString;
}
else {
else
{
PythonModule.RunString(TCHAR_TO_UTF8(*ExecString));
}

}
else if (IsMultiline) {
else if (IsMultiline)
{
IsMultiline = false;
FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked<FUnrealEnginePythonModule>("UnrealEnginePython");
PythonModule.RunString(TCHAR_TO_UTF8(*MultilineString));
Expand Down Expand Up @@ -349,7 +361,11 @@ FPythonLogTextLayoutMarshaller::FPythonLogTextLayoutMarshaller(TArray< TSharedPt
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void SPythonLog::Construct(const FArguments& InArgs)
{
#if ENGINE_MINOR_VERSION < 18
MessagesTextMarshaller = FPythonLogTextLayoutMarshaller::Create(MoveTemp(InArgs._Messages));
#else
MessagesTextMarshaller = FPythonLogTextLayoutMarshaller::Create(InArgs._Messages);
#endif

MessagesTextBox = SNew(SMultiLineEditableTextBox)
.Style(FEditorStyle::Get(), "Log.TextBox")
Expand Down Expand Up @@ -485,14 +501,14 @@ void SPythonLog::ExtendTextBoxMenu(FMenuBuilder& Builder)
FUIAction ClearPythonLogAction(
FExecuteAction::CreateRaw(this, &SPythonLog::OnClearLog),
FCanExecuteAction::CreateSP(this, &SPythonLog::CanClearLog)
);
);

Builder.AddMenuEntry(
NSLOCTEXT("PythonConsole", "ClearLogLabel", "Clear Log"),
NSLOCTEXT("PythonConsole", "ClearLogTooltip", "Clears all log messages"),
FSlateIcon(),
ClearPythonLogAction
);
);
}

void SPythonLog::OnClearLog()
Expand Down
Loading

0 comments on commit 3319e0a

Please sign in to comment.