├── .gitignore ├── LICENSE ├── README.md ├── SanwuBPGraphShot ├── Resources │ ├── ButtonIcon_40x.png │ └── Icon128.png ├── SanwuBPGraphShot.uplugin └── Source │ └── SanwuBPGraphShot │ ├── Private │ ├── SanwuBPGraphShot.cpp │ ├── SanwuBPGraphShotPrivatePCH.h │ └── SanwuBPGraphShotStyle.cpp │ ├── Public │ ├── SanwuBPGraphShot.h │ ├── SanwuBPGraphShotCommands.cpp │ ├── SanwuBPGraphShotCommands.h │ └── SanwuBPGraphShotStyle.h │ └── SanwuBPGraphShot.Build.cs ├── SanwuUEUtilites ├── Resources │ ├── ButtonIcon_40x.png │ └── Icon128.png ├── SanwuUEUtilites.uplugin └── Source │ └── SanwuUEUtilites │ ├── Classes │ ├── SanwuFileManager.cpp │ ├── SanwuFileManager.h │ ├── SanwuHttpDownloadManager.cpp │ ├── SanwuHttpDownloadManager.h │ ├── SanwuHttpRequestHelper.cpp │ ├── SanwuHttpRequestHelper.h │ ├── SanwuPaths.cpp │ ├── SanwuPaths.h │ ├── SanwuScreenShootTool.cpp │ ├── SanwuScreenShootTool.h │ ├── SanwuStringUtilityes.cpp │ ├── SanwuStringUtilityes.h │ ├── SanwuUtilitesMisc.cpp │ └── SanwuUtilitesMisc.h │ ├── Private │ ├── SanwuUEUtilites.cpp │ └── SanwuUEUtilitesPrivatePCH.h │ ├── Public │ └── SanwuUEUtilites.h │ └── SanwuUEUtilites.Build.cs └── SanwuUMGExtender ├── Resources ├── Icon128.png └── imags │ ├── AutoFoldingIcon.png │ ├── AutoLayoutIcon.png │ ├── a-emlarge-.png │ └── a-reduce-.png ├── SanwuUMGExtender.uplugin └── Source └── SanwuUMGExtender ├── Private ├── AutoFolding.cpp ├── AutoFoldingSlot.cpp ├── AutoLayout.cpp ├── SAutoLayout.cpp ├── SanwuUMGExtender.cpp ├── SanwuUMGExtenderPrivatePCH.h └── SanwuUMGExtenderStyle.cpp ├── Public ├── AutoFolding.h ├── AutoFoldingSlot.h ├── AutoLayout.h ├── SAuoFolding.cpp ├── SAutoFolding.h ├── SAutoLayout.h ├── SanwuUMGExtender.h └── SanwuUMGExtenderStyle.h └── SanwuUMGExtender.Build.cs /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | 19 | # Compiled Static libraries 20 | *.lai 21 | *.la 22 | *.a 23 | *.lib 24 | 25 | # Executables 26 | *.exe 27 | *.out 28 | *.app 29 | SanwuUMGExtender/Intermediate/ 30 | SanwuUEUtilites/Intermediate/ 31 | SanwuUEUtilites/Binaries/ 32 | SanwuUMGExtender/Binaries/ 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Sanwu.org 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 2 | #### 这是一个虚幻4的插件集项目: 3 | ##### SanwuUEUtilites 4 | >**SanwuUEUtilites**为一些实用工具类,运行于Runtime环境下。 5 | 6 | ##### SanwuUMGExtender 7 | >**SanwuUMGExtender**为扩展UMG的一个插件。 8 | 9 | #### 这些插件可单独运行。 10 | -------------------------------------------------------------------------------- /SanwuBPGraphShot/Resources/ButtonIcon_40x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanwu/jjboomsky/8cb34874c653acd54378196d8214f11989168199/SanwuBPGraphShot/Resources/ButtonIcon_40x.png -------------------------------------------------------------------------------- /SanwuBPGraphShot/Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanwu/jjboomsky/8cb34874c653acd54378196d8214f11989168199/SanwuBPGraphShot/Resources/Icon128.png -------------------------------------------------------------------------------- /SanwuBPGraphShot/SanwuBPGraphShot.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "Version": 1, 4 | "VersionName": "1.0", 5 | "FriendlyName": "SanwuBPGraphShot", 6 | "Description": "", 7 | "Category": "Other", 8 | "CreatedBy": "", 9 | "CreatedByURL": "sanwu.org", 10 | "DocsURL": "", 11 | "MarketplaceURL": "", 12 | "SupportURL": "", 13 | "EnabledByDefault": false, 14 | "CanContainContent": false, 15 | "IsBetaVersion": false, 16 | "Installed": false, 17 | "Modules": [ 18 | { 19 | "Name": "SanwuBPGraphShot", 20 | "Type": "Editor", 21 | "LoadingPhase": "Default" 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /SanwuBPGraphShot/Source/SanwuBPGraphShot/Private/SanwuBPGraphShot.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "SanwuBPGraphShotPrivatePCH.h" 4 | 5 | #include "SlateBasics.h" 6 | #include "SlateExtras.h" 7 | #include "Runtime/Slate/Private/Framework/Docking/DockingPrivate.h" 8 | 9 | #include "TabManager.h" 10 | #include "SanwuBPGraphShotStyle.h" 11 | #include "SanwuBPGraphShotCommands.h" 12 | 13 | #include "IMainFrameModule.h" 14 | #include "BlueprintEditorModule.h" 15 | 16 | #include "LevelEditor.h" 17 | 18 | static const FName SanwuBPGraphShotTabName("SanwuBPGraphShot"); 19 | 20 | #define LOCTEXT_NAMESPACE "FSanwuBPGraphShotModule" 21 | DEFINE_LOG_CATEGORY_STATIC(LogBPShot, Warning, All); 22 | 23 | void FSanwuBPGraphShotModule::StartupModule() 24 | { 25 | FSanwuBPGraphShotStyle::Initialize(); 26 | FSanwuBPGraphShotStyle::ReloadTextures(); 27 | 28 | FSanwuBPGraphShotCommands::Register(); 29 | 30 | PluginCommands = MakeShareable(new FUICommandList); 31 | 32 | PluginCommands->MapAction( 33 | FSanwuBPGraphShotCommands::Get().PluginAction, 34 | FExecuteAction::CreateRaw(this, &FSanwuBPGraphShotModule::PluginButtonClicked), 35 | FCanExecuteAction()); 36 | 37 | // 38 | IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked(TEXT("MainFrame")); 39 | MainFrameModule.OnMainFrameCreationFinished().AddRaw(this, &FSanwuBPGraphShotModule::OnMainFrameLoad); 40 | 41 | } 42 | void FSanwuBPGraphShotModule::OnMainFrameLoad(TSharedPtr InRootWindow, bool bIsNewProjectWindow) 43 | { 44 | FBlueprintEditorModule& BlueprintEditorModule = FModuleManager::LoadModuleChecked("Kismet"); 45 | { 46 | TSharedPtr BPMenuExtender = MakeShareable(new FExtender()); 47 | BPMenuExtender->AddToolBarExtension("Asset", EExtensionHook::After, PluginCommands, FToolBarExtensionDelegate::CreateRaw(this, &FSanwuBPGraphShotModule::AddToolbarExtension)); 48 | BlueprintEditorModule.GetMenuExtensibilityManager()->AddExtender(BPMenuExtender); 49 | } 50 | } 51 | void FSanwuBPGraphShotModule::ShutdownModule() 52 | { 53 | FSanwuBPGraphShotStyle::Shutdown(); 54 | FSanwuBPGraphShotCommands::Unregister(); 55 | } 56 | 57 | void FSanwuBPGraphShotModule::PluginButtonClicked() 58 | { 59 | TSharedPtrTab=FGlobalTabmanager::Get()->GetActiveTab(); 60 | TSharedPtrTabDockingArea= Tab->GetDockArea(); 61 | TArray>AllTab= TabDockingArea->GetAllChildTabs(); 62 | 63 | for (TSharedRefTabIt : AllTab) 64 | { 65 | TSharedRefTabContent = TabIt->GetContent(); 66 | //UE_LOG(LogBPShot, Warning, TEXT("%s -> %s %d %d %d"), *(TabIt->GetTabLabel().ToString()), *(TabContent->ToString()),TabIt->IsForeground(),TabIt->IsVolatile(),TabIt->IsVolatileIndirectly()); 67 | //SGraphEditor 68 | 69 | if (TabIt->IsForeground()&& TabContent->ToString().Contains("SGraphEditor")) 70 | { 71 | UE_LOG(LogBPShot, Warning, TEXT("%s -> %s "), *(TabIt->GetTabLabel().ToString()), *(TabContent->ToString())); 72 | } 73 | 74 | } 75 | 76 | 77 | FText TabName = Tab->GetTabLabel(); 78 | TSharedPtrTabParentWin = Tab->GetParentWindow(); 79 | TSharedPtr TabParentWell = Tab->GetParent(); 80 | 81 | 82 | } 83 | 84 | 85 | void FSanwuBPGraphShotModule::AddToolbarExtension(FToolBarBuilder& Builder) 86 | { 87 | Builder.AddToolBarButton(FSanwuBPGraphShotCommands::Get().PluginAction); 88 | } 89 | 90 | #undef LOCTEXT_NAMESPACE 91 | 92 | IMPLEMENT_MODULE(FSanwuBPGraphShotModule, SanwuBPGraphShot) -------------------------------------------------------------------------------- /SanwuBPGraphShot/Source/SanwuBPGraphShot/Private/SanwuBPGraphShotPrivatePCH.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "SlateBasics.h" 4 | #include "Engine.h" 5 | #include "SanwuBPGraphShot.h" 6 | -------------------------------------------------------------------------------- /SanwuBPGraphShot/Source/SanwuBPGraphShot/Private/SanwuBPGraphShotStyle.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "SanwuBPGraphShotPrivatePCH.h" 4 | 5 | #include "SanwuBPGraphShotStyle.h" 6 | #include "SlateGameResources.h" 7 | #include "IPluginManager.h" 8 | 9 | TSharedPtr< FSlateStyleSet > FSanwuBPGraphShotStyle::StyleInstance = NULL; 10 | 11 | void FSanwuBPGraphShotStyle::Initialize() 12 | { 13 | if (!StyleInstance.IsValid()) 14 | { 15 | StyleInstance = Create(); 16 | FSlateStyleRegistry::RegisterSlateStyle(*StyleInstance); 17 | } 18 | } 19 | 20 | void FSanwuBPGraphShotStyle::Shutdown() 21 | { 22 | FSlateStyleRegistry::UnRegisterSlateStyle(*StyleInstance); 23 | ensure(StyleInstance.IsUnique()); 24 | StyleInstance.Reset(); 25 | } 26 | 27 | FName FSanwuBPGraphShotStyle::GetStyleSetName() 28 | { 29 | static FName StyleSetName(TEXT("SanwuBPGraphShotStyle")); 30 | return StyleSetName; 31 | } 32 | 33 | #define IMAGE_BRUSH( RelativePath, ... ) FSlateImageBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ ) 34 | #define BOX_BRUSH( RelativePath, ... ) FSlateBoxBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ ) 35 | #define BORDER_BRUSH( RelativePath, ... ) FSlateBorderBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ ) 36 | #define TTF_FONT( RelativePath, ... ) FSlateFontInfo( Style->RootToContentDir( RelativePath, TEXT(".ttf") ), __VA_ARGS__ ) 37 | #define OTF_FONT( RelativePath, ... ) FSlateFontInfo( Style->RootToContentDir( RelativePath, TEXT(".otf") ), __VA_ARGS__ ) 38 | 39 | const FVector2D Icon16x16(16.0f, 16.0f); 40 | const FVector2D Icon20x20(20.0f, 20.0f); 41 | const FVector2D Icon40x40(40.0f, 40.0f); 42 | 43 | TSharedRef< FSlateStyleSet > FSanwuBPGraphShotStyle::Create() 44 | { 45 | TSharedRef< FSlateStyleSet > Style = MakeShareable(new FSlateStyleSet("SanwuBPGraphShotStyle")); 46 | Style->SetContentRoot(IPluginManager::Get().FindPlugin("SanwuBPGraphShot")->GetBaseDir() / TEXT("Resources")); 47 | 48 | Style->Set("SanwuBPGraphShot.PluginAction", new IMAGE_BRUSH(TEXT("ButtonIcon_40x"), Icon40x40)); 49 | 50 | return Style; 51 | } 52 | 53 | #undef IMAGE_BRUSH 54 | #undef BOX_BRUSH 55 | #undef BORDER_BRUSH 56 | #undef TTF_FONT 57 | #undef OTF_FONT 58 | 59 | void FSanwuBPGraphShotStyle::ReloadTextures() 60 | { 61 | if (FSlateApplication::IsInitialized()) 62 | { 63 | FSlateApplication::Get().GetRenderer()->ReloadTextureResources(); 64 | } 65 | } 66 | 67 | const ISlateStyle& FSanwuBPGraphShotStyle::Get() 68 | { 69 | return *StyleInstance; 70 | } 71 | -------------------------------------------------------------------------------- /SanwuBPGraphShot/Source/SanwuBPGraphShot/Public/SanwuBPGraphShot.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "ModuleManager.h" 6 | //#include "TabManager.h" 7 | class FToolBarBuilder; 8 | class FMenuBuilder; 9 | 10 | class FSanwuBPGraphShotModule : public IModuleInterface 11 | { 12 | public: 13 | 14 | /** IModuleInterface implementation */ 15 | virtual void StartupModule() override; 16 | virtual void ShutdownModule() override; 17 | 18 | /** This function will be bound to Command. */ 19 | void PluginButtonClicked(); 20 | 21 | private: 22 | 23 | void AddToolbarExtension(FToolBarBuilder& Builder); 24 | void AddMenuExtension(FMenuBuilder& Builder); 25 | void OnMainFrameLoad(TSharedPtr InRootWindow, bool bIsNewProjectWindow); 26 | 27 | private: 28 | TSharedPtr PluginCommands; 29 | 30 | }; -------------------------------------------------------------------------------- /SanwuBPGraphShot/Source/SanwuBPGraphShot/Public/SanwuBPGraphShotCommands.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "SanwuBPGraphShotPrivatePCH.h" 4 | #include "SanwuBPGraphShotCommands.h" 5 | 6 | #define LOCTEXT_NAMESPACE "FSanwuBPGraphShotModule" 7 | 8 | void FSanwuBPGraphShotCommands::RegisterCommands() 9 | { 10 | UI_COMMAND(PluginAction, "GraphShot", "Take a shot of current graph", EUserInterfaceActionType::Button, FInputGesture()); 11 | } 12 | 13 | #undef LOCTEXT_NAMESPACE 14 | -------------------------------------------------------------------------------- /SanwuBPGraphShot/Source/SanwuBPGraphShot/Public/SanwuBPGraphShotCommands.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "SlateBasics.h" 6 | #include "SanwuBPGraphShotStyle.h" 7 | 8 | class FSanwuBPGraphShotCommands : public TCommands 9 | { 10 | public: 11 | 12 | FSanwuBPGraphShotCommands() 13 | : TCommands(TEXT("SanwuBPGraphShot"), NSLOCTEXT("Contexts", "SanwuBPGraphShot", "SanwuBPGraphShot Plugin"), NAME_None, FSanwuBPGraphShotStyle::GetStyleSetName()) 14 | { 15 | } 16 | 17 | // TCommands<> interface 18 | virtual void RegisterCommands() override; 19 | 20 | public: 21 | TSharedPtr< FUICommandInfo > PluginAction; 22 | }; 23 | -------------------------------------------------------------------------------- /SanwuBPGraphShot/Source/SanwuBPGraphShot/Public/SanwuBPGraphShotStyle.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. 2 | #pragma once 3 | 4 | #include "SlateBasics.h" 5 | 6 | /** */ 7 | class FSanwuBPGraphShotStyle 8 | { 9 | public: 10 | 11 | static void Initialize(); 12 | 13 | static void Shutdown(); 14 | 15 | /** reloads textures used by slate renderer */ 16 | static void ReloadTextures(); 17 | 18 | /** @return The Slate style set for the Shooter game */ 19 | static const ISlateStyle& Get(); 20 | 21 | static FName GetStyleSetName(); 22 | 23 | private: 24 | 25 | static TSharedRef< class FSlateStyleSet > Create(); 26 | 27 | private: 28 | 29 | static TSharedPtr< class FSlateStyleSet > StyleInstance; 30 | }; -------------------------------------------------------------------------------- /SanwuBPGraphShot/Source/SanwuBPGraphShot/SanwuBPGraphShot.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class SanwuBPGraphShot : ModuleRules 6 | { 7 | public SanwuBPGraphShot(TargetInfo Target) 8 | { 9 | 10 | PublicIncludePaths.AddRange( 11 | new string[] { 12 | "SanwuBPGraphShot/Public" 13 | }); 14 | 15 | 16 | PrivateIncludePaths.AddRange( 17 | new string[] { 18 | "SanwuBPGraphShot/Private", 19 | "Runtime/Slate/Private/Framework/Docking" 20 | }); 21 | 22 | 23 | PublicDependencyModuleNames.AddRange( 24 | new string[] 25 | { 26 | "Core", 27 | "Kismet", 28 | "MainFrame", 29 | "Slate" 30 | }); 31 | 32 | 33 | PrivateDependencyModuleNames.AddRange( 34 | new string[] 35 | { 36 | "Projects", 37 | "InputCore", 38 | "UnrealEd", 39 | "LevelEditor", 40 | "CoreUObject", 41 | "Engine", 42 | "Slate", 43 | "SlateCore", 44 | // ... add private dependencies that you statically link with here ... 45 | } 46 | ); 47 | 48 | 49 | DynamicallyLoadedModuleNames.AddRange( 50 | new string[] 51 | { 52 | // ... add any modules that your module loads dynamically here ... 53 | }); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /SanwuUEUtilites/Resources/ButtonIcon_40x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanwu/jjboomsky/8cb34874c653acd54378196d8214f11989168199/SanwuUEUtilites/Resources/ButtonIcon_40x.png -------------------------------------------------------------------------------- /SanwuUEUtilites/Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanwu/jjboomsky/8cb34874c653acd54378196d8214f11989168199/SanwuUEUtilites/Resources/Icon128.png -------------------------------------------------------------------------------- /SanwuUEUtilites/SanwuUEUtilites.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "CanContainContent": false, 3 | "Category": "Sanwu", 4 | "CreatedBy": "Sanwu.org", 5 | "CreatedByURL": "", 6 | "Description": "", 7 | "DocsURL": "", 8 | "EnabledByDefault": true, 9 | "FileVersion": 3, 10 | "FriendlyName": "SanwuUEUtilites", 11 | "Installed": true, 12 | "IsBetaVersion": false, 13 | "MarketplaceURL": "", 14 | "Modules": [ 15 | { 16 | "Name": "SanwuUEUtilites", 17 | "Type": "Runtime", 18 | "LoadingPhase": "Default" 19 | } 20 | ], 21 | "SupportURL": "", 22 | "Version": 1, 23 | "VersionName": "1.0" 24 | } -------------------------------------------------------------------------------- /SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuFileManager.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanwu/jjboomsky/8cb34874c653acd54378196d8214f11989168199/SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuFileManager.cpp -------------------------------------------------------------------------------- /SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuFileManager.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanwu/jjboomsky/8cb34874c653acd54378196d8214f11989168199/SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuFileManager.h -------------------------------------------------------------------------------- /SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuHttpDownloadManager.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanwu/jjboomsky/8cb34874c653acd54378196d8214f11989168199/SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuHttpDownloadManager.cpp -------------------------------------------------------------------------------- /SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuHttpDownloadManager.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanwu/jjboomsky/8cb34874c653acd54378196d8214f11989168199/SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuHttpDownloadManager.h -------------------------------------------------------------------------------- /SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuHttpRequestHelper.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanwu/jjboomsky/8cb34874c653acd54378196d8214f11989168199/SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuHttpRequestHelper.cpp -------------------------------------------------------------------------------- /SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuHttpRequestHelper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "IHttpRequest.h" 3 | #include "Kismet/BlueprintAsyncActionBase.h" 4 | #include "SanwuHttpRequestHelper.generated.h" 5 | 6 | using namespace UF; 7 | using namespace UP; 8 | DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FSanwuHttpRequestDelegate, FString, Content, int32, StatusCode); 9 | 10 | UENUM() 11 | enum SanwuHttpRequestType 12 | { 13 | GET, 14 | POST 15 | }; 16 | 17 | UCLASS() 18 | class USanwuHttpRequestHelper : public UBlueprintAsyncActionBase 19 | { 20 | GENERATED_UCLASS_BODY() 21 | public: 22 | UFUNCTION(BlueprintCallable,Category="Sanwu|Http", meta = (BlueprintInternalUseOnly = "true")) 23 | static USanwuHttpRequestHelper* HttpRequestString(FString url,SanwuHttpRequestType Type,FString Content); 24 | 25 | UPROPERTY(BlueprintAssignable) 26 | FSanwuHttpRequestDelegate OnSuccess; 27 | 28 | UPROPERTY(BlueprintAssignable) 29 | FSanwuHttpRequestDelegate OnFail; 30 | 31 | public: 32 | 33 | private: 34 | void Start(FString URL, SanwuHttpRequestType Type, FString Content); 35 | void HandleRequestComplete(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded); 36 | }; -------------------------------------------------------------------------------- /SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuPaths.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanwu/jjboomsky/8cb34874c653acd54378196d8214f11989168199/SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuPaths.cpp -------------------------------------------------------------------------------- /SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuPaths.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanwu/jjboomsky/8cb34874c653acd54378196d8214f11989168199/SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuPaths.h -------------------------------------------------------------------------------- /SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuScreenShootTool.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #include "SanwuUEUtilitesPrivatePCH.h" 4 | #include "SanwuScreenShootTool.h" 5 | #include "Engine.h" 6 | 7 | FString UScreenShootTool::TakeScreenShoot(FString picName,bool bUnique) 8 | { 9 | FString inStr; 10 | FString Filename; 11 | FScreenshotRequest::RequestScreenshot(picName + ".png", false, bUnique); 12 | FString ResultStr=FScreenshotRequest::GetFilename(); 13 | ResultStr = FPaths::GetBaseFilename(ResultStr, true); 14 | return ResultStr+".png"; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuScreenShootTool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Kismet/BlueprintFunctionLibrary.h" 4 | #include "SanwuScreenShootTool.generated.h" 5 | 6 | /** 7 | * 这是一个用来实现蓝图里截图功能的扩展 8 | *因为目前(4.10)为止,虽然能实现截图,用ExecConsoleCommand节点。 但是它不能获取截图的返回值 9 | *而且不能手动设置截图的名字 10 | *所以写了此功能 11 | */ 12 | using namespace UF; 13 | 14 | UCLASS() 15 | class SANWUUEUTILITES_API UScreenShootTool : public UBlueprintFunctionLibrary 16 | { 17 | GENERATED_BODY() 18 | public: 19 | /** 20 | *截图,并设置名字 21 | *@picName 图片名字。可以不设置 22 | *@bUnique 是否是唯一的名字 例如 picName 设置为 a的话,会截一张名为a.png的图片。 23 | *然后,再次执行截图, 如果bUnique是true,则新截出来的图片会叫作a0001.png , 24 | *如果bUnique为fasle,则新图片会覆盖之前的 25 | */ 26 | UFUNCTION(BlueprintCallable, Category = "Sanwu|SanwuUEUtilites") 27 | static FString TakeScreenShoot(FString picName,bool bUnique=true); 28 | 29 | 30 | }; 31 | -------------------------------------------------------------------------------- /SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuStringUtilityes.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #include "SanwuUEUtilitesPrivatePCH.h" 4 | #include "SanwuStringUtilityes.h" 5 | #include "IImageWrapper.h" 6 | #include "IImageWrapperModule.h" 7 | TArray USanwuStringUtilityes::SplitStringToArray(FString SRC, FString Arg) 8 | { 9 | TArrayresult; 10 | if (SRC.Contains(Arg,ESearchCase::CaseSensitive)) 11 | { 12 | FString leftStr; 13 | FString rightStr; 14 | SRC.Split(Arg, &leftStr, &rightStr, ESearchCase::CaseSensitive); 15 | if (leftStr.Len()>0) 16 | { 17 | result.Add(leftStr); 18 | } 19 | result.Append(SplitStringToArray(rightStr, Arg)); 20 | return result; 21 | } 22 | else { 23 | if (SRC.Len()>0) 24 | { 25 | result.Add(SRC); 26 | } 27 | return result; 28 | } 29 | } 30 | class UTexture2D* USanwuStringUtilityes::GetTexture2DFromDiskFile(const FString& FilePath) 31 | { 32 | TArray RawFileData; 33 | UTexture2D* MyTexture = NULL; 34 | if (FFileHelper::LoadFileToArray(RawFileData, *FilePath /*""*/)) 35 | { 36 | IImageWrapperModule& ImageWrapperModule = FModuleManager::LoadModuleChecked(FName("ImageWrapper")); 37 | // Note: PNG format. Other formats are supported 38 | IImageWrapperPtr ImageWrapper = ImageWrapperModule.CreateImageWrapper(EImageFormat::PNG); 39 | if (ImageWrapper.IsValid() && ImageWrapper->SetCompressed(RawFileData.GetData(), RawFileData.Num())) 40 | { 41 | const TArray* UncompressedBGRA = NULL; 42 | if (ImageWrapper->GetRaw(ERGBFormat::BGRA, 8, UncompressedBGRA)) 43 | { 44 | // Create the UTexture for rendering 45 | MyTexture = UTexture2D::CreateTransient(ImageWrapper->GetWidth(), ImageWrapper->GetHeight(), PF_B8G8R8A8); 46 | 47 | // Fill in the source data from the file 48 | void* TextureData = MyTexture->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE); 49 | FMemory::Memcpy(TextureData, UncompressedBGRA->GetData(), UncompressedBGRA->Num()); 50 | MyTexture->PlatformData->Mips[0].BulkData.Unlock(); 51 | 52 | // Update the rendering resource from data. 53 | MyTexture->UpdateResource(); 54 | } 55 | } 56 | } 57 | return MyTexture; 58 | } 59 | -------------------------------------------------------------------------------- /SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuStringUtilityes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Kismet/BlueprintFunctionLibrary.h" 4 | #include "SanwuStringUtilityes.generated.h" 5 | 6 | /** 7 | * 8 | */ 9 | using namespace UF; 10 | 11 | UCLASS() 12 | class SANWUUEUTILITES_API USanwuStringUtilityes: public UBlueprintFunctionLibrary 13 | { 14 | GENERATED_BODY() 15 | public: 16 | /**把String转化为Array,根据一个标志*/ 17 | UFUNCTION(BlueprintCallable, Category = "SanwuString") 18 | static TArray SplitStringToArray(FString SRC, FString Arg); 19 | 20 | UFUNCTION(BlueprintCallable, Category = "Sanwu|Utilityes") 21 | static class UTexture2D* GetTexture2DFromDiskFile(const FString& FilePath); 22 | }; 23 | -------------------------------------------------------------------------------- /SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuUtilitesMisc.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #include "SanwuUEUtilitesPrivatePCH.h" 4 | #include "Kismet/KismetSystemLibrary.h" 5 | #include "SanwuUtilitesMisc.h" 6 | DEFINE_LOG_CATEGORY_STATIC(LogSanwuUtilitesMisc, Warning, All); 7 | void USanwuUtilitesMisc::RestartGameClient() 8 | { 9 | #if WITH_EDITOR 10 | GEngine->AddOnScreenDebugMessage(0, 1, FColor::Red, "You Can`t use \"RestartGameClient\" node with editor mode !"); 11 | //return; 12 | #endif 13 | FString RootPath = FPaths::RootDir(); 14 | RootPath=RootPath.Replace(*FString("/"), *FString("\\")); 15 | FString GameExeFullPath=RootPath+ UKismetSystemLibrary::GetGameName() + ".exe"; 16 | UE_LOG(LogSanwuUtilitesMisc, Warning, TEXT("%s"), *GameExeFullPath); 17 | FString Command=FString::Printf(TEXT("ping 127.0.0.1 -n 2 > nul\r\n@echo off\r\nstart %s"),*GameExeFullPath); 18 | FFileHelper::SaveStringToFile(Command, *(FPaths::GameSavedDir() / "RestartClient.bat")); 19 | FPlatformProcess::ExecProcess(*(FPaths::GameSavedDir() / "RestartClient.bat"), nullptr, nullptr, nullptr, nullptr); 20 | GEngine->Exec(GWorld, *FString("Exit")); 21 | } -------------------------------------------------------------------------------- /SanwuUEUtilites/Source/SanwuUEUtilites/Classes/SanwuUtilitesMisc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Kismet/BlueprintFunctionLibrary.h" 4 | #include "SanwuUtilitesMisc.generated.h" 5 | 6 | /** 7 | * 8 | */ 9 | using namespace UF; 10 | 11 | UCLASS() 12 | class USanwuUtilitesMisc : public UBlueprintFunctionLibrary 13 | { 14 | GENERATED_BODY() 15 | public: 16 | UFUNCTION(BlueprintCallable, Category = "SanwuMisc") 17 | static void RestartGameClient(); 18 | }; 19 | -------------------------------------------------------------------------------- /SanwuUEUtilites/Source/SanwuUEUtilites/Private/SanwuUEUtilites.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2015 Sanwu Games, Inc. All Rights Reserved. 2 | 3 | #include "SanwuUEUtilitesPrivatePCH.h" 4 | 5 | #include "SlateBasics.h" 6 | #include "SlateExtras.h" 7 | 8 | static const FName SanwuUEUtilitesTabName("SanwuUEUtilites"); 9 | 10 | #define LOCTEXT_NAMESPACE "FSanwuUEUtilitesModule" 11 | 12 | void FSanwuUEUtilitesModule::StartupModule() 13 | { 14 | 15 | } 16 | 17 | void FSanwuUEUtilitesModule::ShutdownModule() 18 | { 19 | 20 | } 21 | 22 | #undef LOCTEXT_NAMESPACE 23 | 24 | IMPLEMENT_MODULE(FSanwuUEUtilitesModule, SanwuUEUtilites) -------------------------------------------------------------------------------- /SanwuUEUtilites/Source/SanwuUEUtilites/Private/SanwuUEUtilitesPrivatePCH.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2015 Sanwu Games, Inc. All Rights Reserved. 2 | #include "Engine.h" 3 | #include "SlateBasics.h" 4 | 5 | #include "SanwuUEUtilites.h" 6 | #include "CoreUObject.h" 7 | -------------------------------------------------------------------------------- /SanwuUEUtilites/Source/SanwuUEUtilites/Public/SanwuUEUtilites.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "ModuleManager.h" 6 | 7 | class FSanwuUEUtilitesModule : public IModuleInterface 8 | { 9 | public: 10 | 11 | virtual void StartupModule() override; 12 | virtual void ShutdownModule() override; 13 | 14 | }; -------------------------------------------------------------------------------- /SanwuUEUtilites/Source/SanwuUEUtilites/SanwuUEUtilites.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class SanwuUEUtilites : ModuleRules 6 | { 7 | public SanwuUEUtilites(TargetInfo Target) 8 | { 9 | 10 | PublicIncludePaths.AddRange( 11 | new string[] { 12 | "SanwuUEUtilites/Public" 13 | }); 14 | PrivateIncludePaths.AddRange( 15 | new string[] { 16 | "SanwuUEUtilites/Private", 17 | }); 18 | PublicDependencyModuleNames.AddRange( 19 | new string[] 20 | { 21 | "Core","CoreUObject","Engine","InputCore" 22 | }); 23 | PrivateDependencyModuleNames.AddRange( 24 | new string[] 25 | { 26 | "Core", 27 | "Projects", 28 | "InputCore", 29 | "CoreUObject", 30 | "Engine", 31 | "Slate", 32 | "SlateCore", 33 | "HTTP", 34 | "Networking", 35 | "ImageWrapper" 36 | }); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /SanwuUMGExtender/Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanwu/jjboomsky/8cb34874c653acd54378196d8214f11989168199/SanwuUMGExtender/Resources/Icon128.png -------------------------------------------------------------------------------- /SanwuUMGExtender/Resources/imags/AutoFoldingIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanwu/jjboomsky/8cb34874c653acd54378196d8214f11989168199/SanwuUMGExtender/Resources/imags/AutoFoldingIcon.png -------------------------------------------------------------------------------- /SanwuUMGExtender/Resources/imags/AutoLayoutIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanwu/jjboomsky/8cb34874c653acd54378196d8214f11989168199/SanwuUMGExtender/Resources/imags/AutoLayoutIcon.png -------------------------------------------------------------------------------- /SanwuUMGExtender/Resources/imags/a-emlarge-.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanwu/jjboomsky/8cb34874c653acd54378196d8214f11989168199/SanwuUMGExtender/Resources/imags/a-emlarge-.png -------------------------------------------------------------------------------- /SanwuUMGExtender/Resources/imags/a-reduce-.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanwu/jjboomsky/8cb34874c653acd54378196d8214f11989168199/SanwuUMGExtender/Resources/imags/a-reduce-.png -------------------------------------------------------------------------------- /SanwuUMGExtender/SanwuUMGExtender.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "CanContainContent": false, 3 | "Category": "Sanwu", 4 | "CreatedBy": "Sanwu.org", 5 | "CreatedByURL": "", 6 | "Description": "", 7 | "DocsURL": "", 8 | "EnabledByDefault": true, 9 | "FileVersion": 3, 10 | "FriendlyName": "SanwuUMGExtender", 11 | "Installed": false, 12 | "IsBetaVersion": false, 13 | "MarketplaceURL": "", 14 | "Modules": [ 15 | { 16 | "LoadingPhase": "Default", 17 | "Name": "SanwuUMGExtender", 18 | "Type": "Runtime" 19 | } 20 | ], 21 | "SupportURL": "", 22 | "Version": 1, 23 | "VersionName": "1.0" 24 | } -------------------------------------------------------------------------------- /SanwuUMGExtender/Source/SanwuUMGExtender/Private/AutoFolding.cpp: -------------------------------------------------------------------------------- 1 | #include "SanwuUMGExtenderPrivatePCH.h" 2 | #include "SanwuUMGExtenderStyle.h" 3 | #include "AutoFolding.h" 4 | #include "SAutoFolding.h" 5 | #include "AutoFoldingSlot.h" 6 | 7 | #define LOCTEXT_NAMESPACE "SanwuUMGExtender" 8 | 9 | UAutoFolding::UAutoFolding(const FObjectInitializer& obj) 10 | :Super(obj) 11 | { 12 | bIsVariable = false; 13 | SAutoFolding::FArguments Defaults; 14 | Visiblity_DEPRECATED = Visibility = UWidget::ConvertRuntimeToSerializedVisibility(Defaults._Visibility.Get()); 15 | } 16 | 17 | void UAutoFolding::SynchronizeProperties() 18 | { 19 | Super::SynchronizeProperties(); 20 | } 21 | 22 | void UAutoFolding::ReleaseSlateResources(bool bReleaseChildren) 23 | { 24 | Super::ReleaseSlateResources(bReleaseChildren); 25 | MyAutoFolding.Reset(); 26 | } 27 | 28 | void UAutoFolding::PostLoad() 29 | { 30 | Super::PostLoad(); 31 | } 32 | #if WITH_EDITOR 33 | const FSlateBrush* UAutoFolding::GetEditorIcon() 34 | { 35 | return FSanwuUMGExtenderStyle::Get().GetBrush("Widget.AutoFoldingIcon"); 36 | } 37 | 38 | const FText UAutoFolding::GetPaletteCategory() 39 | { 40 | return LOCTEXT("Sanwu", "Sanwu"); 41 | } 42 | #endif 43 | 44 | TSharedRef UAutoFolding::RebuildWidget() 45 | { 46 | //if (!b_DoOnce) 47 | //{ 48 | // TSharedPtr btn = SNew(SButton); 49 | // b_DoOnce = !b_DoOnce; 50 | // return btn->AsShared(); 51 | //} 52 | 53 | MyAutoFolding = SNew(SAutoFolding); 54 | for (UPanelSlot* Slot : Slots) 55 | { 56 | if (UAutoFoldingSlot* TypedSlot = Cast(Slot)) 57 | { 58 | TypedSlot->Parent = this; 59 | TypedSlot->BuildSlot(MyAutoFolding.ToSharedRef()); 60 | } 61 | } 62 | return BuildDesignTimeWidget(MyAutoFolding.ToSharedRef()); 63 | } 64 | 65 | UClass* UAutoFolding::GetSlotClass() const 66 | { 67 | return UAutoFoldingSlot::StaticClass(); 68 | } 69 | 70 | void UAutoFolding::OnSlotAdded(UPanelSlot* Slot) 71 | { 72 | if (MyAutoFolding.IsValid()) 73 | { 74 | Cast(Slot)->BuildSlot(MyAutoFolding.ToSharedRef()); 75 | } 76 | } 77 | 78 | void UAutoFolding::OnSlotRemoved(UPanelSlot* Slot) 79 | { 80 | if (MyAutoFolding.IsValid()) 81 | { 82 | TSharedPtr Widget = Slot->Content->GetCachedWidget(); 83 | if (Widget.IsValid()) 84 | { 85 | MyAutoFolding->RemoveSlot(Widget.ToSharedRef()); 86 | } 87 | } 88 | } 89 | 90 | UAutoFoldingSlot* UAutoFolding::AddChildToAutoFolding(UWidget* Content) 91 | { 92 | return Cast(Super::AddChild(Content)); 93 | } 94 | 95 | #undef LOCTEXT_NAMESPACE 96 | -------------------------------------------------------------------------------- /SanwuUMGExtender/Source/SanwuUMGExtender/Private/AutoFoldingSlot.cpp: -------------------------------------------------------------------------------- 1 | #include "SanwuUMGExtenderPrivatePCH.h" 2 | #include "AutoFoldingSlot.h" 3 | 4 | UAutoFoldingSlot::UAutoFoldingSlot(const FObjectInitializer& ObjectInitializer) 5 | :Super(ObjectInitializer) 6 | , Slot(NULL) 7 | { 8 | HorizontalAlignment = HAlign_Fill; 9 | VerticalAlignment = VAlign_Fill; 10 | Size = FSlateChildSize(ESlateSizeRule::Automatic); 11 | } 12 | 13 | void UAutoFoldingSlot::ReleaseSlateResources(bool bReleaseChildren) 14 | { 15 | Super::ReleaseSlateResources(bReleaseChildren); 16 | Slot = NULL; 17 | } 18 | 19 | void UAutoFoldingSlot::BuildSlot(TSharedRef InAutoFolding) 20 | { 21 | Slot = &InAutoFolding->AddSlot() 22 | .Padding(Padding) 23 | .HAlign(HorizontalAlignment) 24 | .VAlign(VerticalAlignment) 25 | [ 26 | Content == NULL ? SNullWidget::NullWidget : Content->TakeWidget() 27 | ]; 28 | Slot->SizeParam = UWidget::ConvertSerializedSizeParamToRuntime(Size); 29 | } 30 | 31 | void UAutoFoldingSlot::SetPadding(FMargin InPadding) 32 | { 33 | Padding = InPadding; 34 | if (Slot) 35 | { 36 | Slot->Padding(InPadding); 37 | } 38 | } 39 | 40 | void UAutoFoldingSlot::SetSize(FSlateChildSize InSize) 41 | { 42 | Size = InSize; 43 | if (Slot) 44 | { 45 | Slot->SizeParam = UWidget::ConvertSerializedSizeParamToRuntime(InSize); 46 | } 47 | } 48 | 49 | void UAutoFoldingSlot::SetHorizontalAlignment(EHorizontalAlignment InHorizontalAlignment) 50 | { 51 | HorizontalAlignment = InHorizontalAlignment; 52 | if (Slot) 53 | { 54 | Slot->HAlign(InHorizontalAlignment); 55 | } 56 | } 57 | 58 | void UAutoFoldingSlot::SetVerticalAlignment(EVerticalAlignment InVerticalAlignment) 59 | { 60 | VerticalAlignment = InVerticalAlignment; 61 | if (Slot) 62 | { 63 | Slot->VAlign(InVerticalAlignment); 64 | } 65 | } 66 | 67 | void UAutoFoldingSlot::SynchronizeProperties() 68 | { 69 | SetPadding(Padding); 70 | SetSize(Size); 71 | SetHorizontalAlignment(HorizontalAlignment); 72 | SetVerticalAlignment(VerticalAlignment); 73 | } 74 | 75 | 76 | -------------------------------------------------------------------------------- /SanwuUMGExtender/Source/SanwuUMGExtender/Private/AutoLayout.cpp: -------------------------------------------------------------------------------- 1 | #include "SanwuUMGExtenderPrivatePCH.h" 2 | #include "SanwuUMGExtenderStyle.h" 3 | #include "AutoLayout.h" 4 | 5 | #define LOCTEXT_NAMESPACE "SanwuUMGExtender" 6 | 7 | UAutoLayout::UAutoLayout(const FObjectInitializer&ObjectInitializer) 8 | :Super(ObjectInitializer) 9 | { 10 | 11 | } 12 | void UAutoLayout::ReleaseSlateResources(bool bReleaseChildren) 13 | { 14 | Super::ReleaseSlateResources(bReleaseChildren); 15 | } 16 | TSharedRef UAutoLayout::RebuildWidget() 17 | { 18 | TSharedPtr btn = SNew(SAutoLayout); 19 | return btn->AsShared(); 20 | } 21 | void UAutoLayout::SynchronizeProperties() 22 | { 23 | Super::SynchronizeProperties(); 24 | } 25 | void UAutoLayout::PostLoad() 26 | { 27 | Super::PostLoad(); 28 | } 29 | #if WITH_EDITOR 30 | const FSlateBrush* UAutoLayout::GetEditorIcon() 31 | { 32 | return FSanwuUMGExtenderStyle::Get().GetBrush("Widget.AutoLayoutIcon"); 33 | } 34 | const FText UAutoLayout::GetPaletteCategory() 35 | { 36 | return LOCTEXT("Sanwu","Sanwu"); 37 | } 38 | #endif 39 | 40 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /SanwuUMGExtender/Source/SanwuUMGExtender/Private/SAutoLayout.cpp: -------------------------------------------------------------------------------- 1 | #include "SanwuUMGExtenderPrivatePCH.h" 2 | #include "SAutoLayout.h" 3 | 4 | void SAutoLayout::Construct(const FArguments& InArgs) 5 | { 6 | const int32 NumSlots = InArgs.Slots.Num(); 7 | contentMargin = InArgs._contentMargin.Get(); 8 | for (int32 SlotIndex = 0; SlotIndex < NumSlots; ++SlotIndex) 9 | { 10 | Children.Add(InArgs.Slots[SlotIndex]); 11 | } 12 | 13 | } 14 | void SAutoLayout::OnArrangeChildren(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren)const 15 | { 16 | areaSize = AllottedGeometry.GetLocalSize(); 17 | float startX = contentMargin.Left; 18 | float startY = contentMargin.Top; 19 | float currentMaxHeight = 0.f; 20 | for (int32 ChildIndex = 0; ChildIndex < Children.Num(); ++ChildIndex) 21 | { 22 | const SBoxPanel::FSlot& CurChild = Children[ChildIndex]; 23 | const EVisibility ChildVisibility = CurChild.GetWidget()->GetVisibility(); 24 | FVector2D size = CurChild.GetWidget()->GetDesiredSize(); 25 | if (ArrangedChildren.Accepts(ChildVisibility)) 26 | { 27 | if (size.Y>currentMaxHeight) 28 | { 29 | currentMaxHeight = size.Y; 30 | } 31 | 32 | 33 | if (startX+size.X FSanwuUMGExtenderStyle::UMGStyleInstance = nullptr; 5 | void FSanwuUMGExtenderStyle::Initialize() 6 | { 7 | if (!UMGStyleInstance.IsValid()) 8 | { 9 | UMGStyleInstance = Create(); 10 | FSlateStyleRegistry::RegisterSlateStyle(*UMGStyleInstance); 11 | } 12 | } 13 | 14 | void FSanwuUMGExtenderStyle::Shutdown() 15 | { 16 | FSlateStyleRegistry::UnRegisterSlateStyle(*UMGStyleInstance); 17 | ensure(UMGStyleInstance.IsUnique()); 18 | UMGStyleInstance.Reset(); 19 | } 20 | FName FSanwuUMGExtenderStyle::GetStyleSetName() 21 | { 22 | static FName StyleSetName(TEXT("SanwuUMGExtenderStyle")); 23 | return StyleSetName; 24 | } 25 | 26 | #define IMAGE_BRUSH( RelativePath, ... ) FSlateImageBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ ) 27 | #define BOX_BRUSH( RelativePath, ... ) FSlateBoxBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ ) 28 | #define BORDER_BRUSH( RelativePath, ... ) FSlateBorderBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ ) 29 | #define TTF_FONT( RelativePath, ... ) FSlateFontInfo( Style->RootToContentDir( RelativePath, TEXT(".ttf") ), __VA_ARGS__ ) 30 | #define OTF_FONT( RelativePath, ... ) FSlateFontInfo( Style->RootToContentDir( RelativePath, TEXT(".otf") ), __VA_ARGS__ ) 31 | 32 | const FVector2D Icon16x16(16.f, 16.f); 33 | const FVector2D Icon50x50(50.f, 50.f); 34 | 35 | TSharedRefFSanwuUMGExtenderStyle::Create() 36 | { 37 | TSharedRef Style = MakeShareable(new FSlateStyleSet("SanwuUMGExtenderStyle")); 38 | Style->SetContentRoot(IPluginManager::Get().FindPlugin("SanwuUMGExtender")->GetBaseDir() / TEXT("Resources")); 39 | Style->Set("Widget.AutoLayoutIcon", new IMAGE_BRUSH(TEXT("imags/AutoLayoutIcon"), Icon16x16)); 40 | Style->Set("Widget.AutoFoldingIcon", new IMAGE_BRUSH(TEXT("images/AutoFoldingIcon"), Icon16x16)); 41 | Style->Set("Widget.EmlargeIcon", new IMAGE_BRUSH(TEXT("images/a-emlarge-"), Icon50x50)); 42 | Style->Set("Widget.ReduceIcon", new IMAGE_BRUSH(TEXT("images/a-reduce-"), Icon50x50)); 43 | 44 | return Style; 45 | } 46 | #undef IMAGE_BRUSH 47 | #undef BOX_BRUSH 48 | #undef BORDER_BRUSH 49 | #undef TTF_FONT 50 | #undef OTF_FONT 51 | void FSanwuUMGExtenderStyle::ReloadTextures() 52 | { 53 | FSlateApplication::Get().GetRenderer()->ReloadTextureResources(); 54 | } 55 | 56 | const ISlateStyle& FSanwuUMGExtenderStyle::Get() 57 | { 58 | return *UMGStyleInstance; 59 | } -------------------------------------------------------------------------------- /SanwuUMGExtender/Source/SanwuUMGExtender/Public/AutoFolding.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2016 Sanwu Games, Inc. All Rights Reserved. 2 | #pragma once 3 | #include "Components/ContentWidget.h" 4 | #include "AutoLayout.h" 5 | #include "AutoFolding.generated.h" 6 | 7 | UCLASS() 8 | class SANWUUMGEXTENDER_API UAutoFolding : public UPanelWidget 9 | { 10 | GENERATED_UCLASS_BODY() 11 | public: 12 | 13 | UFUNCTION(BlueprintCallable, Category = "AutoFolding") 14 | UAutoFoldingSlot* AddChildToAutoFolding(UWidget* Content); 15 | 16 | virtual void SynchronizeProperties() override; 17 | virtual void ReleaseSlateResources(bool bReleaseChildren) override; 18 | virtual void PostLoad() override; 19 | 20 | #if WITH_EDITOR 21 | virtual const FSlateBrush* GetEditorIcon() override; 22 | virtual const FText GetPaletteCategory() override; 23 | #endif 24 | 25 | protected: 26 | virtual UClass* GetSlotClass() const override; 27 | virtual void OnSlotAdded(UPanelSlot* Slot) override; 28 | virtual void OnSlotRemoved(UPanelSlot* Slot) override; 29 | 30 | protected: 31 | TSharedPtr MyAutoFolding; 32 | virtual TSharedRef RebuildWidget() override; 33 | 34 | bool b_DoOnce = false; 35 | }; -------------------------------------------------------------------------------- /SanwuUMGExtender/Source/SanwuUMGExtender/Public/AutoFoldingSlot.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Components/PanelSlot.h" 3 | #include "SlateWrapperTypes.h" 4 | #include "SAutoFolding.h" 5 | 6 | #include "AutoFoldingSlot.generated.h" 7 | 8 | UCLASS() 9 | class SANWUUMGEXTENDER_API UAutoFoldingSlot : public UPanelSlot 10 | { 11 | GENERATED_UCLASS_BODY() 12 | 13 | public: 14 | /** The padding area between the slot and the content it contains. */ 15 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Layout|Vertical Box Slot") 16 | FMargin Padding; 17 | 18 | /** How much space this slot should occupy in the direction of the panel. */ 19 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Layout|Vertical Box Slot") 20 | FSlateChildSize Size; 21 | 22 | /** The alignment of the object horizontally. */ 23 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Layout|Vertical Box Slot") 24 | TEnumAsByte HorizontalAlignment; 25 | 26 | /** The alignment of the object vertically. */ 27 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Layout|Vertical Box Slot") 28 | TEnumAsByte VerticalAlignment; 29 | 30 | UFUNCTION(BlueprintCallable, Category = "Layout|Vertical Box Slot") 31 | void SetPadding(FMargin InPadding); 32 | 33 | UFUNCTION(BlueprintCallable, Category = "Layout|Vertical Box Slot") 34 | void SetSize(FSlateChildSize InSize); 35 | 36 | UFUNCTION(BlueprintCallable, Category = "Layout|Vertical Box Slot") 37 | void SetHorizontalAlignment(EHorizontalAlignment InHorizontalAlignment); 38 | 39 | UFUNCTION(BlueprintCallable, Category = "Layout|Vertical Box Slot") 40 | void SetVerticalAlignment(EVerticalAlignment InVerticalAlignment); 41 | 42 | public: 43 | void BuildSlot(TSharedRef InAutoFolding); 44 | // UPanelSlot interface 45 | virtual void SynchronizeProperties() override; 46 | // End of UPanelSlot interface 47 | 48 | virtual void ReleaseSlateResources(bool bReleaseChildren) override; 49 | private: 50 | SAutoFolding::FSlot* Slot; 51 | }; -------------------------------------------------------------------------------- /SanwuUMGExtender/Source/SanwuUMGExtender/Public/AutoLayout.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2016 Sanwu Games, Inc. All Rights Reserved. 2 | #pragma once 3 | #include "Components/ContentWidget.h" 4 | #include "SAutoLayout.h" 5 | #include "AutoLayout.generated.h" 6 | 7 | /** 8 | * AutoLayout 是一个盛放对象的容器。 9 | * 当AutoLayout的宽高发生变化时,里面的子对象会自动适应 10 | * 比如做一个相册。每个照片宽度是10 AutoLayout宽度为100,那横向则能放10张照片。 11 | * 这时候,当AutoLayout宽度变为90时。里面的照片会自动重新排列,变成一行9个 12 | */ 13 | UCLASS() 14 | class SANWUUMGEXTENDER_API UAutoLayout : public UContentWidget 15 | { 16 | GENERATED_UCLASS_BODY() 17 | public: 18 | 19 | public: 20 | virtual void SynchronizeProperties() override; 21 | virtual void ReleaseSlateResources(bool bReleaseChildren) override; 22 | virtual void PostLoad() override; 23 | 24 | #if WITH_EDITOR 25 | virtual const FSlateBrush* GetEditorIcon() override; 26 | virtual const FText GetPaletteCategory() override; 27 | #endif 28 | 29 | protected: 30 | virtual TSharedRef RebuildWidget() override; 31 | 32 | }; -------------------------------------------------------------------------------- /SanwuUMGExtender/Source/SanwuUMGExtender/Public/SAuoFolding.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanwu/jjboomsky/8cb34874c653acd54378196d8214f11989168199/SanwuUMGExtender/Source/SanwuUMGExtender/Public/SAuoFolding.cpp -------------------------------------------------------------------------------- /SanwuUMGExtender/Source/SanwuUMGExtender/Public/SAutoFolding.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanwu/jjboomsky/8cb34874c653acd54378196d8214f11989168199/SanwuUMGExtender/Source/SanwuUMGExtender/Public/SAutoFolding.h -------------------------------------------------------------------------------- /SanwuUMGExtender/Source/SanwuUMGExtender/Public/SAutoLayout.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "SBoxPanel.h" 3 | 4 | ///自动排列的容器组件。 5 | 6 | 7 | class SAutoLayout :public SBoxPanel 8 | { 9 | public: 10 | class FSlot : public SBoxPanel::FSlot 11 | { 12 | public: 13 | 14 | FSlot() 15 | : SBoxPanel::FSlot() 16 | { 17 | } 18 | 19 | FSlot& AutoHeight() 20 | { 21 | SizeParam = FAuto(); 22 | return *this; 23 | } 24 | 25 | FSlot& MaxHeight(const TAttribute< float >& InMaxHeight) 26 | { 27 | MaxSize = InMaxHeight; 28 | return *this; 29 | } 30 | 31 | FSlot& FillHeight(const TAttribute< float >& StretchCoefficient) 32 | { 33 | SizeParam = FStretch(StretchCoefficient); 34 | return *this; 35 | } 36 | 37 | DEPRECATED(4.5, "AspectRatio() property is no longer supported; it did not behave correctly to begin with and was rarely used.") 38 | FSlot& AspectRatio() 39 | { 40 | return *this; 41 | } 42 | 43 | FSlot& Padding(float Uniform) 44 | { 45 | SlotPadding = FMargin(Uniform); 46 | return *this; 47 | } 48 | 49 | FSlot& Padding(float Horizontal, float Vertical) 50 | { 51 | SlotPadding = FMargin(Horizontal, Vertical); 52 | return *this; 53 | } 54 | 55 | FSlot& Padding(float Left, float Top, float Right, float Bottom) 56 | { 57 | SlotPadding = FMargin(Left, Top, Right, Bottom); 58 | return *this; 59 | } 60 | 61 | FSlot& Padding(const TAttribute::FGetter& InDelegate) 62 | { 63 | SlotPadding.Bind(InDelegate); 64 | return *this; 65 | } 66 | 67 | FSlot& HAlign(EHorizontalAlignment InHAlignment) 68 | { 69 | HAlignment = InHAlignment; 70 | return *this; 71 | } 72 | 73 | FSlot& VAlign(EVerticalAlignment InVAlignment) 74 | { 75 | VAlignment = InVAlignment; 76 | return *this; 77 | } 78 | 79 | FSlot& Padding(TAttribute InPadding) 80 | { 81 | SlotPadding = InPadding; 82 | return *this; 83 | } 84 | 85 | FSlot& operator[](TSharedRef InWidget) 86 | { 87 | SBoxPanel::FSlot::operator[](InWidget); 88 | return *this; 89 | } 90 | 91 | FSlot& Expose(FSlot*& OutVarToInit) 92 | { 93 | OutVarToInit = this; 94 | return *this; 95 | } 96 | }; 97 | 98 | static FSlot& Slot() 99 | { 100 | return *(new FSlot()); 101 | } 102 | 103 | public: 104 | SLATE_BEGIN_ARGS(SAutoLayout){} 105 | SLATE_ATTRIBUTE(FMargin,contentMargin) 106 | SLATE_SUPPORTS_SLOT(SAutoLayout::FSlot) 107 | SLATE_END_ARGS() 108 | 109 | FORCENOINLINE SAutoLayout() 110 | : SBoxPanel(Orient_Horizontal) 111 | { 112 | } 113 | 114 | virtual void OnArrangeChildren(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren)const override; 115 | public: 116 | void Construct(const FArguments& InArgs); 117 | virtual FVector2D ComputeDesiredSize(float) const override; 118 | FSlot& AddSlot() { 119 | SAutoLayout::FSlot& NewSlot = *new FSlot(); 120 | this->Children.Add(&NewSlot); 121 | return NewSlot; 122 | } 123 | private: 124 | mutable FVector2D areaSize; 125 | mutable float areaHeight = 100; 126 | FMargin contentMargin; 127 | 128 | }; 129 | -------------------------------------------------------------------------------- /SanwuUMGExtender/Source/SanwuUMGExtender/Public/SanwuUMGExtender.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2016 Sawnu Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "ModuleManager.h" 6 | 7 | class FSanwuUMGExtenderModule : public IModuleInterface 8 | { 9 | public: 10 | 11 | /** IModuleInterface implementation */ 12 | virtual void StartupModule() override; 13 | virtual void ShutdownModule() override; 14 | }; -------------------------------------------------------------------------------- /SanwuUMGExtender/Source/SanwuUMGExtender/Public/SanwuUMGExtenderStyle.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2016 Sanwu Games, Inc. All Rights Reserved. 2 | #pragma once 3 | #include "SlateBasics.h" 4 | 5 | class SANWUUMGEXTENDER_API FSanwuUMGExtenderStyle 6 | { 7 | public: 8 | static void Initialize(); 9 | static void Shutdown(); 10 | static void ReloadTextures(); 11 | static const ISlateStyle& Get(); 12 | static FName GetStyleSetName(); 13 | private: 14 | static TSharedRef< class FSlateStyleSet > Create(); 15 | static TSharedPtr< class FSlateStyleSet > UMGStyleInstance; 16 | }; 17 | -------------------------------------------------------------------------------- /SanwuUMGExtender/Source/SanwuUMGExtender/SanwuUMGExtender.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class SanwuUMGExtender : ModuleRules 6 | { 7 | public SanwuUMGExtender(TargetInfo Target) 8 | { 9 | 10 | PublicIncludePaths.AddRange( 11 | new string[] { 12 | "SanwuUMGExtender/Public" 13 | }); 14 | PrivateIncludePaths.AddRange( 15 | new string[] { 16 | "SanwuUMGExtender/Private", 17 | }); 18 | PublicDependencyModuleNames.AddRange( 19 | new string[] 20 | { 21 | "Core", "CoreUObject", "Engine", "InputCore", "UMG", "Slate", "SlateCore" 22 | }); 23 | 24 | PrivateDependencyModuleNames.AddRange( 25 | new string[] 26 | { 27 | "Core", 28 | "CoreUObject", 29 | "Engine", 30 | "Slate", 31 | "SlateCore", 32 | "UMG", 33 | "Projects" 34 | }); 35 | DynamicallyLoadedModuleNames.AddRange( 36 | new string[] 37 | { 38 | // ... add any modules that your module loads dynamically here ... 39 | } 40 | ); 41 | } 42 | } 43 | --------------------------------------------------------------------------------