diff --git a/README.md b/README.md index ee231ff61..2c8a2b319 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,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 minimal supported Unreal Engine version is 4.12, while the latest is 4.23 +The minimal supported Unreal Engine version is 4.12, while the latest is 4.24 We support official python.org releases as well as IntelPython and Anaconda distributions. diff --git a/Source/PythonAutomation/PythonAutomation.Build.cs b/Source/PythonAutomation/PythonAutomation.Build.cs index e2f80b814..6e5127cd6 100644 --- a/Source/PythonAutomation/PythonAutomation.Build.cs +++ b/Source/PythonAutomation/PythonAutomation.Build.cs @@ -13,8 +13,7 @@ public PythonAutomation(TargetInfo Target) { PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD"); - bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild); - + bUseUnity = string.IsNullOrEmpty(enableUnityBuild); PrivateIncludePaths.AddRange( new string[] { "PythonConsole/Private", diff --git a/Source/PythonConsole/PythonConsole.Build.cs b/Source/PythonConsole/PythonConsole.Build.cs index 29476f1dc..2065442b2 100644 --- a/Source/PythonConsole/PythonConsole.Build.cs +++ b/Source/PythonConsole/PythonConsole.Build.cs @@ -13,7 +13,7 @@ public PythonConsole(TargetInfo Target) { PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD"); - bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild); + bUseUnity = string.IsNullOrEmpty(enableUnityBuild); PrivateIncludePaths.AddRange( new string[] { diff --git a/Source/PythonEditor/Private/PythonEditor.cpp b/Source/PythonEditor/Private/PythonEditor.cpp index 42bbf9e5e..00d8cb9f4 100644 --- a/Source/PythonEditor/Private/PythonEditor.cpp +++ b/Source/PythonEditor/Private/PythonEditor.cpp @@ -7,6 +7,7 @@ #include "PythonEditorStyle.h" #include "PythonProjectEditor.h" #include "PythonProject.h" +#include "Subsystems/AssetEditorSubsystem.h" #include "Runtime/Slate/Public/Framework/MultiBox/MultiBoxBuilder.h" static const FName PythonEditorTabName( TEXT( "PythonEditor" ) ); diff --git a/Source/PythonEditor/Private/PythonProjectEditor.cpp b/Source/PythonEditor/Private/PythonProjectEditor.cpp index 33b2a56c8..1d17d5bf5 100644 --- a/Source/PythonEditor/Private/PythonProjectEditor.cpp +++ b/Source/PythonEditor/Private/PythonProjectEditor.cpp @@ -1,6 +1,11 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. #include "PythonProjectEditor.h" + +#include "Subsystems/AssetEditorSubsystem.h" + +// #include "UnrealEd.h" + #include "SPythonEditor.h" #include "SPythonProjectEditor.h" #include "Runtime/Slate/Public/Widgets/Docking/SDockTab.h" @@ -13,6 +18,8 @@ #include "PythonProjectEditorCommands.h" #include "Runtime/Core/Public/HAL/PlatformFilemanager.h" #include "Runtime/Core/Public/Misc/MessageDialog.h" + + #define LOCTEXT_NAMESPACE "PythonEditor" TWeakPtr FPythonProjectEditor::PythonEditor; @@ -209,7 +216,9 @@ void FPythonProjectEditor::RegisterToolbarTab(const TSharedRef& InitToolkitHost, class UPythonProject* PythonProject) { - FAssetEditorManager::Get().CloseOtherEditors(PythonProject, this); + // UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + // GEditor->GetEditorSubsystem()->CloseOtherEditors(PythonProject, this); + GEditor->GetEditorSubsystem()->CloseOtherEditors(PythonProject, this); PythonProjectBeingEdited = PythonProject; TSharedPtr ThisPtr(SharedThis(this)); diff --git a/Source/PythonEditor/PythonEditor.Build.cs b/Source/PythonEditor/PythonEditor.Build.cs index 11b024164..bba5cb41b 100644 --- a/Source/PythonEditor/PythonEditor.Build.cs +++ b/Source/PythonEditor/PythonEditor.Build.cs @@ -13,7 +13,7 @@ public PythonEditor(TargetInfo Target) PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD"); - bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild); + bUseUnity = string.IsNullOrEmpty(enableUnityBuild); PrivateIncludePaths.AddRange( new string[] { @@ -32,11 +32,13 @@ public PythonEditor(TargetInfo Target) "UnrealEd", "EditorStyle", "PropertyEditor", + "ContentBrowser", "Kismet", // for FWorkflowCentricApplication "InputCore", "DirectoryWatcher", "LevelEditor", "Projects", + "Engine", "UnrealEnginePython" } ); diff --git a/Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.cpp b/Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.cpp index 0b80f1466..0cd0bdf4d 100644 --- a/Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.cpp +++ b/Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.cpp @@ -1,7 +1,10 @@ #include "UEPyFMaterialEditorUtilities.h" + #if WITH_EDITOR +#include "Subsystems/AssetEditorSubsystem.h" + #include "Materials/Material.h" #include "Runtime/Engine/Classes/EdGraph/EdGraph.h" @@ -54,7 +57,9 @@ static PyObject *py_ue_command_apply(PyObject *cls, PyObject * args) return PyErr_Format(PyExc_Exception, "argument is not a UMaterial"); } - IAssetEditorInstance *Instance = FAssetEditorManager::Get().FindEditorForAsset(Material, false); + //UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + + IAssetEditorInstance *Instance = GEditor->GetEditorSubsystem()->FindEditorForAsset(Material, false); if (!Instance) { return PyErr_Format(PyExc_Exception, "unable to retrieve editor for UMaterial"); diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.cpp b/Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.cpp index 3e0b978ed..29e9e07b2 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.cpp @@ -1,5 +1,5 @@ #include "UEPyFMenuBuilder.h" - +#include "IAssetTools.h" #include "Wrappers/UEPyESlateEnums.h" static PyObject* py_ue_fmenu_builder_begin_section(ue_PyFMenuBuilder* self, PyObject* args) @@ -115,6 +115,9 @@ static PyObject* py_ue_fmenu_builder_add_menu_separator(ue_PyFMenuBuilder* self, } #if WITH_EDITOR + +#include "ContentBrowserModule.h" + static PyObject* py_ue_fmenu_builder_add_asset_actions(ue_PyFMenuBuilder* self, PyObject* args) { PyObject* py_assets; @@ -140,8 +143,10 @@ static PyObject* py_ue_fmenu_builder_add_asset_actions(ue_PyFMenuBuilder* self, Py_DECREF(py_assets); FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked(TEXT("AssetTools")); - bool addedSomething = AssetToolsModule.Get().GetAssetActions(u_objects, self->menu_builder, true); - if (addedSomething) + + FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked("ContentBrowser"); + TArray& AssetMenuExtenderDelegates = ContentBrowserModule.GetAllAssetViewContextMenuExtenders(); + if (AssetMenuExtenderDelegates.Num() > 0) { Py_RETURN_TRUE; } diff --git a/Source/UnrealEnginePython/Private/UEPyEditor.cpp b/Source/UnrealEnginePython/Private/UEPyEditor.cpp index 1b3df7bca..350611c2c 100644 --- a/Source/UnrealEnginePython/Private/UEPyEditor.cpp +++ b/Source/UnrealEnginePython/Private/UEPyEditor.cpp @@ -12,6 +12,7 @@ #include "UnrealEd.h" #include "FbxMeshUtils.h" #include "Kismet2/BlueprintEditorUtils.h" + #include "Editor/LevelEditor/Public/LevelEditorActions.h" #include "Editor/UnrealEd/Public/EditorLevelUtils.h" #include "Runtime/Projects/Public/Interfaces/IPluginManager.h" @@ -41,6 +42,7 @@ #include "UEPyIPlugin.h" + PyObject *py_unreal_engine_redraw_all_viewports(PyObject * self, PyObject * args) { FEditorSupportDelegates::RedrawAllViewports.Broadcast(); @@ -1140,7 +1142,9 @@ PyObject *py_unreal_engine_get_selected_assets(PyObject * self, PyObject * args) PyObject *py_unreal_engine_get_all_edited_assets(PyObject * self, PyObject * args) { - TArray assets = FAssetEditorManager::Get().GetAllEditedAssets(); + + //UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + TArray assets = GEditor->GetEditorSubsystem()->GetAllEditedAssets(); PyObject *assets_list = PyList_New(0); for (UObject *asset : assets) @@ -1168,7 +1172,9 @@ PyObject *py_unreal_engine_open_editor_for_asset(PyObject * self, PyObject * arg if (!u_obj) return PyErr_Format(PyExc_Exception, "argument is not a UObject"); - if (FAssetEditorManager::Get().OpenEditorForAsset(u_obj)) + //UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + + if (GEditor->GetEditorSubsystem()->OpenEditorForAsset(u_obj)) { Py_RETURN_TRUE; } @@ -1193,7 +1199,8 @@ PyObject *py_unreal_engine_find_editor_for_asset(PyObject * self, PyObject * arg if (py_bool && PyObject_IsTrue(py_bool)) bFocus = true; - IAssetEditorInstance *instance = FAssetEditorManager::Get().FindEditorForAsset(u_obj, bFocus); + //UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + IAssetEditorInstance *instance = GEditor->GetEditorSubsystem()->FindEditorForAsset(u_obj, bFocus); if (!instance) return PyErr_Format(PyExc_Exception, "no editor found for asset"); @@ -1212,14 +1219,16 @@ PyObject *py_unreal_engine_close_editor_for_asset(PyObject * self, PyObject * ar UObject *u_obj = ue_py_check_type(py_obj); if (!u_obj) return PyErr_Format(PyExc_Exception, "argument is not a UObject"); - FAssetEditorManager::Get().CloseAllEditorsForAsset(u_obj); + + //UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + GEditor->GetEditorSubsystem()->CloseAllEditorsForAsset(u_obj); Py_RETURN_NONE; } PyObject *py_unreal_engine_close_all_asset_editors(PyObject * self, PyObject * args) { - FAssetEditorManager::Get().CloseAllAssetEditors(); + GEditor->GetEditorSubsystem()->CloseAllAssetEditors(); Py_RETURN_NONE; } @@ -1355,7 +1364,7 @@ PyObject *py_unreal_engine_reload_blueprint(PyObject * self, PyObject * args) UBlueprint *reloaded_bp = nullptr; Py_BEGIN_ALLOW_THREADS - reloaded_bp = FKismetEditorUtilities::ReloadBlueprint(bp); + reloaded_bp = FKismetEditorUtilities::ReplaceBlueprint(bp, bp); Py_END_ALLOW_THREADS Py_RETURN_UOBJECT(reloaded_bp); diff --git a/Source/UnrealEnginePython/Private/UEPyModule.cpp b/Source/UnrealEnginePython/Private/UEPyModule.cpp index 56954d32e..7fb3a139a 100644 --- a/Source/UnrealEnginePython/Private/UEPyModule.cpp +++ b/Source/UnrealEnginePython/Private/UEPyModule.cpp @@ -203,8 +203,8 @@ static PyObject* py_ue_get_py_proxy(ue_PyUObject* self, PyObject* args) static PyObject* py_unreal_engine_shutdown(PyObject* self, PyObject* args) { - GIsRequestingExit = true; - + // GIsRequestingExit = true; + RequestEngineExit(FString(TEXT("I'm Shutting Down, Dave..."))); Py_RETURN_NONE; } diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyActor.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyActor.cpp index e319bcc94..cdde15840 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyActor.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyActor.cpp @@ -649,7 +649,7 @@ PyObject *py_ue_actor_create_default_subobject(ue_PyUObject * self, PyObject * a UObject *ret_obj = nullptr; Py_BEGIN_ALLOW_THREADS; - ret_obj = actor->CreateDefaultSubobject(FName(UTF8_TO_TCHAR(name)), UObject::StaticClass(), u_class, false, false, true); + ret_obj = actor->CreateDefaultSubobject(FName(UTF8_TO_TCHAR(name)), UObject::StaticClass(), u_class, false, true); Py_END_ALLOW_THREADS; if (!ret_obj) diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyMaterial.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyMaterial.cpp index c958094f6..efe80cc65 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyMaterial.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyMaterial.cpp @@ -511,7 +511,7 @@ PyObject *py_ue_static_mesh_set_collision_for_lod(ue_PyUObject *self, PyObject * FMeshSectionInfo info = mesh->SectionInfoMap.Get(lod_index, material_index); #endif info.bEnableCollision = enabled; - mesh->SectionInfoMap.Set(lod_index, material_index, info); + mesh->GetSectionInfoMap().Set(lod_index, material_index, info); mesh->MarkPackageDirty(); @@ -545,9 +545,9 @@ PyObject *py_ue_static_mesh_set_shadow_for_lod(ue_PyUObject *self, PyObject * ar enabled = true; } - FMeshSectionInfo info = mesh->SectionInfoMap.Get(lod_index, material_index); + FMeshSectionInfo info = mesh->GetSectionInfoMap().Get(lod_index, material_index); info.bCastShadow = enabled; - mesh->SectionInfoMap.Set(lod_index, material_index, info); + mesh->GetSectionInfoMap().Set(lod_index, material_index, info); mesh->MarkPackageDirty(); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPySequencer.cpp b/Source/UnrealEnginePython/Private/UObject/UEPySequencer.cpp index 8858a7936..65419111e 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPySequencer.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPySequencer.cpp @@ -8,6 +8,7 @@ #include "Runtime/LevelSequence/Public/LevelSequence.h" #if WITH_EDITOR +#include "Subsystems/AssetEditorSubsystem.h" #include "Editor/Sequencer/Public/ISequencer.h" #include "Editor/Sequencer/Public/ISequencerModule.h" #include "Editor/UnrealEd/Public/Toolkits/AssetEditorManager.h" @@ -209,9 +210,9 @@ static bool ImportFBXTransform(FString NodeName, UMovieScene3DTransformSection* #endif #if WITH_EDITOR + PyObject *py_ue_sequencer_changed(ue_PyUObject *self, PyObject * args) { - ue_py_check(self); PyObject *py_bool = nullptr; @@ -227,13 +228,17 @@ PyObject *py_ue_sequencer_changed(ue_PyUObject *self, PyObject * args) ULevelSequence *seq = (ULevelSequence *)self->ue_object; + //UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + if (py_bool && PyObject_IsTrue(py_bool)) { // try to open the editor for the asset - FAssetEditorManager::Get().OpenEditorForAsset(seq); + // FAssetEditorManager::Get().OpenEditorForAsset(seq); + GEditor->GetEditorSubsystem()->OpenEditorForAsset(seq); } - IAssetEditorInstance *editor = FAssetEditorManager::Get().FindEditorForAsset(seq, true); + // IAssetEditorInstance* editor = FAssetEditorManager::Get().FindEditorForAsset(seq, true); + IAssetEditorInstance* editor = GEditor->GetEditorSubsystem()->FindEditorForAsset(seq, true); if (editor) { FLevelSequenceEditorToolkit *toolkit = (FLevelSequenceEditorToolkit *)editor; @@ -464,9 +469,11 @@ PyObject *py_ue_sequencer_add_actor(ue_PyUObject *self, PyObject * args) actors.Add((AActor *)py_ue_obj->ue_object); // try to open the editor for the asset - FAssetEditorManager::Get().OpenEditorForAsset(seq); - IAssetEditorInstance *editor = FAssetEditorManager::Get().FindEditorForAsset(seq, true); + //UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + GEditor->GetEditorSubsystem()->OpenEditorForAsset(seq); + + IAssetEditorInstance *editor = GEditor->GetEditorSubsystem()->FindEditorForAsset(seq, true); if (editor) { FLevelSequenceEditorToolkit *toolkit = (FLevelSequenceEditorToolkit *)editor; @@ -519,9 +526,11 @@ PyObject *py_ue_sequencer_add_actor_component(ue_PyUObject *self, PyObject * arg UActorComponent* actorComponent = (UActorComponent *)py_ue_obj->ue_object; // try to open the editor for the asset - FAssetEditorManager::Get().OpenEditorForAsset(seq); - IAssetEditorInstance *editor = FAssetEditorManager::Get().FindEditorForAsset(seq, true); + UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + AssetEditorSubsystem->OpenEditorForAsset(seq); + + IAssetEditorInstance *editor = AssetEditorSubsystem->FindEditorForAsset(seq, true); FGuid new_guid; if (editor) { @@ -568,9 +577,11 @@ PyObject *py_ue_sequencer_make_new_spawnable(ue_PyUObject *self, PyObject * args ULevelSequence *seq = (ULevelSequence *)self->ue_object; // try to open the editor for the asset - FAssetEditorManager::Get().OpenEditorForAsset(seq); - IAssetEditorInstance *editor = FAssetEditorManager::Get().FindEditorForAsset(seq, true); + //UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + GEditor->GetEditorSubsystem()->OpenEditorForAsset(seq); + + IAssetEditorInstance *editor = GEditor->GetEditorSubsystem()->FindEditorForAsset(seq, true); if (!editor) { return PyErr_Format(PyExc_Exception, "unable to access sequencer"); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.cpp index eaf1a1cf8..43b4cf434 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.cpp @@ -124,10 +124,10 @@ PyObject *py_ue_static_mesh_get_raw_mesh(ue_PyUObject *self, PyObject * args) FRawMesh raw_mesh; - if (lod_index < 0 || lod_index >= mesh->SourceModels.Num()) + if (lod_index < 0 || lod_index >= mesh->GetSourceModels().Num()) return PyErr_Format(PyExc_Exception, "invalid LOD index"); - mesh->SourceModels[lod_index].RawMeshBulkData->LoadRawMesh(raw_mesh); + mesh->GetSourceModel(lod_index).RawMeshBulkData->LoadRawMesh(raw_mesh); return py_ue_new_fraw_mesh(raw_mesh); } diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyTransform.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyTransform.cpp index 34ae1eade..70793e038 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyTransform.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyTransform.cpp @@ -466,7 +466,7 @@ PyObject *py_ue_get_relative_location(ue_PyUObject *self, PyObject * args) ue_py_check(self); if (self->ue_object->IsA()) { - FVector vec3 = ((USceneComponent *)self->ue_object)->RelativeLocation; + FVector vec3 = ((USceneComponent *)self->ue_object)->GetRelativeLocation(); return py_ue_new_fvector(vec3); } return PyErr_Format(PyExc_Exception, "uobject is not a USceneComponent"); @@ -477,7 +477,7 @@ PyObject *py_ue_get_relative_rotation(ue_PyUObject *self, PyObject * args) ue_py_check(self); if (self->ue_object->IsA()) { - FRotator rot = ((USceneComponent *)self->ue_object)->RelativeRotation; + FRotator rot = ((USceneComponent *)self->ue_object)->GetRelativeRotation(); return py_ue_new_frotator(rot); } return PyErr_Format(PyExc_Exception, "uobject is not a USceneComponent"); @@ -488,7 +488,7 @@ PyObject *py_ue_get_relative_scale(ue_PyUObject *self, PyObject * args) ue_py_check(self); if (self->ue_object->IsA()) { - FVector vec3 = ((USceneComponent *)self->ue_object)->RelativeScale3D; + FVector vec3 = ((USceneComponent *)self->ue_object)->GetRelativeScale3D(); return py_ue_new_fvector(vec3); } return PyErr_Format(PyExc_Exception, "uobject is not a USceneComponent"); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyViewport.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyViewport.cpp index 4e7244b63..1b2d1e5a0 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyViewport.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyViewport.cpp @@ -4,6 +4,8 @@ #include "LevelEditor.h" #include "Editor/LevelEditor/Public/ILevelViewport.h" #include "Editor/UnrealEd/Public/LevelEditorViewport.h" +#include "SLevelViewport.h" + #endif #include "Slate/UEPySWidget.h" @@ -59,14 +61,15 @@ PyObject *py_unreal_engine_editor_set_view_mode(PyObject * self, PyObject * args return NULL; } - FLevelEditorModule &EditorModule = FModuleManager::LoadModuleChecked("LevelEditor"); + FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked("LevelEditor"); + TSharedPtr ActiveLevelViewport = LevelEditorModule.GetFirstActiveLevelViewport(); - if (!EditorModule.GetFirstActiveViewport().IsValid()) + if (!ActiveLevelViewport.IsValid()) return PyErr_Format(PyExc_Exception, "no active LevelEditor Viewport"); - FLevelEditorViewportClient &viewport_client = EditorModule.GetFirstActiveViewport()->GetLevelViewportClient(); + FLevelEditorViewportClient& LevelViewportClient = ActiveLevelViewport->GetLevelViewportClient(); - viewport_client.SetViewMode((EViewModeIndex)mode); + LevelViewportClient.SetViewMode((EViewModeIndex)mode); Py_RETURN_NONE; } @@ -81,14 +84,16 @@ PyObject *py_unreal_engine_editor_set_camera_speed(PyObject * self, PyObject * a return NULL; } - FLevelEditorModule &EditorModule = FModuleManager::LoadModuleChecked("LevelEditor"); - if (!EditorModule.GetFirstActiveViewport().IsValid()) + FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked("LevelEditor"); + TSharedPtr ActiveLevelViewport = LevelEditorModule.GetFirstActiveLevelViewport(); + + if (!ActiveLevelViewport.IsValid()) return PyErr_Format(PyExc_Exception, "no active LevelEditor Viewport"); - FLevelEditorViewportClient &viewport_client = EditorModule.GetFirstActiveViewport()->GetLevelViewportClient(); + FLevelEditorViewportClient& LevelViewportClient = ActiveLevelViewport->GetLevelViewportClient(); - viewport_client.SetCameraSpeedSetting(speed); + LevelViewportClient.SetCameraSpeedSetting(speed); Py_RETURN_NONE; } @@ -107,14 +112,15 @@ PyObject *py_unreal_engine_editor_set_view_location(PyObject * self, PyObject * if (!vector) return PyErr_Format(PyExc_Exception, "argument is not a FVector"); - FLevelEditorModule &EditorModule = FModuleManager::LoadModuleChecked("LevelEditor"); + FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked("LevelEditor"); + TSharedPtr ActiveLevelViewport = LevelEditorModule.GetFirstActiveLevelViewport(); - if (!EditorModule.GetFirstActiveViewport().IsValid()) + if (!ActiveLevelViewport.IsValid()) return PyErr_Format(PyExc_Exception, "no active LevelEditor Viewport"); - FLevelEditorViewportClient &viewport_client = EditorModule.GetFirstActiveViewport()->GetLevelViewportClient(); + FLevelEditorViewportClient& LevelViewportClient = ActiveLevelViewport->GetLevelViewportClient(); - viewport_client.SetViewLocation(vector->vec); + LevelViewportClient.SetViewLocation(vector->vec); Py_RETURN_NONE; } @@ -133,14 +139,15 @@ PyObject *py_unreal_engine_editor_set_view_rotation(PyObject * self, PyObject * if (!rotator) return PyErr_Format(PyExc_Exception, "argument is not a FRotator"); - FLevelEditorModule &EditorModule = FModuleManager::LoadModuleChecked("LevelEditor"); + FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked("LevelEditor"); + TSharedPtr ActiveLevelViewport = LevelEditorModule.GetFirstActiveLevelViewport(); - if (!EditorModule.GetFirstActiveViewport().IsValid()) + if (!ActiveLevelViewport.IsValid()) return PyErr_Format(PyExc_Exception, "no active LevelEditor Viewport"); - FLevelEditorViewportClient &viewport_client = EditorModule.GetFirstActiveViewport()->GetLevelViewportClient(); + FLevelEditorViewportClient& LevelViewportClient = ActiveLevelViewport->GetLevelViewportClient(); - viewport_client.SetViewRotation(rotator->rot); + LevelViewportClient.SetViewRotation(rotator->rot); Py_RETURN_NONE; } diff --git a/Source/UnrealEnginePython/Private/UnrealEnginePython.cpp b/Source/UnrealEnginePython/Private/UnrealEnginePython.cpp index 211124849..41113d733 100644 --- a/Source/UnrealEnginePython/Private/UnrealEnginePython.cpp +++ b/Source/UnrealEnginePython/Private/UnrealEnginePython.cpp @@ -47,7 +47,6 @@ const char *ue4_module_options = "linux_global_symbols"; #include "Android/AndroidApplication.h" #endif - const char *UEPyUnicode_AsUTF8(PyObject *py_str) { #if PY_MAJOR_VERSION < 3 @@ -249,7 +248,11 @@ void FUnrealEnginePythonModule::StartupModule() if (GConfig->GetString(UTF8_TO_TCHAR("Python"), UTF8_TO_TCHAR("Home"), PythonHome, GEngineIni)) { #if PY_MAJOR_VERSION >= 3 + #if ENGINE_MINOR_VERSION >= 20 + wchar_t *home = (wchar_t *)(TCHAR_TO_WCHAR(*PythonHome)); + #else wchar_t *home = (wchar_t *)*PythonHome; + #endif #else char *home = TCHAR_TO_UTF8(*PythonHome); #endif @@ -263,7 +266,11 @@ void FUnrealEnginePythonModule::StartupModule() FPaths::NormalizeFilename(PythonHome); PythonHome = FPaths::ConvertRelativePathToFull(PythonHome); #if PY_MAJOR_VERSION >= 3 + #if ENGINE_MINOR_VERSION >= 20 + wchar_t *home = (wchar_t *)(TCHAR_TO_WCHAR(*PythonHome)); + #else wchar_t *home = (wchar_t *)*PythonHome; + #endif #else char *home = TCHAR_TO_UTF8(*PythonHome); #endif @@ -277,7 +284,11 @@ void FUnrealEnginePythonModule::StartupModule() if (GConfig->GetString(UTF8_TO_TCHAR("Python"), UTF8_TO_TCHAR("ProgramName"), IniValue, GEngineIni)) { #if PY_MAJOR_VERSION >= 3 + #if ENGINE_MINOR_VERSION >= 20 + wchar_t *program_name = (wchar_t *)(TCHAR_TO_WCHAR(*IniValue)); + #else wchar_t *program_name = (wchar_t *)*IniValue; + #endif #else char *program_name = TCHAR_TO_UTF8(*IniValue); #endif @@ -290,7 +301,11 @@ void FUnrealEnginePythonModule::StartupModule() FPaths::NormalizeFilename(IniValue); IniValue = FPaths::ConvertRelativePathToFull(IniValue); #if PY_MAJOR_VERSION >= 3 + #if ENGINE_MINOR_VERSION >= 20 + wchar_t *program_name = (wchar_t *)(TCHAR_TO_WCHAR(*IniValue)); + #else wchar_t *program_name = (wchar_t *)*IniValue; + #endif #else char *program_name = TCHAR_TO_UTF8(*IniValue); #endif @@ -391,6 +406,7 @@ void FUnrealEnginePythonModule::StartupModule() } // Setup our own paths for PYTHONPATH + #if PLATFORM_WINDOWS TArray OurPythonPaths = { PythonHome, FPaths::Combine(PythonHome, TEXT("Lib")), @@ -403,10 +419,10 @@ void FUnrealEnginePythonModule::StartupModule() PathVars.Append(OurPythonPaths); FString ModifiedPath = FString::Join(PathVars, PathDelimiter); FPlatformMisc::SetEnvironmentVar(TEXT("PATH"), *ModifiedPath); + #endif } - #if PY_MAJOR_VERSION >= 3 init_unreal_engine_builtin(); #if PLATFORM_ANDROID diff --git a/Source/UnrealEnginePython/Private/hosts-per-state.py b/Source/UnrealEnginePython/Private/hosts-per-state.py new file mode 100644 index 000000000..4b1fa8084 --- /dev/null +++ b/Source/UnrealEnginePython/Private/hosts-per-state.py @@ -0,0 +1,13 @@ +""" Get lists of event hosts per state """ +from datetime import datetime, timezone, timedelta +import json +import csv +import sys +import copy + +import pytz +import pygsheets +import requests + +from auth.auth import create_drive_api, create_sheets_api, get_mobilize_credentials +import utils diff --git a/Source/UnrealEnginePython/UnrealEnginePython.Build.cs b/Source/UnrealEnginePython/UnrealEnginePython.Build.cs index a6fe71946..ee8070ba7 100644 --- a/Source/UnrealEnginePython/UnrealEnginePython.Build.cs +++ b/Source/UnrealEnginePython/UnrealEnginePython.Build.cs @@ -95,8 +95,9 @@ public UnrealEnginePython(TargetInfo Target) { PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; + PublicDefinitions.Add("WITH_UNREALENGINEPYTHON=1"); // fixed string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD"); - bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild); + bUseUnity = string.IsNullOrEmpty(enableUnityBuild); PublicIncludePaths.AddRange( new string[] { @@ -213,7 +214,7 @@ public UnrealEnginePython(TargetInfo Target) System.Console.WriteLine("Using Python at: " + pythonHome); PublicIncludePaths.Add(pythonHome); string libPath = GetWindowsPythonLibFile(pythonHome); - PublicLibraryPaths.Add(Path.GetDirectoryName(libPath)); + PublicSystemLibraryPaths.Add(Path.GetDirectoryName(libPath)); PublicAdditionalLibraries.Add(libPath); } else if (Target.Platform == UnrealTargetPlatform.Mac) @@ -229,7 +230,7 @@ public UnrealEnginePython(TargetInfo Target) System.Console.WriteLine("Using Python at: " + pythonHome); PublicIncludePaths.Add(pythonHome); string libPath = GetMacPythonLibFile(pythonHome); - PublicLibraryPaths.Add(Path.GetDirectoryName(libPath)); + PublicAdditionalLibraries.Add(Path.GetDirectoryName(libPath)); PublicDelayLoadDLLs.Add(libPath); } else if (Target.Platform == UnrealTargetPlatform.Linux) @@ -259,14 +260,15 @@ public UnrealEnginePython(TargetInfo Target) } #if WITH_FORWARDED_MODULE_RULES_CTOR else if (Target.Platform == UnrealTargetPlatform.Android) - { + { PublicIncludePaths.Add(System.IO.Path.Combine(ModuleDirectory, "../../android/python35/include")); - PublicLibraryPaths.Add(System.IO.Path.Combine(ModuleDirectory, "../../android/armeabi-v7a")); + PublicAdditionalLibraries.Add(System.IO.Path.Combine(ModuleDirectory, "../../android/armeabi-v7a")); PublicAdditionalLibraries.Add("python3.5m"); string APLName = "UnrealEnginePython_APL.xml"; - string RelAPLPath = Utils.MakePathRelativeTo(System.IO.Path.Combine(ModuleDirectory, APLName), Target.RelativeEnginePath); - AdditionalPropertiesForReceipt.Add(new ReceiptProperty("AndroidPlugin", RelAPLPath)); + string RelAPLPath = Utils.MakePathRelativeTo(ModuleDirectory, Target.RelativeEnginePath); + AdditionalPropertiesForReceipt.Add("AndroidPlugin", Path.Combine(RelAPLPath, APLName)); + } #endif