├── .gitattributes ├── .gitignore ├── Config └── FilterPlugin.ini ├── Content ├── Material │ ├── Base │ │ ├── MB_CropTexture.uasset │ │ └── MB_InputSDF.uasset │ ├── Functions │ │ ├── MF_CropByParameters.uasset │ │ ├── MF_Output_BooleansImage.uasset │ │ ├── MF_Output_Multiple.uasset │ │ ├── MF_SDF.uasset │ │ ├── MF_SDF_Outline.uasset │ │ └── MF_SDF_Shadow.uasset │ └── UMG │ │ ├── MB_Icon.uasset │ │ ├── MB_Umg_1Image.uasset │ │ ├── MB_Umg_1Image_M.uasset │ │ ├── MB_Umg_2Image.uasset │ │ ├── MB_Umg_2Image_M.uasset │ │ ├── MB_Umg_3Image.uasset │ │ ├── MB_Umg_3Image_M.uasset │ │ ├── MB_Umg_Tile.uasset │ │ ├── MF_Icon_Color_opacity.uasset │ │ ├── MF_Icon_Color_opacity_M.uasset │ │ ├── MF_Image_Color_opacity.uasset │ │ ├── MF_Image_Color_opacity_M.uasset │ │ ├── MF_UMG_SDF.uasset │ │ ├── MF_UMG_Tiled.uasset │ │ ├── MF_UMG_Tiled_M.uasset │ │ └── MI_IconSelected.uasset └── Textures │ ├── Title_mp.uasset │ └── icon_editor.uasset ├── LICENSE ├── MultiPacker.uplugin ├── README.md ├── Resources ├── ButtonIcon_40x.png ├── Icon128.png ├── IconRuntime128.png ├── ObjectLibrary_64x.png └── SlateWidgetStyleAsset_64x.png └── Source ├── MultiPackerEditor ├── MultiPackerEditor.Build.cs ├── Private │ ├── DetailsProperty │ │ ├── FChannelDatabaseCustomization.cpp │ │ ├── FLayerDatabaseCustomization.cpp │ │ └── FTileCopyCustomization.cpp │ ├── Factory │ │ ├── MultiPackerDatabaseFactory.cpp │ │ ├── MultiPackerFactory.cpp │ │ ├── MultiPackerLayerDatabaseFactory.cpp │ │ └── MultiPackerRuntimeGraphFactory.cpp │ ├── LayerDatabase │ │ ├── LayerStyleEditorToolkit.cpp │ │ ├── MultiPackerLayerDatabaseAssetTypeActions.cpp │ │ └── SLayerStyleEditor.cpp │ ├── MultiPackerAssetEditor │ │ ├── MultiPackerAssetEditor.cpp │ │ ├── MultiPackerAssetEditorToolbar.cpp │ │ ├── MultiPackerAssetGraphSchema.cpp │ │ ├── MultiPackerEdGraph.cpp │ │ ├── MultiPackerEditorCommands.cpp │ │ ├── MultiPackerProcessCore.cpp │ │ ├── Nodes │ │ │ ├── MultiPackerBaseNode.cpp │ │ │ ├── MultiPackerMaterialNode.cpp │ │ │ ├── MultiPackerOutputNode.cpp │ │ │ ├── MultiPackerTextureEdNode.cpp │ │ │ ├── SMultiPackerMaterialNode.cpp │ │ │ ├── SMultiPackerOutputNode.cpp │ │ │ └── SMultiPackerTextureEdNode.cpp │ │ ├── SAssetDropTargetArray.cpp │ │ └── SMultiPackerAssetEditorDrop.cpp │ ├── MultiPackerAssetTypeActions.cpp │ ├── MultiPackerEditor.cpp │ ├── MultiPackerEditorTypes.cpp │ └── RuntimeGraph │ │ ├── MultiPackerRuntimeAssetEditor.cpp │ │ ├── MultiPackerRuntimeAssetEditorToolbar.cpp │ │ ├── MultiPackerRuntimeAssetGraphSchema.cpp │ │ ├── MultiPackerRuntimeAssetTypeActions.cpp │ │ ├── MultiPackerRuntimeEdGraph.cpp │ │ └── Nodes │ │ ├── MultiPackerRuntimeMaterialNode.cpp │ │ ├── MultiPackerRuntimeOutputNode.cpp │ │ ├── SMultiPackerRuntimeMaterialNode.cpp │ │ └── SMultiPackerRuntimeOutputNode.cpp └── Public │ ├── DetailsProperty │ ├── FChannelDatabaseCustomization.h │ ├── FLayerDatabaseCustomization.h │ └── FTileCopyCustomization.h │ ├── Factory │ ├── MultiPackerDatabaseFactory.h │ ├── MultiPackerFactory.h │ ├── MultiPackerLayerDatabaseFactory.h │ └── MultiPackerRuntimeGraphFactory.h │ ├── IMultiPackerEditor.h │ ├── LayerDatabase │ ├── LayerStyleEditorToolkit.h │ ├── MultiPackerLayerDatabaseAssetTypeActions.h │ └── SLayerStyleEditor.h │ ├── MultiPackerAssetEditor │ ├── MultiPackerAssetEditor.h │ ├── MultiPackerAssetEditorToolbar.h │ ├── MultiPackerAssetGraphSchema.h │ ├── MultiPackerColors.h │ ├── MultiPackerEdGraph.h │ ├── MultiPackerEditorCommands.h │ ├── MultiPackerEditorThumbnail.h │ ├── MultiPackerProcessCore.h │ ├── Nodes │ │ ├── MultiPackerBaseNode.h │ │ ├── MultiPackerMaterialNode.h │ │ ├── MultiPackerOutputNode.h │ │ ├── MultiPackerTextureEdNode.h │ │ ├── SMultiPackerMaterialNode.h │ │ ├── SMultiPackerOutputNode.h │ │ └── SMultiPackerTextureEdNode.h │ ├── SAssetDropTargetArray.h │ └── SMultiPackerAssetEditorDrop.h │ ├── MultiPackerAssetTypeActions.h │ ├── MultiPackerEditorTypes.h │ └── RuntimeGraph │ ├── MultiPackerRuntimeAssetEditor.h │ ├── MultiPackerRuntimeAssetEditorToolbar.h │ ├── MultiPackerRuntimeAssetGraphSchema.h │ ├── MultiPackerRuntimeAssetTypeActions.h │ ├── MultiPackerRuntimeEdGraph.h │ └── Nodes │ ├── MultiPackerRuntimeMaterialNode.h │ ├── MultiPackerRuntimeOutputNode.h │ ├── SMultiPackerRuntimeMaterialNode.h │ └── SMultiPackerRuntimeOutputNode.h ├── MultiPackerRuntime ├── MultiPackerRuntime.Build.cs ├── Private │ ├── BinPack │ │ ├── MaxRectsBinPack.cpp │ │ └── MultiPackerRuntimeBinPack.cpp │ ├── Graph │ │ ├── MultiPacker.cpp │ │ ├── MultiPackerMatNode.cpp │ │ └── MultiPackerTextureNode.cpp │ ├── MultiPackerButton.cpp │ ├── MultiPackerDataBase.cpp │ ├── MultiPackerImage.cpp │ ├── MultiPackerImageCore.cpp │ ├── MultiPackerLayerDatabase.cpp │ ├── MultiPackerRuntime.cpp │ ├── MultiPackerRuntimeGraph.cpp │ ├── MultiPackerRuntimeMatNode.cpp │ └── TileUtils │ │ ├── TileCopy.cpp │ │ └── TilePointer.cpp └── Public │ ├── BinPack │ ├── MaxRectsBinPack.h │ └── MultiPackerRuntimeBinPack.h │ ├── Graph │ ├── MultiPacker.h │ ├── MultiPackerMatNode.h │ └── MultiPackerTextureNode.h │ ├── IMultiPackerRuntime.h │ ├── MultiPackerBaseEnums.h │ ├── MultiPackerButton.h │ ├── MultiPackerDataBase.h │ ├── MultiPackerImage.h │ ├── MultiPackerImageCore.h │ ├── MultiPackerLayerDatabase.h │ ├── MultiPackerRuntimeGraph.h │ ├── MultiPackerRuntimeMatNode.h │ ├── MultiPackerSettings.h │ └── TileUtils │ ├── TileCopy.h │ └── TilePointer.h └── MultiPackerTab ├── MultiPackerTab.Build.cs ├── Private ├── MultiPackerChannelTab.cpp ├── MultiPackerChannelTab.h ├── MultiPackerCommands.cpp ├── MultiPackerCommands.h ├── MultiPackerDetailPanel.h ├── MultiPackerTab.cpp ├── MultiPackerTabStyle.cpp ├── MultiPackerTabStyle.h └── Widgets │ ├── SMPTexturePreviewZoomer.cpp │ ├── SMPTexturePreviewZoomer.h │ ├── SMPTextureWidget.cpp │ └── SMPTextureWidget.h └── Public └── MultiPackerTab.h /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Visual Studio 2015 user specific files 2 | .vs/ 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | 22 | # Compiled Static libraries 23 | *.lai 24 | *.la 25 | *.a 26 | *.lib 27 | 28 | # Executables 29 | *.exe 30 | *.out 31 | *.app 32 | *.ipa 33 | 34 | # These project files can be generated by the engine 35 | *.xcodeproj 36 | *.xcworkspace 37 | *.sln 38 | *.suo 39 | *.opensdf 40 | *.sdf 41 | *.VC.db 42 | *.VC.opendb 43 | 44 | # Precompiled Assets 45 | SourceArt/**/*.png 46 | SourceArt/**/*.tga 47 | 48 | # Binary Files 49 | Binaries/* 50 | Plugins/*/Binaries/* 51 | 52 | # Builds 53 | Build/* 54 | 55 | # Whitelist PakBlacklist-.txt files 56 | !Build/*/ 57 | Build/*/** 58 | !Build/*/PakBlacklist*.txt 59 | 60 | # Don't ignore icon files in Build 61 | !Build/**/*.ico 62 | 63 | # Built data for maps 64 | *_BuiltData.uasset 65 | 66 | # Configuration files generated by the Editor 67 | Saved/* 68 | 69 | # Compiled source files for the engine to use 70 | Intermediate/* 71 | Plugins/*/Intermediate/* 72 | 73 | # Cache files for the editor to use 74 | DerivedDataCache/* 75 | -------------------------------------------------------------------------------- /Config/FilterPlugin.ini: -------------------------------------------------------------------------------- 1 | [FilterPlugin] 2 | ; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and 3 | ; may include "...", "*", and "?" wildcards to match directories, files, and individual characters respectively. 4 | ; 5 | ; Examples: 6 | ; /README.txt 7 | ; /Extras/... 8 | ; /Binaries/ThirdParty/*.dll 9 | -------------------------------------------------------------------------------- /Content/Material/Base/MB_CropTexture.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/Base/MB_CropTexture.uasset -------------------------------------------------------------------------------- /Content/Material/Base/MB_InputSDF.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/Base/MB_InputSDF.uasset -------------------------------------------------------------------------------- /Content/Material/Functions/MF_CropByParameters.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/Functions/MF_CropByParameters.uasset -------------------------------------------------------------------------------- /Content/Material/Functions/MF_Output_BooleansImage.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/Functions/MF_Output_BooleansImage.uasset -------------------------------------------------------------------------------- /Content/Material/Functions/MF_Output_Multiple.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/Functions/MF_Output_Multiple.uasset -------------------------------------------------------------------------------- /Content/Material/Functions/MF_SDF.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/Functions/MF_SDF.uasset -------------------------------------------------------------------------------- /Content/Material/Functions/MF_SDF_Outline.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/Functions/MF_SDF_Outline.uasset -------------------------------------------------------------------------------- /Content/Material/Functions/MF_SDF_Shadow.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/Functions/MF_SDF_Shadow.uasset -------------------------------------------------------------------------------- /Content/Material/UMG/MB_Icon.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/UMG/MB_Icon.uasset -------------------------------------------------------------------------------- /Content/Material/UMG/MB_Umg_1Image.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/UMG/MB_Umg_1Image.uasset -------------------------------------------------------------------------------- /Content/Material/UMG/MB_Umg_1Image_M.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/UMG/MB_Umg_1Image_M.uasset -------------------------------------------------------------------------------- /Content/Material/UMG/MB_Umg_2Image.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/UMG/MB_Umg_2Image.uasset -------------------------------------------------------------------------------- /Content/Material/UMG/MB_Umg_2Image_M.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/UMG/MB_Umg_2Image_M.uasset -------------------------------------------------------------------------------- /Content/Material/UMG/MB_Umg_3Image.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/UMG/MB_Umg_3Image.uasset -------------------------------------------------------------------------------- /Content/Material/UMG/MB_Umg_3Image_M.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/UMG/MB_Umg_3Image_M.uasset -------------------------------------------------------------------------------- /Content/Material/UMG/MB_Umg_Tile.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/UMG/MB_Umg_Tile.uasset -------------------------------------------------------------------------------- /Content/Material/UMG/MF_Icon_Color_opacity.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/UMG/MF_Icon_Color_opacity.uasset -------------------------------------------------------------------------------- /Content/Material/UMG/MF_Icon_Color_opacity_M.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/UMG/MF_Icon_Color_opacity_M.uasset -------------------------------------------------------------------------------- /Content/Material/UMG/MF_Image_Color_opacity.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/UMG/MF_Image_Color_opacity.uasset -------------------------------------------------------------------------------- /Content/Material/UMG/MF_Image_Color_opacity_M.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/UMG/MF_Image_Color_opacity_M.uasset -------------------------------------------------------------------------------- /Content/Material/UMG/MF_UMG_SDF.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/UMG/MF_UMG_SDF.uasset -------------------------------------------------------------------------------- /Content/Material/UMG/MF_UMG_Tiled.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/UMG/MF_UMG_Tiled.uasset -------------------------------------------------------------------------------- /Content/Material/UMG/MF_UMG_Tiled_M.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/UMG/MF_UMG_Tiled_M.uasset -------------------------------------------------------------------------------- /Content/Material/UMG/MI_IconSelected.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Material/UMG/MI_IconSelected.uasset -------------------------------------------------------------------------------- /Content/Textures/Title_mp.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Textures/Title_mp.uasset -------------------------------------------------------------------------------- /Content/Textures/icon_editor.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Content/Textures/icon_editor.uasset -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 cheke 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. -------------------------------------------------------------------------------- /MultiPacker.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "Version": 16, 4 | "VersionName": "2.8.1", 5 | "FriendlyName": "MultiPacker", 6 | "Description": "Edit and combine Textures easily", 7 | "Category": "MultiPacker", 8 | "CreatedBy": "@turbocheke", 9 | "DocsURL": "https://cheke.github.io/MultiPacker/", 10 | "MarketplaceURL": "https://ue/marketplace/content/afd1a04001bc4110b4a22460ca09da94", 11 | "EngineVersion": "4.16.0", 12 | "CanContainContent": true, 13 | "IsBetaVersion": false, 14 | "Installed": false, 15 | "Modules": [ 16 | { 17 | "Name": "MultiPackerRuntime", 18 | "Type": "Runtime", 19 | "LoadingPhase": "PreDefault", 20 | "WhitelistPlatforms": [ 21 | "Android", 22 | "Win64", 23 | "Win32" 24 | ] 25 | }, 26 | { 27 | "Name": "MultiPackerEditor", 28 | "Type": "Editor", 29 | "LoadingPhase": "Default", 30 | "WhitelistPlatforms": [ 31 | "Win64", 32 | "Win32" 33 | ] 34 | }, 35 | { 36 | "Name": "MultiPackerTab", 37 | "Type": "Editor", 38 | "LoadingPhase": "Default", 39 | "WhitelistPlatforms": [ 40 | "Win64", 41 | "Win32" 42 | ] 43 | } 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MultiPacker 2 | 3 | MultiPacker now its free, allowing everyone enjoy and use it; if you want to support MultiPacker you can do it in Patreon. 4 | https://www.patreon.com/EstudioCheke 5 | 6 | MutiPacker will grow with your support. 7 | 8 | If you want to download MultiPacker Precompiled to Unreal Engine, almost the three last versions are supported on Unreal Engine Marketplace. 9 | https://www.unrealengine.com/marketplace/multipacker-texture-and-material-packer?sessionInvalidated=true 10 | 11 | 12 | ## This is the Source Code of MultiPacker 13 | 14 | This project is developed under the Unreal Engine 4.16 version and verified by builds on every version at almost the last one at this moment 4.23. 15 | The code uses some tricks via defines allowed by unreal engine to have the same functionality on all the version by equal. 16 | 17 | If you want to compile the code to another version different to 4.16 you need to change on MultiPacker.uplugin the line 18 | "EngineVersion": "4.16.0", 19 | and change "4.16.0" to the number of version you use. 20 | Example: "EngineVersion": "4.18.0" , 21 | 22 | ## MultiPacker Youtube Channel 23 | https://www.youtube.com/user/turbocheke/videos 24 | 25 | ## MultiPacker Project with some assets to show the Plugin features 26 | https://github.com/cheke/MultiPackerProject 27 | 28 | ## Documentation of MultiPacker are on Github Pages 29 | https://cheke.github.io/MultiPacker/ 30 | I try to continually update the documentation 31 | 32 | ## MultiPacker Discord 33 | https://discord.gg/NbzAZh2 34 | -------------------------------------------------------------------------------- /Resources/ButtonIcon_40x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Resources/ButtonIcon_40x.png -------------------------------------------------------------------------------- /Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Resources/Icon128.png -------------------------------------------------------------------------------- /Resources/IconRuntime128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Resources/IconRuntime128.png -------------------------------------------------------------------------------- /Resources/ObjectLibrary_64x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Resources/ObjectLibrary_64x.png -------------------------------------------------------------------------------- /Resources/SlateWidgetStyleAsset_64x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheke/MultiPacker-SourceCode/aa3e30c3090211b8a88d5838f35921befc33dfce/Resources/SlateWidgetStyleAsset_64x.png -------------------------------------------------------------------------------- /Source/MultiPackerEditor/MultiPackerEditor.Build.cs: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | 3 | namespace UnrealBuildTool.Rules 4 | { 5 | public class MultiPackerEditor : ModuleRules 6 | { 7 | public MultiPackerEditor(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | bEnforceIWYU = true; 10 | bUseAVX = true; 11 | OptimizeCode = CodeOptimization.Always; 12 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 13 | PrivateIncludePaths.Add("MultiPackerEditor/Private"); 14 | 15 | PrivateIncludePathModuleNames.AddRange( 16 | new string[] { 17 | "Settings", 18 | "IntroTutorials", 19 | "AssetTools", 20 | } 21 | ); 22 | 23 | PublicDependencyModuleNames.AddRange( 24 | new string[] 25 | { 26 | "Core", 27 | "Engine", 28 | "CoreUObject", 29 | "EditorStyle", 30 | "UnrealEd", 31 | "KismetWidgets", 32 | "GraphEditor", 33 | "Kismet", 34 | "EditorWidgets", 35 | "MultiPackerRuntime", 36 | } 37 | ); 38 | 39 | PrivateDependencyModuleNames.AddRange( 40 | new string[] 41 | { 42 | "InputCore", 43 | "AssetTools", 44 | "Slate", 45 | "SlateCore", 46 | "PropertyEditor", 47 | "ContentBrowser", 48 | "Projects", 49 | "RenderCore", 50 | "MultiPackerRuntime", 51 | } 52 | ); 53 | 54 | #if UE_4_18_OR_LATER 55 | PrivateDependencyModuleNames.AddRange( 56 | new string[] 57 | { 58 | "ApplicationCore" 59 | } 60 | ); 61 | #endif 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/Factory/MultiPackerDatabaseFactory.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "Factory/MultiPackerDatabaseFactory.h" 3 | #include "MultiPackerDataBase.h" 4 | #include "PackageTools.h" 5 | 6 | #define LOCTEXT_NAMESPACE "MultiPacker" 7 | 8 | UMultiPackerDatabaseFactory::UMultiPackerDatabaseFactory(const FObjectInitializer& ObjectInitializer) 9 | : Super(ObjectInitializer) 10 | { 11 | bCreateNew = false; 12 | bEditAfterNew = true; 13 | SupportedClass = UMultiPackerDataBase::StaticClass(); 14 | } 15 | 16 | UObject* UMultiPackerDatabaseFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) 17 | { 18 | UMultiPackerDataBase* NewDataBase = NewObject(InParent, Class, Name, Flags | RF_Transactional); 19 | return NewDataBase; 20 | } 21 | 22 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/Factory/MultiPackerFactory.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "Factory/MultiPackerFactory.h" 3 | #include "UnrealEd.h" 4 | #include "IAssetTools.h" 5 | #include "PackageTools.h" 6 | #include "AssetToolsModule.h" 7 | #include "AssetRegistryModule.h" 8 | #include "ImageUtils.h" 9 | #include "Graph/MultiPacker.h" 10 | 11 | #define LOCTEXT_NAMESPACE "MultiPacker" 12 | 13 | UMultiPackerFactory::UMultiPackerFactory() 14 | { 15 | bCreateNew = true; 16 | bEditAfterNew = true; 17 | SupportedClass = UMultiPacker::StaticClass(); 18 | } 19 | 20 | UMultiPackerFactory::~UMultiPackerFactory() 21 | { 22 | } 23 | 24 | UObject* UMultiPackerFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) 25 | { 26 | UMultiPacker* Result = NewObject(InParent, Class, Name, Flags | RF_Transactional);//Flags 27 | Result->TargetName = *Name.ToString(); 28 | Result->Flags = Flags; 29 | Result->GetOutermost()->SetPackageFlags(PKG_EditorOnly); 30 | return Result; 31 | } 32 | 33 | FText UMultiPackerFactory::GetDisplayName() const 34 | { 35 | return LOCTEXT("UMultiPackerFactory", "MultiPacker Graph"); 36 | } 37 | 38 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/Factory/MultiPackerLayerDatabaseFactory.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "Factory/MultiPackerLayerDatabaseFactory.h" 3 | #include "MultiPackerLayerDatabase.h" 4 | #include "PackageTools.h" 5 | #include 6 | 7 | 8 | #define LOCTEXT_NAMESPACE "MultiPacker" 9 | 10 | UMultiPackerLayerDatabaseFactory::UMultiPackerLayerDatabaseFactory(const FObjectInitializer& ObjectInitializer) 11 | : Super(ObjectInitializer) 12 | { 13 | bCreateNew = true; 14 | bEditAfterNew = true; 15 | SupportedClass = UMultiPackerLayerDatabase::StaticClass(); 16 | } 17 | 18 | UObject* UMultiPackerLayerDatabaseFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) 19 | { 20 | UMultiPackerLayerDatabase* NewDataBase = NewObject(InParent, Class, Name, Flags | RF_Transactional); 21 | return NewDataBase; 22 | } 23 | 24 | FText UMultiPackerLayerDatabaseFactory::GetDisplayName() const 25 | { 26 | return LOCTEXT("UMultiPackerLayerDatabaseFactory", "LayerDatabase"); 27 | } 28 | 29 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/Factory/MultiPackerRuntimeGraphFactory.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "Factory/MultiPackerRuntimeGraphFactory.h" 3 | #include "UnrealEd.h" 4 | #include "IAssetTools.h" 5 | #include "PackageTools.h" 6 | #include "AssetToolsModule.h" 7 | #include "AssetRegistryModule.h" 8 | #include "ImageUtils.h" 9 | #include "MultiPackerRuntimeGraph.h" 10 | 11 | #define LOCTEXT_NAMESPACE "MultiPacker" 12 | 13 | UMultiPackerRuntimeGraphFactory::UMultiPackerRuntimeGraphFactory() 14 | { 15 | bCreateNew = true; 16 | bEditAfterNew = true; 17 | SupportedClass = UMultiPackerRuntimeGraph::StaticClass(); 18 | } 19 | 20 | UMultiPackerRuntimeGraphFactory::~UMultiPackerRuntimeGraphFactory() 21 | { 22 | } 23 | 24 | UObject* UMultiPackerRuntimeGraphFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) 25 | { 26 | UMultiPackerRuntimeGraph* Result = NewObject(InParent, Class, Name, Flags | RF_Transactional);//Flags 27 | //Result->TargetName = *Name.ToString(); 28 | //Result->Flags = Flags; 29 | return Result; 30 | } 31 | 32 | FText UMultiPackerRuntimeGraphFactory::GetDisplayName() const 33 | { 34 | return LOCTEXT("UMultiPackerRuntimeGraphFactory", "MultiPacker Runtime Graph"); 35 | } 36 | 37 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/LayerDatabase/MultiPackerLayerDatabaseAssetTypeActions.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "LayerDatabase/MultiPackerLayerDatabaseAssetTypeActions.h" 3 | #include "LayerDatabase/LayerStyleEditorToolkit.h" 4 | #include "MultiPackerLayerDatabase.h" 5 | 6 | #define LOCTEXT_NAMESPACE "AssetTypeActions" 7 | 8 | FMultiPackerLayerDatabaseAssetTypeActions::FMultiPackerLayerDatabaseAssetTypeActions(EAssetTypeCategories::Type InAssetCategory) 9 | : MyAssetCategory(InAssetCategory) 10 | { 11 | 12 | } 13 | 14 | FText FMultiPackerLayerDatabaseAssetTypeActions::GetName() const 15 | { 16 | return LOCTEXT("FMultiPackerLayerDatabaseAssetTypeActionsName", "LayerDatabase"); 17 | } 18 | 19 | FColor FMultiPackerLayerDatabaseAssetTypeActions::GetTypeColor() const 20 | { 21 | return FColor(129, 196, 115); 22 | } 23 | 24 | UClass* FMultiPackerLayerDatabaseAssetTypeActions::GetSupportedClass() const 25 | { 26 | return UMultiPackerLayerDatabase::StaticClass(); 27 | } 28 | 29 | void FMultiPackerLayerDatabaseAssetTypeActions::OpenAssetEditor(const TArray& InObjects, TSharedPtr EditWithinLevelEditor) 30 | { 31 | const EToolkitMode::Type Mode = EditWithinLevelEditor.IsValid() ? EToolkitMode::WorldCentric : EToolkitMode::Standalone; 32 | 33 | for (auto ObjIt = InObjects.CreateConstIterator(); ObjIt; ++ObjIt) 34 | { 35 | if (UMultiPackerLayerDatabase* Graph = Cast(*ObjIt)) 36 | { 37 | TSharedRef NewGraphEditor(new FLayerStyleEditorToolkit()); 38 | NewGraphEditor->Initialize(Graph, Mode, EditWithinLevelEditor); 39 | } 40 | } 41 | } 42 | 43 | uint32 FMultiPackerLayerDatabaseAssetTypeActions::GetCategories() 44 | { 45 | return MyAssetCategory; 46 | } 47 | 48 | ////////////////////////////////////////////////////////////////////////// 49 | 50 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/MultiPackerAssetEditor/MultiPackerAssetEditorToolbar.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "MultiPackerAssetEditor/MultiPackerAssetEditorToolbar.h" 3 | #include "MultiPackerAssetEditor/MultiPackerAssetEditor.h" 4 | #include "MultiPackerAssetEditor/MultiPackerEditorCommands.h" 5 | #include 6 | 7 | #define LOCTEXT_NAMESPACE "GenericGraphAssetEditorToolbar" 8 | 9 | void FMultiPackerAssetEditorToolbar::AddGenericGraphToolbar(TSharedPtr Extender) 10 | { 11 | check(GenericGraphEditor.IsValid()); 12 | TSharedPtr GenericGraphEditorPtr = GenericGraphEditor.Pin(); 13 | 14 | TSharedPtr ToolbarExtender = MakeShareable(new FExtender); 15 | ToolbarExtender->AddToolBarExtension("Asset", EExtensionHook::After, GenericGraphEditorPtr->GetToolkitCommands(), FToolBarExtensionDelegate::CreateSP( this, &FMultiPackerAssetEditorToolbar::FillMultiPackerToolbar )); 16 | GenericGraphEditorPtr->AddToolbarExtender(ToolbarExtender); 17 | } 18 | 19 | void FMultiPackerAssetEditorToolbar::FillMultiPackerToolbar(FToolBarBuilder& ToolbarBuilder) 20 | { 21 | check(GenericGraphEditor.IsValid()); 22 | ToolbarBuilder.BeginSection("MultiPacker"); 23 | { 24 | const FText GraphSettingsLabelOutput = LOCTEXT("GraphSettings_LabelOut", "Apply"); 25 | const FText GraphSettingsTipOutput = LOCTEXT("GraphSettings_ToolTipOut", "Apply the Settings"); 26 | GraphSettingsIconOutput = FSlateIcon(FEditorStyle::GetStyleSetName(), "MaterialEditor.Apply"); //"Kismet.Status.Good"); 27 | ToolbarBuilder.AddToolBarButton(FMultiPackerEditorCommands::Get().CompileGraphNodes, 28 | NAME_None, 29 | GraphSettingsLabelOutput, 30 | GraphSettingsTipOutput, 31 | GraphSettingsIconOutput); 32 | 33 | const FText GraphSettingsLabel = LOCTEXT("GraphSettings_Label", "Graph Settings"); 34 | const FText GraphSettingsTip = LOCTEXT("GraphSettings_ToolTip", "Show the Graph Settings"); 35 | const FSlateIcon GraphSettingsIcon = FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.GameSettings"); 36 | ToolbarBuilder.AddToolBarButton(FMultiPackerEditorCommands::Get().GraphSettings, 37 | NAME_None, 38 | GraphSettingsLabel, 39 | GraphSettingsTip, 40 | GraphSettingsIcon); 41 | } 42 | ToolbarBuilder.EndSection(); 43 | } 44 | 45 | 46 | #undef LOCTEXT_NAMESPACE 47 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/MultiPackerAssetEditor/MultiPackerEdGraph.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "MultiPackerAssetEditor/MultiPackerEdGraph.h" 3 | #include "Graph/MultiPacker.h" 4 | #include "EdGraph/EdGraphPin.h" 5 | #include "MultiPackerAssetEditor/Nodes/MultiPackerTextureEdNode.h" 6 | #include "MultiPackerAssetEditor/Nodes/MultiPackerOutputNode.h" 7 | #include "MultiPackerAssetEditor/Nodes/MultiPackerMaterialNode.h" 8 | #include "MultiPackerAssetEditor/MultiPackerEditorThumbnail.h" 9 | #include "Graph/MultiPackerTextureNode.h" 10 | 11 | UMultiPackerEdGraph::UMultiPackerEdGraph() 12 | { 13 | } 14 | 15 | UMultiPackerEdGraph::~UMultiPackerEdGraph() 16 | { 17 | } 18 | 19 | void UMultiPackerEdGraph::RebuildGenericGraph() 20 | { 21 | if (!IsRebuilding) 22 | { 23 | IsRebuilding = true; 24 | UMultiPacker* G = CastChecked(GetOuter()); 25 | G->ClearGraph(); 26 | for (int i = 0; i < Nodes.Num(); ++i) 27 | { 28 | UMultiPackerTextureEdNode* TexNode = Cast(Nodes[i]); 29 | 30 | if (TexNode == nullptr || TexNode->GenericGraphNode == nullptr) 31 | { 32 | UMultiPackerOutputNode* OutputNode = Cast(Nodes[i]); 33 | 34 | if (OutputNode == nullptr ) 35 | { 36 | UMultiPackerMaterialNode* MatNode = Cast(Nodes[i]); 37 | if (MatNode == nullptr || MatNode->MultiPackerMatNode == nullptr) 38 | continue; 39 | UMultiPackerMatNode* MNode = MatNode->MultiPackerMatNode; 40 | G->MatNodes.Add(MNode); 41 | } 42 | else 43 | { 44 | OutputNode->ProcessArrayThumbnail(); 45 | continue; 46 | } 47 | } 48 | else 49 | { 50 | UMultiPackerTextureNode* TNode = TexNode->GenericGraphNode; 51 | 52 | if (TNode->CanSetThumbnail()) 53 | { 54 | TexNode->AssetThumbnail = MakeShareable(new FAssetThumbnail(TNode->TextureInput, 128, 128, FMultiPackerEditorThumbnail::Get())); 55 | } 56 | G->TexNodes.Add(TNode); 57 | } 58 | } 59 | IsRebuilding = false; 60 | } 61 | } 62 | 63 | #if WITH_EDITOR 64 | void UMultiPackerEdGraph::PostEditUndo() 65 | { 66 | Super::PostEditUndo(); 67 | 68 | RebuildGenericGraph(); 69 | 70 | Modify(); 71 | } 72 | #endif 73 | 74 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/MultiPackerAssetEditor/MultiPackerEditorCommands.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "MultiPackerAssetEditor/MultiPackerEditorCommands.h" 3 | 4 | #define LOCTEXT_NAMESPACE "GenericGraphEditorCommands" 5 | 6 | void FMultiPackerEditorCommands::RegisterCommands() 7 | { 8 | UI_COMMAND(GraphSettings, "Graph Settings", "Graph Settings", EUserInterfaceActionType::Button, FInputChord()); 9 | UI_COMMAND(CompileGraphNodes, "Apply Changes", "Apply Changes", EUserInterfaceActionType::Button, FInputChord()); 10 | UI_COMMAND(CompileGraphMaterial, "Compile Material", "Compile Material", EUserInterfaceActionType::Button, FInputChord()); 11 | } 12 | 13 | #undef LOCTEXT_NAMESPACE 14 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/MultiPackerAssetEditor/Nodes/MultiPackerBaseNode.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "MultiPackerAssetEditor/Nodes/MultiPackerBaseNode.h" 3 | #include "MultiPackerAssetEditor/MultiPackerEdGraph.h" 4 | #include "MultiPackerBaseEnums.h" 5 | #include "TileUtils/TilePointer.h" 6 | 7 | #define LOCTEXT_NAMESPACE "MultiPackerBaseNode" 8 | 9 | UMultiPackerEdGraph* UMultiPackerBaseNode::GetGenericGraphEdGraph() 10 | { 11 | return Cast(GetGraph()); 12 | } 13 | 14 | FText UMultiPackerBaseNode::GetDescription() const 15 | { 16 | return FText::FromString("Texture"); 17 | } 18 | 19 | bool UMultiPackerBaseNode::GetMsdf() 20 | { 21 | return false; 22 | } 23 | 24 | bool UMultiPackerBaseNode::IsNodeSelectedSdf() 25 | { 26 | return false; 27 | } 28 | 29 | FTileThumbDatabase UMultiPackerBaseNode::GetTileThumbDatabase(uint16 num) 30 | { 31 | FTileThumbDatabase NewTileData; 32 | return NewTileData; 33 | } 34 | 35 | TArray UMultiPackerBaseNode::GetTiles(const uint16 size, FVector2D InTilePadding) 36 | { 37 | if (SizeTile != size || TilesNeedProcess()) 38 | { 39 | SizeTile = size; 40 | ProcessTiles(); 41 | } 42 | for (UTilePointer* Tile : Tiles) 43 | { 44 | Tile->TilePadding = InTilePadding; 45 | } 46 | return Tiles; 47 | } 48 | 49 | void UMultiPackerBaseNode::SetDatabase() 50 | { 51 | for (uint16 n = 0; n < Tiles.Num(); ++n) 52 | { 53 | FTileDatabase NewTileData; 54 | NewTileData.SetFromThumbDatabase(GetTileThumbDatabase(n), IsTilesSDF(), GetMsdf()); 55 | Tiles[n]->TileDatabase = NewTileData; 56 | } 57 | } 58 | 59 | bool UMultiPackerBaseNode::TilesNeedProcess() 60 | { 61 | return !TilesProcessed || TilesChanged; 62 | } 63 | 64 | void UMultiPackerBaseNode::ProcessTiles() 65 | { 66 | } 67 | 68 | bool UMultiPackerBaseNode::IsTilesSDF() 69 | { 70 | return IsNodeSelectedSdf() || GraphSDF; 71 | } 72 | 73 | bool UMultiPackerBaseNode::PinConnected() 74 | { 75 | return false; 76 | } 77 | 78 | bool UMultiPackerBaseNode::IsObjectValid() 79 | { 80 | return false; 81 | } 82 | 83 | uint16 UMultiPackerBaseNode::GetNumberTiles() 84 | { 85 | return 0; 86 | } 87 | 88 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/MultiPackerAssetEditor/Nodes/MultiPackerOutputNode.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "MultiPackerAssetEditor/Nodes/MultiPackerOutputNode.h" 3 | #include "MultiPackerEditorTypes.h" 4 | #include "MultiPackerAssetEditor/MultiPackerEditorThumbnail.h" 5 | #include "Runtime/Launch/Resources/Version.h" 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "AssetThumbnail.h" 11 | 12 | #define LOCTEXT_NAMESPACE "MultiPackerOutputEdNode" 13 | 14 | void UMultiPackerOutputNode::AllocateDefaultPins() 15 | { 16 | FEdGraphPinType newPin = FEdGraphPinType(); 17 | #if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION <= 18) 18 | newPin.PinCategory = UMultiPackerEditorTypes::SPinOutputNode; 19 | CreatePin(EGPD_Input, newPin, FString("Output"), 0); 20 | #endif 21 | #if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION > 18) 22 | newPin.PinCategory = FName(*UMultiPackerEditorTypes::SPinOutputNode); 23 | CreatePin(EGPD_Input, newPin, FName("Output"), 0); 24 | #endif 25 | } 26 | 27 | void UMultiPackerOutputNode::NodeConnectionListChanged() 28 | { 29 | Super::NodeConnectionListChanged(); 30 | GetGenericGraphEdGraph()->MultiPackerNode = true; 31 | } 32 | 33 | UMultiPackerEdGraph* UMultiPackerOutputNode::GetGenericGraphEdGraph() const 34 | { 35 | return Cast(GetGraph()); 36 | } 37 | 38 | bool UMultiPackerOutputNode::CanUserDeleteNode() const 39 | { 40 | return NodeOutput; 41 | } 42 | 43 | void UMultiPackerOutputNode::SetArrayThumnailOutput(TArray Input) 44 | { 45 | ArrayTextureOutput = Input; 46 | ProcessArrayThumbnail(); 47 | } 48 | 49 | int UMultiPackerOutputNode::GetNumTexturesArray() 50 | { 51 | return ArrayTextureOutput.Num(); 52 | } 53 | 54 | TSharedRef UMultiPackerOutputNode::GetThumbnailByNum(int Num) 55 | { 56 | //something inside me say this is a bomb waiting to explode 57 | return ArrayAssetThumbnail[Num].Get()->MakeThumbnailWidget(); 58 | } 59 | 60 | bool UMultiPackerOutputNode::IsThumbRectangled(int Num) 61 | { 62 | return ArrayRectangled[Num]; 63 | } 64 | 65 | FLinearColor UMultiPackerOutputNode::GetNodeTitleColor() const 66 | { 67 | return GetDefault()->ResultNodeTitleColor; 68 | } 69 | 70 | void UMultiPackerOutputNode::ProcessArrayThumbnail() 71 | { 72 | ArrayAssetThumbnail.Empty(ArrayTextureOutput.Num()); 73 | ArrayRectangled.Empty(ArrayTextureOutput.Num()); 74 | for (UTexture2D* Texture : ArrayTextureOutput) 75 | { 76 | FAssetData ValueAsset = FAssetData(Texture); 77 | bool TextureRectangled = Texture->GetSurfaceWidth() != Texture->GetSurfaceHeight() ? true : false; 78 | ArrayRectangled.Add(TextureRectangled); 79 | ArrayAssetThumbnail.Add(MakeShareable(new FAssetThumbnail(ValueAsset, TextureRectangled ? 64 : 128, 128, FMultiPackerEditorThumbnail::Get()))); 80 | } 81 | } 82 | 83 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/MultiPackerAssetEditor/Nodes/SMultiPackerMaterialNode.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "MultiPackerAssetEditor/Nodes/SMultiPackerMaterialNode.h" 3 | #include "MultiPackerAssetEditor/MultiPackerEditorThumbnail.h" 4 | #include "MultiPackerAssetEditor/MultiPackerColors.h" 5 | #include "AssetThumbnail.h" 6 | #include "AssetRegistryModule.h" 7 | #include 8 | #include 9 | 10 | void SMultiPackerMaterialNode::BuildThumbnailWidget() 11 | { 12 | EdActorNode->AssetThumbnail = MakeShareable(new FAssetThumbnail(FAssetData(EdActorNode->MultiPackerMatNode->MaterialBaseInput), ThumbnailSize.X, ThumbnailSize.Y, FMultiPackerEditorThumbnail::Get())); 13 | } 14 | ////////////////////////////////////////////////////////////////////////// 15 | 16 | void SMultiPackerMaterialNode::Construct(const FArguments& InArgs, UMultiPackerMaterialNode* InNode) 17 | { 18 | ThumbnailSize = FIntPoint(128, 128); 19 | GraphNode = InNode; 20 | EdActorNode = InNode; 21 | BuildThumbnailWidget(); 22 | UpdateGraphNode(); 23 | } 24 | 25 | void SMultiPackerMaterialNode::CreatePinWidgets() 26 | { 27 | UMultiPackerMaterialNode* StateNode = CastChecked(GraphNode); 28 | 29 | for (int32 PinIdx = 0; PinIdx < StateNode->Pins.Num(); PinIdx++) 30 | { 31 | UEdGraphPin* MyPin = StateNode->Pins[PinIdx]; 32 | if (!MyPin->bHidden) 33 | { 34 | TSharedPtr NewPin = CreatePinWidget(MyPin); 35 | 36 | AddPin(NewPin.ToSharedRef()); 37 | } 38 | } 39 | } 40 | 41 | void SMultiPackerMaterialNode::AddPin(const TSharedRef& PinToAdd) 42 | { 43 | PinToAdd->SetOwner(SharedThis(this)); 44 | 45 | if (PinToAdd->GetDirection() == EEdGraphPinDirection::EGPD_Output) 46 | { 47 | 48 | FMargin Padding = Settings->GetInputPinPadding(); 49 | Padding.Left *= 0.5f; 50 | Padding.Right = 0.0f; 51 | 52 | RightNodeBox->AddSlot() 53 | .HAlign(HAlign_Right) 54 | .AutoHeight() 55 | .Padding(Padding) 56 | [ 57 | PinToAdd 58 | ]; 59 | OutputPins.Add(PinToAdd); 60 | } 61 | } 62 | 63 | FSlateColor SMultiPackerMaterialNode::GetErrorColor() const 64 | { 65 | return FLinearColor(1.0f, 0.0f, 0.0f, 1.0f); 66 | } 67 | 68 | FText SMultiPackerMaterialNode::GetErrorMsgToolTip() const 69 | { 70 | FString Error = FString(TEXT("")); 71 | UMultiPackerMaterialNode* MyNode = CastChecked(GraphNode); 72 | if (!MyNode->MultiPackerMatNode->MaterialBaseInput) { 73 | Error = FString(TEXT("Need Material")); 74 | } 75 | if (MyNode->MultiPackerMatNode->TilesVertical==0) { 76 | Error = Error == FString(TEXT("")) ? FString(TEXT("Set TilesVertical")) : Error.Append(FString(TEXT(" & Set TilesVertical"))); 77 | } 78 | if (MyNode->MultiPackerMatNode->TilesHorizontal==0) { 79 | Error = Error == FString(TEXT("")) ? FString(TEXT("Set TilesHorizontal")) : Error.Append(FString(TEXT(" & Set TilesHorizontal"))); 80 | } 81 | ErrorText->SetError(Error); 82 | return FText::FromString(Error); 83 | } 84 | 85 | FSlateColor SMultiPackerMaterialNode::GetBorderBackgroundColor() const 86 | { 87 | UMultiPackerMaterialNode* MyNode = CastChecked(GraphNode); 88 | return MyNode ? MyNode->GetBackgroundColor() : MultiPackerColors::NodeBorder::HighlightAbortRange0; 89 | } 90 | 91 | FSlateColor SMultiPackerMaterialNode::GetBackgroundColor() const 92 | { 93 | return MultiPackerColors::NodeBody::Default; 94 | } 95 | 96 | EVisibility SMultiPackerMaterialNode::GetDragOverMarkerVisibility() const 97 | { 98 | return EVisibility::Visible; 99 | } 100 | 101 | FText SMultiPackerMaterialNode::GetDescription() const 102 | { 103 | UMultiPackerMaterialNode* MyNode = CastChecked(GraphNode); 104 | return MyNode ? MyNode->GetDescription() : FText::GetEmpty(); 105 | } 106 | 107 | EVisibility SMultiPackerMaterialNode::GetDescriptionVisibility() const 108 | { 109 | return EVisibility::Hidden; 110 | } 111 | 112 | const FSlateBrush* SMultiPackerMaterialNode::GetNameIcon() const 113 | { 114 | return FEditorStyle::GetBrush(TEXT("BTEditor.Graph.BTNode.Icon")); 115 | } 116 | 117 | TSharedRef SMultiPackerMaterialNode::CreateNodeContentArea() 118 | { 119 | // NODE CONTENT AREA 120 | return SNew(SBorder) 121 | .BorderImage(FEditorStyle::GetBrush("NoBorder")) 122 | .HAlign(HAlign_Fill) 123 | .VAlign(VAlign_Fill) 124 | [ 125 | SNew(SHorizontalBox) 126 | + SHorizontalBox::Slot() 127 | .HAlign(HAlign_Left) 128 | .FillWidth(1.0f) 129 | [ 130 | // LEFT 131 | SAssignNew(LeftNodeBox, SVerticalBox) 132 | + SVerticalBox::Slot() 133 | .AutoHeight() 134 | .HAlign(HAlign_Right) 135 | .VAlign(VAlign_Center) 136 | [ 137 | SNew(SBox) 138 | .WidthOverride(128) 139 | .HeightOverride(128) 140 | [ 141 | EdActorNode->AssetThumbnail->MakeThumbnailWidget() 142 | ] 143 | ] 144 | ] 145 | + SHorizontalBox::Slot() 146 | .AutoWidth() 147 | .HAlign(HAlign_Right) 148 | [ 149 | // RIGHT 150 | SAssignNew(RightNodeBox, SVerticalBox) 151 | 152 | ] 153 | ]; 154 | } 155 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/MultiPackerAssetEditor/Nodes/SMultiPackerOutputNode.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "MultiPackerAssetEditor/Nodes/SMultiPackerOutputNode.h" 3 | #include "CoreMinimal.h" 4 | #include "AssetThumbnail.h" 5 | #include "MultiPackerAssetEditor/MultiPackerEditorThumbnail.h" 6 | #include "SGraphPin.h" 7 | #include "GraphEditor.h" 8 | #include 9 | #include 10 | #include 11 | 12 | ////////////////////////////////////////////////////////////////////////// 13 | void SMultiPackerOutputNode::Construct(const FArguments& InArgs, UMultiPackerOutputNode* InNode) 14 | { 15 | GraphNode = InNode; 16 | EdActorNode = InNode; 17 | EdActorNode->ProcessArrayThumbnail(); 18 | UpdateGraphNode(); 19 | } 20 | 21 | void SMultiPackerOutputNode::CreatePinWidgets() 22 | { 23 | for (int32 PinIdx = 0; PinIdx < GraphNode->Pins.Num(); PinIdx++) 24 | { 25 | UEdGraphPin* MyPin = GraphNode->Pins[PinIdx]; 26 | TSharedPtr NewPin = CreatePinWidget(MyPin); 27 | AddPin(NewPin.ToSharedRef()); 28 | } 29 | } 30 | 31 | void SMultiPackerOutputNode::AddPin(const TSharedRef& PinToAdd) 32 | { 33 | PinToAdd->SetOwner(SharedThis(this)); 34 | if (PinToAdd->GetDirection() == EEdGraphPinDirection::EGPD_Input) 35 | { 36 | FMargin Padding = Settings->GetInputPinPadding(); 37 | Padding.Left *= 0.5f; 38 | Padding.Right = 0.0f; 39 | 40 | LeftNodeBox->AddSlot() 41 | .AutoHeight() 42 | .HAlign(HAlign_Left) 43 | .VAlign(VAlign_Center) 44 | .Padding(Padding) 45 | [ 46 | PinToAdd 47 | ]; 48 | InputPins.Add(PinToAdd); 49 | } 50 | } 51 | 52 | EVisibility SMultiPackerOutputNode::GetDragOverMarkerVisibility() const 53 | { 54 | return EVisibility::Visible; 55 | } 56 | 57 | FText SMultiPackerOutputNode::GetDescription() const 58 | { 59 | return FText::FromString("Texture"); 60 | } 61 | 62 | EVisibility SMultiPackerOutputNode::GetDescriptionVisibility() const 63 | { 64 | return EVisibility::Hidden; 65 | } 66 | 67 | const FSlateBrush* SMultiPackerOutputNode::GetNameIcon() const 68 | { 69 | return FEditorStyle::GetBrush(TEXT("BTEditor.Graph.BTNode.Icon")); 70 | } 71 | 72 | TSharedRef SMultiPackerOutputNode::CreateNodeContentArea() 73 | { 74 | // NODE CONTENT AREA 75 | return SNew(SBorder) 76 | .BorderImage(FEditorStyle::GetBrush("NoBorder")) 77 | .HAlign(HAlign_Fill) 78 | .VAlign(VAlign_Fill) 79 | [ 80 | SNew(SHorizontalBox) 81 | + SHorizontalBox::Slot() 82 | .HAlign(HAlign_Left) 83 | [ 84 | // LEFT 85 | SAssignNew(LeftNodeBox, SVerticalBox) 86 | ] 87 | + SHorizontalBox::Slot() 88 | .AutoWidth() 89 | .HAlign(HAlign_Right) 90 | [ 91 | // RIGHT 92 | SAssignNew(RightNodeBox, SVerticalBox) 93 | + SVerticalBox::Slot() 94 | .AutoHeight() 95 | .HAlign(HAlign_Right) 96 | .VAlign(VAlign_Center) 97 | [ 98 | CreateThumbnailContentArea() 99 | ] 100 | ] 101 | ]; 102 | } 103 | 104 | TSharedRef SMultiPackerOutputNode::CreateThumbnailContentArea() 105 | { 106 | //Get The Size of the Matrix to set Thumbnails 107 | int ArrayTexturesNum = EdActorNode->GetNumTexturesArray(); 108 | int MatrixSize = FMath::CeilToInt(FMath::Sqrt(ArrayTexturesNum));//get the number of columns and rows 109 | TSharedRef WrapSlot = SNew(SWrapBox) 110 | + SWrapBox::Slot() 111 | .HAlign(HAlign_Left) 112 | .VAlign(VAlign_Top); 113 | WrapSlot->SetWrapWidth((128 + 5) * MatrixSize); 114 | for (int Thumb = 0; Thumb < ArrayTexturesNum; ++Thumb) 115 | { 116 | WrapSlot->AddSlot() 117 | [ 118 | SNew(SBox) 119 | .Padding(5.0f) 120 | .MaxDesiredWidth(128.0f) 121 | .MaxDesiredHeight(EdActorNode->IsThumbRectangled(Thumb) ? 64.0f : 128.0f) 122 | .VAlign(VAlign_Center) 123 | [ 124 | EdActorNode->GetThumbnailByNum(Thumb) 125 | ] 126 | ]; 127 | } 128 | return WrapSlot; 129 | } 130 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/MultiPackerAssetEditor/Nodes/SMultiPackerTextureEdNode.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "MultiPackerAssetEditor/Nodes/SMultiPackerTextureEdNode.h" 3 | #include "AssetThumbnail.h" 4 | #include "AssetRegistryModule.h" 5 | #include "MultiPackerEditorTypes.h" 6 | #include "MultiPackerAssetEditor/MultiPackerEditorThumbnail.h" 7 | #include 8 | 9 | void SMultiPackerTextureEdNode::BuildThumbnailWidget() 10 | { 11 | UTexture* C = EdActorNode->GenericGraphNode->TextureInput; 12 | FAssetData ValueAsset = FAssetData(C); 13 | EdActorNode->AssetThumbnail = MakeShareable(new FAssetThumbnail(FAssetData(C), ThumbnailSize.X, ThumbnailSize.Y, FMultiPackerEditorThumbnail::Get())); 14 | } 15 | ////////////////////////////////////////////////////////////////////////// 16 | void SMultiPackerTextureEdNode::Construct(const FArguments& InArgs, UMultiPackerTextureEdNode* InNode) 17 | { 18 | ThumbnailSize = FIntPoint(128, 128); 19 | GraphNode = InNode; 20 | EdActorNode = InNode; 21 | BuildThumbnailWidget(); 22 | UpdateGraphNode(); 23 | } 24 | 25 | void SMultiPackerTextureEdNode::CreatePinWidgets() 26 | { 27 | UMultiPackerTextureEdNode* StateNode = CastChecked(GraphNode); 28 | for (int32 PinIdx = 0; PinIdx < StateNode->Pins.Num(); ++PinIdx) 29 | { 30 | UEdGraphPin* MyPin = StateNode->Pins[PinIdx]; 31 | TSharedPtr NewPin = SNew(SGraphPin, MyPin).UsePinColorForText(false); 32 | AddPin(NewPin.ToSharedRef()); 33 | } 34 | } 35 | 36 | void SMultiPackerTextureEdNode::AddPin(const TSharedRef& PinToAdd) 37 | { 38 | PinToAdd->SetOwner(SharedThis(this)); 39 | if (PinToAdd->GetDirection() == EEdGraphPinDirection::EGPD_Output) 40 | { 41 | FMargin Padding = Settings->GetInputPinPadding(); 42 | Padding.Left *= 0.5f; 43 | Padding.Right = 0.0f; 44 | 45 | RightNodeBox->AddSlot() 46 | .HAlign(HAlign_Right) 47 | .AutoHeight() 48 | .Padding(Padding) 49 | [ 50 | PinToAdd 51 | ]; 52 | OutputPins.Add(PinToAdd); 53 | } 54 | } 55 | 56 | FSlateColor SMultiPackerTextureEdNode::GetErrorColor() const 57 | { 58 | return FLinearColor(1.0f, 0.0f, 0.0f, 1.0f); 59 | } 60 | 61 | FText SMultiPackerTextureEdNode::GetErrorMsgToolTip() const 62 | { 63 | FString Error = FString(TEXT("")); 64 | UMultiPackerTextureEdNode* MyNode = CastChecked(GraphNode); 65 | if (!MyNode->GenericGraphNode->TextureInput) { 66 | Error = FString(TEXT("Need Texture")); 67 | } 68 | if (MyNode->GenericGraphNode->TilesVertical == 0) { 69 | Error = Error== FString(TEXT("")) ? FString(TEXT("Set TilesVertical")): Error.Append(FString(TEXT(" & Set TilesVertical"))); 70 | } 71 | if (MyNode->GenericGraphNode->TilesHorizontal == 0) { 72 | Error = Error == FString(TEXT("")) ? FString(TEXT("Set TilesHorizontal")) : Error.Append(FString(TEXT(" & Set TilesHorizontal"))); 73 | } 74 | ErrorText->SetError(Error); 75 | return FText::FromString(Error); 76 | } 77 | 78 | FSlateColor SMultiPackerTextureEdNode::GetBorderBackgroundColor() const 79 | { 80 | UMultiPackerTextureEdNode* MyNode = CastChecked(GraphNode); 81 | return MyNode ? MyNode->GetBackgroundColor() : MultiPackerColors::NodeBorder::HighlightAbortRange0; 82 | } 83 | 84 | FSlateColor SMultiPackerTextureEdNode::GetBackgroundColor() const 85 | { 86 | return MultiPackerColors::NodeBody::Default; 87 | } 88 | 89 | EVisibility SMultiPackerTextureEdNode::GetDragOverMarkerVisibility() const 90 | { 91 | return EVisibility::Visible; 92 | } 93 | 94 | FText SMultiPackerTextureEdNode::GetDescription() const 95 | { 96 | UMultiPackerTextureEdNode* MyNode = CastChecked(GraphNode); 97 | return MyNode ? MyNode->GetDescription() : FText::GetEmpty(); 98 | } 99 | 100 | EVisibility SMultiPackerTextureEdNode::GetDescriptionVisibility() const 101 | { 102 | return EVisibility::Hidden; 103 | } 104 | 105 | const FSlateBrush* SMultiPackerTextureEdNode::GetNameIcon() const 106 | { 107 | return FEditorStyle::GetBrush(TEXT("BTEditor.Graph.BTNode.Icon")); 108 | } 109 | 110 | TSharedRef SMultiPackerTextureEdNode::CreateNodeContentArea() 111 | { 112 | // NODE CONTENT AREA 113 | return SNew(SBorder) 114 | .BorderImage(FEditorStyle::GetBrush("NoBorder")) 115 | .HAlign(HAlign_Fill) 116 | .VAlign(VAlign_Fill) 117 | [ 118 | SNew(SHorizontalBox) 119 | + SHorizontalBox::Slot() 120 | .HAlign(HAlign_Left) 121 | .FillWidth(1.0f) 122 | [ 123 | // LEFT 124 | SAssignNew(LeftNodeBox, SVerticalBox) 125 | + SVerticalBox::Slot() 126 | .AutoHeight() 127 | .HAlign(HAlign_Right) 128 | .VAlign(VAlign_Center) 129 | [ 130 | SNew(SBox) 131 | .WidthOverride(128) 132 | .HeightOverride(128) 133 | [ 134 | EdActorNode->AssetThumbnail->MakeThumbnailWidget() 135 | ] 136 | ] 137 | ] 138 | + SHorizontalBox::Slot() 139 | .AutoWidth() 140 | .HAlign(HAlign_Right) 141 | [ 142 | // RIGHT 143 | SAssignNew(RightNodeBox, SVerticalBox) 144 | 145 | ] 146 | ]; 147 | } 148 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/MultiPackerAssetEditor/SAssetDropTargetArray.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "MultiPackerAssetEditor/SAssetDropTargetArray.h" 3 | #include "AssetData.h" 4 | #include "DragAndDrop/AssetDragDropOp.h" 5 | #include "DragAndDrop/ActorDragDropOp.h" 6 | #include "AssetSelection.h" 7 | #include "Runtime/Launch/Resources/Version.h" 8 | 9 | #define LOCTEXT_NAMESPACE "EditorWidgets" 10 | 11 | void SAssetDropTargetArray::Construct(const FArguments& InArgs) 12 | { 13 | OnAssetDropped = InArgs._OnAssetDropped; 14 | OnIsAssetAcceptableForDrop = InArgs._OnIsAssetAcceptableForDrop; 15 | 16 | SDropTarget::Construct( 17 | SDropTarget::FArguments() 18 | .OnDrop(this, &SAssetDropTargetArray::OnDropped) 19 | [ 20 | InArgs._Content.Widget 21 | ]); 22 | } 23 | 24 | uint8 SAssetDropTargetArray::GetRow() 25 | { 26 | return RowAssetDrop; 27 | } 28 | 29 | uint8 SAssetDropTargetArray::GetColumn() 30 | { 31 | return ColumnAssetDrop; 32 | } 33 | 34 | FReply SAssetDropTargetArray::OnDropped(TSharedPtr DragDropOperation) 35 | { 36 | bool bUnused; 37 | TArray Objects = GetDroppedObject(DragDropOperation, bUnused); 38 | ArrayObjectNum = 0; 39 | ArrayObjectDropTotal = Objects.Num(); 40 | int MatrixSize = FMath::CeilToInt(FMath::Sqrt(ArrayObjectDropTotal));//get the number of columns and rows 41 | for (UObject* Object :Objects) 42 | { 43 | ColumnAssetDrop = ArrayObjectNum / MatrixSize; 44 | RowAssetDrop = ArrayObjectNum - (ColumnAssetDrop * MatrixSize); 45 | OnAssetDropped.ExecuteIfBound(Object); 46 | ArrayObjectNum++; 47 | } 48 | 49 | return FReply::Handled(); 50 | } 51 | 52 | bool SAssetDropTargetArray::OnAllowDrop(TSharedPtr DragDropOperation) const 53 | { 54 | bool bUnused = false; 55 | TArray Objects = GetDroppedObject(DragDropOperation, bUnused); 56 | for (UObject* Object : Objects) 57 | { 58 | // Check and see if its valid to drop this object 59 | if (OnIsAssetAcceptableForDrop.IsBound()) 60 | { 61 | return OnIsAssetAcceptableForDrop.Execute(Object); 62 | } 63 | else 64 | { 65 | // If no delegate is bound assume its always valid to drop this object 66 | return true; 67 | } 68 | } 69 | 70 | return false; 71 | } 72 | 73 | bool SAssetDropTargetArray::OnIsRecognized(TSharedPtr DragDropOperation) const 74 | { 75 | bool bRecognizedEvent = false; 76 | TArray Object = GetDroppedObject(DragDropOperation, bRecognizedEvent); 77 | 78 | return bRecognizedEvent; 79 | } 80 | 81 | TArray SAssetDropTargetArray::GetDroppedObject(TSharedPtr DragDropOperation, bool& bOutRecognizedEvent) const 82 | { 83 | bOutRecognizedEvent = false; 84 | TArray DropppedArray; 85 | 86 | 87 | // Asset being dragged from content browser 88 | if (DragDropOperation->IsOfType()) 89 | { 90 | bOutRecognizedEvent = true; 91 | TSharedPtr DragDropOp = StaticCastSharedPtr(DragDropOperation); 92 | 93 | #if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION <= 16) 94 | const TArray& DroppedAssets = DragDropOp->AssetData; 95 | #endif 96 | #if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION == 17) 97 | const TArray& DroppedAssets = DragDropOp->GetAssets(); 98 | #endif 99 | #if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION >= 18) 100 | const TArray& DroppedAssets = DragDropOp->GetAssets(); 101 | #endif 102 | if (DroppedAssets.Num() < 1) 103 | { 104 | return DropppedArray; 105 | } 106 | for (FAssetData AssetData : DroppedAssets) 107 | { 108 | DropppedArray.Add(AssetData.GetAsset()); 109 | } 110 | } 111 | // Asset being dragged from some external source 112 | else if (DragDropOperation->IsOfType()) 113 | { 114 | TArray DroppedAssetData = AssetUtil::ExtractAssetDataFromDrag(DragDropOperation); 115 | if (DroppedAssetData.Num() < 1) 116 | { 117 | return DropppedArray; 118 | } 119 | for (FAssetData DroppedAsset : DroppedAssetData) 120 | { 121 | bOutRecognizedEvent = true; 122 | DropppedArray.Add(DroppedAsset.GetAsset()); 123 | } 124 | } 125 | // Actor being dragged? 126 | else if (DragDropOperation->IsOfType()) 127 | { 128 | bOutRecognizedEvent = true; 129 | TSharedPtr ActorDragDrop = StaticCastSharedPtr(DragDropOperation); 130 | if (ActorDragDrop->Actors.Num() < 1) 131 | { 132 | return DropppedArray; 133 | } 134 | for (TWeakObjectPtr ActorDD : ActorDragDrop->Actors) 135 | { 136 | DropppedArray.Add(ActorDD.Get()); 137 | } 138 | } 139 | 140 | return DropppedArray; 141 | } 142 | 143 | #undef LOCTEXT_NAMESPACE 144 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/MultiPackerAssetEditor/SMultiPackerAssetEditorDrop.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "MultiPackerAssetEditor/SMultiPackerAssetEditorDrop.h" 3 | 4 | FReply SMultiPackerAssetEditorDrop::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) 5 | { 6 | PanelCoordDropPosition = MyGeometry.AbsoluteToLocal(DragDropEvent.GetScreenSpacePosition()); 7 | return SAssetDropTargetArray::OnDrop(MyGeometry, DragDropEvent); 8 | } 9 | 10 | void SMultiPackerAssetEditorDrop::Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) 11 | { 12 | SAssetDropTargetArray::Tick(AllottedGeometry, InCurrentTime, InDeltaTime); 13 | 14 | // Enable mouse integration while dragging 15 | if (GetDragOverlayVisibility().IsVisible()) 16 | { 17 | SetVisibility(EVisibility::Visible); 18 | } 19 | else 20 | { 21 | SetVisibility(EVisibility::SelfHitTestInvisible); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/MultiPackerAssetTypeActions.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "MultiPackerAssetTypeActions.h" 3 | #include "MultiPackerAssetEditor/MultiPackerAssetEditor.h" 4 | 5 | #define LOCTEXT_NAMESPACE "AssetTypeActions" 6 | 7 | FMultiPackerAssetTypeActions::FMultiPackerAssetTypeActions(EAssetTypeCategories::Type InAssetCategory) 8 | : MyAssetCategory(InAssetCategory) 9 | { 10 | } 11 | 12 | FText FMultiPackerAssetTypeActions::GetName() const 13 | { 14 | return LOCTEXT("FMultiPackerAssetTypeActionsName", "MultiPacker"); 15 | } 16 | 17 | FColor FMultiPackerAssetTypeActions::GetTypeColor() const 18 | { 19 | return FColor(129, 196, 115); 20 | } 21 | 22 | UClass* FMultiPackerAssetTypeActions::GetSupportedClass() const 23 | { 24 | return UMultiPacker::StaticClass(); 25 | } 26 | 27 | void FMultiPackerAssetTypeActions::OpenAssetEditor(const TArray& InObjects, TSharedPtr EditWithinLevelEditor) 28 | { 29 | const EToolkitMode::Type Mode = EditWithinLevelEditor.IsValid() ? EToolkitMode::WorldCentric : EToolkitMode::Standalone; 30 | 31 | for (auto ObjIt = InObjects.CreateConstIterator(); ObjIt; ++ObjIt) 32 | { 33 | if (UMultiPacker* Graph = Cast(*ObjIt)) 34 | { 35 | TSharedRef NewGraphEditor(new FMultiPackerAssetEditor()); 36 | NewGraphEditor->InitGenericGraphAssetEditor(Mode, EditWithinLevelEditor, Graph); 37 | } 38 | } 39 | } 40 | 41 | uint32 FMultiPackerAssetTypeActions::GetCategories() 42 | { 43 | return MyAssetCategory;//EAssetTypeCategories::Animation | 44 | } 45 | 46 | ////////////////////////////////////////////////////////////////////////// 47 | 48 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/MultiPackerEditorTypes.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "MultiPackerEditorTypes.h" 3 | 4 | const FString UMultiPackerEditorTypes::SPinMaterialNode("MaterialNode"); 5 | const FString UMultiPackerEditorTypes::SPinTextureNode("TextureNode"); 6 | const FString UMultiPackerEditorTypes::SPinOutputNode("OutputNode"); 7 | const FString UMultiPackerEditorTypes::PinCategory_MultipleNodes("MultipleNodes"); 8 | const FString UMultiPackerEditorTypes::PinCategory_SingleNode("SingleNode"); 9 | const FString UMultiPackerEditorTypes::PinCategory_RGB("RGB"); 10 | const FString UMultiPackerEditorTypes::PinCategory_Red("Red"); 11 | const FString UMultiPackerEditorTypes::PinCategory_Green("Green"); 12 | const FString UMultiPackerEditorTypes::PinCategory_Blue("Blue"); 13 | const FString UMultiPackerEditorTypes::PinCategory_Alpha("Alpha"); 14 | const FString UMultiPackerEditorTypes::PinCategory_RGBA("RGBA"); 15 | 16 | UMultiPackerEditorTypes::UMultiPackerEditorTypes(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) 17 | { 18 | } 19 | 20 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/RuntimeGraph/MultiPackerRuntimeAssetEditorToolbar.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "RuntimeGraph/MultiPackerRuntimeAssetEditorToolbar.h" 3 | #include "RuntimeGraph/MultiPackerRuntimeAssetEditor.h" 4 | #include "MultiPackerAssetEditor/MultiPackerEditorCommands.h" 5 | 6 | 7 | #define LOCTEXT_NAMESPACE "GenericGraphRuntimeAssetEditorToolbar" 8 | 9 | void FMultiPackerRuntimeAssetEditorToolbar::AddGenericGraphToolbar(TSharedPtr Extender) 10 | { 11 | check(GenericGraphEditor.IsValid()); 12 | TSharedPtr GenericGraphEditorPtr = GenericGraphEditor.Pin(); 13 | 14 | TSharedPtr ToolbarExtender = MakeShareable(new FExtender); 15 | ToolbarExtender->AddToolBarExtension("Asset", EExtensionHook::After, GenericGraphEditorPtr->GetToolkitCommands(), FToolBarExtensionDelegate::CreateSP( this, &FMultiPackerRuntimeAssetEditorToolbar::FillGenericGraphToolbar )); 16 | GenericGraphEditorPtr->AddToolbarExtender(ToolbarExtender); 17 | } 18 | 19 | void FMultiPackerRuntimeAssetEditorToolbar::FillGenericGraphToolbar(FToolBarBuilder& ToolbarBuilder) 20 | { 21 | check(GenericGraphEditor.IsValid()); 22 | TSharedPtr GenericGraphEditorPtr = GenericGraphEditor.Pin(); 23 | 24 | ToolbarBuilder.BeginSection("MultiPacker"); 25 | { 26 | 27 | //Set("Kismet.Status.Unknown", new IMAGE_BRUSH("Old/Kismet2/CompileStatus_Working", Icon40x40)); SlateEditorStyle.cpp 28 | //Set("Kismet.Status.Error", new IMAGE_BRUSH("Old/Kismet2/CompileStatus_Fail", Icon40x40)); 29 | //Set("Kismet.Status.Good", new IMAGE_BRUSH("Old/Kismet2/CompileStatus_Good", Icon40x40)); 30 | const FText GraphSettingsLabelOutput = LOCTEXT("GraphSettings_LabelOut", "Apply"); 31 | const FText GraphSettingsTipOutput = LOCTEXT("GraphSettings_ToolTipOut", "Apply"); 32 | GraphSettingsIconOutput = FSlateIcon(FEditorStyle::GetStyleSetName(), "MaterialEditor.Apply"); //Kismet.Status.Good"); 33 | ToolbarBuilder.AddToolBarButton(FMultiPackerEditorCommands::Get().CompileGraphNodes, 34 | NAME_None, 35 | GraphSettingsLabelOutput, 36 | GraphSettingsTipOutput, 37 | GraphSettingsIconOutput); 38 | 39 | const FText GraphSettingsLabel = LOCTEXT("GraphSettings_Label", "Graph Settings"); 40 | const FText GraphSettingsTip = LOCTEXT("GraphSettings_ToolTip", "Show the Graph Settings"); 41 | const FSlateIcon GraphSettingsIcon = FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.GameSettings"); 42 | ToolbarBuilder.AddToolBarButton(FMultiPackerEditorCommands::Get().GraphSettings, 43 | NAME_None, 44 | GraphSettingsLabel, 45 | GraphSettingsTip, 46 | GraphSettingsIcon); 47 | 48 | } 49 | ToolbarBuilder.EndSection(); 50 | 51 | } 52 | 53 | 54 | #undef LOCTEXT_NAMESPACE 55 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/RuntimeGraph/MultiPackerRuntimeAssetTypeActions.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "RuntimeGraph/MultiPackerRuntimeAssetTypeActions.h" 3 | #include "RuntimeGraph/MultiPackerRuntimeAssetEditor.h" 4 | 5 | #define LOCTEXT_NAMESPACE "AssetTypeActions" 6 | 7 | FMultiPackerRuntimeAssetTypeActions::FMultiPackerRuntimeAssetTypeActions(EAssetTypeCategories::Type InAssetCategory) 8 | : MyAssetCategory(InAssetCategory) 9 | { 10 | } 11 | 12 | FText FMultiPackerRuntimeAssetTypeActions::GetName() const 13 | { 14 | return LOCTEXT("FMultiPackerRuntimeAssetTypeActionsName", "MultiPacker Runtime Graph"); 15 | } 16 | 17 | FColor FMultiPackerRuntimeAssetTypeActions::GetTypeColor() const 18 | { 19 | return FColor(129, 196, 115); 20 | } 21 | 22 | UClass* FMultiPackerRuntimeAssetTypeActions::GetSupportedClass() const 23 | { 24 | return UMultiPackerRuntimeGraph::StaticClass(); 25 | } 26 | 27 | void FMultiPackerRuntimeAssetTypeActions::OpenAssetEditor(const TArray& InObjects, TSharedPtr EditWithinLevelEditor) 28 | { 29 | const EToolkitMode::Type Mode = EditWithinLevelEditor.IsValid() ? EToolkitMode::WorldCentric : EToolkitMode::Standalone; 30 | 31 | for (auto ObjIt = InObjects.CreateConstIterator(); ObjIt; ++ObjIt) 32 | { 33 | if (UMultiPackerRuntimeGraph* Graph = Cast(*ObjIt)) 34 | { 35 | TSharedRef NewGraphEditor(new FMultiPackerRuntimeAssetEditor()); 36 | NewGraphEditor->InitGenericGraphAssetEditor(Mode, EditWithinLevelEditor, Graph); 37 | } 38 | } 39 | } 40 | 41 | uint32 FMultiPackerRuntimeAssetTypeActions::GetCategories() 42 | { 43 | return MyAssetCategory; 44 | } 45 | 46 | ////////////////////////////////////////////////////////////////////////// 47 | 48 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/RuntimeGraph/MultiPackerRuntimeEdGraph.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "RuntimeGraph/MultiPackerRuntimeEdGraph.h" 3 | #include "EdGraph/EdGraphPin.h" 4 | #include "RuntimeGraph/Nodes/MultiPackerRuntimeOutputNode.h" 5 | #include "RuntimeGraph/Nodes/MultiPackerRuntimeMaterialNode.h" 6 | #include "MultiPackerAssetEditor/MultiPackerEditorThumbnail.h" 7 | #include "MultiPackerRuntimeGraph.h" 8 | 9 | UMultiPackerRuntimeEdGraph::UMultiPackerRuntimeEdGraph() 10 | { 11 | } 12 | 13 | UMultiPackerRuntimeEdGraph::~UMultiPackerRuntimeEdGraph() 14 | { 15 | //destructor 16 | } 17 | 18 | void UMultiPackerRuntimeEdGraph::RebuildGenericGraph() 19 | { 20 | if (!IsRebuilding) 21 | { 22 | IsRebuilding = true; 23 | UMultiPackerRuntimeGraph* G = CastChecked(GetOuter()); 24 | G->ClearGraph(); 25 | for (int i = 0; i < Nodes.Num(); ++i) 26 | { 27 | UMultiPackerRuntimeOutputNode* OutNode = Cast(Nodes[i]); 28 | 29 | if (OutNode == nullptr) 30 | { 31 | UMultiPackerRuntimeMaterialNode* MaterialNode = Cast(Nodes[i]); 32 | if (MaterialNode == nullptr || MaterialNode->MultiPackerRuntimeMatNode == nullptr) 33 | continue; 34 | UMultiPackerRuntimeMatNode* MatNode = MaterialNode->MultiPackerRuntimeMatNode; 35 | G->MatNodes.Add(MatNode); 36 | 37 | for (int PinIdx = 0; PinIdx < MaterialNode->Pins.Num(); ++PinIdx) 38 | { 39 | UEdGraphPin* Pin = MaterialNode->Pins[PinIdx]; 40 | 41 | if (Pin->Direction != EEdGraphPinDirection::EGPD_Output) 42 | continue; 43 | 44 | for (int LinkToIdx = 0; LinkToIdx < Pin->LinkedTo.Num(); ++LinkToIdx) 45 | { 46 | UMultiPackerRuntimeOutputNode* ChildEdNode = Cast(Pin->LinkedTo[LinkToIdx]->GetOwningNode()); 47 | 48 | if (ChildEdNode == nullptr) 49 | continue; 50 | } 51 | } 52 | } 53 | else 54 | { 55 | continue; 56 | } 57 | } 58 | IsRebuilding = false; 59 | } 60 | } 61 | 62 | #if WITH_EDITOR 63 | void UMultiPackerRuntimeEdGraph::PostEditUndo() 64 | { 65 | Super::PostEditUndo(); 66 | 67 | RebuildGenericGraph(); 68 | 69 | Modify(); 70 | } 71 | #endif 72 | 73 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/RuntimeGraph/Nodes/MultiPackerRuntimeMaterialNode.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "RuntimeGraph/Nodes/MultiPackerRuntimeMaterialNode.h" 3 | #include "MultiPackerRuntimeMatNode.h" 4 | #include "MultiPackerEditorTypes.h" 5 | #include 6 | #include "Runtime/Launch/Resources/Version.h" 7 | 8 | #define LOCTEXT_NAMESPACE "MultiPackerRuntimeMaterialNode" 9 | 10 | void UMultiPackerRuntimeMaterialNode::AllocateDefaultPins() 11 | { 12 | FEdGraphPinType newPin = FEdGraphPinType(); 13 | #if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION <= 18) 14 | newPin.PinCategory = UMultiPackerEditorTypes::SPinMaterialNode; 15 | CreatePin(EGPD_Output, newPin, FString("Out"), 0); 16 | #endif 17 | #if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION > 18) 18 | newPin.PinCategory = FName(*UMultiPackerEditorTypes::SPinMaterialNode); 19 | CreatePin(EGPD_Output, newPin, FName("Out"), 0); 20 | #endif 21 | } 22 | 23 | void UMultiPackerRuntimeMaterialNode::NodeConnectionListChanged() 24 | { 25 | Super::NodeConnectionListChanged(); 26 | } 27 | 28 | UMultiPackerRuntimeEdGraph* UMultiPackerRuntimeMaterialNode::GetGenericGraphEdGraph() 29 | { 30 | return Cast(GetGraph()); 31 | } 32 | 33 | FText UMultiPackerRuntimeMaterialNode::GetNodeTitle(ENodeTitleType::Type TitleType) const 34 | { 35 | if (MultiPackerRuntimeMatNode == nullptr) 36 | { 37 | return Super::GetNodeTitle(TitleType); 38 | } 39 | else 40 | { 41 | MultiPackerRuntimeMatNode->ChangeBackground(false); 42 | return FText::FromString(MultiPackerRuntimeMatNode->MaterialBaseInput ? MultiPackerRuntimeMatNode->MaterialBaseInput->GetName() : "Empty"); 43 | } 44 | } 45 | 46 | void UMultiPackerRuntimeMaterialNode::SetGenericGraphNode(UMultiPackerRuntimeMatNode* InNode) 47 | { 48 | MultiPackerRuntimeMatNode = InNode; 49 | } 50 | 51 | FString UMultiPackerRuntimeMaterialNode::GetNodeTitle() 52 | { 53 | return (MultiPackerRuntimeMatNode->MaterialBaseInput ? MultiPackerRuntimeMatNode->MaterialBaseInput->GetName() : "Empty"); 54 | } 55 | 56 | bool UMultiPackerRuntimeMaterialNode::SetThumbnail() 57 | { 58 | return true; 59 | } 60 | 61 | void UMultiPackerRuntimeMaterialNode::SetMaterialInput(UMaterialInterface* Material) 62 | { 63 | MultiPackerRuntimeMatNode->MaterialBaseInput = Material; 64 | } 65 | 66 | FText UMultiPackerRuntimeMaterialNode::GetDescription() const 67 | { 68 | return FText::FromString("Texture"); 69 | } 70 | 71 | UObject* UMultiPackerRuntimeMaterialNode::GetThumbnailAssetObject() 72 | { 73 | return MultiPackerRuntimeMatNode->MaterialBaseInput; 74 | } 75 | 76 | UObject* UMultiPackerRuntimeMaterialNode::GetNodeAssetObject(UObject* Outer) 77 | { 78 | return MultiPackerRuntimeMatNode->MaterialBaseInput; 79 | } 80 | 81 | FLinearColor UMultiPackerRuntimeMaterialNode::GetBackgroundColor() const 82 | { 83 | return MultiPackerRuntimeMatNode->GetBackground(); 84 | } 85 | 86 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/RuntimeGraph/Nodes/MultiPackerRuntimeOutputNode.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "RuntimeGraph/Nodes/MultiPackerRuntimeOutputNode.h" 3 | #include "MultiPackerEditorTypes.h" 4 | #include "MultiPackerAssetEditor/MultiPackerEditorThumbnail.h" 5 | #include "Runtime/Launch/Resources/Version.h" 6 | #include 7 | #include 8 | #include "RuntimeGraph/MultiPackerRuntimeEdGraph.h" 9 | 10 | #define LOCTEXT_NAMESPACE "MultiPackerOutputEdNode" 11 | 12 | void UMultiPackerRuntimeOutputNode::AllocateDefaultPins() 13 | { 14 | FEdGraphPinType newPin = FEdGraphPinType(); 15 | #if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION <= 18) 16 | newPin.PinCategory = UMultiPackerEditorTypes::SPinOutputNode; 17 | CreatePin(EGPD_Input, newPin, FString("Output"), 0); 18 | #endif 19 | #if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION > 18) 20 | newPin.PinCategory = FName(*UMultiPackerEditorTypes::SPinOutputNode); 21 | CreatePin(EGPD_Input, newPin, FName("Output"), 0); 22 | #endif 23 | } 24 | 25 | void UMultiPackerRuntimeOutputNode::NodeConnectionListChanged() 26 | { 27 | Super::NodeConnectionListChanged(); 28 | Cast(GetGraph())->MultiPackerNode = true; 29 | } 30 | 31 | bool UMultiPackerRuntimeOutputNode::CanUserDeleteNode() const 32 | { 33 | return false; 34 | } 35 | 36 | void UMultiPackerRuntimeOutputNode::SetThumnailOutput(UTexture2D* Input) 37 | { 38 | if (Input == nullptr) 39 | Input = TextureInput; 40 | 41 | if (Input) 42 | TextureInput = Input; 43 | 44 | AssetThumbnail = MakeShareable(new FAssetThumbnail(TextureInput, 128, 128, FMultiPackerEditorThumbnail::Get())); 45 | } 46 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/RuntimeGraph/Nodes/SMultiPackerRuntimeMaterialNode.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "RuntimeGraph/Nodes/SMultiPackerRuntimeMaterialNode.h" 3 | #include "MultiPackerAssetEditor/MultiPackerEditorThumbnail.h" 4 | #include "MultiPackerAssetEditor/MultiPackerColors.h" 5 | #include "AssetThumbnail.h" 6 | #include "AssetRegistryModule.h" 7 | #include 8 | #include 9 | 10 | void SMultiPackerRuntimeMaterialNode::BuildThumbnailWidget() 11 | { 12 | EdActorNode->AssetThumbnail = MakeShareable(new FAssetThumbnail(FAssetData(EdActorNode->MultiPackerRuntimeMatNode->MaterialBaseInput), ThumbnailSize.X, ThumbnailSize.Y, FMultiPackerEditorThumbnail::Get())); 13 | } 14 | ////////////////////////////////////////////////////////////////////////// 15 | void SMultiPackerRuntimeMaterialNode::Construct(const FArguments& InArgs, UMultiPackerRuntimeMaterialNode* InNode) 16 | { 17 | ThumbnailSize = FIntPoint(128, 128); 18 | GraphNode = InNode; 19 | EdActorNode = InNode; 20 | BuildThumbnailWidget(); 21 | UpdateGraphNode(); 22 | } 23 | 24 | void SMultiPackerRuntimeMaterialNode::CreatePinWidgets() 25 | { 26 | UMultiPackerRuntimeMaterialNode* StateNode = CastChecked(GraphNode); 27 | 28 | for (int32 PinIdx = 0; PinIdx < StateNode->Pins.Num(); PinIdx++) 29 | { 30 | UEdGraphPin* MyPin = StateNode->Pins[PinIdx]; 31 | if (!MyPin->bHidden) 32 | { 33 | TSharedPtr NewPin = CreatePinWidget(MyPin); 34 | 35 | AddPin(NewPin.ToSharedRef()); 36 | } 37 | } 38 | } 39 | 40 | void SMultiPackerRuntimeMaterialNode::AddPin(const TSharedRef& PinToAdd) 41 | { 42 | PinToAdd->SetOwner(SharedThis(this)); 43 | 44 | if (PinToAdd->GetDirection() == EEdGraphPinDirection::EGPD_Output) 45 | { 46 | 47 | FMargin Padding = Settings->GetInputPinPadding(); 48 | Padding.Left *= 0.5f; 49 | Padding.Right = 0.0f; 50 | 51 | RightNodeBox->AddSlot() 52 | .HAlign(HAlign_Right) 53 | .AutoHeight() 54 | .Padding(Padding) 55 | [ 56 | PinToAdd 57 | ]; 58 | OutputPins.Add(PinToAdd); 59 | } 60 | } 61 | 62 | FSlateColor SMultiPackerRuntimeMaterialNode::GetErrorColor() const 63 | { 64 | return FLinearColor(1.0f, 0.0f, 0.0f, 1.0f); 65 | } 66 | 67 | FText SMultiPackerRuntimeMaterialNode::GetErrorMsgToolTip() const 68 | { 69 | FString Error = FString(TEXT("")); 70 | UMultiPackerRuntimeMaterialNode* MyNode = CastChecked(GraphNode); 71 | if (!MyNode->MultiPackerRuntimeMatNode->MaterialBaseInput) { 72 | Error = FString(TEXT("Need Material")); 73 | } 74 | ErrorText->SetError(Error); 75 | return FText::FromString(Error); 76 | } 77 | 78 | FSlateColor SMultiPackerRuntimeMaterialNode::GetBorderBackgroundColor() const 79 | { 80 | UMultiPackerRuntimeMaterialNode* MyNode = CastChecked(GraphNode); 81 | return MyNode ? MyNode->GetBackgroundColor() : MultiPackerColors::NodeBorder::HighlightAbortRange0; 82 | } 83 | 84 | FSlateColor SMultiPackerRuntimeMaterialNode::GetBackgroundColor() const 85 | { 86 | return MultiPackerColors::NodeBody::Default; 87 | } 88 | 89 | EVisibility SMultiPackerRuntimeMaterialNode::GetDragOverMarkerVisibility() const 90 | { 91 | return EVisibility::Visible; 92 | } 93 | 94 | FText SMultiPackerRuntimeMaterialNode::GetDescription() const 95 | { 96 | UMultiPackerRuntimeMaterialNode* MyNode = CastChecked(GraphNode); 97 | return MyNode ? MyNode->GetDescription() : FText::GetEmpty(); 98 | } 99 | 100 | EVisibility SMultiPackerRuntimeMaterialNode::GetDescriptionVisibility() const 101 | { 102 | return EVisibility::Hidden; 103 | } 104 | 105 | const FSlateBrush* SMultiPackerRuntimeMaterialNode::GetNameIcon() const 106 | { 107 | return FEditorStyle::GetBrush(TEXT("BTEditor.Graph.BTNode.Icon")); 108 | } 109 | 110 | TSharedRef SMultiPackerRuntimeMaterialNode::CreateNodeContentArea() 111 | { 112 | // NODE CONTENT AREA 113 | return SNew(SBorder) 114 | .BorderImage(FEditorStyle::GetBrush("NoBorder")) 115 | .HAlign(HAlign_Fill) 116 | .VAlign(VAlign_Fill) 117 | [ 118 | SNew(SHorizontalBox) 119 | + SHorizontalBox::Slot() 120 | .HAlign(HAlign_Left) 121 | .FillWidth(1.0f) 122 | [ 123 | // LEFT 124 | SAssignNew(LeftNodeBox, SVerticalBox) 125 | + SVerticalBox::Slot() 126 | .AutoHeight() 127 | .HAlign(HAlign_Right) 128 | .VAlign(VAlign_Center) 129 | [ 130 | SNew(SBox) 131 | .WidthOverride(128) 132 | .HeightOverride(128) 133 | [ 134 | EdActorNode->AssetThumbnail->MakeThumbnailWidget() 135 | ] 136 | ] 137 | ] 138 | + SHorizontalBox::Slot() 139 | .AutoWidth() 140 | .HAlign(HAlign_Right) 141 | [ 142 | // RIGHT 143 | SAssignNew(RightNodeBox, SVerticalBox) 144 | 145 | ] 146 | ]; 147 | } 148 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Private/RuntimeGraph/Nodes/SMultiPackerRuntimeOutputNode.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "RuntimeGraph/Nodes/SMultiPackerRuntimeOutputNode.h" 3 | #include "MultiPackerAssetEditor/MultiPackerColors.h" 4 | #include "CoreMinimal.h" 5 | #include "AssetThumbnail.h" 6 | #include "MultiPackerAssetEditor/MultiPackerEditorThumbnail.h" 7 | #include "SGraphPin.h" 8 | #include "GraphEditor.h" 9 | #include 10 | 11 | ////////////////////////////////////////////////////////////////////////// 12 | void SMultiPackerRuntimeOutputNode::Construct(const FArguments& InArgs, UMultiPackerRuntimeOutputNode* InNode) 13 | { 14 | GraphNode = InNode; 15 | EdActorNode = InNode; 16 | EdActorNode->SetThumnailOutput(nullptr); 17 | UpdateGraphNode(); 18 | } 19 | 20 | void SMultiPackerRuntimeOutputNode::CreatePinWidgets() 21 | { 22 | for (int32 PinIdx = 0; PinIdx < GraphNode->Pins.Num(); PinIdx++) 23 | { 24 | UEdGraphPin* MyPin = GraphNode->Pins[PinIdx]; 25 | TSharedPtr NewPin = CreatePinWidget(MyPin); 26 | AddPin(NewPin.ToSharedRef()); 27 | } 28 | } 29 | 30 | void SMultiPackerRuntimeOutputNode::AddPin(const TSharedRef& PinToAdd) 31 | { 32 | PinToAdd->SetOwner(SharedThis(this)); 33 | 34 | if (PinToAdd->GetDirection() == EEdGraphPinDirection::EGPD_Input) 35 | { 36 | FMargin Padding = Settings->GetInputPinPadding(); 37 | Padding.Left *= 0.5f; 38 | Padding.Right = 0.0f; 39 | 40 | LeftNodeBox->AddSlot() 41 | .AutoHeight() 42 | .HAlign(HAlign_Left) 43 | .VAlign(VAlign_Center) 44 | .Padding(Padding) 45 | [ 46 | PinToAdd 47 | ]; 48 | InputPins.Add(PinToAdd); 49 | } 50 | } 51 | 52 | FSlateColor SMultiPackerRuntimeOutputNode::GetBackgroundColor() const 53 | { 54 | return MultiPackerColors::NodeBody::Default; 55 | } 56 | 57 | EVisibility SMultiPackerRuntimeOutputNode::GetDragOverMarkerVisibility() const 58 | { 59 | return EVisibility::Visible; 60 | } 61 | 62 | FText SMultiPackerRuntimeOutputNode::GetDescription() const 63 | { 64 | return FText::FromString("Material"); 65 | } 66 | 67 | EVisibility SMultiPackerRuntimeOutputNode::GetDescriptionVisibility() const 68 | { 69 | return EVisibility::Hidden; 70 | } 71 | 72 | const FSlateBrush* SMultiPackerRuntimeOutputNode::GetNameIcon() const 73 | { 74 | return FEditorStyle::GetBrush(TEXT("BTEditor.Graph.BTNode.Icon")); 75 | } 76 | 77 | TSharedRef SMultiPackerRuntimeOutputNode::CreateNodeContentArea() 78 | { 79 | // NODE CONTENT AREA 80 | return SNew(SBorder) 81 | .BorderImage(FEditorStyle::GetBrush("NoBorder")) 82 | .HAlign(HAlign_Fill) 83 | .VAlign(VAlign_Fill) 84 | [ 85 | SNew(SHorizontalBox) 86 | + SHorizontalBox::Slot() 87 | .HAlign(HAlign_Left) 88 | .FillWidth(1.0f) 89 | [ 90 | // LEFT 91 | SAssignNew(LeftNodeBox, SVerticalBox) 92 | ] 93 | + SHorizontalBox::Slot() 94 | .AutoWidth() 95 | .HAlign(HAlign_Right) 96 | [ 97 | // RIGHT 98 | SAssignNew(RightNodeBox, SVerticalBox) 99 | + SVerticalBox::Slot() 100 | .AutoHeight() 101 | .HAlign(HAlign_Right) 102 | .VAlign(VAlign_Center) 103 | [ 104 | SNew(SBox) 105 | .WidthOverride(128) 106 | .HeightOverride(128) 107 | [ 108 | EdActorNode->AssetThumbnail->MakeThumbnailWidget() 109 | ] 110 | ] 111 | ] 112 | ]; 113 | } 114 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/DetailsProperty/FChannelDatabaseCustomization.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Widgets/SWidget.h" 7 | #include "Layout/Margin.h" 8 | #include "Widgets/DeclarativeSyntaxSupport.h" 9 | #include "IPropertyTypeCustomization.h" 10 | #include "Widgets/Text/STextBlock.h" 11 | #include "Widgets/Input/SComboButton.h" 12 | #include "Widgets/Views/STableViewBase.h" 13 | #include "Widgets/Views/STableRow.h" 14 | #include "Widgets/Views/SListView.h" 15 | #include "IDetailChildrenBuilder.h" 16 | #include "PropertyCustomizationHelpers.h" 17 | #include "IPropertyUtilities.h" 18 | #include "MultiPackerImageCore.h" 19 | #include "Runtime/Launch/Resources/Version.h" 20 | #include "MultiPackerDataBase.h" 21 | 22 | #define LOCTEXT_NAMESPACE "FChannelDatabaseCustomizationLayout" 23 | 24 | /** 25 | * Customizes a DataTable asset to use a dropdown 26 | */ 27 | class FChannelDatabaseCustomizationLayout : public IPropertyTypeCustomization 28 | { 29 | public: 30 | static TSharedRef MakeInstance(); 31 | 32 | /** IPropertyTypeCustomization interface */ 33 | virtual void CustomizeHeader(TSharedRef InStructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override; 34 | 35 | virtual void CustomizeChildren(TSharedRef InStructPropertyHandle, class IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override; 36 | 37 | private: 38 | #if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION <= 16) 39 | bool ShouldFilterAsset(const class FAssetData& AssetData) 40 | #endif 41 | #if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION > 16) 42 | bool ShouldFilterAsset(const struct FAssetData& AssetData) 43 | #endif 44 | { 45 | if (!RowTypeFilter.IsNone()) 46 | { 47 | const UMultiPackerDataBase* MultiPackerDataBase = Cast(AssetData.GetAsset()); 48 | if (MultiPackerDataBase->RowStruct && MultiPackerDataBase->RowStruct->GetFName() == RowTypeFilter) 49 | { 50 | return false; 51 | } 52 | return true; 53 | } 54 | return false; 55 | } 56 | 57 | /** Init the contents the combobox sources its data off */ 58 | TSharedPtr InitWidgetContent(); 59 | 60 | /** Returns the ListView for the ComboButton */ 61 | TSharedRef GetListContent(); 62 | 63 | /** Delegate to refresh the drop down when the datatable changes */ 64 | void OnDataTableChanged(); 65 | 66 | /** Return the representation of the the row names to display */ 67 | TSharedRef HandleRowNameComboBoxGenarateWidget(TSharedPtr InItem, const TSharedRef& OwnerTable); 68 | 69 | /** Display the current selection */ 70 | FText GetNameComboBoxContentText() const; 71 | 72 | /** Update the root data on a change of selection */ 73 | void OnSelectionChanged(TSharedPtr SelectedItem, ESelectInfo::Type SelectInfo); 74 | 75 | 76 | /** Called by Slate when the filter box changes text. */ 77 | void OnFilterTextChanged(const FText& InFilterText); 78 | 79 | /** The comboButton objects */ 80 | TSharedPtr RowNameComboButton; 81 | TSharedPtr > > RowNameComboListView; 82 | TSharedPtr CurrentSelectedItem; 83 | /** Handle to the struct properties being customized */ 84 | TSharedPtr StructPropertyHandle; 85 | TSharedPtr DatabasePropertyHandle; 86 | TSharedPtr NamePropertyHandle; 87 | /** A cached copy of strings to populate the combo box */ 88 | TArray > RowNames; 89 | /** The MetaData derived filter for the row type */ 90 | FName RowTypeFilter; 91 | }; 92 | 93 | #undef LOCTEXT_NAMESPACE 94 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/DetailsProperty/FTileCopyCustomization.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "IPropertyTypeCustomization.h" 7 | #include "IDetailChildrenBuilder.h" 8 | #include "PropertyCustomizationHelpers.h" 9 | #include "IPropertyUtilities.h" 10 | #include "Runtime/Launch/Resources/Version.h" 11 | 12 | #define LOCTEXT_NAMESPACE "FTileCopyCustomizationLayout" 13 | 14 | //Class forwarding 15 | class UMultiPackerLayerDatabase; 16 | 17 | /** 18 | * Customizes TileCopy to have a button 19 | */ 20 | class FTileCopyCustomizationLayout : public IPropertyTypeCustomization 21 | { 22 | public: 23 | static TSharedRef MakeInstance(); 24 | 25 | /** IPropertyTypeCustomization interface */ 26 | virtual void CustomizeHeader(TSharedRef InStructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override; 27 | 28 | virtual void CustomizeChildren(TSharedRef InStructPropertyHandle, class IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override; 29 | 30 | private: 31 | 32 | FReply OnButtonMCPressed(); 33 | 34 | FReply OnButtonLCPressed(); 35 | 36 | void GetNodesOnText(bool bMaterialCollection); 37 | 38 | FString GetNodesMaterialCollection(); 39 | 40 | FString GetNodesLinearColor(); 41 | 42 | UMultiPackerLayerDatabase* LayerDatabase; 43 | 44 | UPROPERTY(EditInstanceOnly, meta = (MultiLine = true)) 45 | FString OutputString; 46 | 47 | }; 48 | 49 | #undef LOCTEXT_NAMESPACE 50 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/Factory/MultiPackerDatabaseFactory.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include 5 | #include "MultiPackerDatabaseFactory.generated.h" 6 | 7 | UCLASS() 8 | class MULTIPACKEREDITOR_API UMultiPackerDatabaseFactory : public UFactory 9 | { 10 | GENERATED_UCLASS_BODY() 11 | public: 12 | virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override; 13 | }; 14 | 15 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/Factory/MultiPackerFactory.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "MultiPackerFactory.generated.h" 5 | 6 | UCLASS() 7 | class MULTIPACKEREDITOR_API UMultiPackerFactory : public UFactory 8 | { 9 | GENERATED_BODY() 10 | 11 | public: 12 | UMultiPackerFactory(); 13 | virtual ~UMultiPackerFactory(); 14 | 15 | virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override; 16 | FText GetDisplayName() const override; 17 | }; 18 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/Factory/MultiPackerLayerDatabaseFactory.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include 5 | #include "MultiPackerLayerDatabaseFactory.generated.h" 6 | 7 | UCLASS() 8 | class MULTIPACKEREDITOR_API UMultiPackerLayerDatabaseFactory : public UFactory 9 | { 10 | GENERATED_UCLASS_BODY() 11 | public: 12 | virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override; 13 | virtual FText GetDisplayName() const override; 14 | }; 15 | 16 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/Factory/MultiPackerRuntimeGraphFactory.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "MultiPackerRuntimeGraphFactory.generated.h" 5 | 6 | UCLASS() 7 | class MULTIPACKEREDITOR_API UMultiPackerRuntimeGraphFactory : public UFactory 8 | { 9 | GENERATED_BODY() 10 | 11 | public: 12 | UMultiPackerRuntimeGraphFactory(); 13 | virtual ~UMultiPackerRuntimeGraphFactory(); 14 | 15 | virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override; 16 | FText GetDisplayName() const override; 17 | }; 18 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/IMultiPackerEditor.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "Modules/ModuleManager.h" 5 | 6 | DECLARE_LOG_CATEGORY_EXTERN(MultiPackerEditor, Log, All); 7 | 8 | /** 9 | * The public interface to this module 10 | */ 11 | class IMultiPackerEditor : public IModuleInterface 12 | { 13 | 14 | public: 15 | 16 | /** 17 | * Singleton-like access to this module's interface. This is just for convenience! 18 | * Beware of calling this during the shutdown phase, though. Your module might have been unloaded already. 19 | * 20 | * @return Returns singleton instance, loading the module on demand if needed 21 | */ 22 | static IMultiPackerEditor& Get() 23 | { 24 | return FModuleManager::LoadModuleChecked< IMultiPackerEditor >( "MultiPackerEditor" ); 25 | } 26 | 27 | /** 28 | * Checks to see if this module is loaded and ready. It is only valid to call Get() if IsAvailable() returns true. 29 | * 30 | * @return True if the module is loaded and ready to use 31 | */ 32 | static bool IsAvailable() 33 | { 34 | return FModuleManager::Get().IsModuleLoaded( "MultiPackerEditor" ); 35 | } 36 | }; 37 | 38 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/LayerDatabase/LayerStyleEditorToolkit.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "EditorUndoClient.h" 5 | #include "Templates/SharedPointer.h" 6 | #include "Toolkits/AssetEditorToolkit.h" 7 | #include "UObject/GCObject.h" 8 | #include 9 | #include 10 | 11 | class FSpawnTabArgs; 12 | class IToolkitHost; 13 | class SDockTab; 14 | class SLayerStyleEditor; 15 | class UMultiPackerLayerDatabase; 16 | //class UMaterialInstanceDynamic; 17 | 18 | /** 19 | * Implements an Editor toolkit for textures. 20 | */ 21 | class FLayerStyleEditorToolkit : public FAssetEditorToolkit, public FNotifyHook, public FEditorUndoClient, public FGCObject 22 | { 23 | public: 24 | FLayerStyleEditorToolkit(); 25 | /** 26 | * Creates and initializes a new instance. 27 | * 28 | * @param InStyle The style set to use. 29 | */ 30 | /*FLayerStyleEditorToolkit(const TSharedRef& InStyle);*/ 31 | 32 | /** Virtual destructor. */ 33 | virtual ~FLayerStyleEditorToolkit(); 34 | 35 | 36 | virtual void NotifyPostChange(const FPropertyChangedEvent& PropertyChangedEvent, UProperty* PropertyThatChanged) override; 37 | 38 | public: 39 | 40 | /** 41 | * Initializes the editor tool kit. 42 | * 43 | * @param InStyleAsset The UMultiPackerLayerDatabaseasset to edit. 44 | * @param InMode The mode to create the toolkit in. 45 | * @param InToolkitHost The toolkit host. 46 | */ 47 | void Initialize(UMultiPackerLayerDatabase* InStyleAsset, const EToolkitMode::Type InMode, const TSharedPtr& InToolkitHost); 48 | 49 | 50 | void CreateInternalWidgets(); 51 | public: 52 | 53 | //~ FAssetEditorToolkit interface 54 | 55 | virtual FString GetDocumentationLink() const override; 56 | virtual void RegisterTabSpawners(const TSharedRef& InTabManager) override; 57 | virtual void UnregisterTabSpawners(const TSharedRef& InTabManager) override; 58 | 59 | public: 60 | 61 | //~ IToolkit interface 62 | 63 | virtual FText GetBaseToolkitName() const override; 64 | virtual FName GetToolkitFName() const override; 65 | virtual FLinearColor GetWorldCentricTabColorScale() const override; 66 | virtual FString GetWorldCentricTabPrefix() const override; 67 | 68 | public: 69 | 70 | //~ FGCObject interface 71 | 72 | virtual void AddReferencedObjects(FReferenceCollector& Collector) override; 73 | 74 | protected: 75 | 76 | //~ FEditorUndoClient interface 77 | 78 | virtual void PostUndo(bool bSuccess) override; 79 | virtual void PostRedo(bool bSuccess) override; 80 | 81 | private: 82 | 83 | /** Callback for spawning the Properties tab. */ 84 | /* TSharedRef HandleTabManagerSpawnTab(const FSpawnTabArgs& Args, FName TabIdentifier);*/ 85 | 86 | TSharedRef SpawnTab_Details(const FSpawnTabArgs& Args); 87 | 88 | TSharedRef SpawnTab_Material(const FSpawnTabArgs& Args); 89 | private: 90 | 91 | /** The text asset being edited. */ 92 | UMultiPackerLayerDatabase* StyleAsset; 93 | 94 | //UMaterial* Material; 95 | //UMaterialInstanceDynamic* Material; 96 | /** Pointer to the style set to use for toolkits. */ 97 | //TSharedRef Style; 98 | 99 | TSharedPtr PropertyWidget; 100 | 101 | /** Preview viewport widget used for UI materials */ 102 | TSharedPtr PreviewUIViewport; 103 | 104 | //TSharedPtr PreviewViewport; 105 | 106 | static const FName AppId; 107 | static const FName PreviewTabId; 108 | static const FName DetailsTabId; 109 | static const FName TextTabId; 110 | }; 111 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/LayerDatabase/MultiPackerLayerDatabaseAssetTypeActions.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "AssetTypeActions_Base.h" 5 | 6 | class FMultiPackerLayerDatabaseAssetTypeActions : public FAssetTypeActions_Base 7 | { 8 | public: 9 | FMultiPackerLayerDatabaseAssetTypeActions(EAssetTypeCategories::Type InAssetCategory); 10 | 11 | virtual FText GetName() const override; 12 | virtual FColor GetTypeColor() const override; 13 | virtual UClass* GetSupportedClass() const override; 14 | virtual void OpenAssetEditor(const TArray& InObjects, TSharedPtr EditWithinLevelEditor = TSharedPtr()) override; 15 | virtual uint32 GetCategories() override; 16 | 17 | private: 18 | EAssetTypeCategories::Type MyAssetCategory; 19 | }; -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/LayerDatabase/SLayerStyleEditor.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "Widgets/SCompoundWidget.h" 5 | #include "Widgets/DeclarativeSyntaxSupport.h" 6 | 7 | class UMaterialInterface; 8 | class SMaterialEditorUIPreviewZoomer; 9 | 10 | /** 11 | * A preview viewport used for 2D UI materials 12 | */ 13 | class SLayerStyleEditor : public SCompoundWidget 14 | { 15 | public: 16 | SLATE_BEGIN_ARGS(SLayerStyleEditor) {} 17 | SLATE_END_ARGS() 18 | 19 | void Construct(const FArguments& InArgs, UMaterialInterface* PreviewMaterial); 20 | void SetPreviewMaterial(UMaterialInterface* InMaterialInterface); 21 | 22 | private: 23 | void OnPreviewXChanged(int32 NewValue); 24 | void OnPreviewXCommitted(int32 NewValue, ETextCommit::Type); 25 | void OnPreviewYChanged(int32 NewValue); 26 | void OnPreviewYCommitted(int32 NewValue, ETextCommit::Type); 27 | TOptional OnGetPreviewXValue() const { return PreviewSize.X; } 28 | TOptional OnGetPreviewYValue() const { return PreviewSize.Y; } 29 | private: 30 | FIntPoint PreviewSize; 31 | TSharedPtr PreviewZoomer; 32 | }; -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/MultiPackerAssetEditor/MultiPackerAssetEditor.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "Toolkits/AssetEditorToolkit.h" 5 | #include "Graph/MultiPacker.h" 6 | #include "Misc/NotifyHook.h" 7 | #include 8 | 9 | class SMultiPackerAssetEditorDrop; 10 | class FGenericGraphAssetEditorToolbar; 11 | class UMultiPackerProcessCore; 12 | class FAssetEditorManager; 13 | class SDockTab; 14 | 15 | class FMultiPackerAssetEditor : public FAssetEditorToolkit, public FNotifyHook, public FGCObject 16 | { 17 | public: 18 | FMultiPackerAssetEditor(); 19 | virtual ~FMultiPackerAssetEditor(); 20 | 21 | void InitGenericGraphAssetEditor(const EToolkitMode::Type Mode, const TSharedPtr< IToolkitHost >& InitToolkitHost, UMultiPacker* Graph); 22 | 23 | // IToolkit interface 24 | virtual void RegisterTabSpawners(const TSharedRef& TabManager) override; 25 | virtual void UnregisterTabSpawners(const TSharedRef& TabManager) override; 26 | // End of IToolkit interface 27 | 28 | // FAssetEditorToolkit 29 | virtual FName GetToolkitFName() const override; 30 | virtual FText GetBaseToolkitName() const override; 31 | virtual FText GetToolkitName() const override; 32 | virtual FText GetToolkitToolTipText() const override; 33 | virtual FLinearColor GetWorldCentricTabColorScale() const override; 34 | virtual FString GetWorldCentricTabPrefix() const override; 35 | virtual FString GetDocumentationLink() const override; 36 | virtual void SaveAsset_Execute() override; 37 | // End of FAssetEditorToolkit 38 | 39 | //Toolbar 40 | void UpdateToolbar(); 41 | TSharedPtr GetToolbarBuilder() { return ToolbarBuilder; } 42 | void RegisterToolbarTab(const TSharedRef& TabManager); 43 | 44 | 45 | // FSerializableObject interface 46 | virtual void AddReferencedObjects(FReferenceCollector& Collector) override; 47 | // End of FSerializableObject interface 48 | 49 | private: 50 | TSharedRef SpawnTab_Viewport(const FSpawnTabArgs& Args); 51 | TSharedRef SpawnTab_Details(const FSpawnTabArgs& Args); 52 | TSharedRef SpawnTab_ContentBrowser(const FSpawnTabArgs& Args); 53 | void CreateInternalWidgets(); 54 | TSharedRef CreateViewportWidget(); 55 | 56 | void BindCommands(); 57 | 58 | void CreateEdGraph(); 59 | 60 | void CreateCommandList(); 61 | 62 | TSharedPtr GetCurrGraphEditor(); 63 | 64 | FGraphPanelSelectionSet GetSelectedNodes(); 65 | 66 | void RebuildGenericGraph(); 67 | 68 | // Delegates for graph editor commands 69 | void SelectAllNodes(); 70 | bool CanSelectAllNodes(); 71 | void DeleteSelectedNodes(); 72 | bool CanDeleteNodes(); 73 | void DeleteSelectedDuplicatableNodes(); 74 | void CutSelectedNodes(); 75 | bool CanCutNodes(); 76 | void CopySelectedNodes(); 77 | bool CanCopyNodes(); 78 | void PasteNodes(); 79 | void PasteNodesHere(const FVector2D& Location); 80 | bool CanPasteNodes(); 81 | void DuplicateNodes(); 82 | bool CanDuplicateNodes(); 83 | 84 | void GraphSettings(); 85 | bool CanGraphSettings(); 86 | void ProcessGraph(); 87 | bool CanProcessGraph(); 88 | void OnCreateComment(); 89 | ////////////////////////////////////////////////////////////////////////// 90 | // graph editor event 91 | void OnSelectedNodesChanged(const TSet& NewSelection); 92 | 93 | void OnNodeDoubleClicked(UEdGraphNode* Node); 94 | 95 | void OnFinishedChangingProperties(const FPropertyChangedEvent& PropertyChangedEvent); 96 | 97 | void OnPackageSaved(const FString& PackageFileName, UObject* Outer); 98 | 99 | void HandleAssetDropped(UObject* AssetObject); 100 | bool IsAssetAcceptableForDrop(const UObject* AssetObject) const; 101 | FVector2D GetAssetDropGridLocation() const; 102 | 103 | UMultiPacker* EditingGraph; 104 | UMultiPackerProcessCore* MPCore; 105 | bool NodesChanged = true; 106 | bool canProcess = true; 107 | //Toolbar 108 | TSharedPtr ToolbarBuilder; 109 | 110 | /** Handle to the registered OnPackageSave delegate */ 111 | FDelegateHandle OnPackageSavedDelegateHandle; 112 | 113 | TSharedPtr ViewportWidget; 114 | TSharedPtr PropertyWidget; 115 | //TSharedRef ViewportTab; 116 | 117 | /** The command list for this editor */ 118 | TSharedPtr GraphEditorCommands; 119 | 120 | TSharedPtr AssetDropTarget; 121 | 122 | /** 123 | * Called when a node's title is committed for a rename 124 | * 125 | * @param NewText New title text 126 | * @param CommitInfo How text was committed 127 | * @param NodeBeingChanged The node being changed 128 | */ 129 | void OnNodeTitleCommitted(const FText& NewText, ETextCommit::Type CommitInfo, UEdGraphNode* NodeBeingChanged); 130 | 131 | }; -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/MultiPackerAssetEditor/MultiPackerAssetEditorToolbar.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | 6 | class FMultiPackerAssetEditor; 7 | class FExtender; 8 | class FToolBarBuilder; 9 | 10 | class FMultiPackerAssetEditorToolbar : public TSharedFromThis 11 | { 12 | public: 13 | FMultiPackerAssetEditorToolbar(TSharedPtr InGenericGraphEditor) 14 | : GenericGraphEditor(InGenericGraphEditor) {} 15 | 16 | //void AddModesToolbar(TSharedPtr Extender); 17 | //void AddDebuggerToolbar(TSharedPtr Extender); 18 | void AddGenericGraphToolbar(TSharedPtr Extender); 19 | FSlateIcon GraphSettingsIconOutput; 20 | private: 21 | //void FillModesToolbar(FToolBarBuilder& ToolbarBuilder); 22 | //void FillDebuggerToolbar(FToolBarBuilder& ToolbarBuilder); 23 | void FillMultiPackerToolbar(FToolBarBuilder& ToolbarBuilder); 24 | 25 | protected: 26 | /** Pointer back to the blueprint editor tool that owns us */ 27 | TWeakPtr GenericGraphEditor; 28 | }; 29 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/MultiPackerAssetEditor/MultiPackerAssetGraphSchema.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "GraphEditor.h" 6 | #include "EdGraph/EdGraphSchema.h" 7 | #include "Framework/MultiBox/MultiBoxBuilder.h" 8 | #include "Runtime/Launch/Resources/Version.h" 9 | #include "MultiPackerAssetGraphSchema.generated.h" 10 | 11 | /** Action to add a node to the graph */ 12 | USTRUCT() 13 | struct FMultiPackerAssetSchemaAction_NewNode: public FEdGraphSchemaAction 14 | { 15 | GENERATED_USTRUCT_BODY(); 16 | 17 | FMultiPackerAssetSchemaAction_NewNode() 18 | : FEdGraphSchemaAction() 19 | {} 20 | 21 | FMultiPackerAssetSchemaAction_NewNode(const FText& InNodeCategory, const FText& InMenuDesc, const FText& InToolTip, const int32 InGrouping) 22 | : FEdGraphSchemaAction(InNodeCategory, InMenuDesc, InToolTip, InGrouping) 23 | {} 24 | 25 | UEdGraphNode* PerformAction(class UEdGraph* ParentGraph, UEdGraphPin* FromPin, const FVector2D Location, bool bSelectNewNode = true) override; 26 | }; 27 | 28 | USTRUCT() 29 | struct FMultiPackerAssetSchemaAction_NewNodeMat : public FEdGraphSchemaAction 30 | { 31 | GENERATED_USTRUCT_BODY(); 32 | 33 | FMultiPackerAssetSchemaAction_NewNodeMat() 34 | : FEdGraphSchemaAction() 35 | {} 36 | 37 | FMultiPackerAssetSchemaAction_NewNodeMat(const FText& InNodeCategory, const FText& InMenuDesc, const FText& InToolTip, const int32 InGrouping) 38 | : FEdGraphSchemaAction(InNodeCategory, InMenuDesc, InToolTip, InGrouping) 39 | {} 40 | 41 | UEdGraphNode* PerformAction(class UEdGraph* ParentGraph, UEdGraphPin* FromPin, const FVector2D Location, bool bSelectNewNode = true) override; 42 | }; 43 | 44 | //* Action to create new comment * 45 | USTRUCT() 46 | struct FMultiPackerAssetSchemaAction_NewNodeComment : public FEdGraphSchemaAction 47 | { 48 | GENERATED_USTRUCT_BODY(); 49 | 50 | FMultiPackerAssetSchemaAction_NewNodeComment() : FEdGraphSchemaAction() {} 51 | FMultiPackerAssetSchemaAction_NewNodeComment(const FText& InNodeCategory, const FText& InMenuDesc, const FText& InToolTip, const int32 InGrouping) 52 | : FEdGraphSchemaAction(InNodeCategory, InMenuDesc, InToolTip, InGrouping) {} 53 | TSharedPtr Graph = NULL; 54 | //~ Begin FEdGraphSchemaAction Interface 55 | UEdGraphNode* PerformAction(UEdGraph* ParentGraph, UEdGraphPin* FromPin, const FVector2D Location, bool bSelectNewNode = true) override; 56 | //~ End FEdGraphSchemaAction Interface 57 | }; 58 | 59 | UCLASS(MinimalAPI) 60 | class UMultiPackerAssetGraphSchema : public UEdGraphSchema 61 | { 62 | GENERATED_BODY() 63 | 64 | void GetBreakLinkToSubMenuActions(class FMenuBuilder& MenuBuilder, class UEdGraphPin* InGraphPin); 65 | 66 | //~ Begin EdGraphSchema Interface 67 | virtual void GetGraphContextActions(FGraphContextMenuBuilder& ContextMenuBuilder) const override; 68 | virtual void GetContextMenuActions(const UEdGraph* CurrentGraph, const UEdGraphNode* InGraphNode, const UEdGraphPin* InGraphPin, class FMenuBuilder* MenuBuilder, bool bIsDebugging) const override; 69 | virtual const FPinConnectionResponse CanCreateConnection(const UEdGraphPin* A, const UEdGraphPin* B) const override; 70 | virtual FLinearColor GetPinTypeColor(const FEdGraphPinType& PinType) const override; 71 | virtual void BreakNodeLinks(UEdGraphNode& TargetNode) const override; 72 | virtual void BreakPinLinks(UEdGraphPin& TargetPin, bool bSendsNodeNotifcation) const override; 73 | #if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION <= 18) 74 | virtual void BreakSinglePinLink(UEdGraphPin* SourcePin, UEdGraphPin* TargetPin) override; 75 | #endif 76 | #if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION >= 19) 77 | virtual void BreakSinglePinLink(UEdGraphPin* SourcePin, UEdGraphPin* TargetPin) const; 78 | #endif 79 | // virtual void DroppedAssetsOnGraph(const TArray& Assets, const FVector2D& GraphPosition, UEdGraph* Graph) const override; 80 | // virtual void DroppedAssetsOnNode(const TArray& Assets, const FVector2D& GraphPosition, UEdGraphNode* Node)const override; 81 | // virtual int32 GetNodeSelectionCount(const UEdGraph* Graph) const override; 82 | virtual TSharedPtr GetCreateCommentAction() const override; 83 | virtual bool IsCacheVisualizationOutOfDate(int32 InVisualizationCacheID) const override; 84 | virtual int32 GetCurrentVisualizationCacheID() const override; 85 | virtual void ForceVisualizationCacheClear() const override; 86 | //~ End EdGraphSchema Interface 87 | 88 | private: 89 | static int32 CurrentCacheRefreshID; 90 | }; 91 | 92 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/MultiPackerAssetEditor/MultiPackerColors.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | namespace MultiPackerColors 5 | { 6 | namespace NodeBody 7 | { 8 | const FLinearColor Default(0.1f, 0.1f, 0.1f); 9 | const FLinearColor Root(0.5f, 0.5f, 0.5f, 0.1f); 10 | const FLinearColor Error(1.0f, 0.0f, 0.0f); 11 | } 12 | 13 | namespace NodeBorder 14 | { 15 | const FLinearColor Inactive(0.08f, 0.08f, 0.08f); 16 | const FLinearColor Root(0.2f, 0.2f, 0.2f, 0.2f); 17 | const FLinearColor Selected(1.00f, 0.08f, 0.08f); 18 | const FLinearColor ActiveDebugging(1.0f, 1.0f, 0.0f); 19 | const FLinearColor InactiveDebugging(0.4f, 0.4f, 0.0f); 20 | const FLinearColor HighlightAbortRange0(0.0f, 0.22f, 0.4f); 21 | const FLinearColor HighlightAbortRange1(0.0f, 0.4f, 0.22f); 22 | const FLinearColor Disconnected(0.f, 0.f, 0.f); 23 | const FLinearColor BrokenWithParent(1.f, 0.f, 1.f); 24 | const FLinearColor QuickFind(0.f, 0.8f, 0.f); 25 | } 26 | 27 | namespace Pin 28 | { 29 | const FLinearColor Diff(0.9f, 0.2f, 0.15f); 30 | const FLinearColor Hover(1.0f, 0.7f, 0.0f); 31 | const FLinearColor Default(0.08f, 0.08f, 0.08f); 32 | const FLinearColor SingleNode(0.02f, 0.02f, 0.02f); 33 | } 34 | 35 | namespace Connection 36 | { 37 | const FLinearColor Default(1.0f, 1.0f, 1.0f); 38 | } 39 | 40 | namespace Action 41 | { 42 | const FLinearColor DragMarker(1.0f, 1.0f, 0.2f); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/MultiPackerAssetEditor/MultiPackerEdGraph.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | #include "EdGraph/EdGraph.h" 4 | #include "MultiPackerEdGraph.generated.h" 5 | 6 | UCLASS() 7 | class UMultiPackerEdGraph : public UEdGraph 8 | { 9 | GENERATED_BODY() 10 | 11 | public: 12 | UMultiPackerEdGraph(); 13 | virtual ~UMultiPackerEdGraph(); 14 | 15 | virtual void RebuildGenericGraph(); 16 | bool MultiPackerNode = false; 17 | bool IsRebuilding = false; 18 | #if WITH_EDITOR 19 | virtual void PostEditUndo() override; 20 | #endif 21 | }; 22 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/MultiPackerAssetEditor/MultiPackerEditorCommands.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | #include "Framework/Commands/GenericCommands.h" 4 | class FMultiPackerEditorCommands : public TCommands 5 | { 6 | public: 7 | /** Constructor */ 8 | FMultiPackerEditorCommands() 9 | : TCommands("GenericGraphEditor", NSLOCTEXT("Contexts", "MultiPackerEditor", "MultiPacker Editor"), NAME_None, FEditorStyle::GetStyleSetName()) 10 | { 11 | } 12 | 13 | TSharedPtr GraphSettings; 14 | TSharedPtr CompileGraphNodes; 15 | TSharedPtr CompileGraphMaterial; 16 | virtual void RegisterCommands() override; 17 | }; -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/MultiPackerAssetEditor/MultiPackerEditorThumbnail.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "AssetThumbnail.h" 5 | 6 | class FMultiPackerEditorThumbnail : public FAssetThumbnailPool 7 | { 8 | public: 9 | FMultiPackerEditorThumbnail(int NumObjectsInPool) : FAssetThumbnailPool(NumObjectsInPool) {} 10 | static TSharedPtr Get() { return Instance; } 11 | static void Create() 12 | { 13 | Instance = MakeShareable(new FMultiPackerEditorThumbnail(256)); 14 | } 15 | private: 16 | static TSharedPtr Instance; 17 | }; 18 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/MultiPackerAssetEditor/MultiPackerProcessCore.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "UObject/ObjectMacros.h" 6 | #include "MultiPackerProcessCore.generated.h" 7 | 8 | class UMultiPacker; 9 | class UTilePointer; 10 | class UTextureRenderTarget2D; 11 | class FAssetToolsModule; 12 | class FContentBrowserModule; 13 | class UMaterialInstanceDynamic; 14 | 15 | UCLASS(hidecategories = object, MinimalAPI) 16 | class UMultiPackerProcessCore : public UObject 17 | { 18 | GENERATED_UCLASS_BODY() 19 | public: 20 | //Variables 21 | UMultiPacker* BaseInput = NULL; 22 | uint16 VTile = 1; 23 | uint16 HTile = 1; 24 | uint16 TileSize = 32; 25 | #if !UE_BUILD_SHIPPING 26 | bool Debug_Log = true; 27 | bool Debug_Log_MatCollection = false; 28 | bool Debug_Log_MaxRectsBinPack = false; 29 | #endif 30 | bool Do_SDF = false; 31 | 32 | bool Do_MSDF = false; 33 | EObjectFlags Flags; 34 | 35 | UPROPERTY(EditDefaultsOnly) 36 | TMap TileMap; 37 | UPROPERTY() 38 | TArray Output; 39 | //old code I must try to change it 40 | void SetGraph(UMultiPacker* EditingGraph); 41 | uint16 GetNumberTiles(); 42 | //Split Canvas 43 | void ProcessNodes(UMultiPacker* Graph); 44 | TArray GetTilesFromNodes(); 45 | TArray TileBinPack(TArray InputTiles, uint16 SizeVertical, uint16 SizeHorizontal, uint16 Masks); 46 | FRectSizePadding GetSizePaddingWithoutPadding(FRectSizePadding InPadding, FVector2D InTilePadding); 47 | //code usefull 48 | uint16 GetNumberOfMasks(); 49 | void GetOutputTileNumbers(uint16 Tiles); 50 | void SaveDataBase(FString TargetName, FAssetToolsModule& AssetToolsModule, FContentBrowserModule& ContentBrowserModule, uint16 width, uint16 height); 51 | void CreateMaterialCollection(uint16 width, uint16 height, FAssetToolsModule& AssetToolsModule, FContentBrowserModule& ContentBrowserModule); 52 | void PopulateMap(uint16 SizeVertical, uint16 SizeHorizontal, uint16 Masks); 53 | void SaveTextureFromTile(UTilePointer* InTile, FString TextureNum, FAssetToolsModule& AssetToolsModule); 54 | TArray PackageName(FString Prefix, FString TextureNum, FAssetToolsModule& AssetToolsModule); 55 | TArray TexturePackageName(FString Prefix, FString TextureNum, FAssetToolsModule& AssetToolsModule); 56 | void SetDataLinearColors(EChannelOutput ChannelOutput, FLinearColor &Channel, FLinearColor &Layer); 57 | }; 58 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/MultiPackerAssetEditor/Nodes/MultiPackerBaseNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "EdGraph/EdGraphNode.h" 6 | #include "MultiPackerBaseEnums.h" 7 | #include "MultiPackerBaseNode.generated.h" 8 | 9 | class FAssetThumbnail; 10 | class UMultiPackerEdGraph; 11 | class UTilePointer; 12 | 13 | UCLASS(MinimalAPI) 14 | class UMultiPackerBaseNode : public UEdGraphNode 15 | { 16 | GENERATED_BODY() 17 | public: 18 | TSharedPtr AssetThumbnail; 19 | 20 | UPROPERTY(Transient) 21 | TArray Tiles; 22 | UPROPERTY(Transient) 23 | bool TilesProcessed = false; 24 | UPROPERTY(Transient) 25 | bool TilesChanged = false; 26 | 27 | 28 | //Enable if you want to Override the global Padding settings and apply this 29 | UPROPERTY(EditDefaultsOnly, Category = "Tiled Options") 30 | bool OverridePadding = false; 31 | 32 | //Padding for individual Tile, This allows to get out the blur border of the nearest tile 33 | //The Padding X work for right and left, and Y for up and down, Advice: control the values will be doubled. 34 | //EveryTime will be applied if you like to not have Padding set to 0 35 | UPROPERTY(EditDefaultsOnly, Category = "Tiled Options", meta = (EditCondition = OverridePadding)) 36 | FVector2D TilePadding; 37 | 38 | UMultiPackerEdGraph* GetGenericGraphEdGraph(); 39 | FText GetDescription() const; 40 | virtual bool GetMsdf(); 41 | virtual bool IsNodeSelectedSdf(); 42 | virtual FTileThumbDatabase GetTileThumbDatabase(uint16 num); 43 | #if WITH_EDITOR 44 | //TilePointer Side class 45 | TArray GetTiles(const uint16 size, FVector2D InTilePadding); 46 | void SetDatabase(); 47 | bool TilesNeedProcess(); 48 | virtual void ProcessTiles(); 49 | bool IsTilesSDF(); 50 | 51 | virtual bool PinConnected(); 52 | virtual bool IsObjectValid(); 53 | #endif 54 | bool GraphSDF = false; 55 | uint16 SizeTile = 0; 56 | 57 | virtual uint16 GetNumberTiles(); 58 | }; -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/MultiPackerAssetEditor/Nodes/MultiPackerOutputNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "EdGraph/EdGraphNode.h" 6 | #include "MultiPackerOutputNode.generated.h" 7 | 8 | class FAssetThumbnail; 9 | class UMultiPackerOutputNodeBase; 10 | class UMultiPackerEdGraph; 11 | class UTexture2D; 12 | 13 | UCLASS(MinimalAPI) 14 | class UMultiPackerOutputNode : public UEdGraphNode 15 | { 16 | GENERATED_BODY() 17 | public: 18 | void ProcessArrayThumbnail(); 19 | void AllocateDefaultPins() override; 20 | void NodeConnectionListChanged() override; 21 | bool CanUserDeleteNode()const override; 22 | 23 | void SetArrayThumnailOutput(TArray Input); 24 | int GetNumTexturesArray(); 25 | TSharedRef GetThumbnailByNum(int Num); 26 | bool IsThumbRectangled(int Num); 27 | private: 28 | UMultiPackerEdGraph* GetGenericGraphEdGraph() const; 29 | virtual FLinearColor GetNodeTitleColor() const override; 30 | static UEdGraphPin* PinDefault; 31 | bool NodeOutput = false; 32 | //OutputAssets 33 | UPROPERTY() 34 | TArray ArrayTextureOutput; 35 | TArray ArrayRectangled; 36 | TArray> ArrayAssetThumbnail; 37 | }; -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/MultiPackerAssetEditor/Nodes/MultiPackerTextureEdNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "MultiPackerAssetEditor/Nodes/MultiPackerBaseNode.h" 5 | #include "MultiPackerTextureEdNode.generated.h" 6 | 7 | class UMultiPackerTextureNode; 8 | 9 | UCLASS(MinimalAPI) 10 | class UMultiPackerTextureEdNode : public UMultiPackerBaseNode 11 | { 12 | GENERATED_UCLASS_BODY() 13 | 14 | public: 15 | UPROPERTY(VisibleAnywhere, instanced, Category = "MultiPacker") 16 | UMultiPackerTextureNode* GenericGraphNode; 17 | 18 | UPROPERTY(EditAnywhere, Category = "TextureNode") 19 | EChannelSelectionInput ChannelInput = EChannelSelectionInput::CSI_RGB; 20 | 21 | void AllocateDefaultPins() override; 22 | void PinConnectionListChanged(UEdGraphPin * Pin) override; 23 | bool PinConnected() override; 24 | bool IsObjectValid() override; 25 | FTileThumbDatabase GetTileThumbDatabase(uint16 num) override; 26 | uint16 GetNumberTiles() override; 27 | 28 | FText GetNodeTitle(ENodeTitleType::Type TitleType) const; 29 | void SetGenericGraphNode(UMultiPackerTextureNode* InNode); 30 | void SetTextureInput(UTexture* Texture); 31 | 32 | void SetChannelInput(EChannelSelectionInput Input); 33 | EChannelSelectionInput GetChannelInput() const; 34 | UObject* GetNodeAssetObject(UObject* Outer); 35 | UObject* GetThumbnailAssetObject(); 36 | FLinearColor GetBackgroundColor() const; 37 | 38 | #if WITH_EDITOR 39 | void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent); 40 | 41 | //TilePointer Side class 42 | void ProcessTiles() override; 43 | FVector2D GetTileSize(); 44 | FVector2D GetSplitTileSize(); 45 | #endif 46 | 47 | bool GetMsdf() override; 48 | bool IsNodeSelectedSdf() override; 49 | private: 50 | 51 | void PrepareTextureToWork(); 52 | }; 53 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/MultiPackerAssetEditor/Nodes/SMultiPackerMaterialNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "MultiPackerAssetEditor/Nodes/MultiPackerMaterialNode.h" 5 | #include 6 | 7 | class SMultiPackerMaterialNode : public SGraphNode 8 | { 9 | public: 10 | SLATE_BEGIN_ARGS(SMultiPackerMaterialNode) {} 11 | SLATE_END_ARGS() 12 | 13 | void Construct(const FArguments& InArgs, UMultiPackerMaterialNode* InNode); 14 | 15 | 16 | //~ Begin SGraphNode Interface 17 | //virtual void UpdateGraphNode() override; 18 | virtual void CreatePinWidgets() override; 19 | virtual void AddPin(const TSharedRef& PinToAdd) override; 20 | // virtual void OnDragEnter(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; 21 | // virtual FReply OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; 22 | // virtual FReply OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; 23 | // virtual void OnDragLeave(const FDragDropEvent& DragDropEvent) override; 24 | // virtual FReply OnMouseMove(const FGeometry& SenderGeometry, const FPointerEvent& MouseEvent) override; 25 | // virtual void SetOwner(const TSharedRef& OwnerPanel) override; 26 | // virtual void AddPin(const TSharedRef& PinToAdd) override; 27 | //~ End SGraphNode Interface 28 | 29 | virtual FSlateColor GetErrorColor() const; 30 | virtual FText GetErrorMsgToolTip() const; 31 | virtual FSlateColor GetBorderBackgroundColor() const; 32 | virtual FSlateColor GetBackgroundColor() const; 33 | 34 | virtual EVisibility GetDragOverMarkerVisibility() const; 35 | 36 | virtual FText GetDescription() const; 37 | virtual EVisibility GetDescriptionVisibility() const; 38 | 39 | virtual const FSlateBrush* GetNameIcon() const; 40 | 41 | protected: 42 | virtual TSharedRef CreateNodeContentArea() override; 43 | TSharedPtr NodeBody; 44 | TSharedPtr OutputPinBox; 45 | 46 | UMultiPackerMaterialNode* EdActorNode; 47 | FIntPoint ThumbnailSize; 48 | private: 49 | void BuildThumbnailWidget(); 50 | 51 | TSharedPtr ErrorText; 52 | }; 53 | 54 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/MultiPackerAssetEditor/Nodes/SMultiPackerOutputNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "SGraphNode.h" 5 | #include "MultiPackerAssetEditor/Nodes/MultiPackerOutputNode.h" 6 | 7 | class SMultiPackerOutputNode : public SGraphNode 8 | { 9 | public: 10 | SLATE_BEGIN_ARGS(SMultiPackerOutputNode) {} 11 | SLATE_END_ARGS() 12 | 13 | void Construct(const FArguments& InArgs, UMultiPackerOutputNode* InNode); 14 | 15 | //~ Begin SGraphNode Interface 16 | //virtual void UpdateGraphNode() override; 17 | void CreatePinWidgets() override; 18 | void AddPin(const TSharedRef& PinToAdd) override; 19 | // virtual void OnDragEnter(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; 20 | // virtual FReply OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; 21 | // virtual FReply OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; 22 | // virtual void OnDragLeave(const FDragDropEvent& DragDropEvent) override; 23 | // virtual FReply OnMouseMove(const FGeometry& SenderGeometry, const FPointerEvent& MouseEvent) override; 24 | // virtual void SetOwner(const TSharedRef& OwnerPanel) override; 25 | // virtual void AddPin(const TSharedRef& PinToAdd) override; 26 | //~ End SGraphNode Interface 27 | 28 | EVisibility GetDragOverMarkerVisibility() const; 29 | 30 | FText GetDescription() const; 31 | EVisibility GetDescriptionVisibility() const; 32 | 33 | const FSlateBrush* GetNameIcon() const; 34 | 35 | protected: 36 | TSharedRef CreateNodeContentArea() override; 37 | TSharedRef CreateThumbnailContentArea(); 38 | TSharedPtr NodeBody; 39 | TSharedPtr OutputPinBox; 40 | 41 | UMultiPackerOutputNode* EdActorNode; 42 | }; 43 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/MultiPackerAssetEditor/Nodes/SMultiPackerTextureEdNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "SGraphNode.h" 6 | #include "MultiPackerAssetEditor/Nodes/MultiPackerTextureEdNode.h" 7 | 8 | class SMultiPackerTextureEdNode : public SGraphNode 9 | { 10 | public: 11 | SLATE_BEGIN_ARGS(SMultiPackerTextureEdNode) {} 12 | SLATE_END_ARGS() 13 | 14 | void Construct(const FArguments& InArgs, UMultiPackerTextureEdNode* InNode); 15 | 16 | 17 | //~ Begin SGraphNode Interface 18 | //virtual void UpdateGraphNode() override; 19 | virtual void CreatePinWidgets() override; 20 | virtual void AddPin(const TSharedRef& PinToAdd) override; 21 | // virtual void OnDragEnter(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; 22 | // virtual FReply OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; 23 | // virtual FReply OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; 24 | // virtual void OnDragLeave(const FDragDropEvent& DragDropEvent) override; 25 | // virtual FReply OnMouseMove(const FGeometry& SenderGeometry, const FPointerEvent& MouseEvent) override; 26 | // virtual void SetOwner(const TSharedRef& OwnerPanel) override; 27 | // virtual void AddPin(const TSharedRef& PinToAdd) override; 28 | //~ End SGraphNode Interface 29 | 30 | virtual FSlateColor GetErrorColor() const; 31 | virtual FText GetErrorMsgToolTip() const; 32 | virtual FSlateColor GetBorderBackgroundColor() const; 33 | virtual FSlateColor GetBackgroundColor() const; 34 | 35 | virtual EVisibility GetDragOverMarkerVisibility() const; 36 | 37 | virtual FText GetDescription() const; 38 | virtual EVisibility GetDescriptionVisibility() const; 39 | 40 | virtual const FSlateBrush* GetNameIcon() const; 41 | 42 | protected: 43 | virtual TSharedRef CreateNodeContentArea() override; 44 | 45 | TSharedPtr NodeBody; 46 | TSharedPtr OutputPinBox; 47 | 48 | UMultiPackerTextureEdNode* EdActorNode; 49 | FIntPoint ThumbnailSize; 50 | private: 51 | void BuildThumbnailWidget(); 52 | 53 | TSharedPtr ErrorText; 54 | }; 55 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/MultiPackerAssetEditor/SAssetDropTargetArray.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "Input/Reply.h" 6 | #include "Widgets/DeclarativeSyntaxSupport.h" 7 | #include "SDropTarget.h" 8 | 9 | /** 10 | * A widget that displays a hover cue and handles dropping assets of allowed types onto this widget 11 | */ 12 | class SAssetDropTargetArray : public SDropTarget 13 | { 14 | public: 15 | /** Called when a valid asset is dropped */ 16 | DECLARE_DELEGATE_OneParam(FOnAssetDropped, UObject*); 17 | 18 | /** Called when we need to check if an asset type is valid for dropping */ 19 | DECLARE_DELEGATE_RetVal_OneParam(bool, FIsAssetAcceptableForDrop, const UObject*); 20 | 21 | SLATE_BEGIN_ARGS(SAssetDropTargetArray) 22 | { } 23 | /* Content to display for the in the drop target */ 24 | SLATE_DEFAULT_SLOT(FArguments, Content) 25 | /** Called when a valid asset is dropped */ 26 | SLATE_EVENT(FOnAssetDropped, OnAssetDropped) 27 | /** Called to check if an asset is acceptible for dropping */ 28 | SLATE_EVENT(FIsAssetAcceptableForDrop, OnIsAssetAcceptableForDrop) 29 | SLATE_END_ARGS() 30 | 31 | void Construct(const FArguments& InArgs); 32 | 33 | uint8 GetRow(); 34 | uint8 GetColumn(); 35 | 36 | protected: 37 | FReply OnDropped(TSharedPtr DragDropOperation); 38 | virtual bool OnAllowDrop(TSharedPtr DragDropOperation) const override; 39 | virtual bool OnIsRecognized(TSharedPtr DragDropOperation) const override; 40 | private: 41 | TArray GetDroppedObject(TSharedPtr DragDropOperation, bool& bOutRecognizedEvent) const; 42 | 43 | private: 44 | uint8 ArrayObjectNum; 45 | uint8 ArrayObjectDropTotal; 46 | uint8 ColumnAssetDrop = 0; 47 | uint8 RowAssetDrop = 0; 48 | /** Delegate to call when an asset is dropped */ 49 | FOnAssetDropped OnAssetDropped; 50 | /** Delegate to call to check validity of the asset */ 51 | FIsAssetAcceptableForDrop OnIsAssetAcceptableForDrop; 52 | }; 53 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/MultiPackerAssetEditor/SMultiPackerAssetEditorDrop.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | #include "MultiPackerAssetEditor/SAssetDropTargetArray.h" 4 | 5 | class SMultiPackerAssetEditorDrop : public SAssetDropTargetArray 6 | { 7 | public: 8 | virtual FReply OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; 9 | virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override; 10 | 11 | FVector2D GetPanelCoordDropPosition() const { return PanelCoordDropPosition; } 12 | 13 | private: 14 | FVector2D PanelCoordDropPosition; 15 | }; -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/MultiPackerAssetTypeActions.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "AssetTypeActions_Base.h" 5 | 6 | class FMultiPackerAssetTypeActions : public FAssetTypeActions_Base 7 | { 8 | public: 9 | FMultiPackerAssetTypeActions(EAssetTypeCategories::Type InAssetCategory); 10 | 11 | virtual FText GetName() const override; 12 | virtual FColor GetTypeColor() const override; 13 | virtual UClass* GetSupportedClass() const override; 14 | virtual void OpenAssetEditor(const TArray& InObjects, TSharedPtr EditWithinLevelEditor = TSharedPtr()) override; 15 | virtual uint32 GetCategories() override; 16 | 17 | private: 18 | EAssetTypeCategories::Type MyAssetCategory; 19 | }; -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/MultiPackerEditorTypes.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "MultiPackerEditorTypes.generated.h" 5 | 6 | UCLASS() 7 | class UMultiPackerEditorTypes : public UObject 8 | { 9 | GENERATED_UCLASS_BODY() 10 | 11 | static const FString SPinMaterialNode; 12 | static const FString SPinTextureNode; 13 | static const FString SPinOutputNode; 14 | static const FString PinCategory_MultipleNodes; 15 | static const FString PinCategory_SingleNode; 16 | static const FString PinCategory_RGB; 17 | static const FString PinCategory_Red; 18 | static const FString PinCategory_Green; 19 | static const FString PinCategory_Blue; 20 | static const FString PinCategory_Alpha; 21 | static const FString PinCategory_RGBA; 22 | }; 23 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/RuntimeGraph/MultiPackerRuntimeAssetEditor.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "Toolkits/AssetEditorToolkit.h" 6 | #include "Misc/NotifyHook.h" 7 | #include "GraphEditor.h" 8 | 9 | class SMultiPackerAssetEditorDrop; 10 | class FMultiPackerRuntimeAssetEditorToolbar; 11 | class UMultiPackerRuntimeGraph; 12 | class UMultiPackerRuntimeOutputNode; 13 | class SMultiPackerAssetEditorDrop; 14 | class FAssetEditorManager; 15 | class SDockTab; 16 | 17 | 18 | class FMultiPackerRuntimeAssetEditor : public FAssetEditorToolkit, public FNotifyHook, public FGCObject 19 | { 20 | public: 21 | FMultiPackerRuntimeAssetEditor(); 22 | virtual ~FMultiPackerRuntimeAssetEditor(); 23 | 24 | void InitGenericGraphAssetEditor(const EToolkitMode::Type Mode, const TSharedPtr< IToolkitHost >& InitToolkitHost, UMultiPackerRuntimeGraph* Graph); 25 | 26 | // IToolkit interface 27 | virtual void RegisterTabSpawners(const TSharedRef& TabManager) override; 28 | virtual void UnregisterTabSpawners(const TSharedRef& TabManager) override; 29 | // End of IToolkit interface 30 | 31 | // FAssetEditorToolkit 32 | virtual FName GetToolkitFName() const override; 33 | virtual FText GetBaseToolkitName() const override; 34 | virtual FText GetToolkitName() const override; 35 | virtual FText GetToolkitToolTipText() const override; 36 | virtual FLinearColor GetWorldCentricTabColorScale() const override; 37 | virtual FString GetWorldCentricTabPrefix() const override; 38 | virtual FString GetDocumentationLink() const override; 39 | virtual void SaveAsset_Execute() override; 40 | // End of FAssetEditorToolkit 41 | 42 | //Toolbar 43 | void UpdateToolbar(); 44 | TSharedPtr GetToolbarBuilder() { return ToolbarBuilder; } 45 | void RegisterToolbarTab(const TSharedRef& TabManager); 46 | 47 | 48 | // FSerializableObject interface 49 | virtual void AddReferencedObjects(FReferenceCollector& Collector) override; 50 | // End of FSerializableObject interface 51 | 52 | private: 53 | TSharedRef SpawnTab_Viewport(const FSpawnTabArgs& Args); 54 | TSharedRef SpawnTab_Details(const FSpawnTabArgs& Args); 55 | TSharedRef SpawnTab_ContentBrowser(const FSpawnTabArgs& Args); 56 | void CreateInternalWidgets(); 57 | TSharedRef CreateViewportWidget(); 58 | 59 | void BindCommands(); 60 | 61 | void CreateEdGraph(); 62 | 63 | void CreateCommandList(); 64 | 65 | TSharedPtr GetCurrGraphEditor(); 66 | 67 | FGraphPanelSelectionSet GetSelectedNodes(); 68 | 69 | void RebuildGenericGraph(); 70 | 71 | // Delegates for graph editor commands 72 | void SelectAllNodes(); 73 | bool CanSelectAllNodes(); 74 | void DeleteSelectedNodes(); 75 | bool CanDeleteNodes(); 76 | void DeleteSelectedDuplicatableNodes(); 77 | void CutSelectedNodes(); 78 | bool CanCutNodes(); 79 | void CopySelectedNodes(); 80 | bool CanCopyNodes(); 81 | void PasteNodes(); 82 | void PasteNodesHere(const FVector2D& Location); 83 | bool CanPasteNodes(); 84 | void DuplicateNodes(); 85 | bool CanDuplicateNodes(); 86 | 87 | void GraphSettings(); 88 | bool CanGraphSettings() const; 89 | void ProcessGraph(); 90 | bool CanProcessGraph(); 91 | void OnCreateComment(); 92 | ////////////////////////////////////////////////////////////////////////// 93 | // graph editor event 94 | void OnSelectedNodesChanged(const TSet& NewSelection); 95 | 96 | void OnNodeDoubleClicked(UEdGraphNode* Node); 97 | 98 | void OnFinishedChangingProperties(const FPropertyChangedEvent& PropertyChangedEvent); 99 | 100 | void OnPackageSaved(const FString& PackageFileName, UObject* Outer); 101 | 102 | void HandleAssetDropped(UObject* AssetObject); 103 | bool IsAssetAcceptableForDrop(const UObject* AssetObject) const; 104 | FVector2D GetAssetDropGridLocation() const; 105 | 106 | UMultiPackerRuntimeGraph* EditingGraph; 107 | bool NodesChanged = true; 108 | bool canProcess = true; 109 | //Toolbar 110 | TSharedPtr ToolbarBuilder; 111 | 112 | /** Handle to the registered OnPackageSave delegate */ 113 | FDelegateHandle OnPackageSavedDelegateHandle; 114 | 115 | TSharedPtr ViewportWidget; 116 | TSharedPtr PropertyWidget; 117 | //TSharedRef ViewportTab; 118 | 119 | /** The command list for this editor */ 120 | TSharedPtr GraphEditorCommands; 121 | 122 | TSharedPtr AssetDropTarget; 123 | 124 | /** 125 | * Called when a node's title is committed for a rename 126 | * 127 | * @param NewText New title text 128 | * @param CommitInfo How text was committed 129 | * @param NodeBeingChanged The node being changed 130 | */ 131 | void OnNodeTitleCommitted(const FText& NewText, ETextCommit::Type CommitInfo, UEdGraphNode* NodeBeingChanged); 132 | }; -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/RuntimeGraph/MultiPackerRuntimeAssetEditorToolbar.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | 6 | class FMultiPackerRuntimeAssetEditor; 7 | class FExtender; 8 | class FToolBarBuilder; 9 | 10 | class FMultiPackerRuntimeAssetEditorToolbar : public TSharedFromThis 11 | { 12 | public: 13 | FMultiPackerRuntimeAssetEditorToolbar(TSharedPtr InGenericGraphEditor) 14 | : GenericGraphEditor(InGenericGraphEditor) {} 15 | 16 | //void AddModesToolbar(TSharedPtr Extender); 17 | //void AddDebuggerToolbar(TSharedPtr Extender); 18 | void AddGenericGraphToolbar(TSharedPtr Extender); 19 | FSlateIcon GraphSettingsIconOutput; 20 | private: 21 | //void FillModesToolbar(FToolBarBuilder& ToolbarBuilder); 22 | //void FillDebuggerToolbar(FToolBarBuilder& ToolbarBuilder); 23 | void FillGenericGraphToolbar(FToolBarBuilder& ToolbarBuilder); 24 | 25 | protected: 26 | /** Pointer back to the blueprint editor tool that owns us */ 27 | TWeakPtr GenericGraphEditor; 28 | }; 29 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/RuntimeGraph/MultiPackerRuntimeAssetGraphSchema.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "GraphEditor.h" 6 | #include "EdGraph/EdGraphSchema.h" 7 | #include "Framework/MultiBox/MultiBoxBuilder.h" 8 | #include "Runtime/Launch/Resources/Version.h" 9 | #include "MultiPackerRuntimeAssetGraphSchema.generated.h" 10 | 11 | USTRUCT() 12 | struct FMultiPackerRuntimeAssetSchemaAction_NewNodeMat : public FEdGraphSchemaAction 13 | { 14 | GENERATED_USTRUCT_BODY(); 15 | 16 | FMultiPackerRuntimeAssetSchemaAction_NewNodeMat() 17 | : FEdGraphSchemaAction() 18 | {} 19 | 20 | FMultiPackerRuntimeAssetSchemaAction_NewNodeMat(const FText& InNodeCategory, const FText& InMenuDesc, const FText& InToolTip, const int32 InGrouping) 21 | : FEdGraphSchemaAction(InNodeCategory, InMenuDesc, InToolTip, InGrouping) 22 | {} 23 | 24 | UEdGraphNode* PerformAction(class UEdGraph* ParentGraph, UEdGraphPin* FromPin, const FVector2D Location, bool bSelectNewNode = true) override; 25 | }; 26 | 27 | //* Action to create new comment * 28 | USTRUCT() 29 | struct FMultiPackerRuntimeAssetSchemaAction_NewNodeComment : public FEdGraphSchemaAction 30 | { 31 | GENERATED_USTRUCT_BODY(); 32 | 33 | FMultiPackerRuntimeAssetSchemaAction_NewNodeComment() : FEdGraphSchemaAction() {} 34 | FMultiPackerRuntimeAssetSchemaAction_NewNodeComment(const FText& InNodeCategory, const FText& InMenuDesc, const FText& InToolTip, const int32 InGrouping) 35 | : FEdGraphSchemaAction(InNodeCategory, InMenuDesc, InToolTip, InGrouping) {} 36 | TSharedPtr Graph = NULL; 37 | //~ Begin FEdGraphSchemaAction Interface 38 | UEdGraphNode* PerformAction(UEdGraph* ParentGraph, UEdGraphPin* FromPin, const FVector2D Location, bool bSelectNewNode = true) override; 39 | //~ End FEdGraphSchemaAction Interface 40 | }; 41 | 42 | UCLASS(MinimalAPI) 43 | class UMultiPackerRuntimeAssetGraphSchema : public UEdGraphSchema 44 | { 45 | GENERATED_BODY() 46 | 47 | void GetBreakLinkToSubMenuActions(class FMenuBuilder& MenuBuilder, class UEdGraphPin* InGraphPin); 48 | 49 | //~ Begin EdGraphSchema Interface 50 | virtual void GetGraphContextActions(FGraphContextMenuBuilder& ContextMenuBuilder) const override; 51 | virtual void GetContextMenuActions(const UEdGraph* CurrentGraph, const UEdGraphNode* InGraphNode, const UEdGraphPin* InGraphPin, class FMenuBuilder* MenuBuilder, bool bIsDebugging) const override; 52 | virtual const FPinConnectionResponse CanCreateConnection(const UEdGraphPin* A, const UEdGraphPin* B) const override; 53 | virtual FLinearColor GetPinTypeColor(const FEdGraphPinType& PinType) const override; 54 | virtual void BreakNodeLinks(UEdGraphNode& TargetNode) const override; 55 | virtual void BreakPinLinks(UEdGraphPin& TargetPin, bool bSendsNodeNotifcation) const override; 56 | #if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION <= 18) 57 | virtual void BreakSinglePinLink(UEdGraphPin* SourcePin, UEdGraphPin* TargetPin) override; 58 | #endif 59 | #if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION >= 19) 60 | virtual void BreakSinglePinLink(UEdGraphPin* SourcePin, UEdGraphPin* TargetPin) const; 61 | #endif 62 | // virtual void DroppedAssetsOnGraph(const TArray& Assets, const FVector2D& GraphPosition, UEdGraph* Graph) const override; 63 | // virtual void DroppedAssetsOnNode(const TArray& Assets, const FVector2D& GraphPosition, UEdGraphNode* Node)const override; 64 | // virtual int32 GetNodeSelectionCount(const UEdGraph* Graph) const override; 65 | virtual TSharedPtr GetCreateCommentAction() const override; 66 | virtual bool IsCacheVisualizationOutOfDate(int32 InVisualizationCacheID) const override; 67 | virtual int32 GetCurrentVisualizationCacheID() const override; 68 | virtual void ForceVisualizationCacheClear() const override; 69 | //~ End EdGraphSchema Interface 70 | 71 | private: 72 | static int32 CurrentCacheRefreshID; 73 | }; 74 | 75 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/RuntimeGraph/MultiPackerRuntimeAssetTypeActions.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "AssetTypeActions_Base.h" 5 | 6 | class FMultiPackerRuntimeAssetTypeActions : public FAssetTypeActions_Base 7 | { 8 | public: 9 | FMultiPackerRuntimeAssetTypeActions(EAssetTypeCategories::Type InAssetCategory); 10 | 11 | virtual FText GetName() const override; 12 | virtual FColor GetTypeColor() const override; 13 | virtual UClass* GetSupportedClass() const override; 14 | virtual void OpenAssetEditor(const TArray& InObjects, TSharedPtr EditWithinLevelEditor = TSharedPtr()) override; 15 | virtual uint32 GetCategories() override; 16 | 17 | private: 18 | EAssetTypeCategories::Type MyAssetCategory; 19 | }; -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/RuntimeGraph/MultiPackerRuntimeEdGraph.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | #include "EdGraph/EdGraph.h" 4 | #include "MultiPackerRuntimeEdGraph.generated.h" 5 | 6 | UCLASS() 7 | class UMultiPackerRuntimeEdGraph : public UEdGraph 8 | { 9 | GENERATED_BODY() 10 | 11 | public: 12 | UMultiPackerRuntimeEdGraph(); 13 | virtual ~UMultiPackerRuntimeEdGraph(); 14 | 15 | virtual void RebuildGenericGraph(); 16 | bool MultiPackerNode = false; 17 | bool IsRebuilding = false; 18 | #if WITH_EDITOR 19 | virtual void PostEditUndo() override; 20 | #endif 21 | }; 22 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/RuntimeGraph/Nodes/MultiPackerRuntimeMaterialNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | #include "CoreMinimal.h" 4 | #include "EdGraph/EdGraphNode.h" 5 | #include "MultiPackerRuntimeMaterialNode.generated.h" 6 | 7 | class UMultiPackerRuntimeMatNode; 8 | class FAssetThumbnail; 9 | class UMultiPackerRuntimeEdGraph; 10 | 11 | UCLASS(MinimalAPI) 12 | class UMultiPackerRuntimeMaterialNode : public UEdGraphNode 13 | { 14 | GENERATED_BODY() 15 | public: 16 | TSharedPtr AssetThumbnail; 17 | 18 | UPROPERTY(VisibleAnywhere, instanced, Category = "MultiPacker") 19 | UMultiPackerRuntimeMatNode* MultiPackerRuntimeMatNode; 20 | 21 | virtual void AllocateDefaultPins() override; 22 | virtual void NodeConnectionListChanged() override; 23 | 24 | UMultiPackerRuntimeEdGraph* GetGenericGraphEdGraph(); 25 | 26 | virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const; 27 | 28 | void SetGenericGraphNode(UMultiPackerRuntimeMatNode* InNode); 29 | 30 | FString GetNodeTitle(); 31 | 32 | bool SetThumbnail(); 33 | 34 | void SetMaterialInput(UMaterialInterface* Material); 35 | 36 | virtual FText GetDescription() const; 37 | 38 | virtual UObject* GetNodeAssetObject(UObject* Outer); 39 | virtual UObject* GetThumbnailAssetObject(); 40 | 41 | virtual FLinearColor GetBackgroundColor() const; 42 | }; 43 | 44 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/RuntimeGraph/Nodes/MultiPackerRuntimeOutputNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "EdGraph/EdGraphNode.h" 6 | #include "MultiPackerRuntimeOutputNode.generated.h" 7 | 8 | class UMultiPackerRuntimeEdGraph; 9 | class FAssetThumbnail; 10 | class UTexture2D; 11 | 12 | UCLASS(MinimalAPI) 13 | class UMultiPackerRuntimeOutputNode : public UEdGraphNode 14 | { 15 | GENERATED_BODY() 16 | public: 17 | TSharedPtr AssetThumbnail; 18 | 19 | void SetThumnailOutput(UTexture2D* Input); 20 | void AllocateDefaultPins() override; 21 | void NodeConnectionListChanged() override; 22 | bool CanUserDeleteNode()const override; 23 | 24 | private: 25 | UTexture2D* TextureInput; 26 | }; -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/RuntimeGraph/Nodes/SMultiPackerRuntimeMaterialNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "RuntimeGraph/Nodes/MultiPackerRuntimeMaterialNode.h" 5 | 6 | class SMultiPackerRuntimeMaterialNode : public SGraphNode 7 | { 8 | public: 9 | SLATE_BEGIN_ARGS(SMultiPackerRuntimeMaterialNode) {} 10 | SLATE_END_ARGS() 11 | 12 | void Construct(const FArguments& InArgs, UMultiPackerRuntimeMaterialNode* InNode); 13 | 14 | 15 | //~ Begin SGraphNode Interface 16 | //virtual void UpdateGraphNode() override; 17 | virtual void CreatePinWidgets() override; 18 | virtual void AddPin(const TSharedRef& PinToAdd) override; 19 | // virtual void OnDragEnter(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; 20 | // virtual FReply OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; 21 | // virtual FReply OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; 22 | // virtual void OnDragLeave(const FDragDropEvent& DragDropEvent) override; 23 | // virtual FReply OnMouseMove(const FGeometry& SenderGeometry, const FPointerEvent& MouseEvent) override; 24 | // virtual void SetOwner(const TSharedRef& OwnerPanel) override; 25 | // virtual void AddPin(const TSharedRef& PinToAdd) override; 26 | //~ End SGraphNode Interface 27 | 28 | virtual FSlateColor GetErrorColor() const; 29 | virtual FText GetErrorMsgToolTip() const; 30 | virtual FSlateColor GetBorderBackgroundColor() const; 31 | virtual FSlateColor GetBackgroundColor() const; 32 | 33 | virtual EVisibility GetDragOverMarkerVisibility() const; 34 | 35 | virtual FText GetDescription() const; 36 | virtual EVisibility GetDescriptionVisibility() const; 37 | 38 | virtual const FSlateBrush* GetNameIcon() const; 39 | 40 | protected: 41 | virtual TSharedRef CreateNodeContentArea() override; 42 | TSharedPtr NodeBody; 43 | TSharedPtr OutputPinBox; 44 | 45 | UMultiPackerRuntimeMaterialNode* EdActorNode; 46 | FIntPoint ThumbnailSize; 47 | private: 48 | void BuildThumbnailWidget(); 49 | 50 | TSharedPtr ErrorText; 51 | }; 52 | 53 | -------------------------------------------------------------------------------- /Source/MultiPackerEditor/Public/RuntimeGraph/Nodes/SMultiPackerRuntimeOutputNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "RuntimeGraph/Nodes/MultiPackerRuntimeOutputNode.h" 5 | #include "SGraphNode.h" 6 | 7 | class SMultiPackerRuntimeOutputNode : public SGraphNode 8 | { 9 | public: 10 | SLATE_BEGIN_ARGS(SMultiPackerRuntimeOutputNode) {} 11 | SLATE_END_ARGS() 12 | 13 | void Construct(const FArguments& InArgs, UMultiPackerRuntimeOutputNode* InNode); 14 | 15 | 16 | //~ Begin SGraphNode Interface 17 | //virtual void UpdateGraphNode() override; 18 | virtual void CreatePinWidgets() override; 19 | virtual void AddPin(const TSharedRef& PinToAdd) override; 20 | // virtual void OnDragEnter(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; 21 | // virtual FReply OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; 22 | // virtual FReply OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; 23 | // virtual void OnDragLeave(const FDragDropEvent& DragDropEvent) override; 24 | // virtual FReply OnMouseMove(const FGeometry& SenderGeometry, const FPointerEvent& MouseEvent) override; 25 | // virtual void SetOwner(const TSharedRef& OwnerPanel) override; 26 | // virtual void AddPin(const TSharedRef& PinToAdd) override; 27 | //~ End SGraphNode Interface 28 | 29 | virtual FSlateColor GetBackgroundColor() const; 30 | 31 | virtual EVisibility GetDragOverMarkerVisibility() const; 32 | 33 | virtual FText GetDescription() const; 34 | virtual EVisibility GetDescriptionVisibility() const; 35 | 36 | virtual const FSlateBrush* GetNameIcon() const; 37 | 38 | protected: 39 | virtual TSharedRef CreateNodeContentArea() override; 40 | TSharedPtr NodeBody; 41 | TSharedPtr OutputPinBox; 42 | 43 | UMultiPackerRuntimeOutputNode* EdActorNode; 44 | 45 | }; 46 | -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/MultiPackerRuntime.Build.cs: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | 3 | namespace UnrealBuildTool.Rules 4 | { 5 | public class MultiPackerRuntime : ModuleRules 6 | { 7 | public MultiPackerRuntime(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | bEnforceIWYU = true; 10 | bUseAVX = true; 11 | OptimizeCode = CodeOptimization.Always; 12 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 13 | PrivateIncludePaths.Add("MultiPackerRuntime/Private"); 14 | 15 | PublicDependencyModuleNames.AddRange( 16 | new string[] 17 | { 18 | "Core", 19 | "Engine", 20 | "CoreUObject", 21 | "UMG" 22 | } 23 | ); 24 | 25 | PrivateDependencyModuleNames.AddRange( 26 | new string[] 27 | { 28 | "Slate", 29 | "SlateCore", 30 | "UMG", 31 | "RenderCore", 32 | } 33 | ); 34 | 35 | if (Target.bBuildEditor == true) 36 | { 37 | PrivateDependencyModuleNames.AddRange( 38 | new string[] 39 | { 40 | "EditorWidgets", 41 | //"UnrealEd", 42 | "LevelEditor" 43 | } 44 | ); 45 | 46 | PublicDependencyModuleNames.AddRange( 47 | new string[] 48 | { 49 | "DesktopPlatform", 50 | "AssetTools", 51 | "EditorStyle" 52 | } 53 | ); 54 | } 55 | } 56 | 57 | } 58 | } -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Private/BinPack/MultiPackerRuntimeBinPack.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | 3 | #include "BinPack/MultiPackerRuntimeBinPack.h" 4 | #include 5 | #include "BinPack/MaxRectsBinPack.h" 6 | #include "CanvasItem.h" 7 | #include "Engine/Canvas.h" 8 | #include "Kismet/KismetRenderingLibrary.h" 9 | #include "Engine/TextureRenderTarget2D.h" 10 | #include 11 | #include 12 | #include 13 | 14 | #define LOCTEXT_NAMESPACE "MultiPackerRuntimeBinPack" 15 | 16 | void UMultiPackerRuntimeBinPack::Init(UObject* WorldContextObject, int InSize, bool InAlpha) 17 | { 18 | Size = InSize; 19 | Alpha = InAlpha; 20 | WorldContext = WorldContextObject; 21 | NumPages.Add(MakeNewPage()); 22 | } 23 | 24 | void UMultiPackerRuntimeBinPack::SetMaterial(UMaterialInterface* Material, int32 Width, int32 Height) 25 | { 26 | FMaterialDataBinPack NewMat = AddMaterialToMap(Material, Width, Height); 27 | MaterialMap.Add( FName( *(Material->GetName() ) ), NewMat); 28 | SetRTOnCanvas(RenderTargetPages[NewMat.NumPage], NewMat.RT_Material, NewMat.MaterialRect, Size, Size);// NewMat.Width, NewMat.Height); 29 | } 30 | 31 | FMaterialDataBinPack* UMultiPackerRuntimeBinPack::GetMaterialData(FName Material) 32 | { 33 | if (MaterialMap.Contains(Material)) 34 | { 35 | return MaterialMap.Find(Material); 36 | } 37 | return nullptr; 38 | } 39 | 40 | FMaterialDataBinPack UMultiPackerRuntimeBinPack::AddMaterialToMap(UMaterialInterface* Material, int32 Width, int32 Height) 41 | { 42 | FMaterialDataBinPack NewMat = FMaterialDataBinPack(); 43 | NewMat.Material = Material; 44 | NewMat.Width = Size; 45 | NewMat.Height = Size; 46 | UTextureRenderTarget2D* RT_new = UMultiPackerBaseEnums::GenerateRenderTarget(Height, Width, Alpha); 47 | UKismetRenderingLibrary::DrawMaterialToRenderTarget(WorldContext, RT_new, Material); 48 | 49 | NewMat.RT_Material = RT_new; 50 | for (int p = 0; p < NumPages.Num(); p++) 51 | { 52 | NewMat.MaterialRect = BinPackPages[NumPages[p]]->Insert(Width, Height, EFreeRectChoiceHeuristic::EMCE_Option3); 53 | if (NewMat.MaterialRect.height == 0 && p == (NumPages.Num() - 1)) 54 | { 55 | int newPage = MakeNewPage(); 56 | NumPages.Add(newPage); 57 | NewMat.MaterialRect = BinPackPages[newPage]->Insert(Width, Height, EFreeRectChoiceHeuristic::EMCE_Option3); 58 | NewMat.NumPage = newPage; 59 | } 60 | else 61 | { 62 | NewMat.NumPage = NumPages[p]; 63 | } 64 | } 65 | return NewMat; 66 | } 67 | 68 | int UMultiPackerRuntimeBinPack::MakeNewPage() 69 | { 70 | UMaxRectsBinPack* BinPack = NewObject(); 71 | BinPack->Init(Size, Size); 72 | RenderTargetPages.Add(UMultiPackerBaseEnums::GenerateRenderTarget(Size, Size, Alpha)); 73 | return BinPackPages.Add(BinPack); 74 | } 75 | 76 | TArray UMultiPackerRuntimeBinPack::RuntimePreProcess(UObject* WorldContextObject, TMap InMaterialMap, int InPages, int InSize, bool InAlpha) 77 | { 78 | WorldContext = WorldContextObject; 79 | TArray RT_New; 80 | for (int page = 0; page < InPages; page++) 81 | { 82 | RT_New.Add(UMultiPackerBaseEnums::GenerateRenderTarget(InSize, InSize, InAlpha)); 83 | } 84 | for (auto& Elem : InMaterialMap) 85 | { 86 | UTextureRenderTarget2D* RT_Mat = UMultiPackerBaseEnums::GenerateRenderTarget(Elem.Value.Height, Elem.Value.Width, InAlpha); 87 | UKismetRenderingLibrary::DrawMaterialToRenderTarget(WorldContextObject, RT_Mat, Elem.Value.Material); 88 | SetRTOnCanvas(RT_New[Elem.Value.NumPage], RT_Mat, Elem.Value.MaterialRect, InSize, InSize); 89 | } 90 | return RT_New; 91 | } 92 | 93 | UTextureRenderTarget2D* UMultiPackerRuntimeBinPack::SetRTOnCanvas(UTextureRenderTarget2D* OutputTexture, UTextureRenderTarget2D* RT_Array_New, FRectSizePadding Rect, uint16 Width, uint16 Height) 94 | { 95 | UCanvas* Canvas; 96 | FDrawToRenderTargetContext Context = FDrawToRenderTargetContext(); 97 | FVector2D VectorSize = FVector2D(Width, Height); 98 | UKismetRenderingLibrary::BeginDrawCanvasToRenderTarget(WorldContext, OutputTexture, Canvas, VectorSize, Context); 99 | 100 | FTexture* RenderTextureResource = (RT_Array_New) ? RT_Array_New->Resource : GWhiteTexture; 101 | FCanvasTileItem TileItem(FVector2D(Rect.x, Rect.y), RenderTextureResource, FVector2D(Rect.width, Rect.height), FVector2D(0.0f, 0.0f), FVector2D(0.0f, 0.0f) + FVector2D::UnitVector, FLinearColor::White); 102 | TileItem.Rotation = FRotator(0, 0.f, 0); 103 | TileItem.PivotPoint = FVector2D(0.5f, 0.5f); 104 | TileItem.BlendMode = FCanvas::BlendToSimpleElementBlend(EBlendMode::BLEND_AlphaComposite); 105 | Canvas->DrawItem(TileItem); 106 | 107 | UKismetRenderingLibrary::EndDrawCanvasToRenderTarget(WorldContext, Context); 108 | return OutputTexture; 109 | } 110 | 111 | #undef LOCTEXT_NAMESPACE 112 | -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Private/Graph/MultiPacker.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | 3 | #include "Graph/MultiPacker.h" 4 | #include "Engine/TextureRenderTarget2D.h" 5 | #include "Graph/MultiPackerTextureNode.h" 6 | #include "Graph/MultiPackerMatNode.h" 7 | #include "MultiPackerSettings.h" 8 | #include 9 | #define LOCTEXT_NAMESPACE "MultiPacker" 10 | 11 | UMultiPacker::UMultiPacker() 12 | { 13 | NodeType = UMultiPackerTextureNode::StaticClass(); 14 | MatNodeType = UMultiPackerMatNode::StaticClass(); 15 | #if WITH_EDITORONLY_DATA 16 | EdGraph = nullptr; 17 | #endif 18 | const UMultiPackerSettings* Settings = GetDefault(); 19 | ChannelMethod = Settings->GetChannelMethod(); 20 | SaveMaterialCollection = Settings->GetSaveMaterialCollection(); 21 | SaveDatabase = Settings->GetSaveDatabase(); 22 | TargetDirectory = Settings->GetTargetDirectory(); 23 | DatabasePrefix = Settings->GetDatabasePrefix(); 24 | TexturePrefix = Settings->GetTexturePrefix(); 25 | MaterialcollectionPrefix = Settings->GetMaterialcollectionPrefix(); 26 | } 27 | 28 | UMultiPacker::~UMultiPacker() 29 | { 30 | } 31 | 32 | void UMultiPacker::ClearGraph() 33 | { 34 | TexNodes.Reset(); 35 | MatNodes.Reset(); 36 | } 37 | 38 | #if WITH_EDITOR 39 | void UMultiPacker::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) 40 | { 41 | FName PropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.Property->GetFName() : NAME_None; 42 | uint32 SizeOut = (uint32)0; 43 | if ((PropertyName == GET_MEMBER_NAME_CHECKED(UMultiPacker, TextureTileSizeOutput))) 44 | { 45 | SizeOut = (uint32)TextureTileSizeOutput * 32; 46 | } 47 | if ((PropertyName == GET_MEMBER_NAME_CHECKED(UMultiPacker, RectangleTiles))) 48 | { 49 | for (UMultiPackerTextureNode* Node : TexNodes) 50 | { 51 | Node->RectangleSize = RectangleTiles; 52 | Node->CompareSizes(UMultiPackerBaseEnums::GetTextureSizeOutputEnum(OutputSizeY), UMultiPackerBaseEnums::GetTextureSizeOutputEnum(OutputSizeX)); 53 | } 54 | for (UMultiPackerMatNode* Node : MatNodes) 55 | { 56 | Node->RectangleSize = RectangleTiles; 57 | Node->CompareSizes(UMultiPackerBaseEnums::GetTextureSizeOutputEnum(OutputSizeY), UMultiPackerBaseEnums::GetTextureSizeOutputEnum(OutputSizeX)); 58 | } 59 | } 60 | if ((PropertyName == GET_MEMBER_NAME_CHECKED(UMultiPacker, OutputSizeX))) 61 | { 62 | for (UMultiPackerTextureNode* Node : TexNodes) 63 | { 64 | Node->CompareSizes(UMultiPackerBaseEnums::GetTextureSizeOutputEnum(OutputSizeY), UMultiPackerBaseEnums::GetTextureSizeOutputEnum(OutputSizeX)); 65 | } 66 | for (UMultiPackerMatNode* Node : MatNodes) 67 | { 68 | Node->CompareSizes(UMultiPackerBaseEnums::GetTextureSizeOutputEnum(OutputSizeY), UMultiPackerBaseEnums::GetTextureSizeOutputEnum(OutputSizeX)); 69 | } 70 | } 71 | if ((PropertyName == GET_MEMBER_NAME_CHECKED(UMultiPacker, OutputSizeY))) 72 | { 73 | for (UMultiPackerTextureNode* Node : TexNodes) 74 | { 75 | Node->CompareSizes(UMultiPackerBaseEnums::GetTextureSizeOutputEnum(OutputSizeY), UMultiPackerBaseEnums::GetTextureSizeOutputEnum(OutputSizeX)); 76 | } 77 | for (UMultiPackerMatNode* Node : MatNodes) 78 | { 79 | Node->CompareSizes(UMultiPackerBaseEnums::GetTextureSizeOutputEnum(OutputSizeY), UMultiPackerBaseEnums::GetTextureSizeOutputEnum(OutputSizeX)); 80 | } 81 | } 82 | Super::PostEditChangeProperty(PropertyChangedEvent); 83 | } 84 | #endif 85 | 86 | #undef LOCTEXT_NAMESPACE 87 | -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Private/Graph/MultiPackerMatNode.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | 3 | #include "Graph/MultiPackerMatNode.h" 4 | #include "Graph/MultiPacker.h" 5 | #include "Materials/MaterialInterface.h" 6 | 7 | #define LOCTEXT_NAMESPACE "MultiPackerMatNode" 8 | 9 | UMultiPackerMatNode::UMultiPackerMatNode() 10 | { 11 | ChangeBackground(false); 12 | ErrorSize = RectangleSize ? CompareSizes(UMultiPackerBaseEnums::GetTextureSizeOutputEnum(GetGraph()->OutputSizeY), UMultiPackerBaseEnums::GetTextureSizeOutputEnum(GetGraph()->OutputSizeY)) : false; 13 | } 14 | 15 | UMultiPacker* UMultiPackerMatNode::GetGraph() const 16 | { 17 | return Cast(GetOuter()); 18 | } 19 | 20 | #if WITH_EDITOR 21 | void UMultiPackerMatNode::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) 22 | { 23 | FName PropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.Property->GetFName() : NAME_None; 24 | Super::PostEditChangeProperty(PropertyChangedEvent); 25 | if ((PropertyName == GET_MEMBER_NAME_CHECKED(UMultiPackerMatNode, SetSizeByParameter))) 26 | { 27 | SizeVertical = SizeHorizontal = UMultiPackerBaseEnums::GetTextureSizeOutputEnum(SetSizeByParameter); 28 | ErrorSize = RectangleSize ? CompareSizes(UMultiPackerBaseEnums::GetTextureSizeOutputEnum(GetGraph()->OutputSizeY), UMultiPackerBaseEnums::GetTextureSizeOutputEnum(GetGraph()->OutputSizeY)) : false; 29 | } 30 | } 31 | #endif 32 | 33 | bool UMultiPackerMatNode::CanProcess() 34 | { 35 | if (MaterialBaseInput) 36 | bMatAsset = true; 37 | bCanProcess = !ErrorSize && !ErrorTiles && bMatAsset; 38 | return bCanProcess; 39 | } 40 | 41 | bool UMultiPackerMatNode::CompareSizes(int32 Vertical, int32 Horizontal) 42 | { 43 | ErrorSize = false; 44 | if (SizeVertical / TilesVertical > Vertical) 45 | ErrorSize = true; 46 | if (SizeHorizontal / TilesHorizontal > Horizontal) 47 | ErrorSize = true; 48 | return ErrorSize; 49 | } 50 | 51 | void UMultiPackerMatNode::SetErrorTiles(bool error) 52 | { 53 | ErrorTiles = error; 54 | } 55 | 56 | void UMultiPackerMatNode::ChangeBackground(bool error) 57 | { 58 | BackgroundColor = error ? FLinearColor(1.0f, 0.0f, 0.0f, 1.0f) : FLinearColor(0.2f, 0.2f, 0.2f, 1.0f); 59 | } 60 | 61 | FLinearColor UMultiPackerMatNode::GetBackground() const 62 | { 63 | return BackgroundColor; 64 | } 65 | 66 | #undef LOCTEXT_NAMESPACE 67 | -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Private/MultiPackerLayerDatabase.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "MultiPackerLayerDatabase.h" 3 | 4 | UMultiPackerLayerDatabase::UMultiPackerLayerDatabase(const FObjectInitializer& ObjectInitializer) 5 | : Super(ObjectInitializer) 6 | { 7 | } -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Private/MultiPackerRuntime.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "IMultiPackerRuntime.h" 3 | 4 | DEFINE_LOG_CATEGORY(MultiPackerRuntime) 5 | 6 | class FMultiPackerRuntime : public IMultiPackerRuntime 7 | { 8 | /** IModuleInterface implementation */ 9 | virtual void StartupModule() override; 10 | virtual void ShutdownModule() override; 11 | }; 12 | 13 | IMPLEMENT_MODULE( FMultiPackerRuntime, MultiPackerRuntime ) 14 | 15 | void FMultiPackerRuntime::StartupModule() 16 | { 17 | // This code will execute after your module is loaded into memory (but after global variables are initialized, of course.) 18 | } 19 | 20 | void FMultiPackerRuntime::ShutdownModule() 21 | { 22 | // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, 23 | // we call this function before unloading the module. 24 | } 25 | -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Private/MultiPackerRuntimeGraph.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | 3 | #include "MultiPackerRuntimeGraph.h" 4 | #include "MultiPackerRuntimeMatNode.h" 5 | #include "Kismet/KismetRenderingLibrary.h" 6 | #include 7 | #include "Engine/Canvas.h" 8 | #include "RenderUtils.h" 9 | #include "BinPack/MultiPackerRuntimeBinPack.h" 10 | #include 11 | #include 12 | #include "TileUtils/TilePointer.h" 13 | 14 | #define LOCTEXT_NAMESPACE "MultiPackerRuntimeGraph" 15 | 16 | UMultiPackerRuntimeGraph::UMultiPackerRuntimeGraph() 17 | { 18 | MatNodeType = UMultiPackerRuntimeMatNode::StaticClass(); 19 | #if WITH_EDITORONLY_DATA 20 | EdGraph = nullptr; 21 | #endif 22 | } 23 | 24 | UMultiPackerRuntimeGraph::~UMultiPackerRuntimeGraph() 25 | { 26 | } 27 | 28 | void UMultiPackerRuntimeGraph::RuntimePreProcess(UObject* WorldContextObject) 29 | { 30 | RuntimeData = NewObject(); 31 | RenderTargetPages = RuntimeData->RuntimePreProcess(WorldContextObject, MaterialMap, Pages, Size, Alpha); 32 | } 33 | 34 | void UMultiPackerRuntimeGraph::RetrieveMaterialInfo(UObject* WorldContextObject, UMaterialInterface* Material, /*out*/ UTextureRenderTarget2D*& RT_Output, /*out*/ FMaterialDataBinPack& Database) 35 | { 36 | ValidationOnRuntime(WorldContextObject); 37 | FMaterialDataBinPack BinPack_value{}; 38 | FCustomThunkTemplates::Map_Find(MaterialMap, FName(*Material->GetName()), /*out*/ BinPack_value); 39 | Database = BinPack_value; 40 | RT_Output = RenderTargetPages[BinPack_value.NumPage]; 41 | } 42 | 43 | void UMultiPackerRuntimeGraph::SetTextureRuntimeOnMaterial(UObject* WorldContextObject, UMaterialInterface* MaterialToGet, UMaterialInstanceDynamic* MaterialToSet, FName Texture, FName Booleans, FName SizePadding) 44 | { 45 | UTextureRenderTarget2D* RT_Output; 46 | FMaterialDataBinPack Database; 47 | RetrieveMaterialInfo(WorldContextObject, MaterialToGet, RT_Output, Database); 48 | MaterialToSet->SetTextureParameterValue(Texture, RT_Output); 49 | MaterialToSet->SetVectorParameterValue(Booleans, FLinearColor(1.0f, 0.0f, 0.0f, 0.0f)); 50 | float Red = (float) Database.MaterialRect.x / (float) Database.MaterialRect.width; 51 | float Green = (float) Database.MaterialRect.y / (float) Database.MaterialRect.height; 52 | float Blue = (float)Size / (float) Database.MaterialRect.width; 53 | float Alpha_f = (float)Size / (float) Database.MaterialRect.height; 54 | Blue = Blue == INFINITY ? 0.0f : Blue; 55 | Alpha_f = Alpha_f == INFINITY ? 0.0f : Alpha_f; 56 | Red = Red == INFINITY ? 0.0f : Red; 57 | Green = Green == INFINITY ? 0.0f : Green; 58 | MaterialToSet->SetVectorParameterValue(SizePadding, FLinearColor(Red, Green, Blue, Alpha_f)); 59 | } 60 | 61 | UTexture2D* UMultiPackerRuntimeGraph::GetTileTexture(UObject* WorldContextObject, UMaterialInterface* MaterialToGet) 62 | { 63 | UTextureRenderTarget2D* RT_Output; 64 | FMaterialDataBinPack Database; 65 | RetrieveMaterialInfo(WorldContextObject, MaterialToGet, RT_Output, Database); 66 | UTilePointer* NewTile = NewObject(UTilePointer::StaticClass()); 67 | NewTile->GenerateFromRT(RT_Output, Size, Size); 68 | UTilePointer* TexTile = NewTile->GetSplitTile(Database.MaterialRect); 69 | return TexTile->TileTexture; 70 | } 71 | 72 | void UMultiPackerRuntimeGraph::ValidationOnRuntime(UObject* WorldContextObject) 73 | { 74 | if (RenderTargetPages.Num() > 0) 75 | { 76 | for (UTextureRenderTarget2D* RT_Transitional : RenderTargetPages) 77 | { 78 | if (!::IsValid(RT_Transitional)) 79 | { 80 | RuntimePreProcess(WorldContextObject);//RT array GC 81 | } 82 | } 83 | } 84 | else 85 | { 86 | RuntimePreProcess(WorldContextObject);//RT array empty 87 | } 88 | } 89 | 90 | void UMultiPackerRuntimeGraph::ClearGraph() 91 | { 92 | for (int i = 0; i < MatNodes.Num(); ++i) 93 | { 94 | UMultiPackerRuntimeMatNode* Node = MatNodes[i]; 95 | 96 | Node->ParentNode = nullptr; 97 | } 98 | MatNodes.Reset(); 99 | } 100 | 101 | #if WITH_EDITOR 102 | void UMultiPackerRuntimeGraph::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) 103 | { 104 | FName PropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.Property->GetFName() : NAME_None; 105 | Super::PostEditChangeProperty(PropertyChangedEvent); 106 | } 107 | 108 | void UMultiPackerRuntimeGraph::ProcessNodes(UObject* WorldContextObject) 109 | { 110 | RuntimeData = NewObject(); 111 | Size = UMultiPackerBaseEnums::GetTextureSizeOutputEnum(RenderTargetSizeOutput); 112 | RuntimeData->Init(WorldContextObject, Size, Alpha); 113 | for (UMultiPackerRuntimeMatNode* Node : MatNodes) 114 | { 115 | RuntimeData->SetMaterial(Node->MaterialBaseInput, Node->Width, Node->Height); 116 | } 117 | Pages = RuntimeData->BinPackPages.Num(); 118 | MaterialMap = RuntimeData->MaterialMap; 119 | MarkPackageDirty(); 120 | } 121 | 122 | #endif 123 | 124 | #undef LOCTEXT_NAMESPACE 125 | -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Private/MultiPackerRuntimeMatNode.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "MultiPackerRuntimeMatNode.h" 3 | #include "Runtime/Launch/Resources/Version.h" 4 | #include "ImageUtils.h" 5 | #include "Engine/TextureRenderTarget2D.h" 6 | #include "Materials/MaterialInterface.h" 7 | #include "Materials/MaterialInstanceDynamic.h" 8 | 9 | #define LOCTEXT_NAMESPACE "MultiPackerRuntimeMatNode" 10 | 11 | UMultiPackerRuntimeMatNode::UMultiPackerRuntimeMatNode() 12 | { 13 | ChangeBackground(false); 14 | } 15 | 16 | UMultiPackerRuntimeMatNode::~UMultiPackerRuntimeMatNode() 17 | { 18 | } 19 | 20 | UMultiPackerRuntimeGraph* UMultiPackerRuntimeMatNode::GetGraph() const 21 | { 22 | return Cast(GetOuter()); 23 | } 24 | 25 | #if WITH_EDITOR 26 | void UMultiPackerRuntimeMatNode::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) 27 | { 28 | FName PropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.Property->GetFName() : NAME_None; 29 | if ((PropertyName == GET_MEMBER_NAME_CHECKED(UMultiPackerRuntimeMatNode, MaterialSize))) 30 | { 31 | Height = Width = UMultiPackerBaseEnums::GetTextureSizeOutputEnum(MaterialSize); 32 | } 33 | } 34 | #endif 35 | 36 | void UMultiPackerRuntimeMatNode::ChangeBackground(bool error) 37 | { 38 | BackgroundColor = error ? FLinearColor(1.0f, 0.0f, 0.0f, 1.0f) : FLinearColor(0.2f, 0.2f, 0.2f, 1.0f); 39 | } 40 | 41 | FLinearColor UMultiPackerRuntimeMatNode::GetBackground() const 42 | { 43 | return BackgroundColor; 44 | } 45 | 46 | #undef LOCTEXT_NAMESPACE 47 | -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Private/TileUtils/TileCopy.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "TileUtils/TileCopy.h" 3 | 4 | UTileCopy::UTileCopy(const FObjectInitializer& ObjectInitializer) 5 | : Super(ObjectInitializer) 6 | { 7 | } -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Public/BinPack/MaxRectsBinPack.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | 3 | /* Based on the work of Jukka Jylanki released as Public Domain*/ 4 | //To solve the warning c4828 the diaeresis are out on the surname of Jukka// 5 | #pragma once 6 | 7 | #include "CoreMinimal.h" 8 | #include "MultiPackerBaseEnums.h" 9 | #include "MaxRectsBinPack.generated.h" 10 | 11 | /** UMaxRectsBinPack implements the MAXRECTS data structure and different bin packing algorithms that 12 | use this structure. */ 13 | UCLASS(hidecategories = object) 14 | class MULTIPACKERRUNTIME_API UMaxRectsBinPack : public UObject 15 | { 16 | GENERATED_BODY() 17 | 18 | public: 19 | /// Instantiates a bin of size (0,0). Call Init to create a new bin. 20 | UMaxRectsBinPack(); 21 | ~UMaxRectsBinPack(); 22 | 23 | /// Returns true if a is contained in b. 24 | bool IsContainedIn(const FRectSizePadding &a, const FRectSizePadding &b); 25 | 26 | /// Instantiates a bin of the given size. 27 | UMaxRectsBinPack(int width, int height); 28 | 29 | 30 | /// (Re)initializes the packer to an empty bin of width x height units. Call whenever 31 | /// you need to restart with a new bin. 32 | void Init(int width, int height); 33 | 34 | /// Inserts the given list of rectangles in an offline/batch mode, possibly rotated. 35 | /// @param rects The list of rectangles to insert. This vector will be destroyed in the process. 36 | /// @param dst [out] This list will contain the packed rectangles. The indices will not correspond to that of rects. 37 | /// @param method The rectangle placement rule to use when packing. 38 | void Insert(TArray &rects, TArray &dst, EFreeRectChoiceHeuristic method); 39 | /// Inserts a single rectangle into the bin, possibly rotated. 40 | FRectSizePadding Insert(int32 width, int32 height, EFreeRectChoiceHeuristic method); 41 | 42 | /// Computes the ratio of used surface area to the total bin area. 43 | float Occupancy() const; 44 | 45 | private: 46 | int binWidth; 47 | int binHeight; 48 | 49 | TArray usedRectangles; 50 | TArray freeRectangles; 51 | 52 | /// Computes the placement score for placing the given rectangle with the given method. 53 | /// @param score1 [out] The primary placement score will be outputted here. 54 | /// @param score2 [out] The secondary placement score will be outputted here. This isu sed to break ties. 55 | /// @return This struct identifies where the rectangle would be placed if it were placed. 56 | FRectSizePadding ScoreRect(int width, int height, EFreeRectChoiceHeuristic method, int &score1, int &score2) const; 57 | 58 | /// Places the given rectangle into the bin. 59 | void PlaceRect(const FRectSizePadding &node); 60 | 61 | /// Computes the placement score for the -CP variant. 62 | int ContactPointScoreNode(int x, int y, int width, int height) const; 63 | 64 | FRectSizePadding FindPositionForNewNodeBottomLeft(int width, int height, int &bestY, int &bestX) const; 65 | FRectSizePadding FindPositionForNewNodeBestShortSideFit(int width, int height, int &bestShortSideFit, int &bestLongSideFit) const; 66 | FRectSizePadding FindPositionForNewNodeBestLongSideFit(int width, int height, int &bestShortSideFit, int &bestLongSideFit) const; 67 | FRectSizePadding FindPositionForNewNodeBestAreaFit(int32 width, int32 height, int &bestAreaFit, int &bestShortSideFit) const; 68 | FRectSizePadding FindPositionForNewNodeContactPoint(int width, int height, int &contactScore) const; 69 | 70 | /// @return True if the free node was split. 71 | bool SplitFreeNode(FRectSizePadding freeNode, const FRectSizePadding &usedNode); 72 | 73 | //int CommonIntervalLength(int i1start, int i1end, int i2start, int i2end); 74 | /// Goes through the free rectangle list and removes any redundant entries. 75 | void PruneFreeList(); 76 | }; 77 | 78 | -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Public/BinPack/MultiPackerRuntimeBinPack.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | 3 | #pragma once 4 | #include "CoreMinimal.h" 5 | #include "MultiPackerBaseEnums.h" 6 | #include "MultiPackerRuntimeBinPack.generated.h" 7 | 8 | class UMaterialInterface; 9 | class UMaxRectsBinPack; 10 | class UTextureRenderTarget2D; 11 | 12 | USTRUCT(BlueprintType) 13 | struct FMaterialDataBinPack 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | 19 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly) 20 | int32 Width; 21 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly) 22 | int32 Height; 23 | UPROPERTY(VisibleAnywhere, Transient) 24 | UTextureRenderTarget2D* RT_Material; 25 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly) 26 | UMaterialInterface* Material; 27 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly) 28 | int32 NumPage; 29 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly) 30 | FRectSizePadding MaterialRect; 31 | }; 32 | 33 | UCLASS(hidecategories = object) 34 | class MULTIPACKERRUNTIME_API UMultiPackerRuntimeBinPack : public UObject 35 | { 36 | GENERATED_BODY() 37 | 38 | public: 39 | UPROPERTY(Transient) 40 | TArray BinPackPages; 41 | 42 | UPROPERTY(VisibleAnywhere, Transient, Category = BinPack) 43 | TArray RenderTargetPages; 44 | 45 | UPROPERTY() 46 | UObject* WorldContext; 47 | 48 | UPROPERTY(Transient) 49 | int Size; 50 | 51 | UPROPERTY(Transient) 52 | bool Alpha; 53 | 54 | UPROPERTY(Transient) 55 | TMap MaterialMap; 56 | 57 | TArray NumPages; 58 | void Init(UObject* WorldContextObject, int InSize, bool InAlpha); 59 | void SetMaterial(UMaterialInterface* Material, int32 Width, int32 Height); 60 | FMaterialDataBinPack* GetMaterialData(FName Material); 61 | FMaterialDataBinPack AddMaterialToMap(UMaterialInterface* Material, int32 Width, int32 Height); 62 | int MakeNewPage(); 63 | TArray RuntimePreProcess(UObject* WorldContextObject, TMap InMaterialMap, int InPages, int InSize, bool InAlpha); 64 | UTextureRenderTarget2D* SetRTOnCanvas(UTextureRenderTarget2D* OutputTexture, UTextureRenderTarget2D* RT_Array_New, FRectSizePadding Rect, uint16 Width, uint16 Height); 65 | }; 66 | 67 | -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Public/Graph/MultiPackerMatNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "MultiPackerImageCore.h" 6 | #include "MultiPackerMatNode.generated.h" 7 | 8 | //class UMultiPackerOutputNodeBase; 9 | class UMultiPacker; 10 | class UMaterialInterface; 11 | class UTilePointer; 12 | 13 | UCLASS() 14 | class MULTIPACKERRUNTIME_API UMultiPackerMatNode : public UObject 15 | { 16 | GENERATED_BODY() 17 | 18 | public: 19 | UMultiPackerMatNode(); 20 | 21 | //Here you can select and change the Material or Material Instance 22 | UPROPERTY(EditDefaultsOnly, Category = "MaterialNode") 23 | UMaterialInterface* MaterialBaseInput; 24 | 25 | //This option is Individual for the node, the size of the Tile has a several impact on performance 26 | UPROPERTY(EditAnywhere, Category = "MaterialNode") 27 | bool SDF = false; 28 | 29 | UPROPERTY(EditAnywhere, Category = "MaterialNode", meta = (ClampMin = "1", ClampMax = "64", UIMin = "1", UIMax = "64", EditCondition = SDF)) 30 | int32 SDF_Radius = 64; 31 | 32 | //Materials can be splitted to get Individual Textures from there, this work for every numprint 33 | UPROPERTY(EditDefaultsOnly, Category = "MaterialNode|Tiled Options") 34 | bool Atlas = false; 35 | 36 | //Number of Vertical Tiles on the Material to divide them 37 | UPROPERTY(EditDefaultsOnly, Category = "MaterialNode|Tiled Options", meta = (ClampMin = "1", ClampMax = "50", UIMin = "1", UIMax = "50", EditCondition = Atlas)) 38 | int32 TilesVertical = 1; 39 | 40 | //Number of Horizontal Tiles on the Material to divide them 41 | UPROPERTY(EditDefaultsOnly, Category = "MaterialNode|Tiled Options", meta = (ClampMin = "1", ClampMax = "50", UIMin = "1", UIMax = "50", EditCondition = Atlas)) 42 | int32 TilesHorizontal = 1; 43 | 44 | //Materials can have a Size non squared 45 | UPROPERTY(VisibleAnywhere, Category = "MaterialNode|Non Square Size") 46 | bool RectangleSize = false; 47 | 48 | //Select to autoFill the Size of the Material 49 | UPROPERTY(EditDefaultsOnly, Category = "MaterialNode|Non Square Size", meta = (EditCondition = RectangleSize)) 50 | ETextureSizeOutputPersonal SetSizeByParameter = ETextureSizeOutputPersonal::EMCE_Option1; 51 | 52 | //Size Vertical of the Material 53 | UPROPERTY(EditDefaultsOnly, Category = "MaterialNode|Non Square Size", meta = (ClampMin = "1", ClampMax = "8096", UIMin = "1", UIMax = "8096", EditCondition = RectangleSize)) 54 | int32 SizeVertical = 32; 55 | 56 | //Size Horizontal of the Material 57 | UPROPERTY(EditDefaultsOnly, Category = "MaterialNode|Non Square Size", meta = (ClampMin = "1", ClampMax = "8096", UIMin = "1", UIMax = "8096", EditCondition = RectangleSize)) 58 | int32 SizeHorizontal = 32; 59 | 60 | //UMultiPackerOutputNodeBase* ParentNode; 61 | int32 NumTiles = 1; 62 | //from multipackerOutput error collector 63 | bool CompareSizes(int32 Vertical, int32 Horizontal); 64 | void SetErrorTiles(bool error); 65 | 66 | void ChangeBackground(bool error); 67 | bool CanProcess(); 68 | FLinearColor GetBackground() const; 69 | public: 70 | bool ErrorTiles = false; 71 | bool ErrorSize = false; 72 | bool bCanProcess = false; 73 | bool bDebug_MatNode = false; 74 | bool bMatAsset = false; 75 | bool DirtyMaterial = false; 76 | 77 | private: 78 | FLinearColor BackgroundColor; 79 | UMultiPacker* GetGraph() const; 80 | #if WITH_EDITOR 81 | void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent); 82 | #endif 83 | }; 84 | 85 | -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Public/Graph/MultiPackerTextureNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "MultiPackerImageCore.h" 6 | #include "MultiPackerTextureNode.generated.h" 7 | 8 | class UMultiPacker; 9 | class UTextureRenderTarget2D; 10 | class UTilePointer; 11 | class UTexture; 12 | class UTilePointer; 13 | 14 | UCLASS() 15 | class MULTIPACKERRUNTIME_API UMultiPackerTextureNode : public UObject 16 | { 17 | GENERATED_BODY() 18 | 19 | public: 20 | UMultiPackerTextureNode(); 21 | virtual ~UMultiPackerTextureNode(); 22 | TArray BaseTile; 23 | 24 | //Here you set the Texture to be processed by the Node Parameters 25 | UPROPERTY(EditAnywhere, Category = "TextureNode") 26 | UTexture* TextureInput; 27 | 28 | //This option is Individual for the node, the size of the Tile has a several impact on performance 29 | UPROPERTY(EditAnywhere, Category = "TextureNode") 30 | bool SDF = false; 31 | 32 | UPROPERTY(EditAnywhere, Category = "TextureNode", meta = (ClampMin = "1", ClampMax = "64", UIMin = "1", UIMax = "64", EditCondition = SDF)) 33 | int32 SDF_Radius = 64; 34 | 35 | //This option is Individual for the node and do some changes on the Texture to get a better result 36 | UPROPERTY(EditAnywhere, Category = "TextureNode") 37 | bool MSDF = false; 38 | 39 | //Number of Vertical Tiles on the Texture to divide them 40 | UPROPERTY(EditAnywhere, Category = "TextureNode|Tiled Options", meta = (ClampMin = "1", ClampMax = "50", UIMin = "1", UIMax = "50")) 41 | int32 TilesVertical = 1; 42 | 43 | //Number of Horizontal Tiles on the Texture to divide them 44 | UPROPERTY(EditAnywhere, Category = "TextureNode|Tiled Options", meta = (ClampMin = "1", ClampMax = "50", UIMin = "1", UIMax = "50")) 45 | int32 TilesHorizontal = 1; 46 | 47 | //Textures can have a Size non squared 48 | UPROPERTY(VisibleAnywhere, Category = "TextureNode|Non Square Size") 49 | bool RectangleSize = false; 50 | 51 | //Select to autoFill the Size of the Texture Input 52 | UPROPERTY(EditDefaultsOnly, Category = "TextureNode|Non Square Size", meta = (EditCondition = RectangleSize)) 53 | ESizeTexture AutoSizeFill; 54 | 55 | //Select to autoFill the Size of the Texture Input 56 | UPROPERTY(EditDefaultsOnly, Category = "TextureNode|Non Square Size", meta = (EditCondition = RectangleSize)) 57 | ETextureSizeOutputPersonal SetSizeByParameter = ETextureSizeOutputPersonal::EMCE_Option1; 58 | 59 | //Size Vertical of the Texture 60 | UPROPERTY(EditDefaultsOnly, Category = "TextureNode|Non Square Size", meta = (ClampMin = "1", ClampMax = "8096", UIMin = "1", UIMax = "8096", EditCondition = RectangleSize)) 61 | int32 SizeVertical = 32; 62 | 63 | //Size Horizontal of the Texture 64 | UPROPERTY(EditDefaultsOnly, Category = "TextureNode|Non Square Size", meta = (ClampMin = "1", ClampMax = "8096", UIMin = "1", UIMax = "8096", EditCondition = RectangleSize)) 65 | int32 SizeHorizontal = 32; 66 | 67 | //Select to autoFill the names of the DataBase 68 | UPROPERTY(EditAnywhere, Category = "TextureNode_TileDatabase") 69 | ENameTexture AutoNameFill; 70 | 71 | //Database with the information of every Tile 72 | UPROPERTY(EditAnywhere, EditFixedSize, Category = "TextureNode_TileDatabase") 73 | TArray ATexTileData; 74 | 75 | UPROPERTY(Transient) 76 | TArray Thumbnails; 77 | 78 | int32 numTiles = 1; 79 | void SetDataBaseTiles(TArray RT_Array); 80 | void SetDataBaseTiles(TArray TileThumbs); 81 | bool CompareSizes(int32 Vertical, int32 Horizontal); 82 | bool NodeCleanErrors() const; 83 | void SetErrorTiles(bool error); 84 | bool CanSetThumbnail() const; 85 | FString GetNodeTitle() const; 86 | FLinearColor GetBackground() const; 87 | void ChangeBackground(bool error); 88 | private: 89 | UMultiPacker* GetGraph() const; 90 | bool CanProcess() const; 91 | #if WITH_EDITOR 92 | void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent); 93 | #endif 94 | bool ErrorSize = false; 95 | bool ErrorTiles = false; 96 | FLinearColor BackgroundColor; 97 | }; 98 | -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Public/IMultiPackerRuntime.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "Modules/ModuleManager.h" 5 | 6 | #define MULTIPACKER_MODULE_NAME "MultiPackerRuntime" 7 | 8 | DECLARE_LOG_CATEGORY_EXTERN(MultiPackerRuntime, Log, All); 9 | 10 | /** 11 | * The public interface to this module 12 | */ 13 | class IMultiPackerRuntime : public IModuleInterface 14 | { 15 | 16 | public: 17 | 18 | /** 19 | * Singleton-like access to this module's interface. This is just for convenience! 20 | * Beware of calling this during the shutdown phase, though. Your module might have been unloaded already. 21 | * 22 | * @return Returns singleton instance, loading the module on demand if needed 23 | */ 24 | static IMultiPackerRuntime& Get() 25 | { 26 | return FModuleManager::LoadModuleChecked< IMultiPackerRuntime >("MultiPackerRuntime"); 27 | } 28 | 29 | /** 30 | * Checks to see if this module is loaded and ready. It is only valid to call Get() if IsAvailable() returns true. 31 | * 32 | * @return True if the module is loaded and ready to use 33 | */ 34 | static bool IsAvailable() 35 | { 36 | return FModuleManager::Get().IsModuleLoaded( "MultiPackerRuntime" ); 37 | } 38 | }; 39 | 40 | -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Public/MultiPackerDataBase.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | #include "CoreMinimal.h" 4 | #include "MultiPackerBaseEnums.h" 5 | #include "MultiPackerDataBase.generated.h" 6 | 7 | class UTextureRenderTarget2D; 8 | class UMaterialInstanceDynamic; 9 | class UMaterialParameterCollection; 10 | class UTexture; 11 | 12 | UCLASS() 13 | class MULTIPACKERRUNTIME_API UMultiPackerDataBase : public UObject 14 | { 15 | GENERATED_UCLASS_BODY() 16 | public: 17 | /** Structure to use for each row of the table, must inherit from FTableRowBase */ 18 | UPROPERTY() 19 | UScriptStruct* RowStruct; 20 | UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "OutputData") 21 | int32 VTile; 22 | UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "OutputData") 23 | int32 HTile; 24 | UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "OutputData") 25 | bool Do_SDF = false; 26 | UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "OutputData") 27 | bool BinPack = false; 28 | UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "OutputData") 29 | bool Alpha = false; 30 | UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "OutputData") 31 | EChannelTextureSave ChannelMethod; 32 | UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "OutputData") 33 | TArray TextureOutput; 34 | UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "OutputData") 35 | UMaterialParameterCollection* MaterialCollection; 36 | 37 | //Extremelly caution modifing this manually, can broke refences 38 | UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "OutputData") 39 | TMap TileMap; 40 | UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "OutputData") 41 | int32 TileSize; 42 | UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "OutputData") 43 | FLinearColor layer_bools; 44 | UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "OutputData") 45 | FLinearColor Tiles_Size = FLinearColor(1,1,1,1); 46 | UFUNCTION(BlueprintCallable, Category = MultiPackerDataBase, meta = (UnsafeDuringActorConstruction = "true")) 47 | UMaterialInstanceDynamic* GetMaterialTile(const FName Key); 48 | UFUNCTION(BlueprintCallable, Category = MultiPackerDataBase, meta = (WorldContext = "WorldContextObject", UnsafeDuringActorConstruction = "true")) 49 | UMaterialInstanceDynamic* GetButtonMaterialState(UObject* WorldContextObject, const FName KeyIcon, const FName KeyBase, const FName KeySelected, int32 size, FLinearColor Color_Base, FLinearColor Color_Icon_Normal, FLinearColor Color_Icon_Press, FLinearColor Color_Ic_Selected, EStateButton EState, bool selected); 50 | UFUNCTION(BlueprintCallable, Category = MultiPackerDataBase, meta = (WorldContext = "WorldContextObject", UnsafeDuringActorConstruction = "true")) 51 | UTextureRenderTarget2D* GetTextureTile(UObject* WorldContextObject, const FName Key, int size); 52 | UFUNCTION(BlueprintCallable, Category = MultiPackerDataBase, meta = (WorldContext = "WorldContextObject", UnsafeDuringActorConstruction = "true")) 53 | FButtonStyle GetButtonStyle(UObject* WorldContextObject, const FName KeyIcon, const FName KeyBase, const FName KeySelected, int32 size, FLinearColor Color_Base, FLinearColor Color_Icon_Normal, FLinearColor Color_Icon_Press, FLinearColor Color_Ic_Selected, bool selected); 54 | 55 | }; -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Public/MultiPackerImageCore.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | #include "CoreMinimal.h" 4 | #include "MultiPackerBaseEnums.h" 5 | #include 6 | #include "MultiPackerImageCore.generated.h" 7 | 8 | class UMultiPacker; 9 | class UMultiPackerDataBase; 10 | class UMaterialInstanceDynamic; 11 | class UMultiPackerLayerDatabase; 12 | struct FLayerDatabase; 13 | 14 | USTRUCT(BlueprintType) 15 | struct FChannelDatabase 16 | { 17 | GENERATED_USTRUCT_BODY() 18 | public: 19 | UPROPERTY(EditAnywhere) 20 | UMultiPackerDataBase* Database; 21 | 22 | UPROPERTY(EditAnywhere, BlueprintReadWrite) 23 | FName Name; 24 | }; 25 | 26 | USTRUCT(BlueprintType) 27 | struct FLayerDatabase 28 | { 29 | GENERATED_USTRUCT_BODY() 30 | 31 | public: 32 | 33 | UPROPERTY(EditAnywhere) 34 | FChannelDatabase Color; 35 | 36 | UPROPERTY(EditAnywhere) 37 | FChannelDatabase Alpha; 38 | 39 | UPROPERTY(AdvancedDisplay, VisibleInstanceOnly) 40 | bool SDF = false; 41 | 42 | UPROPERTY() 43 | bool MSDF = false; 44 | 45 | UPROPERTY() 46 | bool Multiple = false; 47 | 48 | UPROPERTY() 49 | bool SDF_Interior = false; 50 | 51 | UPROPERTY() 52 | bool SDF_Alpha = false; 53 | 54 | UPROPERTY() 55 | bool CanProcess_Interior = false; 56 | 57 | UPROPERTY() 58 | bool CanProcess_Alpha = false; 59 | 60 | UPROPERTY(EditAnywhere, BlueprintReadWrite) 61 | bool UseColor = false; 62 | 63 | UPROPERTY(BlueprintReadWrite, EditAnywhere) 64 | bool Outline = false; 65 | 66 | UPROPERTY(BlueprintReadWrite) 67 | FLinearColor ColorOutline; 68 | 69 | UPROPERTY(BlueprintReadWrite) 70 | FLinearColor ColorInterior; 71 | 72 | UPROPERTY(EditAnywhere) 73 | float EdgeSoftness = 0.0f; 74 | 75 | UPROPERTY(BlueprintReadWrite) 76 | float OutlineThresold = 0.5f; 77 | 78 | UPROPERTY(BlueprintReadWrite) 79 | float SDFThresold = 0.5f; 80 | 81 | //initialize the vars , dont work properly 82 | void SetData(FLayerDatabase InStruct) 83 | { 84 | Color.Database = InStruct.Color.Database; 85 | Color.Name = InStruct.Color.Name; 86 | Alpha.Database = InStruct.Alpha.Database; 87 | Alpha.Name = InStruct.Alpha.Name; 88 | UseColor = InStruct.UseColor; 89 | Outline = InStruct.Outline; 90 | ColorOutline = InStruct.ColorOutline; 91 | ColorInterior = InStruct.ColorInterior; 92 | EdgeSoftness = InStruct.EdgeSoftness; 93 | OutlineThresold = InStruct.OutlineThresold; 94 | SDFThresold = InStruct.SDFThresold; 95 | } 96 | }; 97 | 98 | UCLASS() 99 | class MULTIPACKERRUNTIME_API UMultiPackerImageCore : public UObject 100 | { 101 | GENERATED_BODY() 102 | public: 103 | static UMaterialInstanceDynamic* CreateMaterial(EMultiPackerImageLayer Layer, UObject *InOuter, FLayerDatabase LayerBase, FLayerDatabase LayerAddition, FLayerDatabase LayerDetail); 104 | static FLayerDatabase ProcessChanges(FLayerDatabase Layer); 105 | static FLayerDatabase ProcessStyle(FLayerDatabase InLayer, UMultiPackerLayerDatabase* InStyle); 106 | static UMaterialInstanceDynamic* SetDataBaseLayer(UMaterialInstanceDynamic* MB_Function, FLayerDatabase LayerBase, FString SuFix); 107 | private: 108 | static UMaterialInstanceDynamic* LayerMaterialInstance(UMaterialInstanceDynamic* MB_Function, FLayerDatabase LayerInfo, FTileDatabase layer_interior, FTileDatabase layer_alpha, FString SuFix); 109 | }; 110 | -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Public/MultiPackerLayerDatabase.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | #include "CoreMinimal.h" 4 | #include "MultiPackerImageCore.h" 5 | #include "TileUtils/TileCopy.h" 6 | #include "MultiPackerLayerDatabase.generated.h" 7 | 8 | class UMaterialInstanceDynamic; 9 | 10 | UCLASS() 11 | class MULTIPACKERRUNTIME_API UMultiPackerLayerDatabase : public UObject 12 | { 13 | GENERATED_UCLASS_BODY() 14 | public: 15 | UPROPERTY(EditAnywhere, Category = "Appearance") 16 | FLayerDatabase LayerBase = FLayerDatabase(); 17 | 18 | UPROPERTY(EditAnywhere, Category = "Appearance") 19 | FLinearColor ColorOutline; 20 | 21 | UPROPERTY(EditAnywhere, Category = "Appearance") 22 | FLinearColor ColorInterior; 23 | 24 | UPROPERTY(EditAnywhere, Category = "Appearance") 25 | float OutlineThresold = 0.5; 26 | 27 | UPROPERTY(EditAnywhere, Category = "Appearance") 28 | float SDFThresold = 0.5; 29 | 30 | UPROPERTY(EditAnywhere, Category = "GetNodesToClipboard") 31 | UTileCopy* Button; 32 | 33 | UPROPERTY() 34 | UMaterialInstanceDynamic* Material; 35 | }; 36 | -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Public/MultiPackerRuntimeGraph.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "MultiPackerBaseEnums.h" 6 | #include "BinPack/MultiPackerRuntimeBinPack.h" 7 | #include "MultiPackerRuntimeGraph.generated.h" 8 | 9 | // Forward Declarations 10 | class UMultiPackerRuntimeMatNode; 11 | class UMultiPackerDataBase; 12 | class UTextureRenderTarget2D; 13 | class UMaterialInstanceDynamic; 14 | 15 | UCLASS(BlueprintType) 16 | class MULTIPACKERRUNTIME_API UMultiPackerRuntimeGraph : public UObject 17 | { 18 | GENERATED_BODY() 19 | 20 | public: 21 | UMultiPackerRuntimeGraph(); 22 | ~UMultiPackerRuntimeGraph(); 23 | 24 | //Output Size of the RenderTarget 25 | UPROPERTY(EditAnywhere, Category = "OutputConfig") 26 | ETextureSizeOutputPersonal RenderTargetSizeOutput; 27 | 28 | //Select this if you want to have the Alpha channel active on Texture Output 29 | UPROPERTY(EditAnywhere, Category = "OutputConfig") 30 | bool Alpha = false; 31 | 32 | UPROPERTY(VisibleAnywhere, instanced, Category = BinPack) 33 | UMultiPackerRuntimeBinPack* RuntimeData; 34 | 35 | UPROPERTY(VisibleAnywhere, Category = BinPack) 36 | int Size; 37 | 38 | UPROPERTY(VisibleAnywhere, Category = BinPack) 39 | int Pages; 40 | 41 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = BinPack) 42 | TMap MaterialMap; 43 | 44 | UPROPERTY(BlueprintReadOnly, Category = BinPack) 45 | TArray RenderTargetPages; 46 | 47 | TArray MatNodes; 48 | TSubclassOf MatNodeType; 49 | 50 | UFUNCTION(BlueprintCallable, Category = BinPack, meta = (WorldContext = "WorldContextObject", UnsafeDuringActorConstruction = "true")) 51 | void RuntimePreProcess(UObject* WorldContextObject); 52 | UFUNCTION(BlueprintCallable, Category = BinPack, meta = ( WorldContext = "WorldContextObject", UnsafeDuringActorConstruction = "true")) 53 | void RetrieveMaterialInfo(UObject* WorldContextObject, UMaterialInterface* Material, /*out*/ UTextureRenderTarget2D*& RT_Output, /*out*/ FMaterialDataBinPack& Database); 54 | UFUNCTION(BlueprintCallable, Category = BinPack, meta = (WorldContext = "WorldContextObject", UnsafeDuringActorConstruction = "true")) 55 | void SetTextureRuntimeOnMaterial(UObject* WorldContextObject, UMaterialInterface* Material, UMaterialInstanceDynamic* MaterialToSet, FName Texture, FName Booleans, FName SizePadding); 56 | UFUNCTION(BlueprintCallable, Category = BinPack, meta = (WorldContext = "WorldContextObject", UnsafeDuringActorConstruction = "true")) 57 | UTexture2D* GetTileTexture(UObject* WorldContextObject, UMaterialInterface* MaterialToGet); 58 | UFUNCTION(BlueprintCallable, Category = BinPack, meta = (WorldContext = "WorldContextObject", UnsafeDuringActorConstruction = "true")) 59 | void ValidationOnRuntime(UObject* WorldContextObject); 60 | 61 | #if WITH_EDITORONLY_DATA 62 | UPROPERTY() 63 | class UEdGraph* EdGraph; 64 | #endif 65 | void ClearGraph(); 66 | 67 | void ProcessNodes(UObject* WorldContextObject); 68 | private: 69 | #if WITH_EDITOR 70 | void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent); 71 | #endif 72 | }; -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Public/MultiPackerRuntimeMatNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "MultiPackerBaseEnums.h" 6 | #include "MultiPackerRuntimeMatNode.generated.h" 7 | 8 | 9 | class UMultiPackerRuntimeGraph; 10 | class UMultiPackerRuntimeOutputNodeBase; 11 | class UTextureRenderTarget2D; 12 | class UMaterialInterface; 13 | class UMaterialInstanceDynamic; 14 | 15 | UCLASS() 16 | class MULTIPACKERRUNTIME_API UMultiPackerRuntimeMatNode : public UObject 17 | { 18 | GENERATED_BODY() 19 | 20 | public: 21 | UMultiPackerRuntimeMatNode(); 22 | virtual ~UMultiPackerRuntimeMatNode(); 23 | 24 | //Here you can select and change the Material or Material Instance 25 | UPROPERTY(EditDefaultsOnly, Category = "MaterialNode") 26 | UMaterialInterface* MaterialBaseInput; 27 | 28 | //Size Vertical of the Material 29 | UPROPERTY(EditDefaultsOnly, Category = "MaterialNode", meta = (ClampMin = "1", ClampMax = "8096", UIMin = "1", UIMax = "8096")) 30 | int32 Height = 1; 31 | 32 | //Size Horizontal of the Material 33 | UPROPERTY(EditDefaultsOnly, Category = "MaterialNode", meta = (ClampMin = "1", ClampMax = "8096", UIMin = "1", UIMax = "8096")) 34 | int32 Width = 1; 35 | 36 | //Size Vertical and Horizontal of the Material 37 | UPROPERTY(EditDefaultsOnly, Category = "MaterialNode") 38 | ETextureSizeOutputPersonal MaterialSize; 39 | 40 | UMultiPackerRuntimeOutputNodeBase* ParentNode; 41 | 42 | void ChangeBackground(bool error); 43 | FLinearColor GetBackground() const; 44 | private: 45 | FLinearColor BackgroundColor; 46 | UMultiPackerRuntimeGraph* GetGraph() const; 47 | #if WITH_EDITOR 48 | void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent); 49 | #endif 50 | }; 51 | 52 | -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Public/MultiPackerSettings.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "Engine/DeveloperSettings.h" 5 | #include "MultiPackerBaseEnums.h" 6 | #include "MultiPackerSettings.generated.h" 7 | 8 | 9 | /** 10 | * Default Settings for MultiPacker Graph 11 | * The Settings selected to be here are the most important and global for every Asset 12 | */ 13 | UCLASS(config=Game, defaultconfig) 14 | class MULTIPACKERRUNTIME_API UMultiPackerSettings : public UDeveloperSettings 15 | { 16 | GENERATED_BODY() 17 | 18 | public: 19 | 20 | UMultiPackerSettings() 21 | { 22 | ChannelMethod = EChannelTextureSave::CS_Atlas; 23 | SaveMaterialCollection = true; 24 | SaveDatabase = true; 25 | TargetDirectory.Path = "Textures/"; 26 | DatabasePrefix = "MPDB_"; 27 | TexturePrefix = "T_"; 28 | MaterialcollectionPrefix = "MC_"; 29 | TextureChannelName = "MultiPacker_CP"; 30 | } 31 | 32 | FORCEINLINE EChannelTextureSave GetChannelMethod() const 33 | { 34 | return ChannelMethod; 35 | } 36 | 37 | FORCEINLINE bool GetSaveMaterialCollection() const 38 | { 39 | return SaveMaterialCollection; 40 | } 41 | 42 | FORCEINLINE bool GetSaveDatabase() const 43 | { 44 | return SaveDatabase; 45 | } 46 | 47 | FORCEINLINE FDirectoryPath GetTargetDirectory() const 48 | { 49 | return TargetDirectory; 50 | } 51 | 52 | FORCEINLINE FString GetDatabasePrefix() const 53 | { 54 | return DatabasePrefix; 55 | } 56 | 57 | FORCEINLINE FString GetTexturePrefix() const 58 | { 59 | return TexturePrefix; 60 | } 61 | 62 | FORCEINLINE FString GetMaterialcollectionPrefix() const 63 | { 64 | return MaterialcollectionPrefix; 65 | } 66 | 67 | FORCEINLINE FString GetTextureChannelName() const 68 | { 69 | return TextureChannelName; 70 | } 71 | private: 72 | //Select between multiples modes for save the texture on channel; 73 | //Multiple saves 3 Textures by Channel 74 | //One save 1 Texture on Channel 75 | //Atlas save 1 Texture on RGB/A Channels 76 | //One_SDF save 1 Texture SDF on Channel , This is the Global option who process all the nodes to SDF, for a granular selection you have the Boolean selection on the nodes 77 | UPROPERTY(config, EditAnywhere, Category = "ChannelsOptions") 78 | EChannelTextureSave ChannelMethod = EChannelTextureSave::CS_Atlas; 79 | 80 | //Make and save the Material Collection 81 | UPROPERTY(config, EditAnywhere, Category = "SaveData") 82 | bool SaveMaterialCollection = true; 83 | 84 | //Make and save the Material Collection 85 | UPROPERTY(config, EditAnywhere, Category = "SaveData") 86 | bool SaveDatabase = true; 87 | 88 | //Directory to save the Output Texture 89 | UPROPERTY(config, EditAnywhere, Category = "Location", meta = (RelativeToGameContentDir)) 90 | FDirectoryPath TargetDirectory; 91 | 92 | UPROPERTY(EditAnywhere, Category = "Output") 93 | FString TextureChannelName = "MultiPacker_CP"; 94 | 95 | //Prefix for the MultiPacker Database to use with blueprints 96 | UPROPERTY(config, EditAnywhere, Category = "Prefix") 97 | FString DatabasePrefix = "MPDB_"; 98 | 99 | //Prefix for the Output Textures 100 | UPROPERTY(config, EditAnywhere, Category = "Prefix") 101 | FString TexturePrefix = "T_"; 102 | 103 | //Prefix for the Material Collection 104 | UPROPERTY(config, EditAnywhere, Category = "Prefix") 105 | FString MaterialcollectionPrefix = "MC_"; 106 | 107 | 108 | }; -------------------------------------------------------------------------------- /Source/MultiPackerRuntime/Public/TileUtils/TileCopy.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | #include "CoreMinimal.h" 4 | #include "TileCopy.generated.h" 5 | 6 | 7 | /* 8 | / This Object only exist to have an detail customization with a Button and copy to the clipboard the material nodes 9 | */ 10 | UCLASS() 11 | class UTileCopy: public UObject 12 | { 13 | GENERATED_UCLASS_BODY() 14 | }; 15 | -------------------------------------------------------------------------------- /Source/MultiPackerTab/MultiPackerTab.Build.cs: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | 3 | namespace UnrealBuildTool.Rules 4 | { 5 | public class MultiPackerTab : ModuleRules 6 | { 7 | public MultiPackerTab (ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | bEnforceIWYU = true; 10 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 11 | 12 | PrivateIncludePaths.Add("MultiPackerTab/Private"); 13 | PublicDependencyModuleNames.AddRange( 14 | new string[] 15 | { 16 | "Core", 17 | "EditorWidgets", 18 | "AssetTools", 19 | "MultiPackerRuntime", 20 | } 21 | ); 22 | 23 | PrivateDependencyModuleNames.AddRange( 24 | new string[] 25 | { 26 | "Projects", 27 | "InputCore", 28 | "UnrealEd", 29 | "LevelEditor", 30 | "CoreUObject", 31 | "Engine", 32 | "Slate", 33 | "SlateCore", 34 | "EditorStyle", 35 | "RenderCore", 36 | } 37 | ); 38 | 39 | } 40 | 41 | } 42 | } -------------------------------------------------------------------------------- /Source/MultiPackerTab/Private/MultiPackerChannelTab.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 @TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | #include "MultiPackerBaseEnums.h" 4 | #include "MultiPackerDetailPanel.h" 5 | #include "MultiPackerChannelTab.generated.h" 6 | 7 | class SMPTextureWidget; 8 | class IDetailsView; 9 | class FSpawnTabArgs; 10 | class FAssetToolsModule; 11 | class UTilePointer; 12 | 13 | UCLASS() 14 | class UMultiPackerChannelTab : public UObject 15 | { 16 | GENERATED_BODY() 17 | public: 18 | void InitializeTab(); 19 | 20 | TSharedRef OnSpawnPluginTab(const class FSpawnTabArgs& SpawnTabArgs); 21 | 22 | UPROPERTY() 23 | UMultiPackerDetailPanel* PropertyMPChannel; 24 | 25 | private: 26 | TSharedPtr PropertyWidget; 27 | 28 | TSharedPtr PreviewTextureViewport; 29 | 30 | FReply OnClickButton(); 31 | 32 | EChannelSelectionInput GetChannelEnum(EMPChannelMaskParameterColor InEnum); 33 | UTilePointer* ProcessTextureChannel(UTexture2D* InTexture, const int32 InSizeVertical, const int32 InSizeHorizontal, EMPChannelMaskParameterColor InChannel); 34 | TArray TexturePackageName(FAssetToolsModule& AssetToolsModule); 35 | }; 36 | -------------------------------------------------------------------------------- /Source/MultiPackerTab/Private/MultiPackerCommands.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 @TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | 3 | #include "MultiPackerCommands.h" 4 | 5 | #define LOCTEXT_NAMESPACE "FMultiPackerCommands" 6 | 7 | void FMultiPackerCommands::RegisterCommands() 8 | { 9 | UI_COMMAND(OpenPluginWindow, "MultiPacker", "Bring up MultiPacker Channel Pack Tab", EUserInterfaceActionType::Button, FInputGesture()); 10 | } 11 | 12 | #undef LOCTEXT_NAMESPACE 13 | -------------------------------------------------------------------------------- /Source/MultiPackerTab/Private/MultiPackerCommands.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 @TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | #include "Framework/Commands/Commands.h" 4 | #include "MultiPackerTabStyle.h" 5 | 6 | #define LOCTEXT_NAMESPACE "FMultiPackerCommands" 7 | 8 | class FMultiPackerCommands : public TCommands 9 | { 10 | public: 11 | 12 | FMultiPackerCommands() 13 | : TCommands(TEXT("MultiPacker"), NSLOCTEXT("Compile", "MultiPacker", "MultiPacker Plugin"), NAME_None, FMultiPackerTabStyle::GetStyleSetName()) 14 | { 15 | } 16 | 17 | // TCommands<> interface 18 | virtual void RegisterCommands() override; 19 | 20 | public: 21 | TSharedPtr< FUICommandInfo > OpenPluginWindow; 22 | }; -------------------------------------------------------------------------------- /Source/MultiPackerTab/Private/MultiPackerDetailPanel.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 @TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | #include 4 | #include "MultiPackerBaseEnums.h" 5 | #include "MultiPackerDetailPanel.generated.h" 6 | 7 | UENUM(BlueprintType) 8 | enum class EMPChannelMaskParameterColor : uint8 9 | { 10 | Red, 11 | Green, 12 | Blue, 13 | Alpha, 14 | }; 15 | 16 | UCLASS(NonTransient) 17 | class UMultiPackerDetailPanel : public UObject 18 | { 19 | GENERATED_BODY() 20 | public: 21 | UPROPERTY(EditAnywhere, Category = "Input") 22 | UTexture2D* TextureRed; 23 | UPROPERTY(EditAnywhere, Category = "Input") 24 | EMPChannelMaskParameterColor MaskTextureRed; 25 | 26 | UPROPERTY(EditAnywhere, Category = "Input") 27 | UTexture2D* TextureGreen; 28 | UPROPERTY(EditAnywhere, Category = "Input") 29 | EMPChannelMaskParameterColor MaskTextureGreen; 30 | 31 | UPROPERTY(EditAnywhere, Category = "Input") 32 | UTexture2D* TextureBlue; 33 | UPROPERTY(EditAnywhere, Category = "Input") 34 | EMPChannelMaskParameterColor MaskTextureBlue; 35 | 36 | UPROPERTY(EditAnywhere, Category = "Input") 37 | bool AlphaChannel; 38 | UPROPERTY(EditAnywhere, Category = "Input", meta = (EditCondition = AlphaChannel)) 39 | UTexture2D* TextureAlpha; 40 | UPROPERTY(EditAnywhere, Category = "Input", meta = (EditCondition = AlphaChannel)) 41 | EMPChannelMaskParameterColor MaskTextureAlpha; 42 | 43 | UPROPERTY(EditAnywhere, Category = "Output", meta = (RelativeToGameContentDir)) 44 | FDirectoryPath TargetDirectory; 45 | UPROPERTY(EditAnywhere, Category = "Output") 46 | FString TextureName = "MultiPacker_CP"; 47 | UPROPERTY(EditAnywhere, Category = "Output") 48 | UTexture2D* Texture; 49 | 50 | UPROPERTY(EditAnywhere, Category = "Output") 51 | ETextureSizeOutputPersonal SizeVertical = ETextureSizeOutputPersonal::EMCE_Option5; 52 | UPROPERTY(EditAnywhere, Category = "Output") 53 | ETextureSizeOutputPersonal SizeHorizontal = ETextureSizeOutputPersonal::EMCE_Option5; 54 | }; 55 | 56 | 57 | -------------------------------------------------------------------------------- /Source/MultiPackerTab/Private/MultiPackerTab.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 @TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "MultiPackerTab.h" 3 | #include "MultiPackerChannelTab.h" 4 | #include "MultiPackerTabStyle.h" 5 | #include "MultiPackerCommands.h" 6 | 7 | #include "LevelEditor.h" 8 | 9 | #include "Widgets/SMPTextureWidget.h" 10 | #include 11 | #include 12 | 13 | static const FName MultiPackerTabName("MultiPacker"); 14 | 15 | const FName ViewportTabId(TEXT("MultiPackerTab_Viewport")); 16 | #define LOCTEXT_NAMESPACE "MultiPackerTab" 17 | 18 | void FMultiPackerTab::StartupModule() 19 | { 20 | // register menu extensions 21 | MenuExtensibilityManager = MakeShareable(new FExtensibilityManager); 22 | ToolBarExtensibilityManager = MakeShareable(new FExtensibilityManager); 23 | PluginCommands = MakeShareable(new FUICommandList); 24 | 25 | // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module 26 | 27 | FMultiPackerTabStyle::Initialize(); 28 | FMultiPackerTabStyle::ReloadTextures(); 29 | FMultiPackerCommands::Register(); 30 | 31 | PluginCommands->MapAction( 32 | FMultiPackerCommands::Get().OpenPluginWindow, 33 | FExecuteAction::CreateRaw(this, &FMultiPackerTab::PluginButtonClicked), 34 | FCanExecuteAction()); 35 | 36 | FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked("LevelEditor"); 37 | 38 | { 39 | TSharedPtr MenuExtender = MakeShareable(new FExtender()); 40 | MenuExtender->AddMenuExtension("WindowLayout", EExtensionHook::After, PluginCommands, FMenuExtensionDelegate::CreateRaw(this, &FMultiPackerTab::AddMenuExtension)); 41 | 42 | LevelEditorModule.GetMenuExtensibilityManager()->AddExtender(MenuExtender); 43 | } 44 | 45 | { 46 | TSharedPtr ToolbarExtender = MakeShareable(new FExtender); 47 | ToolbarExtender->AddToolBarExtension("Compile", EExtensionHook::After, PluginCommands, FToolBarExtensionDelegate::CreateRaw(this, &FMultiPackerTab::AddToolbarExtension)); 48 | 49 | LevelEditorModule.GetToolBarExtensibilityManager()->AddExtender(ToolbarExtender); 50 | } 51 | 52 | FGlobalTabmanager::Get()->RegisterNomadTabSpawner(MultiPackerTabName, FOnSpawnTab::CreateRaw(this, &FMultiPackerTab::OnSpawnPluginTab)) 53 | .SetDisplayName(LOCTEXT("FMultiPackerTabTitle", "MultiPackerTab")) 54 | .SetMenuType(ETabSpawnerMenuType::Hidden); 55 | 56 | } 57 | 58 | void FMultiPackerTab::ShutdownModule() 59 | { 60 | // unregister menu extensions 61 | MenuExtensibilityManager.Reset(); 62 | ToolBarExtensibilityManager.Reset(); 63 | 64 | // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, 65 | // we call this function before unloading the module. 66 | FMultiPackerTabStyle::Shutdown(); 67 | FMultiPackerCommands::Unregister(); 68 | FGlobalTabmanager::Get()->UnregisterNomadTabSpawner(MultiPackerTabName); 69 | } 70 | 71 | void FMultiPackerTab::PluginButtonClicked() 72 | { 73 | TabSpawn = NewObject(UMultiPackerChannelTab::StaticClass()); 74 | TabSpawn->InitializeTab(); 75 | FGlobalTabmanager::Get()->InvokeTab(MultiPackerTabName); 76 | } 77 | 78 | void FMultiPackerTab::AddMenuExtension(FMenuBuilder& Builder) 79 | { 80 | Builder.AddMenuEntry(FMultiPackerCommands::Get().OpenPluginWindow); 81 | } 82 | 83 | TSharedRef FMultiPackerTab::OnSpawnPluginTab(const class FSpawnTabArgs& SpawnTabArgs) 84 | { 85 | return TabSpawn->OnSpawnPluginTab(SpawnTabArgs); 86 | } 87 | 88 | void FMultiPackerTab::AddToolbarExtension(FToolBarBuilder& Builder) 89 | { 90 | Builder.AddToolBarButton(FMultiPackerCommands::Get().OpenPluginWindow); 91 | } 92 | 93 | #undef LOCTEXT_NAMESPACE 94 | 95 | IMPLEMENT_MODULE(FMultiPackerTab, MultiPackerTab) -------------------------------------------------------------------------------- /Source/MultiPackerTab/Private/MultiPackerTabStyle.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 @TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #include "MultiPackerTabStyle.h" 3 | #include "Styling/SlateStyleRegistry.h" 4 | #include "Framework/Application/SlateApplication.h" 5 | #include "Slate/SlateGameResources.h" 6 | #include "Interfaces/IPluginManager.h" 7 | 8 | TSharedPtr< FSlateStyleSet > FMultiPackerTabStyle::StyleInstance = NULL; 9 | 10 | void FMultiPackerTabStyle::Initialize() 11 | { 12 | if (!StyleInstance.IsValid()) 13 | { 14 | StyleInstance = Create(); 15 | FSlateStyleRegistry::RegisterSlateStyle(*StyleInstance); 16 | } 17 | } 18 | 19 | void FMultiPackerTabStyle::Shutdown() 20 | { 21 | FSlateStyleRegistry::UnRegisterSlateStyle(*StyleInstance); 22 | ensure(StyleInstance.IsUnique()); 23 | StyleInstance.Reset(); 24 | } 25 | 26 | FName FMultiPackerTabStyle::GetStyleSetName() 27 | { 28 | static FName StyleSetName(TEXT("MultiPacker")); 29 | return StyleSetName; 30 | } 31 | 32 | #define IMAGE_BRUSH( RelativePath, ... ) FSlateImageBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ ) 33 | 34 | const FVector2D Icon20x20(20.0f, 20.0f); 35 | const FVector2D Icon40x40(40.0f, 40.0f); 36 | 37 | TSharedRef< FSlateStyleSet > FMultiPackerTabStyle::Create() 38 | { 39 | TSharedRef< FSlateStyleSet > Style = MakeShareable(new FSlateStyleSet("MultiPacker")); 40 | Style->SetContentRoot(IPluginManager::Get().FindPlugin("MultiPacker")->GetBaseDir() / TEXT("Resources")); 41 | 42 | Style->Set("MultiPacker.OpenPluginWindow", new IMAGE_BRUSH(TEXT("ButtonIcon_40x"), Icon40x40)); 43 | Style->Set("MultiPacker.OpenPluginWindow.Small", new IMAGE_BRUSH(TEXT("ButtonIcon_40x"), Icon20x20)); 44 | 45 | return Style; 46 | } 47 | 48 | #undef IMAGE_BRUSH 49 | 50 | void FMultiPackerTabStyle::ReloadTextures() 51 | { 52 | if (FSlateApplication::IsInitialized()) 53 | { 54 | FSlateApplication::Get().GetRenderer()->ReloadTextureResources(); 55 | } 56 | } 57 | 58 | const ISlateStyle& FMultiPackerTabStyle::Get() 59 | { 60 | return *StyleInstance; 61 | } 62 | -------------------------------------------------------------------------------- /Source/MultiPackerTab/Private/MultiPackerTabStyle.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 @TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "Styling/SlateStyle.h" 6 | 7 | /** */ 8 | class FMultiPackerTabStyle 9 | { 10 | public: 11 | 12 | static void Initialize(); 13 | 14 | static void Shutdown(); 15 | 16 | /** reloads textures used by slate renderer */ 17 | static void ReloadTextures(); 18 | 19 | /** @return The Slate style set for the Shooter game */ 20 | static const ISlateStyle& Get(); 21 | 22 | static FName GetStyleSetName(); 23 | 24 | private: 25 | 26 | static TSharedRef< class FSlateStyleSet > Create(); 27 | 28 | private: 29 | 30 | static TSharedPtr< class FSlateStyleSet > StyleInstance; 31 | }; -------------------------------------------------------------------------------- /Source/MultiPackerTab/Private/Widgets/SMPTexturePreviewZoomer.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 @TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | 3 | #include "Widgets/SMPTexturePreviewZoomer.h" 4 | #include "Widgets/SMPTextureWidget.h" 5 | #include "Widgets/Images/SImage.h" 6 | #include "Templates/SharedPointer.h" 7 | #include "EditorStyleSet.h" 8 | #include 9 | #include 10 | 11 | #define LOCTEXT_NAMESPACE "SMPTexturePreviewZoomer" 12 | 13 | void SMPTexturePreviewZoomer::Construct(const FArguments& InArgs, UTexture2D* InPreviewTexture) 14 | { 15 | //Tint = FLinearColor(1, 1, 1, 1); 16 | PreviewBrush = MakeShareable(new FSlateImageBrush(InPreviewTexture, FVector2D(250, 250))); 17 | 18 | ChildSlot 19 | [ 20 | SAssignNew(ImageWidget, SImage) 21 | .Image(PreviewBrush.Get()) 22 | ]; 23 | 24 | ZoomLevel = 1.0f; 25 | } 26 | 27 | void SMPTexturePreviewZoomer::OnArrangeChildren(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const 28 | { 29 | CachedSize = AllottedGeometry.GetLocalSize(); 30 | 31 | const TSharedRef& ChildWidget = ChildSlot.GetWidget(); 32 | if (ChildWidget->GetVisibility() != EVisibility::Collapsed) 33 | { 34 | const FVector2D& WidgetDesiredSize = ChildWidget->GetDesiredSize(); 35 | 36 | ArrangedChildren.AddWidget(AllottedGeometry.MakeChild(ChildWidget, FVector2D::ZeroVector, WidgetDesiredSize * ZoomLevel)); 37 | } 38 | } 39 | 40 | FVector2D SMPTexturePreviewZoomer::ComputeDesiredSize(float) const 41 | { 42 | FVector2D ThisDesiredSize = FVector2D::ZeroVector; 43 | 44 | const TSharedRef& ChildWidget = ChildSlot.GetWidget(); 45 | if (ChildWidget->GetVisibility() != EVisibility::Collapsed) 46 | { 47 | ThisDesiredSize = ChildWidget->GetDesiredSize() * ZoomLevel; 48 | } 49 | 50 | return ThisDesiredSize; 51 | } 52 | 53 | FChildren* SMPTexturePreviewZoomer::GetChildren() 54 | { 55 | return &ChildSlot; 56 | } 57 | 58 | FReply SMPTexturePreviewZoomer::OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) 59 | { 60 | ZoomBy(MouseEvent.GetWheelDelta()); 61 | 62 | return FReply::Handled(); 63 | } 64 | 65 | int32 SMPTexturePreviewZoomer::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const 66 | { 67 | LayerId = SPanel::OnPaint(Args, AllottedGeometry, MyClippingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled); 68 | return LayerId; 69 | } 70 | 71 | bool SMPTexturePreviewZoomer::ZoomBy(const float Amount) 72 | { 73 | static const float MinZoomLevel = 0.2f; 74 | static const float MaxZoomLevel = 4.0f; 75 | 76 | const float PrevZoomLevel = ZoomLevel; 77 | ZoomLevel = FMath::Clamp(ZoomLevel + (Amount * 0.05f), MinZoomLevel, MaxZoomLevel); 78 | return ZoomLevel != PrevZoomLevel; 79 | } 80 | 81 | float SMPTexturePreviewZoomer::GetZoomLevel() const 82 | { 83 | return ZoomLevel; 84 | } 85 | 86 | 87 | void SMPTexturePreviewZoomer::SetPreviewSize(const FVector2D PreviewSize) 88 | { 89 | PreviewBrush->ImageSize = PreviewSize; 90 | } 91 | 92 | void SMPTexturePreviewZoomer::SetPreviewTexture(UTexture2D* InPreviewTexture) 93 | { 94 | PreviewBrush = MakeShareable(new FSlateImageBrush(InPreviewTexture, PreviewBrush->ImageSize)); 95 | ImageWidget->SetImage(PreviewBrush.Get()); 96 | } 97 | 98 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Source/MultiPackerTab/Private/Widgets/SMPTexturePreviewZoomer.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 @TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "Widgets/SPanel.h" 5 | #include "Runtime/Launch/Resources/Version.h" 6 | #include "Widgets/DeclarativeSyntaxSupport.h" 7 | 8 | class UMaterialInterface; 9 | class UTexture2D; 10 | struct FSlateImageBrush; 11 | 12 | class SMPTexturePreviewZoomer : public SPanel 13 | { 14 | public: 15 | 16 | class FRMPreviewPanelSlot : public TSupportsOneChildMixin 17 | { 18 | public: 19 | #if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION <= 19) 20 | FRMPreviewPanelSlot() 21 | : TSupportsOneChildMixin() 22 | { 23 | } 24 | }; 25 | #endif 26 | #if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION > 19) 27 | FRMPreviewPanelSlot(SWidget* InOwner) 28 | : TSupportsOneChildMixin(InOwner) 29 | { 30 | } 31 | }; 32 | #endif 33 | SLATE_BEGIN_ARGS(SMPTexturePreviewZoomer) {} 34 | SLATE_END_ARGS() 35 | 36 | SMPTexturePreviewZoomer() 37 | #if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION > 19) 38 | : ChildSlot(this) 39 | #endif 40 | { 41 | } 42 | 43 | void Construct(const FArguments& InArgs, UTexture2D* InPreviewTexture); 44 | 45 | virtual void OnArrangeChildren(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const override; 46 | virtual FVector2D ComputeDesiredSize(float) const override; 47 | virtual FChildren* GetChildren() override; 48 | virtual FReply OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override; 49 | virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override; 50 | 51 | bool ZoomBy(const float Amount); 52 | float GetZoomLevel() const; 53 | 54 | void SetPreviewSize(const FVector2D PreviewSize); 55 | void SetPreviewTexture(UTexture2D* InPreviewTexture); 56 | private: 57 | //FLinearColor Tint= FLinearColor(1,1,1,1); 58 | mutable FVector2D CachedSize; 59 | float ZoomLevel; 60 | 61 | FRMPreviewPanelSlot ChildSlot; 62 | TSharedPtr PreviewBrush; 63 | TSharedPtr ImageWidget; 64 | }; -------------------------------------------------------------------------------- /Source/MultiPackerTab/Private/Widgets/SMPTextureWidget.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 @TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | 3 | #include "Widgets/SMPTextureWidget.h" 4 | #include "Widgets/SMPTexturePreviewZoomer.h" 5 | #include 6 | #include "Widgets/Images/SImage.h" 7 | #include "Templates/SharedPointer.h" 8 | #include "EditorStyleSet.h" 9 | #include 10 | 11 | #define LOCTEXT_NAMESPACE "SMPTextureWidget" 12 | 13 | void SMPTextureWidget::Construct(const FArguments& InArgs, UTexture2D* InPreviewTexture) 14 | { 15 | 16 | ChildSlot 17 | [ 18 | SNew(SVerticalBox) 19 | + SVerticalBox::Slot() 20 | .AutoHeight() 21 | [ 22 | SNew(SBorder) 23 | .HAlign(HAlign_Right) 24 | .VAlign(VAlign_Top) 25 | .BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder")) 26 | [ 27 | SNew(SHorizontalBox) 28 | + SHorizontalBox::Slot() 29 | .VAlign(VAlign_Center) 30 | .Padding(3.f) 31 | .AutoWidth() 32 | [ 33 | SNew(STextBlock) 34 | .Text(LOCTEXT("PreviewSize", "Preview Size")) 35 | ] 36 | + SHorizontalBox::Slot() 37 | .VAlign(VAlign_Center) 38 | .Padding(3.f) 39 | .MaxWidth(75) 40 | [ 41 | SNew(SNumericEntryBox) 42 | .AllowSpin(true) 43 | .MinValue(1) 44 | .MaxSliderValue(4096) 45 | .OnValueChanged(this, &SMPTextureWidget::OnPreviewXChanged) 46 | .OnValueCommitted(this, &SMPTextureWidget::OnPreviewXCommitted) 47 | .Value(this, &SMPTextureWidget::OnGetPreviewXValue) 48 | .MinDesiredValueWidth(75) 49 | .Label() 50 | [ 51 | SNew(SBox) 52 | .VAlign(VAlign_Center) 53 | [ 54 | SNew(STextBlock) 55 | .Text(LOCTEXT("PreviewSize_X", "X")) 56 | ] 57 | ] 58 | ] 59 | + SHorizontalBox::Slot() 60 | .VAlign(VAlign_Center) 61 | .Padding(3.f) 62 | .MaxWidth(75) 63 | [ 64 | SNew(SNumericEntryBox) 65 | .AllowSpin(true) 66 | .MinValue(1) 67 | .MaxSliderValue(4096) 68 | .MinDesiredValueWidth(75) 69 | .OnValueChanged(this, &SMPTextureWidget::OnPreviewYChanged) 70 | .OnValueCommitted(this, &SMPTextureWidget::OnPreviewYCommitted) 71 | .Value(this, &SMPTextureWidget::OnGetPreviewYValue) 72 | .Label() 73 | [ 74 | SNew(SBox) 75 | .VAlign(VAlign_Center) 76 | [ 77 | SNew(STextBlock) 78 | .Text(LOCTEXT("PreviewSize_Y", "Y")) 79 | ] 80 | ] 81 | ] 82 | ] 83 | ] 84 | + SVerticalBox::Slot() 85 | [ 86 | SNew(SBorder) 87 | .HAlign(HAlign_Center) 88 | .VAlign(VAlign_Center) 89 | .BorderImage(FEditorStyle::GetBrush("BlackBrush")) 90 | [ 91 | SAssignNew(PreviewZoomer, SMPTexturePreviewZoomer, InPreviewTexture) 92 | ] 93 | ] 94 | ]; 95 | 96 | PreviewSize = FIntPoint(250, 250); 97 | PreviewZoomer->SetPreviewSize(FVector2D(PreviewSize)); 98 | } 99 | 100 | void SMPTextureWidget::SetPreviewTexture(UTexture2D* InPreviewTexture) 101 | { 102 | PreviewZoomer->SetPreviewTexture(InPreviewTexture); 103 | } 104 | 105 | void SMPTextureWidget::OnPreviewXChanged(int32 NewValue) 106 | { 107 | PreviewSize.X = NewValue; 108 | PreviewZoomer->SetPreviewSize(FVector2D(PreviewSize)); 109 | } 110 | 111 | void SMPTextureWidget::OnPreviewXCommitted(int32 NewValue, ETextCommit::Type) 112 | { 113 | OnPreviewXChanged(NewValue); 114 | } 115 | 116 | void SMPTextureWidget::OnPreviewYChanged(int32 NewValue) 117 | { 118 | PreviewSize.Y = NewValue; 119 | PreviewZoomer->SetPreviewSize(FVector2D(PreviewSize)); 120 | } 121 | 122 | void SMPTextureWidget::OnPreviewYCommitted(int32 NewValue, ETextCommit::Type) 123 | { 124 | OnPreviewYChanged(NewValue); 125 | } 126 | 127 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Source/MultiPackerTab/Private/Widgets/SMPTextureWidget.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 @TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | 4 | #include "Widgets/SCompoundWidget.h" 5 | #include "Widgets/DeclarativeSyntaxSupport.h" 6 | 7 | class UTexture2D; 8 | class SMPTexturePreviewZoomer; 9 | /** 10 | * A preview viewport used for 2D Textures 11 | */ 12 | class SMPTextureWidget : public SCompoundWidget 13 | { 14 | public: 15 | SLATE_BEGIN_ARGS(SMPTextureWidget) {} 16 | SLATE_END_ARGS() 17 | 18 | void Construct(const FArguments& InArgs, UTexture2D* InPreviewTexture); 19 | void SetPreviewTexture(UTexture2D* InPreviewTexture); 20 | 21 | private: 22 | void OnPreviewXChanged(int32 NewValue); 23 | void OnPreviewXCommitted(int32 NewValue, ETextCommit::Type); 24 | void OnPreviewYChanged(int32 NewValue); 25 | void OnPreviewYCommitted(int32 NewValue, ETextCommit::Type); 26 | TOptional OnGetPreviewXValue() const { return PreviewSize.X; } 27 | TOptional OnGetPreviewYValue() const { return PreviewSize.Y; } 28 | private: 29 | FIntPoint PreviewSize; 30 | TSharedPtr PreviewZoomer; 31 | }; -------------------------------------------------------------------------------- /Source/MultiPackerTab/Public/MultiPackerTab.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 @TurboCheke, Estudio Cheke - All Rights Reserved */ 2 | #pragma once 3 | #include "Modules/ModuleManager.h" 4 | 5 | class FToolBarBuilder; 6 | class FMenuBuilder; 7 | class UMultiPackerChannelTab; 8 | 9 | class FMultiPackerTab : public IModuleInterface 10 | { 11 | public: 12 | 13 | /** IModuleInterface implementation */ 14 | virtual void StartupModule() override; 15 | virtual void ShutdownModule() override; 16 | 17 | void PluginButtonClicked(); 18 | 19 | private: 20 | 21 | TSharedRef OnSpawnPluginTab(const class FSpawnTabArgs& SpawnTabArgs); 22 | void AddToolbarExtension(FToolBarBuilder& Builder); 23 | void AddMenuExtension(FMenuBuilder& Builder); 24 | 25 | // Holds the menu extensibility manager. 26 | TSharedPtr MenuExtensibilityManager; 27 | 28 | // Holds the tool bar extensibility manager. 29 | TSharedPtr ToolBarExtensibilityManager; 30 | private: 31 | TSharedPtr PluginCommands; 32 | 33 | UMultiPackerChannelTab* TabSpawn; 34 | }; --------------------------------------------------------------------------------