Skip to content

Commit 8bfc1f7

Browse files
committed
merge
2 parents 9d30675 + 000402f commit 8bfc1f7

File tree

94 files changed

+2854
-387
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+2854
-387
lines changed

Source/PythonConsole/Private/PyFbxFactory.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
#include "PyFbxFactory.h"
33
#include "FbxMeshUtils.h"
4+
#include "Runtime/Launch/Resources/Version.h"
45

56
UPyFbxFactory::UPyFbxFactory(const FObjectInitializer& ObjectInitializer)
67
: Super(ObjectInitializer)
@@ -23,6 +24,23 @@ void UPyFbxFactory::PostInitProperties() {
2324
ImportUI->MeshTypeToImport = FBXIT_MAX;
2425
}
2526

27+
UObject * UPyFbxFactory::FactoryCreateFile(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, const FString& Filename, const TCHAR* Parms, FFeedbackContext* Warn, bool& bOutOperationCanceled)
28+
{
29+
#if ENGINE_MINOR_VERSION >= 20
30+
if (ImportUI->MeshTypeToImport == FBXIT_MAX)
31+
{
32+
if (!DetectImportType(UFactory::CurrentFilename))
33+
{
34+
return nullptr;
35+
}
36+
}
37+
FbxMeshUtils::SetImportOption(ImportUI);
38+
// ensure auto-detect is skipped
39+
bDetectImportTypeOnImport = false;
40+
#endif
41+
return Super::FactoryCreateFile(InClass, InParent, InName, Flags, Filename, Parms, Warn, bOutOperationCanceled);
42+
}
43+
2644
UObject *UPyFbxFactory::FactoryCreateBinary
2745
(
2846
UClass * InClass,

Source/PythonConsole/Public/PyFbxFactory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class UPyFbxFactory : public UFbxFactory
1515

1616
virtual bool ConfigureProperties() override;
1717
virtual void PostInitProperties() override;
18+
virtual UObject * FactoryCreateFile(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, const FString& Filename, const TCHAR* Parms, FFeedbackContext* Warn, bool& bOutOperationCanceled) override;
1819
virtual UObject * FactoryCreateBinary
1920
(
2021
UClass * InClass,

Source/PythonEditor/Private/SPythonEditableText.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ FReply SPythonEditableText::OnKeyChar(const FGeometry& MyGeometry, const FCharac
3434
return Reply;
3535
}
3636
Reply = FReply::Handled();
37+
// substitute tab, with 4 spaces
3738
if (Character == TEXT('\t'))
3839
{
39-
FString String;
40-
String.AppendChar(Character);
41-
InsertTextAtCursor(String);
40+
InsertTextAtCursor(FString(" "));
4241
}
4342
//else if (Character == TEXT('('))
4443
//{

Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraph.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,7 @@ PyObject *py_ue_node_allocate_default_pins(ue_PyUObject * self, PyObject * args)
489489

490490
node->AllocateDefaultPins();
491491

492-
Py_INCREF(Py_None);
493-
return Py_None;
492+
Py_RETURN_NONE;
494493
}
495494

496495
PyObject *py_ue_node_reconstruct(ue_PyUObject * self, PyObject * args)
@@ -504,8 +503,7 @@ PyObject *py_ue_node_reconstruct(ue_PyUObject * self, PyObject * args)
504503

505504
node->GetSchema()->ReconstructNode(*node);
506505

507-
Py_INCREF(Py_None);
508-
return Py_None;
506+
Py_RETURN_NONE;
509507
}
510508

511509
PyObject *py_ue_node_find_pin(ue_PyUObject * self, PyObject * args)
@@ -532,9 +530,7 @@ PyObject *py_ue_node_find_pin(ue_PyUObject * self, PyObject * args)
532530
return PyErr_Format(PyExc_Exception, "unable to find pin \"%s\"", name);
533531
}
534532

535-
PyObject *ret = py_ue_new_edgraphpin(pin);
536-
Py_INCREF(ret);
537-
return ret;
533+
return py_ue_new_edgraphpin(pin);
538534
}
539535

