├── .gitignore ├── Content ├── BP_ActorTest.uasset ├── QRender │ └── Materials │ │ ├── AmbientOcclusion.uasset │ │ ├── BaseColor.uasset │ │ ├── Mat_InverseGammaSpace.uasset │ │ ├── Metallic.uasset │ │ ├── Roughness.uasset │ │ ├── SceneColor_RG.uasset │ │ ├── WorldNormal.uasset │ │ └── mat_inverseGammaSpace_Inst.uasset └── QUMG │ ├── QDialog │ ├── DefaultDialogCase.uasset │ ├── Dialog_Test.uasset │ └── QDialogDefaultTitlebar.uasset │ └── RectUI │ ├── Materials │ ├── BizMat │ │ ├── M_ModelItem_Inst.uasset │ │ ├── M_ModelItem_Outline_Inst.uasset │ │ ├── M_border_Inst.uasset │ │ └── M_btn_Inst.uasset │ ├── RectMaterial │ │ ├── MF_ClosestPointOnSegment.uasset │ │ ├── MF_PixelDistance.uasset │ │ ├── MF_PixelSizeToPercentage.uasset │ │ ├── MF_PixelSizeToPercentageNoRatio.uasset │ │ ├── MF_RoundBorderAlpha.uasset │ │ ├── MF_UniformPercentage.uasset │ │ ├── MF_WeightedInterpolation.uasset │ │ ├── MF_linearGradientSmooting.uasset │ │ └── M_RoundBorders.uasset │ └── SampleMI │ │ ├── MI_Sample_71.uasset │ │ └── MI_Sample_72.uasset │ └── Textures │ └── TX_HandPaintedWall.uasset ├── QCorePlugin.uplugin ├── Readme ├── BPExam.jpg ├── spliterwidget.png └── splitteranim.gif ├── Resources └── Icon128.png ├── Source ├── QCorePlugin │ ├── API │ │ ├── BusinssNetAPI.cpp │ │ ├── BusinssNetAPI.h │ │ ├── NetAPI.cpp │ │ └── NetAPI.h │ ├── BPLibrary │ │ ├── AssetBPLibrary.cpp │ │ ├── AssetBPLibrary.h │ │ ├── ComponentBPLibrary.cpp │ │ ├── ComponentBPLibrary.h │ │ ├── CoordProjectionBPLibrary.cpp │ │ ├── CoordProjectionBPLibrary.h │ │ ├── CoreBPLibrary.cpp │ │ ├── CoreBPLibrary.h │ │ ├── HttpBPLibrary.cpp │ │ ├── HttpBPLibrary.h │ │ ├── IOBPLibrary.cpp │ │ ├── IOBPLibrary.h │ │ ├── InputBPLibrary.cpp │ │ └── InputBPLibrary.h │ ├── CppWgt_BaseUserWidget.cpp │ ├── CppWgt_BaseUserWidget.h │ ├── Helper │ │ ├── DownloadHelper.cpp │ │ ├── DownloadHelper.h │ │ ├── ImageHelper.cpp │ │ ├── ImageHelper.h │ │ ├── NamedPipeHelper.cpp │ │ └── NamedPipeHelper.h │ ├── JsonObjectConverterEX.cpp │ ├── JsonObjectConverterEX.h │ ├── QCorePlugin.Build.cs │ ├── QCorePlugin.cpp │ ├── QCorePlugin.h │ └── Utils │ │ └── HACK_PRIVATE_MEMBER_UTILS.hpp ├── QDesktopPlatform │ ├── Private │ │ ├── DesktopPlatformBase.cpp │ │ ├── DesktopPlatformBase.h │ │ ├── DesktopPlatformPrivate.h │ │ ├── DesktopPlatformStub.h │ │ ├── Linux │ │ │ ├── DesktopPlatformLinux.cpp │ │ │ └── DesktopPlatformLinux.h │ │ ├── Mac │ │ │ ├── DesktopPlatformMac.cpp │ │ │ ├── DesktopPlatformMac.h │ │ │ ├── MacNativeFeedbackContext.cpp │ │ │ └── MacNativeFeedbackContext.h │ │ ├── PlatformInfo.cpp │ │ ├── QDesktopPlatformModule.cpp │ │ ├── TargetReceipt.cpp │ │ └── Windows │ │ │ ├── DesktopPlatformWindows.cpp │ │ │ ├── DesktopPlatformWindows.h │ │ │ ├── WindowsNativeFeedbackContext.cpp │ │ │ ├── WindowsNativeFeedbackContext.h │ │ │ ├── WindowsRegistry.cpp │ │ │ └── WindowsRegistry.h │ ├── Public │ │ ├── IDesktopPlatform.h │ │ ├── PlatformInfo.h │ │ ├── QDesktopPlatformModule.h │ │ └── TargetReceipt.h │ └── QDesktopPlatform.Build.cs ├── QRender │ ├── Private │ │ ├── Library │ │ │ ├── CaptureExtensionMethods.cpp │ │ │ └── OpenSysDialogMethods.cpp │ │ ├── Pipeline │ │ │ ├── CaptureRTTViewExtension.cpp │ │ │ ├── CaptureRTTViewExtension.h │ │ │ ├── CaptureRenderTarget.cpp │ │ │ ├── CaptureScreenPercentageDriver.cpp │ │ │ └── CaptureScreenPercentageDriver.h │ │ └── QRender.cpp │ ├── Public │ │ ├── DTO │ │ │ ├── ImageFormatEx.h │ │ │ └── MedioDTOModel.h │ │ ├── Library │ │ │ ├── CaptureExtensionMethods.h │ │ │ └── OpenSysDialogMethods.h │ │ ├── Pipeline │ │ │ └── CaptureRenderTarget.h │ │ └── QRender.h │ └── QRender.build.cs ├── QSlateFileDialogs │ ├── Private │ │ ├── SlateFileDialogsModule.cpp │ │ ├── SlateFileDialogsPrivate.h │ │ ├── SlateFileDialogsStyles.cpp │ │ ├── SlateFileDlgWindow.cpp │ │ └── SlateFileDlgWindow.h │ ├── Public │ │ ├── ISlateFileDialogModule.h │ │ ├── SlateFileDialogs.h │ │ └── SlateFileDialogsStyles.h │ └── QSlateFileDialogs.Build.cs └── QUMG │ ├── QUMG.Build.cs │ ├── QUMG.cpp │ ├── QUMG.h │ ├── UMG │ ├── Dialog │ │ ├── DialogManager.cpp │ │ ├── DialogManager.h │ │ ├── Interface │ │ │ ├── IQDialogInterface.cpp │ │ │ └── IQDialogInterface.h │ │ ├── QDialogContainer.cpp │ │ ├── QDialogContainer.h │ │ ├── QDialogTitlebar.cpp │ │ ├── QDialogTitlebar.h │ │ ├── QDialogWidget.cpp │ │ ├── QDialogWidget.h │ │ └── Utils │ │ │ ├── QDialogBPLibrary.cpp │ │ │ └── QDialogBPLibrary.h │ ├── Splitter │ │ ├── QSpliter.cpp │ │ ├── QSpliter.h │ │ ├── QSplitterSlot.cpp │ │ ├── QSplitterSlot.h │ │ ├── QSplitterWidget.cpp │ │ └── QSplitterWidget.h │ └── Tab │ │ ├── CppWgt_BaseTabContainer.cpp │ │ ├── CppWgt_BaseTabContainer.h │ │ ├── CppWgt_BaseTabContainerBtn.cpp │ │ ├── CppWgt_BaseTabContainerBtn.h │ │ └── Data │ │ └── QUI_TabItem.h │ └── WebExtend │ ├── SWebBrowserExtend.cpp │ ├── SWebBrowserExtend.h │ ├── WebBrowserExtend.cpp │ └── WebBrowserExtend.h └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。 3 | ################################################################################ 4 | 5 | /Binaries/Win64 6 | /.vs 7 | /Intermediate/Build/Win64 8 | -------------------------------------------------------------------------------- /Content/BP_ActorTest.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/BP_ActorTest.uasset -------------------------------------------------------------------------------- /Content/QRender/Materials/AmbientOcclusion.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QRender/Materials/AmbientOcclusion.uasset -------------------------------------------------------------------------------- /Content/QRender/Materials/BaseColor.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QRender/Materials/BaseColor.uasset -------------------------------------------------------------------------------- /Content/QRender/Materials/Mat_InverseGammaSpace.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QRender/Materials/Mat_InverseGammaSpace.uasset -------------------------------------------------------------------------------- /Content/QRender/Materials/Metallic.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QRender/Materials/Metallic.uasset -------------------------------------------------------------------------------- /Content/QRender/Materials/Roughness.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QRender/Materials/Roughness.uasset -------------------------------------------------------------------------------- /Content/QRender/Materials/SceneColor_RG.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QRender/Materials/SceneColor_RG.uasset -------------------------------------------------------------------------------- /Content/QRender/Materials/WorldNormal.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QRender/Materials/WorldNormal.uasset -------------------------------------------------------------------------------- /Content/QRender/Materials/mat_inverseGammaSpace_Inst.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QRender/Materials/mat_inverseGammaSpace_Inst.uasset -------------------------------------------------------------------------------- /Content/QUMG/QDialog/DefaultDialogCase.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/QDialog/DefaultDialogCase.uasset -------------------------------------------------------------------------------- /Content/QUMG/QDialog/Dialog_Test.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/QDialog/Dialog_Test.uasset -------------------------------------------------------------------------------- /Content/QUMG/QDialog/QDialogDefaultTitlebar.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/QDialog/QDialogDefaultTitlebar.uasset -------------------------------------------------------------------------------- /Content/QUMG/RectUI/Materials/BizMat/M_ModelItem_Inst.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/RectUI/Materials/BizMat/M_ModelItem_Inst.uasset -------------------------------------------------------------------------------- /Content/QUMG/RectUI/Materials/BizMat/M_ModelItem_Outline_Inst.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/RectUI/Materials/BizMat/M_ModelItem_Outline_Inst.uasset -------------------------------------------------------------------------------- /Content/QUMG/RectUI/Materials/BizMat/M_border_Inst.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/RectUI/Materials/BizMat/M_border_Inst.uasset -------------------------------------------------------------------------------- /Content/QUMG/RectUI/Materials/BizMat/M_btn_Inst.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/RectUI/Materials/BizMat/M_btn_Inst.uasset -------------------------------------------------------------------------------- /Content/QUMG/RectUI/Materials/RectMaterial/MF_ClosestPointOnSegment.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/RectUI/Materials/RectMaterial/MF_ClosestPointOnSegment.uasset -------------------------------------------------------------------------------- /Content/QUMG/RectUI/Materials/RectMaterial/MF_PixelDistance.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/RectUI/Materials/RectMaterial/MF_PixelDistance.uasset -------------------------------------------------------------------------------- /Content/QUMG/RectUI/Materials/RectMaterial/MF_PixelSizeToPercentage.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/RectUI/Materials/RectMaterial/MF_PixelSizeToPercentage.uasset -------------------------------------------------------------------------------- /Content/QUMG/RectUI/Materials/RectMaterial/MF_PixelSizeToPercentageNoRatio.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/RectUI/Materials/RectMaterial/MF_PixelSizeToPercentageNoRatio.uasset -------------------------------------------------------------------------------- /Content/QUMG/RectUI/Materials/RectMaterial/MF_RoundBorderAlpha.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/RectUI/Materials/RectMaterial/MF_RoundBorderAlpha.uasset -------------------------------------------------------------------------------- /Content/QUMG/RectUI/Materials/RectMaterial/MF_UniformPercentage.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/RectUI/Materials/RectMaterial/MF_UniformPercentage.uasset -------------------------------------------------------------------------------- /Content/QUMG/RectUI/Materials/RectMaterial/MF_WeightedInterpolation.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/RectUI/Materials/RectMaterial/MF_WeightedInterpolation.uasset -------------------------------------------------------------------------------- /Content/QUMG/RectUI/Materials/RectMaterial/MF_linearGradientSmooting.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/RectUI/Materials/RectMaterial/MF_linearGradientSmooting.uasset -------------------------------------------------------------------------------- /Content/QUMG/RectUI/Materials/RectMaterial/M_RoundBorders.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/RectUI/Materials/RectMaterial/M_RoundBorders.uasset -------------------------------------------------------------------------------- /Content/QUMG/RectUI/Materials/SampleMI/MI_Sample_71.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/RectUI/Materials/SampleMI/MI_Sample_71.uasset -------------------------------------------------------------------------------- /Content/QUMG/RectUI/Materials/SampleMI/MI_Sample_72.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/RectUI/Materials/SampleMI/MI_Sample_72.uasset -------------------------------------------------------------------------------- /Content/QUMG/RectUI/Textures/TX_HandPaintedWall.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Content/QUMG/RectUI/Textures/TX_HandPaintedWall.uasset -------------------------------------------------------------------------------- /QCorePlugin.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "Version": 1, 4 | "VersionName": "1.0", 5 | "FriendlyName": "QCorePlugin", 6 | "Description": "", 7 | "Category": "Other", 8 | "CreatedBy": "bj-linqing", 9 | "CreatedByURL": "", 10 | "DocsURL": "", 11 | "MarketplaceURL": "", 12 | "SupportURL": "", 13 | "CanContainContent": true, 14 | "IsBetaVersion": false, 15 | "Installed": false, 16 | "Modules": [ 17 | { 18 | "Name": "QCorePlugin", 19 | "Type": "Runtime", 20 | "LoadingPhase": "PreDefault" 21 | }, 22 | { 23 | "Name": "QUMG", 24 | "Type": "Runtime", 25 | "LoadingPhase": "PreDefault" 26 | }, 27 | { 28 | "Name": "QRender", 29 | "Type": "Runtime", 30 | "LoadingPhase": "PreDefault" 31 | } 32 | ], 33 | "Plugins": [ 34 | { 35 | "Name": "WebBrowserWidget", 36 | "Enabled": true 37 | }, 38 | { 39 | "Name": "OpenColorIO", 40 | "Enabled": true, 41 | "Optional": false 42 | }, 43 | { 44 | "Name": "OpenCVLensDistortion", 45 | "Enabled": true, 46 | "Optional": false 47 | } 48 | ] 49 | } -------------------------------------------------------------------------------- /Readme/BPExam.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Readme/BPExam.jpg -------------------------------------------------------------------------------- /Readme/spliterwidget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Readme/spliterwidget.png -------------------------------------------------------------------------------- /Readme/splitteranim.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Readme/splitteranim.gif -------------------------------------------------------------------------------- /Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Resources/Icon128.png -------------------------------------------------------------------------------- /Source/QCorePlugin/API/BusinssNetAPI.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Source/QCorePlugin/API/BusinssNetAPI.cpp -------------------------------------------------------------------------------- /Source/QCorePlugin/API/BusinssNetAPI.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Source/QCorePlugin/API/BusinssNetAPI.h -------------------------------------------------------------------------------- /Source/QCorePlugin/API/NetAPI.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Source/QCorePlugin/API/NetAPI.cpp -------------------------------------------------------------------------------- /Source/QCorePlugin/API/NetAPI.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Source/QCorePlugin/API/NetAPI.h -------------------------------------------------------------------------------- /Source/QCorePlugin/BPLibrary/AssetBPLibrary.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #include "AssetBPLibrary.h" 4 | 5 | #include "Engine/AssetManager.h" 6 | #include "Engine/Engine.h" 7 | 8 | UAssetBPLibrary::UAssetBPLibrary(const FObjectInitializer& ObjectInitializer) 9 | : Super(ObjectInitializer) 10 | { 11 | } 12 | 13 | FString UAssetBPLibrary::GetSoftObjectPtrRefPath(TSoftObjectPtr ptr) 14 | { 15 | FSoftObjectPath objPath = ptr.ToSoftObjectPath(); 16 | return objPath.GetAssetPathString(); 17 | } 18 | 19 | UObject* UAssetBPLibrary::LoadAsset(UObject* WorldContextObject, TSubclassOf ObjectClass, const FString& Path) 20 | { 21 | UObject* obj = LoadObject(nullptr, *Path); 22 | 23 | if ( obj ) 24 | { 25 | UE_LOG(LogTemp, Error, TEXT("Static Object name is %s"), *obj->GetName()); 26 | } 27 | 28 | return obj; 29 | } 30 | 31 | bool UAssetBPLibrary::IsValidOfAsset(UObject* WorldContextObject, const FString& Path) 32 | { 33 | 34 | FSoftObjectPath SoftPath (Path); 35 | FAssetData AssetData; 36 | 37 | UAssetManager &AssetMgr = UAssetManager::Get(); 38 | AssetMgr.GetAssetDataForPath(SoftPath, AssetData); 39 | 40 | 41 | return AssetData.GetPrimaryAssetId().IsValid(); 42 | 43 | } 44 | 45 | 46 | bool UAssetBPLibrary::IsLoadedOfAsset(UObject* WorldContextObject, const FString& Path) 47 | { 48 | FSoftObjectPath SoftPath(Path); 49 | FAssetData AssetData; 50 | 51 | UAssetManager &AssetMgr = UAssetManager::Get(); 52 | AssetMgr.GetAssetDataForPath(SoftPath, AssetData); 53 | 54 | return AssetData.IsAssetLoaded(); 55 | } -------------------------------------------------------------------------------- /Source/QCorePlugin/BPLibrary/AssetBPLibrary.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Kismet/BlueprintFunctionLibrary.h" 7 | 8 | #include "AssetBPLibrary.generated.h" 9 | 10 | /** 11 | * 12 | */ 13 | UCLASS() 14 | class QCOREPLUGIN_API UAssetBPLibrary : public UBlueprintFunctionLibrary 15 | { 16 | GENERATED_UCLASS_BODY() 17 | public: 18 | 19 | UFUNCTION( BlueprintPure, Category = "QCore | Asset") 20 | /** 获取Skeletal Mesh Asset 路径(目前主要用于编辑器工具集中) */ 21 | static FString GetSoftObjectPtrRefPath(TSoftObjectPtr ptr); 22 | 23 | UFUNCTION(BlueprintPure, Category = "QCore | Asset", meta = ( HidePin = "WorldContextObject", DeterminesOutputType = "ObjectClass", DefaultToSelf = "WorldContextObject") ) 24 | /**便捷函数,加载资源并自动转换资源为指定类型 */ 25 | static UObject* LoadAsset(UObject* WorldContextObject, TSubclassOf ObjectClass, const FString &Path ); 26 | 27 | UFUNCTION(BlueprintPure, Category = "QCore | Asset", meta = (HidePin = "WorldContextObject")) 28 | static bool IsValidOfAsset(UObject* WorldContextObject, const FString &Path); 29 | 30 | UFUNCTION(BlueprintPure, Category = "QCore | Asset", meta = (HidePin = "WorldContextObject")) 31 | static bool IsLoadedOfAsset(UObject * WorldContextObject, const FString & Path); 32 | }; 33 | -------------------------------------------------------------------------------- /Source/QCorePlugin/BPLibrary/ComponentBPLibrary.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Source/QCorePlugin/BPLibrary/ComponentBPLibrary.cpp -------------------------------------------------------------------------------- /Source/QCorePlugin/BPLibrary/ComponentBPLibrary.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqingwudiv1/QCorePlugin/b50565f5b7e4c580989ed32279f148d8f6ecf2a4/Source/QCorePlugin/BPLibrary/ComponentBPLibrary.h -------------------------------------------------------------------------------- /Source/QCorePlugin/BPLibrary/CoordProjectionBPLibrary.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #include "CoordProjectionBPLibrary.h" 4 | 5 | #include "Kismet/GameplayStatics.h" 6 | #include "Blueprint/WidgetLayoutLibrary.h" 7 | #include "Kismet/KismetInputLibrary.h" 8 | #include "Engine/Engine.h" 9 | 10 | #include "GameFramework/PlayerController.h" 11 | #include "Engine/LocalPlayer.h" 12 | #include "CoordProjectionBPLibrary.h" 13 | 14 | #include "SceneView.h" 15 | #include "UObject/UObjectIterator.h" 16 | 17 | FVector2D UCoordProjectionBPLibrary::ProjectWorldToScreenPosition(const FVector& WorldLocation) 18 | { 19 | TObjectIterator ThePC; 20 | // 21 | if (!ThePC) 22 | { 23 | return FVector2D::ZeroVector; 24 | } 25 | 26 | ULocalPlayer* LocalPlayer = Cast(ThePC->Player); 27 | if (LocalPlayer != NULL && LocalPlayer->ViewportClient != NULL && LocalPlayer->ViewportClient->Viewport != NULL) 28 | { 29 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 30 | 31 | // Create A View family for the game viewport 32 | FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues( 33 | LocalPlayer->ViewportClient->Viewport, 34 | ThePC->GetWorld()->Scene, 35 | LocalPlayer->ViewportClient->EngineShowFlags) 36 | .SetRealtimeUpdate(true)); 37 | 38 | // Calculate a view where the player is to update the streaming from the players start location 39 | FVector ViewLocation; 40 | FRotator ViewRotation; 41 | FSceneView* SceneView = LocalPlayer->CalcSceneView(&ViewFamily, /*out*/ ViewLocation, /*out*/ ViewRotation, LocalPlayer->ViewportClient->Viewport); 42 | 43 | //Valid Scene View? 44 | if (SceneView) 45 | { 46 | //Return 47 | FVector2D ScreenLocation; 48 | SceneView->WorldToPixel(WorldLocation, ScreenLocation); 49 | 50 | return ScreenLocation; 51 | } 52 | } 53 | 54 | return FVector2D::ZeroVector; 55 | } 56 | 57 | 58 | bool UCoordProjectionBPLibrary::DeprojectScreenPosition(UObject * WorldContextObject, const FVector2D & ViewportPosition, FVector & OutWorldOrigin, FVector & OutWorldDirection) 59 | { 60 | bool bResult = false; 61 | 62 | if (UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::ReturnNull)) 63 | { 64 | bResult = UGameplayStatics::DeprojectScreenToWorld(World->GetFirstPlayerController(), ViewportPosition, OutWorldOrigin, OutWorldDirection); 65 | } 66 | 67 | return bResult; 68 | } 69 | 70 | 71 | 72 | TArray UCoordProjectionBPLibrary::WorldBoxToScreenBox(UObject *WorldContextObject, const FVector& Center, const FRotator& rot, const FVector& Extend) 73 | { 74 | FTransform tran(rot); 75 | TArray arr; 76 | 77 | arr.Add(Center + tran.TransformPosition(FVector{ Extend.X , Extend.Y, Extend.Z })); 78 | arr.Add(Center + tran.TransformPosition(FVector{ Extend.X , -Extend.Y, -Extend.Z })); 79 | arr.Add(Center + tran.TransformPosition(FVector{ Extend.X , Extend.Y, -Extend.Z })); 80 | arr.Add(Center + tran.TransformPosition(FVector{ Extend.X , -Extend.Y, Extend.Z })); 81 | 82 | arr.Add(Center + tran.TransformPosition(FVector{ -Extend.X , Extend.Y, Extend.Z })); 83 | arr.Add(Center + tran.TransformPosition(FVector{ -Extend.X , -Extend.Y, -Extend.Z })); 84 | arr.Add(Center + tran.TransformPosition(FVector{ -Extend.X , Extend.Y, -Extend.Z })); 85 | arr.Add(Center + tran.TransformPosition(FVector{ -Extend.X , -Extend.Y, Extend.Z })); 86 | 87 | TArray arr2d; 88 | 89 | for (FVector vec : arr) 90 | { 91 | //DrawDebugPoint(WorldContextObject->GetWorld(), vec, 4, FColor::Red); 92 | FVector2D temp_vec2d = UCoordProjectionBPLibrary::ProjectWorldToScreenPosition(vec) * (1.00000f / UWidgetLayoutLibrary::GetViewportScale(WorldContextObject)); 93 | arr2d.Add(temp_vec2d); 94 | } 95 | 96 | TArray arrline; 97 | 98 | #pragma region draw surface line 99 | 100 | arrline.Add(arr2d[0]); 101 | arrline.Add(arr2d[2]); 102 | 103 | arrline.Add(arr2d[1]); 104 | arrline.Add(arr2d[3]); 105 | 106 | arrline.Add(arr2d[4]); 107 | arrline.Add(arr2d[6]); 108 | 109 | arrline.Add(arr2d[5]); 110 | arrline.Add(arr2d[7]); 111 | 112 | arrline.Add(arr2d[0]); 113 | arrline.Add(arr2d[4]); 114 | 115 | arrline.Add(arr2d[3]); 116 | arrline.Add(arr2d[7]); 117 | 118 | arrline.Add(arr2d[1]); 119 | arrline.Add(arr2d[5]); 120 | 121 | arrline.Add(arr2d[2]); 122 | arrline.Add(arr2d[6]); 123 | 124 | arrline.Add(arr2d[0]); 125 | arrline.Add(arr2d[3]); 126 | 127 | arrline.Add(arr2d[2]); 128 | arrline.Add(arr2d[1]); 129 | 130 | arrline.Add(arr2d[6]); 131 | arrline.Add(arr2d[5]); 132 | 133 | arrline.Add(arr2d[4]); 134 | arrline.Add(arr2d[7]); 135 | 136 | #pragma endregion 137 | 138 | return arrline; 139 | } 140 | 141 | 142 | FVector2D UCoordProjectionBPLibrary::GetMousePosition(UObject * WorldContextObject) 143 | { 144 | if (!GEngine) 145 | { 146 | return FVector2D{}; 147 | } 148 | UGameViewportClient* viewport = GEngine->GameViewport; 149 | float factory = UWidgetLayoutLibrary::GetViewportScale(WorldContextObject); 150 | FVector2D mousePos = UWidgetLayoutLibrary::GetMousePositionOnViewport(WorldContextObject); 151 | mousePos = mousePos * factory; 152 | return mousePos; 153 | } 154 | 155 | bool UCoordProjectionBPLibrary::GetMousePositionByScreenPosition(UObject * WorldContextObject, FVector & OutWorldOrigin, FVector & OutWorldDirection) 156 | { 157 | FVector2D ViewPos = UCoordProjectionBPLibrary::GetMousePosition(WorldContextObject); 158 | bool bResult = UCoordProjectionBPLibrary::DeprojectScreenPosition(WorldContextObject, ViewPos, OutWorldOrigin, OutWorldDirection); 159 | return bResult; 160 | } -------------------------------------------------------------------------------- /Source/QCorePlugin/BPLibrary/CoordProjectionBPLibrary.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Kismet/BlueprintFunctionLibrary.h" 7 | 8 | 9 | #include "CoordProjectionBPLibrary.generated.h" 10 | 11 | 12 | /** 13 | * 2D-3D空间坐标系投影 14 | */ 15 | UCLASS() 16 | class QCOREPLUGIN_API UCoordProjectionBPLibrary : public UBlueprintFunctionLibrary 17 | { 18 | GENERATED_BODY() 19 | public: 20 | 21 | /* 世界坐标转屏幕坐标(屏幕投影) */ 22 | UFUNCTION(BlueprintPure, Category = "QCore | CoordProjection") 23 | static FVector2D ProjectWorldToScreenPosition(const FVector& WorldLocation); 24 | 25 | /* 转换屏幕坐标到场景坐标(屏幕解投影). */ 26 | UFUNCTION( BlueprintPure, Category = "QCore | CoordProjection", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject") ) 27 | static bool DeprojectScreenPosition(UObject* WorldContextObject, const FVector2D& ViewportPosition, FVector& OutWorldOrigin, FVector& OutWorldDirection); 28 | 29 | /** 世界坐标盒体到屏幕盒体(绘制线)的投影. */ 30 | UFUNCTION( BlueprintPure, Category = "QCore | CoordProjection", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject") ) 31 | static TArray WorldBoxToScreenBox(UObject *WorldContextObject,const FVector& Center, const FRotator& rot, const FVector& Extend); 32 | 33 | /** 获取鼠标在视口的位置 */ 34 | UFUNCTION( BlueprintPure, Category = "QCore | CoordProjection", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject") ) 35 | static FVector2D GetMousePosition(UObject *WorldContextObject); 36 | 37 | /** 获取鼠标在视口位置的场景投影与方向 */ 38 | UFUNCTION( BlueprintPure, Category = "QCore | CoordProjection", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject") ) 39 | static bool GetMousePositionByScreenPosition(UObject *WorldContextObject, FVector& OutWorldOrigin, FVector& OutWorldDirection); 40 | 41 | }; 42 | -------------------------------------------------------------------------------- /Source/QCorePlugin/BPLibrary/CoreBPLibrary.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #include "CoreBPLibrary.h" 4 | 5 | 6 | #include "Engine/Engine.h" 7 | #include "Misc/Paths.h" 8 | #include "Misc/FileHelper.h" 9 | #include "Engine/Texture2D.h" 10 | #include "IImageWrapperModule.h" 11 | #include "IImageWrapper.h" 12 | #include "Engine/StaticMesh.h" 13 | #include "Kismet/GameplayStatics.h" 14 | #include "Kismet/KismetInputLibrary.h" 15 | #include "Internationalization/Regex.h" 16 | 17 | // 18 | #include "Framework/Application/SlateApplication.h" 19 | #include "Widgets/SViewport.h" 20 | 21 | // 22 | #include "IDesktopPlatform.h" 23 | #if UE_BUILD_SHIPPING 24 | #include "QDesktopPlatformModule.h" 25 | #else 26 | #include "DesktopPlatformModule.h" 27 | #endif 28 | 29 | 30 | 31 | // 32 | #include "Helper/ImageHelper.h" 33 | 34 | #pragma region Static Method 35 | 36 | static bool IsAllowedChar(UTF8CHAR LookupChar) 37 | { 38 | static char AllowedChars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+=_.~:/#@?&!"; 39 | static bool bTableFilled = false; 40 | static bool AllowedTable[256] = { false }; 41 | 42 | if (!bTableFilled) 43 | { 44 | for (int32 Idx = 0; Idx < UE_ARRAY_COUNT(AllowedChars) - 1; ++Idx) // -1 to avoid trailing 0 45 | { 46 | uint8 AllowedCharIdx = static_cast(AllowedChars[Idx]); 47 | 48 | check(AllowedCharIdx < UE_ARRAY_COUNT(AllowedTable)); 49 | AllowedTable[AllowedCharIdx] = true; 50 | } 51 | 52 | bTableFilled = true; 53 | } 54 | 55 | return AllowedTable[LookupChar]; 56 | } 57 | 58 | #pragma endregion 59 | 60 | UCoreBPLibrary::UCoreBPLibrary(const FObjectInitializer& ObjectInitializer) 61 | : Super(ObjectInitializer) 62 | { 63 | } 64 | 65 | FString UCoreBPLibrary::GetPointerAddress(UObject* obj) 66 | { 67 | return FString::Printf(TEXT("%p"), obj); 68 | } 69 | 70 | bool UCoreBPLibrary::RegexMatch(const FString& Str, const FString& Pattern, TArray& Result) 71 | { 72 | FRegexPattern MatherPatter(Pattern); 73 | FRegexMatcher Matcher(MatherPatter, Str); 74 | 75 | while (Matcher.FindNext()) 76 | { 77 | Result.Add(Matcher.GetCaptureGroup(0)); 78 | } 79 | 80 | return Result.Num() == 0 ? false : true; 81 | } 82 | 83 | TArray UCoreBPLibrary::OpenFileDialog( UObject * WorldContextObject, 84 | const FString &Title , 85 | const FString defPath , 86 | const FString& FileTypes , 87 | EM_EFileDialogFlags Flags ) 88 | { 89 | void* ParentWindowPtr = FSlateApplication::Get().GetActiveTopLevelWindow()->GetNativeWindow()->GetOSWindowHandle(); 90 | TArray arr_outfile; 91 | IDesktopPlatform* deskPlatform = nullptr; 92 | 93 | #if UE_BUILD_SHIPPING 94 | deskPlatform = FQDesktopPlatformModule::Get(); 95 | #else 96 | deskPlatform = FDesktopPlatformModule::Get(); 97 | #endif 98 | 99 | FString def_path = defPath.IsEmpty() ? FPaths::ProjectDir() : defPath; 100 | 101 | bool isSuccess = deskPlatform->OpenFileDialog(ParentWindowPtr, 102 | *Title, 103 | def_path, 104 | TEXT("") , 105 | FileTypes /*TEXT("打开图片|*.png;*.jpg;*.jpeg")*/, 106 | (uint32)Flags, 107 | arr_outfile); 108 | 109 | return arr_outfile; 110 | } 111 | 112 | int32 UCoreBPLibrary::GetMeshMaterialNum(UStaticMesh * mesh) 113 | { 114 | 115 | int32 num = mesh->GetStaticMaterials().Num(); 116 | 117 | return num; 118 | } 119 | 120 | bool UCoreBPLibrary::executeShellCMD(const FString & cmd) 121 | { 122 | #if PLATFORM_WINDOWS 123 | const char* convert_cmd = TCHAR_TO_UTF8(*cmd); 124 | system(convert_cmd); 125 | return true; 126 | #else 127 | UE_LOG(LogTemp, Error, TEXT("platform is not support")); 128 | return false; 129 | #endif 130 | } 131 | 132 | 133 | FString UCoreBPLibrary::UrlEncode( const FString &UnencodedString) 134 | { 135 | FTCHARToUTF8 Converter(*UnencodedString); //url encoding must be encoded over each utf-8 byte 136 | const UTF8CHAR* UTF8Data = (UTF8CHAR*)Converter.Get(); //converter uses ANSI instead of UTF8CHAR - not sure why - but other code seems to just do this cast. In this case it really doesn't matter 137 | FString EncodedString = TEXT(""); 138 | 139 | TCHAR Buffer[2] = { 0, 0 }; 140 | 141 | for (int32 ByteIdx = 0, Length = Converter.Length(); ByteIdx < Length; ++ByteIdx) 142 | { 143 | UTF8CHAR ByteToEncode = UTF8Data[ByteIdx]; 144 | 145 | if (IsAllowedChar(ByteToEncode)) 146 | { 147 | Buffer[0] = ByteToEncode; 148 | FString TmpString = Buffer; 149 | EncodedString += TmpString; 150 | } 151 | else if (ByteToEncode != '\0') 152 | { 153 | EncodedString += TEXT("%"); 154 | EncodedString += FString::Printf(TEXT("%.2X"), ByteToEncode); 155 | } 156 | } 157 | return EncodedString; 158 | } 159 | 160 | void UCoreBPLibrary::AdjustViewportSize(UObject * WorldContextObject, FMargin padding) 161 | { 162 | if (WorldContextObject->GetWorld() && GEngine) 163 | { 164 | 165 | UGameViewportClient* gameViewport = GEngine->GameViewport; 166 | 167 | FVector2D ViewportSize; 168 | 169 | gameViewport->GetViewportSize(ViewportSize); 170 | 171 | // The GameViewport takes some time to initialize 172 | if (ViewportSize.X > 0 && ViewportSize.Y > 0) 173 | { 174 | FMargin relativeMat = FMargin 175 | { 176 | padding.Left / ViewportSize.X , 177 | padding.Top / ViewportSize.Y , 178 | 1 - padding.Right / ViewportSize.X , 179 | 1 - padding.Bottom / ViewportSize.Y 180 | }; 181 | 182 | gameViewport->SplitscreenInfo[0].PlayerData[0].OriginX = relativeMat.Left; 183 | gameViewport->SplitscreenInfo[0].PlayerData[0].OriginY = relativeMat.Top; 184 | 185 | gameViewport->SplitscreenInfo[0].PlayerData[0].SizeX = relativeMat.Right; 186 | gameViewport->SplitscreenInfo[0].PlayerData[0].SizeY = relativeMat.Bottom; 187 | 188 | } 189 | } 190 | } 191 | 192 | 193 | UTexture2D * UCoreBPLibrary::ConvertTexture2DDynaimcToTexture2D(UTexture2DDynamic * target) 194 | { 195 | return UImageHelper::ConvertTexture2DDynamicToTexture2D(target); 196 | } 197 | 198 | -------------------------------------------------------------------------------- /Source/QCorePlugin/BPLibrary/CoreBPLibrary.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Kismet/BlueprintFunctionLibrary.h" 7 | 8 | #include "CoreBPLibrary.generated.h" 9 | 10 | class UTexture2D; 11 | class UTexture2DDynamic; 12 | class UObject; 13 | 14 | UENUM(BlueprintType) 15 | enum class EM_EFileDialogFlags : uint8 16 | { 17 | None = 0x00 UMETA(DisplayName = "None"), // No flags 18 | Multiple = 0x01 UMETA(DisplayName = "Multiple") // Allow multiple file selections 19 | }; 20 | 21 | /** 22 | * 23 | */ 24 | UCLASS() 25 | class QCOREPLUGIN_API UCoreBPLibrary : public UBlueprintFunctionLibrary 26 | { 27 | GENERATED_UCLASS_BODY() 28 | public: 29 | 30 | UFUNCTION(BlueprintPure, Category = "QCore |Common Function") 31 | static FString GetPointerAddress(UObject * obj); 32 | 33 | 34 | /** 正则 */ 35 | UFUNCTION(BlueprintPure, Category = "QCore |Common Function") 36 | static bool RegexMatch(const FString& Str, const FString& Pattern, TArray& Result); 37 | 38 | /** 39 | * 40 | **/ 41 | UFUNCTION(BlueprintCallable, Category = "QCore | Common Function", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject")) 42 | static TArray OpenFileDialog(UObject * WorldContextObject, 43 | const FString &Title = "Title", 44 | const FString defPath = "", 45 | const FString& FileTypes = "All Files|*.*", 46 | EM_EFileDialogFlags Flags = EM_EFileDialogFlags::None); 47 | 48 | /** 49 | * 模型的材质数 50 | **/ 51 | UFUNCTION(BlueprintCallable, Category = "QCore | Common Function") 52 | static int32 GetMeshMaterialNum(class UStaticMesh *mesh); 53 | 54 | /** Shell */ 55 | UFUNCTION(BlueprintCallable, Category = "QCore | Common Function") 56 | static bool executeShellCMD(const FString& cmd); 57 | 58 | /** 解码URL */ 59 | UFUNCTION(BlueprintPure, Category = "QCore | Common Function") 60 | static FString UrlEncode( const FString& UnencodedString); 61 | 62 | /** 改变3D视口大小*/ 63 | UFUNCTION(BlueprintCallable, Category = "QCore | Common Function", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject")) 64 | static void AdjustViewportSize(UObject * WorldContextObject, FMargin padding); 65 | 66 | /** */ 67 | UFUNCTION(BlueprintPure, Category = "QCore | Common Function") 68 | static UTexture2D* ConvertTexture2DDynaimcToTexture2D(UTexture2DDynamic* target); 69 | 70 | }; 71 | -------------------------------------------------------------------------------- /Source/QCorePlugin/BPLibrary/HttpBPLibrary.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #include "HttpBPLibrary.h" 4 | 5 | #include "Helper/DownloadHelper.h" 6 | 7 | UDownloadHelper* UHttpBPLibrary::DownloadRange(UObject* WorldContextObject, const FString& Url) 8 | { 9 | UDownloadHelper* NewObj = NewObject(WorldContextObject, NAME_None, RF_Transient); 10 | 11 | NewObj->StartByDisk(Url, TEXT("d:/disk.png")); 12 | 13 | NewObj->OnDownloadCompleted().AddLambda([](UDownloadHelper* _DownloadHelper, bool bSuccessful , const FString &msg) 14 | { 15 | UE_LOG(LogTemp, Log, TEXT("Download Completed... %d %s"), bSuccessful ,*msg); 16 | }); 17 | NewObj->OnDownloadProgress().AddLambda([](UDownloadHelper* _DownloadHelper,const FQHttpProgress& info ) 18 | { 19 | UE_LOG(LogTemp, Log, TEXT("Download Progress... %d / %d %f / %f"), info.NewReceive, info.NewSent, info.ReceiveProgress, info.SentProgress); 20 | }); 21 | 22 | return NewObj; 23 | } -------------------------------------------------------------------------------- /Source/QCorePlugin/BPLibrary/HttpBPLibrary.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Kismet/BlueprintFunctionLibrary.h" 7 | 8 | #include "HttpBPLibrary.generated.h" 9 | 10 | class UDownloadHelper; 11 | /** 12 | * 13 | */ 14 | UCLASS() 15 | class QCOREPLUGIN_API UHttpBPLibrary : public UBlueprintFunctionLibrary 16 | { 17 | GENERATED_BODY() 18 | public: 19 | UFUNCTION(BlueprintCallable, Category = "QCore | Http", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject") ) 20 | static UDownloadHelper* DownloadRange(UObject* WorldContextObject, const FString & Url); 21 | }; 22 | -------------------------------------------------------------------------------- /Source/QCorePlugin/BPLibrary/IOBPLibrary.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #include "IOBPLibrary.h" 4 | 5 | 6 | #include "Misc/FileHelper.h" 7 | // 8 | #include "Helper/ImageHelper.h" 9 | 10 | UIOBPLibrary::UIOBPLibrary(const FObjectInitializer& ObjectInitializer) 11 | : Super(ObjectInitializer) 12 | { 13 | } 14 | 15 | UTexture2D * UIOBPLibrary::LoadTexture2DFromDisk(const FString &Path, bool bAutoGenerateMips, bool bForceGenerateMips) 16 | { 17 | return UImageHelper::LoadFromDisk(Path, bAutoGenerateMips, bForceGenerateMips); 18 | } 19 | 20 | bool UIOBPLibrary::WriteFile(const FString& FilePath, TArray& Data) 21 | { 22 | if (!FPaths::FileExists(FilePath)) 23 | { 24 | FFileHelper::SaveArrayToFile(Data, *FilePath); 25 | } 26 | else 27 | { 28 | FArchive* FileWriter = IFileManager::Get().CreateFileWriter(*FilePath, EFileWrite::FILEWRITE_Append); 29 | FileWriter->Serialize(Data.GetData(), Data.Num()); 30 | FileWriter->Close(); 31 | } 32 | 33 | return true; 34 | } 35 | -------------------------------------------------------------------------------- /Source/QCorePlugin/BPLibrary/IOBPLibrary.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Kismet/BlueprintFunctionLibrary.h" 7 | 8 | #include "IOBPLibrary.generated.h" 9 | 10 | class UTexture2D; 11 | class UTexture2DDynamic; 12 | 13 | 14 | /** 15 | * 16 | */ 17 | UCLASS() 18 | class QCOREPLUGIN_API UIOBPLibrary : public UBlueprintFunctionLibrary 19 | { 20 | GENERATED_UCLASS_BODY() 21 | public: 22 | 23 | /** 24 | * 从磁盘中加载UTexture2D 25 | **/ 26 | UFUNCTION(BlueprintPure, Category = "QCore | IO |Common Function") 27 | static class UTexture2D* LoadTexture2DFromDisk(const FString &Path, bool bAutoGenerateMips = true, bool bForceGenerateMips = false); 28 | 29 | 30 | static bool WriteFile(const FString& FilePath, TArray& Data); 31 | }; 32 | -------------------------------------------------------------------------------- /Source/QCorePlugin/BPLibrary/InputBPLibrary.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #include "InputBPLibrary.h" 4 | 5 | 6 | 7 | UInputBPLibrary::UInputBPLibrary(const FObjectInitializer& ObjectInitializer) 8 | : Super(ObjectInitializer) 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /Source/QCorePlugin/BPLibrary/InputBPLibrary.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Kismet/BlueprintFunctionLibrary.h" 7 | 8 | #include "InputBPLibrary.generated.h" 9 | 10 | 11 | 12 | /** 13 | * 14 | */ 15 | UCLASS() 16 | class QCOREPLUGIN_API UInputBPLibrary : public UBlueprintFunctionLibrary 17 | { 18 | GENERATED_UCLASS_BODY() 19 | public: 20 | 21 | /** 22 | * 模拟Input 23 | **/ 24 | 25 | }; 26 | -------------------------------------------------------------------------------- /Source/QCorePlugin/CppWgt_BaseUserWidget.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "CppWgt_BaseUserWidget.h" 5 | 6 | FReply UCppWgt_BaseUserWidget::NativeOnMouseWheel(const FGeometry & InGeometry, const FPointerEvent & InMouseEvent) 7 | { 8 | return Super::NativeOnMouseWheel(InGeometry, InMouseEvent); 9 | } 10 | 11 | void UCppWgt_BaseUserWidget::NativeConstruct() 12 | { 13 | Super::NativeConstruct(); 14 | OnInitCompleted().Broadcast(); 15 | } -------------------------------------------------------------------------------- /Source/QCorePlugin/CppWgt_BaseUserWidget.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Blueprint/UserWidget.h" 7 | #include "CppWgt_BaseUserWidget.generated.h" 8 | 9 | 10 | 11 | //DECLARE_MULTICAST_DELEGATE(FOnDialogClose); 12 | 13 | /** 14 | * 15 | */ 16 | UCLASS(Abstract, editinlinenew, BlueprintType, Blueprintable, meta = (DontUseGenericSpawnObject = "True", DisableNativeTick)) 17 | class QCOREPLUGIN_API UCppWgt_BaseUserWidget : public UUserWidget 18 | { 19 | GENERATED_BODY() 20 | 21 | #pragma region Event 22 | 23 | public: 24 | DECLARE_EVENT(FString, FOnInitCompleted); 25 | FOnInitCompleted& OnInitCompleted() {return this->Event_InitCompleted;} 26 | protected: 27 | FOnInitCompleted Event_InitCompleted; 28 | 29 | #pragma endregion 30 | 31 | protected: 32 | /***/ 33 | virtual FReply NativeOnMouseWheel(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent); 34 | /***/ 35 | virtual void NativeConstruct(); 36 | }; 37 | -------------------------------------------------------------------------------- /Source/QCorePlugin/Helper/DownloadHelper.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "DownloadHelper.h" 5 | 6 | #include "BPLibrary/CoreBPLibrary.h" 7 | 8 | #include "API/NetAPI.h" 9 | 10 | #include "Misc/FileHelper.h" 11 | #include "Internationalization/Regex.h" 12 | #include "GenericPlatform/GenericPlatformFile.h" 13 | #include "HAL/PlatformFilemanager.h" 14 | 15 | UDownloadHelper::UDownloadHelper(const FObjectInitializer & PCIP) 16 | : Super(PCIP) 17 | { 18 | } 19 | 20 | void UDownloadHelper::StartByMemory(const FString& _Url) 21 | { 22 | this->Start(_Url, false); 23 | } 24 | 25 | void UDownloadHelper::StartByDisk(const FString& _Url, const FString& _SaveFilePath) 26 | { 27 | this->Start(_Url, true, _SaveFilePath); 28 | } 29 | 30 | void UDownloadHelper::Start(const FString& _Url, bool bCacheFromDisk, const FString& _SaveFilePath) 31 | { 32 | this->Url = _Url; 33 | this->SaveFilePath = _SaveFilePath; 34 | this->bIsCacheToMemory = !bCacheFromDisk; 35 | 36 | this->Clear(); 37 | 38 | TSharedRef req = UNetAPI::createRequest(Url, TEXT("HEAD")); 39 | 40 | req->OnHeaderReceived().BindLambda([this]( FHttpRequestPtr Request, 41 | const FString& HeaderName, 42 | const FString& NewHeaderValue ) 43 | { 44 | UE_LOG(LogTemp, Log, TEXT("OnHeaderReceived... %s %s"), *HeaderName, *NewHeaderValue); 45 | if ( HeaderName == TEXT("Content-Length") ) 46 | { 47 | ContentLength = FCString::Atoi(*NewHeaderValue); 48 | } 49 | int i = 0; 50 | }); 51 | 52 | req->OnProcessRequestComplete().BindLambda([this]( FHttpRequestPtr Request , 53 | FHttpResponsePtr Response , 54 | bool bConnectedSuccessfully ) 55 | { 56 | if ( bConnectedSuccessfully && 57 | Response->GetResponseCode() == 200 ) 58 | { 59 | this->Downloading(); 60 | } 61 | }); 62 | 63 | req->ProcessRequest(); 64 | } 65 | 66 | TArray64& UDownloadHelper::GetRawData() 67 | { 68 | return this->rawData; 69 | } 70 | 71 | //uint8* p_temp; 72 | void UDownloadHelper::Downloading() 73 | { 74 | if (this->bIsCacheToMemory) 75 | { 76 | rawData.Empty(); 77 | rawData.SetNum(this->ContentLength); 78 | } 79 | else 80 | { 81 | if ( FPaths::FileExists( this->SaveFilePath) ) 82 | { 83 | 84 | FPlatformFileManager::Get().GetPlatformFile().DeleteFile(*this->SaveFilePath); 85 | } 86 | 87 | uint8 temp_data = 0; 88 | 89 | FArchive* FileWriter = IFileManager::Get().CreateFileWriter(*this->SaveFilePath, EFileWrite::FILEWRITE_Append); 90 | 91 | FileWriter->Seek(this->ContentLength - 1L); 92 | //FileWriter->see 93 | FileWriter->Serialize(&temp_data, 1L); 94 | 95 | FileWriter->Close(); 96 | } 97 | 98 | ReqStack.Empty(); 99 | int32 MaxReq = ( ContentLength / MaxOnceRequestRange + ( ContentLength % MaxOnceRequestRange == 0 ? 0 : 1 ) ); 100 | 101 | // Assign Ranges 102 | for (int i = 0; i < MaxReq; i++) 103 | { 104 | FQHttpRanges HttpRange; 105 | HttpRange.RangeStart = this->MaxOnceRequestRange * i; 106 | 107 | if ( i == MaxReq - 1 ) 108 | { 109 | HttpRange.RangeEnd = this->MaxOnceRequestRange * i + ContentLength % this->MaxOnceRequestRange; 110 | } 111 | else 112 | { 113 | HttpRange.RangeEnd = this->MaxOnceRequestRange * ( i + 1UL ) - 1UL; 114 | } 115 | 116 | this->ReqStack.Add(HttpRange); 117 | } 118 | 119 | while(IsRequestable()) 120 | { 121 | this->ReqRange(); 122 | } 123 | } 124 | 125 | bool UDownloadHelper::IsRequestable() const 126 | { 127 | return ( this->MaxRequestNum > this->HttpRangeProcessor.Num() && this->ReqStack.Num() > 0 ); 128 | } 129 | 130 | void UDownloadHelper::Clear() 131 | { 132 | this->ContentLength = 0L; 133 | this->ReceivedContentLength = 0L; 134 | this->SentContentLength = 0L; 135 | 136 | this->ReqStack.Empty(); 137 | this->HttpRangeProcessor.Empty(); 138 | this->HttpRangeErrorProcessor.Empty(); 139 | } 140 | 141 | void UDownloadHelper::ReqRange() 142 | { 143 | FQHttpRanges&& HttpRange = ReqStack.Pop(); 144 | URangeDownloadAsyncProcessor* processor = URangeDownloadAsyncProcessor::Create(this, Url, HttpRange.RangeStart, HttpRange.RangeEnd); 145 | 146 | this->HttpRangeProcessor.Add(processor); 147 | processor->OnRangeCompleted().AddUObject(this, &UDownloadHelper::HandleOnRangeCompleted); 148 | processor->OnRangeProgress().AddUObject(this, &UDownloadHelper::HandleOnRangeProgress); 149 | 150 | processor->Start(); 151 | } 152 | 153 | void UDownloadHelper::HandleOnRangeCompleted(URangeDownloadAsyncProcessor* Processor, bool bSuccessful, const FString& message, FHttpRequestPtr Request, FHttpResponsePtr Response) 154 | { 155 | this->HttpRangeProcessor.Remove(Processor); 156 | 157 | if (!bSuccessful) 158 | { 159 | this->HttpRangeErrorProcessor.Add(Processor); 160 | } 161 | 162 | if (this->ReqStack.Num() > 0) 163 | { 164 | ReqRange(); 165 | } 166 | else 167 | { 168 | if ( this->HttpRangeProcessor.Num() == 0 && 169 | this->HttpRangeErrorProcessor.Num() <= 0 ) 170 | { 171 | bool bHandleResult = this->HttpRangeErrorProcessor.Num() == 0; 172 | this->OnDownloadCompleted().Broadcast(this, bHandleResult, TEXT("Success") ); 173 | } 174 | else 175 | { 176 | UE_LOG(LogTemp, Log, TEXT("################################ Error reqeust num: %d"), this->HttpRangeErrorProcessor.Num()); 177 | } 178 | } 179 | } 180 | 181 | void UDownloadHelper::HandleOnRangeProgress(URangeDownloadAsyncProcessor* Processor, int32 BytesSent, int32 BytesReceived, int32 NewSent, int32 NewReceived) 182 | { 183 | ReceivedContentLength += NewReceived; 184 | SentContentLength += NewSent; 185 | 186 | FQHttpProgress Progress; 187 | Progress.NewSent = NewSent; 188 | Progress.NewReceive = NewReceived; 189 | Progress.ReceiveProgress = ReceivedContentLength / (float)this->ContentLength; 190 | Progress.SentProgress = SentContentLength / (float)this->ContentLength; 191 | 192 | UE_LOG(LogTemp, Log, TEXT("RangeProgress: ReceiveProgress:{%f}. new Receive: {%d} | SentProgress:{%f}, New Sent:{%d} "), Progress.ReceiveProgress, 193 | Progress.NewReceive, 194 | Progress.SentProgress, 195 | Progress.NewSent); 196 | 197 | this->OnDownloadProgress().Broadcast(this, Progress); 198 | } 199 | 200 | URangeDownloadAsyncProcessor* URangeDownloadAsyncProcessor::Create(UDownloadHelper* WorldCTX, const FString &Url, int64 from, int64 to) 201 | { 202 | URangeDownloadAsyncProcessor* ret_obj = NewObject(WorldCTX, NAME_None, RF_Transient); 203 | 204 | ret_obj->CTX = WorldCTX; 205 | ret_obj->Url = Url; 206 | ret_obj->RangeStart = from; 207 | ret_obj->RangeEnd = to; 208 | 209 | return ret_obj; 210 | } 211 | 212 | void URangeDownloadAsyncProcessor::Start() 213 | { 214 | TSharedRef req = UNetAPI::createRequestRange(Url,this->CTX->rawData.Num(), this->RangeStart, this->RangeEnd); 215 | 216 | req->OnProcessRequestComplete().BindUObject(this, &URangeDownloadAsyncProcessor::HandleRequestCompleted); 217 | req->OnRequestProgress().BindUObject(this, &URangeDownloadAsyncProcessor::HandleRequestProgress); 218 | 219 | if ( req->ProcessRequest() ) 220 | { 221 | } 222 | } 223 | 224 | void URangeDownloadAsyncProcessor::HandleRequestCompleted( FHttpRequestPtr Request, 225 | FHttpResponsePtr Response, 226 | bool bConnectedSuccessfully ) 227 | { 228 | if ( bConnectedSuccessfully && 229 | Response->GetResponseCode() == 206 ) 230 | { 231 | TArray NewRawData = Response->GetContent(); 232 | 233 | if (CTX->bIsCacheToMemory) 234 | { 235 | // update memory data 236 | uint8* pData = CTX->rawData.GetData(); 237 | FMemory::Memcpy( (pData + this->RangeStart), NewRawData.GetData(), NewRawData.Num()); 238 | } 239 | else 240 | { 241 | FArchive* FileWriter = nullptr; 242 | int i = 0; 243 | do 244 | { 245 | //防止 IO 堵塞 246 | if (i > 0) 247 | { 248 | 249 | FPlatformProcess::Sleep(0.01f); 250 | } 251 | FileWriter = IFileManager::Get().CreateFileWriter(*this->CTX->SaveFilePath, EFileWrite::FILEWRITE_Append | EFileOpenFlags::IO_WRITE); 252 | i++; 253 | } 254 | while (FileWriter == nullptr); 255 | 256 | FileWriter->Seek(this->RangeStart); 257 | FileWriter->Serialize(NewRawData.GetData(), NewRawData.Num()); 258 | FileWriter->Close(); 259 | } 260 | 261 | this->OnRangeCompleted().Broadcast(this, true, TEXT("Success"), Request, Response); 262 | } 263 | else 264 | { 265 | UE_LOG(LogTemp, Log, TEXT("#####################################---------- error...")); 266 | //this->OnRangeCompleted().Broadcast(this, false, TEXT("Error"), Request, Response); 267 | } 268 | } 269 | 270 | 271 | void URangeDownloadAsyncProcessor::HandleRequestProgress( FHttpRequestPtr Request, 272 | int32 BytesSent, 273 | int32 BytesReceived ) 274 | { 275 | int64 NewReceived = BytesReceived - previousReceviced; 276 | int32 NewSent = BytesSent - previousSent; 277 | this->previousSent = previousSent; 278 | this->previousReceviced = BytesReceived; 279 | 280 | this->OnRangeProgress().Broadcast(this, BytesSent, BytesReceived, NewSent, NewReceived); 281 | } 282 | -------------------------------------------------------------------------------- /Source/QCorePlugin/Helper/DownloadHelper.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "UObject/NoExportTypes.h" 7 | #include "Interfaces/IHttpRequest.h" 8 | #include "DownloadHelper.generated.h" 9 | 10 | 11 | USTRUCT() 12 | struct FQHttpRanges 13 | { 14 | GENERATED_USTRUCT_BODY() 15 | public: 16 | UPROPERTY() 17 | int64 RangeStart ; 18 | 19 | UPROPERTY() 20 | int64 RangeEnd; 21 | 22 | }; 23 | 24 | 25 | USTRUCT() 26 | struct FQHttpProgress 27 | { 28 | GENERATED_USTRUCT_BODY() 29 | public: 30 | UPROPERTY() 31 | /** 上传进度0.0-1.0 */ 32 | float SentProgress; 33 | 34 | UPROPERTY() 35 | /** 下载进度0.0-1.0 */ 36 | float ReceiveProgress; 37 | 38 | UPROPERTY() 39 | /** 新发送数据量 */ 40 | int32 NewSent; 41 | 42 | UPROPERTY() 43 | /** 新接收数据量 */ 44 | int32 NewReceive; 45 | 46 | }; 47 | 48 | class URangeDownloadAsyncProcessor; 49 | /** 50 | * 下载帮助器 51 | */ 52 | UCLASS(BlueprintType) 53 | class QCOREPLUGIN_API UDownloadHelper : public UObject 54 | { 55 | GENERATED_UCLASS_BODY() 56 | public: 57 | friend URangeDownloadAsyncProcessor; 58 | public: 59 | UFUNCTION(BlueprintCallable, Category = "QCore | DownloadHelper ") 60 | void StartByMemory(const FString &_Url); 61 | 62 | UFUNCTION(BlueprintCallable, Category = "QCore | DownloadHelper ") 63 | void StartByDisk( const FString& _Url, const FString &_SaveFilePath ); 64 | 65 | UFUNCTION(BlueprintCallable, Category = "QCore | DownloadHelper ") 66 | void Start(const FString& _Url, bool bCacheFromDisk = false, const FString &_SaveFilePath = TEXT("") ); 67 | 68 | public: 69 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = " QCore | DownloadHelper ") 70 | FString Url; 71 | 72 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = " QCore | DownloadHelper ") 73 | FString SaveFilePath; 74 | 75 | TArray64& GetRawData(); 76 | protected: 77 | /** */ 78 | void Downloading(); 79 | 80 | 81 | bool IsRequestable() const; 82 | 83 | void Clear() ; 84 | 85 | /** */ 86 | void ReqRange(); 87 | 88 | /** */ 89 | void HandleOnRangeCompleted( URangeDownloadAsyncProcessor* Processor , 90 | bool bSuccessful, 91 | const FString&message, 92 | FHttpRequestPtr Request, 93 | FHttpResponsePtr Response 94 | ); 95 | 96 | void HandleOnRangeProgress( 97 | URangeDownloadAsyncProcessor* Processor, 98 | int32 BytesSent, 99 | int32 BytesReceived, 100 | int32 NewSent, 101 | int32 NewReceived 102 | ); 103 | 104 | protected: 105 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = " QCore | DownloadHelper ") 106 | /** */ 107 | bool bIsCacheToMemory = true; 108 | 109 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = " QCore | DownloadHelper ") 110 | /** */ 111 | int MaxRequestNum = 15; 112 | 113 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = " QCore | DownloadHelper ") 114 | /** */ 115 | int MaxOnceRequestRange = 1024 * 256 ; 116 | 117 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = " QCore | DownloadHelper ") 118 | /** */ 119 | int64 ContentLength = 0; 120 | 121 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = " QCore | DownloadHelper ") 122 | /** 已接收(下载)内容长度 */ 123 | int64 ReceivedContentLength = 0; 124 | 125 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = " QCore | DownloadHelper ") 126 | /** 已发送(上传)内容 */ 127 | int64 SentContentLength = 0; 128 | 129 | /** */ 130 | TArray HttpRangeProcessor; 131 | 132 | /** */ 133 | TArray HttpRangeErrorProcessor; 134 | 135 | /** */ 136 | TArray64 rawData; 137 | 138 | /** 待请求分段 */ 139 | TArray ReqStack; 140 | 141 | #pragma region Delegate Event 142 | public: 143 | DECLARE_EVENT_ThreeParams( FString, FEvent_OnDownloadCompleted, UDownloadHelper* /** target*/ , 144 | bool /* bSuccessful */ , 145 | const FString & /* message */ ) 146 | FEvent_OnDownloadCompleted& OnDownloadCompleted() 147 | { 148 | return Event_OnDownloadCompleted; 149 | } 150 | 151 | 152 | protected: 153 | FEvent_OnDownloadCompleted Event_OnDownloadCompleted; 154 | 155 | public: 156 | DECLARE_EVENT_TwoParams( FString, FEvent_OnDownloadProgress, UDownloadHelper* /* target */, 157 | const FQHttpProgress & /* data*/ 158 | ) 159 | 160 | FEvent_OnDownloadProgress& OnDownloadProgress() 161 | { 162 | return Event_OnDownloadProgress; 163 | } 164 | 165 | protected: 166 | FEvent_OnDownloadProgress Event_OnDownloadProgress; 167 | 168 | #pragma endregion 169 | 170 | }; 171 | 172 | 173 | UCLASS() 174 | class QCOREPLUGIN_API URangeDownloadAsyncProcessor : public UObject 175 | { 176 | GENERATED_BODY() 177 | public: 178 | //friend UDownloadHelper; 179 | /** */ 180 | static URangeDownloadAsyncProcessor* Create(UDownloadHelper* WorldCTX, const FString& Url, int64 from, int64 to); 181 | // static URangeDownloadAsyncProcessor 182 | public: 183 | UFUNCTION() 184 | void Start(); 185 | 186 | protected: 187 | void HandleRequestCompleted( FHttpRequestPtr Request, 188 | FHttpResponsePtr Response, 189 | bool bConnectedSuccessfully ); 190 | 191 | void HandleRequestProgress( FHttpRequestPtr Request, 192 | int32 BytesSent, 193 | int32 BytesReceived 194 | ); 195 | 196 | #pragma region Delegate Event 197 | public: 198 | DECLARE_EVENT_FiveParams(FString, FEvent_OnRangeCompleted, URangeDownloadAsyncProcessor*, 199 | bool /*bSuccessful*/ , 200 | const FString& /*message*/ , 201 | FHttpRequestPtr /*Request*/ , 202 | FHttpResponsePtr /*Response*/ 203 | ) 204 | FEvent_OnRangeCompleted& OnRangeCompleted() 205 | { 206 | return Event_OnRangeCompleted; 207 | } 208 | 209 | protected: 210 | FEvent_OnRangeCompleted Event_OnRangeCompleted; 211 | 212 | public: 213 | 214 | DECLARE_EVENT_FiveParams( FString, FEvent_OnRangeProgress, URangeDownloadAsyncProcessor* /** Processor */ , 215 | int32 /** BytesSent */ , 216 | int32 /** BytesReceived */ , 217 | int32 /** NewSent */ , 218 | int32 /** NewReceived */ 219 | ) 220 | FEvent_OnRangeProgress& OnRangeProgress() 221 | { 222 | return Event_OnRangeProgress; 223 | } 224 | 225 | protected: 226 | FEvent_OnRangeProgress Event_OnRangeProgress; 227 | #pragma endregion Delegate Event 228 | protected: 229 | int64 RangeStart; 230 | int64 RangeEnd; 231 | UDownloadHelper* CTX; 232 | FString Url; 233 | int64 previousReceviced = 0; 234 | int64 previousSent = 0; 235 | }; 236 | -------------------------------------------------------------------------------- /Source/QCorePlugin/Helper/ImageHelper.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "UObject/NoExportTypes.h" 7 | #include "IImageWrapper.h" 8 | 9 | #include "Interfaces/IHttpRequest.h" 10 | #include "ImageHelper.generated.h" 11 | 12 | 13 | class UTexture2D; 14 | class UTexture2DDynamic; 15 | /** 16 | * 17 | */ 18 | UCLASS() 19 | class QCOREPLUGIN_API UImageHelper : public UObject 20 | { 21 | GENERATED_UCLASS_BODY() 22 | 23 | public: 24 | /** */ 25 | void LoadFormURL(const FString &Url, bool bAutoGenerateMips = true, bool bForceGenerateMips = false); 26 | 27 | /** */ 28 | void LoadFormURL(const FString &Url, UObject *target, void(UObject::* bindfunc)(bool, UTexture2D *), bool bAutoGenerateMips = true, bool bForceGenerateMips = false); 29 | 30 | /** */ 31 | void LoadFormURL(const FString &Url, void(bindfunc)(bool, UTexture2D *), bool bAutoGenerateMips = true, bool bForceGenerateMips = false); 32 | 33 | static UTexture2D * LoadFromDisk(const FString &Path, bool bAutoGenerateMips = true, bool bForceGenerateMips = false); 34 | 35 | 36 | public: 37 | bool bLoading = false; 38 | #pragma region Delegate Event 39 | 40 | public: 41 | 42 | DECLARE_EVENT_TwoParams(FString, FOnLoadCompleted, bool,UTexture2D*); 43 | FOnLoadCompleted& OnLoadCompleted() 44 | { 45 | return Event_OnLoadCompleted; 46 | } 47 | protected: 48 | FOnLoadCompleted Event_OnLoadCompleted; 49 | 50 | 51 | public: 52 | DECLARE_EVENT_OneParam(FString, FOnLoadProgress, float) 53 | FOnLoadProgress& OnLoadProgress() 54 | { 55 | return Event_OnLoadProgress; 56 | } 57 | 58 | protected: 59 | FOnLoadProgress Event_OnLoadProgress; 60 | 61 | #pragma endregion 62 | 63 | public: 64 | static UTexture2DDynamic* ConvertTexture2DToTexture2DDynamic(UTexture2D *target); 65 | static UTexture2D* ConvertTexture2DDynamicToTexture2D(UTexture2DDynamic *target); 66 | }; 67 | 68 | /** 图片异步处理 */ 69 | UCLASS() 70 | class QCOREPLUGIN_API UImageAsyncProcessor : public UObject 71 | { 72 | GENERATED_BODY() 73 | 74 | 75 | public: 76 | /** */ 77 | static UImageAsyncProcessor * CreataFactory(bool bAutoGenerateMips = true, bool bForceGenerateMips = false); 78 | /** */ 79 | void Http_HandleCompleted(FHttpRequestPtr Req, FHttpResponsePtr Res, bool bConnectedSuccessfully); 80 | 81 | void Http_Progress(FHttpRequestPtr Request, int32 BytesSent, int32 BytesReceived); 82 | #pragma region Delegate Event 83 | public: 84 | 85 | DECLARE_EVENT_TwoParams(FString, FEvent_OnLoadCompleted, bool, UTexture2D*); 86 | FEvent_OnLoadCompleted& OnLoadCompleted() 87 | { 88 | return Event_OnLoadCompleted; 89 | } 90 | 91 | 92 | DECLARE_EVENT_OneParam(FString, FEvent_OnLoadProgress, float); 93 | FEvent_OnLoadProgress& OnLoadProgress() 94 | { 95 | return Event_OnLoadProgress; 96 | } 97 | 98 | 99 | protected: 100 | FEvent_OnLoadCompleted Event_OnLoadCompleted; 101 | FEvent_OnLoadProgress Event_OnLoadProgress; 102 | #pragma endregion 103 | 104 | private: 105 | bool bAutoGenerateMips = true; 106 | bool bForceGenerateMips = false; 107 | }; -------------------------------------------------------------------------------- /Source/QCorePlugin/Helper/NamedPipeHelper.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "NamedPipeHelper.h" 5 | 6 | UNamedPipeHelper::UNamedPipeHelper() 7 | { 8 | this->AddToRoot(); 9 | } 10 | 11 | UNamedPipeHelper * UNamedPipeHelper::CreateNamedPipeHelper(const FString& PipeName, bool bServer, bool bAsync) 12 | { 13 | UNamedPipeHelper * Obj = NewObject(); 14 | 15 | if (Obj == nullptr || !Obj->IsValidLowLevel()) 16 | { 17 | return nullptr; 18 | } 19 | 20 | Obj->PipeName = PipeName; 21 | Obj->bServer = bServer; 22 | Obj->bAsync = bAsync; 23 | 24 | return Obj; 25 | } 26 | 27 | FPlatformNamedPipe * UNamedPipeHelper::GetNamedPipe() 28 | { 29 | //static bCreate 30 | if (!NamedPipe.IsCreated()) 31 | { 32 | bool isSuccess = NamedPipe.Create(this->PipeName, bServer, bAsync); 33 | 34 | if (!isSuccess) 35 | { 36 | return nullptr; 37 | } 38 | } 39 | 40 | return &NamedPipe; 41 | } 42 | 43 | -------------------------------------------------------------------------------- /Source/QCorePlugin/Helper/NamedPipeHelper.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "UObject/Object.h" 7 | #include "HAL/PlatformNamedPipe.h" 8 | 9 | #include "NamedPipeHelper.generated.h" 10 | /** 11 | * 12 | */ 13 | UCLASS(ABSTRACT) 14 | class QCOREPLUGIN_API UNamedPipeHelper: public UObject 15 | { 16 | GENERATED_BODY() 17 | protected: 18 | /** */ 19 | UNamedPipeHelper(); 20 | 21 | public: 22 | static UNamedPipeHelper* CreateNamedPipeHelper( const FString& PipeName = TEXT("\\\\.\\my_pipe"), 23 | bool bServer = false, 24 | bool bAsync = true ); 25 | 26 | /** 返回pipe管线 */ 27 | FPlatformNamedPipe* GetNamedPipe(); 28 | 29 | protected: 30 | 31 | /** */ 32 | FPlatformNamedPipe NamedPipe; 33 | 34 | FString PipeName; 35 | bool bServer = false; 36 | bool bAsync = true; 37 | }; 38 | -------------------------------------------------------------------------------- /Source/QCorePlugin/QCorePlugin.Build.cs: -------------------------------------------------------------------------------- 1 | // Some copyright should be here... 2 | 3 | using System; 4 | using System.IO; 5 | using UnrealBuildTool; 6 | 7 | public class QCorePlugin : ModuleRules 8 | { 9 | 10 | static private bool IsShipping(ReadOnlyTargetRules Target) 11 | { 12 | return Target.Configuration == UnrealTargetConfiguration.Shipping; 13 | } 14 | 15 | public QCorePlugin(ReadOnlyTargetRules Target) : base(Target) 16 | { 17 | 18 | 19 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 20 | 21 | PublicIncludePaths.Add(Path.GetFullPath(ModuleDirectory)); 22 | 23 | PublicIncludePaths.AddRange( 24 | new string[] { 25 | // ... add public include paths required here ... 26 | } 27 | ); 28 | 29 | 30 | PrivateIncludePaths.AddRange( 31 | new string[] { 32 | // ... add other private include paths required here ... 33 | } 34 | ); 35 | 36 | 37 | PublicDependencyModuleNames.AddRange( 38 | new string[] 39 | { 40 | "Core" , 41 | "CoreUObject" , 42 | "Engine" , 43 | "InputCore" , 44 | "RHI" , 45 | "RenderCore" , 46 | "Slate" , 47 | "SlateCore" , 48 | "HTTP" , 49 | "UMG" , 50 | "AIModule" , 51 | "ImageWrapper" , 52 | "Json" , 53 | "JsonUtilities" , 54 | "Sockets" , 55 | "Networking" , 56 | "IPC" , 57 | // ... add other public dependencies that you statically link with here ... 58 | "QUMG", 59 | "QRender" 60 | } 61 | ); 62 | 63 | 64 | PrivateDependencyModuleNames.AddRange( 65 | new string[] 66 | { 67 | 68 | // web plugin 69 | "WebBrowser" , 70 | "WebBrowserWidget" , 71 | 72 | // custom modules 73 | 74 | // ... add private dependencies that you statically link with here ... 75 | } 76 | ); 77 | 78 | if (IsShipping(Target)) 79 | { 80 | PrivateDependencyModuleNames.Add("QDesktopPlatform"); 81 | } 82 | else 83 | { 84 | PrivateDependencyModuleNames.Add("DesktopPlatform"); 85 | } 86 | 87 | //WebBrowser Dependency 88 | if (Target.Type == TargetRules.TargetType.Editor) 89 | { 90 | PrivateDependencyModuleNames.AddRange( 91 | new string[] 92 | { 93 | "UnrealEd" 94 | } 95 | ); 96 | } 97 | PublicDefinitions.Add("WIN32_LEAN_AND_MEAN"); 98 | 99 | DynamicallyLoadedModuleNames.AddRange( 100 | new string[] 101 | { 102 | // ... add any modules that your module loads dynamically here ... 103 | "AssetRegistry" 104 | } 105 | ); 106 | 107 | OptimizeCode = CodeOptimization.InShippingBuildsOnly; 108 | 109 | //PrivateIncludePathModuleNames.Add("TargetPlatform"); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /Source/QCorePlugin/QCorePlugin.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "QCorePlugin.h" 4 | 5 | #define LOCTEXT_NAMESPACE "FQCorePluginModule" 6 | 7 | 8 | 9 | void FQCorePluginModule::StartupModule() 10 | { 11 | // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module 12 | 13 | } 14 | 15 | void FQCorePluginModule::ShutdownModule() 16 | { 17 | // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, 18 | // we call this function before unloading the module. 19 | } 20 | 21 | #undef LOCTEXT_NAMESPACE 22 | 23 | IMPLEMENT_MODULE(FQCorePluginModule, QCorePlugin) 24 | -------------------------------------------------------------------------------- /Source/QCorePlugin/QCorePlugin.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "Modules/ModuleManager.h" 6 | 7 | class FQCorePluginModule : public IModuleInterface 8 | { 9 | public: 10 | 11 | /** IModuleInterface implementation */ 12 | virtual void StartupModule() override; 13 | virtual void ShutdownModule() override; 14 | }; 15 | -------------------------------------------------------------------------------- /Source/QCorePlugin/Utils/HACK_PRIVATE_MEMBER_UTILS.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************/ 2 | /* 私有变量访问帮助宏,(快速绑定友元类) */ 3 | /************************************************************************/ 4 | 5 | // #include 6 | // using namespace std; 7 | namespace Hacker 8 | { 9 | template 10 | struct PrivateMemberStealer 11 | { 12 | // define friend funtion GetPrivate,return class member pointer 13 | friend typename Tag::MemType GetPrivate(Tag) { return M; } 14 | }; 15 | } 16 | #define DECL_HACK_PRIVATE_DATA(ClassName,DataType,DataName) namespace Hacker{\ 17 | struct ClassName##_##DataName\ 18 | {\ 19 | typedef DataType ClassName::*MemType;\ 20 | friend MemType GetPrivate(ClassName##_##DataName);\ 21 | };\ 22 | template struct PrivateMemberStealer;\ 23 | } 24 | #define GET_VAR_PRIVATE_DATA_MEMBER(ClassInstancePointer,ClassName,DataName) ClassInstancePointer->*GetPrivate(::Hacker::ClassName##_##DataName()) 25 | #define GET_REF_PRIVATE_DATA_MEMBER(RefName,ClassInstancePointer,ClassName,DataName) auto& RefName = ClassInstancePointer->*GetPrivate(::Hacker::ClassName##_##DataName()) 26 | 27 | 28 | #define DECL_HACK_PRIVATE_NOCONST_FUNCTION(ClassName,MemberName,ReturnType,...) \ 29 | namespace Hacker{\ 30 | struct ClassName##_##MemberName \ 31 | {\ 32 | typedef ReturnType (ClassName::*MemType)(__VA_ARGS__);\ 33 | friend MemType GetPrivate(ClassName##_##MemberName);\ 34 | };\ 35 | template struct PrivateMemberStealer;\ 36 | } 37 | #define DECL_HACK_PRIVATE_CONST_FUNCTION(ClassName,MemberName,ReturnType,...) \ 38 | namespace Hacker{\ 39 | struct ClassName##_##MemberName \ 40 | {\ 41 | typedef ReturnType (ClassName::*MemType)(__VA_ARGS__)const;\ 42 | friend MemType GetPrivate(ClassName##_##MemberName);\ 43 | };\ 44 | template struct PrivateMemberStealer;\ 45 | } 46 | 47 | // using ADL found to ::Hacker::Getprivate 48 | #define GET_PRIVATE_MEMBER_FUNCTION(ClassName,MemberName) GetPrivate(::Hacker::ClassName##_##MemberName()) 49 | #define CALL_MEMBER_FUNCTION(ClassPointer,MemberFuncPointer,...) (ClassPointer->*MemberFuncPointer)(__VA_ARGS__) 50 | 51 | #define WRAP_TEMPLATE_ARGS(TEMP_TYPE,...) TEMP_TYPE<__VA_ARGS__> 52 | 53 | 54 | #pragma region exam 55 | // class A{ 56 | // public: 57 | // A(int ivalp=0):ival{ivalp}{} 58 | // private: 59 | // int func(int ival)const 60 | // { 61 | // printf("A::func(int)\t%d\n",ival); 62 | // printf("ival is %d\n",ival); 63 | // return 0; 64 | // } 65 | // int ival; 66 | // }; 67 | 68 | // DECL_HACK_PRIVATE_DATA(A,int,ival) 69 | // DECL_HACK_PRIVATE_CONST_FUNCTION(A, func, int, int) 70 | 71 | // int main() 72 | // { 73 | // A aobj(789); 74 | // // get private data member 75 | // GET_REF_PRIVATE_DATA_MEMBER(ref_ival, &aobj, A, ival); 76 | // ref_ival=456; 77 | // cout< &OutInstallations) override; 25 | virtual void EnumerateLauncherSampleInstallations(TArray &OutInstallations) override; 26 | virtual void EnumerateLauncherSampleProjects(TArray &OutFileNames) override; 27 | virtual bool GetEngineRootDirFromIdentifier(const FString &Identifier, FString &OutRootDir) override; 28 | virtual bool GetEngineIdentifierFromRootDir(const FString &RootDir, FString &OutIdentifier) override; 29 | 30 | virtual bool GetDefaultEngineIdentifier(FString &OutIdentifier) override; 31 | virtual bool GetDefaultEngineRootDir(FString &OutRootDir) override; 32 | virtual FString GetEngineSavedConfigDirectory(const FString& Identifier) override; 33 | virtual bool IsPreferredEngineIdentifier(const FString &Identifier, const FString &OtherIdentifier) override; 34 | 35 | virtual bool TryGetEngineVersion(const FString& RootDir, FEngineVersion& OutVersion) override; 36 | virtual bool IsStockEngineRelease(const FString &Identifier) override; 37 | virtual bool TryParseStockEngineVersion(const FString& Identifier, FEngineVersion& OutVersion) override; 38 | virtual bool IsSourceDistribution(const FString &RootDir) override; 39 | virtual bool IsPerforceBuild(const FString &RootDir) override; 40 | virtual bool IsValidRootDirectory(const FString &RootDir) override; 41 | 42 | virtual bool SetEngineIdentifierForProject(const FString &ProjectFileName, const FString &Identifier) override; 43 | virtual bool GetEngineIdentifierForProject(const FString &ProjectFileName, FString &OutIdentifier) override; 44 | 45 | virtual bool OpenProject(const FString& ProjectFileName) override; 46 | 47 | virtual bool CleanGameProject(const FString& ProjectDir, FString& OutFailPath, FFeedbackContext* Warn) override; 48 | virtual bool CompileGameProject(const FString& RootDir, const FString& ProjectFileName, FFeedbackContext* Warn) override; 49 | virtual bool GenerateProjectFiles(const FString& RootDir, const FString& ProjectFileName, FFeedbackContext* Warn, FString LogFilePath = FString()) override; 50 | virtual bool IsUnrealBuildToolAvailable() override; 51 | virtual bool InvokeUnrealBuildToolSync(const FString& InCmdLineParams, FOutputDevice &Ar, bool bSkipBuildUBT, int32& OutReturnCode, FString& OutProcOutput) override; 52 | virtual FProcHandle InvokeUnrealBuildToolAsync(const FString& InCmdLineParams, FOutputDevice &Ar, void*& OutReadPipe, void*& OutWritePipe, bool bSkipBuildUBT = false) override; 53 | 54 | virtual const TArray& GetTargetsForProject(const FString& ProjectFile) const override; 55 | virtual const TArray& GetTargetsForCurrentProject() const override; 56 | 57 | virtual bool GetSolutionPath(FString& OutSolutionPath) override; 58 | 59 | virtual bool EnumerateProjectsKnownByEngine(const FString &Identifier, bool bIncludeNativeProjects, TArray &OutProjectFileNames) override; 60 | virtual FString GetDefaultProjectCreationPath() override; 61 | 62 | private: 63 | FString CurrentEngineIdentifier; 64 | FDateTime LauncherInstallationTimestamp; 65 | TMap LauncherInstallationList; 66 | TMap CachedProjectDictionaries; 67 | mutable TMap> ProjectFileToTargets; 68 | 69 | void ReadLauncherInstallationList(); 70 | void CheckForLauncherEngineInstallation(const FString &AppId, const FString &Identifier, TMap &OutInstallations); 71 | int32 ParseReleaseVersion(const FString &Version); 72 | 73 | TSharedPtr LoadProjectFile(const FString &FileName); 74 | bool SaveProjectFile(const FString &FileName, TSharedPtr Object); 75 | 76 | const FUProjectDictionary &GetCachedProjectDictionary(const FString& RootDir); 77 | 78 | void GetProjectBuildProducts(const FString& ProjectFileName, TArray &OutFileNames, TArray &OutDirectoryNames); 79 | bool BuildUnrealBuildTool(const FString& RootDir, FOutputDevice &Ar); 80 | 81 | static bool ReadTargetInfo(const FString& FileName, TArray& Targets); 82 | 83 | protected: 84 | 85 | FString GetUnrealBuildToolProjectFileName(const FString& RootDir) const; 86 | FString GetUnrealBuildToolExecutableFilename(const FString& RootDir) const; 87 | }; 88 | 89 | PRAGMA_ENABLE_DEPRECATION_WARNINGS 90 | -------------------------------------------------------------------------------- /Source/QDesktopPlatform/Private/DesktopPlatformPrivate.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | #if PLATFORM_WINDOWS 8 | #include "Windows/DesktopPlatformWindows.h" 9 | #elif PLATFORM_MAC 10 | #include "Mac/DesktopPlatformMac.h" 11 | #elif PLATFORM_LINUX 12 | #include "Linux/DesktopPlatformLinux.h" 13 | #else 14 | #include "DesktopPlatformStub.h" 15 | #endif 16 | 17 | DECLARE_LOG_CATEGORY_EXTERN(LogQDesktopPlatform, Log, All); 18 | -------------------------------------------------------------------------------- /Source/QDesktopPlatform/Private/DesktopPlatformStub.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "DesktopPlatformBase.h" 7 | #include "Misc/Paths.h" 8 | 9 | class FDesktopPlatformStub : public FDesktopPlatformBase 10 | { 11 | public: 12 | // IDesktopPlatform Implementation 13 | virtual bool OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames) override { return false; } 14 | virtual bool OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames, int32& OutFilterIndex) override { return false; } 15 | virtual bool SaveFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames) override { return false; } 16 | virtual bool OpenDirectoryDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, FString& OutFolderName) override { return false; } 17 | virtual bool OpenFontDialog(const void* ParentWindowHandle, FString& OutFontName, float& OutHeight, EFontImportFlags& OutFlags) override { return false; } 18 | 19 | virtual bool RegisterEngineInstallation(const FString &RootDir, FString &OutIdentifier) override { return false; } 20 | virtual void EnumerateEngineInstallations(TMap &OutInstallations) override {} 21 | 22 | virtual bool VerifyFileAssociations() override { return false; } 23 | virtual bool UpdateFileAssociations() override { return false; } 24 | 25 | virtual bool RunUnrealBuildTool(const FText& Description, const FString& RootDir, const FString& Arguments, FFeedbackContext* Warn) override { return false; } 26 | virtual bool IsUnrealBuildToolRunning() override { return false; } 27 | 28 | virtual FFeedbackContext* GetNativeFeedbackContext() override { return nullptr; } 29 | 30 | virtual FString GetUserTempPath() override { return FPaths::ProjectIntermediateDir() + TEXT("UserTemp/"); } 31 | }; 32 | 33 | typedef FDesktopPlatformStub FDesktopPlatform; 34 | -------------------------------------------------------------------------------- /Source/QDesktopPlatform/Private/Linux/DesktopPlatformLinux.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "DesktopPlatformBase.h" 7 | 8 | class FDesktopPlatformLinux : public FDesktopPlatformBase 9 | { 10 | public: 11 | // IDesktopPlatform Implementation 12 | virtual bool OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames) override; 13 | virtual bool OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames, int32& OutFilterIndex) override; 14 | virtual bool SaveFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames) override; 15 | virtual bool OpenDirectoryDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, FString& OutFolderName) override; 16 | virtual bool OpenFontDialog(const void* ParentWindowHandle, FString& OutFontName, float& OutHeight, EFontImportFlags& OutFlags) override; 17 | 18 | virtual bool RegisterEngineInstallation(const FString &RootDir, FString &OutIdentifier) override; 19 | virtual void EnumerateEngineInstallations(TMap &OutInstallations) override; 20 | 21 | virtual bool IsSourceDistribution(const FString &RootDir) override; 22 | 23 | virtual bool VerifyFileAssociations() override; 24 | virtual bool UpdateFileAssociations() override; 25 | 26 | virtual bool OpenProject(const FString &ProjectFileName) override; 27 | 28 | virtual bool RunUnrealBuildTool(const FText& Description, const FString& RootDir, const FString& Arguments, FFeedbackContext* Warn) override; 29 | virtual bool IsUnrealBuildToolRunning() override; 30 | 31 | virtual FFeedbackContext* GetNativeFeedbackContext() override; 32 | 33 | virtual FString GetUserTempPath() override; 34 | 35 | FDesktopPlatformLinux(); 36 | virtual ~FDesktopPlatformLinux(); 37 | 38 | private: 39 | bool FileDialogShared(bool bSave, const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames, int32& OutFilterIndex); 40 | }; 41 | 42 | typedef FDesktopPlatformLinux FDesktopPlatform; 43 | -------------------------------------------------------------------------------- /Source/QDesktopPlatform/Private/Mac/DesktopPlatformMac.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "../DesktopPlatformBase.h" 6 | 7 | class FDesktopPlatformMac : public FDesktopPlatformBase 8 | { 9 | public: 10 | // IDesktopPlatform Implementation 11 | virtual bool OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames) override; 12 | virtual bool OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames, int32& OutFilterIndex) override; 13 | virtual bool SaveFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames) override; 14 | virtual bool OpenDirectoryDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, FString& OutFolderName) override; 15 | virtual bool OpenFontDialog(const void* ParentWindowHandle, FString& OutFontName, float& OutHeight, EFontImportFlags& OutFlags) override; 16 | 17 | virtual bool RegisterEngineInstallation(const FString &RootDir, FString &OutIdentifier) override; 18 | virtual void EnumerateEngineInstallations(TMap &OutInstallations) override; 19 | 20 | virtual bool VerifyFileAssociations() override; 21 | virtual bool UpdateFileAssociations() override; 22 | 23 | virtual bool RunUnrealBuildTool(const FText& Description, const FString& RootDir, const FString& Arguments, FFeedbackContext* Warn) override; 24 | virtual bool IsUnrealBuildToolRunning() override; 25 | 26 | virtual FFeedbackContext* GetNativeFeedbackContext() override; 27 | 28 | virtual FString GetUserTempPath() override; 29 | 30 | private: 31 | bool FileDialogShared(bool bSave, const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames, int32& OutFilterIndex); 32 | }; 33 | 34 | typedef FDesktopPlatformMac FDesktopPlatform; 35 | -------------------------------------------------------------------------------- /Source/QDesktopPlatform/Private/Mac/MacNativeFeedbackContext.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Mac/MacSystemIncludes.h" 7 | #include "Misc/FeedbackContext.h" 8 | 9 | @interface FMacNativeFeedbackContextWindowController : NSObject 10 | { 11 | @public 12 | NSTextView* TextView; 13 | @private 14 | NSScrollView* LogView; 15 | NSWindow* Window; 16 | NSTextField* StatusLabel; 17 | NSButton* CancelButton; 18 | NSButton* ShowLogButton; 19 | NSProgressIndicator* ProgressIndicator; 20 | } 21 | -(id)init; 22 | -(void)dealloc; 23 | -(void)setShowProgress:(bool)bShowProgress; 24 | -(void)setShowCancelButton:(bool)bShowCancelButton; 25 | -(void)setTitleText:(NSString*)Title; 26 | -(void)setStatusText:(NSString*)Text; 27 | -(void)setProgress:(double)Progress total:(double)Total; 28 | -(void)showWindow; 29 | -(void)hideWindow; 30 | -(bool)windowOpen; 31 | @end 32 | 33 | /** 34 | * Feedback context implementation for Mac. 35 | */ 36 | class FMacNativeFeedbackContext : public FFeedbackContext 37 | { 38 | public: 39 | // Constructor. 40 | FMacNativeFeedbackContext(); 41 | virtual ~FMacNativeFeedbackContext(); 42 | 43 | virtual void Serialize( const TCHAR* V, ELogVerbosity::Type Verbosity, const class FName& Category ) override; 44 | 45 | virtual bool YesNof(const FText& Text) override; 46 | 47 | virtual bool ReceivedUserCancel() override; 48 | 49 | virtual void StartSlowTask( const FText& Task, bool bShowCancelButton=false ) override; 50 | virtual void FinalizeSlowTask( ) override; 51 | virtual void ProgressReported( const float TotalProgressInterp, FText DisplayMessage ) override; 52 | 53 | FContextSupplier* GetContext() const; 54 | void SetContext( FContextSupplier* InSupplier ); 55 | 56 | private: 57 | void SetDefaultTextColor(); 58 | 59 | private: 60 | /** Critical section for Serialize() */ 61 | FCriticalSection CriticalSection; 62 | FMacNativeFeedbackContextWindowController* WindowController; 63 | NSDictionary* TextViewTextColor; 64 | FContextSupplier* Context; 65 | uint64 OutstandingTasks; 66 | int32 SlowTaskCount; 67 | bool bShowingConsoleForSlowTask; 68 | }; 69 | -------------------------------------------------------------------------------- /Source/QDesktopPlatform/Private/QDesktopPlatformModule.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "QDesktopPlatformModule.h" 4 | #include "DesktopPlatformPrivate.h" 5 | 6 | IMPLEMENT_MODULE(FQDesktopPlatformModule, QDesktopPlatform ); 7 | DEFINE_LOG_CATEGORY(LogQDesktopPlatform); 8 | 9 | void FQDesktopPlatformModule::StartupModule() 10 | { 11 | DesktopPlatform = new FDesktopPlatform(); 12 | } 13 | 14 | void FQDesktopPlatformModule::ShutdownModule() 15 | { 16 | if (DesktopPlatform != NULL) 17 | { 18 | delete DesktopPlatform; 19 | DesktopPlatform = NULL; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/QDesktopPlatform/Private/TargetReceipt.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "TargetReceipt.h" 4 | #include "Misc/Paths.h" 5 | #include "Misc/FileHelper.h" 6 | #include "Dom/JsonObject.h" 7 | #include "Serialization/JsonSerializer.h" 8 | 9 | bool FTargetReceipt::Read(const FString& FileName) 10 | { 11 | // Read the file from disk 12 | FString FileContents; 13 | if (!FFileHelper::LoadFileToString(FileContents, *FileName)) 14 | { 15 | return false; 16 | } 17 | 18 | TSharedPtr Object; 19 | TSharedRef> Reader = TJsonReaderFactory<>::Create(FileContents); 20 | if (!FJsonSerializer::Deserialize(Reader, Object) || !Object.IsValid()) 21 | { 22 | return false; 23 | } 24 | 25 | // Get the project file 26 | FString RelativeProjectFile; 27 | if(Object->TryGetStringField(TEXT("Project"), RelativeProjectFile)) 28 | { 29 | ProjectFile = FPaths::Combine(FPaths::GetPath(FileName), RelativeProjectFile); 30 | FPaths::MakeStandardFilename(ProjectFile); 31 | ProjectDir = FPaths::GetPath(ProjectFile); 32 | } 33 | 34 | // Get the target name 35 | if (!Object->TryGetStringField(TEXT("TargetName"), TargetName)) 36 | { 37 | return false; 38 | } 39 | if (!Object->TryGetStringField(TEXT("Platform"), Platform)) 40 | { 41 | return false; 42 | } 43 | if (!Object->TryGetStringField(TEXT("Architecture"), Architecture)) 44 | { 45 | return false; 46 | } 47 | 48 | // Read the configuration 49 | FString ConfigurationString; 50 | if (!Object->TryGetStringField(TEXT("Configuration"), ConfigurationString) || !LexTryParseString(Configuration, *ConfigurationString)) 51 | { 52 | return false; 53 | } 54 | 55 | // Read the target type 56 | FString TargetTypeString; 57 | if (!Object->TryGetStringField(TEXT("TargetType"), TargetTypeString) || !LexTryParseString(TargetType, *TargetTypeString)) 58 | { 59 | return false; 60 | } 61 | 62 | // Get the launch path 63 | if(!Object->TryGetStringField(TEXT("Launch"), Launch)) 64 | { 65 | return false; 66 | } 67 | ExpandVariables(Launch); 68 | 69 | // Read the list of build products 70 | const TArray>* BuildProductsArray; 71 | if (Object->TryGetArrayField(TEXT("BuildProducts"), BuildProductsArray)) 72 | { 73 | for(const TSharedPtr& BuildProductValue : *BuildProductsArray) 74 | { 75 | const TSharedPtr* BuildProductObject; 76 | if(!BuildProductValue->TryGetObject(BuildProductObject)) 77 | { 78 | return false; 79 | } 80 | 81 | FBuildProduct BuildProduct; 82 | if(!(*BuildProductObject)->TryGetStringField(TEXT("Type"), BuildProduct.Type) || !(*BuildProductObject)->TryGetStringField(TEXT("Path"), BuildProduct.Path)) 83 | { 84 | return false; 85 | } 86 | 87 | ExpandVariables(BuildProduct.Path); 88 | 89 | BuildProducts.Add(MoveTemp(BuildProduct)); 90 | } 91 | } 92 | 93 | // Read the list of runtime dependencies 94 | const TArray>* RuntimeDependenciesArray; 95 | if (Object->TryGetArrayField(TEXT("RuntimeDependencies"), RuntimeDependenciesArray)) 96 | { 97 | for(const TSharedPtr& RuntimeDependencyValue : *RuntimeDependenciesArray) 98 | { 99 | const TSharedPtr* RuntimeDependencyObject; 100 | if(!RuntimeDependencyValue->TryGetObject(RuntimeDependencyObject)) 101 | { 102 | return false; 103 | } 104 | 105 | FRuntimeDependency RuntimeDependency; 106 | if(!(*RuntimeDependencyObject)->TryGetStringField(TEXT("Path"), RuntimeDependency.Path) || !(*RuntimeDependencyObject)->TryGetStringField(TEXT("Type"), RuntimeDependency.Type)) 107 | { 108 | return false; 109 | } 110 | 111 | ExpandVariables(RuntimeDependency.Path); 112 | 113 | RuntimeDependencies.Add(MoveTemp(RuntimeDependency)); 114 | } 115 | } 116 | 117 | // Read the list of additional properties 118 | const TArray>* AdditionalPropertiesArray; 119 | if (Object->TryGetArrayField(TEXT("AdditionalProperties"), AdditionalPropertiesArray)) 120 | { 121 | for(const TSharedPtr& AdditionalPropertyValue : *AdditionalPropertiesArray) 122 | { 123 | const TSharedPtr* AdditionalPropertyObject; 124 | if(!AdditionalPropertyValue->TryGetObject(AdditionalPropertyObject)) 125 | { 126 | return false; 127 | } 128 | 129 | FReceiptProperty Property; 130 | if(!(*AdditionalPropertyObject)->TryGetStringField(TEXT("Name"), Property.Name) || !(*AdditionalPropertyObject)->TryGetStringField(TEXT("Value"), Property.Value)) 131 | { 132 | return false; 133 | } 134 | 135 | ExpandVariables(Property.Value); 136 | 137 | AdditionalProperties.Add(MoveTemp(Property)); 138 | } 139 | } 140 | 141 | return true; 142 | } 143 | 144 | FString FTargetReceipt::GetDefaultPath(const TCHAR* BaseDir, const TCHAR* TargetName, const TCHAR* Platform, EBuildConfiguration Configuration, const TCHAR* BuildArchitecture) 145 | { 146 | const TCHAR* ArchitectureSuffix = TEXT(""); 147 | if (BuildArchitecture != nullptr) 148 | { 149 | ArchitectureSuffix = BuildArchitecture; 150 | } 151 | 152 | if ((BuildArchitecture == nullptr || BuildArchitecture[0] == 0) && Configuration == EBuildConfiguration::Development) 153 | { 154 | return FPaths::Combine(BaseDir, FString::Printf(TEXT("Binaries/%s/%s.target"), Platform, TargetName)); 155 | } 156 | else 157 | { 158 | return FPaths::Combine(BaseDir, FString::Printf(TEXT("Binaries/%s/%s-%s-%s%s.target"), Platform, TargetName, Platform, LexToString(Configuration), ArchitectureSuffix)); 159 | } 160 | } 161 | 162 | void FTargetReceipt::ExpandVariables(FString& Path) 163 | { 164 | static FString EngineDirPrefix = TEXT("$(EngineDir)"); 165 | static FString ProjectDirPrefix = TEXT("$(ProjectDir)"); 166 | if(Path.StartsWith(EngineDirPrefix)) 167 | { 168 | FString EngineDir = FPaths::EngineDir(); 169 | if (EngineDir.Len() > 0 && EngineDir[EngineDir.Len() - 1] == '/') 170 | { 171 | EngineDir = EngineDir.Left(EngineDir.Len() - 1); 172 | } 173 | Path = EngineDir + Path.Mid(EngineDirPrefix.Len()); 174 | } 175 | else if(Path.StartsWith(ProjectDirPrefix) && ProjectDir.Len() > 0) 176 | { 177 | Path = ProjectDir + Path.Mid(ProjectDirPrefix.Len()); 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /Source/QDesktopPlatform/Private/Windows/DesktopPlatformWindows.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "../DesktopPlatformBase.h" 7 | #include "Containers/IndirectArray.h" 8 | #include "Windows/WindowsHWrapper.h" 9 | #include "WindowsRegistry.h" 10 | 11 | class FDesktopPlatformWindows : public FDesktopPlatformBase 12 | { 13 | public: 14 | // IDesktopPlatform Implementation 15 | virtual bool OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames) override; 16 | virtual bool OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames, int32& OutFilterIndex) override; 17 | virtual bool SaveFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames) override; 18 | virtual bool OpenDirectoryDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, FString& OutFolderName) override; 19 | virtual bool OpenFontDialog(const void* ParentWindowHandle, FString& OutFontName, float& OutHeight, EFontImportFlags& OutFlags) override; 20 | 21 | virtual bool RegisterEngineInstallation(const FString &RootDir, FString &OutIdentifier) override; 22 | virtual void EnumerateEngineInstallations(TMap &OutInstallations) override; 23 | 24 | virtual bool IsSourceDistribution(const FString &RootDir) override; 25 | 26 | virtual bool VerifyFileAssociations() override; 27 | virtual bool UpdateFileAssociations() override; 28 | 29 | virtual bool OpenProject(const FString &ProjectFileName) override; 30 | 31 | virtual bool RunUnrealBuildTool(const FText& Description, const FString& RootDir, const FString& Arguments, FFeedbackContext* Warn) override; 32 | virtual bool IsUnrealBuildToolRunning() override; 33 | 34 | virtual FFeedbackContext* GetNativeFeedbackContext() override; 35 | 36 | virtual FString GetUserTempPath() override; 37 | 38 | private: 39 | bool FileDialogShared(bool bSave, const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames, int32& OutFilterIndex); 40 | void GetRequiredRegistrySettings(TIndirectArray &RootedKeys); 41 | int32 GetShellIntegrationVersion(const FString &FileName); 42 | }; 43 | 44 | typedef FDesktopPlatformWindows FDesktopPlatform; 45 | -------------------------------------------------------------------------------- /Source/QDesktopPlatform/Private/Windows/WindowsNativeFeedbackContext.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Misc/FeedbackContext.h" 7 | #include "Windows/WindowsHWrapper.h" 8 | #include "Windows/AllowWindowsPlatformTypes.h" 9 | #include 10 | 11 | 12 | /** 13 | * Feedback context implementation for windows. 14 | */ 15 | class FWindowsNativeFeedbackContext : public FFeedbackContext 16 | { 17 | public: 18 | // Constructor. 19 | FWindowsNativeFeedbackContext(); 20 | virtual ~FWindowsNativeFeedbackContext(); 21 | 22 | virtual void Serialize( const TCHAR* V, ELogVerbosity::Type Verbosity, const class FName& Category ) override; 23 | 24 | virtual bool ReceivedUserCancel() override; 25 | virtual void StartSlowTask( const FText& Task, bool bShouldShowCancelButton=false ) override; 26 | virtual void FinalizeSlowTask( ) override; 27 | virtual void ProgressReported( const float TotalProgressInterp, FText DisplayMessage ) override; 28 | 29 | FContextSupplier* GetContext() const; 30 | void SetContext( FContextSupplier* InSupplier ); 31 | 32 | private: 33 | struct FWindowParams 34 | { 35 | FWindowsNativeFeedbackContext* Context; 36 | int32 ScaleX; 37 | int32 ScaleY; 38 | int32 StandardW; 39 | int32 StandardH; 40 | bool bLogVisible; 41 | }; 42 | 43 | static const uint16 StatusCtlId = 200; 44 | static const uint16 ProgressCtlId = 201; 45 | static const uint16 ShowLogCtlId = 202; 46 | static const uint16 LogOutputCtlId = 203; 47 | 48 | FContextSupplier* Context; 49 | HANDLE hThread; 50 | HANDLE hCloseEvent; 51 | HANDLE hUpdateEvent; 52 | FCriticalSection CriticalSection; 53 | FString Status; 54 | float Progress; 55 | FString LogOutput; 56 | bool bReceivedUserCancel; 57 | bool bShowCancelButton; 58 | 59 | void CreateSlowTaskWindow(const FText &InStatus, bool bInShowCancelButton); 60 | void DestroySlowTaskWindow(); 61 | 62 | static DWORD WINAPI SlowTaskThreadProc(void *Params); 63 | static LRESULT CALLBACK SlowTaskWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); 64 | static void LayoutControls(HWND hWnd, const FWindowParams* Params); 65 | }; 66 | 67 | #include "Windows/HideWindowsPlatformTypes.h" 68 | -------------------------------------------------------------------------------- /Source/QDesktopPlatform/Private/Windows/WindowsRegistry.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Containers/Array.h" 7 | #include "Containers/Map.h" 8 | #include "Containers/UnrealString.h" 9 | #include "Windows/WindowsHWrapper.h" 10 | #include "Templates/UniquePtr.h" 11 | 12 | struct FRegistryValue 13 | { 14 | uint32 Type; 15 | TArray Data; 16 | 17 | FRegistryValue(); 18 | 19 | void Set(const FString &NewValue); 20 | void Set(uint32 NewValue); 21 | 22 | bool Read(HKEY hKey, const FString &Name); 23 | bool Write(HKEY hKey, const FString &Name) const; 24 | bool IsUpToDate(HKEY hKey, const FString &Name) const; 25 | }; 26 | 27 | struct FRegistryKey : FNoncopyable 28 | { 29 | TMap Keys; 30 | TMap Values; 31 | 32 | FRegistryKey(); 33 | ~FRegistryKey(); 34 | 35 | FRegistryKey *FindOrAddKey(const FString &Name); 36 | FRegistryValue *FindOrAddValue(const FString &Name); 37 | 38 | void SetValue(const FString &Name, const FString &Value); 39 | void SetValue(const FString &Name, uint32 Value); 40 | 41 | bool Read(HKEY hKey); 42 | bool Read(HKEY hKey, const FString &Path); 43 | 44 | bool Write(HKEY hKey, bool bRemoveDifferences) const; 45 | bool Write(HKEY hKey, const FString &Path, bool bRemoveDifferences) const; 46 | 47 | bool IsUpToDate(HKEY hKey, bool bRemoveDifferences) const; 48 | bool IsUpToDate(HKEY hKey, const FString &Path, bool bRemoveDifferences) const; 49 | }; 50 | 51 | struct FRegistryRootedKey 52 | { 53 | HKEY hRootKey; 54 | FString Path; 55 | TUniquePtr Key; 56 | 57 | FRegistryRootedKey(HKEY hInKeyRoot, const FString &InPath); 58 | 59 | bool Exists() const; 60 | 61 | bool Read(); 62 | bool Write(bool bRemoveDifferences) const; 63 | bool IsUpToDate(bool bRemoveDifferences) const; 64 | }; 65 | 66 | bool EnumerateRegistryKeys(HKEY hKey, TArray &OutNames); 67 | bool EnumerateRegistryValues(HKEY hKey, TArray &OutNames); 68 | 69 | -------------------------------------------------------------------------------- /Source/QDesktopPlatform/Public/QDesktopPlatformModule.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/ModuleInterface.h" 7 | #include "Modules/ModuleManager.h" 8 | #include "IDesktopPlatform.h" 9 | 10 | class FQDesktopPlatformModule : public IModuleInterface 11 | { 12 | public: 13 | virtual void StartupModule(); 14 | virtual void ShutdownModule(); 15 | 16 | static IDesktopPlatform* Get() 17 | { 18 | FQDesktopPlatformModule& DesktopPlatformModule = FModuleManager::Get().LoadModuleChecked("QDesktopPlatform"); 19 | return DesktopPlatformModule.GetSingleton(); 20 | } 21 | 22 | private: 23 | virtual IDesktopPlatform* GetSingleton() const { return DesktopPlatform; } 24 | 25 | IDesktopPlatform* DesktopPlatform; 26 | }; 27 | -------------------------------------------------------------------------------- /Source/QDesktopPlatform/Public/TargetReceipt.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/BuildVersion.h" 7 | 8 | /** 9 | * Record of a file that was created as part of the build process 10 | */ 11 | struct FBuildProduct 12 | { 13 | /** Path to the file. */ 14 | FString Path; 15 | 16 | /** Type of the build product. */ 17 | FString Type; 18 | }; 19 | 20 | /** 21 | * Information about a file which is required by the target at runtime, and must be moved around with it. 22 | */ 23 | struct FRuntimeDependency 24 | { 25 | /** The file that should be staged. Should use $(EngineDir) and $(ProjectDir) variables as a root, so that the target can be relocated to different machines. */ 26 | FString Path; 27 | 28 | /** How to stage this file. */ 29 | FString Type; 30 | }; 31 | 32 | /** 33 | * Arbitrary property name/value which metadata from the build scripts can be passed on to downstream tasks 34 | */ 35 | struct FReceiptProperty 36 | { 37 | /** Property name */ 38 | FString Name; 39 | 40 | /** Value of the property */ 41 | FString Value; 42 | }; 43 | 44 | /** 45 | * Stores information about a compiled target. Mirror of the TargetReceipt class generated by UBT. 46 | */ 47 | struct QDESKTOPPLATFORM_API FTargetReceipt 48 | { 49 | /** Path to the project file for this target */ 50 | FString ProjectFile; 51 | 52 | /** The project directory */ 53 | FString ProjectDir; 54 | 55 | /** The name of this target */ 56 | FString TargetName; 57 | 58 | /** Which platform the target is compiled for */ 59 | FString Platform; 60 | 61 | /** Which platform the target is compiled for */ 62 | FString Architecture; 63 | 64 | /** Which configuration this target is compiled in */ 65 | EBuildConfiguration Configuration; 66 | 67 | /** The type of the target */ 68 | EBuildTargetType TargetType; 69 | 70 | /** The exectuable to launch for this target */ 71 | FString Launch; 72 | 73 | /** The build products which are part of this target */ 74 | TArray BuildProducts; 75 | 76 | /** All the runtime dependencies that this target relies on */ 77 | TArray RuntimeDependencies; 78 | 79 | /** Additional build properties passed through from the module rules */ 80 | TArray AdditionalProperties; 81 | 82 | /** 83 | * Read a target receipt from disk 84 | * 85 | * @param FileName The file to read from 86 | * @return True if the file was read successfully 87 | */ 88 | bool Read(const FString& FileName); 89 | 90 | /** 91 | * Gets the default path for a target receipt 92 | * 93 | * @param BaseDir Base directory for the target being built; either the project directory or engine directory. 94 | * @param TargetName The target being built 95 | * @param Platform The target platform 96 | * @param Configuration The target configuration 97 | * @param BuildArchitecture The architecture being built 98 | * @return Path to the receipt for this target 99 | */ 100 | static FString GetDefaultPath(const TCHAR* BaseDir, const TCHAR* TargetName, const TCHAR* Platform, EBuildConfiguration Configuration, const TCHAR* BuildArchitecture); 101 | 102 | private: 103 | /** 104 | * Expands the $(EngineDir) and $(ProjectDir) variables within a string 105 | * 106 | * @param Path Path to expand variables within 107 | */ 108 | void ExpandVariables(FString& Path); 109 | }; 110 | -------------------------------------------------------------------------------- /Source/QDesktopPlatform/QDesktopPlatform.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | using System; 4 | using System.IO; 5 | using UnrealBuildTool; 6 | 7 | public class QDesktopPlatform : ModuleRules 8 | { 9 | protected string PrivateDirectory 10 | { 11 | get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "Private/")); } 12 | } 13 | 14 | public QDesktopPlatform(ReadOnlyTargetRules Target) : base(Target) 15 | { 16 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 17 | PrivatePCHHeaderFile = Path.GetFullPath(Path.Combine(PrivateDirectory, "DesktopPlatformPrivate.h")); 18 | 19 | PrivateIncludePaths.Add( PrivateDirectory ); 20 | 21 | PublicIncludePaths.Add(Path.GetFullPath(Path.Combine(ModuleDirectory, "Public/"))); 22 | 23 | PrivateDependencyModuleNames.AddRange( 24 | new string[] { 25 | "Core", 26 | "ApplicationCore", 27 | "Json", 28 | } 29 | ); 30 | 31 | if (Target.IsInPlatformGroup(UnrealPlatformGroup.Linux)) 32 | { 33 | PrivateIncludePathModuleNames.AddRange( 34 | new string[] { 35 | "QSlateFileDialogs", 36 | } 37 | ); 38 | 39 | DynamicallyLoadedModuleNames.AddRange( 40 | new string[] { 41 | "QSlateFileDialogs", 42 | } 43 | ); 44 | 45 | AddEngineThirdPartyPrivateStaticDependencies(Target, "SDL2"); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Source/QRender/Private/Library/OpenSysDialogMethods.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #include "Library/OpenSysDialogMethods.h" 4 | 5 | 6 | #include "GenericPlatform/GenericPlatformMisc.h" 7 | #include "GenericPlatform/GenericPlatformProcess.h" 8 | 9 | #include "Engine.h" 10 | #include "Windows/AllowWindowsPlatformTypes.h" 11 | #include "Windows/COMPointer.h" 12 | #include 13 | #include "Windows/HideWindowsPlatformTypes.h" 14 | 15 | bool UOpenSysDialogMethods::OpenSystemFileDialog(FString& OutFilePath, const FString& Title, const FString& DefaultPath, ESystemFileDialogTypeEx Type, const FString& Filter) 16 | { 17 | OutFilePath.Empty(); 18 | TComPtr FileDialog; 19 | 20 | CLSID type_clsid; 21 | IID type_iid; 22 | 23 | switch( Type) 24 | { 25 | case ESystemFileDialogTypeEx::Open: { type_clsid = CLSID_FileOpenDialog; type_iid = IID_IFileOpenDialog; break; } 26 | case ESystemFileDialogTypeEx::Save: { type_clsid = CLSID_FileSaveDialog; type_iid = IID_IFileSaveDialog; break; } 27 | } 28 | 29 | //auto c = CLSID_FileSaveDialog; 30 | if (!SUCCEEDED(::CoCreateInstance( type_clsid, 31 | nullptr, 32 | CLSCTX_INPROC_SERVER, 33 | type_iid, 34 | IID_PPV_ARGS_Helper(&FileDialog) 35 | ))) 36 | { 37 | return false; 38 | } 39 | // Set up common settings 40 | FileDialog->SetTitle( *Title); 41 | 42 | FString DefaultWindowsPath = DefaultPath; 43 | if (DefaultWindowsPath.IsEmpty() ) 44 | { 45 | DefaultWindowsPath = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir()); 46 | } 47 | 48 | DefaultWindowsPath.ReplaceInline(TEXT("/"), TEXT("\\"), ESearchCase::CaseSensitive); 49 | TComPtr DefaultPathItem; 50 | if (SUCCEEDED(::SHCreateItemFromParsingName(*DefaultWindowsPath, nullptr, IID_PPV_ARGS(&DefaultPathItem)))) 51 | { 52 | FileDialog->SetFolder(DefaultPathItem); 53 | } 54 | TArray UnformattedExtensions; 55 | TArray FileDialogFilters; 56 | { 57 | Filter.ParseIntoArray(UnformattedExtensions, TEXT("|"), true); 58 | if (UnformattedExtensions.Num() % 2 == 0) 59 | { 60 | FileDialogFilters.Reserve(UnformattedExtensions.Num() / 2); 61 | for (int32 ExtensionIndex = 0; ExtensionIndex < UnformattedExtensions.Num();) 62 | { 63 | COMDLG_FILTERSPEC& NewFilterSpec = FileDialogFilters[FileDialogFilters.AddDefaulted()]; 64 | NewFilterSpec.pszName = *UnformattedExtensions[ExtensionIndex++]; 65 | NewFilterSpec.pszSpec = *UnformattedExtensions[ExtensionIndex++]; 66 | } 67 | } 68 | } 69 | FileDialog->SetFileTypes(FileDialogFilters.Num(), FileDialogFilters.GetData()); 70 | // show 71 | if (!SUCCEEDED( 72 | FileDialog->Show(static_cast(FSlateApplication::Get().GetActiveTopLevelWindow()->GetNativeWindow()-> 73 | GetOSWindowHandle())))) 74 | { 75 | return false; 76 | } 77 | TComPtr Result; 78 | if (!SUCCEEDED(FileDialog->GetResult(&Result))) { return false; } 79 | PWSTR pFilePath = nullptr; 80 | if (SUCCEEDED(Result->GetDisplayName(SIGDN_FILESYSPATH, &pFilePath))) 81 | { 82 | FString SaveFilePath = pFilePath; 83 | int32 FilterIndex = 0; 84 | if (SUCCEEDED(FileDialog->GetFileTypeIndex(reinterpret_cast(&FilterIndex)))) 85 | { 86 | FilterIndex -= 1; // GetFileTypeIndex returns a 1-based index 87 | } 88 | if (FileDialogFilters.IsValidIndex(FilterIndex)) 89 | { 90 | const FString ExtensionPattern = FileDialogFilters[FilterIndex].pszSpec; 91 | TArray SaveExtensions; 92 | ExtensionPattern.ParseIntoArray(SaveExtensions, TEXT(";")); 93 | FString CleanExtension = SaveExtensions[0]; 94 | if (CleanExtension == TEXT("*.*")) 95 | { 96 | CleanExtension.Reset(); 97 | } 98 | else 99 | { 100 | int32 WildCardIndex = INDEX_NONE; 101 | if (CleanExtension.FindChar(TEXT('*'), WildCardIndex)) 102 | { 103 | CleanExtension = CleanExtension.RightChop(WildCardIndex + 1); 104 | } 105 | } 106 | FString SaveFileName = FPaths::GetCleanFilename(SaveFilePath); 107 | SaveFilePath = FPaths::GetPath(SaveFilePath); 108 | if (FPaths::GetExtension(SaveFileName).IsEmpty() && !CleanExtension.IsEmpty()) 109 | { 110 | SaveFileName = FPaths::SetExtension(SaveFileName, CleanExtension); 111 | } 112 | OutFilePath = FPaths::ConvertRelativePathToFull(FPaths::Combine(SaveFilePath, SaveFileName)); 113 | } 114 | } 115 | ::CoTaskMemFree(pFilePath); 116 | 117 | return true; 118 | } 119 | -------------------------------------------------------------------------------- /Source/QRender/Private/Pipeline/CaptureRTTViewExtension.cpp: -------------------------------------------------------------------------------- 1 | #include "CaptureRTTViewExtension.h" 2 | 3 | FCaptureRTTViewExtension::FCaptureRTTViewExtension(const FAutoRegister& AutoReg): 4 | FSceneViewExtensionBase(AutoReg) 5 | { 6 | } 7 | 8 | FCaptureRTTViewExtension::~FCaptureRTTViewExtension() 9 | { 10 | } 11 | 12 | void FCaptureRTTViewExtension::SetupViewFamily(FSceneViewFamily& InViewFamily) 13 | { 14 | } 15 | 16 | 17 | void FCaptureRTTViewExtension::PreRenderView_RenderThread(FRHICommandListImmediate& RHICmdList, FSceneView& InView) 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /Source/QRender/Private/Pipeline/CaptureRTTViewExtension.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CoreMinimal.h" 4 | #include "SceneViewExtension.h" 5 | 6 | 7 | class FCaptureRTTViewExtension : public FSceneViewExtensionBase 8 | { 9 | public: 10 | FCaptureRTTViewExtension(const FAutoRegister& AutoReg); 11 | ~FCaptureRTTViewExtension(); 12 | 13 | // FSceneViewExtensionBase implementation : 14 | virtual void SetupViewFamily(FSceneViewFamily& InViewFamily) override; 15 | 16 | virtual void SetupView(FSceneViewFamily& InViewFamily, FSceneView& InView) override 17 | { 18 | } 19 | 20 | virtual void BeginRenderViewFamily(FSceneViewFamily& InViewFamily) override 21 | { 22 | } 23 | 24 | virtual void PreRenderViewFamily_RenderThread(FRHICommandListImmediate& RHICmdList, FSceneViewFamily& InViewFamily) override 25 | { 26 | } 27 | 28 | virtual void PreRenderView_RenderThread(FRHICommandListImmediate& RHICmdList, FSceneView& InView) override; 29 | 30 | 31 | bool bRebuildGPUData = false; 32 | 33 | FBufferRHIRef DataBuffer; 34 | FShaderResourceViewRHIRef DataSRV; 35 | 36 | FBufferRHIRef IndirectionBuffer; 37 | FShaderResourceViewRHIRef IndirectionSRV; 38 | }; 39 | -------------------------------------------------------------------------------- /Source/QRender/Private/Pipeline/CaptureScreenPercentageDriver.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | /*============================================================================= 4 | Renderer.cpp: Renderer module implementation. 5 | =============================================================================*/ 6 | 7 | #include "CaptureScreenPercentageDriver.h" 8 | #include "UnrealEngine.h" 9 | 10 | #include "Misc/ConfigCacheIni.h" 11 | #include "DynamicResolutionState.h" 12 | 13 | FCaptureScreenPercentageDriver::FCaptureScreenPercentageDriver( 14 | const FSceneViewFamily& InViewFamily, 15 | float InGlobalResolutionFraction, 16 | float InGlobalResolutionFractionUpperBound) 17 | : ViewFamily(InViewFamily) 18 | , GlobalResolutionFraction(InGlobalResolutionFraction) 19 | , GlobalResolutionFractionUpperBound(InGlobalResolutionFractionUpperBound) 20 | { 21 | } 22 | 23 | DynamicRenderScaling::TMap FCaptureScreenPercentageDriver::GetResolutionFractionsUpperBound() const 24 | { 25 | DynamicRenderScaling::TMap UpperBounds; 26 | UpperBounds.SetAll(1.0f); 27 | 28 | if (ViewFamily.EngineShowFlags.ScreenPercentage) 29 | { 30 | UpperBounds[GDynamicPrimaryResolutionFraction] = FMath::Clamp( 31 | GlobalResolutionFractionUpperBound, 32 | ISceneViewFamilyScreenPercentage::kMinResolutionFraction, 33 | ISceneViewFamilyScreenPercentage::kMaxResolutionFraction); 34 | } 35 | 36 | return UpperBounds; 37 | } 38 | 39 | ISceneViewFamilyScreenPercentage* FCaptureScreenPercentageDriver::Fork_GameThread( 40 | const FSceneViewFamily& ForkedViewFamily) const 41 | { 42 | check(IsInGameThread()); 43 | //return nullptr; 44 | return new FCaptureScreenPercentageDriver( 45 | ForkedViewFamily, GlobalResolutionFraction, GlobalResolutionFractionUpperBound); 46 | } 47 | 48 | DynamicRenderScaling::TMap FCaptureScreenPercentageDriver::GetResolutionFractions_RenderThread() const 49 | { 50 | check(IsInRenderingThread()); 51 | 52 | DynamicRenderScaling::TMap ResolutionFractions; 53 | ResolutionFractions.SetAll(1.0f); 54 | 55 | if (ViewFamily.EngineShowFlags.ScreenPercentage) 56 | { 57 | ResolutionFractions[GDynamicPrimaryResolutionFraction] = FMath::Clamp( 58 | GlobalResolutionFraction, 59 | ISceneViewFamilyScreenPercentage::kMinResolutionFraction, 60 | ISceneViewFamilyScreenPercentage::kMaxResolutionFraction); 61 | } 62 | 63 | return ResolutionFractions; 64 | } 65 | 66 | 67 | //void FCaptureScreenPercentageDriver::ComputePrimaryResolutionFractions_RenderThread( 68 | // TArray& OutViewScreenPercentageConfigs) const 69 | //{ 70 | // check(IsInRenderingThread()); 71 | // // 如果不支持ScenePercentage功能则直接返回 72 | // if (!ViewFamily.EngineShowFlags.ScreenPercentage) 73 | // { 74 | // return; 75 | // } 76 | // 77 | // for (int32 i = 0; i < ViewFamily.Views.Num(); i++) 78 | // { 79 | // float ResolutionFraction = GlobalResolutionFraction; 80 | // //TODO:限制大小,避免卡死..后面可根据硬件等级设置上下界 81 | // OutViewScreenPercentageConfigs[i].PrimaryResolutionFraction = FMath::Clamp( 82 | // ResolutionFraction, 83 | // MinResolutionFraction, 84 | // MaxResolutionFraction ); 85 | // } 86 | //} 87 | -------------------------------------------------------------------------------- /Source/QRender/Private/Pipeline/CaptureScreenPercentageDriver.h: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | /*============================================================================= 4 | RendererPrivate.h: Renderer interface private definitions. 5 | =============================================================================*/ 6 | 7 | #pragma once 8 | 9 | #include "SceneView.h" 10 | 11 | 12 | /** 13 | * 自定义场景百分比接口...为了更自由的控制Capture的最大最小百分比 14 | */ 15 | class QRENDER_API FCaptureScreenPercentageDriver : public ISceneViewFamilyScreenPercentage 16 | { 17 | public: 18 | FORCEINLINE FCaptureScreenPercentageDriver( 19 | const FSceneViewFamily& InViewFamily, 20 | float InGlobalResolutionFraction) 21 | : FCaptureScreenPercentageDriver(InViewFamily, InGlobalResolutionFraction, InGlobalResolutionFraction) 22 | { 23 | } 24 | 25 | FCaptureScreenPercentageDriver( 26 | const FSceneViewFamily& InViewFamily, 27 | float InGlobalResolutionFraction, 28 | float InGlobalResolutionFractionUpperBound); 29 | 30 | public: 31 | FORCEINLINE float GetGlobalResolutionFraction() const 32 | { 33 | return GlobalResolutionFraction; 34 | } 35 | 36 | FORCEINLINE bool SetGlobalResolutionFraction(float newFraction) volatile 37 | { 38 | float newF = this->GlobalResolutionFraction = FMath::Clamp(newFraction, ISceneViewFamilyScreenPercentage::kMinResolutionFraction, ISceneViewFamilyScreenPercentage::kMaxResolutionFraction); 39 | if (GlobalResolutionFractionUpperBound < newF) 40 | { 41 | //防止上界小于当前 42 | GlobalResolutionFractionUpperBound = this->GlobalResolutionFraction; 43 | } 44 | this->GlobalResolutionFraction = newF; 45 | return true; 46 | } 47 | 48 | private: 49 | const FSceneViewFamily& ViewFamily; 50 | 51 | volatile float GlobalResolutionFraction; 52 | volatile float GlobalResolutionFractionUpperBound; 53 | 54 | #pragma region ISceneViewFamilyScreenPercentage虚函数实现 55 | virtual DynamicRenderScaling::TMap GetResolutionFractionsUpperBound() const override; 56 | virtual DynamicRenderScaling::TMap GetResolutionFractions_RenderThread() const override; 57 | virtual ISceneViewFamilyScreenPercentage* Fork_GameThread(const class FSceneViewFamily& ForkedViewFamily) const override; 58 | #pragma endregion 59 | }; 60 | -------------------------------------------------------------------------------- /Source/QRender/Private/QRender.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "QRender.h" 4 | #define LOCTEXT_NAMESPACE "FQRenderModule" 5 | 6 | void FRenderGModule::StartupModule() 7 | { 8 | //UE_LOG(LogTemp, Log, TEXT("-------------------------------------------------------------------- QRender")) 9 | } 10 | 11 | 12 | void FRenderGModule::ShutdownModule() 13 | { 14 | } 15 | 16 | #undef LOCTEXT_NAMESPACE 17 | 18 | IMPLEMENT_MODULE(FRenderGModule, QRender); 19 | -------------------------------------------------------------------------------- /Source/QRender/Public/DTO/ImageFormatEx.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | #include "ImageFormatEx.generated.h" 8 | 9 | UENUM(BlueprintType) 10 | enum class EImageFormatEx : uint8 11 | { 12 | /** Invalid or unrecognized format. */ 13 | Invalid = 0, 14 | 15 | /** Portable Network Graphics. */ 16 | PNG = 1, 17 | 18 | /** Joint Photographic Experts Group. */ 19 | JPEG, 20 | 21 | /** Single channel JPEG. */ 22 | GrayscaleJPEG, 23 | 24 | /** Windows Bitmap. */ 25 | BMP, 26 | 27 | /** Windows Icon resource. */ 28 | ICO, 29 | 30 | /** OpenEXR (HDR) image file format. */ 31 | EXR, 32 | 33 | /** Mac icon. */ 34 | ICNS, 35 | 36 | /** Truevision TGA / TARGA */ 37 | TGA, 38 | 39 | /** 扩展 */ 40 | WebP 41 | }; 42 | -------------------------------------------------------------------------------- /Source/QRender/Public/DTO/MedioDTOModel.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | #include "MediaPacket.h" 8 | #include "ImageFormatEx.h" 9 | #include "MedioDTOModel.generated.h" 10 | 11 | /** 12 | * 消费者的抽象 13 | */ 14 | class ICFVideoCaptureListener 15 | { 16 | public: 17 | virtual void OnMediaSample(const AVEncoder::FMediaPacket&Sample) = 0; 18 | //捕获完成时 19 | virtual void OnCaptureCompleted() = 0; 20 | 21 | virtual void OnStartCaptureMedia() = 0; 22 | 23 | //virtual bool StartImpl(double RingBufferDurationSecs = 30.0f, AActor *InTrackActor = nullptr) = 0; 24 | virtual bool StartImpl(FVideoCaptureOptions opt) = 0; 25 | // 26 | virtual void StopImpl() = 0; 27 | }; 28 | 29 | USTRUCT(BlueprintType) 30 | struct QRENDER_API FVideoTimelineKeys 31 | { 32 | GENERATED_USTRUCT_BODY() 33 | public: 34 | UPROPERTY(BlueprintReadWrite) 35 | float time; 36 | 37 | UPROPERTY(BlueprintReadWrite) 38 | FVector location; 39 | 40 | UPROPERTY(BlueprintReadWrite) 41 | FRotator rotation; 42 | }; 43 | 44 | /** 45 | * 预留 46 | **/ 47 | USTRUCT(BlueprintType) 48 | struct QRENDER_API FVideoCaptureOptions 49 | { 50 | GENERATED_USTRUCT_BODY() 51 | public: 52 | //内存帧缓存最大量(framerate * second) 53 | UPROPERTY(BlueprintReadWrite) 54 | float RingBufferDurationSecs = 30.0f; 55 | 56 | //如果keysInfo帧时间大于此取keys 57 | UPROPERTY(BlueprintReadWrite) 58 | float CaptureTimeSec = 30.0f; 59 | 60 | UPROPERTY(BlueprintReadWrite) 61 | TArray keysInfo; 62 | 63 | UPROPERTY(BlueprintReadWrite) 64 | bool bTrackPawn = true; 65 | }; 66 | 67 | UCLASS(BlueprintType, config = MediaCapture, defaultconfig) 68 | class QRENDER_API UMediaUserSettings : public UObject 69 | { 70 | GENERATED_BODY() 71 | public: 72 | //UPROPERTY(config) 73 | //bool bTrackPawn = false; 74 | 75 | //UPROPERTY(config) 76 | //TArray keys; 77 | 78 | UPROPERTY(config) 79 | FString QualityType = TEXT("720P"); 80 | 81 | UPROPERTY(config) 82 | FString SavePath; 83 | 84 | UPROPERTY(config) 85 | float BitRate = 5000000; 86 | 87 | UPROPERTY(config) 88 | int32 FrameRate = 30; 89 | 90 | public: 91 | UFUNCTION(BlueprintCallable) 92 | FORCEINLINE FIntPoint GetSize() 93 | { 94 | //XXX:应该用枚举改善一下 95 | FIntPoint size = {}; 96 | if (QualityType == TEXT("720P")) 97 | { 98 | size.X = 1280; 99 | size.Y = 720; 100 | } 101 | else if (QualityType == TEXT("1080P")) 102 | { 103 | size.X = 1920; 104 | size.Y = 1080; 105 | } 106 | else if (QualityType == TEXT("2K")) 107 | { 108 | size.X = 2880; 109 | size.Y = 1660; 110 | } 111 | else if (QualityType == TEXT("4K")) 112 | { 113 | size.X = 3840; 114 | size.Y = 2160; 115 | } 116 | return size; 117 | } 118 | 119 | 120 | UFUNCTION(BlueprintCallable) 121 | FORCEINLINE void UpdateBitRate() 122 | { 123 | if (QualityType == TEXT("720P")) 124 | { 125 | BitRate = FrameRate <= 30 ? 5000000 : 7500000; 126 | } 127 | else if (QualityType == TEXT("1080P")) 128 | { 129 | BitRate = FrameRate <= 30 ? 8000000 : 12000000; 130 | } 131 | else if (QualityType == TEXT("2K")) 132 | { 133 | BitRate = FrameRate <= 30 ? 16000000 : 24000000; 134 | } 135 | else if (QualityType == TEXT("4K")) 136 | { 137 | BitRate = FrameRate <= 30 ? 40000000 : 60000000; 138 | } 139 | } 140 | 141 | UFUNCTION(BlueprintCallable) 142 | FORCEINLINE void SetQualityType(const FString& _qualityType ) 143 | { 144 | QualityType = _qualityType; 145 | this->UpdateBitRate(); 146 | } 147 | 148 | UFUNCTION(BlueprintCallable) 149 | FORCEINLINE void SetFrameRate(const int32 _frameRate ) 150 | { 151 | FrameRate = _frameRate; 152 | UpdateBitRate(); 153 | } 154 | }; 155 | 156 | 157 | 158 | DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnHasScreenshotCompleted, const FString&, SavePath); 159 | 160 | UCLASS(BlueprintType, config = Screenshot, defaultconfig) 161 | class QRENDER_API UScreenshotUserSettings : public UObject 162 | { 163 | GENERATED_BODY() 164 | public: 165 | UPROPERTY(config) 166 | EImageFormatEx ImageType = EImageFormatEx::JPEG; //EScreenShotImageType::JPEG; 167 | 168 | UPROPERTY(config) 169 | FString QualityType = TEXT("1080P"); 170 | 171 | UPROPERTY(config) 172 | FString SavePath; 173 | 174 | UPROPERTY(config) 175 | bool bAllowRenameSaveFile = false; 176 | 177 | UPROPERTY(config) 178 | bool bKeepRatio = false; 179 | 180 | UPROPERTY(config) 181 | int Width = 1280; 182 | 183 | UPROPERTY(config) 184 | int Height = 720; 185 | 186 | UPROPERTY(BlueprintAssignable) 187 | FOnHasScreenshotCompleted OnHasScreenshotCompleted; 188 | public: 189 | UFUNCTION(BlueprintCallable) 190 | FORCEINLINE FString GetImageType() 191 | { 192 | switch (this->ImageType) 193 | { 194 | case EImageFormatEx::JPEG: 195 | { 196 | return TEXT("JPG"); 197 | } 198 | case EImageFormatEx::PNG: 199 | { 200 | return TEXT("PNG"); 201 | } 202 | case EImageFormatEx::WebP: 203 | { 204 | return TEXT("WEBP"); 205 | } 206 | } 207 | return TEXT("JPG"); 208 | } 209 | 210 | UFUNCTION(BlueprintCallable) 211 | FORCEINLINE void SetImageType(const FString& InImageType) 212 | { 213 | if (InImageType == TEXT("JPG") || InImageType == TEXT("JPEG")) 214 | { 215 | this->ImageType = EImageFormatEx::JPEG; 216 | } 217 | else if (InImageType == TEXT("PNG") ) 218 | { 219 | this->ImageType = EImageFormatEx::PNG; 220 | } 221 | else if (InImageType == TEXT("WEBP")) 222 | { 223 | this->ImageType = EImageFormatEx::WebP; 224 | } 225 | } 226 | 227 | UFUNCTION(BlueprintCallable) 228 | FORCEINLINE void SetQualityType(const FString& InQualityType) 229 | { 230 | this->QualityType = InQualityType; 231 | 232 | if(InQualityType == TEXT("1080P")) 233 | { 234 | this->Width = 1920; 235 | this->Height = 1080; 236 | } 237 | else if (InQualityType == TEXT("2K")) 238 | { 239 | this->Width = 2560; 240 | this->Height = 1440; 241 | } 242 | else if (InQualityType == TEXT("4K")) 243 | { 244 | this->Width = 3840; 245 | this->Height = 2160; 246 | } 247 | else if (InQualityType == TEXT("8K")) 248 | { 249 | this->Width = 7680; 250 | this->Height = 4320; 251 | } 252 | else if (InQualityType == TEXT("自定义")) 253 | { 254 | //由TS设置Width 和 Height 255 | } 256 | } 257 | }; -------------------------------------------------------------------------------- /Source/QRender/Public/Library/CaptureExtensionMethods.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Kismet/BlueprintFunctionLibrary.h" 7 | #include "DTO/ImageFormatEx.h" 8 | #include "CaptureExtensionMethods.generated.h" 9 | 10 | 11 | 12 | class UMediaUserSettings; 13 | class UScreenshotUserSettings; 14 | //DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnHasScreenshotCompleted, const FString&, SavePath); 15 | /** 16 | * 版本更新相关,GameIsntance检查或服务器socket主动进行新版本推送 17 | */ 18 | UCLASS() 19 | class QRENDER_API UCaptureExtensionMethods : public UBlueprintFunctionLibrary 20 | { 21 | GENERATED_BODY() 22 | public: 23 | /** Debug */ 24 | UFUNCTION(BlueprintCallable) 25 | static void ScreenShot_HighRes(); 26 | 27 | UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject")) 28 | static void HighScreenShot( UObject* WorldContextObject, EImageFormatEx InSaveType); 29 | 30 | static void CustomCameraHighScreenShot( 31 | UWorld* InWorld, EImageFormatEx InSaveType, 32 | const FVector& InLocation, const FRotator& InRotation, float InFov); 33 | 34 | static void CustomHighScreenShot( 35 | UWorld* InWorld, const FVector& InLocation, const FRotator& InRotation, float InFov, 36 | float InScreenPercent, const FVector2D& InSize, 37 | TFunction&, const FVector2D&)> InCallback); 38 | 39 | UFUNCTION(BlueprintCallable) 40 | static UMediaUserSettings* GetMediaUserSettings(); 41 | 42 | UFUNCTION(BlueprintCallable) 43 | static void SaveMediaUserSettings(); 44 | 45 | UFUNCTION(BlueprintCallable) 46 | static UScreenshotUserSettings* GetScreenshotUserSettings(); 47 | 48 | UFUNCTION(BlueprintCallable) 49 | static void SaveScreenshotUserSettings(); 50 | 51 | /*截帧,用于相机位的UI封面 */ 52 | UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject")) 53 | static UTexture2D* CaptureCameraFrame(UObject* WorldContextObject); 54 | 55 | 56 | UFUNCTION(BlueprintCallable) 57 | static void CubeMap2Per(); 58 | }; -------------------------------------------------------------------------------- /Source/QRender/Public/Library/OpenSysDialogMethods.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Kismet/BlueprintFunctionLibrary.h" 7 | #include "OpenSysDialogMethods.generated.h" 8 | 9 | 10 | UENUM(BlueprintType) 11 | enum class ESystemFileDialogTypeEx : uint8 12 | { 13 | Save, 14 | Open 15 | }; 16 | 17 | //DECLARE_ENUM_TO_STRING(ESystemFileDialogType); 18 | /** 19 | * 版本更新相关,GameIsntance检查或服务器socket主动进行新版本推送 20 | */ 21 | UCLASS() 22 | class QRENDER_API UOpenSysDialogMethods : public UBlueprintFunctionLibrary 23 | { 24 | GENERATED_BODY() 25 | 26 | public: 27 | UFUNCTION(BlueprintCallable, Category = "PuertsExtra | Library") 28 | static bool OpenSystemFileDialog( 29 | FString& OutFilePath, 30 | const FString& Title, const FString& DefaultPath, 31 | ESystemFileDialogTypeEx Type = ESystemFileDialogTypeEx::Open, 32 | const FString& Filter = TEXT("*.*") 33 | ); 34 | 35 | }; 36 | -------------------------------------------------------------------------------- /Source/QRender/Public/Pipeline/CaptureRenderTarget.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "CoreMinimal.h" 9 | #include "UObject/Object.h" 10 | #include "DTO/ImageFormatEx.h" 11 | #include "CaptureRenderTarget.generated.h" 12 | 13 | 14 | class APostProcessVolume; 15 | 16 | 17 | UENUM() 18 | enum class ECaptureState : uint8 19 | { 20 | Initilize = 0, 21 | Warmup, 22 | Renderering, 23 | Renderered, 24 | Captured, 25 | Finished 26 | }; 27 | 28 | UENUM(BlueprintType) 29 | enum class ECaptureCubeFace : uint8 30 | { 31 | CubeFace_PosX = 0, 32 | CubeFace_NegX, 33 | CubeFace_PosY, 34 | CubeFace_NegY, 35 | CubeFace_PosZ, 36 | CubeFace_NegZ, 37 | CubeFace_MAX 38 | }; 39 | 40 | /** 41 | * XXX:维护自己的worldTime用于Vedio 42 | */ 43 | UCLASS(BlueprintType) 44 | class QRENDER_API UCaptureRenderTarget : public UObject, public FTickableGameObject 45 | { 46 | GENERATED_UCLASS_BODY() 47 | public: 48 | //UCaptureRenderTarget(); 49 | ~UCaptureRenderTarget(); 50 | 51 | UFUNCTION(BlueprintCallable) 52 | void Initilize(const FIntPoint& Size, 53 | const FVector& Location = FVector::ZeroVector, 54 | const FRotator& Rotator = FRotator::ZeroRotator, 55 | const float FOV = 90.0f, 56 | const float ScenePercentage = 100.0f, 57 | const bool InbNotInverseGamma = false, 58 | const bool bInAsync = true, //是否是异步捕获模式 59 | APostProcessVolume* PP = nullptr); 60 | 61 | UFUNCTION(BlueprintCallable) 62 | void ResizeRenderTarget(const FIntPoint& Size); 63 | 64 | UFUNCTION(BlueprintCallable) 65 | FORCEINLINE bool IsInitilized() 66 | { 67 | return GetState() != ECaptureState::Initilize; 68 | } 69 | 70 | UFUNCTION(BlueprintCallable) 71 | void SetScreenPercentage(float screenPercentage = 100.0f); 72 | 73 | UFUNCTION(BlueprintCallable) 74 | void SetWorldPause(bool NewPause); 75 | 76 | UFUNCTION(BlueprintCallable) 77 | FORCEINLINE UTextureRenderTarget2D* GetRTT2D() const 78 | { 79 | return this->mRTT2D; 80 | } 81 | 82 | UFUNCTION(BlueprintCallable) 83 | void Capture(const uint8 PreCaptureFrameNum = 2); 84 | 85 | UFUNCTION(BlueprintCallable) 86 | void CaptureFromLocationAndRotation(const FVector& Location = FVector::ZeroVector, 87 | const FRotator& Rotator = FRotator::ZeroRotator, 88 | const uint8 PreCaptureFrameNum = 2 89 | ); 90 | 91 | 92 | //UFUNCTION(BlueprintCallable) 93 | void SetupCustomPassMass(FSceneView* InSceneView); 94 | 95 | //UFUNCTION(BlueprintCallable) 96 | //void AddWeightedBlendables(TArray& arr); 97 | 98 | UFUNCTION(BlueprintCallable) 99 | void SaveToDisk(FString path = TEXT(""), ECaptureCubeFace CubeFace = ECaptureCubeFace::CubeFace_MAX, EImageFormatEx ImageFormat = EImageFormatEx::PNG, int Quility = 100); 100 | 101 | 102 | UFUNCTION(BlueprintCallable) 103 | void SaveToDiskAsync(FString path = TEXT(""), ECaptureCubeFace CubeFace = ECaptureCubeFace::CubeFace_MAX, EImageFormatEx ImageFormat = EImageFormatEx::PNG, int Quility = 100); 104 | 105 | ECaptureState GetState(); 106 | #pragma region event 107 | public: 108 | DECLARE_MULTICAST_DELEGATE_OneParam(FOnCaptureCompleted, UCaptureRenderTarget*) 109 | 110 | FOnCaptureCompleted& OnCaptureCompleted() 111 | { 112 | return Event_OnCaptureCompleted; 113 | } 114 | 115 | FOnCaptureCompleted& OnCaptureCompleted_RenderThread() 116 | { 117 | return Event_OnCaptureCompleted_RenderThread; 118 | } 119 | 120 | //FOnCaptureCompleted& OnCaptureWarmupCompleted() 121 | //{ 122 | // return Event_OnCaptureWarmupCompleted; 123 | //} 124 | 125 | FOnCaptureCompleted& OnCaptureWarmupCompleted_RenderThread() 126 | { 127 | return Event_OnCaptureWarmupCompleted_RenderThread; 128 | } 129 | 130 | DECLARE_MULTICAST_DELEGATE_OneParam(FOnSaveToDiskFinished, const FString &) 131 | FOnSaveToDiskFinished& OnSaveToDiskFinished() 132 | { 133 | check(IsInGameThread()); 134 | return Event_OnSaveToDiskFinished; 135 | } 136 | 137 | DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnSaveToDiskFinished_BP,const FString&, SavePath); 138 | UPROPERTY(BlueprintAssignable) 139 | FOnSaveToDiskFinished_BP OnSaveToDiskFinished_BP; 140 | protected: 141 | FOnCaptureCompleted Event_OnCaptureCompleted; 142 | FOnCaptureCompleted Event_OnCaptureCompleted_RenderThread; 143 | //FOnCaptureCompleted Event_OnCaptureWarmupCompleted; 144 | FOnCaptureCompleted Event_OnCaptureWarmupCompleted_RenderThread; 145 | FOnSaveToDiskFinished Event_OnSaveToDiskFinished; 146 | #pragma endregion event 147 | protected: 148 | void InitRenderTarget(const FIntPoint& Size); 149 | void SetState(ECaptureState NewState); 150 | TSharedPtr SetupViewFamily(); 151 | FSceneView* SetupSceneView(TSharedPtr InViewFamily); 152 | 153 | void UpdateSceneViewPP(FSceneView* SceneView); 154 | void CalculateProjectionMatrix(); 155 | 156 | //ref: UMovieScenePipeline::FlushAsyncEngineSystems 同步等待UE完成渲染每一帧前的预处理.. 157 | void FlushAsyncEngineSystems(); 158 | void RenderFrame(); 159 | void PostRendererSubmission(); 160 | void HandleFrame_OnRenderThread(); 161 | protected: 162 | #pragma region tickable impl 163 | virtual void Tick(float DeltaTime) override; 164 | virtual bool IsTickable() const override; 165 | virtual TStatId GetStatId() const override { return TStatId(); } 166 | #pragma endregion tickable impl 167 | 168 | public: 169 | /** Read RTT pixel Data, from FloatRGBA to R8G8B8A */ 170 | static bool GetRawData(UTextureRenderTarget2D* RTT, TArray64& OutRawData, ECaptureCubeFace CubeFace = ECaptureCubeFace::CubeFace_MAX); 171 | private: 172 | bool IOToDisk(const TArray64 & rawData,const FString& SavePath, const FIntPoint &Size, EImageFormatEx ImageFormat, int Quility); 173 | protected: 174 | #pragma region View 175 | FMatrix mProjectionMatrix = FMatrix::Identity; 176 | FVector mViewLocation = FVector::ZeroVector; 177 | FRotator mViewRotation = FRotator::ZeroRotator; 178 | float mViewFOV = 90.0f; 179 | float mScenePercentage = 100.0f; // important 180 | bool bWorldPause = false; 181 | //bool bFixedExposure = false; 182 | 183 | #pragma endregion 184 | bool bNotInverseGamma = false; 185 | bool bAsync = true; 186 | 187 | //Only Sync Mode 188 | bool bStartWarmup = false; 189 | bool bStartRender = false; 190 | 191 | /** 192 | * 193 | */ 194 | FSceneViewStateReference SceneViewState; 195 | 196 | UPROPERTY() 197 | UTextureRenderTarget2D* mRTT2D = nullptr; 198 | 199 | ECaptureState CaptureState = ECaptureState::Initilize; 200 | 201 | //预渲染帧数 202 | uint8 PreRenderingFrameNum = 2; 203 | uint8 CurPreFrame = 0; 204 | 205 | UPROPERTY() 206 | APostProcessVolume* mPP = nullptr; 207 | 208 | UPROPERTY() 209 | class UMaterial* Mat_PPGamma; 210 | 211 | UPROPERTY() 212 | class UMaterialInstanceDynamic* MatInsDyn_PPGamma; 213 | }; 214 | -------------------------------------------------------------------------------- /Source/QRender/Public/QRender.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/ModuleInterface.h" 7 | /**/ 8 | class FRenderGModule : public IModuleInterface 9 | { 10 | public: 11 | // IModuleInterface interface 12 | virtual void StartupModule() override; 13 | virtual void ShutdownModule() override; 14 | 15 | }; 16 | -------------------------------------------------------------------------------- /Source/QRender/QRender.build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | using System; 3 | using System.IO; 4 | using UnrealBuildTool; 5 | 6 | public class QRender : ModuleRules 7 | { 8 | /// 9 | /// 10 | /// 11 | protected string PrivateDirectory 12 | { 13 | get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "Private/")); } 14 | } 15 | 16 | public QRender(ReadOnlyTargetRules Target) : base(Target) 17 | { 18 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 19 | PrivateIncludePaths.AddRange( 20 | new string[] { 21 | } 22 | ); 23 | 24 | Console.WriteLine(this.EngineDirectory); 25 | var AudioMixerInclude = Path.Combine(this.EngineDirectory, "Source/Runtime/AudioMixer/Private"); 26 | Console.WriteLine("==================", AudioMixerInclude); 27 | PrivateIncludePaths.Add(AudioMixerInclude); 28 | 29 | PublicDependencyModuleNames.AddRange(new string[] 30 | { 31 | "OpenCVHelper", 32 | "OpenCV", 33 | "AudioMixer", 34 | "AVEncoder", 35 | //"GameplayMediaEncoder" 36 | }); 37 | 38 | PublicDelayLoadDLLs.Add("mfplat.dll"); 39 | PublicDelayLoadDLLs.Add("mfuuid.dll"); 40 | PublicDelayLoadDLLs.Add("Mfreadwrite.dll"); 41 | 42 | PrivateDependencyModuleNames.AddRange( 43 | new string[] { 44 | "Core", 45 | "CoreUObject", 46 | "Engine", 47 | "ImageWrapper", 48 | "InputCore", 49 | "RenderCore", 50 | "Renderer", 51 | "Json", 52 | "JsonUtilities", 53 | //"ImageWriteQueue", 54 | "OpenColorIO", 55 | "OpenCVLensDistortion", 56 | "OpenCVLensCalibration", 57 | "RHI", 58 | "Slate", 59 | "SlateCore", 60 | "Landscape", 61 | //"MessageLog", 62 | //"MeshUtilities2", 63 | //"JsEnv", 64 | //"PuertsExtra" 65 | } 66 | ); 67 | 68 | if (Target.bBuildEditor == true) 69 | { 70 | PrivateDependencyModuleNames.Add("EditorFramework"); 71 | PrivateDependencyModuleNames.Add("UnrealEd"); 72 | PrivateDependencyModuleNames.Add("OpenColorIOEditor"); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Source/QSlateFileDialogs/Private/SlateFileDialogsModule.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "CoreMinimal.h" 4 | #include "Modules/ModuleManager.h" 5 | #include "SlateFileDialogs.h" 6 | #include "SlateFileDialogsStyles.h" 7 | #include "SlateFileDlgWindow.h" 8 | 9 | void FSlateFileDialogsModule::StartupModule() 10 | { 11 | SlateFileDialog = new FSlateFileDialogsModule(); 12 | 13 | FileDialogStyle = new FSlateFileDialogsStyle; 14 | FileDialogStyle->Initialize(); 15 | } 16 | 17 | 18 | void FSlateFileDialogsModule::ShutdownModule() 19 | { 20 | if (SlateFileDialog != NULL) 21 | { 22 | FileDialogStyle->Shutdown(); 23 | delete FileDialogStyle; 24 | 25 | delete SlateFileDialog; 26 | SlateFileDialog = NULL; 27 | } 28 | } 29 | 30 | 31 | bool FSlateFileDialogsModule::OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, 32 | const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames, int32& OutFilterIndex) 33 | { 34 | FSlateFileDlgWindow dialog(FileDialogStyle); 35 | return dialog.OpenFileDialog(ParentWindowHandle, DialogTitle, DefaultPath, DefaultFile, FileTypes, Flags, OutFilenames, OutFilterIndex); 36 | } 37 | 38 | 39 | bool FSlateFileDialogsModule::OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, 40 | const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames) 41 | { 42 | FSlateFileDlgWindow dialog(FileDialogStyle); 43 | return dialog.OpenFileDialog(ParentWindowHandle, DialogTitle, DefaultPath, DefaultFile, FileTypes, Flags, OutFilenames); 44 | } 45 | 46 | bool FSlateFileDialogsModule::OpenDirectoryDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, 47 | FString& OutFoldername) 48 | { 49 | FSlateFileDlgWindow dialog(FileDialogStyle); 50 | 51 | return dialog.OpenDirectoryDialog(ParentWindowHandle, DialogTitle, DefaultPath, OutFoldername); 52 | } 53 | 54 | 55 | bool FSlateFileDialogsModule::SaveFileDialog( const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, 56 | const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames) 57 | { 58 | FSlateFileDlgWindow dialog(FileDialogStyle); 59 | return dialog.SaveFileDialog(ParentWindowHandle, DialogTitle, DefaultPath, DefaultFile, FileTypes, Flags, OutFilenames); 60 | } 61 | 62 | 63 | ISlateFileDialogsModule* FSlateFileDialogsModule::Get() 64 | { 65 | return SlateFileDialog; 66 | } 67 | 68 | IMPLEMENT_MODULE(FSlateFileDialogsModule, QSlateFileDialogs); 69 | -------------------------------------------------------------------------------- /Source/QSlateFileDialogs/Private/SlateFileDialogsPrivate.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | #define HIDE_HIDDEN_FILES 1 8 | #define MAX_FILTER_LENGTH 8192 9 | #define MAX_PATH_LENGTH 8192 10 | 11 | #define ENABLE_DIRECTORY_WATCHER 1 12 | -------------------------------------------------------------------------------- /Source/QSlateFileDialogs/Private/SlateFileDialogsStyles.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "SlateFileDialogsStyles.h" 4 | #include "Styling/SlateStyleRegistry.h" 5 | #include "Styling/SlateTypes.h" 6 | #include "Styling/CoreStyle.h" 7 | 8 | TSharedPtr< FSlateStyleSet > FSlateFileDialogsStyle::StyleInstance = nullptr; 9 | 10 | #define IMAGE_BRUSH( RelativePath, ... ) FSlateImageBrush(Style->RootToContentDir(RelativePath, TEXT(".png")), __VA_ARGS__) 11 | #define BOX_BRUSH( RelativePath, ... ) FSlateBoxBrush(Style->RootToContentDir(RelativePath, TEXT(".png")), __VA_ARGS__) 12 | #define BORDER_BRUSH( RelativePath, ... ) FSlateBorderBrush(Style->RootToContentDir(RelativePath, TEXT(".png")), __VA_ARGS__) 13 | #define DEFAULT_FONT(...) FCoreStyle::GetDefaultFontStyle(__VA_ARGS__) 14 | 15 | 16 | void FSlateFileDialogsStyle::Initialize() 17 | { 18 | if (!StyleInstance.IsValid()) 19 | { 20 | StyleInstance = Create(); 21 | FSlateStyleRegistry::RegisterSlateStyle(*StyleInstance); 22 | } 23 | } 24 | 25 | 26 | void FSlateFileDialogsStyle::Shutdown() 27 | { 28 | FSlateStyleRegistry::UnRegisterSlateStyle(*StyleInstance); 29 | ensure(StyleInstance.IsUnique()); 30 | StyleInstance.Reset(); 31 | } 32 | 33 | 34 | FName FSlateFileDialogsStyle::GetStyleSetName() 35 | { 36 | static FName StyleSetName(TEXT("SlateFileDialogsStyle")); 37 | return StyleSetName; 38 | } 39 | 40 | 41 | const FSlateStyleSet *FSlateFileDialogsStyle::Get() 42 | { 43 | return StyleInstance.Get(); 44 | } 45 | 46 | 47 | TSharedPtr< FSlateStyleSet > FSlateFileDialogsStyle::Create() 48 | { 49 | TSharedPtr< FSlateStyleSet > Style = MakeShareable(new FSlateStyleSet(FSlateFileDialogsStyle::GetStyleSetName())); 50 | Style->SetContentRoot(FPaths::EngineContentDir()); 51 | 52 | const FVector2D Icon10x10(10.0f, 10.0f); 53 | const FVector2D Icon16x16(16.0f, 16.0f); 54 | const FVector2D Icon24x24(24.0f, 24.0f); 55 | const FVector2D Icon64x64(64.0f, 64.0f); 56 | 57 | const FSlateColor InvertedForeground(FLinearColor(0.0f, 0.0f, 0.0f)); 58 | const FSlateColor SelectionColor(FLinearColor(0.701f, 0.225f, 0.003f)); 59 | const FSlateColor SelectionColor_Inactive(FLinearColor(0.25f, 0.25f, 0.25f)); 60 | const FSlateColor SelectionColor_Pressed(FLinearColor(0.701f, 0.225f, 0.003f)); 61 | 62 | 63 | // SButton defaults... 64 | const FButtonStyle Button = FButtonStyle() 65 | .SetNormal( BOX_BRUSH( "Slate/Common/Button", FVector2D(32,32), 8.0f/32.0f ) ) 66 | .SetHovered( BOX_BRUSH( "Slate/Common/Button_Hovered", FVector2D(32,32), 8.0f/32.0f ) ) 67 | .SetPressed( BOX_BRUSH( "Slate/Common/Button_Pressed", FVector2D(32,32), 8.0f/32.0f ) ) 68 | .SetDisabled( BOX_BRUSH( "Slate/Common/Button_Disabled", 8.0f/32.0f ) ) 69 | .SetNormalPadding( FMargin( 2,2,2,2 ) ) 70 | .SetPressedPadding( FMargin( 2,3,2,1 ) ); 71 | { 72 | Style->Set( "Button", Button ); 73 | 74 | Style->Set( "InvertedForeground", InvertedForeground ); 75 | } 76 | 77 | Style->Set("SlateFileDialogs.Dialog", DEFAULT_FONT("Regular", 10)); 78 | Style->Set("SlateFileDialogs.DialogBold", DEFAULT_FONT("Bold", 10)); 79 | Style->Set("SlateFileDialogs.DialogLarge", DEFAULT_FONT("Bold", 16)); 80 | Style->Set("SlateFileDialogs.DirectoryItem", DEFAULT_FONT("Bold", 11)); 81 | Style->Set( "SlateFileDialogs.GroupBorder", new BOX_BRUSH( "Slate/Common/GroupBorder", FMargin(4.0f/16.0f) ) ); 82 | 83 | Style->Set("SlateFileDialogs.Folder16", new IMAGE_BRUSH("SlateFileDialogs/Icons/icon_file_folder_16x", Icon16x16)); 84 | Style->Set("SlateFileDialogs.Folder24", new IMAGE_BRUSH("SlateFileDialogs/Icons/icon_file_folder_40x", Icon24x24)); 85 | Style->Set("SlateFileDialogs.NewFolder24", new IMAGE_BRUSH("SlateFileDialogs/Icons/icon_new_folder_40x", Icon24x24)); 86 | Style->Set("SlateFileDialogs.BrowseBack24", new IMAGE_BRUSH("SlateFileDialogs/Common/back_arrow_40x", Icon24x24)); 87 | Style->Set("SlateFileDialogs.BrowseForward24", new IMAGE_BRUSH("SlateFileDialogs/Common/forward_arrow_40x", Icon24x24)); 88 | Style->Set("SlateFileDialogs.WhiteBackground", new IMAGE_BRUSH("SlateFileDialogs/Common/Window/WindowWhite", Icon64x64)); 89 | 90 | Style->Set("SlateFileDialogs.UAsset16", new IMAGE_BRUSH("SlateFileDialogs/Icons/icon_uasset_24x", Icon16x16)); 91 | Style->Set("SlateFileDialogs.UProject16", new IMAGE_BRUSH("SlateFileDialogs/Icons/icon_uproject_24x", Icon16x16)); 92 | Style->Set("SlateFileDialogs.Model3D", new IMAGE_BRUSH("SlateFileDialogs/Icons/icon_model_24x", Icon16x16)); 93 | Style->Set("SlateFileDialogs.Video", new IMAGE_BRUSH("SlateFileDialogs/Icons/icon_video_24x", Icon16x16)); 94 | Style->Set("SlateFileDialogs.Audio", new IMAGE_BRUSH("SlateFileDialogs/Icons/icon_audio_24x", Icon16x16)); 95 | Style->Set("SlateFileDialogs.Image", new IMAGE_BRUSH("SlateFileDialogs/Icons/icon_image_24x", Icon16x16)); 96 | Style->Set("SlateFileDialogs.TextFile", new IMAGE_BRUSH("SlateFileDialogs/Icons/icon_text_24x", Icon16x16)); 97 | Style->Set("SlateFileDialogs.PlaceHolder", new IMAGE_BRUSH("SlateFileDialogs/Icons/icon_skull_16x", Icon16x16)); 98 | 99 | 100 | Style->Set( "SlateFileDialogs.PathDelimiter", new IMAGE_BRUSH( "SlateFileDialogs/Common/SmallArrowRight", Icon10x10 ) ); 101 | 102 | Style->Set( "SlateFileDialogs.PathText", FTextBlockStyle() 103 | .SetFont( DEFAULT_FONT( "Bold", 11 ) ) 104 | .SetColorAndOpacity( FLinearColor( 1.0f, 1.0f, 1.0f ) ) 105 | .SetHighlightColor( FLinearColor( 1.0f, 1.0f, 1.0f ) ) 106 | .SetHighlightShape(BOX_BRUSH("Slate/Common/TextBlockHighlightShape", FMargin(3.f /8.f))) 107 | .SetShadowOffset( FVector2D( 1,1 ) ) 108 | .SetShadowColorAndOpacity( FLinearColor(0,0,0,0.9f) ) ); 109 | 110 | Style->Set("SlateFileDialogs.FlatButton", FButtonStyle(Button) 111 | .SetNormal(FSlateNoResource()) 112 | .SetHovered(BOX_BRUSH("SlateFileDialogs/Common/FlatButton", 2.0f / 8.0f, SelectionColor)) 113 | .SetPressed(BOX_BRUSH("SlateFileDialogs/Common/FlatButton", 2.0f / 8.0f, SelectionColor_Pressed)) 114 | ); 115 | 116 | return Style; 117 | } 118 | 119 | 120 | #undef IMAGE_BRUSH 121 | #undef BOX_BRUSH 122 | #undef BORDER_BRUSH 123 | #undef DEFAULT_FONT 124 | -------------------------------------------------------------------------------- /Source/QSlateFileDialogs/Public/ISlateFileDialogModule.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/ModuleInterface.h" 7 | 8 | /** 9 | * Interface for slate file dialog modules. 10 | */ 11 | class ISlateFileDialogsModule : public IModuleInterface 12 | { 13 | public: 14 | /** 15 | * Virtual destructor. 16 | */ 17 | virtual ~ISlateFileDialogsModule( ) { } 18 | 19 | virtual bool OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, 20 | const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames, int32& OutFilterIndex) 21 | { 22 | return false; 23 | } 24 | 25 | virtual bool OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, 26 | const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames) 27 | { 28 | return false; 29 | } 30 | 31 | virtual bool OpenDirectoryDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, 32 | FString& OutFoldername) 33 | { 34 | return false; 35 | } 36 | 37 | virtual bool SaveFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, 38 | const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames) 39 | { 40 | return false; 41 | } 42 | 43 | virtual ISlateFileDialogsModule* Get() { return nullptr; } 44 | 45 | private: 46 | ISlateFileDialogsModule *SlateFileDialog; 47 | }; 48 | -------------------------------------------------------------------------------- /Source/QSlateFileDialogs/Public/SlateFileDialogs.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "ISlateFileDialogModule.h" 7 | 8 | class FSlateFileDialogsStyle; 9 | 10 | class FSlateFileDialogsModule : public ISlateFileDialogsModule 11 | { 12 | public: 13 | 14 | // IModuleInterface interface 15 | 16 | virtual void StartupModule() override; 17 | virtual void ShutdownModule() override; 18 | 19 | public: 20 | //ISlateFileDialogModule interface 21 | 22 | bool OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, 23 | const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames, int32& OutFilterIndex); 24 | 25 | bool OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, 26 | const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames); 27 | 28 | bool OpenDirectoryDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, 29 | FString& OutFoldername); 30 | 31 | bool SaveFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, 32 | const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray& OutFilenames); 33 | 34 | ISlateFileDialogsModule* Get(); 35 | 36 | FSlateFileDialogsStyle *GetFileDialogsStyle() { return FileDialogStyle; } 37 | 38 | private: 39 | ISlateFileDialogsModule *SlateFileDialog; 40 | 41 | FSlateFileDialogsStyle *FileDialogStyle; 42 | }; 43 | -------------------------------------------------------------------------------- /Source/QSlateFileDialogs/Public/SlateFileDialogsStyles.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Fonts/SlateFontInfo.h" 7 | #include "Styling/SlateStyle.h" 8 | 9 | class FSlateFileDialogsStyle 10 | { 11 | public: 12 | static void Initialize(); 13 | static void Shutdown(); 14 | static const FSlateStyleSet *Get(); 15 | static FName GetStyleSetName(); 16 | 17 | static const FSlateBrush * GetBrush(FName PropertyName, const ANSICHAR* Specifier = NULL) 18 | { 19 | return StyleInstance->GetBrush(PropertyName, Specifier); 20 | } 21 | 22 | static FSlateFontInfo GetFontStyle(FName PropertyName, const ANSICHAR* Specifier = NULL) 23 | { 24 | return StyleInstance->GetFontStyle(PropertyName, Specifier); 25 | } 26 | 27 | private: 28 | static TSharedPtr Create(); 29 | static TSharedPtr StyleInstance; 30 | }; 31 | -------------------------------------------------------------------------------- /Source/QSlateFileDialogs/QSlateFileDialogs.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | using System; 3 | using System.IO; 4 | using UnrealBuildTool; 5 | 6 | public class QSlateFileDialogs : ModuleRules 7 | { 8 | protected string PrivateDirectory 9 | { 10 | get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "Private/")); } 11 | } 12 | 13 | 14 | public QSlateFileDialogs(ReadOnlyTargetRules Target) : base(Target) 15 | { 16 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 17 | PrivatePCHHeaderFile = Path.GetFullPath(Path.Combine(PrivateDirectory, "SlateFileDialogsPrivate.h")); 18 | 19 | PrivateDependencyModuleNames.AddRange( 20 | new string[] { 21 | "Core" , 22 | "CoreUObject" , 23 | "InputCore" , 24 | "Slate" , 25 | "SlateCore" , 26 | "DirectoryWatcher" , 27 | } 28 | ); 29 | 30 | PrivateIncludePaths.AddRange( 31 | new string[] { 32 | PrivateDirectory, 33 | } 34 | ); 35 | 36 | PrivateIncludePathModuleNames.Add("TargetPlatform"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Source/QUMG/QUMG.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | using System; 3 | using System.IO; 4 | using UnrealBuildTool; 5 | 6 | public class QUMG : ModuleRules 7 | { 8 | /// 9 | /// 10 | /// 11 | protected string PrivateDirectory 12 | { 13 | get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "Private/")); } 14 | } 15 | 16 | public QUMG(ReadOnlyTargetRules Target) : base(Target) 17 | { 18 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 19 | //PrivatePCHHeaderFile = Path.GetFullPath(Path.Combine(ModuleDirectory, "QUMGPrivate.h")); 20 | 21 | PrivateIncludePaths.Add(PrivateDirectory); 22 | 23 | PublicIncludePaths.Add(Path.GetFullPath(ModuleDirectory)); 24 | 25 | 26 | bEnforceIWYU = false; 27 | 28 | PublicDependencyModuleNames.AddRange( 29 | new string[] { 30 | "Core" , 31 | "CoreUObject" , 32 | "Engine" , 33 | "InputCore" , 34 | "RenderCore" , 35 | "RHI" , 36 | "Slate" , 37 | "SlateCore" , 38 | "UMG" , 39 | "WebBrowser" , 40 | "HTTP" 41 | } 42 | ); 43 | 44 | PrivateDependencyModuleNames.AddRange( 45 | new string[] 46 | { 47 | 48 | }); 49 | 50 | if (Target.bBuildEditor || Target.Platform == UnrealTargetPlatform.Android) 51 | { 52 | PrivateIncludePathModuleNames.AddRange( 53 | new string[] 54 | { 55 | "WebBrowserTexture" 56 | } 57 | ); 58 | 59 | PrivateDependencyModuleNames.AddRange( 60 | new string[] 61 | { 62 | "WebBrowserTexture" 63 | } 64 | ); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Source/QUMG/QUMG.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "QUMG.h" 4 | #define LOCTEXT_NAMESPACE "FQUMGModule" 5 | 6 | void FQUMGModule::StartupModule() 7 | { 8 | //UE_LOG(LogTemp, Log, TEXT("-------------------------------------------------------------------- QUMG")) 9 | } 10 | 11 | 12 | void FQUMGModule::ShutdownModule() 13 | { 14 | } 15 | 16 | #undef LOCTEXT_NAMESPACE 17 | 18 | IMPLEMENT_MODULE(FQUMGModule, QUMG); 19 | -------------------------------------------------------------------------------- /Source/QUMG/QUMG.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/ModuleInterface.h" 7 | /**/ 8 | class FQUMGModule : public IModuleInterface 9 | { 10 | public: 11 | // IModuleInterface interface 12 | virtual void StartupModule() override; 13 | virtual void ShutdownModule() override; 14 | 15 | }; 16 | -------------------------------------------------------------------------------- /Source/QUMG/UMG/Dialog/DialogManager.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "DialogManager.h" 5 | 6 | -------------------------------------------------------------------------------- /Source/QUMG/UMG/Dialog/DialogManager.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "UObject/NoExportTypes.h" 7 | #include "DialogManager.generated.h" 8 | 9 | /** 10 | * 11 | */ 12 | UCLASS() 13 | class QUMG_API UDialogManager : public UObject 14 | { 15 | GENERATED_BODY() 16 | public: 17 | 18 | }; -------------------------------------------------------------------------------- /Source/QUMG/UMG/Dialog/Interface/IQDialogInterface.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "IQDialogInterface.h" 5 | 6 | UQDialogInterface::UQDialogInterface(const FObjectInitializer & PCIP) 7 | :Super(PCIP) 8 | { 9 | 10 | } 11 | 12 | 13 | 14 | 15 | // 16 | //void IQDialogInterface::Close_Implementation() {} 17 | //void IQDialogInterface::Maximalize_Implementation() {} 18 | //void IQDialogInterface::Minimalize_Implementation() {} -------------------------------------------------------------------------------- /Source/QUMG/UMG/Dialog/Interface/IQDialogInterface.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | #include "UObject/Interface.h" 8 | 9 | #include "IQDialogInterface.generated.h" 10 | 11 | UINTERFACE(BlueprintType, Meta= (CannotImplementInterfaceInBlueprint)) 12 | class QUMG_API UQDialogInterface : public UInterface 13 | { 14 | GENERATED_UINTERFACE_BODY() 15 | }; 16 | 17 | /** 18 | * 19 | */ 20 | class QUMG_API IQDialogInterface : public IInterface 21 | { 22 | GENERATED_IINTERFACE_BODY() 23 | /** */ 24 | public: 25 | 26 | UFUNCTION(BlueprintCallable ,Category = "QDialog" ) 27 | virtual void Close () {} 28 | 29 | 30 | //virtual void Close_Implementation(); 31 | 32 | //UFUNCTION(BlueprintNativeEvent, Category = "QDialog") 33 | //void Maximalize(); 34 | ////virtual void Maximalize_Implementation(); 35 | // 36 | //UFUNCTION(BlueprintNativeEvent,Category = "QDialog") 37 | //void Minimalize(); 38 | //virtual void Minimalize_Implementation(); 39 | 40 | }; 41 | 42 | 43 | -------------------------------------------------------------------------------- /Source/QUMG/UMG/Dialog/QDialogContainer.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | #include "Components/Border.h" 8 | #include "Fonts/SlateFontInfo.h" 9 | #include "QDialogContainer.generated.h" 10 | 11 | /** 12 | * 13 | */ 14 | //DECLARE_EVENT_OneParam(IAssetRegistry, FAssetAddedEvent, const FAssetData&); 15 | 16 | 17 | UENUM(BlueprintType) 18 | enum class EM_DialogScaleDirection : uint8 19 | { 20 | EM_None = 0 UMETA(DisplayName = "None"), 21 | EM_Increase UMETA(DisplayName = "Increase"), 22 | EM_Decrease UMETA(DisplayName = "Decrease") 23 | }; 24 | 25 | UCLASS(BlueprintType) 26 | class QUMG_API UQDialogContainer : public UBorder 27 | { 28 | GENERATED_UCLASS_BODY() 29 | 30 | public: 31 | UQDialogContainer(); 32 | 33 | public: 34 | DECLARE_EVENT_ThreeParams(FString, FEvent_OnTitleMouseDown, UQDialogContainer*, const FGeometry&, const FPointerEvent&) 35 | FEvent_OnTitleMouseDown& OnTitleMouseDown() { return Event_OnTitleMouseDown; } 36 | 37 | DECLARE_EVENT_ThreeParams(FString, FEvent_OnTitleMouseUp, UQDialogContainer*, const FGeometry&, const FPointerEvent&) 38 | FEvent_OnTitleMouseUp& OnTitleMouseUp() { return Event_OnTitleMouseUp; } 39 | 40 | DECLARE_EVENT_ThreeParams(FString, FEvent_OnMouseMove, UQDialogContainer*, const FGeometry&, const FPointerEvent&) 41 | FEvent_OnMouseMove& OnMouseMove() { return Event_OnMouseMove; } 42 | 43 | // 44 | DECLARE_EVENT_ThreeParams(FString, FEvent_OnResizeSizeComplated, UQDialogContainer*, const FGeometry&, const FPointerEvent&) 45 | FEvent_OnResizeSizeComplated& OnResizeSizeComplated() { return Event_OnResizeSizeComplated; } 46 | 47 | //true is axis +, flase is axis -; 48 | DECLARE_EVENT_FiveParams(FString, FEvent_OnResizingSize, UQDialogContainer*, EM_DialogScaleDirection, EM_DialogScaleDirection, const FGeometry&, const FPointerEvent&) 49 | FEvent_OnResizingSize& OnResizingSize() { return Event_OnResizingSize; } 50 | 51 | DECLARE_EVENT_OneParam(FString, FEvent_OnClose, UQDialogContainer*) 52 | FEvent_OnClose& OnClose() { return Event_OnClose; } 53 | 54 | #pragma region Event 55 | //UInterface 56 | DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FEvent_OnClose_BP, UQDialogContainer*, target); 57 | UPROPERTY(BlueprintAssignable, Category = "Button|Event") 58 | FEvent_OnClose_BP OnClose_BP; 59 | 60 | #pragma endregion Event 61 | 62 | private: 63 | FEvent_OnTitleMouseDown Event_OnTitleMouseDown; 64 | FEvent_OnTitleMouseUp Event_OnTitleMouseUp; 65 | FEvent_OnMouseMove Event_OnMouseMove; 66 | 67 | FEvent_OnResizingSize Event_OnResizingSize; 68 | FEvent_OnResizeSizeComplated Event_OnResizeSizeComplated; 69 | 70 | FEvent_OnClose Event_OnClose; 71 | 72 | #if WITH_EDITOR 73 | public: 74 | // UWidget interface 75 | virtual const FText GetPaletteCategory() override; 76 | // End UWidget interface 77 | #endif 78 | 79 | public: 80 | 81 | //左右 82 | TSharedPtr Border_ML; 83 | TSharedPtr Border_MR; 84 | 85 | //标题区 86 | TSharedPtr Border_MShortL; 87 | TSharedPtr Border_MShortR; 88 | 89 | //顶部 90 | TSharedPtr Border_TL; 91 | TSharedPtr Border_TC; 92 | TSharedPtr Border_TR; 93 | 94 | //底部 95 | TSharedPtr Border_BL; 96 | TSharedPtr Border_BC; 97 | TSharedPtr Border_BR; 98 | 99 | 100 | public: 101 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "QDialog Widget") 102 | /** */ 103 | FVector2D MaxSize = FVector2D{ 1280.0f, 1024.0f }; 104 | 105 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "QDialog Widget") 106 | /** */ 107 | FVector2D MinSize = FVector2D{ 320.0f, 480.0f }; 108 | 109 | 110 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "QDialog Widget") 111 | TSubclassOf DefaultTitlebarClass; 112 | 113 | protected: 114 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "QDialog Widget") 115 | /** */ 116 | FMargin DialogBorderSize = { 6.0f, 6.0f, 6.0f, 6.0f }; 117 | 118 | protected: 119 | /** */ 120 | virtual TSharedRef RebuildWidget() override; 121 | 122 | /** */ 123 | TSharedRef CreateTitlebar(); 124 | protected: 125 | 126 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "QDialog Widget") 127 | /** */ 128 | FSlateBrush TitleBrush; 129 | 130 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "QDialog Widget") 131 | /** */ 132 | FSlateBrush BorderBrush; 133 | 134 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "QDialog Widget") 135 | /** */ 136 | FSlateBrush BorderLineBrush; 137 | 138 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "QDialog Widget") 139 | /** */ 140 | FLinearColor BorderColor; 141 | 142 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "QDialog Widget") 143 | /** */ 144 | FLinearColor TitleBrushColor; 145 | 146 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "QDialog Widget") 147 | /** */ 148 | FText TitleText; 149 | 150 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "QDialog Widget") 151 | /** */ 152 | FSlateFontInfo DefaultFont; 153 | 154 | protected: 155 | FReply HandleTitleBarMouseDown (const FGeometry& geo, const FPointerEvent& ev); 156 | FReply HandleTitleBarMouseUp (const FGeometry& geo, const FPointerEvent& ev); 157 | 158 | void HandleDialogTitleBarMouseDown ( const FGeometry& geo, const FPointerEvent& ev); 159 | void HandleDialogTitleBarMouseUp ( const FGeometry& geo, const FPointerEvent& ev); 160 | 161 | FReply HandleMouseMove ( const FGeometry& geo, const FPointerEvent& ev ); 162 | FReply HandleBorderAreaDown ( const FGeometry& geo, const FPointerEvent& ev ); 163 | FReply HandleBorderAreaUp ( const FGeometry& geo, const FPointerEvent& ev ); 164 | 165 | FReply HandleCloseBtnClick(); 166 | 167 | void HandleClose(); 168 | }; -------------------------------------------------------------------------------- /Source/QUMG/UMG/Dialog/QDialogTitlebar.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "QDialogTitlebar.h" 5 | 6 | #include "Components/Border.h" 7 | 8 | UQDialogTitlebar::UQDialogTitlebar(const FObjectInitializer & PCIP) 9 | : Super(PCIP) 10 | { 11 | } 12 | 13 | void UQDialogTitlebar::Close() 14 | { 15 | OnClose().Broadcast(); 16 | } 17 | 18 | void UQDialogTitlebar::NativePreConstruct() 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /Source/QUMG/UMG/Dialog/QDialogTitlebar.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Blueprint/UserWidget.h" 7 | 8 | #include "Interface/IQDialogInterface.h" 9 | 10 | #include "QDialogTitlebar.generated.h" 11 | 12 | /** 13 | * 14 | */ 15 | class UBorder; 16 | UCLASS(Abstract) 17 | class QUMG_API UQDialogTitlebar : public UUserWidget , public IQDialogInterface 18 | { 19 | GENERATED_UCLASS_BODY() 20 | 21 | public: 22 | UPROPERTY(BlueprintReadWrite , EditAnywhere , Category = "QDialog") 23 | FText Title ; 24 | 25 | protected: 26 | 27 | #pragma region interface 28 | UFUNCTION() 29 | virtual void Close(); 30 | 31 | #pragma endregion interface 32 | 33 | 34 | #pragma region UserWidget virtual function 35 | 36 | /** */ 37 | virtual void NativePreConstruct() override; 38 | 39 | #pragma endregion UserWidget virtual function 40 | 41 | #pragma region Event 42 | 43 | public: 44 | DECLARE_EVENT(FString, FEvent_OnClose); 45 | FEvent_OnClose& OnClose() 46 | { 47 | return Event_OnClose; 48 | } 49 | protected: 50 | FEvent_OnClose Event_OnClose; 51 | 52 | public: 53 | DECLARE_EVENT_TwoParams(FString ,FEvent_OnTileMouseButtonUp, const FGeometry& , const FPointerEvent& ); 54 | FEvent_OnTileMouseButtonUp & OnTitleMouseButtonUp() 55 | { 56 | return Event_OnTileMouseUp; 57 | } 58 | protected: 59 | FEvent_OnTileMouseButtonUp Event_OnTileMouseUp; 60 | 61 | public: 62 | DECLARE_EVENT_TwoParams(FString ,FEvent_OnTileMouseButtonDown, const FGeometry& , const FPointerEvent& ); 63 | FEvent_OnTileMouseButtonDown& OnTitleMouseButtonDown() 64 | { 65 | return Event_OnTileMouseDown; 66 | } 67 | //DECLARE_EVENT_TwoParams(FString, FEvent_OnTileMouseButtonDown, const FGeometry&, const FPointerEvent&); 68 | 69 | protected: 70 | FEvent_OnTileMouseButtonDown Event_OnTileMouseDown; 71 | 72 | 73 | #pragma endregion Event 74 | }; 75 | -------------------------------------------------------------------------------- /Source/QUMG/UMG/Dialog/QDialogWidget.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #include "QDialogWidget.h" 4 | 5 | #include "Components/CanvasPanel.h" 6 | #include "Components/CanvasPanelSlot.h" 7 | 8 | #include "Kismet/GameplayStatics.h" 9 | #include "Blueprint/WidgetBlueprintLibrary.h" 10 | #include "Blueprint/WidgetLayoutLibrary.h" 11 | 12 | #include "Kismet/KismetInputLibrary.h" 13 | #include "Kismet/KismetMathLibrary.h" 14 | 15 | 16 | #include "Runtime/Slate/Public/Widgets/Layout/SBorder.h" 17 | 18 | 19 | 20 | UQDialogWidget::UQDialogWidget( const FObjectInitializer & PCIP) 21 | :Super(PCIP) 22 | { 23 | 24 | } 25 | 26 | void UQDialogWidget::NativeOnInitialized() 27 | { 28 | Super::NativeOnInitialized(); 29 | } 30 | 31 | void UQDialogWidget::NativeConstruct() 32 | { 33 | Super::NativeConstruct(); 34 | 35 | UWidget* root_wgt = this->GetRootWidget(); 36 | UClass* temp_class = root_wgt->GetClass(); 37 | 38 | UCanvasPanel* root_canvas = Cast< UCanvasPanel >(root_wgt); 39 | check ( root_canvas ); 40 | 41 | if ( root_canvas == nullptr ) 42 | { 43 | UE_LOG(LogTemp, Error, TEXT("[Error]: root is not UCanvasPanel !!!! ")); 44 | return; 45 | } 46 | 47 | TArray children = root_canvas->GetAllChildren(); 48 | 49 | for (UWidget* wgt_item : children) 50 | { 51 | UQDialogContainer* dialog_item = Cast< UQDialogContainer >( wgt_item ); 52 | 53 | if (dialog_item != nullptr) 54 | { 55 | Arr_DialogContain.Add(dialog_item); 56 | 57 | UCanvasPanelSlot* temp_canvasSlot = Cast(dialog_item->Slot); 58 | 59 | //UE_LOG(LogTemp, Log,TEXT("[desired Size:] %s")); 60 | if ( temp_canvasSlot->GetSize().X < dialog_item->GetDesiredSize().X || 61 | temp_canvasSlot->GetSize().Y < dialog_item->GetDesiredSize().Y ) 62 | { 63 | FVector2D temp_size = temp_canvasSlot->GetSize(); 64 | temp_size.X = FMath::Max( temp_canvasSlot->GetSize().X, dialog_item->GetDesiredSize().X ); 65 | temp_size.Y = FMath::Max( temp_canvasSlot->GetSize().Y, dialog_item->GetDesiredSize().Y ); 66 | } 67 | 68 | this->BindEvent(dialog_item); 69 | } 70 | } 71 | } 72 | 73 | void UQDialogWidget::NativeTick(const FGeometry& MyGeometry, float InDeltaTime) 74 | { 75 | Super::NativeTick(MyGeometry, InDeltaTime); 76 | //处理位移和缩放 77 | 78 | { 79 | FVector2D newMousePos = UWidgetLayoutLibrary::GetMousePositionOnViewport(this); 80 | 81 | if ( bMove ) 82 | { 83 | UCanvasPanelSlot* canvas = Cast(DialogContainer->Slot); 84 | 85 | if (canvas != nullptr) 86 | { 87 | auto temp_vec = newMousePos - vec2d_oldMousePos; 88 | canvas->SetPosition(canvas->GetPosition() + temp_vec); 89 | } 90 | 91 | vec2d_oldMousePos = newMousePos; 92 | 93 | } 94 | 95 | if ( bResizing ) 96 | { 97 | UCanvasPanelSlot* canvas = Cast(DialogContainer->Slot); 98 | 99 | if (canvas == nullptr) 100 | { 101 | UE_LOG(LogTemp, Log, TEXT("[dialog warning]: canvas is not vaild.")); 102 | return; 103 | } 104 | 105 | FVector2D offset_vec = newMousePos - vec2d_oldMousePos; 106 | 107 | FVector2D canvasPos = canvas->GetPosition(); 108 | FVector2D canvasSize = canvas->GetSize(); 109 | 110 | FVector2D newPos = canvasPos; 111 | FVector2D newSize = canvasSize; 112 | 113 | switch ( XAxisDirection ) 114 | { 115 | case EM_DialogScaleDirection::EM_Increase : 116 | { 117 | // 正方向递增(右边拖拽) 118 | newPos.X = canvasPos.X ; 119 | newSize.X = FMath::Clamp(canvasSize.X + offset_vec.X, DialogContainer->MinSize.X, DialogContainer->MaxSize.X); 120 | break; 121 | } 122 | case EM_DialogScaleDirection::EM_Decrease : 123 | { 124 | float real_width = FMath::Clamp(canvasSize.X - offset_vec.X, DialogContainer->MinSize.X, DialogContainer->MaxSize.X); 125 | 126 | float difference_offset = real_width - ( canvasSize.X - offset_vec.X ); 127 | 128 | if (difference_offset == 0.0f) 129 | { 130 | newPos.X = canvasPos.X + offset_vec.X; 131 | newSize.X = canvasSize.X - offset_vec.X; 132 | } 133 | 134 | break; 135 | } 136 | default:{ break; } 137 | } 138 | 139 | switch ( YAxisDirection ) 140 | { 141 | case EM_DialogScaleDirection::EM_Increase: 142 | { 143 | newPos .Y = canvasPos.Y; 144 | 145 | newSize.Y = FMath::Clamp(canvasSize.Y + offset_vec.Y, DialogContainer->MinSize.Y, DialogContainer->MaxSize.Y); 146 | break; 147 | } 148 | case EM_DialogScaleDirection::EM_Decrease: 149 | { 150 | // step one: count offset value.` 151 | float real_height = FMath::Clamp(canvasSize.Y - offset_vec.Y, DialogContainer->MinSize.Y, DialogContainer->MaxSize.Y); 152 | 153 | float difference_offset = real_height - (canvasSize.Y - offset_vec.Y); 154 | if (difference_offset == 0.0f) 155 | { 156 | newPos.Y = canvasPos.Y + offset_vec.Y; 157 | newSize.Y = canvasSize.Y - offset_vec.Y; 158 | } 159 | 160 | break; 161 | } 162 | default: { break; } 163 | } 164 | 165 | canvas->SetPosition(newPos); 166 | canvas->SetSize(newSize); 167 | 168 | vec2d_oldMousePos = newMousePos; 169 | } 170 | } 171 | } 172 | 173 | FReply UQDialogWidget::NativeOnMouseButtonUp(const FGeometry & InGeometry, const FPointerEvent & InMouseEvent) 174 | { 175 | Super::NativeOnMouseButtonUp(InGeometry, InMouseEvent); 176 | 177 | 178 | if ( bResizing ) 179 | { 180 | bResizing = false; 181 | return FReply::Handled(); 182 | } 183 | else 184 | { 185 | return FReply::Unhandled(); 186 | } 187 | 188 | } 189 | 190 | TSharedRef UQDialogWidget::RebuildWidget() 191 | { 192 | return Super::RebuildWidget(); 193 | } 194 | 195 | void UQDialogWidget::HandleOnTitleBarDown(UQDialogContainer *target, const FGeometry & geo, const FPointerEvent & ev) 196 | { 197 | bMove = true; 198 | DialogContainer = target; 199 | 200 | if (target->Border_ML->IsHovered() || target->Border_MR->IsHovered()) 201 | { 202 | bResizing = true; 203 | } 204 | 205 | APlayerController* controller = UGameplayStatics::GetPlayerController(this, 0); 206 | vec2d_oldMousePos = UWidgetLayoutLibrary::GetMousePositionOnViewport(this); 207 | } 208 | 209 | void UQDialogWidget::HandleOnTitleBarUp(UQDialogContainer *target, const FGeometry & geo, const FPointerEvent & ev) 210 | { 211 | bMove = false; 212 | APlayerController *controller = UGameplayStatics::GetPlayerController(this, 0); 213 | } 214 | 215 | void UQDialogWidget::HandleOnMouseMove(UQDialogContainer *target, const FGeometry & geo, const FPointerEvent & ev) 216 | { 217 | } 218 | 219 | void UQDialogWidget::HandleOnResizingDialog( UQDialogContainer * target , 220 | EM_DialogScaleDirection XAsix , 221 | EM_DialogScaleDirection YAsix , 222 | const FGeometry &geo , 223 | const FPointerEvent &events ) 224 | { 225 | DialogContainer = target; 226 | bResizing = true; 227 | XAxisDirection = XAsix; 228 | YAxisDirection = YAsix; 229 | 230 | APlayerController* controller = UGameplayStatics::GetPlayerController(this, 0); 231 | 232 | vec2d_oldMousePos = UWidgetLayoutLibrary::GetMousePositionOnViewport(this); 233 | } 234 | 235 | void UQDialogWidget::HandleOnResizingDialogComplate(UQDialogContainer * target, const FGeometry & geo, const FPointerEvent & ev) 236 | { 237 | bResizing = false; 238 | APlayerController *controller = UGameplayStatics::GetPlayerController(this, 0); 239 | } 240 | 241 | void UQDialogWidget::HandleOnClose(UQDialogContainer *target) 242 | { 243 | target->RemoveFromParent(); 244 | Arr_DialogContain.Remove(target); 245 | 246 | if (Arr_DialogContain.Num() <= 0 ) 247 | { 248 | this->RemoveFromParent(); 249 | } 250 | 251 | this->OnClose().Broadcast(target); 252 | } 253 | 254 | void UQDialogWidget::BindEvent( UQDialogContainer * const container ) 255 | { 256 | 257 | container->OnTitleMouseDown().AddUObject(this, &UQDialogWidget::HandleOnTitleBarDown); 258 | container->OnTitleMouseUp().AddUObject(this, &UQDialogWidget::HandleOnTitleBarUp); 259 | container->OnClose().AddUObject(this, &UQDialogWidget::HandleOnClose); 260 | 261 | container->OnResizingSize().AddUObject(this, &UQDialogWidget::HandleOnResizingDialog); 262 | container->OnResizeSizeComplated().AddUObject(this, &UQDialogWidget::HandleOnResizingDialogComplate); 263 | } 264 | -------------------------------------------------------------------------------- /Source/QUMG/UMG/Dialog/QDialogWidget.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Blueprint/UserWidget.h" 7 | #include "umg/Dialog/QDialogContainer.h" 8 | #include "QDialogWidget.generated.h" 9 | 10 | 11 | /** 12 | * 13 | */ 14 | UCLASS(BlueprintType) 15 | class QUMG_API UQDialogWidget : public UUserWidget 16 | { 17 | GENERATED_UCLASS_BODY() 18 | 19 | public: 20 | UPROPERTY(BlueprintReadOnly, Category = "QDialog", Meta = (BindWidget) ) 21 | class UCanvasPanel *DialogCanvas = nullptr; 22 | 23 | UPROPERTY(BlueprintReadOnly, Category = "QDialog", Meta = (BindWidget) ) 24 | UBorder* Background = nullptr; 25 | 26 | public: 27 | protected: 28 | #pragma region event 29 | virtual void NativeOnInitialized() override; 30 | virtual void NativeConstruct() override; 31 | virtual void NativeTick(const FGeometry& MyGeometry, float InDeltaTime) override; 32 | 33 | virtual FReply NativeOnMouseButtonUp(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent) override; 34 | 35 | virtual TSharedRef RebuildWidget() override; 36 | #pragma endregion event 37 | 38 | protected: 39 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "QDialog") 40 | /** */ 41 | bool bMove = false; 42 | 43 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "QDialog") 44 | /** */ 45 | bool bResizing = false; 46 | 47 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "QDialog") 48 | /** */ 49 | FVector2D vec2d_oldMousePos; 50 | 51 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "QDialog") 52 | class UQDialogContainer *DialogContainer = nullptr; 53 | 54 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "QDialog") 55 | TArray< UQDialogContainer* > Arr_DialogContain; 56 | 57 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "QDialog") 58 | EM_DialogScaleDirection XAxisDirection; 59 | 60 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "QDialog") 61 | EM_DialogScaleDirection YAxisDirection; 62 | 63 | #pragma region Event and Delegate 64 | public: 65 | DECLARE_EVENT_OneParam(FString, FEvent_OnDialogClose, UQDialogContainer*) 66 | FEvent_OnDialogClose& OnClose() { return Event_OnClose; } 67 | 68 | protected: 69 | FEvent_OnDialogClose Event_OnClose; 70 | #pragma endregion 71 | 72 | protected: 73 | /** */ 74 | void HandleOnTitleBarDown(class UQDialogContainer*, const FGeometry & geo, const FPointerEvent & ev); 75 | 76 | /** */ 77 | void HandleOnTitleBarUp(class UQDialogContainer*, const FGeometry & geo, const FPointerEvent & ev); 78 | 79 | /** */ 80 | void HandleOnMouseMove(class UQDialogContainer*, const FGeometry & geo, const FPointerEvent & ev); 81 | 82 | /** */ 83 | void HandleOnResizingDialog(class UQDialogContainer *target, EM_DialogScaleDirection XAsix, EM_DialogScaleDirection YAsix, const FGeometry & geo, const FPointerEvent & ev); 84 | /** */ 85 | void HandleOnResizingDialogComplate(class UQDialogContainer *target, const FGeometry & geo, const FPointerEvent & ev); 86 | 87 | void HandleOnClose(class UQDialogContainer *target); 88 | 89 | void BindEvent(UQDialogContainer* const container); 90 | }; -------------------------------------------------------------------------------- /Source/QUMG/UMG/Dialog/Utils/QDialogBPLibrary.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "QDialogBPLibrary.h" 5 | 6 | 7 | void UQDialogBPLibrary::CreateDialog(TSubclassOf ContentClass,const FVector2D &position) 8 | { 9 | } 10 | -------------------------------------------------------------------------------- /Source/QUMG/UMG/Dialog/Utils/QDialogBPLibrary.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Kismet/BlueprintFunctionLibrary.h" 7 | #include "QDialogBPLibrary.generated.h" 8 | 9 | /** 10 | * 11 | */ 12 | UCLASS() 13 | class QUMG_API UQDialogBPLibrary : public UBlueprintFunctionLibrary 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | UFUNCTION(BlueprintCallable, Category = "QDialog | Helper") 19 | static void CreateDialog(TSubclassOf ContentClass,const FVector2D &position ); 20 | }; 21 | -------------------------------------------------------------------------------- /Source/QUMG/UMG/Splitter/QSpliter.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "QSpliter.h" 5 | 6 | #include "QSplitterWidget.h" 7 | 8 | #include "Components/Border.h" 9 | #include "Runtime/Slate/Public/Widgets/Layout/SBorder.h" 10 | 11 | #include "Runtime/UMG/Public/Components/PanelSlot.h" 12 | #include "umg/Splitter/QSplitterSlot.h" 13 | 14 | #include "Runtime/UMG/Public/Components/HorizontalBox.h" 15 | 16 | #define LOCTEXT_NAMESPACE "UMG" 17 | 18 | #if WITH_EDITOR 19 | const FText UQSpliter::GetPaletteCategory() 20 | { 21 | //UE_LOG(LogTemp, Log, TEXT(" GetPaletteCategory ")); 22 | 23 | return LOCTEXT("QUI", "QUI"); 24 | } 25 | #endif 26 | 27 | void UQSpliter::ReleaseSlateResources(bool bReleaseChildren) 28 | { 29 | Super::ReleaseSlateResources(bReleaseChildren); 30 | 31 | MySplitter.Reset(); 32 | } 33 | 34 | int32 UQSpliter::GetChildrenCountByNotCollapsed() const 35 | { 36 | if (!MySplitter) 37 | { 38 | return INDEX_NONE; 39 | } 40 | 41 | int32 count = 0; 42 | FChildren* Children = MySplitter->GetChildren(); 43 | 44 | for (int32 i = 0; i < this->GetChildrenCount();i ++ ) 45 | { 46 | UWidget* wgt = GetChildAt(i); 47 | if ( ESlateVisibility::Collapsed != wgt->GetVisibility() ) 48 | { 49 | count++; 50 | } 51 | } 52 | 53 | UE_LOG(LogTemp, Log, TEXT("[cccc] : %f"), this->GetChildrenCount()); 54 | 55 | return count; 56 | } 57 | 58 | float UQSpliter::GetCoefficientCountByNotCollapsed() const 59 | { 60 | if ( !MySplitter ) 61 | { 62 | return INDEX_NONE; 63 | } 64 | 65 | float count = 0; 66 | TArray arr_slots = this->GetSlots(); 67 | 68 | for (int32 i = 0; i < arr_slots.Num() ; i++) 69 | { 70 | UWidget* wgt = GetChildAt(i); 71 | if ( ESlateVisibility::Collapsed != wgt->GetVisibility() ) 72 | { 73 | UQSplitterSlot* temp_slot = Cast(arr_slots[i]); 74 | 75 | if ( !temp_slot ) 76 | { 77 | continue; 78 | } 79 | 80 | count += temp_slot->SizeValue; 81 | } 82 | } 83 | 84 | return count; 85 | } 86 | 87 | EOrientation UQSpliter::GetEOrientation() const 88 | { 89 | switch (this->Direction) 90 | { 91 | case EM_SplitterDirectionType::EM_Vertical: 92 | { 93 | return EOrientation::Orient_Vertical; 94 | } 95 | case EM_SplitterDirectionType::EM_Horizontal: 96 | { 97 | return EOrientation::Orient_Horizontal; 98 | } 99 | default: 100 | { 101 | return EOrientation::Orient_Horizontal; 102 | } 103 | } 104 | } 105 | 106 | ESplitterResizeMode::Type UQSpliter::GetESplitterResizeMode() const 107 | { 108 | switch (this->ResizeMode) 109 | { 110 | case EM_SplitterResizeMode::EM_FixedPosition: 111 | { 112 | return ESplitterResizeMode::FixedPosition; 113 | } 114 | case EM_SplitterResizeMode::EM_FixedSize: 115 | { 116 | return ESplitterResizeMode::FixedSize; 117 | } 118 | case EM_SplitterResizeMode::EM_Fill: 119 | { 120 | return ESplitterResizeMode::Fill; 121 | } 122 | default: 123 | { 124 | return ESplitterResizeMode::FixedPosition; 125 | } 126 | } 127 | } 128 | 129 | UClass * UQSpliter::GetSlotClass() const 130 | { 131 | UE_LOG(LogTemp, Log, TEXT(" GetSlotClass ")); 132 | 133 | return UQSplitterSlot::StaticClass(); 134 | } 135 | 136 | void UQSpliter::OnSlotAdded(UPanelSlot * slot) 137 | { 138 | if (!MySplitter.IsValid()) 139 | { 140 | return; 141 | } 142 | 143 | UE_LOG(LogTemp, Log, TEXT(" OnSlotAdded ")); 144 | 145 | CastChecked< UQSplitterSlot>(slot)->BuildSlot(MySplitter.ToSharedRef()); 146 | } 147 | 148 | void UQSpliter::OnSlotRemoved(UPanelSlot * slot) 149 | { 150 | // develop 151 | TSharedPtr Widget = slot->Content->GetCachedWidget(); 152 | 153 | if ( !MySplitter.IsValid() || 154 | !Widget.IsValid() ) 155 | { 156 | return; 157 | } 158 | 159 | FChildren* Children = MySplitter->GetChildren(); 160 | 161 | for (int32 i = 0; i < Children->Num(); i++ ) 162 | { 163 | TSharedRef tempWgt = Children->GetChildAt(i); 164 | 165 | if (Widget == tempWgt) 166 | { 167 | MySplitter->RemoveAt(i); 168 | break; 169 | } 170 | } 171 | } 172 | 173 | void UQSpliter::Handle_OnSplitteItemResize(UWidget* wgt,float val) 174 | { 175 | OnSplitteItemResize.Broadcast(wgt, val); 176 | 177 | UE_LOG(LogTemp, Log, TEXT(" Handle_OnSplitteItemResize ")); 178 | } 179 | 180 | TSharedRef UQSpliter::RebuildWidget() 181 | { 182 | MySplitter = SNew(SSplitterEx).Orientation ( this->GetEOrientation() ) 183 | .PhysicalSplitterHandleSize ( HandSize ) 184 | .HitDetectionSplitterHandleSize ( HandSize ) 185 | .ResizeMode ( this->GetESplitterResizeMode() ); 186 | 187 | for ( UPanelSlot* PanelSlot : Slots ) 188 | { 189 | if (UQSplitterSlot* TypedSlot = Cast(PanelSlot)) 190 | { 191 | TypedSlot->Parent = this; 192 | TypedSlot->BuildSlot( MySplitter.ToSharedRef() ); 193 | TypedSlot->OnSplitteItemResize().AddUObject(this, &UQSpliter::Handle_OnSplitteItemResize); 194 | } 195 | } 196 | 197 | return MySplitter.ToSharedRef(); 198 | } 199 | 200 | #undef LOCTEXT_NAMESPACE 201 | 202 | 203 | 204 | 205 | int32 SSplitterEx::OnPaint(const FPaintArgs& Args, 206 | const FGeometry& AllottedGeometry, 207 | const FSlateRect& MyCullingRect, 208 | FSlateWindowElementList& OutDrawElements, 209 | int32 LayerId, 210 | const FWidgetStyle& InWidgetStyle, 211 | bool bParentEnabled) const 212 | { 213 | 214 | FArrangedChildren ArrangedChildren(EVisibility::Visible); 215 | ArrangeChildren(AllottedGeometry, ArrangedChildren); 216 | 217 | int32 MaxLayerId = PaintArrangedChildren(Args, ArrangedChildren, AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled); 218 | 219 | const FSlateBrush* NormalHandleBrush = &Style->HandleNormalBrush; 220 | 221 | // Draw the splitter above any children 222 | MaxLayerId += 1; 223 | 224 | ///绘制分割线Make Box 225 | for (int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex) 226 | { 227 | //if (ChildIndex == 1) { continue; } 228 | const FGeometry& GeometryAfterSplitter = ArrangedChildren[FMath::Clamp(ChildIndex + 1, 0, ArrangedChildren.Num() - 1)].Geometry; 229 | 230 | const float HalfHitDetectionSplitterHandleSize = FMath::RoundToInt(HitDetectionSplitterHandleSize / 2.0f); 231 | const float HalfPhysicalSplitterHandleSize = PhysicalSplitterHandleSize; 232 | 233 | FVector2D HandleSize; 234 | FVector2D HandlePosition; 235 | 236 | if (Orientation == Orient_Horizontal) 237 | { 238 | HandleSize.Set(PhysicalSplitterHandleSize, GeometryAfterSplitter.Size.Y); 239 | HandlePosition.Set(-PhysicalSplitterHandleSize, 0); 240 | } 241 | else 242 | { 243 | HandleSize.Set(GeometryAfterSplitter.Size.X, PhysicalSplitterHandleSize); 244 | HandlePosition.Set(0, -PhysicalSplitterHandleSize); 245 | } 246 | 247 | if (HoveredHandleIndex != ChildIndex) 248 | { 249 | FSlateDrawElement::MakeBox( 250 | OutDrawElements, 251 | MaxLayerId, 252 | GeometryAfterSplitter.ToPaintGeometry(HandlePosition, HandleSize, 1.0f), 253 | NormalHandleBrush, 254 | ShouldBeEnabled(bParentEnabled) ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect, 255 | InWidgetStyle.GetColorAndOpacityTint() * NormalHandleBrush->TintColor.GetSpecifiedColor() 256 | ); 257 | } 258 | else 259 | { 260 | FSlateDrawElement::MakeBox( 261 | OutDrawElements, 262 | MaxLayerId, 263 | GeometryAfterSplitter.ToPaintGeometry(HandlePosition, HandleSize, 1.0f), 264 | &Style->HandleHighlightBrush, 265 | ShouldBeEnabled(bParentEnabled) ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect, 266 | InWidgetStyle.GetColorAndOpacityTint() * Style->HandleHighlightBrush.TintColor.GetSpecifiedColor() 267 | ); 268 | } 269 | } 270 | 271 | return MaxLayerId; 272 | } 273 | -------------------------------------------------------------------------------- /Source/QUMG/UMG/Splitter/QSpliter.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | #include "Runtime/UMG/Public/Components/PanelWidget.h" 8 | //#include "UMG/Splitter/CppWgt_BaseSplitter.h" 9 | #include "QSpliter.generated.h" 10 | 11 | 12 | 13 | UENUM(BlueprintType) 14 | enum class EM_SplitterDirectionType : uint8 15 | { 16 | EM_Vertical UMETA( DisplayName = "Vertical" ) , 17 | EM_Horizontal UMETA( DisplayName = "Horizontal" ) 18 | }; 19 | 20 | 21 | UENUM(BlueprintType) 22 | enum class EM_SplitterResizeMode : uint8 23 | { 24 | EM_FixedPosition UMETA( DisplayName = "FixedPosition" ) , 25 | EM_FixedSize UMETA( DisplayName = "FixedSize" ) , 26 | EM_Fill UMETA( DisplayName = "Fill" ) 27 | }; 28 | 29 | 30 | class SSplitterEx; 31 | 32 | /** 33 | * 34 | */ 35 | UCLASS() 36 | class QUMG_API UQSpliter : public UPanelWidget 37 | { 38 | GENERATED_BODY() 39 | public: 40 | 41 | #if WITH_EDITOR 42 | // UWidget interface 43 | virtual const FText GetPaletteCategory() override; 44 | 45 | // End UWidget interface 46 | #endif 47 | 48 | virtual void ReleaseSlateResources(bool bReleaseChildren) override; 49 | public: 50 | #pragma region Event 51 | 52 | DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnSplitteResize, UWidget*, wgt, float, val); 53 | UPROPERTY(BlueprintAssignable, Category = "Spliter | Event") 54 | FOnSplitteResize OnSplitteItemResize; 55 | 56 | #pragma endregion Event 57 | 58 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Variant") 59 | float HandSize = 8.0f; 60 | 61 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Variant") 62 | EM_SplitterDirectionType Direction = EM_SplitterDirectionType::EM_Horizontal; 63 | 64 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Variant") 65 | EM_SplitterResizeMode ResizeMode = EM_SplitterResizeMode::EM_FixedPosition; 66 | 67 | public: 68 | UFUNCTION(BlueprintCallable, Category = "Spliter | Function") 69 | ///获取未收起隐藏的Children数量 70 | int32 GetChildrenCountByNotCollapsed() const; 71 | 72 | UFUNCTION(BlueprintCallable, Category = "Spliter | Function") 73 | /// 获取系数总和计数 74 | float GetCoefficientCountByNotCollapsed() const; 75 | private: 76 | EOrientation GetEOrientation() const; 77 | ESplitterResizeMode::Type GetESplitterResizeMode() const; 78 | protected: 79 | 80 | // UPanelWidget 81 | virtual UClass* GetSlotClass() const override; 82 | virtual void OnSlotAdded(UPanelSlot* slot) override; 83 | virtual void OnSlotRemoved(UPanelSlot* slot) override; 84 | // End UPanelWidget 85 | protected: 86 | void Handle_OnSplitteItemResize(UWidget* wgt, float val); 87 | 88 | protected: 89 | TSharedPtr MySplitter; 90 | 91 | protected: 92 | // UWidget interface 93 | virtual TSharedRef RebuildWidget() override; 94 | // End of UWidget interface 95 | }; 96 | 97 | 98 | 99 | /** Splitter extend */ 100 | class QUMG_API SSplitterEx : public SSplitter 101 | { 102 | public: 103 | virtual int32 OnPaint(const FPaintArgs& Args, 104 | const FGeometry& AllottedGeometry, 105 | const FSlateRect& MyCullingRect, 106 | FSlateWindowElementList& OutDrawElements, 107 | int32 LayerId, 108 | const FWidgetStyle& InWidgetStyle, 109 | bool bParentEnabled) const override; 110 | }; 111 | 112 | -------------------------------------------------------------------------------- /Source/QUMG/UMG/Splitter/QSplitterSlot.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "QSplitterSlot.h" 4 | 5 | 6 | #include "QSpliter.h" 7 | 8 | #include "Components/Widget.h" 9 | 10 | #include "Engine/Engine.h" 11 | #include "Components/PanelWidget.h" 12 | 13 | 14 | 15 | ///////////////////////////////////////////////////// 16 | // UHorizontalBoxSlot 17 | 18 | UQSplitterSlot::UQSplitterSlot(const FObjectInitializer& ObjectInitializer) 19 | : Super(ObjectInitializer) 20 | { 21 | Slot = NULL; 22 | } 23 | 24 | void UQSplitterSlot::ReleaseSlateResources(bool bReleaseChildren) 25 | { 26 | Super::ReleaseSlateResources(bReleaseChildren); 27 | 28 | Slot = NULL; 29 | } 30 | 31 | void UQSplitterSlot::Handle_OnSlotResized(float val) 32 | { 33 | if (Slot == nullptr) 34 | { 35 | return; 36 | } 37 | 38 | Slot->SetSizeValue( val ); 39 | SizeValue = val; 40 | 41 | this->OnSplitteItemResize().Broadcast(Content, val); 42 | } 43 | 44 | UWidget * UQSplitterSlot::GetContentWidget() const 45 | { 46 | return this->Content; 47 | } 48 | 49 | float UQSplitterSlot::GetSize() const 50 | { 51 | UQSpliter* splitter = Cast(this->Parent); 52 | 53 | FVector2D size = splitter->GetCachedGeometry ().GetLocalSize(); 54 | 55 | float len = 0.0f; 56 | switch ( splitter->Direction ) 57 | { 58 | case EM_SplitterDirectionType::EM_Horizontal: 59 | { 60 | len = size.X; 61 | break; 62 | } 63 | case EM_SplitterDirectionType::EM_Vertical: 64 | { 65 | len = size.Y; 66 | break; 67 | } 68 | default: 69 | { 70 | len = size.Y; 71 | break; 72 | } 73 | } 74 | 75 | float factor = 0.0f; 76 | 77 | for (auto slot : splitter->GetSlots()) 78 | { 79 | UQSplitterSlot* SplitterSlot = Cast(slot); 80 | 81 | if ( SplitterSlot == nullptr ) 82 | { 83 | continue; 84 | } 85 | 86 | factor += SplitterSlot->SizeValue; 87 | } 88 | 89 | float ret_len = ( len / factor ) * SizeValue; 90 | 91 | return ret_len; 92 | } 93 | 94 | void UQSplitterSlot::BuildSlot(TSharedRef SplitterCom) 95 | { 96 | Slot = SplitterCom->AddSlot() 97 | [ 98 | Content == NULL ? SNullWidget::NullWidget : Content->TakeWidget() 99 | ].GetSlot(); 100 | 101 | //TBaseDelegate delegate_event; 102 | //delegate_event.BindUObject(this, &UQSplitterSlot::Handle_OnSlotResized); 103 | 104 | Slot->OnSlotResized().BindUObject(this, &UQSplitterSlot::Handle_OnSlotResized); 105 | } 106 | 107 | void UQSplitterSlot::SynchronizeProperties() 108 | { 109 | Super::SynchronizeProperties(); 110 | } 111 | -------------------------------------------------------------------------------- /Source/QUMG/UMG/Splitter/QSplitterSlot.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "UObject/ObjectMacros.h" 7 | #include "UObject/ScriptMacros.h" 8 | #include "Components/PanelSlot.h" 9 | #include "Components/SlateWrapperTypes.h" 10 | 11 | #include "Widgets/Layout/SSplitter.h" 12 | 13 | #include "QSplitterSlot.generated.h" 14 | 15 | UCLASS() 16 | class QUMG_API UQSplitterSlot : public UPanelSlot 17 | { 18 | GENERATED_UCLASS_BODY() 19 | public : 20 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Slot | QSpliter Slot") 21 | float SizeValue = 1.0f; 22 | 23 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Slot | QSpliter Slot") 24 | /// Unit DPI 25 | float MinSize = 0.0f; 26 | 27 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Slot | QSpliter Slot") 28 | /// Unit DPI 29 | float MaxSize = 0.0f; 30 | 31 | public: 32 | #pragma region event 33 | DECLARE_EVENT_TwoParams(FString, FEvent_OnSplitteItemResize, UWidget*, float) 34 | FEvent_OnSplitteItemResize& OnSplitteItemResize() { return Event_OnSplitteItemResize; } 35 | 36 | protected: 37 | FEvent_OnSplitteItemResize Event_OnSplitteItemResize; 38 | #pragma endregion event 39 | 40 | public: 41 | 42 | UFUNCTION(BlueprintCallable, Category = "Slot | QSpliter Slot") 43 | // 44 | UWidget * GetContentWidget() const; 45 | 46 | UFUNCTION(BlueprintCallable, Category = "Slot | QSpliter Slot") 47 | // 48 | float GetSize() const; 49 | public: 50 | // 51 | void BuildSlot(TSharedRef SplitterCom); 52 | 53 | #pragma region UPanelSlot Interface 54 | 55 | // UPanelSlot interface 56 | virtual void SynchronizeProperties() override; 57 | // End of UPanelSlot interface 58 | 59 | #pragma endregion UPanelSlot Interface 60 | 61 | 62 | // 63 | virtual void ReleaseSlateResources(bool bReleaseChildren) override; 64 | 65 | protected: 66 | void Handle_OnSlotResized(float val); 67 | 68 | private: 69 | SSplitter::FSlot* Slot; 70 | }; 71 | -------------------------------------------------------------------------------- /Source/QUMG/UMG/Splitter/QSplitterWidget.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #include "QSplitterWidget.h" 4 | 5 | #include "Slate.h" 6 | #include "Widgets/Layout/SConstraintCanvas.h" 7 | #include "Kismet/GameplayStatics.h" 8 | 9 | void SMySlateWidget::Construct(const FArguments& InArgs) 10 | { 11 | TSharedRef border = SNew(SBorder); 12 | 13 | border->SetBorderBackgroundColor(FLinearColor::Red); 14 | border->SetForegroundColor(FLinearColor(0, 255, 0, 0.5)); 15 | border->SetBorderImage(&brush); 16 | border->SetColorAndOpacity(FLinearColor::Green); 17 | 18 | TSharedRef border1 = SNew(SBorder); 19 | 20 | border1->SetBorderBackgroundColor(FLinearColor::Green); 21 | border1->SetForegroundColor(FLinearColor(0, 255, 0, 0.5)); 22 | border1->SetBorderImage(&brush); 23 | border1->SetColorAndOpacity(FLinearColor::Green); 24 | 25 | TSharedRef border2 = SNew(SBorder); 26 | 27 | border2->SetBorderBackgroundColor(FLinearColor::Blue); 28 | border2->SetForegroundColor(FLinearColor(0, 255, 0, 0.5)); 29 | border2->SetBorderImage(&brush); 30 | border2->SetColorAndOpacity(FLinearColor::Green); 31 | 32 | auto container = SNew(SVerticalBox) + SVerticalBox::Slot().FillHeight(1) 33 | [ 34 | SNew(SSplitter) 35 | + SSplitter::Slot() 36 | .Value(0.75f) 37 | [ 38 | border1 39 | ] 40 | + SSplitter::Slot() 41 | .Value(0.25f) 42 | [ 43 | border2 44 | ] 45 | ]; 46 | 47 | SConstraintCanvas::FSlot::FSlotArguments temp_slot = SConstraintCanvas::Slot(); 48 | temp_slot.Anchors(FAnchors(0.0f, 0.0f, 1.0f, 1.0f)) 49 | .Offset(FMargin(100.0f, 100.0f, 100.0f, 100.0f)) 50 | .ZOrder(1) 51 | .AttachWidget(container); 52 | 53 | SUserWidget::Construct( 54 | SUserWidget::FArguments() 55 | [ 56 | SNew(SConstraintCanvas) + temp_slot 57 | ] 58 | ); 59 | } 60 | 61 | TSharedRef SMySlateWidget::New() 62 | { 63 | return MakeShareable(new SMySlateWidget()); 64 | } 65 | 66 | #if WITH_EDITOR 67 | const FText UQSplitterWidget::GetPaletteCategory() 68 | { 69 | return NSLOCTEXT("UContenSlatetWidget", "QUI", "QUI"); 70 | } 71 | #endif 72 | 73 | TSharedRef UQSplitterWidget::RebuildWidget() 74 | { 75 | //auto temporary_wgt = CreateWidget(this, ins->ColorPickerUMGClass); 76 | TSharedRef border1 = SNew(SBorder); 77 | 78 | //temporary_wgt->TakeWidget(); 79 | 80 | auto container = SNew(SVerticalBox) + SVerticalBox::Slot().FillHeight(1) 81 | [ 82 | SNew(SSplitter) 83 | + SSplitter::Slot() 84 | .Value(0.75f) 85 | [ 86 | border1 87 | ] 88 | + SSplitter::Slot() 89 | .Value(0.25f) 90 | [ 91 | SNew(SMySlateWidget) 92 | ] 93 | ]; 94 | 95 | SConstraintCanvas::FSlot::FSlotArguments temp_slot = SConstraintCanvas::Slot(); 96 | temp_slot.Anchors(FAnchors(0.0f, 0.0f, 1.0f, 1.0f)) 97 | .Offset(FMargin(100.0f, 100.0f, 100.0f, 100.0f)) 98 | .ZOrder(1) 99 | .AttachWidget(container); 100 | 101 | auto ret_wgt = SNew(SConstraintCanvas) + temp_slot; 102 | return ret_wgt; 103 | } 104 | -------------------------------------------------------------------------------- /Source/QUMG/UMG/Splitter/QSplitterWidget.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Blueprint/UserWidget.h" 7 | 8 | #include "Widgets/SUserWidget.h" 9 | #include "Components/PanelWidget.h" 10 | #include "Runtime/Slate/Public/Widgets/Layout/SSplitter.h" 11 | #include "QSplitterWidget.generated.h" 12 | 13 | /** 14 | * Slate分割控件/UMG封装类 15 | */ 16 | UCLASS() 17 | class QUMG_API UQSplitterWidget : public UUserWidget 18 | { 19 | GENERATED_BODY() 20 | public: 21 | 22 | #if WITH_EDITOR 23 | virtual const FText GetPaletteCategory() override; 24 | #endif 25 | 26 | protected: 27 | virtual TSharedRef RebuildWidget() override; 28 | }; 29 | 30 | UCLASS() 31 | class QUMG_API UCppWgt_UPanelWidget : public UPanelWidget 32 | { 33 | GENERATED_BODY() 34 | 35 | }; 36 | 37 | class QUMG_API SMySlateWidget : public SUserWidget 38 | { 39 | public: 40 | SLATE_USER_ARGS(SMySlateWidget) 41 | {} 42 | SLATE_END_ARGS() 43 | 44 | public: 45 | virtual void Construct(const FArguments& InArgs); 46 | 47 | protected: 48 | FSlateBrush brush; 49 | }; 50 | -------------------------------------------------------------------------------- /Source/QUMG/UMG/Tab/CppWgt_BaseTabContainer.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | #include "CppWgt_BaseTabContainer.h" 3 | 4 | #include "Components/PanelWidget.h" 5 | #include "CppWgt_BaseTabContainerBtn.h" 6 | #include "Components/WidgetSwitcher.h" 7 | 8 | void UCppWgt_BaseTabContainer::NativeOnInitialized() 9 | { 10 | Super::NativeOnInitialized(); 11 | UE_LOG(LogTemp, Log, TEXT("NativeOnInitialized")); 12 | } 13 | 14 | void UCppWgt_BaseTabContainer::NativePreConstruct() 15 | { 16 | Super::NativePreConstruct(); 17 | UE_LOG(LogTemp, Log, TEXT("NativePreConstruct")); 18 | } 19 | 20 | void UCppWgt_BaseTabContainer::NativeConstruct() 21 | { 22 | Super::NativeConstruct(); 23 | 24 | UE_LOG(LogTemp, Log, TEXT("NativeConstruct")); 25 | } 26 | 27 | void UCppWgt_BaseTabContainer::NativeDestruct() 28 | { 29 | Super::NativeDestruct(); 30 | UE_LOG(LogTemp, Log, TEXT("NativeDestruct")); 31 | } 32 | 33 | void UCppWgt_BaseTabContainer::NativeTick(const FGeometry & MyGeometry, float InDeltaTime) 34 | { 35 | static bool wait_once = true; 36 | if (wait_once) 37 | { 38 | UE_LOG(LogTemp, Log, TEXT("NativeTick")); 39 | wait_once = false; 40 | } 41 | Super::NativeTick(MyGeometry, InDeltaTime); 42 | } 43 | 44 | int32 UCppWgt_BaseTabContainer::NativePaint(const FPaintArgs & Args , 45 | const FGeometry & AllottedGeometry , 46 | const FSlateRect & MyCullingRect , 47 | FSlateWindowElementList & OutDrawElements , 48 | int32 LayerId , 49 | const FWidgetStyle & InWidgetStyle , 50 | bool bParentEnabled) const 51 | { 52 | static bool wait_once = true; 53 | if (wait_once) 54 | { 55 | UE_LOG(LogTemp, Log, TEXT("NativePaint")); 56 | wait_once = false; 57 | } 58 | return Super::NativePaint(Args, AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled); 59 | } 60 | 61 | UPanelSlot* UCppWgt_BaseTabContainer::Add(FQUI_TabItem tabdata, class UUserWidget* wgt) 62 | { 63 | check(TabBtnClass); 64 | UCppWgt_BaseTabContainerBtn* btnitem_umg = UCppWgt_BaseTabContainerBtn::CreateUMG(this, TabBtnClass, tabdata); 65 | UPanelSlot *ret_slot = nullptr; 66 | 67 | if ( btnitem_umg != nullptr ) 68 | { 69 | auto delegate1 = btnitem_umg->OnTabBtnClick().AddUObject(this, &UCppWgt_BaseTabContainer::HandleItemTabBtnClick); 70 | bool boolean = delegate1.IsValid(); 71 | UE_LOG(LogTemp, Log, TEXT("is IsValid :%d"), boolean); 72 | ret_slot = TabContainer->AddChild(btnitem_umg); 73 | } 74 | 75 | ContentContainer->AddChild(wgt); 76 | 77 | return ret_slot; 78 | } 79 | 80 | void UCppWgt_BaseTabContainer::Remove(int32 index) 81 | { 82 | } 83 | 84 | void UCppWgt_BaseTabContainer::Switch(int32 index) 85 | { 86 | UCppWgt_BaseTabContainerBtn* oldBtn = (Current_Index == INDEX_NONE ? nullptr: Cast(TabContainer->GetChildAt(Current_Index)) ); 87 | UCppWgt_BaseTabContainerBtn* btn = Cast(TabContainer->GetChildAt(index)); 88 | 89 | if (oldBtn != nullptr) 90 | { 91 | oldBtn->SetIsEnabled(true); 92 | } 93 | 94 | if (btn != nullptr) 95 | { 96 | btn->SetIsEnabled(false); 97 | } 98 | 99 | Current_Index = index; 100 | 101 | ContentContainer->SetActiveWidgetIndex(index); 102 | 103 | OnTabChange().Broadcast(this, index); 104 | } 105 | 106 | bool UCppWgt_BaseTabContainer::Clear() 107 | { 108 | bool ret_result = true; 109 | 110 | TabContainer->ClearChildren(); 111 | ContentContainer->ClearChildren(); 112 | Current_Index = INDEX_NONE; 113 | 114 | return ret_result; 115 | } 116 | 117 | bool UCppWgt_BaseTabContainer::RemoveAll() 118 | { 119 | return this->Clear(); 120 | } 121 | 122 | void UCppWgt_BaseTabContainer::HandleItemTabBtnClick(const UCppWgt_BaseTabContainerBtn* target, int32 index) 123 | { 124 | UE_LOG(LogTemp, Log, TEXT(" tab click event ")); 125 | Switch(index); 126 | } -------------------------------------------------------------------------------- /Source/QUMG/UMG/Tab/CppWgt_BaseTabContainer.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Blueprint/UserWidget.h" 7 | #include "data/QUI_TabItem.h" 8 | #include "CppWgt_BaseTabContainer.generated.h" 9 | 10 | /** 11 | * 12 | */ 13 | UCLASS(Abstract) 14 | class QUMG_API UCppWgt_BaseTabContainer : public UUserWidget 15 | { 16 | GENERATED_BODY() 17 | protected: 18 | virtual void NativeOnInitialized() override; 19 | virtual void NativePreConstruct() override; 20 | virtual void NativeConstruct() override; 21 | virtual void NativeDestruct() override; 22 | virtual void NativeTick(const FGeometry& MyGeometry, float InDeltaTime) override; 23 | virtual int32 NativePaint(const FPaintArgs& Args, 24 | const FGeometry& AllottedGeometry, 25 | const FSlateRect& MyCullingRect, 26 | FSlateWindowElementList& OutDrawElements, 27 | int32 LayerId, 28 | const FWidgetStyle& InWidgetStyle, 29 | bool bParentEnabled) const override; 30 | public: 31 | 32 | UFUNCTION(BlueprintCallable, Category = "Tab Container") 33 | class UPanelSlot* Add(FQUI_TabItem tabdata,class UUserWidget* wgt); 34 | 35 | UFUNCTION(BlueprintCallable, Category = "Tab Container") 36 | void Remove(int32 index); 37 | 38 | UFUNCTION(BlueprintCallable, Category = "Tab Container") 39 | void Switch(int32 index); 40 | 41 | /** **/ 42 | UFUNCTION(BlueprintCallable, Category = "Tab Container") 43 | bool Clear(); 44 | 45 | /** **/ 46 | UFUNCTION(BlueprintCallable, Category = "Tab Container") 47 | bool RemoveAll(); 48 | public: 49 | //event 50 | 51 | DECLARE_EVENT_TwoParams(FString, FEvent_OnTabChange, const UCppWgt_BaseTabContainer*, int32) 52 | FEvent_OnTabChange& OnTabChange() { return Event_OnTabChange; } 53 | protected: 54 | virtual void HandleItemTabBtnClick(const class UCppWgt_BaseTabContainerBtn* target, int32 index); 55 | protected: 56 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CppVariant") 57 | int32 Current_Index = INDEX_NONE; 58 | 59 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CppVariant") 60 | class UWidgetSwitcher* ContentContainer = nullptr; 61 | 62 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CppVariant") 63 | class UPanelWidget* TabContainer = nullptr; 64 | 65 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CppVariant") 66 | TSubclassOf TabBtnClass; 67 | 68 | protected: 69 | FEvent_OnTabChange Event_OnTabChange; 70 | }; 71 | -------------------------------------------------------------------------------- /Source/QUMG/UMG/Tab/CppWgt_BaseTabContainerBtn.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #include "CppWgt_BaseTabContainerBtn.h" 4 | 5 | #include "Components/PanelWidget.h" 6 | 7 | void UCppWgt_BaseTabContainerBtn::HandleOnClick() 8 | { 9 | UPanelWidget* wgt = Cast(this->GetParent()); 10 | 11 | if (wgt == nullptr) 12 | { 13 | UE_LOG(LogTemp, Error, TEXT("parent widget is nullptr.") ); 14 | } 15 | 16 | int32 index = wgt->GetChildIndex(this); 17 | this->OnTabBtnClick().Broadcast(this, index); 18 | } 19 | 20 | UCppWgt_BaseTabContainerBtn* UCppWgt_BaseTabContainerBtn::CreateUMG(UObject *WorldObjectContext, TSubclassOf cla, const FQUI_TabItem& data) 21 | { 22 | auto btnitem_umg = CreateWidget< UCppWgt_BaseTabContainerBtn>(WorldObjectContext->GetWorld(), cla); 23 | if (btnitem_umg == nullptr) 24 | { 25 | return nullptr; 26 | } 27 | 28 | btnitem_umg->Data = data; 29 | return btnitem_umg; 30 | } 31 | -------------------------------------------------------------------------------- /Source/QUMG/UMG/Tab/CppWgt_BaseTabContainerBtn.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Blueprint/UserWidget.h" 7 | #include "data/QUI_TabItem.h" 8 | #include "CppWgt_BaseTabContainerBtn.generated.h" 9 | 10 | /** 11 | * 12 | */ 13 | UCLASS(Abstract) 14 | class QUMG_API UCppWgt_BaseTabContainerBtn : public UUserWidget 15 | { 16 | GENERATED_BODY() 17 | public: 18 | UFUNCTION(BlueprintCallable, Category = "TabBtnCommponent") 19 | void HandleOnClick(); 20 | 21 | DECLARE_EVENT_TwoParams(FString, FEvent_OnTabBtnClick,const UCppWgt_BaseTabContainerBtn*, int32) 22 | FEvent_OnTabBtnClick& OnTabBtnClick() { return Event_OnTabBtnClick; } 23 | 24 | static UCppWgt_BaseTabContainerBtn* CreateUMG(UObject *WorldObjectContext, TSubclassOf cla,const FQUI_TabItem& data); 25 | protected: 26 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CppVariant") 27 | FQUI_TabItem Data; 28 | protected: 29 | FEvent_OnTabBtnClick Event_OnTabBtnClick; 30 | }; 31 | -------------------------------------------------------------------------------- /Source/QUMG/UMG/Tab/Data/QUI_TabItem.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "QUI_TabItem.generated.h" 7 | /** 8 | * 9 | */ 10 | USTRUCT(BlueprintType) 11 | struct QUMG_API FQUI_TabItem 12 | { 13 | GENERATED_USTRUCT_BODY() 14 | 15 | public: 16 | /** */ 17 | FQUI_TabItem() 18 | { 19 | 20 | } 21 | 22 | public: 23 | /** */ 24 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CppVariant") 25 | FString Name; 26 | 27 | /** */ 28 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CppVariant") 29 | FString ImgPath; 30 | 31 | }; -------------------------------------------------------------------------------- /Source/QUMG/WebExtend/WebBrowserExtend.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "WebBrowserExtend.h" 4 | #include "SWebBrowserExtend.h" 5 | 6 | #include "Widgets/Layout/SBox.h" 7 | #include "Widgets/Text/STextBlock.h" 8 | #include "Async/TaskGraphInterfaces.h" 9 | #include "UObject/ConstructorHelpers.h" 10 | 11 | #if WITH_EDITOR 12 | #include "Materials/MaterialInterface.h" 13 | #include "Materials/MaterialExpressionMaterialFunctionCall.h" 14 | #include "Materials/MaterialExpressionTextureSample.h" 15 | #include "Materials/MaterialExpressionTextureSampleParameter2D.h" 16 | #include "Materials/MaterialFunction.h" 17 | #include "Factories/MaterialFactoryNew.h" 18 | #include "AssetRegistry/AssetRegistryModule.h" 19 | #include "PackageHelperFunctions.h" 20 | #endif 21 | 22 | #define LOCTEXT_NAMESPACE "WebBrowserExtend" 23 | 24 | ///////////////////////////////////////////////////// 25 | // UWebBrowserExtend 26 | 27 | UWebBrowserExtend::UWebBrowserExtend(const FObjectInitializer& ObjectInitializer) 28 | : Super(ObjectInitializer) 29 | { 30 | bIsVariable = true; 31 | } 32 | 33 | void UWebBrowserExtend::LoadURL(const FString& NewURL) 34 | { 35 | if (WebBrowserWidget.IsValid()) 36 | { 37 | return WebBrowserWidget->LoadURL(NewURL); 38 | } 39 | } 40 | 41 | void UWebBrowserExtend::SetInitialURL(const FString& NewURL) 42 | { 43 | this->InitialURL = NewURL; 44 | } 45 | 46 | void UWebBrowserExtend::LoadString(const FString& Contents, const FString& DummyURL) 47 | { 48 | if (WebBrowserWidget.IsValid()) 49 | { 50 | return WebBrowserWidget->LoadString(Contents, DummyURL); 51 | } 52 | } 53 | 54 | void UWebBrowserExtend::ExecuteJavascript(const FString& ScriptText) 55 | { 56 | if (WebBrowserWidget.IsValid()) 57 | { 58 | return WebBrowserWidget->ExecuteJavascript(ScriptText); 59 | } 60 | } 61 | 62 | FText UWebBrowserExtend::GetTitleText() const 63 | { 64 | if (WebBrowserWidget.IsValid()) 65 | { 66 | return WebBrowserWidget->GetTitleText(); 67 | } 68 | 69 | return FText::GetEmpty(); 70 | } 71 | 72 | FString UWebBrowserExtend::GetUrl() const 73 | { 74 | if (WebBrowserWidget.IsValid()) 75 | { 76 | return WebBrowserWidget->GetUrl(); 77 | } 78 | 79 | return FString(); 80 | } 81 | 82 | void UWebBrowserExtend::ReleaseSlateResources(bool bReleaseChildren) 83 | { 84 | Super::ReleaseSlateResources(bReleaseChildren); 85 | 86 | WebBrowserWidget.Reset(); 87 | } 88 | 89 | void UWebBrowserExtend::HandleLoadCompleted() 90 | { 91 | #if UE_EDITOR 92 | 93 | #else 94 | //禁用右键上下文菜单 95 | FString script = TEXT("window.oncontextmenu = function(event) { event.preventDefault(); event.stopPropagation(); return false; };"); 96 | this->ExecuteJavascript(script); 97 | #endif 98 | OnLoadCompleted().Broadcast(); 99 | } 100 | 101 | TSharedRef UWebBrowserExtend::RebuildWidget() 102 | { 103 | if (IsDesignTime()) 104 | { 105 | return SNew(SBox) 106 | .HAlign(HAlign_Center) 107 | .VAlign(VAlign_Center) 108 | [ 109 | SNew(STextBlock) 110 | .Text(LOCTEXT("Web Browser extend", "Web Browser extend")) 111 | ]; 112 | } 113 | else 114 | { 115 | WebBrowserWidget = SNew(SWebBrowserExtend) 116 | .InitialURL(InitialURL) 117 | #if UE_EDITOR 118 | .ShowControls(true) 119 | #else 120 | .ShowControls(false) 121 | #endif 122 | .EnableMouseTransparency(this->bMouseTransparency) 123 | .EnableVirtualPointerTransparency(this->bVirtualPointerTransparency) 124 | .TransparencyDelay(this->TransparencyDelay) 125 | .TransparencyThreshold(this->TransparencyThreshold) 126 | .BrowserFrameRate(this->BrowserFrameRate) 127 | .SupportsTransparency(bSupportsTransparency) 128 | .OnUrlChanged(BIND_UOBJECT_DELEGATE(FOnTextChanged, HandleOnUrlChanged)) 129 | .OnBeforePopup(BIND_UOBJECT_DELEGATE(FOnBeforePopupDelegate, HandleOnBeforePopup)) 130 | .OnLoadCompleted(BIND_UOBJECT_DELEGATE(FSimpleDelegate, HandleLoadCompleted)); 131 | 132 | //第三方输入法支持 133 | if (WebBrowserWidget.IsValid()) 134 | { 135 | ITextInputMethodSystem* const TextInputMethodSys = FSlateApplication::Get().GetTextInputMethodSystem(); 136 | WebBrowserWidget->BindInputMethodSystem(TextInputMethodSys); 137 | } 138 | 139 | return WebBrowserWidget.ToSharedRef(); 140 | } 141 | } 142 | 143 | void UWebBrowserExtend::SynchronizeProperties() 144 | { 145 | Super::SynchronizeProperties(); 146 | 147 | if (WebBrowserWidget.IsValid()) 148 | { 149 | 150 | } 151 | } 152 | 153 | void UWebBrowserExtend::HandleOnUrlChanged(const FText& InText) 154 | { 155 | OnUrlChanged.Broadcast(InText); 156 | } 157 | 158 | bool UWebBrowserExtend::HandleOnBeforePopup(FString URL, FString Frame) 159 | { 160 | if (OnBeforePopup.IsBound()) 161 | { 162 | if (IsInGameThread()) 163 | { 164 | OnBeforePopup.Broadcast(URL, Frame); 165 | } 166 | else 167 | { 168 | // Retry on the GameThread. 169 | TWeakObjectPtr WeakThis = this; 170 | FFunctionGraphTask::CreateAndDispatchWhenReady([WeakThis, URL, Frame]() 171 | { 172 | if (WeakThis.IsValid()) 173 | { 174 | WeakThis->HandleOnBeforePopup(URL, Frame); 175 | } 176 | }, TStatId(), nullptr, ENamedThreads::GameThread); 177 | } 178 | 179 | return true; 180 | } 181 | 182 | return false; 183 | } 184 | 185 | void UWebBrowserExtend::BindUObject(FString Name, UObject* Object) 186 | { 187 | if (this && WebBrowserWidget.IsValid()) 188 | { 189 | WebBrowserWidget->BindUObject(Name, Object); 190 | } 191 | } 192 | 193 | void UWebBrowserExtend::DispatchEvent(const FString& eventName, const FString& paramjson) 194 | { 195 | FString jsScript = FString::Printf(TEXT("document.dispatchEvent(new CustomEvent('%s', {detail: %s})); "), *eventName, *paramjson); 196 | 197 | UE_LOG(LogTemp, Log, TEXT("---------------------- js script :%s "), *jsScript); 198 | 199 | this->ExecuteJavascript(jsScript); 200 | } 201 | 202 | #if WITH_EDITOR 203 | 204 | const FText UWebBrowserExtend::GetPaletteCategory() 205 | { 206 | return LOCTEXT("QUI", "QUI"); 207 | } 208 | 209 | #endif 210 | 211 | ///////////////////////////////////////////////////// 212 | 213 | #undef LOCTEXT_NAMESPACE 214 | -------------------------------------------------------------------------------- /Source/QUMG/WebExtend/WebBrowserExtend.h: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Components/Widget.h" 7 | 8 | #include "WebBrowserExtend.generated.h" 9 | 10 | 11 | class SWebBrowserExtend; 12 | /** 13 | * 14 | */ 15 | UCLASS() 16 | class QUMG_API UWebBrowserExtend : public UWidget 17 | { 18 | GENERATED_UCLASS_BODY() 19 | 20 | 21 | 22 | public: 23 | UFUNCTION(BlueprintCallable, Category = "UWebBrowser Extend") 24 | void BindUObject(FString Name, UObject* Object); 25 | 26 | UFUNCTION(BlueprintCallable, Category = "UWebBrowser Extend") 27 | void DispatchEvent(const FString& eventName, const FString& paramjson); 28 | 29 | public: 30 | DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnUrlChanged, const FText&, Text); 31 | DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnBeforePopup, FString, URL, FString, Frame); 32 | 33 | /** 34 | * Load the specified URL 35 | * 36 | * @param NewURL New URL to load 37 | */ 38 | UFUNCTION(BlueprintCallable, Category = "Web Browser Extend") 39 | void LoadURL(const FString& NewURL); 40 | 41 | UFUNCTION(BlueprintCallable, Category = "Web Browser Extend") 42 | void SetInitialURL(const FString& NewURL); 43 | 44 | /** 45 | * Load a string as data to create a web page 46 | * 47 | * @param Contents String to load 48 | * @param DummyURL Dummy URL for the page 49 | */ 50 | UFUNCTION(BlueprintCallable, Category = "Web Browser Extend") 51 | void LoadString(const FString& Contents, const FString& DummyURL); 52 | 53 | /** 54 | * Executes a JavaScript string in the context of the web page 55 | * 56 | * @param ScriptText JavaScript string to execute 57 | */ 58 | UFUNCTION(BlueprintCallable, Category = "Web Browser Extend") 59 | void ExecuteJavascript(const FString& ScriptText); 60 | 61 | /** 62 | * Get the current title of the web page 63 | */ 64 | UFUNCTION(BlueprintCallable, Category = "Web Browser Extend") 65 | FText GetTitleText() const; 66 | 67 | /** 68 | * Gets the currently loaded URL. 69 | * 70 | * @return The URL, or empty string if no document is loaded. 71 | */ 72 | UFUNCTION(BlueprintCallable, Category = "Web Browser Extend") 73 | FString GetUrl() const; 74 | 75 | /** Called when the Url changes. */ 76 | UPROPERTY(BlueprintAssignable, Category = "Web Browser Extend | Event") 77 | FOnUrlChanged OnUrlChanged; 78 | 79 | /** Called when a popup is about to spawn. */ 80 | UPROPERTY(BlueprintAssignable, Category = "Web Browser Extend | Event") 81 | FOnBeforePopup OnBeforePopup; 82 | #pragma region event 83 | 84 | 85 | public: 86 | DECLARE_EVENT(FString, FOnLoadCompleted) 87 | FOnLoadCompleted& OnLoadCompleted() { return this->Event_OnLoadCompleted; }; 88 | 89 | protected: 90 | FOnLoadCompleted Event_OnLoadCompleted; 91 | #pragma endregion 92 | protected: 93 | /** */ 94 | void HandleLoadCompleted(); 95 | 96 | 97 | public: 98 | 99 | //~ Begin UWidget interface 100 | virtual void SynchronizeProperties() override; 101 | // End UWidget interface 102 | 103 | /** */ 104 | virtual void ReleaseSlateResources(bool bReleaseChildren) override; 105 | 106 | #if WITH_EDITOR 107 | virtual const FText GetPaletteCategory() override; 108 | #endif 109 | 110 | protected: 111 | /** URL that the browser will initially navigate to. The URL should include the protocol, eg http:// */ 112 | UPROPERTY(EditAnywhere, Category = Appearance) 113 | FString InitialURL; 114 | 115 | /** Should the browser window support transparency. */ 116 | UPROPERTY(EditAnywhere, Category = Appearance) 117 | bool bSupportsTransparency = true; 118 | 119 | UPROPERTY(EditAnywhere, Category = Appearance) 120 | int BrowserFrameRate = 90; 121 | 122 | UPROPERTY(EditAnywhere, Category = Appearance) 123 | bool bMouseTransparency = false; 124 | UPROPERTY(EditAnywhere, Category = Appearance) 125 | bool bVirtualPointerTransparency = false; 126 | 127 | UPROPERTY(EditAnywhere, Category = Appearance) 128 | float TransparencyDelay = 0.0f; 129 | UPROPERTY(EditAnywhere, Category = Appearance) 130 | float TransparencyThreshold = 0.333f; 131 | 132 | protected: 133 | TSharedPtr WebBrowserWidget; 134 | 135 | protected: 136 | // UWidget interface 137 | virtual TSharedRef RebuildWidget() override; 138 | 139 | 140 | //virtual FEventReply Native 141 | // End of UWidget interface 142 | 143 | void HandleOnUrlChanged(const FText& Text); 144 | bool HandleOnBeforePopup(FString URL, FString Frame); 145 | 146 | 147 | }; 148 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | support 4.2x.x and 5.3.x 4 | 5 | 6 | Tool Plugin.The UE4 Feature Extend/Helper contain some method about Texture/Pipe/WebBrowser/HTTP/IO/JSON/round corner in 4.2x.x(ue5 already implement round feature UBorder) 7 | 8 | 9 | 5.3.x new: 10 | 11 | * lumen high frame ouput and high shot to disk(like scene capture 2d) 12 | * winapi implmentantion system open file dialog at runtime. 13 | * Additional Examples 14 | 15 | 16 | # Use Exam 17 | 18 | ##### 1.High Shot and open file dialog at runtime : 19 | 20 | ![描述文本](Readme/BPExam.jpg) 21 | 22 | ##### 2.umg splitter component widget: 23 | 24 | 描述文本 25 | 描述文本 26 | 27 | 28 | ##### 3. download large file use range download to disk: 29 | 30 | ```cpp 31 | UDownloadHelper* UHttpBPLibrary::DownloadRange(UObject* WorldContextObject, const FString& Url) 32 | { 33 | UDownloadHelper* NewObj = NewObject(WorldContextObject, NAME_None, RF_Transient); 34 | 35 | NewObj->StartByDisk(Url, TEXT("d:/disk.png")); 36 | 37 | NewObj->OnDownloadCompleted().AddLambda([](UDownloadHelper* _DownloadHelper, bool bSuccessful , const FString &msg) 38 | { 39 | UE_LOG(LogTemp, Log, TEXT("Download Completed... %d %s"), bSuccessful ,*msg); 40 | }); 41 | NewObj->OnDownloadProgress().AddLambda([](UDownloadHelper* _DownloadHelper,const FQHttpProgress& info ) 42 | { 43 | UE_LOG(LogTemp, Log, TEXT("Download Progress... %d / %d %f / %f"), info.NewReceive, info.NewSent, info.ReceiveProgress, info.SentProgress); 44 | }); 45 | 46 | return NewObj; 47 | } 48 | ``` 49 | 50 | #### 4. dynamic loading texture2d and generate mipmap array: 51 | 52 | ```cpp 53 | auto imageHelper = NewObject(); 54 | //generate mipmaps array need ensure image size is 2 of power or enable bForceGenerateMips 55 | UTexture2D* t2d = imageHelper->LoadFromDisk(const FString &Path, bool bAutoGenerateMips = true, bool bForceGenerateMips = false); 56 | ``` 57 | 58 | Copy to QCorePlugin by 2024 59 | --------------------------------------------------------------------------------