540536
PyObject *py_ue_node_function_entry_set_pure(ue_PyUObject * self, PyObject * args)
@@ -635,9 +631,7 @@ PyObject *py_ue_node_create_pin(ue_PyUObject * self, PyObject * args)
635631
FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(bp);
636632
}
637633

638-
PyObject *ret = py_ue_new_edgraphpin(pin);
639-
Py_INCREF(ret);
640-
return ret;
634+
return py_ue_new_edgraphpin(pin);
641635
}
642636

643637

Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraphPin.cpp

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ static PyObject *py_ue_edgraphpin_make_link_to(ue_PyEdGraphPin *self, PyObject *
2626
FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(bp);
2727
}
2828

29-
Py_INCREF(Py_None);
30-
return Py_None;
29+
Py_RETURN_NONE;
3130
}
3231

3332
static PyObject *py_ue_edgraphpin_connect(ue_PyEdGraphPin *self, PyObject * args)
@@ -54,8 +53,7 @@ static PyObject *py_ue_edgraphpin_connect(ue_PyEdGraphPin *self, PyObject * args
5453
FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(bp);
5554
}
5655

57-
Py_INCREF(Py_None);
58-
return Py_None;
56+
Py_RETURN_NONE;
5957
}
6058

6159
static PyObject *py_ue_edgraphpin_break_link_to(ue_PyEdGraphPin *self, PyObject * args)
@@ -79,8 +77,7 @@ static PyObject *py_ue_edgraphpin_break_link_to(ue_PyEdGraphPin *self, PyObject
7977
FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(bp);
8078
}
8179

82-
Py_INCREF(Py_None);
83-
return Py_None;
80+
Py_RETURN_NONE;
8481
}
8582

8683
static PyMethodDef ue_PyEdGraphPin_methods[] = {
@@ -124,7 +121,7 @@ static PyObject *py_ue_edgraphpin_get_default_value(ue_PyEdGraphPin *self, void
124121

125122
static int py_ue_edgraphpin_set_default_value(ue_PyEdGraphPin *self, PyObject *value, void *closure)
126123
{
127-
if (value && PyUnicode_Check(value))
124+
if (value && PyUnicodeOrString_Check(value))
128125
{
129126
const char *str = UEPyUnicode_AsUTF8(value);
130127
self->pin->DefaultValue = UTF8_TO_TCHAR(str);
@@ -141,7 +138,7 @@ static PyObject *py_ue_edgraphpin_get_default_text_value(ue_PyEdGraphPin *self,
141138

142139
static int py_ue_edgraphpin_set_default_text_value(ue_PyEdGraphPin *self, PyObject *value, void *closure)
143140
{
144-
if (value && PyUnicode_Check(value))
141+
if (value && PyUnicodeOrString_Check(value))
145142
{
146143
const char *str = UEPyUnicode_AsUTF8(value);
147144
self->pin->DefaultTextValue = FText::FromString(UTF8_TO_TCHAR(str));
@@ -175,10 +172,51 @@ static int py_ue_edgraphpin_set_default_object(ue_PyEdGraphPin *self, PyObject *
175172
return -1;
176173
}
177174

175+
static int py_ue_edgraphpin_set_category(ue_PyEdGraphPin *self, PyObject *value, void *closure)
176+
{
177+
if (value && PyUnicodeOrString_Check(value))
178+
{
179+
const char *str = UEPyUnicode_AsUTF8(value);
180+
#if ENGINE_MINOR_VERSION > 18
181+
self->pin->PinType.PinCategory = FName(UTF8_TO_TCHAR(str));
182+
#else
183+
self->pin->PinType.PinCategory = FString(UTF8_TO_TCHAR(str));
184+
#endif
185+
return 0;
186+
}
187+
PyErr_SetString(PyExc_TypeError, "value is not a string");
188+
return -1;
189+
}
190+
191+
static int py_ue_edgraphpin_set_sub_category(ue_PyEdGraphPin *self, PyObject *value, void *closure)
192+
{
193+
if (value)
194+
{
195+
if (ue_is_pyuobject(value))
196+
{
197+
ue_PyUObject *py_obj = (ue_PyUObject *)value;
198+
self->pin->PinType.PinSubCategoryObject = py_obj->ue_object;
199+
return 0;
200+
}
201+
if (PyUnicodeOrString_Check(value))
202+
{
203+
const char *str = UEPyUnicode_AsUTF8(value);
204+
#if ENGINE_MINOR_VERSION > 18
205+
self->pin->PinType.PinSubCategory = FName(UTF8_TO_TCHAR(str));
206+
#else
207+
self->pin->PinType.PinSubCategory = FString(UTF8_TO_TCHAR(str));
208+
#endif
209+
return 0;
210+
}
211+
}
212+
PyErr_SetString(PyExc_TypeError, "value is not a UObject");
213+
return -1;
214+
}
215+
178216
static PyGetSetDef ue_PyEdGraphPin_getseters[] = {
179217
{ (char*)"name", (getter)py_ue_edgraphpin_get_name, NULL, (char *)"", NULL },
180-
{ (char*)"category", (getter)py_ue_edgraphpin_get_category, NULL, (char *)"", NULL },
181-
{ (char*)"sub_category", (getter)py_ue_edgraphpin_get_sub_category, NULL, (char *)"", NULL },
218+
{ (char*)"category", (getter)py_ue_edgraphpin_get_category, (setter)py_ue_edgraphpin_set_category, (char *)"", NULL },
219+
{ (char*)"sub_category", (getter)py_ue_edgraphpin_get_sub_category, (setter)py_ue_edgraphpin_set_sub_category, (char *)"", NULL },
182220
{ (char*)"default_value", (getter)py_ue_edgraphpin_get_default_value, (setter)py_ue_edgraphpin_set_default_value, (char *)"", NULL },
183221
{ (char*)"default_text_value", (getter)py_ue_edgraphpin_get_default_text_value, (setter)py_ue_edgraphpin_set_default_text_value, (char *)"", NULL },
184222
{ (char*)"default_object", (getter)py_ue_edgraphpin_get_default_object, (setter)py_ue_edgraphpin_set_default_object, (char *)"", NULL },

Source/UnrealEnginePython/Private/Fbx/UEPyFbx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#pragma once
2+
23
#if ENGINE_MINOR_VERSION > 12
34
#include "UEPyModule.h"
45

Source/UnrealEnginePython/Private/Http/UEPyIHttpRequest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static PyObject *py_ue_ihttp_request_set_content(ue_PyIHttpRequest *self, PyObje
7272
return NULL;
7373
}
7474

75-
if (PyUnicode_Check(py_obj))
75+
if (PyUnicodeOrString_Check(py_obj))
7676
{
7777
self->http_request->SetContentAsString(UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(py_obj)));
7878
}
@@ -154,7 +154,7 @@ void FPythonSmartHttpDelegate::OnRequestComplete(FHttpRequestPtr request, FHttpR
154154
return;
155155
}
156156

157-
PyObject *ret = PyObject_CallFunction(py_callable, (char *)"OOO", py_http_request, py_ue_new_ihttp_response(response.Get()), successful ? Py_True : Py_False);
157+
PyObject *ret = PyObject_CallFunction(py_callable, (char *)"ONO", py_http_request, py_ue_new_ihttp_response(response.Get()), successful ? Py_True : Py_False);
158158
if (!ret)
159159
{
160160
unreal_engine_py_log_error();

Source/UnrealEnginePython/Private/PyUserWidget.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,22 +339,55 @@ bool UPyUserWidget::NativeIsInteractable() const
339339
return false;
340340
}
341341

342+
#if ENGINE_MINOR_VERSION < 20
342343
void UPyUserWidget::NativePaint(FPaintContext & InContext) const
344+
#else
345+
int32 UPyUserWidget::NativePaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
346+
#endif
343347
{
348+
349+
#if ENGINE_MINOR_VERSION >= 20
350+
FPaintContext InContext(AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled);
351+
#endif
352+
344353
if (!py_user_widget_instance)
354+
#if ENGINE_MINOR_VERSION >= 20
355+
return -1;
356+
#else
345357
return;
358+
#endif
346359

347360
FScopePythonGIL gil;
348361

349362
if (!PyObject_HasAttrString(py_user_widget_instance, (char *)"paint"))
363+
#if ENGINE_MINOR_VERSION >= 20
364+
return -1;
365+
#else
350366
return;
367+
#endif
351368

352369
PyObject *ret = PyObject_CallMethod(py_user_widget_instance, (char *)"paint", (char *)"O", py_ue_new_fpaint_context(InContext));
353370
if (!ret) {
354371
unreal_engine_py_log_error();
372+
#if ENGINE_MINOR_VERSION >= 20
373+
return -1;
374+
#else
355375
return;
376+
#endif
356377
}
378+
#if ENGINE_MINOR_VERSION >= 20
379+
int32 RetValue = -1;
380+
if (PyNumber_Check(ret))
381+
{
382+
PyObject *py_value = PyNumber_Long(ret);
383+
RetValue = PyLong_AsLong(py_value);
384+
Py_DECREF(py_value);
385+
}
386+
#endif
357387
Py_DECREF(ret);
388+
#if ENGINE_MINOR_VERSION >= 20
389+
return RetValue;
390+
#endif
358391
}
359392

360393
UPyUserWidget::UPyUserWidget(const FObjectInitializer& ObjectInitializer)

Source/UnrealEnginePython/Private/PythonComponent.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,6 @@ void UPythonComponent::EndPlay(const EEndPlayReason::Type EndPlayReason)
138138
return;
139139

140140
FScopePythonGIL gil;
141-
if (!PyObject_HasAttrString(py_component_instance, (char *)"end_play")) {
142-
return;
143-
}
144141

145142
if (PyObject_HasAttrString(py_component_instance, (char *)"end_play"))
146143
{
@@ -155,6 +152,8 @@ void UPythonComponent::EndPlay(const EEndPlayReason::Type EndPlayReason)
155152
}
156153

157154
Super::EndPlay(EndPlayReason);
155+
156+
// ...
158157
}
159158

160159
// Called every frame

Source/UnrealEnginePython/Private/PythonFunction.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL)
1919

2020
FScopePythonGIL gil;
2121

22+
#if ENGINE_MINOR_VERSION <= 18
23+
UObject *Context = Stack.Object;
24+
#endif
25+
2226
UPythonFunction *function = static_cast<UPythonFunction *>(Stack.CurrentNativeFunction);
2327

2428
bool on_error = false;
2529
bool is_static = function->HasAnyFunctionFlags(FUNC_Static);
2630

2731
// count the number of arguments
28-
Py_ssize_t argn = (Stack.Object && !is_static) ? 1 : 0;
32+
Py_ssize_t argn = (Context && !is_static) ? 1 : 0;
2933
TFieldIterator<UProperty> IArgs(function);
3034
for (; IArgs && ((IArgs->PropertyFlags & (CPF_Parm | CPF_ReturnParm)) == CPF_Parm); ++IArgs) {
3135
argn++;
@@ -34,22 +38,22 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL)
3438
UE_LOG(LogPython, Warning, TEXT("Initializing %d parameters"), argn);
3539
#endif
3640
PyObject *py_args = PyTuple_New(argn);
41+
argn = 0;
3742

38-
if (Stack.Object && !is_static) {
39-
PyObject *py_obj = (PyObject *)ue_get_python_uobject(Stack.Object);
43+
if (Context && !is_static) {
44+
PyObject *py_obj = (PyObject *)ue_get_python_uobject(Context);
4045
if (!py_obj) {
4146
unreal_engine_py_log_error();
4247
on_error = true;
4348
}
4449
else {
4550
Py_INCREF(py_obj);
46-
PyTuple_SetItem(py_args, 0, py_obj);
51+
PyTuple_SetItem(py_args, argn++, py_obj);
4752
}
4853
}
4954

5055
uint8 *frame = Stack.Locals;
5156

52-
argn = (Stack.Object && !is_static) ? 1 : 0;
5357
// is it a blueprint call ?
5458
if (*Stack.Code == EX_EndFunctionParms) {
5559
for (UProperty *prop = (UProperty *)function->Children; prop; prop = (UProperty *)prop->Next) {

0 commit comments

Comments
 (0)