├── .gitignore ├── Config ├── DefaultEditor.ini ├── DefaultEngine.ini ├── DefaultGame.ini └── DefaultInput.ini ├── GraphPrinterPlugin.uproject ├── LICENSE ├── Plugins └── GraphPrinter │ ├── Config │ └── FilterPlugin.ini │ ├── GraphPrinter.uplugin │ ├── Resources │ ├── Icon128.png │ ├── Icons │ │ ├── ClipboardAll128.png │ │ ├── ClipboardSelected128.png │ │ ├── GrayClipboardAll128.png │ │ ├── GrayClipboardSelected128.png │ │ ├── GrayOpen128.png │ │ ├── GrayPlugin128.png │ │ ├── GrayPrintAll128.png │ │ ├── GrayPrintSelected128.png │ │ ├── GrayRestore128.png │ │ ├── Open128.png │ │ ├── Plugin128.png │ │ ├── PrintAll128.png │ │ ├── PrintSelected128.png │ │ └── Restore128.png │ └── StreamDeck │ │ └── com.naotsun.graphprinter.streamDeckPlugin │ └── Source │ ├── ClipboardImageExtension │ ├── ClipboardImageExtension.Build.cs │ ├── Private │ │ └── ClipboardImageExtension │ │ │ ├── ClipboardImageExtensionModule.cpp │ │ │ ├── Linux │ │ │ └── LinuxClipboardImageExtension.cpp │ │ │ ├── Mac │ │ │ └── MacClipboardImageExtension.cpp │ │ │ └── Windows │ │ │ └── WindowsClipboardImageExtension.cpp │ └── Public │ │ └── ClipboardImageExtension │ │ ├── GenericPlatform │ │ └── GenericClipboardImageExtension.h │ │ ├── HAL │ │ └── ClipboardImageExtension.h │ │ ├── Linux │ │ └── LinuxClipboardImageExtension.h │ │ ├── Mac │ │ └── MacClipboardImageExtension.h │ │ └── Windows │ │ └── WindowsClipboardImageExtension.h │ ├── DetailsPanelPrinter │ ├── DetailsPanelPrinter.Build.cs │ ├── Private │ │ └── DetailsPanelPrinter │ │ │ ├── DetailsPanelPrinterModule.cpp │ │ │ ├── Types │ │ │ ├── PrintDetailsPanelOptions.cpp │ │ │ └── RestoreDetailsPanelOptions.cpp │ │ │ ├── Utilities │ │ │ ├── DetailsPanelPrinterSettings.cpp │ │ │ └── DetailsPanelPrinterUtils.cpp │ │ │ └── WidgetPrinters │ │ │ ├── ActorDetailsPanelPrinter.cpp │ │ │ ├── DetailsPanelPrinter.cpp │ │ │ └── InnerDetailsPanelPrinter.cpp │ └── Public │ │ └── DetailsPanelPrinter │ │ ├── Types │ │ ├── PrintDetailsPanelOptions.h │ │ └── RestoreDetailsPanelOptions.h │ │ ├── Utilities │ │ ├── DetailsPanelPrinterSettings.h │ │ └── DetailsPanelPrinterUtils.h │ │ └── WidgetPrinters │ │ ├── ActorDetailsPanelPrinter.h │ │ ├── DetailsPanelPrinter.h │ │ └── InnerDetailsPanelPrinter.h │ ├── GenericGraphPrinter │ ├── GenericGraphPrinter.Build.cs │ ├── Private │ │ └── GenericGraphPrinter │ │ │ ├── GenericGraphPrinterModule.cpp │ │ │ ├── Types │ │ │ └── PrintGraphOptions.cpp │ │ │ ├── Utilities │ │ │ ├── GenericGraphPrinterSettings.cpp │ │ │ └── GenericGraphPrinterUtils.cpp │ │ │ └── WidgetPrinters │ │ │ └── GenericGraphPrinter.cpp │ └── Public │ │ └── GenericGraphPrinter │ │ ├── Types │ │ └── PrintGraphOptions.h │ │ ├── Utilities │ │ ├── GenericGraphPrinterSettings.h │ │ └── GenericGraphPrinterUtils.h │ │ └── WidgetPrinters │ │ ├── GenericGraphPrinter.h │ │ └── InnerGenericGraphPrinter.h │ ├── GraphPrinterEditorExtension │ ├── GraphPrinterEditorExtension.Build.cs │ ├── Private │ │ └── GraphPrinterEditorExtension │ │ │ ├── CommandActions │ │ │ ├── GraphPrinterCommandActions.cpp │ │ │ ├── GraphPrinterCommandActions.h │ │ │ └── GraphPrinterCommands.cpp │ │ │ ├── GraphPrinterEditorExtensionModule.cpp │ │ │ ├── UIExtensions │ │ │ ├── AutoToolMenuExtender.cpp │ │ │ ├── StatusBarExtender.cpp │ │ │ ├── ToolMenuExtender.cpp │ │ │ └── ToolbarExtender.cpp │ │ │ └── Utilities │ │ │ ├── GraphPrinterEditorExtensionSettings.cpp │ │ │ └── GraphPrinterStyle.cpp │ └── Public │ │ └── GraphPrinterEditorExtension │ │ ├── CommandActions │ │ └── GraphPrinterCommands.h │ │ ├── UIExtensions │ │ ├── AutoToolMenuExtender.h │ │ └── ToolMenuExtensionConstants.h │ │ └── Utilities │ │ ├── GraphPrinterEditorExtensionSettings.h │ │ └── GraphPrinterStyle.h │ ├── GraphPrinterGlobals │ ├── GraphPrinterGlobals.Build.cs │ ├── Private │ │ └── GraphPrinterGlobals │ │ │ ├── GraphPrinterGlobalsModule.cpp │ │ │ └── Utilities │ │ │ ├── GraphPrinterSettings.cpp │ │ │ └── GraphPrinterUtils.cpp │ └── Public │ │ └── GraphPrinterGlobals │ │ ├── GraphPrinterGlobals.h │ │ └── Utilities │ │ ├── GraphPrinterSettings.h │ │ └── GraphPrinterUtils.h │ ├── GraphPrinterRemoteControl │ ├── GraphPrinterRemoteControl.Build.cs │ ├── Private │ │ └── GraphPrinterRemoteControl │ │ │ ├── GraphPrinterRemoteControlModule.cpp │ │ │ ├── Utilities │ │ │ └── GraphPrinterRemoteControlSettings.cpp │ │ │ └── WebSockets │ │ │ ├── GraphPrinterRemoteControlReceiver.cpp │ │ │ └── GraphPrinterRemoteControlReceiver.h │ └── Public │ │ └── GraphPrinterRemoteControl │ │ └── Utilities │ │ └── GraphPrinterRemoteControlSettings.h │ ├── GraphPrinterStreamDeck │ ├── GraphPrinterStreamDeck.Build.cs │ ├── Private │ │ └── GraphPrinterStreamDeck │ │ │ ├── GraphPrinterStreamDeckModule.cpp │ │ │ └── Windows │ │ │ └── WindowsStreamDeckUtils.cpp │ └── Public │ │ └── GraphPrinterStreamDeck │ │ ├── GenericPlatform │ │ └── GenericStreamDeckUtils.h │ │ ├── HAL │ │ └── StreamDeckUtils.h │ │ └── Windows │ │ └── WindowsStreamDeckUtils.h │ ├── MaterialGraphPrinter │ ├── MaterialGraphPrinter.Build.cs │ ├── Private │ │ └── MaterialGraphPrinter │ │ │ ├── MaterialGraphPrinterModule.cpp │ │ │ ├── Types │ │ │ └── PrintMaterialGraphOptions.cpp │ │ │ ├── Utilities │ │ │ └── MaterialGraphPrinterSettings.cpp │ │ │ └── WidgetPrinters │ │ │ ├── InnerMaterialGraphPrinter.cpp │ │ │ └── MaterialGraphPrinter.cpp │ └── Public │ │ └── MaterialGraphPrinter │ │ ├── Types │ │ ├── MaterialGraphExportMethod.h │ │ └── PrintMaterialGraphOptions.h │ │ ├── Utilities │ │ └── MaterialGraphPrinterSettings.h │ │ └── WidgetPrinters │ │ ├── InnerMaterialGraphPrinter.h │ │ └── MaterialGraphPrinter.h │ ├── ReferenceViewerPrinter │ ├── Private │ │ └── ReferenceViewerPrinter │ │ │ ├── ReferenceViewerPrinterModule.cpp │ │ │ └── WidgetPrinters │ │ │ ├── InnerReferenceViewerPrinter.cpp │ │ │ ├── InnerReferenceViewerPrinter.h │ │ │ ├── ReferenceViewerPrinter.cpp │ │ │ └── ReferenceViewerPrinter.h │ └── ReferenceViewerPrinter.Build.cs │ ├── TextChunkHelper │ ├── Private │ │ └── TextChunkHelper │ │ │ ├── Png │ │ │ ├── PngTextChunk.cpp │ │ │ └── PngTextChunk.h │ │ │ └── TextChunkHelperModule.cpp │ ├── Public │ │ └── TextChunkHelper │ │ │ ├── ITextChunk.h │ │ │ └── ITextChunkHelper.h │ └── TextChunkHelper.Build.cs │ ├── ViewportPrinter │ ├── Private │ │ └── ViewportPrinter │ │ │ ├── ViewportPrinterModule.cpp │ │ │ └── WidgetPrinters │ │ │ ├── InnerViewportPrinter.cpp │ │ │ └── ViewportPrinter.cpp │ ├── Public │ │ └── ViewportPrinter │ │ │ └── WidgetPrinters │ │ │ ├── InnerViewportPrinter.h │ │ │ └── ViewportPrinter.h │ └── ViewportPrinter.Build.cs │ └── WidgetPrinter │ ├── Private │ └── WidgetPrinter │ │ ├── SupportedWidgetRegistryImpl.cpp │ │ ├── Types │ │ ├── PrintWidgetOptions.cpp │ │ ├── RestoreWidgetOptions.cpp │ │ └── SupportedWidget.cpp │ │ ├── Utilities │ │ ├── WidgetPrinterSettings.cpp │ │ └── WidgetPrinterUtils.cpp │ │ ├── WidgetPrinterModule.cpp │ │ ├── WidgetPrinterRegistryImpl.cpp │ │ └── WidgetPrinters │ │ ├── InnerWidgetPrinter.cpp │ │ └── WidgetPrinter.cpp │ ├── Public │ └── WidgetPrinter │ │ ├── ISupportedWidgetRegistry.h │ │ ├── IWidgetPrinterRegistry.h │ │ ├── Types │ │ ├── OneWayBool.h │ │ ├── PrintWidgetOptions.h │ │ ├── RestoreWidgetOptions.h │ │ └── SupportedWidget.h │ │ ├── Utilities │ │ ├── CastSlateWidget.h │ │ ├── WidgetPrinterSettings.h │ │ └── WidgetPrinterUtils.h │ │ └── WidgetPrinters │ │ ├── InnerWidgetPrinter.h │ │ └── WidgetPrinter.h │ └── WidgetPrinter.Build.cs ├── README.md └── Source ├── GraphPrinterPlugin.Target.cs ├── GraphPrinterPlugin ├── GraphPrinterPlugin.Build.cs ├── GraphPrinterPlugin.cpp └── GraphPrinterPlugin.h └── GraphPrinterPluginEditor.Target.cs /.gitignore: -------------------------------------------------------------------------------- 1 | # Visual Studio user specific files 2 | .vs/ 3 | 4 | # Rider for Unreal Engine user specific files 5 | .idea/ 6 | *.user 7 | Plugins/Developer/RiderLink/* 8 | 9 | # Visual Studio database file 10 | *.VC.db 11 | 12 | # Compiled Object files 13 | *.slo 14 | *.lo 15 | *.o 16 | *.obj 17 | 18 | # Precompiled Headers 19 | *.gch 20 | *.pch 21 | 22 | # Compiled Dynamic libraries 23 | *.so 24 | *.dylib 25 | *.dll 26 | 27 | # Fortran module files 28 | *.mod 29 | 30 | # Compiled Static libraries 31 | *.lai 32 | *.la 33 | *.a 34 | *.lib 35 | 36 | # Executables 37 | *.exe 38 | *.out 39 | *.app 40 | *.ipa 41 | 42 | # These project files can be generated by the engine 43 | *.xcodeproj 44 | *.xcworkspace 45 | *.sln 46 | *.suo 47 | *.opensdf 48 | *.sdf 49 | *.VC.db 50 | *.VC.opendb 51 | *.vsconfig 52 | 53 | # Precompiled Assets 54 | SourceArt/**/*.png 55 | SourceArt/**/*.tga 56 | 57 | # Binary Files 58 | Binaries/* 59 | Plugins/*/Binaries/* 60 | 61 | # Builds 62 | Build/ 63 | Build/* 64 | 65 | # Whitelist PakBlacklist-.txt files 66 | !Build/*/ 67 | Build/*/** 68 | !Build/*/PakBlacklist*.txt 69 | 70 | # Don't ignore icon files in Build 71 | !Build/**/*.ico 72 | 73 | # Built data for maps 74 | *_BuiltData.uasset 75 | 76 | # Configuration files generated by the Editor 77 | Saved/* 78 | Config/User*.ini 79 | 80 | # Compiled source files for the engine to use 81 | Intermediate/* 82 | Plugins/*/Intermediate/* 83 | 84 | # Cache files for the editor to use 85 | DerivedDataCache/* 86 | 87 | # Python modules 88 | Plugins/*/Content/Python/* 89 | -------------------------------------------------------------------------------- /Config/DefaultEditor.ini: -------------------------------------------------------------------------------- 1 | [/Script/AdvancedPreviewScene.SharedProfiles] 2 | 3 | -------------------------------------------------------------------------------- /Config/DefaultEngine.ini: -------------------------------------------------------------------------------- 1 | 2 | 3 | [/Script/HardwareTargeting.HardwareTargetingSettings] 4 | TargetedHardwareClass=Desktop 5 | AppliedTargetedHardwareClass=Desktop 6 | DefaultGraphicsPerformance=Maximum 7 | AppliedDefaultGraphicsPerformance=Maximum 8 | 9 | [/Script/Engine.Engine] 10 | +ActiveGameNameRedirects=(OldGameName="TP_Blank",NewGameName="/Script/GraphPrinterPlugin") 11 | +ActiveGameNameRedirects=(OldGameName="/Script/TP_Blank",NewGameName="/Script/GraphPrinterPlugin") 12 | +ActiveClassRedirects=(OldClassName="TP_BlankGameModeBase",NewClassName="GraphPrinterPluginGameModeBase") 13 | 14 | [/Script/AndroidFileServerEditor.AndroidFileServerRuntimeSettings] 15 | bEnablePlugin=True 16 | bAllowNetworkConnection=True 17 | SecurityToken=6A669ADF4180A3763A25E4A84AF31871 18 | bIncludeInShipping=False 19 | bAllowExternalStartInShipping=False 20 | bCompileAFSProject=False 21 | bUseCompression=False 22 | bLogFiles=False 23 | bReportStats=False 24 | ConnectionType=USBOnly 25 | bUseManualIPAddress=False 26 | ManualIPAddress= 27 | 28 | -------------------------------------------------------------------------------- /Config/DefaultGame.ini: -------------------------------------------------------------------------------- 1 | 2 | [/Script/EngineSettings.GeneralProjectSettings] 3 | ProjectID=84125DCD4B1CE7B9B9F82CBEAAD4CE27 4 | CopyrightNotice=Copyright 2020-2025 Naotsun. All Rights Reserved. 5 | 6 | -------------------------------------------------------------------------------- /GraphPrinterPlugin.uproject: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "EngineAssociation": "5.6", 4 | "Category": "", 5 | "Description": "", 6 | "Modules": [ 7 | { 8 | "Name": "GraphPrinterPlugin", 9 | "Type": "Runtime", 10 | "LoadingPhase": "Default" 11 | } 12 | ], 13 | "Plugins": [ 14 | { 15 | "Name": "GraphPrinter", 16 | "Enabled": true, 17 | "MarketplaceURL": "com.epicgames.launcher://ue/marketplace/content/466303b6cd724968b3ee0a1a1b623f4b" 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Naotsun 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/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 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/GraphPrinter.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "Version": 2, 4 | "VersionName": "2.9", 5 | "FriendlyName": "GraphPrinter", 6 | "Description": "It is a plugin that adds a shortcut to output the graph editor to the image file and a shortcut to restore the node from the image file.", 7 | "Category": "Editor", 8 | "CreatedBy": "Naotsun", 9 | "CreatedByURL": "https://twitter.com/Naotsun_UE", 10 | "DocsURL": "https://github.com/Naotsun19B/GraphPrinter", 11 | "MarketplaceURL": "com.epicgames.launcher://ue/marketplace/content/466303b6cd724968b3ee0a1a1b623f4b", 12 | "SupportURL": "https://github.com/Naotsun19B/GraphPrinter", 13 | "CanContainContent": false, 14 | "IsBetaVersion": false, 15 | "IsExperimentalVersion": false, 16 | "Installed": true, 17 | "EnabledByDefault": true, 18 | "Modules": [ 19 | { 20 | "Name": "GraphPrinterGlobals", 21 | "Type": "EditorNoCommandlet", 22 | "LoadingPhase": "Default", 23 | "WhitelistPlatforms": [ 24 | "Win64", 25 | "Win32", 26 | "Mac", 27 | "Linux" 28 | ] 29 | }, 30 | { 31 | "Name": "WidgetPrinter", 32 | "Type": "EditorNoCommandlet", 33 | "LoadingPhase": "Default", 34 | "WhitelistPlatforms": [ 35 | "Win64", 36 | "Win32", 37 | "Mac", 38 | "Linux" 39 | ] 40 | }, 41 | { 42 | "Name": "GenericGraphPrinter", 43 | "Type": "EditorNoCommandlet", 44 | "LoadingPhase": "Default", 45 | "WhitelistPlatforms": [ 46 | "Win64", 47 | "Win32", 48 | "Mac", 49 | "Linux" 50 | ] 51 | }, 52 | { 53 | "Name": "ReferenceViewerPrinter", 54 | "Type": "EditorNoCommandlet", 55 | "LoadingPhase": "Default", 56 | "WhitelistPlatforms": [ 57 | "Win64", 58 | "Win32", 59 | "Mac", 60 | "Linux" 61 | ] 62 | }, 63 | { 64 | "Name": "ViewportPrinter", 65 | "Type": "EditorNoCommandlet", 66 | "LoadingPhase": "Default", 67 | "WhitelistPlatforms": [ 68 | "Win64", 69 | "Win32", 70 | "Mac", 71 | "Linux" 72 | ] 73 | }, 74 | { 75 | "Name": "MaterialGraphPrinter", 76 | "Type": "EditorNoCommandlet", 77 | "LoadingPhase": "Default", 78 | "WhitelistPlatforms": [ 79 | "Win64", 80 | "Win32", 81 | "Mac", 82 | "Linux" 83 | ] 84 | }, 85 | { 86 | "Name": "DetailsPanelPrinter", 87 | "Type": "EditorNoCommandlet", 88 | "LoadingPhase": "Default", 89 | "WhitelistPlatforms": [ 90 | "Win64", 91 | "Win32", 92 | "Mac", 93 | "Linux" 94 | ] 95 | }, 96 | { 97 | "Name": "GraphPrinterEditorExtension", 98 | "Type": "EditorNoCommandlet", 99 | "LoadingPhase": "Default", 100 | "WhitelistPlatforms": [ 101 | "Win64", 102 | "Win32", 103 | "Mac", 104 | "Linux" 105 | ] 106 | }, 107 | { 108 | "Name": "GraphPrinterRemoteControl", 109 | "Type": "EditorNoCommandlet", 110 | "LoadingPhase": "Default", 111 | "WhitelistPlatforms": [ 112 | "Win64", 113 | "Win32", 114 | "Mac", 115 | "Linux" 116 | ] 117 | }, 118 | { 119 | "Name": "GraphPrinterStreamDeck", 120 | "Type": "EditorNoCommandlet", 121 | "LoadingPhase": "Default", 122 | "WhitelistPlatforms": [ 123 | "Win64", 124 | "Win32", 125 | "Mac", 126 | "Linux" 127 | ] 128 | }, 129 | { 130 | "Name": "TextChunkHelper", 131 | "Type": "EditorNoCommandlet", 132 | "LoadingPhase": "Default", 133 | "WhitelistPlatforms": [ 134 | "Win64", 135 | "Win32", 136 | "Mac", 137 | "Linux" 138 | ] 139 | }, 140 | { 141 | "Name": "ClipboardImageExtension", 142 | "Type": "EditorNoCommandlet", 143 | "LoadingPhase": "Default", 144 | "WhitelistPlatforms": [ 145 | "Win64", 146 | "Win32", 147 | "Mac", 148 | "Linux" 149 | ] 150 | } 151 | ], 152 | "Plugins": [ 153 | { 154 | "Name": "AssetManagerEditor", 155 | "Enabled": true 156 | } 157 | ] 158 | } -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naotsun19B/GraphPrinter/4f26c17caa837880171c139046db708b60ad00a5/Plugins/GraphPrinter/Resources/Icon128.png -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Resources/Icons/ClipboardAll128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naotsun19B/GraphPrinter/4f26c17caa837880171c139046db708b60ad00a5/Plugins/GraphPrinter/Resources/Icons/ClipboardAll128.png -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Resources/Icons/ClipboardSelected128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naotsun19B/GraphPrinter/4f26c17caa837880171c139046db708b60ad00a5/Plugins/GraphPrinter/Resources/Icons/ClipboardSelected128.png -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Resources/Icons/GrayClipboardAll128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naotsun19B/GraphPrinter/4f26c17caa837880171c139046db708b60ad00a5/Plugins/GraphPrinter/Resources/Icons/GrayClipboardAll128.png -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Resources/Icons/GrayClipboardSelected128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naotsun19B/GraphPrinter/4f26c17caa837880171c139046db708b60ad00a5/Plugins/GraphPrinter/Resources/Icons/GrayClipboardSelected128.png -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Resources/Icons/GrayOpen128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naotsun19B/GraphPrinter/4f26c17caa837880171c139046db708b60ad00a5/Plugins/GraphPrinter/Resources/Icons/GrayOpen128.png -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Resources/Icons/GrayPlugin128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naotsun19B/GraphPrinter/4f26c17caa837880171c139046db708b60ad00a5/Plugins/GraphPrinter/Resources/Icons/GrayPlugin128.png -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Resources/Icons/GrayPrintAll128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naotsun19B/GraphPrinter/4f26c17caa837880171c139046db708b60ad00a5/Plugins/GraphPrinter/Resources/Icons/GrayPrintAll128.png -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Resources/Icons/GrayPrintSelected128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naotsun19B/GraphPrinter/4f26c17caa837880171c139046db708b60ad00a5/Plugins/GraphPrinter/Resources/Icons/GrayPrintSelected128.png -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Resources/Icons/GrayRestore128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naotsun19B/GraphPrinter/4f26c17caa837880171c139046db708b60ad00a5/Plugins/GraphPrinter/Resources/Icons/GrayRestore128.png -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Resources/Icons/Open128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naotsun19B/GraphPrinter/4f26c17caa837880171c139046db708b60ad00a5/Plugins/GraphPrinter/Resources/Icons/Open128.png -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Resources/Icons/Plugin128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naotsun19B/GraphPrinter/4f26c17caa837880171c139046db708b60ad00a5/Plugins/GraphPrinter/Resources/Icons/Plugin128.png -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Resources/Icons/PrintAll128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naotsun19B/GraphPrinter/4f26c17caa837880171c139046db708b60ad00a5/Plugins/GraphPrinter/Resources/Icons/PrintAll128.png -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Resources/Icons/PrintSelected128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naotsun19B/GraphPrinter/4f26c17caa837880171c139046db708b60ad00a5/Plugins/GraphPrinter/Resources/Icons/PrintSelected128.png -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Resources/Icons/Restore128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naotsun19B/GraphPrinter/4f26c17caa837880171c139046db708b60ad00a5/Plugins/GraphPrinter/Resources/Icons/Restore128.png -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Resources/StreamDeck/com.naotsun.graphprinter.streamDeckPlugin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naotsun19B/GraphPrinter/4f26c17caa837880171c139046db708b60ad00a5/Plugins/GraphPrinter/Resources/StreamDeck/com.naotsun.graphprinter.streamDeckPlugin -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ClipboardImageExtension/ClipboardImageExtension.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | using System.IO; 4 | using UnrealBuildTool; 5 | 6 | public class ClipboardImageExtension : ModuleRules 7 | { 8 | public ClipboardImageExtension(ReadOnlyTargetRules Target) : base(Target) 9 | { 10 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 11 | #if UE_5_2_OR_LATER 12 | IncludeOrderVersion = EngineIncludeOrderVersion.Latest; 13 | #endif 14 | 15 | PublicIncludePaths.AddRange( 16 | new string[] 17 | { 18 | Path.Combine(ModuleDirectory, "Public", "ClipboardImageExtension"), 19 | } 20 | ); 21 | 22 | PublicDependencyModuleNames.AddRange( 23 | new string[] 24 | { 25 | "Core", 26 | } 27 | ); 28 | 29 | PrivateDependencyModuleNames.AddRange( 30 | new string[] 31 | { 32 | "ImageWrapper", 33 | "ImageWriteQueue", 34 | "ApplicationCore", 35 | 36 | "GraphPrinterGlobals", 37 | } 38 | ); 39 | 40 | PublicDefinitions.Add("WITH_CLIPBOARD_IMAGE_EXTENSION"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ClipboardImageExtension/Private/ClipboardImageExtension/ClipboardImageExtensionModule.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "CoreMinimal.h" 4 | #include "Modules/ModuleManager.h" 5 | 6 | namespace ClipboardImageExtension 7 | { 8 | class FClipboardImageExtensionModule : public IModuleInterface 9 | { 10 | public: 11 | // IModuleInterface interface. 12 | virtual void StartupModule() override; 13 | virtual void ShutdownModule() override; 14 | // End of IModuleInterface interface. 15 | }; 16 | 17 | void FClipboardImageExtensionModule::StartupModule() 18 | { 19 | } 20 | 21 | void FClipboardImageExtensionModule::ShutdownModule() 22 | { 23 | } 24 | } 25 | 26 | IMPLEMENT_MODULE(ClipboardImageExtension::FClipboardImageExtensionModule, ClipboardImageExtension) 27 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ClipboardImageExtension/Private/ClipboardImageExtension/Linux/LinuxClipboardImageExtension.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "ClipboardImageExtension/Linux/LinuxClipboardImageExtension.h" 4 | 5 | namespace ClipboardImageExtension 6 | { 7 | bool FLinuxClipboardImageExtension::IsCopyImageToClipboardAvailable() 8 | { 9 | const FString Command = FString::Printf(TEXT("which xclip > /dev/null 2>&1")); 10 | FProcHandle Handle = FPlatformProcess::CreateProc( 11 | *Command, 12 | nullptr, 13 | true, 14 | false, 15 | false, 16 | nullptr, 17 | 0, 18 | nullptr, 19 | nullptr 20 | ); 21 | 22 | int32 ReturnCode; 23 | if (!FPlatformProcess::GetProcReturnCode(Handle, &ReturnCode)) 24 | { 25 | return false; 26 | } 27 | 28 | return (ReturnCode == 0); 29 | } 30 | 31 | bool FLinuxClipboardImageExtension::ClipboardCopy(const FString& Filename) 32 | { 33 | const FString Command = FString::Printf( 34 | TEXT("xclip -selection clipboard -t image/png -i %s"), 35 | *Filename 36 | ); 37 | FProcHandle Handle = FPlatformProcess::CreateProc( 38 | *Command, 39 | nullptr, 40 | true, 41 | false, 42 | false, 43 | nullptr, 44 | 0, 45 | nullptr, 46 | nullptr 47 | ); 48 | 49 | int32 ReturnCode; 50 | if (!FPlatformProcess::GetProcReturnCode(Handle, &ReturnCode)) 51 | { 52 | return false; 53 | } 54 | 55 | return (ReturnCode == 0); 56 | } 57 | 58 | EDesiredImageFormat FLinuxClipboardImageExtension::GetCopyableImageFormat() 59 | { 60 | return EDesiredImageFormat::PNG; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ClipboardImageExtension/Private/ClipboardImageExtension/Mac/MacClipboardImageExtension.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "ClipboardImageExtension/Mac/MacClipboardImageExtension.h" 4 | 5 | namespace ClipboardImageExtension 6 | { 7 | bool FMacClipboardImageExtension::IsCopyImageToClipboardAvailable() 8 | { 9 | return true; 10 | } 11 | 12 | bool FMacClipboardImageExtension::ClipboardCopy(const FString& Filename) 13 | { 14 | bool bWasCopySuccessful = false; 15 | 16 | #if PLATFORM_MAC 17 | NSString* Path = [NSString stringWithUTF8String:TCHAR_TO_UTF8(*Filename)]; 18 | NSImage* Image = [[NSImage alloc] initWithContentsOfFile:Path]; 19 | 20 | bWasCopySuccessful = (Image != nil); 21 | if (bWasCopySuccessful) 22 | { 23 | NSPasteboard* Pasteboard = [NSPasteboard generalPasteboard]; 24 | [Pasteboard clearContents]; 25 | [Pasteboard writeObjects:@[Image]]; 26 | } 27 | 28 | [Image release]; 29 | #endif 30 | 31 | return bWasCopySuccessful; 32 | } 33 | 34 | EDesiredImageFormat FMacClipboardImageExtension::GetCopyableImageFormat() 35 | { 36 | return EDesiredImageFormat::JPG; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ClipboardImageExtension/Private/ClipboardImageExtension/Windows/WindowsClipboardImageExtension.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "ClipboardImageExtension/Windows/WindowsClipboardImageExtension.h" 4 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 5 | #include "IImageWrapperModule.h" 6 | #include "IImageWrapper.h" 7 | #include "Misc/FileHelper.h" 8 | #include "Modules/ModuleManager.h" 9 | 10 | #if PLATFORM_WINDOWS 11 | #include "Windows/WindowsApplication.h" 12 | #endif 13 | 14 | namespace ClipboardImageExtension 15 | { 16 | #if PLATFORM_WINDOWS 17 | namespace ClipboardImageExtensionInternal 18 | { 19 | HBITMAP LoadBitmapImage(const FString& Filename) 20 | { 21 | TArray RawFileData; 22 | if (!FFileHelper::LoadFileToArray(RawFileData, *Filename)) 23 | { 24 | return nullptr; 25 | } 26 | 27 | auto& ImageWrapperModule = FModuleManager::LoadModuleChecked(FName("ImageWrapper")); 28 | const TSharedPtr ImageWrapper = ImageWrapperModule.CreateImageWrapper(EImageFormat::BMP); 29 | if (!ImageWrapper.IsValid()) 30 | { 31 | return nullptr; 32 | } 33 | 34 | if (!ImageWrapper->SetCompressed(RawFileData.GetData(), RawFileData.GetAllocatedSize())) 35 | { 36 | return nullptr; 37 | } 38 | 39 | #if UE_4_25_OR_LATER 40 | TArray BitmapBuffer; 41 | if (!ImageWrapper->GetRaw(ImageWrapper->GetFormat(), ImageWrapper->GetBitDepth(), BitmapBuffer)) 42 | { 43 | return nullptr; 44 | } 45 | #else 46 | const TArray* BitmapBuffer; 47 | if (!ImageWrapper->GetRaw(ImageWrapper->GetFormat(), ImageWrapper->GetBitDepth(), BitmapBuffer)) 48 | { 49 | return nullptr; 50 | } 51 | if (BitmapBuffer == nullptr) 52 | { 53 | return nullptr; 54 | } 55 | #endif 56 | 57 | return CreateBitmap( 58 | ImageWrapper->GetWidth(), ImageWrapper->GetHeight(), 1, 32, 59 | #if UE_4_25_OR_LATER 60 | BitmapBuffer.GetData() 61 | #else 62 | BitmapBuffer->GetData() 63 | #endif 64 | ); 65 | } 66 | #endif 67 | } 68 | 69 | bool FWindowsClipboardImageExtension::IsCopyImageToClipboardAvailable() 70 | { 71 | return true; 72 | } 73 | 74 | bool FWindowsClipboardImageExtension::ClipboardCopy(const FString& Filename) 75 | { 76 | #if PLATFORM_WINDOWS 77 | const HBITMAP Bitmap = ClipboardImageExtensionInternal::LoadBitmapImage(Filename); 78 | if (Bitmap == nullptr) 79 | { 80 | UE_LOG(LogGraphPrinter, Error, TEXT("Failed to load the file to copy to the clipboard (%s)"), *Filename); 81 | return false; 82 | } 83 | 84 | if (!OpenClipboard(GetActiveWindow())) 85 | { 86 | return false; 87 | } 88 | 89 | verify(EmptyClipboard()); 90 | 91 | if (SetClipboardData(CF_BITMAP, Bitmap) == nullptr) 92 | { 93 | UE_LOG(LogGraphPrinter, Fatal, TEXT("SetClipboardData failed with error code %i"), static_cast(GetLastError())); 94 | } 95 | 96 | verify(CloseClipboard()); 97 | 98 | return true; 99 | #else 100 | return false; 101 | #endif 102 | } 103 | 104 | EDesiredImageFormat FWindowsClipboardImageExtension::GetCopyableImageFormat() 105 | { 106 | return EDesiredImageFormat::BMP; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ClipboardImageExtension/Public/ClipboardImageExtension/GenericPlatform/GenericClipboardImageExtension.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "ImageWriteTypes.h" 7 | 8 | namespace ClipboardImageExtension 9 | { 10 | /** 11 | * A extension class for working with images on the clipboard. 12 | */ 13 | class CLIPBOARDIMAGEEXTENSION_API FGenericClipboardImageExtension 14 | { 15 | public: 16 | // Returns whether the function to copy images to the clipboard is available. 17 | static bool IsCopyImageToClipboardAvailable() { return false; } 18 | 19 | // Copies the image file with the specified path to the clipboard. 20 | static bool ClipboardCopy(const FString& Filename) { return false; } 21 | 22 | // Returns an image format that can be copied to the clipboard. 23 | static EDesiredImageFormat GetCopyableImageFormat() { return EDesiredImageFormat::PNG; } 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ClipboardImageExtension/Public/ClipboardImageExtension/HAL/ClipboardImageExtension.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | #include COMPILED_PLATFORM_HEADER(ClipboardImageExtension.h) 8 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ClipboardImageExtension/Public/ClipboardImageExtension/Linux/LinuxClipboardImageExtension.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "ClipboardImageExtension/GenericPlatform/GenericClipboardImageExtension.h" 7 | 8 | namespace ClipboardImageExtension 9 | { 10 | /** 11 | * An extension class for working with clipboard images on Linux. 12 | */ 13 | class CLIPBOARDIMAGEEXTENSION_API FLinuxClipboardImageExtension : public FGenericClipboardImageExtension 14 | { 15 | public: 16 | // FGenericClipboardImageExtension interface. 17 | static bool IsCopyImageToClipboardAvailable(); 18 | static bool ClipboardCopy(const FString& Filename); 19 | static EDesiredImageFormat GetCopyableImageFormat(); 20 | // End of FGenericClipboardImageExtension interface. 21 | }; 22 | 23 | #if PLATFORM_LINUX 24 | using FClipboardImageExtension = FLinuxClipboardImageExtension; 25 | #endif 26 | } 27 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ClipboardImageExtension/Public/ClipboardImageExtension/Mac/MacClipboardImageExtension.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "ClipboardImageExtension/GenericPlatform/GenericClipboardImageExtension.h" 7 | 8 | namespace ClipboardImageExtension 9 | { 10 | /** 11 | * An extension class for working with clipboard images on Mac. 12 | */ 13 | class CLIPBOARDIMAGEEXTENSION_API FMacClipboardImageExtension : public FGenericClipboardImageExtension 14 | { 15 | public: 16 | // FGenericClipboardImageExtension interface. 17 | static bool IsCopyImageToClipboardAvailable(); 18 | static bool ClipboardCopy(const FString& Filename); 19 | static EDesiredImageFormat GetCopyableImageFormat(); 20 | // End of FGenericClipboardImageExtension interface. 21 | }; 22 | 23 | #if PLATFORM_MAC 24 | using FClipboardImageExtension = FMacClipboardImageExtension; 25 | #endif 26 | } 27 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ClipboardImageExtension/Public/ClipboardImageExtension/Windows/WindowsClipboardImageExtension.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "ClipboardImageExtension/GenericPlatform/GenericClipboardImageExtension.h" 7 | 8 | namespace ClipboardImageExtension 9 | { 10 | /** 11 | * An extension class for working with clipboard images on Windows. 12 | */ 13 | class CLIPBOARDIMAGEEXTENSION_API FWindowsClipboardImageExtension : public FGenericClipboardImageExtension 14 | { 15 | public: 16 | // FGenericClipboardImageExtension interface. 17 | static bool IsCopyImageToClipboardAvailable(); 18 | static bool ClipboardCopy(const FString& Filename); 19 | static EDesiredImageFormat GetCopyableImageFormat(); 20 | // End of FGenericClipboardImageExtension interface. 21 | }; 22 | 23 | #if PLATFORM_WINDOWS 24 | using FClipboardImageExtension = FWindowsClipboardImageExtension; 25 | #endif 26 | } 27 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/DetailsPanelPrinter/DetailsPanelPrinter.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | using System.IO; 4 | using UnrealBuildTool; 5 | 6 | public class DetailsPanelPrinter : ModuleRules 7 | { 8 | public DetailsPanelPrinter(ReadOnlyTargetRules Target) : base(Target) 9 | { 10 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 11 | #if UE_5_2_OR_LATER 12 | IncludeOrderVersion = EngineIncludeOrderVersion.Latest; 13 | #endif 14 | 15 | PublicDependencyModuleNames.AddRange( 16 | new string[] 17 | { 18 | "Core", 19 | } 20 | ); 21 | 22 | PrivateDependencyModuleNames.AddRange( 23 | new string[] 24 | { 25 | "CoreUObject", 26 | "UMG", 27 | "Slate", 28 | "SlateCore", 29 | "Engine", 30 | "UnrealEd", 31 | "MainFrame", 32 | "Json", 33 | "JsonUtilities", 34 | 35 | "GraphPrinterGlobals", 36 | "WidgetPrinter", 37 | "TextChunkHelper", 38 | "ClipboardImageExtension", 39 | } 40 | ); 41 | if (Target.Version.MajorVersion >= 5) 42 | { 43 | PrivateDependencyModuleNames.Add("SubobjectEditor"); 44 | } 45 | 46 | PublicIncludePaths.AddRange( 47 | new string[] 48 | { 49 | #if UE_5_2_OR_LATER 50 | // In UHT for UE5.2 and later, when you use PublicIncludePaths, the base path of the module's include will be replaced with the first value, so add the correct base path of the include first. 51 | Path.Combine(ModuleDirectory, ".."), 52 | #endif 53 | // To use SDetailsView. 54 | Path.Combine(EngineDirectory, "Source", "Editor", "PropertyEditor", "Private"), 55 | 56 | // To use SActorDetails. 57 | Path.Combine(EngineDirectory, "Source", "Editor", "LevelEditor", "Private"), 58 | } 59 | ); 60 | 61 | // #TODO: Allows the use of details panel printer on Mac/Linux and before UE4.27. 62 | if (Target.IsInPlatformGroup(UnrealPlatformGroup.Windows)) 63 | { 64 | if (Target.Version.MajorVersion >= 5) 65 | { 66 | PublicDefinitions.Add("WITH_DETAILS_PANEL_PRINTER"); 67 | } 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/DetailsPanelPrinter/Private/DetailsPanelPrinter/DetailsPanelPrinterModule.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "CoreMinimal.h" 4 | #include "Modules/ModuleManager.h" 5 | 6 | namespace GraphPrinter 7 | { 8 | class FDetailsPanelPrinterModule : public IModuleInterface 9 | { 10 | public: 11 | // IModuleInterface interface. 12 | virtual void StartupModule() override; 13 | virtual void ShutdownModule() override; 14 | // End of IModuleInterface interface. 15 | }; 16 | 17 | void FDetailsPanelPrinterModule::StartupModule() 18 | { 19 | } 20 | 21 | void FDetailsPanelPrinterModule::ShutdownModule() 22 | { 23 | } 24 | } 25 | 26 | IMPLEMENT_MODULE(GraphPrinter::FDetailsPanelPrinterModule, DetailsPanelPrinter) 27 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/DetailsPanelPrinter/Private/DetailsPanelPrinter/Types/PrintDetailsPanelOptions.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "DetailsPanelPrinter/Types/PrintDetailsPanelOptions.h" 4 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 5 | 6 | #if UE_5_01_OR_LATER 7 | #include UE_INLINE_GENERATED_CPP_BY_NAME(PrintDetailsPanelOptions) 8 | #endif 9 | 10 | UPrintDetailsPanelOptions::UPrintDetailsPanelOptions() 11 | : Padding(50.f) 12 | , bIsIncludeExpansionStateInImageFile(true) 13 | { 14 | } 15 | 16 | UPrintWidgetOptions* UPrintDetailsPanelOptions::Duplicate(const TSubclassOf& DestinationClass) const 17 | { 18 | auto* Destination = Super::Duplicate(DestinationClass); 19 | if (auto* CastedDestination = Cast(Destination)) 20 | { 21 | CastedDestination->Padding = Padding; 22 | CastedDestination->bIsIncludeExpansionStateInImageFile = bIsIncludeExpansionStateInImageFile; 23 | } 24 | 25 | return Destination; 26 | } 27 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/DetailsPanelPrinter/Private/DetailsPanelPrinter/Types/RestoreDetailsPanelOptions.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "DetailsPanelPrinter/Types/RestoreDetailsPanelOptions.h" 4 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 5 | #if UE_5_01_OR_LATER 6 | #include UE_INLINE_GENERATED_CPP_BY_NAME(RestoreDetailsPanelOptions) 7 | #endif 8 | 9 | URestoreDetailsPanelOptions::URestoreDetailsPanelOptions() 10 | : bWhetherToAlsoRestoreExpandedStates(true) 11 | { 12 | } 13 | 14 | URestoreWidgetOptions* URestoreDetailsPanelOptions::Duplicate(const TSubclassOf& DestinationClass) const 15 | { 16 | auto* Destination = Super::Duplicate(DestinationClass); 17 | if (auto* CastedDestination = Cast(Destination)) 18 | { 19 | CastedDestination->bWhetherToAlsoRestoreExpandedStates = bWhetherToAlsoRestoreExpandedStates; 20 | } 21 | 22 | return Destination; 23 | } 24 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/DetailsPanelPrinter/Private/DetailsPanelPrinter/Utilities/DetailsPanelPrinterSettings.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "DetailsPanelPrinter/Utilities/DetailsPanelPrinterSettings.h" 4 | #include "WidgetPrinter/Utilities/WidgetPrinterSettings.h" 5 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 6 | 7 | #if UE_5_01_OR_LATER 8 | #include UE_INLINE_GENERATED_CPP_BY_NAME(DetailsPanelPrinterSettings) 9 | #endif 10 | 11 | UDetailsPanelPrinterSettings::UDetailsPanelPrinterSettings() 12 | : Padding(50.f) 13 | , bIsIncludeExpansionStateInImageFile(true) 14 | , bWhetherToAlsoRestoreExpandedStates(true) 15 | { 16 | #if !UE_5_00_OR_LATER 17 | if (UClass* Class = GetClass()) 18 | { 19 | Class->ClassFlags |= CLASS_Abstract; 20 | } 21 | #endif 22 | } 23 | 24 | bool UDetailsPanelPrinterSettings::CanEditChange(const FProperty* InProperty) const 25 | { 26 | bool bCanEditChange = true; 27 | if (InProperty != nullptr) 28 | { 29 | if ((InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UDetailsPanelPrinterSettings, bIsIncludeExpansionStateInImageFile)) || 30 | (InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UDetailsPanelPrinterSettings, bWhetherToAlsoRestoreExpandedStates))) 31 | { 32 | const auto& Settings = GraphPrinter::GetSettings(); 33 | if (!Settings.bIsIncludeWidgetInfoInImageFile) 34 | { 35 | bCanEditChange = false; 36 | } 37 | } 38 | } 39 | 40 | return (Super::CanEditChange(InProperty) && bCanEditChange); 41 | } 42 | 43 | FString UDetailsPanelPrinterSettings::GetSettingsName() const 44 | { 45 | return TEXT("DetailsPanelPrinter"); 46 | } 47 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/DetailsPanelPrinter/Private/DetailsPanelPrinter/WidgetPrinters/ActorDetailsPanelPrinter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "DetailsPanelPrinter/WidgetPrinters/ActorDetailsPanelPrinter.h" 4 | #include "DetailsPanelPrinter/WidgetPrinters/InnerDetailsPanelPrinter.h" 5 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 6 | 7 | #if UE_5_01_OR_LATER 8 | #include UE_INLINE_GENERATED_CPP_BY_NAME(ActorDetailsPanelPrinter) 9 | #endif 10 | 11 | UActorDetailsPanelPrinter::UActorDetailsPanelPrinter() 12 | { 13 | #ifndef WITH_DETAILS_PANEL_PRINTER 14 | if (UClass* Class = GetClass()) 15 | { 16 | Class->ClassFlags |= CLASS_Abstract; 17 | } 18 | #endif 19 | } 20 | 21 | int32 UActorDetailsPanelPrinter::GetPriority() const 22 | { 23 | return DetailsPanelPrinterPriority + 1; 24 | } 25 | 26 | #ifdef WITH_DETAILS_PANEL_PRINTER 27 | TOptional UActorDetailsPanelPrinter::CheckIfSupported(const TSharedRef& TestWidget) const 28 | { 29 | const TSharedPtr ActorDetailsPanel = GraphPrinter::FActorDetailsPanelPrinter::FindTargetWidgetFromSearchTarget(TestWidget); 30 | if (!ActorDetailsPanel.IsValid()) 31 | { 32 | return {}; 33 | } 34 | 35 | const TSharedPtr DetailsPanel = GraphPrinter::FDetailsPanelPrinterUtils::FindNearestChildDetailsView(ActorDetailsPanel); 36 | if (!DetailsPanel.IsValid()) 37 | { 38 | return {}; 39 | } 40 | 41 | const FString& EditingActorName = GraphPrinter::FActorDetailsPanelPrinter::GetEditingActorName(DetailsPanel); 42 | return GraphPrinter::FSupportedWidget(ActorDetailsPanel.ToSharedRef(), EditingActorName, GetPriority()); 43 | } 44 | 45 | TSharedRef UActorDetailsPanelPrinter::CreatePrintModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const 46 | { 47 | return MakeShared( 48 | GetPrintOptions(), 49 | OnPrinterProcessingFinished 50 | ); 51 | } 52 | 53 | TSharedRef UActorDetailsPanelPrinter::CreateRestoreModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const 54 | { 55 | return MakeShared( 56 | GetRestoreOptions(), 57 | OnPrinterProcessingFinished 58 | ); 59 | } 60 | #endif 61 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/DetailsPanelPrinter/Private/DetailsPanelPrinter/WidgetPrinters/DetailsPanelPrinter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "DetailsPanelPrinter/WidgetPrinters/DetailsPanelPrinter.h" 4 | #include "DetailsPanelPrinter/Utilities/DetailsPanelPrinterSettings.h" 5 | #include "DetailsPanelPrinter/Types/PrintDetailsPanelOptions.h" 6 | #include "DetailsPanelPrinter/Types/RestoreDetailsPanelOptions.h" 7 | #include "DetailsPanelPrinter/WidgetPrinters/InnerDetailsPanelPrinter.h" 8 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 9 | 10 | #if UE_5_01_OR_LATER 11 | #include UE_INLINE_GENERATED_CPP_BY_NAME(DetailsPanelPrinter) 12 | #endif 13 | 14 | UDetailsPanelPrinter::UDetailsPanelPrinter() 15 | { 16 | #ifndef WITH_DETAILS_PANEL_PRINTER 17 | if (UClass* Class = GetClass()) 18 | { 19 | Class->ClassFlags |= CLASS_Abstract; 20 | } 21 | #endif 22 | } 23 | 24 | int32 UDetailsPanelPrinter::GetPriority() const 25 | { 26 | return DetailsPanelPrinterPriority; 27 | } 28 | 29 | #ifdef WITH_DETAILS_PANEL_PRINTER 30 | TOptional UDetailsPanelPrinter::CheckIfSupported(const TSharedRef& TestWidget) const 31 | { 32 | const TSharedPtr DetailsPanel = GraphPrinter::FDetailsPanelPrinter::FindTargetWidgetFromSearchTarget(TestWidget); 33 | if (!DetailsPanel.IsValid()) 34 | { 35 | return {}; 36 | } 37 | 38 | const FString& EditingObjectName = GraphPrinter::FDetailsPanelPrinter::GetEditingObjectName(DetailsPanel); 39 | return GraphPrinter::FSupportedWidget(DetailsPanel.ToSharedRef(), EditingObjectName, GetPriority()); 40 | } 41 | #endif 42 | 43 | UPrintWidgetOptions* UDetailsPanelPrinter::CreateDefaultPrintOptions( 44 | const UPrintWidgetOptions::EPrintScope PrintScope, 45 | const UPrintWidgetOptions::EExportMethod ExportMethod 46 | ) const 47 | { 48 | if (UPrintWidgetOptions* PrintWidgetOptions = Super::CreateDefaultPrintOptions(PrintScope, ExportMethod)) 49 | { 50 | if (auto* PrintGraphOptions = PrintWidgetOptions->Duplicate()) 51 | { 52 | const auto& Settings = GraphPrinter::GetSettings(); 53 | 54 | PrintGraphOptions->Padding = Settings.Padding; 55 | PrintGraphOptions->bIsIncludeExpansionStateInImageFile = Settings.bIsIncludeExpansionStateInImageFile; 56 | 57 | return PrintGraphOptions; 58 | } 59 | } 60 | 61 | return nullptr; 62 | } 63 | 64 | URestoreWidgetOptions* UDetailsPanelPrinter::CreateDefaultRestoreOptions() const 65 | { 66 | if (URestoreWidgetOptions* RestoreWidgetOptions = Super::CreateDefaultRestoreOptions()) 67 | { 68 | if (auto* RestoreDetailsPanelOptions = RestoreWidgetOptions->Duplicate()) 69 | { 70 | const auto& Settings = GraphPrinter::GetSettings(); 71 | 72 | RestoreDetailsPanelOptions->bWhetherToAlsoRestoreExpandedStates = Settings.bWhetherToAlsoRestoreExpandedStates; 73 | 74 | return RestoreDetailsPanelOptions; 75 | } 76 | } 77 | 78 | return nullptr; 79 | } 80 | 81 | #ifdef WITH_DETAILS_PANEL_PRINTER 82 | TSharedRef UDetailsPanelPrinter::CreatePrintModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const 83 | { 84 | return MakeShared( 85 | GetPrintOptions(), 86 | OnPrinterProcessingFinished 87 | ); 88 | } 89 | 90 | TSharedRef UDetailsPanelPrinter::CreateRestoreModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const 91 | { 92 | return MakeShared( 93 | GetRestoreOptions(), 94 | OnPrinterProcessingFinished 95 | ); 96 | } 97 | #endif 98 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/DetailsPanelPrinter/Public/DetailsPanelPrinter/Types/PrintDetailsPanelOptions.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "WidgetPrinter/Types/PrintWidgetOptions.h" 7 | #include "PrintDetailsPanelOptions.generated.h" 8 | 9 | /** 10 | * An optional class to specify when printing the details panel. 11 | */ 12 | UCLASS() 13 | class DETAILSPANELPRINTER_API UPrintDetailsPanelOptions : public UPrintWidgetOptions 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | // Constructor. 19 | UPrintDetailsPanelOptions(); 20 | 21 | // UPrintWidgetOptions interface. 22 | virtual UPrintWidgetOptions* Duplicate(const TSubclassOf& DestinationClass) const override; 23 | // End of UPrintWidgetOptions interface. 24 | 25 | public: 26 | // The height margin when drawing the details view. 27 | float Padding; 28 | 29 | // Whether to embed the expanded state of each item in the image file and restore the expanded state of each item when restoring. 30 | bool bIsIncludeExpansionStateInImageFile; 31 | }; 32 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/DetailsPanelPrinter/Public/DetailsPanelPrinter/Types/RestoreDetailsPanelOptions.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "WidgetPrinter/Types/RestoreWidgetOptions.h" 7 | #include "RestoreDetailsPanelOptions.generated.h" 8 | 9 | /** 10 | * An optional class to specify when restore the state of the details panel. 11 | */ 12 | UCLASS() 13 | class DETAILSPANELPRINTER_API URestoreDetailsPanelOptions : public URestoreWidgetOptions 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | // Constructor. 19 | URestoreDetailsPanelOptions(); 20 | 21 | // URestoreWidgetOptions interface. 22 | virtual URestoreWidgetOptions* Duplicate(const TSubclassOf& DestinationClass) const override; 23 | // End of URestoreWidgetOptions interface. 24 | 25 | public: 26 | // Whether to also restore the expanded state when restoring. 27 | bool bWhetherToAlsoRestoreExpandedStates; 28 | }; 29 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/DetailsPanelPrinter/Public/DetailsPanelPrinter/Utilities/DetailsPanelPrinterSettings.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GraphPrinterGlobals/Utilities/GraphPrinterSettings.h" 7 | #include "DetailsPanelPrinterSettings.generated.h" 8 | 9 | /** 10 | * A class that sets the default values for UPrintDetailsPanelOptions from the editor preferences. 11 | */ 12 | UCLASS() 13 | class DETAILSPANELPRINTER_API UDetailsPanelPrinterSettings : public UGraphPrinterSettings 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | // The height margin when drawing the details view. 19 | UPROPERTY(EditAnywhere, Config, Category = "Image", meta = (UIMin = 0.f, ClampMin = 0.f)) 20 | float Padding; 21 | 22 | // Whether to embed the expanded state of each item in the image file and restore the expanded state of each item when restoring. 23 | UPROPERTY(EditAnywhere, Config, Category = "Expansion State") 24 | bool bIsIncludeExpansionStateInImageFile; 25 | 26 | // Whether to also restore the expanded state when restoring. 27 | UPROPERTY(EditAnywhere, Config, Category = "Expansion State") 28 | bool bWhetherToAlsoRestoreExpandedStates; 29 | 30 | public: 31 | // Constructor. 32 | UDetailsPanelPrinterSettings(); 33 | 34 | // UObject interface. 35 | virtual bool CanEditChange(const FProperty* InProperty) const override; 36 | // End of UObject interface. 37 | 38 | // UGraphPrinterSettings interface. 39 | virtual FString GetSettingsName() const override; 40 | // End of UGraphPrinterSettings interface. 41 | }; 42 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/DetailsPanelPrinter/Public/DetailsPanelPrinter/Utilities/DetailsPanelPrinterUtils.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | class SWidget; 8 | class SDetailsView; 9 | class SActorDetails; 10 | class FJsonObject; 11 | 12 | namespace GraphPrinter 13 | { 14 | /** 15 | * A utility class that defines utility functions used in details panel printer classes. 16 | */ 17 | class DETAILSPANELPRINTER_API FDetailsPanelPrinterUtils 18 | { 19 | public: 20 | // Finds the widget that is the details view and nearest child of SearchTarget. 21 | static TSharedPtr FindNearestChildDetailsView(const TSharedPtr& SearchTarget); 22 | 23 | // Returns the details view contained in the currently active tab. 24 | static TSharedPtr GetActiveDetailsView(); 25 | 26 | // Finds the widget that is the actor details view and nearest child of SearchTarget. 27 | static TSharedPtr FindNearestChildActorDetailsView(const TSharedPtr& SearchTarget); 28 | 29 | // Returns the actor details view contained in the currently active tab. 30 | static TSharedPtr GetActiveActorDetailsView(); 31 | 32 | // Finds the widget that is the subobject instance editor and nearest child of SearchTarget. 33 | static TSharedPtr FindNearestChildSubobjectInstanceEditor(const TSharedPtr& SearchTarget); 34 | 35 | // Returns the difference between the widget's actual visible size and its overall size. 36 | static FVector2D GetDifferenceBetweenWidgetLocalSizeAndDesiredSize(TSharedPtr Widget); 37 | 38 | // Imports properties of UObject from Json formatted string. 39 | static bool ImportObjectPropertiesFromJsonString(UObject* Object, const FString& JsonString); 40 | 41 | // Exports properties of UObject as Json formatted string. 42 | static bool ExportObjectPropertiesAsJsonString(UObject* Object, FString& JsonString); 43 | 44 | // Writes all properties recorded in the json object to the UObject and returns the number of properties read. 45 | static int32 JsonObjectToUObject(UObject& Object, const TSharedRef& JsonObject); 46 | 47 | // Writes all properties that match the specified flags of the UObject to the json object and returns the number of properties written. 48 | static int32 UObjectToJsonObject( 49 | UObject& Object, 50 | const TSharedRef& JsonObject, 51 | const int64 CheckFlags = 0, 52 | const int64 SkipFlags = 0 53 | ); 54 | }; 55 | } 56 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/DetailsPanelPrinter/Public/DetailsPanelPrinter/WidgetPrinters/ActorDetailsPanelPrinter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "DetailsPanelPrinter/WidgetPrinters/DetailsPanelPrinter.h" 7 | #include "ActorDetailsPanelPrinter.generated.h" 8 | 9 | /** 10 | * A printer class for the actor details panel. 11 | */ 12 | UCLASS() 13 | class DETAILSPANELPRINTER_API UActorDetailsPanelPrinter : public UDetailsPanelPrinter 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | // Constructor. 19 | UActorDetailsPanelPrinter(); 20 | 21 | // UWidgetPrinter interface. 22 | virtual int32 GetPriority() const override; 23 | #ifdef WITH_DETAILS_PANEL_PRINTER 24 | virtual TOptional CheckIfSupported(const TSharedRef& TestWidget) const override; 25 | virtual TSharedRef CreatePrintModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const override; 26 | virtual TSharedRef CreateRestoreModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const override; 27 | #endif 28 | // End of UWidgetPrinter interface. 29 | }; 30 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/DetailsPanelPrinter/Public/DetailsPanelPrinter/WidgetPrinters/DetailsPanelPrinter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "WidgetPrinter/WidgetPrinters/WidgetPrinter.h" 7 | #include "DetailsPanelPrinter.generated.h" 8 | 9 | /** 10 | * A printer class for the details panel. 11 | */ 12 | UCLASS() 13 | class DETAILSPANELPRINTER_API UDetailsPanelPrinter : public UWidgetPrinter 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | // The priority of this widget printer. 19 | static constexpr int32 DetailsPanelPrinterPriority = 200; 20 | 21 | public: 22 | // Constructor. 23 | UDetailsPanelPrinter(); 24 | 25 | // UWidgetPrinter interface. 26 | virtual int32 GetPriority() const override; 27 | #ifdef WITH_DETAILS_PANEL_PRINTER 28 | virtual TOptional CheckIfSupported(const TSharedRef& TestWidget) const override; 29 | #endif 30 | virtual UPrintWidgetOptions* CreateDefaultPrintOptions( 31 | const UPrintWidgetOptions::EPrintScope PrintScope, 32 | const UPrintWidgetOptions::EExportMethod ExportMethod 33 | ) const override; 34 | virtual URestoreWidgetOptions* CreateDefaultRestoreOptions() const override; 35 | #ifdef WITH_DETAILS_PANEL_PRINTER 36 | virtual TSharedRef CreatePrintModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const override; 37 | virtual TSharedRef CreateRestoreModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const override; 38 | #endif 39 | // End of UWidgetPrinter interface. 40 | }; 41 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GenericGraphPrinter/GenericGraphPrinter.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | using System.IO; 4 | using UnrealBuildTool; 5 | 6 | public class GenericGraphPrinter : ModuleRules 7 | { 8 | public GenericGraphPrinter(ReadOnlyTargetRules Target) : base(Target) 9 | { 10 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 11 | #if UE_5_2_OR_LATER 12 | IncludeOrderVersion = EngineIncludeOrderVersion.Latest; 13 | #endif 14 | 15 | PublicDependencyModuleNames.AddRange( 16 | new string[] 17 | { 18 | "Core", 19 | } 20 | ); 21 | 22 | PrivateDependencyModuleNames.AddRange( 23 | new string[] 24 | { 25 | "CoreUObject", 26 | "UMG", 27 | "Slate", 28 | "SlateCore", 29 | "Engine", 30 | "UnrealEd", 31 | "MainFrame", 32 | "RenderCore", 33 | 34 | "GraphPrinterGlobals", 35 | "WidgetPrinter", 36 | "TextChunkHelper", 37 | "ClipboardImageExtension", 38 | } 39 | ); 40 | 41 | PublicIncludePaths.AddRange( 42 | new string[] 43 | { 44 | #if UE_5_2_OR_LATER 45 | // In UHT for UE5.2 and later, when you use PublicIncludePaths, the base path of the module's include will be replaced with the first value, so add the correct base path of the include first. 46 | Path.Combine(ModuleDirectory, ".."), 47 | #endif 48 | // To use SGraphEditorImpl. 49 | Path.Combine(EngineDirectory, "Source", "Editor", "GraphEditor", "Private"), 50 | } 51 | ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GenericGraphPrinter/Private/GenericGraphPrinter/GenericGraphPrinterModule.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "CoreMinimal.h" 4 | #include "Modules/ModuleManager.h" 5 | 6 | namespace GraphPrinter 7 | { 8 | class FGenericGraphPrinterModule : public IModuleInterface 9 | { 10 | public: 11 | // IModuleInterface interface. 12 | virtual void StartupModule() override; 13 | virtual void ShutdownModule() override; 14 | // End of IModuleInterface interface. 15 | }; 16 | 17 | void FGenericGraphPrinterModule::StartupModule() 18 | { 19 | } 20 | 21 | void FGenericGraphPrinterModule::ShutdownModule() 22 | { 23 | } 24 | } 25 | 26 | IMPLEMENT_MODULE(GraphPrinter::FGenericGraphPrinterModule, GenericGraphPrinter) 27 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GenericGraphPrinter/Private/GenericGraphPrinter/Types/PrintGraphOptions.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "GenericGraphPrinter/Types/PrintGraphOptions.h" 4 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 5 | 6 | #if UE_5_01_OR_LATER 7 | #include UE_INLINE_GENERATED_CPP_BY_NAME(PrintGraphOptions) 8 | #endif 9 | 10 | UPrintGraphOptions::UPrintGraphOptions() 11 | : Super() 12 | , Padding(0.f) 13 | , bDrawOnlyGraph(false) 14 | { 15 | } 16 | 17 | UPrintWidgetOptions* UPrintGraphOptions::Duplicate(const TSubclassOf& DestinationClass) const 18 | { 19 | auto* Destination = Super::Duplicate(DestinationClass); 20 | if (auto* CastedDestination = Cast(Destination)) 21 | { 22 | CastedDestination->Padding = Padding; 23 | CastedDestination->bDrawOnlyGraph = bDrawOnlyGraph; 24 | } 25 | 26 | return Destination; 27 | } 28 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GenericGraphPrinter/Private/GenericGraphPrinter/Utilities/GenericGraphPrinterSettings.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "GenericGraphPrinter/Utilities/GenericGraphPrinterSettings.h" 4 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 5 | 6 | #if UE_5_01_OR_LATER 7 | #include UE_INLINE_GENERATED_CPP_BY_NAME(GenericGraphPrinterSettings) 8 | #endif 9 | 10 | UGenericGraphPrinterSettings::UGenericGraphPrinterSettings() 11 | : Padding(100.f) 12 | , bDrawOnlyGraph(false) 13 | { 14 | } 15 | 16 | FString UGenericGraphPrinterSettings::GetSettingsName() const 17 | { 18 | return TEXT("GenericGraphPrinter"); 19 | } 20 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GenericGraphPrinter/Private/GenericGraphPrinter/Utilities/GenericGraphPrinterUtils.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "GenericGraphPrinter/Utilities/GenericGraphPrinterUtils.h" 4 | #include "WidgetPrinter/Utilities/WidgetPrinterUtils.h" 5 | #include "WidgetPrinter/Utilities/CastSlateWidget.h" 6 | #include "Framework/Docking/TabManager.h" 7 | #include "Framework/Application/SlateApplication.h" 8 | #include "SGraphEditorImpl.h" 9 | #include "Widgets/Text/STextBlock.h" 10 | #include "Widgets/Docking/SDockTab.h" 11 | 12 | namespace GraphPrinter 13 | { 14 | namespace GenericGraphPrinterUtilsConstant 15 | { 16 | // The name of the minimap widget class. 17 | static const FName GraphMinimapClassName = TEXT("SGraphMinimap"); 18 | } 19 | 20 | TSharedPtr FGenericGraphPrinterUtils::FindNearestChildGraphEditor(const TSharedPtr& SearchTarget) 21 | { 22 | TSharedPtr FoundGraphEditor = GP_CAST_SLATE_WIDGET(SGraphEditorImpl, SearchTarget); 23 | if (!FoundGraphEditor.IsValid()) 24 | { 25 | FWidgetPrinterUtils::EnumerateChildWidgets( 26 | SearchTarget, 27 | [&FoundGraphEditor](const TSharedPtr ChildWidget) -> bool 28 | { 29 | const TSharedPtr GraphEditor = GP_CAST_SLATE_WIDGET(SGraphEditorImpl, ChildWidget); 30 | if (GraphEditor.IsValid()) 31 | { 32 | FoundGraphEditor = GraphEditor; 33 | return false; 34 | } 35 | 36 | return true; 37 | } 38 | ); 39 | } 40 | 41 | return FoundGraphEditor; 42 | } 43 | 44 | TSharedPtr FGenericGraphPrinterUtils::GetActiveGraphEditor() 45 | { 46 | const TSharedRef GlobalTabManager = FGlobalTabmanager::Get(); 47 | const TSharedPtr ActiveTab = GlobalTabManager->GetActiveTab(); 48 | if (ActiveTab.IsValid()) 49 | { 50 | const TSharedPtr DockingTabStack = FWidgetPrinterUtils::FindNearestParentDockingTabStack(ActiveTab); 51 | if (DockingTabStack.IsValid()) 52 | { 53 | TSharedPtr GraphEditor = FindNearestChildGraphEditor(DockingTabStack); 54 | if (GraphEditor.IsValid()) 55 | { 56 | return GraphEditor; 57 | } 58 | } 59 | } 60 | 61 | const TSharedPtr ActiveWindow = FSlateApplication::Get().GetActiveTopLevelWindow(); 62 | if (ActiveWindow.IsValid()) 63 | { 64 | return FindNearestChildGraphEditor(ActiveWindow); 65 | } 66 | 67 | return nullptr; 68 | } 69 | 70 | TSharedPtr FGenericGraphPrinterUtils::FindNearestChildMinimap(const TSharedPtr& SearchTarget) 71 | { 72 | TSharedPtr FoundMinimap = Private::CastSlateWidget( 73 | SearchTarget, 74 | GenericGraphPrinterUtilsConstant::GraphMinimapClassName 75 | ); 76 | if (!FoundMinimap.IsValid()) 77 | { 78 | FWidgetPrinterUtils::EnumerateChildWidgets( 79 | SearchTarget, 80 | [&FoundMinimap](const TSharedPtr& ChildWidget) -> bool 81 | { 82 | const TSharedPtr Minimap = Private::CastSlateWidget( 83 | ChildWidget, 84 | GenericGraphPrinterUtilsConstant::GraphMinimapClassName 85 | ); 86 | if (Minimap.IsValid()) 87 | { 88 | FoundMinimap = Minimap; 89 | return false; 90 | } 91 | 92 | return true; 93 | } 94 | ); 95 | } 96 | 97 | return FoundMinimap; 98 | } 99 | 100 | TArray> FGenericGraphPrinterUtils::GetVisibleChildTextBlocks(const TSharedPtr& SearchTarget) 101 | { 102 | if (!SearchTarget.IsValid()) 103 | { 104 | return {}; 105 | } 106 | 107 | FChildren* Children = SearchTarget->GetChildren(); 108 | if (Children == nullptr) 109 | { 110 | return {}; 111 | } 112 | 113 | TArray> VisibleChildTextBlocks; 114 | for (int32 Index = 0; Index < Children->Num(); Index++) 115 | { 116 | const TSharedPtr ChildWidget = Children->GetChildAt(Index); 117 | TSharedPtr TextBlock = GP_CAST_SLATE_WIDGET(STextBlock, ChildWidget); 118 | if (TextBlock.IsValid()) 119 | { 120 | if (TextBlock->GetVisibility().IsVisible()) 121 | { 122 | VisibleChildTextBlocks.Add(TextBlock); 123 | } 124 | } 125 | } 126 | 127 | return VisibleChildTextBlocks; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GenericGraphPrinter/Private/GenericGraphPrinter/WidgetPrinters/GenericGraphPrinter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "GenericGraphPrinter/WidgetPrinters/GenericGraphPrinter.h" 4 | #include "GenericGraphPrinter/Types/PrintGraphOptions.h" 5 | #include "GenericGraphPrinter/Utilities/GenericGraphPrinterSettings.h" 6 | #include "GenericGraphPrinter/WidgetPrinters/InnerGenericGraphPrinter.h" 7 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 8 | 9 | #if UE_5_01_OR_LATER 10 | #include UE_INLINE_GENERATED_CPP_BY_NAME(GenericGraphPrinter) 11 | #endif 12 | 13 | int32 UGenericGraphPrinter::GetPriority() const 14 | { 15 | return GenericGraphPrinterPriority; 16 | } 17 | 18 | TOptional UGenericGraphPrinter::CheckIfSupported(const TSharedRef& TestWidget) const 19 | { 20 | const TSharedPtr GraphEditor = GraphPrinter::FGenericGraphPrinter::FindTargetWidgetFromSearchTarget(TestWidget); 21 | if (!GraphEditor.IsValid()) 22 | { 23 | return {}; 24 | } 25 | 26 | FString GraphTitle; 27 | if (!GraphPrinter::FGenericGraphPrinter::GetGraphTitle(GraphEditor, GraphTitle)) 28 | { 29 | return {}; 30 | } 31 | 32 | return GraphPrinter::FSupportedWidget(GraphEditor.ToSharedRef(), GraphTitle, GetPriority()); 33 | } 34 | 35 | UPrintWidgetOptions* UGenericGraphPrinter::CreateDefaultPrintOptions( 36 | const UPrintWidgetOptions::EPrintScope PrintScope, 37 | const UPrintWidgetOptions::EExportMethod ExportMethod 38 | ) const 39 | { 40 | if (UPrintWidgetOptions* PrintWidgetOptions = Super::CreateDefaultPrintOptions(PrintScope, ExportMethod)) 41 | { 42 | if (auto* PrintGraphOptions = PrintWidgetOptions->Duplicate()) 43 | { 44 | const auto& Settings = GraphPrinter::GetSettings(); 45 | 46 | PrintGraphOptions->Padding = Settings.Padding; 47 | PrintGraphOptions->bDrawOnlyGraph = Settings.bDrawOnlyGraph; 48 | 49 | return PrintGraphOptions; 50 | } 51 | } 52 | 53 | return nullptr; 54 | } 55 | 56 | TSharedRef UGenericGraphPrinter::CreatePrintModeInnerPrinter( const FSimpleDelegate& OnPrinterProcessingFinished) const 57 | { 58 | return MakeShared( 59 | GetPrintOptions(), 60 | OnPrinterProcessingFinished 61 | ); 62 | } 63 | 64 | TSharedRef UGenericGraphPrinter::CreateRestoreModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const 65 | { 66 | return MakeShared( 67 | GetRestoreOptions(), 68 | OnPrinterProcessingFinished 69 | ); 70 | } 71 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GenericGraphPrinter/Public/GenericGraphPrinter/Types/PrintGraphOptions.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "WidgetPrinter/Types/PrintWidgetOptions.h" 7 | #include "PrintGraphOptions.generated.h" 8 | 9 | /** 10 | * An optional class to specify when printing the graph editor. 11 | */ 12 | UCLASS() 13 | class GENERICGRAPHPRINTER_API UPrintGraphOptions : public UPrintWidgetOptions 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | // Constructor. 19 | UPrintGraphOptions(); 20 | 21 | // UPrintWidgetOptions interface. 22 | virtual UPrintWidgetOptions* Duplicate(const TSubclassOf& DestinationClass) const override; 23 | // End of UPrintWidgetOptions interface. 24 | 25 | public: 26 | // The margins when drawing the graph editor. 27 | float Padding; 28 | 29 | // Whether to hide the title bar of the graph editor and the text of the graph type in the lower right. 30 | bool bDrawOnlyGraph; 31 | }; 32 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GenericGraphPrinter/Public/GenericGraphPrinter/Utilities/GenericGraphPrinterSettings.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GraphPrinterGlobals/Utilities/GraphPrinterSettings.h" 7 | #include "GenericGraphPrinterSettings.generated.h" 8 | 9 | /** 10 | * A class that sets the default values for UPrintGraphOptions from the editor preferences. 11 | */ 12 | UCLASS() 13 | class UGenericGraphPrinterSettings : public UGraphPrinterSettings 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | // The wide margin when drawing the graph editor. 19 | UPROPERTY(EditAnywhere, Config, Category = "Image", meta = (UIMin = 0.f, ClampMin = 0.f)) 20 | float Padding; 21 | 22 | // Whether to hide the title bar of the graph editor and the text of the graph type in the lower right. 23 | UPROPERTY(EditAnywhere, Config, Category = "Image") 24 | bool bDrawOnlyGraph; 25 | 26 | public: 27 | // Constructor. 28 | UGenericGraphPrinterSettings(); 29 | 30 | // UGraphPrinterSettings interface. 31 | virtual FString GetSettingsName() const override; 32 | // End of UGraphPrinterSettings interface. 33 | }; 34 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GenericGraphPrinter/Public/GenericGraphPrinter/Utilities/GenericGraphPrinterUtils.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | class SWidget; 8 | class STextBlock; 9 | class SGraphEditorImpl; 10 | 11 | namespace GraphPrinter 12 | { 13 | /** 14 | * A utility class that defines utility functions used in generic graph printer classes. 15 | */ 16 | class GENERICGRAPHPRINTER_API FGenericGraphPrinterUtils 17 | { 18 | public: 19 | // Finds the widget that is the graph editor and nearest child of SearchTarget. 20 | static TSharedPtr FindNearestChildGraphEditor(const TSharedPtr& SearchTarget); 21 | 22 | // Returns the graph editor contained in the currently active tab. 23 | static TSharedPtr GetActiveGraphEditor(); 24 | 25 | // Returns a minimap if it was a child of the graph editor. 26 | // What to do if GraphMinimap is installed. 27 | static TSharedPtr FindNearestChildMinimap(const TSharedPtr& SearchTarget); 28 | 29 | // Returns the displayed text blocks that are children of SearchTarget. 30 | static TArray> GetVisibleChildTextBlocks(const TSharedPtr& SearchTarget); 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GenericGraphPrinter/Public/GenericGraphPrinter/WidgetPrinters/GenericGraphPrinter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "WidgetPrinter/WidgetPrinters/WidgetPrinter.h" 7 | #include "GenericGraphPrinter.generated.h" 8 | 9 | /** 10 | * A general-purpose printer class for the graph editor. 11 | */ 12 | UCLASS() 13 | class GENERICGRAPHPRINTER_API UGenericGraphPrinter : public UWidgetPrinter 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | // The priority of this widget printer. 19 | static constexpr int32 GenericGraphPrinterPriority = 0; 20 | 21 | public: 22 | // UWidgetPrinter interface. 23 | virtual int32 GetPriority() const override; 24 | virtual TOptional CheckIfSupported(const TSharedRef& TestWidget) const override; 25 | virtual UPrintWidgetOptions* CreateDefaultPrintOptions( 26 | const UPrintWidgetOptions::EPrintScope PrintScope, 27 | const UPrintWidgetOptions::EExportMethod ExportMethod 28 | ) const override; 29 | virtual TSharedRef CreatePrintModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const override; 30 | virtual TSharedRef CreateRestoreModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const override; 31 | // End of UWidgetPrinter interface. 32 | }; 33 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterEditorExtension/GraphPrinterEditorExtension.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class GraphPrinterEditorExtension : ModuleRules 6 | { 7 | public GraphPrinterEditorExtension(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 10 | #if UE_5_2_OR_LATER 11 | IncludeOrderVersion = EngineIncludeOrderVersion.Latest; 12 | #endif 13 | 14 | PublicDependencyModuleNames.AddRange( 15 | new string[] 16 | { 17 | "Core", 18 | } 19 | ); 20 | 21 | PrivateDependencyModuleNames.AddRange( 22 | new string[] 23 | { 24 | "CoreUObject", 25 | "InputCore", 26 | "UnrealEd", 27 | "Engine", 28 | "Slate", 29 | "SlateCore", 30 | "EditorStyle", 31 | "Projects", 32 | "MainFrame", 33 | "ToolMenus", 34 | 35 | "GraphPrinterGlobals", 36 | "WidgetPrinter", 37 | "TextChunkHelper", 38 | "ClipboardImageExtension", 39 | "GraphPrinterStreamDeck", 40 | } 41 | ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterEditorExtension/Private/GraphPrinterEditorExtension/CommandActions/GraphPrinterCommandActions.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | namespace GraphPrinter 8 | { 9 | /** 10 | * A class that defines the function executed from the shortcut key. 11 | */ 12 | class GRAPHPRINTEREDITOREXTENSION_API FGraphPrinterCommandActions 13 | { 14 | public: 15 | #ifdef WITH_CLIPBOARD_IMAGE_EXTENSION 16 | // Copies the entire target widget as an image to the clipboard. 17 | static void CopyAllAreaOfWidgetToClipboard(); 18 | static bool CanCopyAllAreaOfWidgetToClipboard(); 19 | 20 | // Copies the selected area of the target widget to the clipboard as an image. 21 | static void CopySelectedAreaOfWidgetToClipboard(); 22 | static bool CanCopySelectedAreaOfWidgetToClipboard(); 23 | #endif 24 | 25 | // Outputs the entire target widget as an image file. 26 | static void PrintAllAreaOfWidget(); 27 | static bool CanPrintAllAreaOfWidget(); 28 | 29 | // Outputs the selected area of the target widget as an image file. 30 | static void PrintSelectedAreaOfWidget(); 31 | static bool CanPrintSelectedAreaOfWidget(); 32 | 33 | #ifdef WITH_TEXT_CHUNK_HELPER 34 | // Restores the state of the widget from the image file. 35 | // You can only restore from images output from this plugin. 36 | static void RestoreWidgetFromImageFile(); 37 | static bool CanExecuteRestoreWidget(); 38 | #endif 39 | 40 | // Opens the folder containing the images saved by this plugin in explorer. 41 | static void OpenExportDestinationFolder(); 42 | static bool CanOpenExportDestinationFolder(); 43 | }; 44 | } -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterEditorExtension/Private/GraphPrinterEditorExtension/GraphPrinterEditorExtensionModule.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "CoreMinimal.h" 4 | #include "Modules/ModuleManager.h" 5 | #include "GraphPrinterEditorExtension/Utilities/GraphPrinterStyle.h" 6 | #include "GraphPrinterEditorExtension/CommandActions/GraphPrinterCommands.h" 7 | 8 | namespace GraphPrinter 9 | { 10 | class FGraphPrinterEditorExtensionModule : public IModuleInterface 11 | { 12 | public: 13 | // IModuleInterface interface. 14 | virtual void StartupModule() override; 15 | virtual void ShutdownModule() override; 16 | // End of IModuleInterface interface. 17 | }; 18 | 19 | void FGraphPrinterEditorExtensionModule::StartupModule() 20 | { 21 | // Registers style set. 22 | FGraphPrinterStyle::Register(); 23 | 24 | // Registers command actions. 25 | FGraphPrinterCommands::Register(); 26 | FGraphPrinterCommands::Bind(); 27 | } 28 | 29 | void FGraphPrinterEditorExtensionModule::ShutdownModule() 30 | { 31 | // Unregisters command actions. 32 | FGraphPrinterCommands::Unregister(); 33 | 34 | // Unregisters style set. 35 | FGraphPrinterStyle::Unregister(); 36 | } 37 | } 38 | 39 | IMPLEMENT_MODULE(GraphPrinter::FGraphPrinterEditorExtensionModule, GraphPrinterEditorExtension) 40 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterEditorExtension/Private/GraphPrinterEditorExtension/UIExtensions/AutoToolMenuExtender.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "GraphPrinterEditorExtension/UIExtensions/AutoToolMenuExtender.h" 4 | #include "Misc/DelayedAutoRegister.h" 5 | 6 | namespace GraphPrinter 7 | { 8 | FAutoToolMenuExtender::FAutoToolMenuExtender() 9 | { 10 | DelayedAutoRegister = FDelayedAutoRegisterHelper( 11 | EDelayedRegisterRunPhase::EndOfEngineInit, 12 | [this]() 13 | { 14 | UToolMenus::RegisterStartupCallback( 15 | FSimpleMulticastDelegate::FDelegate::CreateRaw(this, &FAutoToolMenuExtender::ExtendToolMenu) 16 | ); 17 | } 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterEditorExtension/Private/GraphPrinterEditorExtension/UIExtensions/StatusBarExtender.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "CoreMinimal.h" 4 | #include "GraphPrinterEditorExtension/UIExtensions/AutoToolMenuExtender.h" 5 | #include "GraphPrinterEditorExtension/UIExtensions/ToolMenuExtensionConstants.h" 6 | #include "GraphPrinterEditorExtension/CommandActions/GraphPrinterCommands.h" 7 | #include "GraphPrinterEditorExtension/Utilities/GraphPrinterStyle.h" 8 | #include "GraphPrinterEditorExtension/Utilities/GraphPrinterEditorExtensionSettings.h" 9 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 10 | #include "Interfaces/IMainFrameModule.h" 11 | #include "Subsystems/AssetEditorSubsystem.h" 12 | #include "Toolkits/AssetEditorToolkit.h" 13 | 14 | #define LOCTEXT_NAMESPACE "StatusBarExtender" 15 | 16 | #if UE_5_00_OR_LATER 17 | namespace GraphPrinter 18 | { 19 | class FStatusBarExtension : public FAutoToolMenuExtender 20 | { 21 | private: 22 | // FAutoToolMenuExtender interface. 23 | virtual void ExtendToolMenu() override 24 | { 25 | const auto& Settings = GetSettings(); 26 | if (!Settings.bShowComboButtonInStatusBar) 27 | { 28 | return; 29 | } 30 | 31 | ExtendStatusBar(TEXT("LevelEditor.StatusBar.ToolBar")); 32 | 33 | IMainFrameModule::Get().OnMainFrameCreationFinished().AddStatic(&FStatusBarExtension::HandleOnMainFrameCreationFinished); 34 | } 35 | // End of FAutoToolMenuExtender interface. 36 | 37 | // Called when the editor mainframe has been created. 38 | static void HandleOnMainFrameCreationFinished(TSharedPtr InRootWindow, bool bIsNewProjectWindow) 39 | { 40 | if (auto* AssetEditorSubsystem = GEditor->GetEditorSubsystem()) 41 | { 42 | AssetEditorSubsystem->OnEditorOpeningPreWidgets().AddStatic(&FStatusBarExtension::HandleOnEditorOpeningPreWidgets); 43 | } 44 | } 45 | 46 | // Called when an asset editor is opening and before widgets are constructed. 47 | static void HandleOnEditorOpeningPreWidgets(const TArray& AssetsToEdit, IAssetEditorInstance* AssetEditorInstance) 48 | { 49 | if (AssetEditorInstance == nullptr) 50 | { 51 | return; 52 | } 53 | 54 | FName BuiltStatusBarName; 55 | { 56 | const auto* AssetEditorToolkit = static_cast(AssetEditorInstance); 57 | check(AssetEditorToolkit != nullptr); 58 | const TSharedRef& ToolkitHost = AssetEditorToolkit->GetToolkitHost(); 59 | 60 | const FString StatusBarName = ToolkitHost->GetStatusBarName().ToString(); 61 | FString AssetEditorName; 62 | if (!StatusBarName.Split(TEXT("_"), &AssetEditorName, nullptr)) 63 | { 64 | return; 65 | } 66 | 67 | BuiltStatusBarName = FName(AssetEditorName + TEXT(".ToolBar")); 68 | } 69 | ExtendStatusBar(BuiltStatusBarName); 70 | } 71 | 72 | // Called when the menu is expanded. 73 | static void ExtendStatusBar(const FName& StatusBarName) 74 | { 75 | auto* ToolMenus = UToolMenus::Get(); 76 | if (!IsValid(ToolMenus)) 77 | { 78 | return; 79 | } 80 | 81 | UToolMenu* ToolMenu = ToolMenus->ExtendMenu(StatusBarName); 82 | if (!IsValid(ToolMenu)) 83 | { 84 | return; 85 | } 86 | 87 | FToolMenuSection& ToolMenuSection = ToolMenu->AddSection(Global::PluginName); 88 | ToolMenuSection.AddEntry( 89 | FToolMenuEntry::InitComboButton( 90 | Global::PluginName, 91 | FToolUIActionChoice(), 92 | FNewToolMenuChoice( 93 | FNewToolMenuDelegate::CreateStatic(&FGraphPrinterCommands::FillMenuBuilder) 94 | ), 95 | FText::GetEmpty(), // Currently, if I don't create a combo box myself using Slate, the label will be buried, so I can only use the icon. 96 | ToolMenuExtensionConstants::ToolMenuTooltip, 97 | FGraphPrinterStyle::GetSlateIconFromIconType(EGraphPrinterStyleIconType::PluginIcon) 98 | ) 99 | ); 100 | } 101 | }; 102 | static FStatusBarExtension StatusBarExtension; 103 | } 104 | #endif 105 | 106 | #undef LOCTEXT_NAMESPACE 107 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterEditorExtension/Private/GraphPrinterEditorExtension/UIExtensions/ToolMenuExtender.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "CoreMinimal.h" 4 | #include "GraphPrinterEditorExtension/UIExtensions/AutoToolMenuExtender.h" 5 | #include "GraphPrinterEditorExtension/UIExtensions/ToolMenuExtensionConstants.h" 6 | #include "GraphPrinterEditorExtension/CommandActions/GraphPrinterCommands.h" 7 | #include "GraphPrinterEditorExtension/Utilities/GraphPrinterStyle.h" 8 | #include "GraphPrinterEditorExtension/Utilities/GraphPrinterEditorExtensionSettings.h" 9 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 10 | 11 | #define LOCTEXT_NAMESPACE "ToolMenuExtender" 12 | 13 | namespace GraphPrinter 14 | { 15 | class FToolMenuExtension : public FAutoToolMenuExtender 16 | { 17 | private: 18 | // FAutoToolMenuExtender interface. 19 | virtual void ExtendToolMenu() override 20 | { 21 | const auto& Settings = GetSettings(); 22 | if (!Settings.bShowSubMenuInToolMenu) 23 | { 24 | return; 25 | } 26 | 27 | auto* ToolMenus = UToolMenus::Get(); 28 | check(IsValid(ToolMenus)); 29 | 30 | UToolMenu* ToolsMenu = ToolMenus->ExtendMenu(TEXT("MainFrame.MainMenu.Tools")); 31 | if (!IsValid(ToolsMenu)) 32 | { 33 | return; 34 | } 35 | 36 | FToolMenuSection& ToolsSection = ToolsMenu->FindOrAddSection(TEXT("Tools")); 37 | ToolsSection.AddDynamicEntry( 38 | Global::PluginName, 39 | FNewToolMenuSectionDelegate::CreateLambda( 40 | [](FToolMenuSection& Section) 41 | { 42 | Section.AddSubMenu( 43 | Global::PluginName, 44 | ToolMenuExtensionConstants::ToolMenuLabel, 45 | ToolMenuExtensionConstants::ToolMenuTooltip, 46 | FNewToolMenuDelegate::CreateStatic(&FGraphPrinterCommands::FillMenuBuilder), 47 | false, 48 | FGraphPrinterStyle::GetSlateIconFromIconType(EGraphPrinterStyleIconType::PluginIcon) 49 | ); 50 | } 51 | ) 52 | ); 53 | } 54 | // End of FAutoToolMenuExtender interface. 55 | }; 56 | static FToolMenuExtension ToolMenuExtension; 57 | } 58 | 59 | #undef LOCTEXT_NAMESPACE 60 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterEditorExtension/Private/GraphPrinterEditorExtension/UIExtensions/ToolbarExtender.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "CoreMinimal.h" 4 | #include "GraphPrinterEditorExtension/UIExtensions/AutoToolMenuExtender.h" 5 | #include "GraphPrinterEditorExtension/UIExtensions/ToolMenuExtensionConstants.h" 6 | #include "GraphPrinterEditorExtension/CommandActions/GraphPrinterCommands.h" 7 | #include "GraphPrinterEditorExtension/Utilities/GraphPrinterStyle.h" 8 | #include "GraphPrinterEditorExtension/Utilities/GraphPrinterEditorExtensionSettings.h" 9 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 10 | 11 | #define LOCTEXT_NAMESPACE "ToolbarExtender" 12 | 13 | namespace GraphPrinter 14 | { 15 | class FToolbarExtension : public FAutoToolMenuExtender 16 | { 17 | private: 18 | // FAutoToolMenuExtender interface. 19 | virtual void ExtendToolMenu() override 20 | { 21 | const auto& Settings = GetSettings(); 22 | if (!Settings.bShowComboButtonInToolbar) 23 | { 24 | return; 25 | } 26 | 27 | auto* ToolMenus = UToolMenus::Get(); 28 | check(IsValid(ToolMenus)); 29 | 30 | UToolMenu* AssetEditorToolbarMenu = ToolMenus->ExtendMenu(TEXT("AssetEditor.DefaultToolBar")); 31 | if (!IsValid(AssetEditorToolbarMenu)) 32 | { 33 | return; 34 | } 35 | 36 | FToolMenuSection& AssetSection = AssetEditorToolbarMenu->FindOrAddSection(TEXT("Asset")); 37 | AssetSection.AddEntry( 38 | FToolMenuEntry::InitComboButton( 39 | Global::PluginName, 40 | FToolUIActionChoice(), 41 | FNewToolMenuChoice( 42 | FNewToolMenuDelegate::CreateStatic(&FGraphPrinterCommands::FillMenuBuilder) 43 | ), 44 | ToolMenuExtensionConstants::ToolMenuLabel, 45 | ToolMenuExtensionConstants::ToolMenuTooltip, 46 | FGraphPrinterStyle::GetSlateIconFromIconType(EGraphPrinterStyleIconType::PluginIcon) 47 | ) 48 | ); 49 | } 50 | // End of FAutoToolMenuExtender interface. 51 | }; 52 | static FToolbarExtension ToolbarExtension; 53 | } 54 | 55 | #undef LOCTEXT_NAMESPACE 56 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterEditorExtension/Private/GraphPrinterEditorExtension/Utilities/GraphPrinterEditorExtensionSettings.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "GraphPrinterEditorExtension/Utilities/GraphPrinterEditorExtensionSettings.h" 4 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 5 | 6 | #if UE_5_01_OR_LATER 7 | #include UE_INLINE_GENERATED_CPP_BY_NAME(GraphPrinterEditorExtensionSettings) 8 | #endif 9 | 10 | UGraphPrinterEditorExtensionSettings::UGraphPrinterEditorExtensionSettings() 11 | : bShowSubMenuInToolMenu(true) 12 | , bShowComboButtonInToolbar(true) 13 | , bShowComboButtonInStatusBar(true) 14 | , bCollectTargetWidgetsAutomatically(false) 15 | { 16 | } 17 | 18 | bool UGraphPrinterEditorExtensionSettings::CanEditChange(const FProperty* InProperty) const 19 | { 20 | bool bCanEditChange = true; 21 | if (InProperty != nullptr) 22 | { 23 | if (InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UGraphPrinterEditorExtensionSettings, bShowComboButtonInStatusBar)) 24 | { 25 | #if !UE_5_00_OR_LATER 26 | bCanEditChange = false; 27 | #endif 28 | } 29 | } 30 | 31 | return (Super::CanEditChange(InProperty) && bCanEditChange); 32 | } 33 | 34 | FString UGraphPrinterEditorExtensionSettings::GetSettingsName() const 35 | { 36 | return TEXT("EditorExtension"); 37 | } 38 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterEditorExtension/Private/GraphPrinterEditorExtension/Utilities/GraphPrinterStyle.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "GraphPrinterEditorExtension/Utilities/GraphPrinterStyle.h" 4 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 5 | #include "Interfaces/IPluginManager.h" 6 | #include "Styling/SlateStyleRegistry.h" 7 | #if UE_5_00_OR_LATER 8 | #include "Styling/SlateStyleMacros.h" 9 | #include "Styling/CoreStyle.h" 10 | #endif 11 | #include "Textures/SlateIcon.h" 12 | #include "Misc/Paths.h" 13 | 14 | namespace GraphPrinter 15 | { 16 | #if !UE_5_00_OR_LATER 17 | namespace CoreStyleConstants 18 | { 19 | static const FVector2D Icon64x64(64.0f, 64.0f); 20 | } 21 | #endif 22 | 23 | FGraphPrinterStyle::FGraphPrinterStyle() 24 | : FSlateStyleSet(TEXT("GraphPrinterStyle")) 25 | { 26 | } 27 | 28 | #if !UE_5_00_OR_LATER 29 | #define IMAGE_BRUSH(RelativePath, ...) FSlateImageBrush(RootToContentDir(RelativePath, TEXT(".png")), __VA_ARGS__) 30 | #endif 31 | 32 | void FGraphPrinterStyle::RegisterInternal() 33 | { 34 | SetCoreContentRoot(FPaths::EngineContentDir()); 35 | { 36 | FString StyleContentRoot; 37 | { 38 | const TSharedPtr Plugin = IPluginManager::Get().FindPlugin(Global::PluginName.ToString()); 39 | check(Plugin.IsValid()); 40 | StyleContentRoot = FPaths::ConvertRelativePathToFull( 41 | Plugin->GetBaseDir() / TEXT("Resources") / TEXT("Icons") 42 | ); 43 | } 44 | SetContentRoot(StyleContentRoot); 45 | } 46 | 47 | auto GetBrushName = [](const FString& Name) -> FString 48 | { 49 | #if UE_5_00_OR_LATER 50 | return FString::Printf(TEXT("Gray%s"), *Name); 51 | #else 52 | return Name; 53 | #endif 54 | }; 55 | 56 | Set( 57 | GetPropertyNameFromIconType(EGraphPrinterStyleIconType::PluginIcon), 58 | new IMAGE_BRUSH( 59 | GetBrushName(TEXT("Plugin128")), 60 | CoreStyleConstants::Icon64x64 61 | ) 62 | ); 63 | Set( 64 | GetPropertyNameFromIconType(EGraphPrinterStyleIconType::CopyAllAreaOfWidgetToClipboard), 65 | new IMAGE_BRUSH( 66 | GetBrushName(TEXT("ClipboardAll128")), 67 | CoreStyleConstants::Icon64x64 68 | ) 69 | ); 70 | Set( 71 | GetPropertyNameFromIconType(EGraphPrinterStyleIconType::CopySelectedAreaOfWidgetToClipboard), 72 | new IMAGE_BRUSH( 73 | GetBrushName(TEXT("ClipboardSelected128")), 74 | CoreStyleConstants::Icon64x64 75 | ) 76 | ); 77 | Set( 78 | GetPropertyNameFromIconType(EGraphPrinterStyleIconType::PrintAllAreaOfWidget), 79 | new IMAGE_BRUSH( 80 | GetBrushName(TEXT("PrintAll128")), 81 | CoreStyleConstants::Icon64x64 82 | ) 83 | ); 84 | Set( 85 | GetPropertyNameFromIconType(EGraphPrinterStyleIconType::PrintSelectedAreaOfWidget), 86 | new IMAGE_BRUSH( 87 | GetBrushName(TEXT("PrintSelected128")), 88 | CoreStyleConstants::Icon64x64 89 | ) 90 | ); 91 | Set( 92 | GetPropertyNameFromIconType(EGraphPrinterStyleIconType::RestoreWidgetFromImageFile), 93 | new IMAGE_BRUSH( 94 | GetBrushName(TEXT("Restore128")), 95 | CoreStyleConstants::Icon64x64 96 | ) 97 | ); 98 | Set( 99 | GetPropertyNameFromIconType(EGraphPrinterStyleIconType::OpenExportDestinationFolder), 100 | new IMAGE_BRUSH( 101 | GetBrushName(TEXT("Open128")), 102 | CoreStyleConstants::Icon64x64 103 | ) 104 | ); 105 | } 106 | 107 | #if !UE_5_00_OR_LATER 108 | #undef IMAGE_BRUSH 109 | #endif 110 | 111 | void FGraphPrinterStyle::Register() 112 | { 113 | Instance = MakeUnique(); 114 | Instance->RegisterInternal(); 115 | FSlateStyleRegistry::RegisterSlateStyle(*Instance); 116 | } 117 | 118 | void FGraphPrinterStyle::Unregister() 119 | { 120 | FSlateStyleRegistry::UnRegisterSlateStyle(*Instance); 121 | Instance.Reset(); 122 | } 123 | 124 | const ISlateStyle& FGraphPrinterStyle::Get() 125 | { 126 | check(Instance.IsValid()); // Don't call before Register is called or after Unregister is called. 127 | return *Instance.Get(); 128 | } 129 | 130 | const FSlateBrush* FGraphPrinterStyle::GetBrushFromIconType(const EGraphPrinterStyleIconType IconType) 131 | { 132 | return Get().GetBrush(GetPropertyNameFromIconType(IconType)); 133 | } 134 | 135 | FSlateIcon FGraphPrinterStyle::GetSlateIconFromIconType(const EGraphPrinterStyleIconType IconType) 136 | { 137 | return FSlateIcon(Get().GetStyleSetName(), GetPropertyNameFromIconType(IconType)); 138 | } 139 | 140 | FName FGraphPrinterStyle::GetPropertyNameFromIconType(const EGraphPrinterStyleIconType IconType) 141 | { 142 | const UEnum* EnumPtr = StaticEnum(); 143 | check(IsValid(EnumPtr)); 144 | 145 | const FString EnumName = EnumPtr->GetNameStringByValue(static_cast(IconType)); 146 | return *FString::Printf(TEXT("%s.%s"), *Global::PluginName.ToString(), *EnumName); 147 | } 148 | 149 | TUniquePtr FGraphPrinterStyle::Instance = nullptr; 150 | } 151 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterEditorExtension/Public/GraphPrinterEditorExtension/CommandActions/GraphPrinterCommands.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Framework/Commands/Commands.h" 7 | #include "Framework/Commands/UICommandList.h" 8 | #include "Framework/Commands/UICommandInfo.h" 9 | 10 | class UToolMenu; 11 | 12 | namespace GraphPrinter 13 | { 14 | /** 15 | * A class to register the shortcut key used in this plugin. 16 | */ 17 | class GRAPHPRINTEREDITOREXTENSION_API FGraphPrinterCommands : public TCommands 18 | { 19 | public: 20 | // Constructor. 21 | FGraphPrinterCommands(); 22 | 23 | // TCommands interface. 24 | virtual void RegisterCommands() override; 25 | // End of TCommands interface. 26 | 27 | // Returns whether the commands registered here are bound. 28 | static bool IsBound(); 29 | 30 | // Binds commands registered here. 31 | static void Bind(); 32 | 33 | // Fills the menu builder with the commands of this plugin. 34 | static void FillMenuBuilder(UToolMenu* ToolMenu); 35 | 36 | // Returns commands with names matching the specified name. 37 | TSharedPtr FindCommandByName(const FName& CommandName) const; 38 | 39 | protected: 40 | // Binds commands actually registered here. 41 | virtual void BindCommands(); 42 | 43 | private: 44 | // Called when a submenu that opens plugin settings is built. 45 | static void OnExtendOpenSettingsSubMenu(UToolMenu* ToolMenu); 46 | 47 | public: 48 | // The list of shortcut keys used by this plugin. 49 | TSharedRef CommandBindings; 50 | 51 | // Instances of bound commands. 52 | TSharedPtr CollectTargetWidgets; 53 | #ifdef WITH_CLIPBOARD_IMAGE_EXTENSION 54 | TSharedPtr CopyAllAreaOfWidgetToClipboard; 55 | TSharedPtr CopySelectedAreaOfWidgetToClipboard; 56 | #endif 57 | TSharedPtr PrintAllAreaOfWidget; 58 | TSharedPtr PrintSelectedAreaOfWidget; 59 | #ifdef WITH_TEXT_CHUNK_HELPER 60 | TSharedPtr RestoreWidgetFromImageFile; 61 | #endif 62 | TSharedPtr OpenExportDestinationFolder; 63 | 64 | private: 65 | // Whether the commands registered here are bound. 66 | bool bIsBound; 67 | }; 68 | } 69 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterEditorExtension/Public/GraphPrinterEditorExtension/UIExtensions/AutoToolMenuExtender.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "ToolMenus.h" 7 | 8 | struct FDelayedAutoRegisterHelper; 9 | 10 | namespace GraphPrinter 11 | { 12 | /** 13 | * A base class that extend the menu on the editor after the engine initialization is complete. 14 | */ 15 | class GRAPHPRINTEREDITOREXTENSION_API FAutoToolMenuExtender 16 | { 17 | public: 18 | // Destructor. 19 | virtual ~FAutoToolMenuExtender() = default; 20 | 21 | protected: 22 | // Constructor. 23 | FAutoToolMenuExtender(); 24 | 25 | // Actually expands the editor menu. 26 | virtual void ExtendToolMenu() = 0; 27 | 28 | private: 29 | // The instance of the helper that actually calls the menu expansion at a delayed time. 30 | TOptional DelayedAutoRegister; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterEditorExtension/Public/GraphPrinterEditorExtension/UIExtensions/ToolMenuExtensionConstants.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | #define LOCTEXT_NAMESPACE "GraphPrinterToolMenu" 8 | 9 | namespace GraphPrinter 10 | { 11 | /** 12 | * Define here the common display name and tooltip text used by this plugin's editor extensions. 13 | */ 14 | namespace ToolMenuExtensionConstants 15 | { 16 | static FText ToolMenuLabel = LOCTEXT("Label", "Graph Printer"); 17 | static FText ToolMenuTooltip = LOCTEXT("Tooltip", "You can perform the functions of Gprah Printer from here."); 18 | } 19 | } 20 | 21 | #undef LOCTEXT_NAMESPACE 22 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterEditorExtension/Public/GraphPrinterEditorExtension/Utilities/GraphPrinterEditorExtensionSettings.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GraphPrinterGlobals/Utilities/GraphPrinterSettings.h" 7 | #include "GraphPrinterEditorExtensionSettings.generated.h" 8 | 9 | /** 10 | * A editor preferences class related to the editor extension of this plugin. 11 | */ 12 | UCLASS() 13 | class UGraphPrinterEditorExtensionSettings : public UGraphPrinterSettings 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | // Whether to display submenus that perform plugin functions in the editor's tools menu. 19 | UPROPERTY(EditAnywhere, Config, Category = "UI", meta = (ConfigRestartRequired = true)) 20 | bool bShowSubMenuInToolMenu; 21 | 22 | // Whether to show the combo button that performs the function of the plugin in the toolbar of the asset editor. 23 | UPROPERTY(EditAnywhere, Config, Category = "UI", meta = (ConfigRestartRequired = true)) 24 | bool bShowComboButtonInToolbar; 25 | 26 | // Whether to show the combo button that performs the function of the plugin in the editor's status bar. 27 | UPROPERTY(EditAnywhere, Config, Category = "UI", meta = (ConfigRestartRequired = true)) 28 | bool bShowComboButtonInStatusBar; 29 | 30 | // Whether to automatically collect the target widgets when opening any type of menu. 31 | UPROPERTY(EditAnywhere, Config, Category = "UI") 32 | bool bCollectTargetWidgetsAutomatically; 33 | 34 | public: 35 | // Constructor. 36 | UGraphPrinterEditorExtensionSettings(); 37 | 38 | // UObject interface. 39 | virtual bool CanEditChange(const FProperty* InProperty) const override; 40 | // End of UObject interface. 41 | 42 | // UGraphPrinterSettings interface. 43 | virtual FString GetSettingsName() const override; 44 | // End of UGraphPrinterSettings interface. 45 | }; 46 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterEditorExtension/Public/GraphPrinterEditorExtension/Utilities/GraphPrinterStyle.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Styling/SlateStyle.h" 7 | #include "GraphPrinterStyle.generated.h" 8 | 9 | struct FSlateIcon; 10 | 11 | // An enum class that defines type of icon registered in this style set. 12 | UENUM() 13 | enum class EGraphPrinterStyleIconType : uint8 14 | { 15 | PluginIcon, 16 | CopyAllAreaOfWidgetToClipboard, 17 | CopySelectedAreaOfWidgetToClipboard, 18 | PrintAllAreaOfWidget, 19 | PrintSelectedAreaOfWidget, 20 | RestoreWidgetFromImageFile, 21 | OpenExportDestinationFolder, 22 | }; 23 | 24 | namespace GraphPrinter 25 | { 26 | /** 27 | * A class that manages the slate icon used by this plugin. 28 | */ 29 | class GRAPHPRINTEREDITOREXTENSION_API FGraphPrinterStyle : public FSlateStyleSet 30 | { 31 | public: 32 | // Constructor. 33 | FGraphPrinterStyle(); 34 | 35 | private: 36 | // The actual registration process for this class. 37 | void RegisterInternal(); 38 | 39 | public: 40 | // Registers-Unregisters and instance getter this class. 41 | static void Register(); 42 | static void Unregister(); 43 | static const ISlateStyle& Get(); 44 | 45 | // Returns slate brush of specified icon type. 46 | static const FSlateBrush* GetBrushFromIconType(const EGraphPrinterStyleIconType IconType); 47 | 48 | // Returns slate icon of specified icon type. 49 | static FSlateIcon GetSlateIconFromIconType(const EGraphPrinterStyleIconType IconType); 50 | 51 | // Returns property name of specified icon type. 52 | static FName GetPropertyNameFromIconType(const EGraphPrinterStyleIconType IconType); 53 | 54 | private: 55 | // The instance of this style class. 56 | static TUniquePtr Instance; 57 | }; 58 | } -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterGlobals/GraphPrinterGlobals.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class GraphPrinterGlobals : ModuleRules 6 | { 7 | public GraphPrinterGlobals(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 10 | #if UE_5_2_OR_LATER 11 | IncludeOrderVersion = EngineIncludeOrderVersion.Latest; 12 | #endif 13 | 14 | PublicDependencyModuleNames.AddRange( 15 | new string[] 16 | { 17 | "Core", 18 | } 19 | ); 20 | 21 | PrivateDependencyModuleNames.AddRange( 22 | new string[] 23 | { 24 | "CoreUObject", 25 | "Slate", 26 | "SlateCore", 27 | "Settings", 28 | "SettingsEditor", 29 | "DesktopPlatform", 30 | "ImageWriteQueue", 31 | } 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterGlobals/Private/GraphPrinterGlobals/GraphPrinterGlobalsModule.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "CoreMinimal.h" 4 | #include "Modules/ModuleManager.h" 5 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 6 | #include "GraphPrinterGlobals/Utilities/GraphPrinterSettings.h" 7 | 8 | DEFINE_LOG_CATEGORY(LogGraphPrinter); 9 | 10 | namespace GraphPrinter 11 | { 12 | class FGraphPrinterGlobalsModule : public IModuleInterface 13 | { 14 | public: 15 | // IModuleInterface interface. 16 | virtual void StartupModule() override; 17 | virtual void ShutdownModule() override; 18 | // End of IModuleInterface interface. 19 | }; 20 | 21 | void FGraphPrinterGlobalsModule::StartupModule() 22 | { 23 | // Registers settings. 24 | UGraphPrinterSettings::Register(); 25 | } 26 | 27 | void FGraphPrinterGlobalsModule::ShutdownModule() 28 | { 29 | } 30 | } 31 | 32 | IMPLEMENT_MODULE(GraphPrinter::FGraphPrinterGlobalsModule, GraphPrinterGlobals) 33 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterGlobals/Private/GraphPrinterGlobals/Utilities/GraphPrinterSettings.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "GraphPrinterGlobals/Utilities/GraphPrinterSettings.h" 4 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 5 | #include "Modules/ModuleManager.h" 6 | #include "ISettingsModule.h" 7 | #include "ISettingsContainer.h" 8 | #include "ISettingsCategory.h" 9 | #include "ISettingsSection.h" 10 | #include "Misc/CoreDelegates.h" 11 | #include "UObject/UObjectIterator.h" 12 | 13 | #if UE_5_01_OR_LATER 14 | #include UE_INLINE_GENERATED_CPP_BY_NAME(GraphPrinterSettings) 15 | #endif 16 | 17 | #define LOCTEXT_NAMESPACE "GraphPrinterSettings" 18 | 19 | namespace GraphPrinter 20 | { 21 | namespace Settings 22 | { 23 | static const FName ContainerName = TEXT("Editor"); 24 | static const FName CategoryName = TEXT("Plugins"); 25 | 26 | ISettingsModule* GetSettingsModule() 27 | { 28 | return FModuleManager::GetModulePtr(TEXT("Settings")); 29 | } 30 | } 31 | } 32 | 33 | void UGraphPrinterSettings::Register() 34 | { 35 | FCoreDelegates::OnPostEngineInit.AddStatic(&UGraphPrinterSettings::HandleOnPostEngineInit); 36 | FCoreDelegates::OnEnginePreExit.AddStatic(&UGraphPrinterSettings::HandleOnEnginePreExit); 37 | } 38 | 39 | FName UGraphPrinterSettings::GetSectionName() const 40 | { 41 | return *(GraphPrinter::Global::PluginName.ToString() + GetSettingsName()); 42 | } 43 | 44 | FText UGraphPrinterSettings::GetDisplayName() const 45 | { 46 | return FText::Format( 47 | LOCTEXT("DisplayNameFormat", "{0} - {1}"), 48 | FText::FromString(FName::NameToDisplayString(GraphPrinter::Global::PluginName.ToString(), false)), 49 | FText::FromString(GetSettingsName()) 50 | ); 51 | } 52 | 53 | FText UGraphPrinterSettings::GetTooltipText() const 54 | { 55 | const UClass* SettingsClass = GetClass(); 56 | check(IsValid(SettingsClass)); 57 | return SettingsClass->GetToolTipText(); 58 | } 59 | 60 | void UGraphPrinterSettings::OpenSettings(const FName SectionName) 61 | { 62 | if (ISettingsModule* SettingsModule = GraphPrinter::Settings::GetSettingsModule()) 63 | { 64 | SettingsModule->ShowViewer( 65 | GraphPrinter::Settings::ContainerName, 66 | GraphPrinter::Settings::CategoryName, 67 | SectionName 68 | ); 69 | } 70 | } 71 | 72 | const TArray& UGraphPrinterSettings::GetAllSettings() 73 | { 74 | return AllSettings; 75 | } 76 | 77 | void UGraphPrinterSettings::HandleOnPostEngineInit() 78 | { 79 | ISettingsModule* SettingsModule = GraphPrinter::Settings::GetSettingsModule(); 80 | if (SettingsModule == nullptr) 81 | { 82 | return; 83 | } 84 | 85 | for (auto* Settings : TObjectRange(RF_NoFlags)) 86 | { 87 | if (!IsValid(Settings)) 88 | { 89 | continue; 90 | } 91 | 92 | const UClass* SettingsClass = Settings->GetClass(); 93 | if (!IsValid(SettingsClass)) 94 | { 95 | continue; 96 | } 97 | if (SettingsClass->HasAnyClassFlags(CLASS_Abstract)) 98 | { 99 | continue; 100 | } 101 | if (!Settings->IsTemplate()) 102 | { 103 | continue; 104 | } 105 | 106 | SettingsModule->RegisterSettings( 107 | GraphPrinter::Settings::ContainerName, 108 | GraphPrinter::Settings::CategoryName, 109 | Settings->GetSectionName(), 110 | Settings->GetDisplayName(), 111 | Settings->GetTooltipText(), 112 | Settings 113 | ); 114 | 115 | Settings->AddToRoot(); 116 | AllSettings.Add(Settings); 117 | } 118 | } 119 | 120 | void UGraphPrinterSettings::HandleOnEnginePreExit() 121 | { 122 | ISettingsModule* SettingsModule = GraphPrinter::Settings::GetSettingsModule(); 123 | if (SettingsModule == nullptr) 124 | { 125 | return; 126 | } 127 | 128 | for (auto* Settings : AllSettings) 129 | { 130 | Settings->PreSaveConfig(); 131 | 132 | const TSharedPtr Container = SettingsModule->GetContainer(GraphPrinter::Settings::ContainerName); 133 | check(Container.IsValid()); 134 | const TSharedPtr Category = Container->GetCategory(GraphPrinter::Settings::CategoryName); 135 | check(Category.IsValid()); 136 | const TSharedPtr Section = Category->GetSection(Settings->GetSectionName()); 137 | check(Section.IsValid()); 138 | Section->Save(); 139 | 140 | SettingsModule->UnregisterSettings( 141 | GraphPrinter::Settings::ContainerName, 142 | GraphPrinter::Settings::CategoryName, 143 | Settings->GetSectionName() 144 | ); 145 | 146 | Settings->RemoveFromRoot(); 147 | } 148 | } 149 | 150 | TArray UGraphPrinterSettings::AllSettings; 151 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterGlobals/Public/GraphPrinterGlobals/GraphPrinterGlobals.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Misc/EngineVersionComparison.h" 7 | 8 | namespace GraphPrinter 9 | { 10 | namespace Global 11 | { 12 | // The name of this plugin. 13 | static const FName PluginName = TEXT("GraphPrinter"); 14 | } 15 | } 16 | 17 | /** 18 | * Macros to support each engine version. 19 | */ 20 | #ifndef UE_5_06_OR_LATER 21 | #if !UE_VERSION_OLDER_THAN(5, 6, 0) 22 | #define UE_5_06_OR_LATER 1 23 | #else 24 | #define UE_5_06_OR_LATER 0 25 | #endif 26 | #endif 27 | 28 | #ifndef UE_5_02_OR_LATER 29 | #if !UE_VERSION_OLDER_THAN(5, 2, 0) 30 | #define UE_5_02_OR_LATER 1 31 | #else 32 | #define UE_5_02_OR_LATER 0 33 | #endif 34 | #endif 35 | 36 | #ifndef UE_5_01_OR_LATER 37 | #if !UE_VERSION_OLDER_THAN(5, 1, 0) 38 | #define UE_5_01_OR_LATER 1 39 | #else 40 | #define UE_5_01_OR_LATER 0 41 | #endif 42 | #endif 43 | 44 | #ifndef UE_5_00_OR_LATER 45 | #if !UE_VERSION_OLDER_THAN(5, 0, 0) 46 | #define UE_5_00_OR_LATER 1 47 | #else 48 | #define UE_5_00_OR_LATER 0 49 | #endif 50 | #endif 51 | 52 | #ifndef UE_4_25_OR_LATER 53 | #if !UE_VERSION_OLDER_THAN(4, 25, 0) 54 | #define UE_4_25_OR_LATER 1 55 | #else 56 | #define UE_4_25_OR_LATER 0 57 | #endif 58 | #endif 59 | 60 | #ifndef UE_4_24_OR_LATER 61 | #if !UE_VERSION_OLDER_THAN(4, 24, 0) 62 | #define UE_4_24_OR_LATER 1 63 | #else 64 | #define UE_4_24_OR_LATER 0 65 | #endif 66 | #endif 67 | 68 | #ifndef UE_4_22_OR_LATER 69 | #if !UE_VERSION_OLDER_THAN(4, 22, 0) 70 | #define UE_4_22_OR_LATER 1 71 | #else 72 | #define UE_4_22_OR_LATER 0 73 | #endif 74 | #endif 75 | 76 | /** 77 | * Categories used for log output with this plugin. 78 | */ 79 | GRAPHPRINTERGLOBALS_API DECLARE_LOG_CATEGORY_EXTERN(LogGraphPrinter, Log, All); 80 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterGlobals/Public/GraphPrinterGlobals/Utilities/GraphPrinterSettings.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "UObject/Object.h" 7 | #include "GraphPrinterSettings.generated.h" 8 | 9 | /** 10 | * An editor preferences class for this plugin. 11 | */ 12 | UCLASS(Abstract, Config = Editor, GlobalUserConfig) 13 | class GRAPHPRINTERGLOBALS_API UGraphPrinterSettings : public UObject 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | // Registers in the editor setting item. 19 | static void Register(); 20 | 21 | // Returns the name of the section registered in ISettingsModule. 22 | virtual FName GetSectionName() const; 23 | 24 | // Returns the name of the settings that will be displayed in the editor. 25 | virtual FText GetDisplayName() const; 26 | 27 | // Returns tooltip text for settings displayed in the editor. 28 | virtual FText GetTooltipText() const; 29 | 30 | // Opens the settings menu for this plugin. 31 | static void OpenSettings(const FName SectionName); 32 | 33 | // Returns all registered editor settings classes about GraphPrinter. 34 | static const TArray& GetAllSettings(); 35 | 36 | protected: 37 | // Returns the unique name of this setting. 38 | virtual FString GetSettingsName() const PURE_VIRTUAL(UGraphPrinterSettings::GetSettingsName, return {};) 39 | 40 | // Called before saving to the config file. 41 | virtual void PreSaveConfig() {} 42 | 43 | private: 44 | // Called when the end of UEngine::Init, right before loading PostEngineInit modules for both normal execution and commandlets. 45 | static void HandleOnPostEngineInit(); 46 | 47 | // Called before the engine exits. Separate from OnPreExit as OnEnginePreExit occurs before shutting down any core modules. 48 | static void HandleOnEnginePreExit(); 49 | 50 | private: 51 | // The list of all registered editor settings classes about this plugin. 52 | static TArray AllSettings; 53 | }; 54 | 55 | namespace GraphPrinter 56 | { 57 | // Returns reference of this settings. 58 | template 59 | static const TSettings& GetSettings() 60 | { 61 | const auto* Settings = GetDefault(); 62 | check(IsValid(Settings)); 63 | return *Settings; 64 | } 65 | 66 | // Opens the settings menu for this plugin. 67 | template 68 | static void OpenSettings() 69 | { 70 | static_assert(TIsDerivedFrom::IsDerived, "This implementation wasn't tested for a filter that isn't a child of UGraphPrinterSettings."); 71 | 72 | const auto& Settings = GetSettings(); 73 | UGraphPrinterSettings::OpenSettings(Settings.GetSectionName()); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterGlobals/Public/GraphPrinterGlobals/Utilities/GraphPrinterUtils.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "ImageWriteTypes.h" 7 | 8 | class SNotificationItem; 9 | 10 | namespace GraphPrinter 11 | { 12 | // A struct of notification item handles that can indirectly manipulate SNotificationItem. 13 | struct GRAPHPRINTERGLOBALS_API FNotificationHandle 14 | { 15 | public: 16 | // Constructor. 17 | explicit FNotificationHandle(const TSharedPtr& InNotificationItem); 18 | 19 | // Begin the fade out, 20 | void Fadeout(); 21 | 22 | private: 23 | // Indirectly operated SNotificationItem. 24 | TSharedPtr NotificationItem; 25 | }; 26 | 27 | // A struct for adding buttons, hyperlinks, etc. to notifications. 28 | struct GRAPHPRINTERGLOBALS_API FNotificationInteraction 29 | { 30 | public: 31 | // Types of things that users of editor notifications can interact with. 32 | enum class EInteractionType : uint8 33 | { 34 | Hyperlink, 35 | Button, 36 | }; 37 | EInteractionType Type; 38 | 39 | // The text displayed by the button or hyperlink. 40 | FText Text; 41 | 42 | // Tooltip text that appears when you hover over a button. 43 | FText Tooltip; 44 | 45 | // A callback that is called when a button or hyperlink is pressed. 46 | FSimpleDelegate Callback; 47 | 48 | public: 49 | // Constructor. 50 | FNotificationInteraction( 51 | const EInteractionType InType, 52 | const FText& InText, 53 | const FText& InTooltip, 54 | const FSimpleDelegate& InCallback 55 | ); 56 | FNotificationInteraction(); 57 | FNotificationInteraction(const FText& InText, const FSimpleDelegate& InCallback); 58 | FNotificationInteraction(const FText& InText, const FText& InTooltip, const FSimpleDelegate& InCallback); 59 | }; 60 | 61 | /** 62 | * A utility class that defines utility functions used in this plugin. 63 | */ 64 | class GRAPHPRINTERGLOBALS_API FGraphPrinterUtils 65 | { 66 | public: 67 | // Define notification types so don't need to include "SNotificationList.h". 68 | using ECompletionState = int32; 69 | static const ECompletionState CS_Pending; 70 | static const ECompletionState CS_Success; 71 | static const ECompletionState CS_Fail; 72 | 73 | public: 74 | // Shows notifications at the bottom right of the editor (When Expire Duration is 0 or less, you need to call the fade process manually.). 75 | static FNotificationHandle ShowNotification( 76 | const FText& NotificationText, 77 | ECompletionState CompletionState, 78 | float ExpireDuration = 4.f, 79 | const TArray& Interactions = TArray() 80 | ); 81 | 82 | // Gets the extension by the format of the image file. 83 | static FString GetImageFileExtension(const EDesiredImageFormat ImageFormat, const bool bWithDot = true); 84 | 85 | // Opens the folder containing the file in Explorer. 86 | static void OpenFolderWithExplorer(const FString& Filename); 87 | 88 | // Shows the file browser and let the user select a file. 89 | static bool OpenFileDialog( 90 | TArray& Filenames, 91 | const FString& DialogTitle = TEXT("Open File Dialog"), 92 | const FString& DefaultPath = TEXT(""), 93 | const FString& DefaultFile = TEXT(""), 94 | const FString& FileTypes = TEXT("All (*)|*.*"), 95 | const bool bIsMultiple = false 96 | ); 97 | 98 | // Cuts out unnecessary character strings mixed in at the beginning of sentences. 99 | // Returns whether the clipping was actually done. 100 | static bool ClearUnnecessaryCharactersFromHead(FString& String, const FString& BeginningOfString); 101 | }; 102 | } 103 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterRemoteControl/GraphPrinterRemoteControl.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class GraphPrinterRemoteControl : ModuleRules 6 | { 7 | public GraphPrinterRemoteControl(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 10 | #if UE_5_2_OR_LATER 11 | IncludeOrderVersion = EngineIncludeOrderVersion.Latest; 12 | #endif 13 | 14 | PublicDependencyModuleNames.AddRange( 15 | new string[] 16 | { 17 | "Core", 18 | } 19 | ); 20 | 21 | PrivateDependencyModuleNames.AddRange( 22 | new string[] 23 | { 24 | "CoreUObject", 25 | "Engine", 26 | "WebSockets", 27 | 28 | "GraphPrinterGlobals", 29 | "GraphPrinterEditorExtension", 30 | "ClipboardImageExtension", 31 | "TextChunkHelper", 32 | } 33 | ); 34 | } 35 | } -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterRemoteControl/Private/GraphPrinterRemoteControl/GraphPrinterRemoteControlModule.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "CoreMinimal.h" 4 | #include "Modules/ModuleManager.h" 5 | #include "GraphPrinterRemoteControl/WebSockets/GraphPrinterRemoteControlReceiver.h" 6 | 7 | namespace GraphPrinter 8 | { 9 | class FGraphPrinterRemoteControlModule : public IModuleInterface 10 | { 11 | public: 12 | // IModuleInterface interface. 13 | virtual void StartupModule() override; 14 | virtual void ShutdownModule() override; 15 | // End of IModuleInterface interface. 16 | }; 17 | 18 | void FGraphPrinterRemoteControlModule::StartupModule() 19 | { 20 | // Registers remote control receiver. 21 | FGraphPrinterRemoteControlReceiver::Register(); 22 | } 23 | 24 | void FGraphPrinterRemoteControlModule::ShutdownModule() 25 | { 26 | // Unregisters remote control receiver. 27 | FGraphPrinterRemoteControlReceiver::Unregister(); 28 | } 29 | } 30 | 31 | IMPLEMENT_MODULE(GraphPrinter::FGraphPrinterRemoteControlModule, GraphPrinterRemoteControl) 32 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterRemoteControl/Private/GraphPrinterRemoteControl/Utilities/GraphPrinterRemoteControlSettings.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "GraphPrinterRemoteControl/Utilities/GraphPrinterRemoteControlSettings.h" 4 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 5 | 6 | #if UE_5_01_OR_LATER 7 | #include UE_INLINE_GENERATED_CPP_BY_NAME(GraphPrinterRemoteControlSettings) 8 | #endif 9 | 10 | UGraphPrinterRemoteControlSettings::FOnRemoteControlEnabled UGraphPrinterRemoteControlSettings::OnRemoteControlEnabled; 11 | UGraphPrinterRemoteControlSettings::FOnRemoteControlDisabled UGraphPrinterRemoteControlSettings::OnRemoteControlDisabled; 12 | 13 | UGraphPrinterRemoteControlSettings::UGraphPrinterRemoteControlSettings() 14 | : bEnableRemoteControl(false) 15 | , ServerURL(TEXT("ws://127.0.0.1:3000/")) 16 | { 17 | } 18 | 19 | void UGraphPrinterRemoteControlSettings::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) 20 | { 21 | Super::PostEditChangeProperty(PropertyChangedEvent); 22 | 23 | if (PropertyChangedEvent.MemberProperty == nullptr) 24 | { 25 | return; 26 | } 27 | 28 | if (PropertyChangedEvent.MemberProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UGraphPrinterRemoteControlSettings, bEnableRemoteControl)) 29 | { 30 | if (bEnableRemoteControl) 31 | { 32 | OnRemoteControlEnabled.Broadcast(ServerURL); 33 | } 34 | else 35 | { 36 | OnRemoteControlDisabled.Broadcast(); 37 | } 38 | } 39 | } 40 | 41 | FString UGraphPrinterRemoteControlSettings::GetSettingsName() const 42 | { 43 | return TEXT("RemoteControl"); 44 | } 45 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterRemoteControl/Private/GraphPrinterRemoteControl/WebSockets/GraphPrinterRemoteControlReceiver.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "GraphPrinterRemoteControl/WebSockets/GraphPrinterRemoteControlReceiver.h" 4 | #include "GraphPrinterRemoteControl/Utilities/GraphPrinterRemoteControlSettings.h" 5 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 6 | #include "GraphPrinterEditorExtension/CommandActions/GraphPrinterCommands.h" 7 | #include "WebSocketsModule.h" 8 | #include "IWebSocket.h" 9 | 10 | namespace GraphPrinter 11 | { 12 | void FGraphPrinterRemoteControlReceiver::Register() 13 | { 14 | Instance = MakeUnique(); 15 | check(Instance.IsValid()); 16 | 17 | UGraphPrinterRemoteControlSettings::OnRemoteControlEnabled.AddRaw( 18 | Instance.Get(), &FGraphPrinterRemoteControlReceiver::ConnectToServer 19 | ); 20 | UGraphPrinterRemoteControlSettings::OnRemoteControlDisabled.AddRaw( 21 | Instance.Get(), &FGraphPrinterRemoteControlReceiver::DisconnectFromServer 22 | ); 23 | 24 | const auto& Settings = GetSettings(); 25 | if (Settings.bEnableRemoteControl) 26 | { 27 | Instance->ConnectToServer(Settings.ServerURL); 28 | } 29 | } 30 | 31 | void FGraphPrinterRemoteControlReceiver::Unregister() 32 | { 33 | UGraphPrinterRemoteControlSettings::OnRemoteControlEnabled.RemoveAll(Instance.Get()); 34 | UGraphPrinterRemoteControlSettings::OnRemoteControlDisabled.RemoveAll(Instance.Get()); 35 | 36 | Instance.Reset(); 37 | } 38 | 39 | void FGraphPrinterRemoteControlReceiver::ConnectToServer(const FString ServerURL) 40 | { 41 | DisconnectFromServer(); 42 | 43 | Socket = FWebSocketsModule::Get().CreateWebSocket(ServerURL); 44 | check(Socket.IsValid()); 45 | 46 | Socket->OnConnected().AddRaw( 47 | this, &FGraphPrinterRemoteControlReceiver::HandleOnConnected, 48 | ServerURL 49 | ); 50 | Socket->OnConnectionError().AddRaw(this, &FGraphPrinterRemoteControlReceiver::HandleOnConnectionError); 51 | Socket->OnClosed().AddRaw(this, &FGraphPrinterRemoteControlReceiver::HandleOnClosed); 52 | Socket->OnMessage().AddRaw(this, &FGraphPrinterRemoteControlReceiver::HandleOnMessage); 53 | 54 | Socket->Connect(); 55 | } 56 | 57 | void FGraphPrinterRemoteControlReceiver::DisconnectFromServer() 58 | { 59 | if (Socket.IsValid()) 60 | { 61 | Socket->Close(); 62 | } 63 | Socket.Reset(); 64 | } 65 | 66 | void FGraphPrinterRemoteControlReceiver::HandleOnConnected(const FString ServerURL) 67 | { 68 | UE_LOG(LogGraphPrinter, Log, TEXT("Connected to server (URL: %s)"), *ServerURL); 69 | } 70 | 71 | void FGraphPrinterRemoteControlReceiver::HandleOnConnectionError(const FString& Error) 72 | { 73 | UE_LOG(LogGraphPrinter, Error, TEXT("Occurred connection error : %s"), *Error); 74 | UE_LOG(LogGraphPrinter, Error, TEXT("Make sure the server is up and re-enable remote control.")); 75 | } 76 | 77 | void FGraphPrinterRemoteControlReceiver::HandleOnClosed(int32 StatusCode, const FString& Reason, bool bWasClean) 78 | { 79 | UE_LOG(LogGraphPrinter, Log, TEXT("Dissconnected from server (Status Code: %d | Reason: %s)"), StatusCode, *Reason); 80 | } 81 | 82 | void FGraphPrinterRemoteControlReceiver::HandleOnMessage(const FString& Message) 83 | { 84 | FName CommandName = NAME_None; 85 | { 86 | TArray ParsedMessage; 87 | Message.ParseIntoArray(ParsedMessage, TEXT("-")); 88 | if (ParsedMessage.Num() == 3) 89 | { 90 | CommandName = *ParsedMessage[2]; 91 | } 92 | } 93 | 94 | const auto& Commands = FGraphPrinterCommands::Get(); 95 | const TSharedPtr& CommandToExecute = Commands.FindCommandByName(CommandName); 96 | if (CommandToExecute.IsValid()) 97 | { 98 | Commands.CommandBindings->ExecuteAction(CommandToExecute.ToSharedRef()); 99 | UE_LOG(LogGraphPrinter, Log, TEXT("Received request from server : %s"), *CommandName.ToString()); 100 | } 101 | else 102 | { 103 | UE_LOG(LogGraphPrinter, Error, TEXT("Received invalid message from server : %s"), *Message); 104 | } 105 | } 106 | 107 | TUniquePtr FGraphPrinterRemoteControlReceiver::Instance; 108 | } 109 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterRemoteControl/Private/GraphPrinterRemoteControl/WebSockets/GraphPrinterRemoteControlReceiver.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | class IWebSocket; 8 | 9 | namespace GraphPrinter 10 | { 11 | /** 12 | * A receiver class that utilizes the functionality of this plugin externally via a web socket. 13 | * 14 | * The format of the request from the server is as follows: 15 | * UnrealEngine-GraphPrinter-[CommandName] 16 | * 17 | * CommandName is the name of the command defined in FGraphPrinterCommands. 18 | */ 19 | class GRAPHPRINTERREMOTECONTROL_API FGraphPrinterRemoteControlReceiver 20 | { 21 | public: 22 | // Registers-Unregisters the remote control receiver. 23 | static void Register(); 24 | static void Unregister(); 25 | 26 | private: 27 | // Called when remote control is enabled. 28 | void ConnectToServer(const FString ServerURL); 29 | 30 | // Called when remote control is disabled. 31 | void DisconnectFromServer(); 32 | 33 | // Callback functions for events emitted from web sockets. 34 | void HandleOnConnected(const FString ServerURL); 35 | void HandleOnConnectionError(const FString& Error); 36 | void HandleOnClosed(int32 StatusCode, const FString& Reason, bool bWasClean); 37 | void HandleOnMessage(const FString& Message); 38 | 39 | private: 40 | // The currently connected web socket instance. 41 | TSharedPtr Socket; 42 | 43 | // The unique instance of this class. 44 | static TUniquePtr Instance; 45 | }; 46 | } 47 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterRemoteControl/Public/GraphPrinterRemoteControl/Utilities/GraphPrinterRemoteControlSettings.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GraphPrinterGlobals/Utilities/GraphPrinterSettings.h" 7 | #include "GraphPrinterRemoteControlSettings.generated.h" 8 | 9 | /** 10 | * A editor preferences class related to the remote control of this plugin. 11 | */ 12 | UCLASS() 13 | class UGraphPrinterRemoteControlSettings : public UGraphPrinterSettings 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | // Whether remote control via web socket is enabled. 19 | // Please check again when the server is rebuilt. 20 | UPROPERTY(EditAnywhere, Config, Category = "Remote Control") 21 | bool bEnableRemoteControl; 22 | 23 | // Your server URL. You can use ws, wss or wss+insecure. 24 | // Disable remote control once to edit. 25 | UPROPERTY(EditAnywhere, Config, Category = "Remote Control", meta = (EditCondition = "!bEnableRemoteControl")) 26 | FString ServerURL; 27 | 28 | public: 29 | // The event called when remote control is enabled. 30 | DECLARE_MULTICAST_DELEGATE_OneParam(FOnRemoteControlEnabled, const FString /* ServerURL */); 31 | static FOnRemoteControlEnabled OnRemoteControlEnabled; 32 | 33 | // The event called when remote control is disabled. 34 | DECLARE_MULTICAST_DELEGATE(FOnRemoteControlDisabled); 35 | static FOnRemoteControlDisabled OnRemoteControlDisabled; 36 | 37 | public: 38 | // Constructor. 39 | UGraphPrinterRemoteControlSettings(); 40 | 41 | // UObject interface. 42 | virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override; 43 | // End of UObject interface. 44 | 45 | // UGraphPrinterSettings interface. 46 | virtual FString GetSettingsName() const override; 47 | // End of UGraphPrinterSettings interface. 48 | }; 49 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterStreamDeck/GraphPrinterStreamDeck.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | using System.IO; 4 | using UnrealBuildTool; 5 | 6 | public class GraphPrinterStreamDeck : ModuleRules 7 | { 8 | public GraphPrinterStreamDeck(ReadOnlyTargetRules Target) : base(Target) 9 | { 10 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 11 | #if UE_5_2_OR_LATER 12 | IncludeOrderVersion = EngineIncludeOrderVersion.Latest; 13 | #endif 14 | 15 | PublicIncludePaths.AddRange( 16 | new string[] 17 | { 18 | Path.Combine(ModuleDirectory, "Public", "GraphPrinterStreamDeck"), 19 | } 20 | ); 21 | 22 | PublicDependencyModuleNames.AddRange( 23 | new string[] 24 | { 25 | "Core", 26 | } 27 | ); 28 | 29 | PrivateDependencyModuleNames.AddRange( 30 | new string[] 31 | { 32 | "CoreUObject", 33 | "Projects", 34 | 35 | "GraphPrinterGlobals", 36 | } 37 | ); 38 | 39 | // #TODO: Allows the use of the Stream Deck plugin on Mac. 40 | if (Target.IsInPlatformGroup(UnrealPlatformGroup.Windows)) 41 | { 42 | PublicDefinitions.Add("WITH_STREAM_DECK"); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterStreamDeck/Private/GraphPrinterStreamDeck/GraphPrinterStreamDeckModule.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "CoreMinimal.h" 4 | #include "Modules/ModuleManager.h" 5 | 6 | namespace GraphPrinter 7 | { 8 | class FGraphPrinterStreamDeckModule : public IModuleInterface 9 | { 10 | public: 11 | // IModuleInterface interface. 12 | virtual void StartupModule() override; 13 | virtual void ShutdownModule() override; 14 | // End of IModuleInterface interface. 15 | }; 16 | 17 | void FGraphPrinterStreamDeckModule::StartupModule() 18 | { 19 | } 20 | 21 | void FGraphPrinterStreamDeckModule::ShutdownModule() 22 | { 23 | } 24 | } 25 | 26 | IMPLEMENT_MODULE(GraphPrinter::FGraphPrinterStreamDeckModule, GraphPrinterStreamDeck) 27 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterStreamDeck/Public/GraphPrinterStreamDeck/GenericPlatform/GenericStreamDeckUtils.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | namespace GraphPrinter 8 | { 9 | /** 10 | * A class that defines the processing related to the Stream Deck. 11 | */ 12 | class GRAPHPRINTERSTREAMDECK_API FGenericStreamDeckUtils 13 | { 14 | public: 15 | // Returns whether the Stream Deck application is installed. 16 | static bool IsStreamDeckInstalled() { return false; } 17 | 18 | // Installs the Stream Deck plugin that works with this plugin on the Stream Deck. 19 | static void InstallStreamDeckPlugin() {} 20 | 21 | // Returns whether the Stream Deck plugin is installed. 22 | static bool IsInstalledStreamDeckPlugin() { return false; } 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterStreamDeck/Public/GraphPrinterStreamDeck/HAL/StreamDeckUtils.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | #include COMPILED_PLATFORM_HEADER(StreamDeckUtils.h) 8 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/GraphPrinterStreamDeck/Public/GraphPrinterStreamDeck/Windows/WindowsStreamDeckUtils.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GraphPrinterStreamDeck/GenericPlatform/GenericStreamDeckUtils.h" 7 | 8 | namespace GraphPrinter 9 | { 10 | /** 11 | * A class that defines the processing related to Stream Deck on Windows. 12 | */ 13 | class GRAPHPRINTERSTREAMDECK_API FWindowsStreamDeckUtils : public FGenericStreamDeckUtils 14 | { 15 | public: 16 | // FGenericStreamDeckUtils interface. 17 | static bool IsStreamDeckInstalled(); 18 | static void InstallStreamDeckPlugin(); 19 | static bool IsInstalledStreamDeckPlugin(); 20 | // End of FGenericStreamDeckUtils interface. 21 | }; 22 | 23 | #if PLATFORM_WINDOWS 24 | using FStreamDeckUtils = FWindowsStreamDeckUtils; 25 | #endif 26 | } 27 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/MaterialGraphPrinter/MaterialGraphPrinter.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class MaterialGraphPrinter : ModuleRules 6 | { 7 | public MaterialGraphPrinter(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 10 | #if UE_5_2_OR_LATER 11 | IncludeOrderVersion = EngineIncludeOrderVersion.Latest; 12 | #endif 13 | 14 | PublicDependencyModuleNames.AddRange( 15 | new string[] 16 | { 17 | "Core", 18 | } 19 | ); 20 | 21 | PrivateDependencyModuleNames.AddRange( 22 | new string[] 23 | { 24 | "CoreUObject", 25 | "UMG", 26 | "Slate", 27 | "SlateCore", 28 | "Engine", 29 | "UnrealEd", 30 | "MainFrame", 31 | "RenderCore", 32 | 33 | "GraphPrinterGlobals", 34 | "WidgetPrinter", 35 | "GenericGraphPrinter", 36 | "ViewportPrinter", 37 | "TextChunkHelper", 38 | "ClipboardImageExtension", 39 | } 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/MaterialGraphPrinter/Private/MaterialGraphPrinter/MaterialGraphPrinterModule.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "CoreMinimal.h" 4 | #include "Modules/ModuleManager.h" 5 | 6 | namespace GraphPrinter 7 | { 8 | class FMaterialGraphPrinterModule : public IModuleInterface 9 | { 10 | public: 11 | // IModuleInterface interface. 12 | virtual void StartupModule() override; 13 | virtual void ShutdownModule() override; 14 | // End of IModuleInterface interface. 15 | }; 16 | 17 | void FMaterialGraphPrinterModule::StartupModule() 18 | { 19 | } 20 | 21 | void FMaterialGraphPrinterModule::ShutdownModule() 22 | { 23 | } 24 | } 25 | 26 | IMPLEMENT_MODULE(GraphPrinter::FMaterialGraphPrinterModule, MaterialGraphPrinter) 27 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/MaterialGraphPrinter/Private/MaterialGraphPrinter/Types/PrintMaterialGraphOptions.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "MaterialGraphPrinter/Types/PrintMaterialGraphOptions.h" 4 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 5 | 6 | #if UE_5_01_OR_LATER 7 | #include UE_INLINE_GENERATED_CPP_BY_NAME(PrintMaterialGraphOptions) 8 | #endif 9 | 10 | UPrintMaterialGraphOptions::UPrintMaterialGraphOptions() 11 | : MaterialGraphExportMethod(EMaterialGraphExportMethod::CombinePreviewAndGraph) 12 | { 13 | } 14 | 15 | UPrintWidgetOptions* UPrintMaterialGraphOptions::Duplicate(const TSubclassOf& DestinationClass) const 16 | { 17 | auto* Destination = Super::Duplicate(DestinationClass); 18 | if (auto* CastedDestination = Cast(Destination)) 19 | { 20 | CastedDestination->MaterialGraphExportMethod = MaterialGraphExportMethod; 21 | } 22 | 23 | return Destination; 24 | } 25 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/MaterialGraphPrinter/Private/MaterialGraphPrinter/Utilities/MaterialGraphPrinterSettings.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "MaterialGraphPrinter/Utilities/MaterialGraphPrinterSettings.h" 4 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 5 | 6 | #if UE_5_01_OR_LATER 7 | #include UE_INLINE_GENERATED_CPP_BY_NAME(MaterialGraphPrinterSettings) 8 | #endif 9 | 10 | UMaterialGraphPrinterSettings::UMaterialGraphPrinterSettings() 11 | : MaterialGraphExportMethod(EMaterialGraphExportMethod::CombinePreviewAndGraph) 12 | { 13 | } 14 | 15 | FString UMaterialGraphPrinterSettings::GetSettingsName() const 16 | { 17 | return TEXT("MaterialGraphPrinter"); 18 | } 19 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/MaterialGraphPrinter/Private/MaterialGraphPrinter/WidgetPrinters/InnerMaterialGraphPrinter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "MaterialGraphPrinter/WidgetPrinters/InnerMaterialGraphPrinter.h" 4 | #include "ViewportPrinter/WidgetPrinters/ViewportPrinter.h" 5 | #include "MaterialGraph/MaterialGraph.h" 6 | #include "Materials/MaterialFunction.h" 7 | #include "SGraphEditorImpl.h" 8 | #include "Widgets/SBoxPanel.h" 9 | #include "Widgets/Layout/SBox.h" 10 | #include "Widgets/Images/SImage.h" 11 | 12 | namespace GraphPrinter 13 | { 14 | FMaterialGraphPrinter::FMaterialGraphPrinter(UPrintWidgetOptions* InPrintOptions, const FSimpleDelegate& InOnPrinterProcessingFinished) 15 | : Super(InPrintOptions, InOnPrinterProcessingFinished) 16 | { 17 | } 18 | 19 | FMaterialGraphPrinter::FMaterialGraphPrinter(URestoreWidgetOptions* InRestoreOptions, const FSimpleDelegate& InOnPrinterProcessingFinished) 20 | : Super(InRestoreOptions, InOnPrinterProcessingFinished) 21 | { 22 | } 23 | 24 | bool FMaterialGraphPrinter::CanPrintWidget() const 25 | { 26 | if (Super::CanPrintWidget()) 27 | { 28 | const TSharedPtr GraphEditor = FindTargetWidget(PrintOptions->SearchTarget); 29 | return IsValid(Cast(GraphEditor->GetCurrentGraph())); 30 | } 31 | 32 | return false; 33 | } 34 | 35 | UTextureRenderTarget2D* FMaterialGraphPrinter::DrawWidgetToRenderTarget() 36 | { 37 | UTextureRenderTarget2D* RenderedGraph = Super::DrawWidgetToRenderTarget(); 38 | if (!IsValid(RenderedGraph)) 39 | { 40 | return nullptr; 41 | } 42 | 43 | if (PrintOptions->MaterialGraphExportMethod == EMaterialGraphExportMethod::GraphOnly) 44 | { 45 | return RenderedGraph; 46 | } 47 | 48 | auto* ToRenderTarget = PrintOptions->Duplicate(UPrintWidgetOptions::StaticClass()); 49 | ToRenderTarget->PrintScope = UPrintWidgetOptions::EPrintScope::All; 50 | ToRenderTarget->ExportMethod = UPrintWidgetOptions::EExportMethod::RenderTarget; 51 | ToRenderTarget->SearchTarget = FWidgetPrinterUtils::FindNearestParentStandaloneAssetEditorToolkitHost(Widget);; 52 | const UWidgetPrinter::FRenderingResult RenderingResult = GetRenderingResult(ToRenderTarget); 53 | if (!RenderingResult.IsValid()) 54 | { 55 | return nullptr; 56 | } 57 | 58 | if (PrintOptions->MaterialGraphExportMethod == EMaterialGraphExportMethod::PreviewAndGraphSeparately) 59 | { 60 | ExportRenderTargetToImageFileInternal( 61 | RenderingResult.RenderTarget.Get(), 62 | RenderingResult.Filename, 63 | PrintOptions->ImageWriteOptions 64 | ); 65 | 66 | return RenderedGraph; 67 | } 68 | 69 | // Re-renders the widget that concatenates the two render targets. 70 | const TSharedPtr PreviewViewportBrush = MakeShared(); 71 | PreviewViewportBrush->SetResourceObject(RenderingResult.RenderTarget.Get()); 72 | const TSharedPtr GraphBrush = MakeShared(); 73 | GraphBrush->SetResourceObject(RenderedGraph); 74 | 75 | const TSharedRef CombinedWidget = SNew(SHorizontalBox) 76 | + SHorizontalBox::Slot() 77 | .VAlign(VAlign_Top) 78 | .AutoWidth() 79 | [ 80 | SNew(SBox) 81 | .WidthOverride(RenderingResult.RenderTarget->SizeX) 82 | .HeightOverride(RenderingResult.RenderTarget->SizeY) 83 | [ 84 | SNew(SImage) 85 | .Image(PreviewViewportBrush.Get()) 86 | ] 87 | ] 88 | + SHorizontalBox::Slot() 89 | .VAlign(VAlign_Top) 90 | .AutoWidth() 91 | [ 92 | SNew(SBox) 93 | .WidthOverride(RenderedGraph->SizeX) 94 | .HeightOverride(RenderedGraph->SizeY) 95 | [ 96 | SNew(SImage) 97 | .Image(GraphBrush.Get()) 98 | ] 99 | ]; 100 | 101 | #if UE_5_00_OR_LATER 102 | CombinedWidget->MarkPrepassAsDirty(); 103 | #else 104 | CombinedWidget->InvalidatePrepass(); 105 | #endif 106 | 107 | const FVector2D CombinedSize( 108 | RenderingResult.RenderTarget->SizeX + RenderedGraph->SizeX, 109 | FMath::Max(RenderingResult.RenderTarget->SizeY, RenderedGraph->SizeY) 110 | ); 111 | 112 | return DrawWidgetToRenderTargetInternal( 113 | CombinedWidget, 114 | CombinedSize, 115 | PrintOptions->FilteringMode, 116 | false, // If draws with gamma twice, it will be too bright, so gamma is not used here. 117 | PrintOptions->RenderingScale 118 | ); 119 | } 120 | 121 | FString FMaterialGraphPrinter::GetWidgetTitle() 122 | { 123 | FString Title; 124 | GetMaterialGraphTitle(Widget, Title); 125 | return Title; 126 | } 127 | 128 | bool FMaterialGraphPrinter::GetMaterialGraphTitle(const TSharedPtr& MaterialGraphEditor, FString& Title) 129 | { 130 | Title = TEXT("InvalidMaterialEditor"); 131 | 132 | const auto* MaterialGraph = Cast(MaterialGraphEditor->GetCurrentGraph()); 133 | if (!IsValid(MaterialGraph)) 134 | { 135 | return false; 136 | } 137 | 138 | FString MaterialName; 139 | if (const UMaterialFunction* MaterialFunction = MaterialGraph->MaterialFunction) 140 | { 141 | MaterialName = MaterialFunction->GetName(); 142 | } 143 | else if (const UMaterial* Material = MaterialGraph->Material) 144 | { 145 | MaterialName = Material->GetName(); 146 | } 147 | else 148 | { 149 | return false; 150 | } 151 | 152 | Title = FString::Printf(TEXT("MaterialGraph-%s"), *MaterialName); 153 | return true; 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/MaterialGraphPrinter/Private/MaterialGraphPrinter/WidgetPrinters/MaterialGraphPrinter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "MaterialGraphPrinter/WidgetPrinters/MaterialGraphPrinter.h" 4 | #include "MaterialGraphPrinter/WidgetPrinters/InnerMaterialGraphPrinter.h" 5 | #include "MaterialGraphPrinter/Types/PrintMaterialGraphOptions.h" 6 | #include "MaterialGraphPrinter/Utilities/MaterialGraphPrinterSettings.h" 7 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 8 | 9 | #if UE_5_01_OR_LATER 10 | #include UE_INLINE_GENERATED_CPP_BY_NAME(MaterialGraphPrinter) 11 | #endif 12 | 13 | int32 UMaterialGraphPrinter::GetPriority() const 14 | { 15 | return MaterialGraphPrinterPriority; 16 | } 17 | 18 | TOptional UMaterialGraphPrinter::CheckIfSupported(const TSharedRef& TestWidget) const 19 | { 20 | const TSharedPtr MaterialGraphEditor = GraphPrinter::FMaterialGraphPrinter::FindTargetWidgetFromSearchTarget(TestWidget); 21 | if (!MaterialGraphEditor.IsValid()) 22 | { 23 | return {}; 24 | } 25 | 26 | FString MaterialGraphTitle; 27 | if (!GraphPrinter::FMaterialGraphPrinter::GetMaterialGraphTitle(MaterialGraphEditor, MaterialGraphTitle)) 28 | { 29 | return {}; 30 | } 31 | 32 | return GraphPrinter::FSupportedWidget(MaterialGraphEditor.ToSharedRef(), MaterialGraphTitle, GetPriority()); 33 | } 34 | 35 | UPrintWidgetOptions* UMaterialGraphPrinter::CreateDefaultPrintOptions( 36 | const UPrintWidgetOptions::EPrintScope PrintScope, 37 | const UPrintWidgetOptions::EExportMethod ExportMethod 38 | ) const 39 | { 40 | if (UPrintWidgetOptions* PrintWidgetOptions = Super::CreateDefaultPrintOptions(PrintScope, ExportMethod)) 41 | { 42 | if (auto* PrintMaterialGraphOptions = PrintWidgetOptions->Duplicate()) 43 | { 44 | const auto& Settings = GraphPrinter::GetSettings(); 45 | 46 | PrintMaterialGraphOptions->MaterialGraphExportMethod = Settings.MaterialGraphExportMethod; 47 | 48 | return PrintMaterialGraphOptions; 49 | } 50 | } 51 | 52 | return nullptr; 53 | } 54 | 55 | TSharedRef UMaterialGraphPrinter::CreatePrintModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const 56 | { 57 | return MakeShared( 58 | GetPrintOptions(), 59 | OnPrinterProcessingFinished 60 | ); 61 | } 62 | 63 | TSharedRef UMaterialGraphPrinter::CreateRestoreModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const 64 | { 65 | return MakeShared( 66 | GetRestoreOptions(), 67 | OnPrinterProcessingFinished 68 | ); 69 | } 70 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/MaterialGraphPrinter/Public/MaterialGraphPrinter/Types/MaterialGraphExportMethod.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "MaterialGraphExportMethod.generated.h" 7 | 8 | /** 9 | * An enum that defines how to output a graph in the material editor. 10 | */ 11 | UENUM() 12 | enum class EMaterialGraphExportMethod : uint8 13 | { 14 | GraphOnly, 15 | CombinePreviewAndGraph, 16 | PreviewAndGraphSeparately, 17 | }; 18 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/MaterialGraphPrinter/Public/MaterialGraphPrinter/Types/PrintMaterialGraphOptions.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GenericGraphPrinter/Types/PrintGraphOptions.h" 7 | #include "MaterialGraphPrinter/Types/MaterialGraphExportMethod.h" 8 | #include "PrintMaterialGraphOptions.generated.h" 9 | 10 | /** 11 | * An optional class to specify when printing the material graph editor. 12 | */ 13 | UCLASS() 14 | class UPrintMaterialGraphOptions : public UPrintGraphOptions 15 | { 16 | GENERATED_BODY() 17 | 18 | public: 19 | // Constructor. 20 | UPrintMaterialGraphOptions(); 21 | 22 | // UPrintWidgetOptions interface. 23 | virtual UPrintWidgetOptions* Duplicate(const TSubclassOf& DestinationClass) const override; 24 | // End of UPrintWidgetOptions interface. 25 | 26 | public: 27 | // How to output a graph in the material editor. 28 | EMaterialGraphExportMethod MaterialGraphExportMethod; 29 | }; 30 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/MaterialGraphPrinter/Public/MaterialGraphPrinter/Utilities/MaterialGraphPrinterSettings.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GraphPrinterGlobals/Utilities/GraphPrinterSettings.h" 7 | #include "MaterialGraphPrinter/Types/MaterialGraphExportMethod.h" 8 | #include "MaterialGraphPrinterSettings.generated.h" 9 | 10 | /** 11 | * A class that sets the default values for UPrintMaterialGraphOptions from the editor preferences. 12 | */ 13 | UCLASS() 14 | class MATERIALGRAPHPRINTER_API UMaterialGraphPrinterSettings : public UGraphPrinterSettings 15 | { 16 | GENERATED_BODY() 17 | 18 | public: 19 | // How to output a graph in the material editor. 20 | UPROPERTY(EditAnywhere, Config, Category = "Material Editor") 21 | EMaterialGraphExportMethod MaterialGraphExportMethod; 22 | 23 | public: 24 | // Constructor. 25 | UMaterialGraphPrinterSettings(); 26 | 27 | // UGraphPrinterSettings interface. 28 | virtual FString GetSettingsName() const override; 29 | // End of UGraphPrinterSettings interface. 30 | }; 31 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/MaterialGraphPrinter/Public/MaterialGraphPrinter/WidgetPrinters/InnerMaterialGraphPrinter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GenericGraphPrinter/WidgetPrinters/InnerGenericGraphPrinter.h" 7 | #include "MaterialGraphPrinter/Types/PrintMaterialGraphOptions.h" 8 | 9 | class UTextureRenderTarget2D; 10 | 11 | namespace GraphPrinter 12 | { 13 | /** 14 | * An inner class with the ability to print and restore graph editors. 15 | */ 16 | class MATERIALGRAPHPRINTER_API FMaterialGraphPrinter 17 | : public TGraphPrinter 18 | { 19 | public: 20 | using Super = TGraphPrinter; 21 | 22 | public: 23 | // Constructor. 24 | FMaterialGraphPrinter(UPrintWidgetOptions* InPrintOptions, const FSimpleDelegate& InOnPrinterProcessingFinished); 25 | FMaterialGraphPrinter(URestoreWidgetOptions* InRestoreOptions, const FSimpleDelegate& InOnPrinterProcessingFinished); 26 | 27 | // IInnerWidgetPrinter interface. 28 | virtual bool CanPrintWidget() const override; 29 | // End of IInnerWidgetPrinter interface. 30 | 31 | // TInnerWidgetPrinter interface. 32 | virtual UTextureRenderTarget2D* DrawWidgetToRenderTarget() override; 33 | virtual FString GetWidgetTitle() override; 34 | // End of TInnerWidgetPrinter interface. 35 | 36 | // Returns the title from the material graph in the format "[material name]-[graph title]". 37 | static bool GetMaterialGraphTitle(const TSharedPtr& MaterialGraphEditor, FString& Title); 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/MaterialGraphPrinter/Public/MaterialGraphPrinter/WidgetPrinters/MaterialGraphPrinter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GenericGraphPrinter/WidgetPrinters/GenericGraphPrinter.h" 7 | #include "MaterialGraphPrinter.generated.h" 8 | 9 | /** 10 | * A class of graph printers dedicated to material assets. 11 | * Print the preview window along with the graph editor. 12 | */ 13 | UCLASS() 14 | class MATERIALGRAPHPRINTER_API UMaterialGraphPrinter : public UGenericGraphPrinter 15 | { 16 | GENERATED_BODY() 17 | 18 | public: 19 | // The priority of this widget printer. 20 | static constexpr int32 MaterialGraphPrinterPriority = (GenericGraphPrinterPriority + 50); 21 | 22 | public: 23 | // UWidgetPrinter interface. 24 | virtual int32 GetPriority() const override; 25 | virtual TOptional CheckIfSupported(const TSharedRef& TestWidget) const override; 26 | virtual UPrintWidgetOptions* CreateDefaultPrintOptions( 27 | const UPrintWidgetOptions::EPrintScope PrintScope, 28 | const UPrintWidgetOptions::EExportMethod ExportMethod 29 | ) const override; 30 | virtual TSharedRef CreatePrintModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const override; 31 | virtual TSharedRef CreateRestoreModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const override; 32 | // End of UWidgetPrinter interface. 33 | }; 34 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ReferenceViewerPrinter/Private/ReferenceViewerPrinter/ReferenceViewerPrinterModule.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "CoreMinimal.h" 4 | #include "Modules/ModuleManager.h" 5 | 6 | namespace GraphPrinter 7 | { 8 | class FMaterialGraphPrinterModule : public IModuleInterface 9 | { 10 | public: 11 | // IModuleInterface interface. 12 | virtual void StartupModule() override; 13 | virtual void ShutdownModule() override; 14 | // End of IModuleInterface interface. 15 | }; 16 | 17 | void FMaterialGraphPrinterModule::StartupModule() 18 | { 19 | } 20 | 21 | void FMaterialGraphPrinterModule::ShutdownModule() 22 | { 23 | } 24 | } 25 | 26 | IMPLEMENT_MODULE(GraphPrinter::FMaterialGraphPrinterModule, ReferenceViewerPrinter) 27 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ReferenceViewerPrinter/Private/ReferenceViewerPrinter/WidgetPrinters/InnerReferenceViewerPrinter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "ReferenceViewerPrinter/WidgetPrinters/InnerReferenceViewerPrinter.h" 4 | #include "SGraphEditorImpl.h" 5 | #include "ReferenceViewer/EdGraph_ReferenceViewer.h" 6 | 7 | namespace GraphPrinter 8 | { 9 | FReferenceViewerPrinter::FReferenceViewerPrinter(UPrintWidgetOptions* InPrintOptions, const FSimpleDelegate& InOnPrinterProcessingFinished) 10 | : Super(InPrintOptions, InOnPrinterProcessingFinished) 11 | { 12 | } 13 | 14 | FReferenceViewerPrinter::FReferenceViewerPrinter(URestoreWidgetOptions* InRestoreOptions, const FSimpleDelegate& InOnPrinterProcessingFinished) 15 | : Super(InRestoreOptions, InOnPrinterProcessingFinished) 16 | { 17 | } 18 | 19 | bool FReferenceViewerPrinter::CanPrintWidget() const 20 | { 21 | if (Super::CanPrintWidget()) 22 | { 23 | const TSharedPtr GraphEditor = FindTargetWidget(PrintOptions->SearchTarget); 24 | return IsValid(Cast(GraphEditor->GetCurrentGraph())); 25 | } 26 | 27 | return false; 28 | } 29 | 30 | FString FReferenceViewerPrinter::GetWidgetTitle() 31 | { 32 | FString Title; 33 | GetReferenceViewerGraphTitle(Widget, Title); 34 | return Title; 35 | } 36 | 37 | bool FReferenceViewerPrinter::GetReferenceViewerGraphTitle(const TSharedPtr& ReferenceViewerGraphEditor, FString& Title) 38 | { 39 | Title = TEXT("InvalidReferenceViewer"); 40 | 41 | const auto* ReferenceViewerGraph = Cast(ReferenceViewerGraphEditor->GetCurrentGraph()); 42 | if (!IsValid(ReferenceViewerGraph)) 43 | { 44 | return false; 45 | } 46 | 47 | const TArray& Assets = ReferenceViewerGraph->GetCurrentGraphRootIdentifiers(); 48 | #if UE_5_00_OR_LATER 49 | if (Assets.IsEmpty()) 50 | #else 51 | if (Assets.Num() == 0) 52 | #endif 53 | { 54 | return false; 55 | } 56 | 57 | Title = FString::Printf(TEXT("ReferenceViewer-%s"), *FPaths::GetBaseFilename(Assets[0].PackageName.ToString())); 58 | return true; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ReferenceViewerPrinter/Private/ReferenceViewerPrinter/WidgetPrinters/InnerReferenceViewerPrinter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GenericGraphPrinter/WidgetPrinters/InnerGenericGraphPrinter.h" 7 | 8 | namespace GraphPrinter 9 | { 10 | /** 11 | * An inner class with the ability to print and restore graph editors. 12 | */ 13 | class REFERENCEVIEWERPRINTER_API FReferenceViewerPrinter 14 | : public TGraphPrinter 15 | { 16 | public: 17 | using Super = TGraphPrinter; 18 | 19 | public: 20 | // Constructor. 21 | FReferenceViewerPrinter(UPrintWidgetOptions* InPrintOptions, const FSimpleDelegate& InOnPrinterProcessingFinished); 22 | FReferenceViewerPrinter(URestoreWidgetOptions* InRestoreOptions, const FSimpleDelegate& InOnPrinterProcessingFinished); 23 | 24 | // IInnerWidgetPrinter interface. 25 | virtual bool CanPrintWidget() const override; 26 | // End of IInnerWidgetPrinter interface. 27 | 28 | // TInnerWidgetPrinter interface. 29 | virtual FString GetWidgetTitle() override; 30 | // End of TInnerWidgetPrinter interface. 31 | 32 | // Returns the title from the reference viewer graph in the format "ReferenceViewer-[package name]". 33 | static bool GetReferenceViewerGraphTitle(const TSharedPtr& ReferenceViewerGraphEditor, FString& Title); 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ReferenceViewerPrinter/Private/ReferenceViewerPrinter/WidgetPrinters/ReferenceViewerPrinter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "ReferenceViewerPrinter/WidgetPrinters/ReferenceViewerPrinter.h" 4 | #include "ReferenceViewerPrinter/WidgetPrinters/InnerReferenceViewerPrinter.h" 5 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 6 | 7 | #if UE_5_01_OR_LATER 8 | #include UE_INLINE_GENERATED_CPP_BY_NAME(ReferenceViewerPrinter) 9 | #endif 10 | 11 | int32 UReferenceViewerPrinter::GetPriority() const 12 | { 13 | return ReferenceViewerPrinterPriority; 14 | } 15 | 16 | TOptional UReferenceViewerPrinter::CheckIfSupported(const TSharedRef& TestWidget) const 17 | { 18 | const TSharedPtr ReferenceViewerGraphEditor = GraphPrinter::FReferenceViewerPrinter::FindTargetWidgetFromSearchTarget(TestWidget); 19 | if (!ReferenceViewerGraphEditor.IsValid()) 20 | { 21 | return {}; 22 | } 23 | 24 | FString ReferenceViewerGraphTitle; 25 | if (!GraphPrinter::FReferenceViewerPrinter::GetReferenceViewerGraphTitle(ReferenceViewerGraphEditor, ReferenceViewerGraphTitle)) 26 | { 27 | return {}; 28 | } 29 | 30 | return GraphPrinter::FSupportedWidget(ReferenceViewerGraphEditor.ToSharedRef(), ReferenceViewerGraphTitle, GetPriority()); 31 | } 32 | 33 | TSharedRef UReferenceViewerPrinter::CreatePrintModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const 34 | { 35 | return MakeShared( 36 | GetPrintOptions(), 37 | OnPrinterProcessingFinished 38 | ); 39 | } 40 | 41 | TSharedRef UReferenceViewerPrinter::CreateRestoreModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const 42 | { 43 | return MakeShared( 44 | GetRestoreOptions(), 45 | OnPrinterProcessingFinished 46 | ); 47 | } 48 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ReferenceViewerPrinter/Private/ReferenceViewerPrinter/WidgetPrinters/ReferenceViewerPrinter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GenericGraphPrinter/WidgetPrinters/GenericGraphPrinter.h" 7 | #include "ReferenceViewerPrinter.generated.h" 8 | 9 | /** 10 | * A class of graph printers dedicated to material assets. 11 | * Print the preview window along with the graph editor. 12 | */ 13 | UCLASS() 14 | class REFERENCEVIEWERPRINTER_API UReferenceViewerPrinter : public UGenericGraphPrinter 15 | { 16 | GENERATED_BODY() 17 | 18 | public: 19 | // The priority of this widget printer. 20 | static constexpr int32 ReferenceViewerPrinterPriority = (GenericGraphPrinterPriority + 100); 21 | 22 | public: 23 | // UWidgetPrinter interface. 24 | virtual int32 GetPriority() const override; 25 | virtual TOptional CheckIfSupported(const TSharedRef& TestWidget) const override; 26 | virtual TSharedRef CreatePrintModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const override; 27 | virtual TSharedRef CreateRestoreModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const override; 28 | // End of UWidgetPrinter interface. 29 | }; 30 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ReferenceViewerPrinter/ReferenceViewerPrinter.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class ReferenceViewerPrinter : ModuleRules 6 | { 7 | public ReferenceViewerPrinter(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 10 | #if UE_5_2_OR_LATER 11 | IncludeOrderVersion = EngineIncludeOrderVersion.Latest; 12 | #endif 13 | 14 | PublicDependencyModuleNames.AddRange( 15 | new string[] 16 | { 17 | "Core", 18 | } 19 | ); 20 | 21 | PrivateDependencyModuleNames.AddRange( 22 | new string[] 23 | { 24 | "CoreUObject", 25 | "UMG", 26 | "Slate", 27 | "SlateCore", 28 | "Engine", 29 | "UnrealEd", 30 | "MainFrame", 31 | "RenderCore", 32 | "AssetManagerEditor", 33 | 34 | "GraphPrinterGlobals", 35 | "WidgetPrinter", 36 | "GenericGraphPrinter", 37 | "TextChunkHelper", 38 | "ClipboardImageExtension", 39 | } 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/TextChunkHelper/Private/TextChunkHelper/Png/PngTextChunk.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "TextChunkHelper/ITextChunk.h" 7 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 8 | 9 | #if WITH_UNREALPNG 10 | 11 | THIRD_PARTY_INCLUDES_START 12 | // Make sure no other versions of libpng headers are picked up. 13 | #if WITH_LIBPNG_1_6 14 | #if UE_5_06_OR_LATER 15 | #include "ThirdParty/libPNG/libPNG-1.6.44/png.h" 16 | #include "ThirdParty/libPNG/libPNG-1.6.44/pngstruct.h" 17 | #include "ThirdParty/libPNG/libPNG-1.6.44/pnginfo.h" 18 | #else 19 | #include "ThirdParty/libPNG/libPNG-1.6.37/png.h" 20 | #include "ThirdParty/libPNG/libPNG-1.6.37/pngstruct.h" 21 | #include "ThirdParty/libPNG/libPNG-1.6.37/pnginfo.h" 22 | #endif 23 | #else 24 | #include "ThirdParty/libPNG/libPNG-1.5.2/png.h" 25 | #endif 26 | THIRD_PARTY_INCLUDES_END 27 | 28 | namespace TextChunkHelper 29 | { 30 | /** 31 | * A helper class for accessing text chunks in png files. 32 | */ 33 | class TEXTCHUNKHELPER_API FPngTextChunk : public ITextChunk 34 | { 35 | public: 36 | // Constructor. 37 | FPngTextChunk(); 38 | 39 | protected: 40 | // ITextChunk interface. 41 | virtual bool Write(const TMap& MapToWrite) override; 42 | virtual bool Read(TMap& MapToRead) override; 43 | virtual bool Initialize(const FString& InFilename, const void* InCompressedData, int64 InCompressedSize) override; 44 | // End of ITextChunk interface. 45 | 46 | // Checks if the format of the loaded image file is png. 47 | virtual bool IsPng() const; 48 | 49 | // Callbacks for the libpng. 50 | static void UserReadCompressed(png_structp PngPtr, png_bytep Data, png_size_t Length); 51 | static void UserWriteCompressed(png_structp PngPtr, png_bytep Data, png_size_t Length); 52 | static void UserFlushData(png_structp PngPtr); 53 | static void UserError(png_structp PngPtr, png_const_charp ErrorMessage); 54 | static void UserWarning(png_structp PngPtr, png_const_charp WarningMessage); 55 | static void* UserMalloc(png_structp PngPtr, png_size_t Size); 56 | static void UserFree(png_structp PngPtr, png_voidp StructPtr); 57 | // End of callbacks for the libpng. 58 | 59 | protected: 60 | // The file path of the original file. 61 | FString Filename; 62 | 63 | // The compressed raw data. 64 | TArray CompressedData; 65 | 66 | // The read offset into our array. 67 | int64 ReadOffset; 68 | }; 69 | } 70 | #endif 71 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/TextChunkHelper/Private/TextChunkHelper/TextChunkHelperModule.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "TextChunkHelper/ITextChunkHelper.h" 4 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 5 | #include "UObject/Class.h" 6 | #include "Misc/FileHelper.h" 7 | #include "IImageWrapper.h" 8 | #include "IImageWrapperModule.h" 9 | #if WITH_UNREALPNG 10 | #include "TextChunkHelper/Png/PngTextChunk.h" 11 | #endif 12 | 13 | namespace TextChunkHelper 14 | { 15 | const FName ITextChunkHelper::PluginModuleName = TEXT("TextChunkHelper"); 16 | 17 | class FTextChunkHelperModule : public ITextChunkHelper 18 | { 19 | public: 20 | // IModuleInterface interface. 21 | virtual void StartupModule() override; 22 | virtual void ShutdownModule() override; 23 | // End of IModuleInterface interface. 24 | 25 | // ITextChunkHelper interface. 26 | virtual TSharedPtr CreateTextChunk(const FString& InFilename) const override; 27 | virtual bool IsSupportedImageFormat(const EDesiredImageFormat ImageFormat) const override; 28 | virtual void RegisterTextChunkGenerator( 29 | const EDesiredImageFormat ImageFormat, 30 | const FOnCreateTextChunk& GenerationProcess 31 | ) override; 32 | virtual void UnregisterTextChunkGenerator(const EDesiredImageFormat ImageFormat) override; 33 | // End of ITextChunkHelper interface. 34 | 35 | private: 36 | // The text chunk generation process for each image format. 37 | TMap GenerationProcesses; 38 | }; 39 | 40 | void FTextChunkHelperModule::StartupModule() 41 | { 42 | #if WITH_UNREALPNG 43 | RegisterTextChunkGenerator( 44 | EDesiredImageFormat::PNG, 45 | FOnCreateTextChunk::CreateLambda( 46 | []() -> TSharedPtr 47 | { 48 | return MakeShared(); 49 | } 50 | ) 51 | ); 52 | #endif 53 | } 54 | 55 | void FTextChunkHelperModule::ShutdownModule() 56 | { 57 | #if WITH_UNREALPNG 58 | UnregisterTextChunkGenerator(EDesiredImageFormat::PNG); 59 | #endif 60 | } 61 | 62 | TSharedPtr FTextChunkHelperModule::CreateTextChunk(const FString& InFilename) const 63 | { 64 | TArray CompressedData; 65 | if (!FFileHelper::LoadFileToArray(CompressedData, *InFilename)) 66 | { 67 | UE_LOG(LogGraphPrinter, Error, TEXT("Failed to load the file : %s"), *InFilename); 68 | return nullptr; 69 | } 70 | 71 | auto ToDesiredImageFormat = [](const EImageFormat ImageFormat) -> TOptional 72 | { 73 | switch (ImageFormat) 74 | { 75 | case EImageFormat::PNG: 76 | return EDesiredImageFormat::PNG; 77 | case EImageFormat::JPEG: 78 | return EDesiredImageFormat::JPG; 79 | case EImageFormat::BMP: 80 | return EDesiredImageFormat::BMP; 81 | case EImageFormat::EXR: 82 | return EDesiredImageFormat::EXR; 83 | default: 84 | break; 85 | }; 86 | 87 | return {}; 88 | }; 89 | 90 | auto& ImageWrapper = FModuleManager::LoadModuleChecked(TEXT("ImageWrapper")); 91 | const TOptional ImageFormat = ToDesiredImageFormat( 92 | ImageWrapper.DetectImageFormat( 93 | CompressedData.GetData(), 94 | CompressedData.Num() 95 | ) 96 | ); 97 | if (!ImageFormat.IsSet()) 98 | { 99 | return nullptr; 100 | } 101 | 102 | const FOnCreateTextChunk* GenerationProcess = GenerationProcesses.Find(ImageFormat.GetValue()); 103 | if (GenerationProcess == nullptr) 104 | { 105 | return nullptr; 106 | } 107 | 108 | check(GenerationProcess->IsBound()); 109 | 110 | TSharedPtr TextChunk = GenerationProcess->Execute(); 111 | if (!TextChunk.IsValid()) 112 | { 113 | return nullptr; 114 | } 115 | 116 | const ITextChunk::FInitializer Initializer(TextChunk.Get()); 117 | if (!Initializer.Initialize(InFilename, CompressedData.GetData(), CompressedData.Num())) 118 | { 119 | return nullptr; 120 | } 121 | 122 | return TextChunk; 123 | } 124 | 125 | bool FTextChunkHelperModule::IsSupportedImageFormat(const EDesiredImageFormat ImageFormat) const 126 | { 127 | return GenerationProcesses.Contains(ImageFormat); 128 | } 129 | 130 | void FTextChunkHelperModule::RegisterTextChunkGenerator( 131 | const EDesiredImageFormat ImageFormat, 132 | const FOnCreateTextChunk& GenerationProcess 133 | ) 134 | { 135 | if (FOnCreateTextChunk* ExistingProcess = GenerationProcesses.Find(ImageFormat)) 136 | { 137 | *ExistingProcess = GenerationProcess; 138 | UE_LOG(LogGraphPrinter, Log, TEXT("Overwrote the processing of %s."), *UEnum::GetDisplayValueAsText(ImageFormat).ToString()); 139 | } 140 | else 141 | { 142 | GenerationProcesses.Add(ImageFormat, GenerationProcess); 143 | } 144 | } 145 | 146 | void FTextChunkHelperModule::UnregisterTextChunkGenerator(const EDesiredImageFormat ImageFormat) 147 | { 148 | GenerationProcesses.Remove(ImageFormat); 149 | } 150 | } 151 | 152 | IMPLEMENT_MODULE(TextChunkHelper::FTextChunkHelperModule, TextChunkHelper) 153 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/TextChunkHelper/Public/TextChunkHelper/ITextChunk.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | namespace TextChunkHelper 8 | { 9 | /** 10 | * An interface for manipulating text chunks in image files. 11 | */ 12 | class TEXTCHUNKHELPER_API ITextChunk 13 | { 14 | public: 15 | // Destructor. 16 | virtual ~ITextChunk() = default; 17 | 18 | // Writes to text chunk of image file. 19 | virtual bool Write(const TMap& MapToWrite) = 0; 20 | 21 | // Reads into text chunks in image files. 22 | virtual bool Read(TMap& MapToRead) = 0; 23 | 24 | protected: 25 | // Copies loaded data to member variables. 26 | virtual bool Initialize(const FString& InFilename, const void* InCompressedData, const int64 InCompressedSize) = 0; 27 | 28 | public: 29 | // Partial friend for calling initialization from the factory class of the module class. 30 | struct FInitializer 31 | { 32 | private: 33 | friend class FTextChunkHelperModule; 34 | ITextChunk* This = nullptr; 35 | 36 | explicit FInitializer(ITextChunk* InThis) : This(InThis) { check(This != nullptr); } 37 | bool Initialize(const FString& InFilename, const void* InCompressedData, const int64 InCompressedSize) const 38 | { 39 | return This->Initialize(InFilename, InCompressedData, InCompressedSize); 40 | } 41 | }; 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/TextChunkHelper/Public/TextChunkHelper/ITextChunkHelper.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/ModuleManager.h" 7 | #include "ImageWriteTypes.h" 8 | #include "TextChunkHelper/ITextChunk.h" 9 | 10 | namespace TextChunkHelper 11 | { 12 | // Define the event for the text chunk generation process. 13 | DECLARE_DELEGATE_RetVal(TSharedPtr, FOnCreateTextChunk); 14 | 15 | /** 16 | * A public interface to the TextChunkHelper module. 17 | */ 18 | class ITextChunkHelper : public IModuleInterface 19 | { 20 | public: 21 | // The name of the module for this plugin. 22 | TEXTCHUNKHELPER_API static const FName PluginModuleName; 23 | 24 | public: 25 | // Returns singleton instance, loading the module on demand if needed. 26 | static ITextChunkHelper& Get() 27 | { 28 | return FModuleManager::LoadModuleChecked(PluginModuleName); 29 | } 30 | 31 | // Returns whether the module is loaded and ready to use. 32 | static bool IsAvailable() 33 | { 34 | return FModuleManager::Get().IsModuleLoaded(PluginModuleName); 35 | } 36 | 37 | // Returns a class of text chunks depending on the type of image file. 38 | virtual TSharedPtr CreateTextChunk(const FString& InFilename) const = 0; 39 | 40 | // Returns whether text chunks in the specified image format is supported. 41 | virtual bool IsSupportedImageFormat(const EDesiredImageFormat ImageFormat) const = 0; 42 | 43 | // Adds text chunk generation processing for the specified image format. 44 | virtual void RegisterTextChunkGenerator( 45 | const EDesiredImageFormat ImageFormat, 46 | const FOnCreateTextChunk& GenerationProcess 47 | ) = 0; 48 | 49 | // Deletes the text chunk generation process for the specified image format. 50 | virtual void UnregisterTextChunkGenerator(const EDesiredImageFormat ImageFormat) = 0; 51 | }; 52 | } 53 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/TextChunkHelper/TextChunkHelper.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class TextChunkHelper : ModuleRules 6 | { 7 | public TextChunkHelper(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 10 | #if UE_5_2_OR_LATER 11 | IncludeOrderVersion = EngineIncludeOrderVersion.Latest; 12 | #endif 13 | 14 | PublicDependencyModuleNames.AddRange( 15 | new string[] 16 | { 17 | "Core", 18 | } 19 | ); 20 | 21 | PrivateDependencyModuleNames.AddRange( 22 | new string[] 23 | { 24 | "CoreUObject", 25 | "ImageWrapper", 26 | "ImageWriteQueue", 27 | 28 | "GraphPrinterGlobals" 29 | } 30 | ); 31 | 32 | AddEngineThirdPartyPrivateStaticDependencies( 33 | Target, 34 | "zlib", 35 | "UElibPNG" 36 | ); 37 | 38 | PublicDefinitions.Add("WITH_TEXT_CHUNK_HELPER"); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ViewportPrinter/Private/ViewportPrinter/ViewportPrinterModule.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "CoreMinimal.h" 4 | #include "Modules/ModuleManager.h" 5 | 6 | namespace GraphPrinter 7 | { 8 | class FViewportPrinterModule : public IModuleInterface 9 | { 10 | public: 11 | // IModuleInterface interface. 12 | virtual void StartupModule() override; 13 | virtual void ShutdownModule() override; 14 | // End of IModuleInterface interface. 15 | }; 16 | 17 | void FViewportPrinterModule::StartupModule() 18 | { 19 | } 20 | 21 | void FViewportPrinterModule::ShutdownModule() 22 | { 23 | } 24 | } 25 | 26 | IMPLEMENT_MODULE(GraphPrinter::FViewportPrinterModule, ViewportPrinter) 27 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ViewportPrinter/Private/ViewportPrinter/WidgetPrinters/InnerViewportPrinter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "ViewportPrinter/WidgetPrinters/InnerViewportPrinter.h" 4 | #include "WidgetPrinter/Utilities/WidgetPrinterUtils.h" 5 | #include "WidgetPrinter/Utilities/CastSlateWidget.h" 6 | #include "Framework/Docking/SDockingTabStack.h" 7 | #include "Widgets/Docking/SDockTab.h" 8 | 9 | namespace GraphPrinter 10 | { 11 | FViewportPrinter::FViewportPrinter(UPrintWidgetOptions* InPrintOptions, const FSimpleDelegate& InOnPrinterProcessingFinished) 12 | : Super(InPrintOptions, InOnPrinterProcessingFinished) 13 | { 14 | } 15 | 16 | FViewportPrinter::FViewportPrinter(URestoreWidgetOptions* InRestoreOptions, const FSimpleDelegate& InOnPrinterProcessingFinished) 17 | : Super(InRestoreOptions, InOnPrinterProcessingFinished) 18 | { 19 | } 20 | 21 | TSharedPtr FViewportPrinter::FindTargetWidget(const TSharedPtr& SearchTarget) const 22 | { 23 | TSharedPtr ActualSearchTarget = SearchTarget; 24 | if (!ActualSearchTarget.IsValid()) 25 | { 26 | const TSharedRef GlobalTabManager = FGlobalTabmanager::Get(); 27 | const TSharedPtr ActiveTab = GlobalTabManager->GetActiveTab(); 28 | ActualSearchTarget = FWidgetPrinterUtils::FindNearestParentDockingTabStack(ActiveTab); 29 | } 30 | if (!ActualSearchTarget.IsValid()) 31 | { 32 | return nullptr; 33 | } 34 | 35 | return FindTargetWidgetFromSearchTarget(ActualSearchTarget); 36 | } 37 | 38 | void FViewportPrinter::PreDrawWidget() 39 | { 40 | const TSharedPtr Overlay = FWidgetPrinterUtils::FindNearestChildOverlay(Widget); 41 | if (Overlay.IsValid()) 42 | { 43 | ViewportPrinterParams.PreviousVisibility = Overlay->GetVisibility(); 44 | Overlay->SetVisibility(EVisibility::Collapsed); 45 | } 46 | } 47 | 48 | void FViewportPrinter::PostDrawWidget() 49 | { 50 | const TSharedPtr Overlay = FWidgetPrinterUtils::FindNearestChildOverlay(Widget); 51 | if (Overlay.IsValid()) 52 | { 53 | Overlay->SetVisibility(ViewportPrinterParams.PreviousVisibility); 54 | } 55 | } 56 | 57 | FString FViewportPrinter::GetWidgetTitle() 58 | { 59 | FString Title; 60 | GetViewportTitle(Widget, Title); 61 | return Title; 62 | } 63 | 64 | TSharedPtr FViewportPrinter::FindTargetWidgetFromSearchTarget(const TSharedPtr& SearchTarget) 65 | { 66 | TSharedPtr FoundViewport = GP_CAST_SLATE_WIDGET(SViewport, SearchTarget); 67 | if (!FoundViewport.IsValid()) 68 | { 69 | FWidgetPrinterUtils::EnumerateChildWidgets( 70 | SearchTarget, 71 | [&](const TSharedPtr& ChildWidget) -> bool 72 | { 73 | const TSharedPtr Viewport = GP_CAST_SLATE_WIDGET(SViewport, ChildWidget); 74 | if (Viewport.IsValid()) 75 | { 76 | FoundViewport = Viewport; 77 | return false; 78 | } 79 | 80 | return true; 81 | } 82 | ); 83 | } 84 | 85 | return FoundViewport; 86 | } 87 | 88 | bool FViewportPrinter::GetViewportTitle(const TSharedPtr& Viewport, FString& Title) 89 | { 90 | Title = TEXT("InvalidViewport"); 91 | 92 | const TSharedPtr DockingTabStack = GP_CAST_SLATE_WIDGET(SDockingTabStack, FWidgetPrinterUtils::FindNearestParentDockingTabStack(Viewport)); 93 | if (DockingTabStack.IsValid()) 94 | { 95 | const TArray>& Tabs = DockingTabStack->GetTabs().AsArrayCopy(); 96 | for (const auto& Tab : Tabs) 97 | { 98 | if (Tab->IsActive()) 99 | { 100 | Title = Tab->GetTabLabel().ToString(); 101 | return true; 102 | } 103 | } 104 | 105 | if (Tabs.Num() == 1) 106 | { 107 | Title = Tabs[0]->GetTabLabel().ToString(); 108 | return true; 109 | } 110 | } 111 | 112 | return false; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ViewportPrinter/Private/ViewportPrinter/WidgetPrinters/ViewportPrinter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "ViewportPrinter/WidgetPrinters/ViewportPrinter.h" 4 | #include "ViewportPrinter/WidgetPrinters/InnerViewportPrinter.h" 5 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 6 | 7 | #if UE_5_01_OR_LATER 8 | #include UE_INLINE_GENERATED_CPP_BY_NAME(ViewportPrinter) 9 | #endif 10 | 11 | int32 UViewportPrinter::GetPriority() const 12 | { 13 | return ViewportPrinterPriority; 14 | } 15 | 16 | TOptional UViewportPrinter::CheckIfSupported(const TSharedRef& TestWidget) const 17 | { 18 | const TSharedPtr Viewport = GraphPrinter::FViewportPrinter::FindTargetWidgetFromSearchTarget(TestWidget); 19 | if (!Viewport.IsValid()) 20 | { 21 | return {}; 22 | } 23 | 24 | FString ViewportTitle; 25 | if (!GraphPrinter::FViewportPrinter::GetViewportTitle(Viewport, ViewportTitle)) 26 | { 27 | return {}; 28 | } 29 | 30 | return GraphPrinter::FSupportedWidget(Viewport.ToSharedRef(), ViewportTitle, GetPriority()); 31 | } 32 | 33 | TSharedRef UViewportPrinter::CreatePrintModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const 34 | { 35 | return MakeShared( 36 | GetPrintOptions(), 37 | OnPrinterProcessingFinished 38 | ); 39 | } 40 | 41 | TSharedRef UViewportPrinter::CreateRestoreModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const 42 | { 43 | return MakeShared( 44 | GetRestoreOptions(), 45 | OnPrinterProcessingFinished 46 | ); 47 | } 48 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ViewportPrinter/Public/ViewportPrinter/WidgetPrinters/InnerViewportPrinter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "WidgetPrinter/WidgetPrinters/InnerWidgetPrinter.h" 7 | #include "Widgets/SViewport.h" 8 | 9 | namespace GraphPrinter 10 | { 11 | /** 12 | * An inner class with the ability to print viewport. 13 | */ 14 | class VIEWPORTPRINTER_API FViewportPrinter 15 | : public TInnerWidgetPrinter 16 | { 17 | public: 18 | using Super = TInnerWidgetPrinter; 19 | 20 | public: 21 | // Constructor. 22 | FViewportPrinter(UPrintWidgetOptions* InPrintOptions, const FSimpleDelegate& InOnPrinterProcessingFinished); 23 | FViewportPrinter(URestoreWidgetOptions* InRestoreOptions, const FSimpleDelegate& InOnPrinterProcessingFinished); 24 | 25 | // TInnerWidgetPrinter interface. 26 | virtual TSharedPtr FindTargetWidget(const TSharedPtr& SearchTarget) const override; 27 | virtual void PreDrawWidget() override; 28 | virtual void PostDrawWidget() override; 29 | virtual FString GetWidgetTitle() override; 30 | // End of TInnerWidgetPrinter interface. 31 | 32 | // Finds the target widget from the search target. 33 | static TSharedPtr FindTargetWidgetFromSearchTarget(const TSharedPtr& SearchTarget); 34 | 35 | // Returns the title from the viewport. 36 | static bool GetViewportTitle(const TSharedPtr& Viewport, FString& Title); 37 | 38 | protected: 39 | // A group of parameters that must be retained for processing. 40 | struct FViewportPrinterParams 41 | { 42 | // The original visibility to temporarily hide the viewport menu widget. 43 | EVisibility PreviousVisibility; 44 | }; 45 | FViewportPrinterParams ViewportPrinterParams; 46 | }; 47 | } 48 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ViewportPrinter/Public/ViewportPrinter/WidgetPrinters/ViewportPrinter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "WidgetPrinter/WidgetPrinters/WidgetPrinter.h" 7 | #include "ViewportPrinter.generated.h" 8 | 9 | /** 10 | * A class of graph printers dedicated to viewport in levels, materials, animation blueprints, etc. 11 | */ 12 | UCLASS() 13 | class VIEWPORTPRINTER_API UViewportPrinter : public UWidgetPrinter 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | // The priority of this widget printer. 19 | static constexpr int32 ViewportPrinterPriority = 150; 20 | 21 | public: 22 | // UWidgetPrinter interface. 23 | virtual int32 GetPriority() const override; 24 | virtual TOptional CheckIfSupported(const TSharedRef& TestWidget) const override; 25 | virtual TSharedRef CreatePrintModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const override; 26 | virtual TSharedRef CreateRestoreModeInnerPrinter(const FSimpleDelegate& OnPrinterProcessingFinished) const override; 27 | // End of UWidgetPrinter interface. 28 | }; 29 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/ViewportPrinter/ViewportPrinter.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class ViewportPrinter : ModuleRules 6 | { 7 | public ViewportPrinter(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 10 | #if UE_5_2_OR_LATER 11 | IncludeOrderVersion = EngineIncludeOrderVersion.Latest; 12 | #endif 13 | 14 | PublicDependencyModuleNames.AddRange( 15 | new string[] 16 | { 17 | "Core", 18 | } 19 | ); 20 | 21 | PrivateDependencyModuleNames.AddRange( 22 | new string[] 23 | { 24 | "CoreUObject", 25 | "UMG", 26 | "Slate", 27 | "SlateCore", 28 | "Engine", 29 | "UnrealEd", 30 | "MainFrame", 31 | "RenderCore", 32 | 33 | "GraphPrinterGlobals", 34 | "WidgetPrinter", 35 | "TextChunkHelper", 36 | "ClipboardImageExtension", 37 | } 38 | ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/WidgetPrinter/Private/WidgetPrinter/SupportedWidgetRegistryImpl.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "WidgetPrinter/ISupportedWidgetRegistry.h" 4 | #include "WidgetPrinter/IWidgetPrinterRegistry.h" 5 | #include "WidgetPrinter/Utilities/WidgetPrinterUtils.h" 6 | #include "Framework/Application/SlateApplication.h" 7 | 8 | namespace GraphPrinter 9 | { 10 | class FSupportedWidgetRegistryImpl : public ISupportedWidgetRegistry 11 | { 12 | public: 13 | // Constructor. 14 | FSupportedWidgetRegistryImpl(); 15 | 16 | // Destructor. 17 | virtual ~FSupportedWidgetRegistryImpl() override; 18 | 19 | // ISupportedWidgetRegistry interface. 20 | virtual void CollectSupportedWidget() override; 21 | virtual const TArray& GetSupportedWidgets() const override; 22 | virtual TOptional GetSelectedWidget() const override; 23 | virtual void SetSelectedWidget(const FGuid Identifier) override; 24 | virtual bool WasAnyMenuVisibleInPreviousFrame() const override; 25 | // End of ISupportedWidgetRegistry interface. 26 | 27 | private: 28 | // Called when before slate application ticks. 29 | void HandleOnPreTick(const float DeltaTime); 30 | 31 | private: 32 | // The list of widgets supported by either printer. 33 | TArray RegisteredWidgets; 34 | 35 | // The widget selected in a menu from RegisteredWidgets. 36 | FGuid SelectedWidgetIdentifier; 37 | 38 | // Whether menus such as the tools menu and toolbar were visible in the previous frame. 39 | bool bWasAnyMenuVisibleInPreviousFrame; 40 | 41 | // The lambda function that compares widget information by unique ID. 42 | TFunction EqualsByIdentifier = [&](const FSupportedWidget& RegisteredWidget) -> bool 43 | { 44 | return (RegisteredWidget.GetIdentifier() == SelectedWidgetIdentifier); 45 | }; 46 | }; 47 | 48 | FSupportedWidgetRegistryImpl::FSupportedWidgetRegistryImpl() 49 | : bWasAnyMenuVisibleInPreviousFrame(false) 50 | { 51 | if (FSlateApplication::IsInitialized()) 52 | { 53 | FSlateApplication::Get().OnPreTick().AddRaw(this, &FSupportedWidgetRegistryImpl::HandleOnPreTick); 54 | } 55 | } 56 | 57 | FSupportedWidgetRegistryImpl::~FSupportedWidgetRegistryImpl() 58 | { 59 | if (FSlateApplication::IsInitialized()) 60 | { 61 | FSlateApplication::Get().OnPreTick().RemoveAll(this); 62 | } 63 | } 64 | 65 | void FSupportedWidgetRegistryImpl::CollectSupportedWidget() 66 | { 67 | RegisteredWidgets.Empty(); 68 | 69 | FWidgetPrinterUtils::EnumerateChildWidgets( 70 | FSlateApplication::Get().GetActiveTopLevelWindow(), 71 | [&](const TSharedPtr& ChildWidget) -> bool 72 | { 73 | if (ChildWidget.IsValid()) 74 | { 75 | const TOptional& SupportedWidget = IWidgetPrinterRegistry::Get().CheckIfSupported(ChildWidget.ToSharedRef()); 76 | if (SupportedWidget.IsSet()) 77 | { 78 | RegisteredWidgets.AddUnique(SupportedWidget.GetValue()); 79 | } 80 | } 81 | 82 | return true; 83 | } 84 | ); 85 | } 86 | 87 | const TArray& FSupportedWidgetRegistryImpl::GetSupportedWidgets() const 88 | { 89 | return RegisteredWidgets; 90 | } 91 | 92 | TOptional FSupportedWidgetRegistryImpl::GetSelectedWidget() const 93 | { 94 | if (const FSupportedWidget* FoundRegisteredWidget = RegisteredWidgets.FindByPredicate(EqualsByIdentifier)) 95 | { 96 | return *FoundRegisteredWidget; 97 | } 98 | 99 | return {}; 100 | } 101 | 102 | void FSupportedWidgetRegistryImpl::SetSelectedWidget(const FGuid Identifier) 103 | { 104 | if (RegisteredWidgets.ContainsByPredicate(EqualsByIdentifier)) 105 | { 106 | SelectedWidgetIdentifier = Identifier; 107 | } 108 | } 109 | 110 | bool FSupportedWidgetRegistryImpl::WasAnyMenuVisibleInPreviousFrame() const 111 | { 112 | return bWasAnyMenuVisibleInPreviousFrame; 113 | } 114 | 115 | void FSupportedWidgetRegistryImpl::HandleOnPreTick(const float DeltaTime) 116 | { 117 | RegisteredWidgets.RemoveAll( 118 | [](const FSupportedWidget& RegisteredWidget) -> bool 119 | { 120 | return !RegisteredWidget.IsValid(); 121 | } 122 | ); 123 | 124 | if (!SelectedWidgetIdentifier.IsValid() || !RegisteredWidgets.ContainsByPredicate(EqualsByIdentifier)) 125 | { 126 | #if UE_5_00_OR_LATER 127 | if (!RegisteredWidgets.IsEmpty()) 128 | #else 129 | if (RegisteredWidgets.Num() > 0) 130 | #endif 131 | { 132 | SelectedWidgetIdentifier = RegisteredWidgets[0].GetIdentifier(); 133 | } 134 | } 135 | 136 | bWasAnyMenuVisibleInPreviousFrame = FSlateApplication::Get().AnyMenusVisible(); 137 | } 138 | 139 | namespace SupportedWidgetHolder 140 | { 141 | static TUniquePtr Instance; 142 | } 143 | 144 | void ISupportedWidgetRegistry::Register() 145 | { 146 | SupportedWidgetHolder::Instance = MakeUnique(); 147 | } 148 | 149 | void ISupportedWidgetRegistry::Unregister() 150 | { 151 | SupportedWidgetHolder::Instance.Reset(); 152 | } 153 | 154 | ISupportedWidgetRegistry& ISupportedWidgetRegistry::Get() 155 | { 156 | // Don't call before Register is called or after Unregister is called. 157 | check(SupportedWidgetHolder::Instance.IsValid()); 158 | return *SupportedWidgetHolder::Instance.Get(); 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/WidgetPrinter/Private/WidgetPrinter/Types/PrintWidgetOptions.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "WidgetPrinter/Types/PrintWidgetOptions.h" 4 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 5 | #if UE_5_02_OR_LATER 6 | #include "Engine/TextureDefines.h" 7 | #else 8 | #include "Engine/Texture.h" 9 | #endif 10 | #include "UObject/Package.h" 11 | 12 | #if UE_5_01_OR_LATER 13 | #include UE_INLINE_GENERATED_CPP_BY_NAME(PrintWidgetOptions) 14 | #endif 15 | 16 | UPrintWidgetOptions::UPrintWidgetOptions() 17 | : PrintScope(EPrintScope::All) 18 | , ExportMethod(EExportMethod::ImageFile) 19 | #ifdef WITH_TEXT_CHUNK_HELPER 20 | , bIsIncludeWidgetInfoInImageFile(true) 21 | #endif 22 | , bUseGamma(true) 23 | , MaxImageSize(FVector2D::ZeroVector) 24 | , RenderingScale(1.f) 25 | , FilteringMode(TF_Default) 26 | , SearchTarget(nullptr) 27 | { 28 | ImageWriteOptions.bAsync = true; 29 | ImageWriteOptions.bOverwriteFile = false; 30 | ImageWriteOptions.CompressionQuality = 0; 31 | ImageWriteOptions.Format = EDesiredImageFormat::PNG; 32 | } 33 | 34 | UPrintWidgetOptions* UPrintWidgetOptions::Duplicate(const TSubclassOf& DestinationClass) const 35 | { 36 | auto* Destination = NewObject(GetTransientPackage(), DestinationClass); 37 | if (IsValid(Destination)) 38 | { 39 | Destination->PrintScope = PrintScope; 40 | Destination->ExportMethod = ExportMethod; 41 | Destination->bIsIncludeWidgetInfoInImageFile = bIsIncludeWidgetInfoInImageFile; 42 | Destination->bUseGamma = bUseGamma; 43 | Destination->MaxImageSize = MaxImageSize; 44 | Destination->RenderingScale = RenderingScale; 45 | Destination->FilteringMode = FilteringMode; 46 | Destination->ImageWriteOptions = ImageWriteOptions; 47 | Destination->OutputDirectoryPath = OutputDirectoryPath; 48 | Destination->SearchTarget = SearchTarget; 49 | } 50 | 51 | return Destination; 52 | } 53 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/WidgetPrinter/Private/WidgetPrinter/Types/RestoreWidgetOptions.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "WidgetPrinter/Types/RestoreWidgetOptions.h" 4 | #include "WidgetPrinter/Utilities/WidgetPrinterSettings.h" 5 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 6 | #include "GraphPrinterGlobals/Utilities/GraphPrinterUtils.h" 7 | #include "UObject/Package.h" 8 | #include "Misc/Paths.h" 9 | #include "ImageWriteTypes.h" 10 | 11 | #if UE_5_01_OR_LATER 12 | #include UE_INLINE_GENERATED_CPP_BY_NAME(RestoreWidgetOptions) 13 | #endif 14 | 15 | URestoreWidgetOptions::URestoreWidgetOptions() 16 | : DialogTitle(TEXT("Select the png file that contains the widget info")) 17 | , DefaultFile(TEXT("")) 18 | , SearchTarget(nullptr) 19 | { 20 | const auto& Settings = GraphPrinter::GetSettings(); 21 | DefaultPath = Settings.OutputDirectory.Path; 22 | SetFileTypesFromImageFormat(EDesiredImageFormat::PNG); 23 | } 24 | 25 | URestoreWidgetOptions* URestoreWidgetOptions::Duplicate(const TSubclassOf& DestinationClass) const 26 | { 27 | auto* Destination = NewObject(GetTransientPackage(), DestinationClass); 28 | if (IsValid(Destination)) 29 | { 30 | Destination->DialogTitle = DialogTitle; 31 | Destination->DefaultPath = DefaultPath; 32 | Destination->DefaultFile = DefaultFile; 33 | Destination->FileTypes = FileTypes; 34 | Destination->SearchTarget = SearchTarget; 35 | Destination->SourceImageFilePath = SourceImageFilePath; 36 | } 37 | 38 | return Destination; 39 | } 40 | 41 | FString URestoreWidgetOptions::GetSourceImageFilePath() const 42 | { 43 | check(HasValidSourceImageFilePath()); 44 | return SourceImageFilePath.GetValue(); 45 | } 46 | 47 | void URestoreWidgetOptions::SetSourceImageFilePath(const FString& InSourceImageFilePath) 48 | { 49 | SourceImageFilePath = InSourceImageFilePath; 50 | } 51 | 52 | bool URestoreWidgetOptions::HasValidSourceImageFilePath() const 53 | { 54 | if (SourceImageFilePath.IsSet()) 55 | { 56 | return FPaths::FileExists(SourceImageFilePath.GetValue()); 57 | } 58 | 59 | return false; 60 | } 61 | 62 | void URestoreWidgetOptions::SetFileTypesFromImageFormat(const EDesiredImageFormat ImageFormat) 63 | { 64 | const FString FormatString = GraphPrinter::FGraphPrinterUtils::GetImageFileExtension(ImageFormat, false); 65 | FileTypes = FString::Printf( 66 | TEXT("%s Image (.%s)|*.%s"), 67 | *FormatString.ToUpper(), 68 | *FormatString.ToLower(), 69 | *FormatString.ToLower() 70 | ); 71 | } 72 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/WidgetPrinter/Private/WidgetPrinter/Types/SupportedWidget.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "WidgetPrinter/Types/SupportedWidget.h" 4 | #include "WidgetPrinter/WidgetPrinters/WidgetPrinter.h" 5 | #include "Framework/Application/SlateApplication.h" 6 | 7 | namespace GraphPrinter 8 | { 9 | FSupportedWidget::FSupportedWidget(const TSharedRef& InWidget, const FString& InDisplayName, const int32 InPriority) 10 | : Identifier(FGuid::NewGuid()) 11 | , Widget(InWidget) 12 | , DisplayName(FText::FromString(InDisplayName)) 13 | , Priority(InPriority) 14 | { 15 | } 16 | 17 | bool FSupportedWidget::IsValid() const 18 | { 19 | if (!Widget.IsValid()) 20 | { 21 | return false; 22 | } 23 | 24 | auto& SlateApplication = FSlateApplication::Get(); 25 | 26 | FWidgetPath WidgetPath; 27 | if (!SlateApplication.FindPathToWidget(Widget.Pin().ToSharedRef(), WidgetPath)) 28 | { 29 | return false; 30 | } 31 | 32 | return WidgetPath.IsValid(); 33 | } 34 | 35 | const FGuid& FSupportedWidget::GetIdentifier() const 36 | { 37 | return Identifier; 38 | } 39 | 40 | TSharedPtr FSupportedWidget::GetWidget() const 41 | { 42 | return Widget.Pin(); 43 | } 44 | 45 | const FText& FSupportedWidget::GetDisplayName() const 46 | { 47 | return DisplayName; 48 | } 49 | 50 | bool FSupportedWidget::operator==(const FSupportedWidget& Other) const 51 | { 52 | if (Identifier == Other.Identifier) 53 | { 54 | return true; 55 | } 56 | 57 | if (!Widget.IsValid() || !Other.Widget.IsValid()) 58 | { 59 | return (!Widget.IsValid() && !Other.Widget.IsValid()); 60 | } 61 | 62 | return (Widget.Pin()->GetId() == Other.Widget.Pin()->GetId()); 63 | } 64 | 65 | bool FSupportedWidget::operator<(const FSupportedWidget& Other) const 66 | { 67 | return (Priority < Other.Priority); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/WidgetPrinter/Private/WidgetPrinter/Utilities/WidgetPrinterSettings.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "WidgetPrinter/Utilities/WidgetPrinterSettings.h" 4 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 5 | #include "GraphPrinterGlobals/Utilities/GraphPrinterUtils.h" 6 | #ifdef WITH_TEXT_CHUNK_HELPER 7 | #include "TextChunkHelper/ITextChunkHelper.h" 8 | #endif 9 | #include "ImageWriteTypes.h" 10 | #include "Engine/Texture.h" 11 | #include "Misc/Paths.h" 12 | #include "HAL/FileManager.h" 13 | 14 | #if UE_5_01_OR_LATER 15 | #include UE_INLINE_GENERATED_CPP_BY_NAME(WidgetPrinterSettings) 16 | #endif 17 | 18 | #define LOCTEXT_NAMESPACE "WidgetPrinterSettings" 19 | 20 | UWidgetPrinterSettings::UWidgetPrinterSettings() 21 | : Format(EDesiredImageFormat::PNG) 22 | , CompressionQuality(0) 23 | , FilteringMode(TF_Default) 24 | , bUseGamma(true) 25 | , MaxImageSize(15000.f, 15000.f) 26 | , RenderingScale(1.f) 27 | , bCanOverwriteFileWhenExport(false) 28 | { 29 | #ifdef WITH_TEXT_CHUNK_HELPER 30 | bIsIncludeWidgetInfoInImageFile = true; 31 | #else 32 | bIsIncludeWidgetInfoInImageFile = false; 33 | #endif 34 | 35 | OutputDirectory.Path = FPaths::ConvertRelativePathToFull( 36 | FPaths::Combine( 37 | FPaths::ProjectSavedDir(), 38 | GraphPrinter::Global::PluginName.ToString() 39 | ) 40 | ); 41 | } 42 | 43 | void UWidgetPrinterSettings::PostInitProperties() 44 | { 45 | Super::PostInitProperties(); 46 | 47 | #ifndef WITH_TEXT_CHUNK_HELPER 48 | bIsIncludeWidgetInfoInImageFile = false; 49 | #endif 50 | 51 | // If you don't have a directory, you can't open it with Explorer, so create it first. 52 | auto& FileManager = IFileManager::Get(); 53 | if (!FileManager.DirectoryExists(*OutputDirectory.Path)) 54 | { 55 | FileManager.MakeDirectory(*OutputDirectory.Path, true); 56 | } 57 | 58 | ModifyFormat(); 59 | ModifyCompressionQuality(); 60 | ModifyMaxImageSize(); 61 | } 62 | 63 | void UWidgetPrinterSettings::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) 64 | { 65 | Super::PostEditChangeProperty(PropertyChangedEvent); 66 | 67 | if (PropertyChangedEvent.MemberProperty == nullptr) 68 | { 69 | return; 70 | } 71 | 72 | if (PropertyChangedEvent.MemberProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UWidgetPrinterSettings, bIsIncludeWidgetInfoInImageFile) || 73 | PropertyChangedEvent.MemberProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UWidgetPrinterSettings, Format)) 74 | { 75 | ModifyFormat(); 76 | } 77 | 78 | if (PropertyChangedEvent.MemberProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UWidgetPrinterSettings, Format) || 79 | PropertyChangedEvent.MemberProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UWidgetPrinterSettings, CompressionQuality)) 80 | { 81 | ModifyCompressionQuality(); 82 | } 83 | 84 | if (PropertyChangedEvent.MemberProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UWidgetPrinterSettings, MaxImageSize)) 85 | { 86 | ModifyMaxImageSize(); 87 | } 88 | } 89 | 90 | #if UE_4_25_OR_LATER 91 | bool UWidgetPrinterSettings::CanEditChange(const FProperty* InProperty) const 92 | #else 93 | bool UWidgetPrinterSettings::CanEditChange(const UProperty* InProperty) const 94 | #endif 95 | { 96 | if (InProperty != nullptr) 97 | { 98 | if (InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UWidgetPrinterSettings, bIsIncludeWidgetInfoInImageFile)) 99 | { 100 | #ifndef WITH_TEXT_CHUNK_HELPER 101 | return false; 102 | #endif 103 | } 104 | } 105 | 106 | return Super::CanEditChange(InProperty); 107 | } 108 | 109 | FString UWidgetPrinterSettings::GetSettingsName() const 110 | { 111 | return TEXT("WidgetPrinter"); 112 | } 113 | 114 | void UWidgetPrinterSettings::ModifyFormat() 115 | { 116 | #ifdef WITH_TEXT_CHUNK_HELPER 117 | if (bIsIncludeWidgetInfoInImageFile) 118 | { 119 | if (!TextChunkHelper::ITextChunkHelper::Get().IsSupportedImageFormat(Format)) 120 | { 121 | const FText Message = FText::Format( 122 | LOCTEXT("FormatWarningText", "The specified image format ({Extension}) does not support text chunks."), 123 | FText::FromString(GraphPrinter::FGraphPrinterUtils::GetImageFileExtension(Format, false)) 124 | ); 125 | GraphPrinter::FGraphPrinterUtils::ShowNotification( 126 | Message, 127 | GraphPrinter::FGraphPrinterUtils::CS_Fail 128 | ); 129 | 130 | bool bFoundSupportedImageFormat = false; 131 | if (const UEnum* DesiredImageFormatEnum = StaticEnum()) 132 | { 133 | for (int32 Index = 0; Index < DesiredImageFormatEnum->NumEnums() -1; Index++) 134 | { 135 | const auto DesiredImageFormat = static_cast(Index); 136 | if (TextChunkHelper::ITextChunkHelper::Get().IsSupportedImageFormat(DesiredImageFormat)) 137 | { 138 | Format = DesiredImageFormat; 139 | bFoundSupportedImageFormat = true; 140 | } 141 | } 142 | } 143 | if (!bFoundSupportedImageFormat) 144 | { 145 | bIsIncludeWidgetInfoInImageFile = false; 146 | } 147 | } 148 | } 149 | #endif 150 | } 151 | 152 | void UWidgetPrinterSettings::ModifyCompressionQuality() 153 | { 154 | int32 Max = 100; 155 | if (Format == EDesiredImageFormat::EXR) 156 | { 157 | Max = 1; 158 | } 159 | CompressionQuality = FMath::Clamp(CompressionQuality, 0, Max); 160 | } 161 | 162 | void UWidgetPrinterSettings::ModifyMaxImageSize() 163 | { 164 | if (MaxImageSize.X < 0.f) 165 | { 166 | MaxImageSize.X = 0.f; 167 | } 168 | if (MaxImageSize.Y < 0.f) 169 | { 170 | MaxImageSize.Y = 0.f; 171 | } 172 | } 173 | 174 | #undef LOCTEXT_NAMESPACE 175 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/WidgetPrinter/Private/WidgetPrinter/Utilities/WidgetPrinterUtils.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "WidgetPrinter/Utilities/WidgetPrinterUtils.h" 4 | #include "WidgetPrinter/Utilities/CastSlateWidget.h" 5 | #include "WidgetPrinter/ISupportedWidgetRegistry.h" 6 | #include "Framework/Application/SlateApplication.h" 7 | #include "Framework/Docking/SDockingTabStack.h" 8 | #include "Toolkits/SStandaloneAssetEditorToolkitHost.h" 9 | #include "Widgets/SOverlay.h" 10 | 11 | namespace GraphPrinter 12 | { 13 | void FWidgetPrinterUtils::EnumerateChildWidgets( 14 | const TSharedPtr& SearchTarget, 15 | const TFunction& ChildWidget)>& Predicate 16 | ) 17 | { 18 | if (!SearchTarget.IsValid()) 19 | { 20 | return; 21 | } 22 | 23 | FChildren* Children = SearchTarget->GetChildren(); 24 | if (Children == nullptr) 25 | { 26 | return; 27 | } 28 | 29 | for (int32 Index = 0; Index < Children->Num(); Index++) 30 | { 31 | TSharedPtr ChildWidget = Children->GetChildAt(Index); 32 | if (ChildWidget.IsValid()) 33 | { 34 | if (Predicate(ChildWidget)) 35 | { 36 | EnumerateChildWidgets(ChildWidget, Predicate); 37 | } 38 | } 39 | } 40 | } 41 | 42 | void FWidgetPrinterUtils::EnumerateParentWidgets( 43 | const TSharedPtr& SearchTarget, 44 | const TFunction& ParentWidget)>& Predicate 45 | ) 46 | { 47 | if (!SearchTarget.IsValid()) 48 | { 49 | return; 50 | } 51 | 52 | const TSharedPtr ParentWidget = SearchTarget->GetParentWidget(); 53 | if (!ParentWidget.IsValid()) 54 | { 55 | return; 56 | } 57 | 58 | if (Predicate(ParentWidget)) 59 | { 60 | EnumerateParentWidgets(ParentWidget, Predicate); 61 | } 62 | } 63 | 64 | TSharedPtr FWidgetPrinterUtils::FindNearestParentDockingTabStack(const TSharedPtr& SearchTarget) 65 | { 66 | TSharedPtr FoundDockingTabStack = GP_CAST_SLATE_WIDGET(SDockingTabStack, SearchTarget); 67 | if (!FoundDockingTabStack.IsValid()) 68 | { 69 | EnumerateParentWidgets( 70 | SearchTarget, 71 | [&FoundDockingTabStack](const TSharedPtr& ParentWidget) -> bool 72 | { 73 | const TSharedPtr DockingTabStack = GP_CAST_SLATE_WIDGET(SDockingTabStack, ParentWidget); 74 | if (DockingTabStack.IsValid()) 75 | { 76 | FoundDockingTabStack = DockingTabStack; 77 | return false; 78 | } 79 | 80 | return true; 81 | } 82 | ); 83 | } 84 | 85 | return FoundDockingTabStack; 86 | } 87 | 88 | TSharedPtr FWidgetPrinterUtils::FindNearestParentStandaloneAssetEditorToolkitHost(const TSharedPtr& SearchTarget) 89 | { 90 | TSharedPtr FoundStandaloneAssetEditorToolkitHost = GP_CAST_SLATE_WIDGET(SStandaloneAssetEditorToolkitHost, SearchTarget); 91 | if (!FoundStandaloneAssetEditorToolkitHost.IsValid()) 92 | { 93 | EnumerateParentWidgets( 94 | SearchTarget, 95 | [&FoundStandaloneAssetEditorToolkitHost](const TSharedPtr& ParentWidget) -> bool 96 | { 97 | const TSharedPtr StandaloneAssetEditorToolkitHost = GP_CAST_SLATE_WIDGET(SStandaloneAssetEditorToolkitHost, ParentWidget); 98 | if (StandaloneAssetEditorToolkitHost.IsValid()) 99 | { 100 | FoundStandaloneAssetEditorToolkitHost = StandaloneAssetEditorToolkitHost; 101 | return false; 102 | } 103 | 104 | return true; 105 | } 106 | ); 107 | } 108 | 109 | return FoundStandaloneAssetEditorToolkitHost; 110 | } 111 | 112 | TSharedPtr FWidgetPrinterUtils::FindNearestChildOverlay(const TSharedPtr& SearchTarget) 113 | { 114 | TSharedPtr FoundOverlay = GP_CAST_SLATE_WIDGET(SOverlay, SearchTarget); 115 | if (!FoundOverlay.IsValid()) 116 | { 117 | EnumerateChildWidgets( 118 | SearchTarget, 119 | [&FoundOverlay](const TSharedPtr& ChildWidget) -> bool 120 | { 121 | const TSharedPtr Overlay = GP_CAST_SLATE_WIDGET(SOverlay, ChildWidget); 122 | if (Overlay.IsValid()) 123 | { 124 | FoundOverlay = Overlay; 125 | return false; 126 | } 127 | 128 | return true; 129 | } 130 | ); 131 | } 132 | 133 | return FoundOverlay; 134 | } 135 | 136 | TSharedPtr FWidgetPrinterUtils::GetMostSuitableSearchTarget() 137 | { 138 | FSlateApplication& SlateApplication = FSlateApplication::Get(); 139 | 140 | const auto& SupportedWidgetRegistry = ISupportedWidgetRegistry::Get(); 141 | if (SupportedWidgetRegistry.WasAnyMenuVisibleInPreviousFrame()) 142 | { 143 | const TOptional& SelectedWidget = SupportedWidgetRegistry.GetSelectedWidget(); 144 | if (SelectedWidget.IsSet() && SelectedWidget->IsValid()) 145 | { 146 | UE_LOG(LogTemp, Warning, TEXT("%s"), *SelectedWidget->GetWidget()->GetTypeAsString()); 147 | return SelectedWidget->GetWidget(); 148 | } 149 | } 150 | 151 | const FWidgetPath WidgetsUnderCursor = SlateApplication.LocateWindowUnderMouse( 152 | SlateApplication.GetCursorPos(), SlateApplication.GetInteractiveTopLevelWindows() 153 | ); 154 | if (WidgetsUnderCursor.IsValid()) 155 | { 156 | const FArrangedChildren& Widgets = WidgetsUnderCursor.Widgets; 157 | return Widgets.Last().Widget; 158 | } 159 | 160 | return nullptr; 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/WidgetPrinter/Private/WidgetPrinter/WidgetPrinterModule.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "CoreMinimal.h" 4 | #include "Modules/ModuleManager.h" 5 | #include "WidgetPrinter/IWidgetPrinterRegistry.h" 6 | #include "WidgetPrinter/ISupportedWidgetRegistry.h" 7 | 8 | namespace GraphPrinter 9 | { 10 | class FWidgetPrinterModule : public IModuleInterface 11 | { 12 | public: 13 | // IModuleInterface interface. 14 | virtual void StartupModule() override; 15 | virtual void ShutdownModule() override; 16 | // End of IModuleInterface interface. 17 | }; 18 | 19 | void FWidgetPrinterModule::StartupModule() 20 | { 21 | // Registers widget printer registry. 22 | IWidgetPrinterRegistry::Register(); 23 | 24 | // Registers supported widget registry. 25 | ISupportedWidgetRegistry::Register(); 26 | } 27 | 28 | void FWidgetPrinterModule::ShutdownModule() 29 | { 30 | // Unregisters supported widget registry. 31 | ISupportedWidgetRegistry::Unregister(); 32 | 33 | // Unregisters widget printer registry. 34 | IWidgetPrinterRegistry::Unregister(); 35 | } 36 | } 37 | 38 | IMPLEMENT_MODULE(GraphPrinter::FWidgetPrinterModule, WidgetPrinter) 39 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/WidgetPrinter/Private/WidgetPrinter/WidgetPrinters/InnerWidgetPrinter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #include "WidgetPrinter/WidgetPrinters/InnerWidgetPrinter.h" 4 | #include "Slate/WidgetRenderer.h" 5 | #include "RenderingThread.h" 6 | 7 | namespace GraphPrinter 8 | { 9 | void IInnerWidgetPrinter::SetOnRendered(const FOnRendered& InOnRendered) 10 | { 11 | OnRendered = InOnRendered; 12 | } 13 | 14 | UTextureRenderTarget2D* IInnerWidgetPrinter::DrawWidgetToRenderTargetInternal( 15 | const TSharedRef& Widget, 16 | const FVector2D& DrawSize, 17 | const TextureFilter FilteringMode, 18 | const bool bUseGamma, 19 | const float RenderingScale 20 | ) 21 | { 22 | FWidgetRenderer* WidgetRenderer = new FWidgetRenderer(bUseGamma, false); 23 | if (WidgetRenderer == nullptr) 24 | { 25 | UE_LOG(LogGraphPrinter, Error, TEXT("Widget Renderer could not be generated.")); 26 | return nullptr; 27 | } 28 | 29 | UTextureRenderTarget2D* RenderTarget = FWidgetRenderer::CreateTargetFor( 30 | DrawSize, 31 | FilteringMode, 32 | bUseGamma 33 | ); 34 | if (!IsValid(RenderTarget)) 35 | { 36 | UE_LOG(LogGraphPrinter, Error, TEXT("Failed to generate RenderTarget.")); 37 | return nullptr; 38 | } 39 | if (bUseGamma) 40 | { 41 | RenderTarget->bForceLinearGamma = true; 42 | RenderTarget->UpdateResourceImmediate(true); 43 | } 44 | 45 | // Since the drawing result may be corrupted the first time, draws multiple times. 46 | for (int32 Count = 0; Count < DrawTimes; Count++) 47 | { 48 | WidgetRenderer->DrawWidget( 49 | RenderTarget, 50 | Widget, 51 | RenderingScale, 52 | DrawSize, 53 | 0.f 54 | ); 55 | FlushRenderingCommands(); 56 | } 57 | 58 | BeginCleanup(WidgetRenderer); 59 | 60 | return RenderTarget; 61 | } 62 | 63 | void IInnerWidgetPrinter::ExportRenderTargetToImageFileInternal( 64 | UTextureRenderTarget2D* RenderTarget, 65 | const FString& Filename, 66 | const FImageWriteOptions& ImageWriteOptions 67 | ) 68 | { 69 | if (!IsValid(RenderTarget)) 70 | { 71 | return; 72 | } 73 | 74 | UImageWriteBlueprintLibrary::ExportToDisk( 75 | RenderTarget, 76 | Filename, 77 | ImageWriteOptions 78 | ); 79 | 80 | // As a symptomatic treatment for the problem that the first image output after startup is whitish, 81 | // the first output is re-outputs as many times as NumberOfRedrawsWhenFirstTime. 82 | if (IsFirstOutput.GetValue()) 83 | { 84 | for (int32 Count = 0; Count < NumberOfReOutputWhenFirstTime; Count++) 85 | { 86 | FImageWriteOptions ForceOverwriteAndQuiet = ImageWriteOptions; 87 | ForceOverwriteAndQuiet.bOverwriteFile = true; 88 | ForceOverwriteAndQuiet.NativeOnComplete = nullptr; 89 | UImageWriteBlueprintLibrary::ExportToDisk( 90 | RenderTarget, 91 | Filename, 92 | ForceOverwriteAndQuiet 93 | ); 94 | IsFirstOutput.Switch(); 95 | } 96 | } 97 | } 98 | 99 | FOneWayBool IInnerWidgetPrinter::IsFirstOutput = true; 100 | } 101 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/WidgetPrinter/Public/WidgetPrinter/ISupportedWidgetRegistry.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "WidgetPrinter/Types/SupportedWidget.h" 7 | 8 | namespace GraphPrinter 9 | { 10 | /** 11 | * A class that holds the widgets that are currently available and supported by any printer. 12 | */ 13 | class WIDGETPRINTER_API ISupportedWidgetRegistry 14 | { 15 | public: 16 | // Registers-Unregisters and instance getter this class. 17 | static void Register(); 18 | static void Unregister(); 19 | static ISupportedWidgetRegistry& Get(); 20 | 21 | // Destructor. 22 | virtual ~ISupportedWidgetRegistry() = default; 23 | 24 | // Collects supported widgets from the currently displayed screen. 25 | virtual void CollectSupportedWidget() = 0; 26 | 27 | // Returns a list of widgets currently available and supported by any printer. 28 | virtual const TArray& GetSupportedWidgets() const = 0; 29 | 30 | // Returns the widget selected from the menu. 31 | virtual TOptional GetSelectedWidget() const = 0; 32 | 33 | // Selects the widget specified by index from the supported widgets. 34 | virtual void SetSelectedWidget(const FGuid Identifier) = 0; 35 | 36 | // Returns whether menus such as the tools menu and toolbar were visible in the previous frame. 37 | virtual bool WasAnyMenuVisibleInPreviousFrame() const = 0; 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/WidgetPrinter/Public/WidgetPrinter/IWidgetPrinterRegistry.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "WidgetPrinter/WidgetPrinters/WidgetPrinter.h" 7 | 8 | class SWidget; 9 | 10 | namespace GraphPrinter 11 | { 12 | struct FSupportedWidget; 13 | 14 | /** 15 | * A class that allows you to collect and search widget printers. 16 | */ 17 | class WIDGETPRINTER_API IWidgetPrinterRegistry 18 | { 19 | public: 20 | // Registers-Unregisters and instance getter this class. 21 | static void Register(); 22 | static void Unregister(); 23 | static IWidgetPrinterRegistry& Get(); 24 | 25 | // Destructor. 26 | virtual ~IWidgetPrinterRegistry() = default; 27 | 28 | // Returns a widget printer that meets the criteria. 29 | virtual UWidgetPrinter* FindAvailableWidgetPrinter(UPrintWidgetOptions* Options) const = 0; 30 | virtual UWidgetPrinter* FindAvailableWidgetPrinter(URestoreWidgetOptions* Options) const = 0; 31 | 32 | // Returns a data structure if the specified widget is supported by any printer. 33 | virtual TOptional CheckIfSupported(const TSharedRef& TestWidget) const = 0; 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/WidgetPrinter/Public/WidgetPrinter/Types/OneWayBool.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | namespace GraphPrinter 8 | { 9 | /** 10 | * A bool type that can change the value only once from the default value. 11 | */ 12 | struct FOneWayBool 13 | { 14 | public: 15 | FOneWayBool(const bool bInDefaultValue) 16 | : bDefaultValue(bInDefaultValue) 17 | , bValue(bInDefaultValue) 18 | { 19 | } 20 | 21 | bool GetValue() const 22 | { 23 | return bValue; 24 | } 25 | 26 | void Switch() 27 | { 28 | if (bDefaultValue == bValue) 29 | { 30 | bValue = !bValue; 31 | } 32 | } 33 | 34 | private: 35 | bool bDefaultValue; 36 | bool bValue; 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/WidgetPrinter/Public/WidgetPrinter/Types/PrintWidgetOptions.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "UObject/Object.h" 7 | #include "ImageWriteBlueprintLibrary.h" 8 | #include "Templates/SubclassOf.h" 9 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 10 | #if UE_5_02_OR_LATER 11 | #include "Engine/TextureDefines.h" 12 | #endif 13 | #include "PrintWidgetOptions.generated.h" 14 | 15 | class SWidget; 16 | #if !UE_5_02_OR_LATER 17 | enum TextureFilter; 18 | #endif 19 | 20 | /** 21 | * An optional class to specify when printing the widget. 22 | */ 23 | UCLASS() 24 | class WIDGETPRINTER_API UPrintWidgetOptions : public UObject 25 | { 26 | GENERATED_BODY() 27 | 28 | public: 29 | // An enum class that defines type of range to print. 30 | enum class EPrintScope : uint8 31 | { 32 | All, 33 | Selected, 34 | }; 35 | 36 | // An enum class that defines type of output destination for the printed image. 37 | enum class EExportMethod : uint8 38 | { 39 | RenderTarget, 40 | ImageFile, 41 | #ifdef WITH_CLIPBOARD_IMAGE_EXTENSION 42 | Clipboard, 43 | #endif 44 | }; 45 | 46 | public: 47 | // Constructor. 48 | UPrintWidgetOptions(); 49 | 50 | // Creates and returns a duplicate as the specified option class. 51 | virtual UPrintWidgetOptions* Duplicate(const TSubclassOf& DestinationClass) const; 52 | template 53 | TPrintOptions* Duplicate() 54 | { 55 | static_assert(TIsDerivedFrom::IsDerived, "This implementation wasn't tested for a filter that isn't a child of UPrintWidgetOptions."); 56 | 57 | return Cast(Duplicate(TPrintOptions::StaticClass())); 58 | } 59 | 60 | public: 61 | // The type of node range to print. 62 | EPrintScope PrintScope; 63 | 64 | // The type of output destination for the printed image. 65 | EExportMethod ExportMethod; 66 | 67 | #ifdef WITH_TEXT_CHUNK_HELPER 68 | // Whether to embed the widget information in the image file. 69 | // When this option is enabled, the image formats that can be selected are limited. 70 | bool bIsIncludeWidgetInfoInImageFile; 71 | #endif 72 | 73 | // Whether to output the drawing result affected by the gamma value. 74 | bool bUseGamma; 75 | 76 | // The maximum size of the output image. 77 | FVector2D MaxImageSize; 78 | 79 | // The drawing scale of the output image. 80 | float RenderingScale; 81 | 82 | // The texture filtering mode to use when outputting. 83 | TEnumAsByte FilteringMode; 84 | 85 | // The options related to image output processing. 86 | FImageWriteOptions ImageWriteOptions; 87 | 88 | // The directory path where the image file is output. 89 | FString OutputDirectoryPath; 90 | 91 | // The widget to search for a graph editor to draw on. 92 | TSharedPtr SearchTarget; 93 | }; 94 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/WidgetPrinter/Public/WidgetPrinter/Types/RestoreWidgetOptions.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "UObject/Object.h" 7 | #include "Templates/SubclassOf.h" 8 | #include "RestoreWidgetOptions.generated.h" 9 | 10 | class SWidget; 11 | enum class EDesiredImageFormat : uint8; 12 | 13 | /** 14 | * An optional class to specify when restore the state of the widget. 15 | */ 16 | UCLASS() 17 | class WIDGETPRINTER_API URestoreWidgetOptions : public UObject 18 | { 19 | GENERATED_BODY() 20 | 21 | public: 22 | // Constructor. 23 | URestoreWidgetOptions(); 24 | 25 | // Creates and returns a duplicate as the specified option class. 26 | virtual URestoreWidgetOptions* Duplicate(const TSubclassOf& DestinationClass) const; 27 | template 28 | TRestoreOptions* Duplicate() 29 | { 30 | static_assert(TIsDerivedFrom::IsDerived, "This implementation wasn't tested for a filter that isn't a child of URestoreWidgetOptions."); 31 | 32 | return Cast(Duplicate(TRestoreOptions::StaticClass())); 33 | } 34 | 35 | // Returns the path of the image file that will be the source to restore. 36 | // Do not call when no valid value is set. 37 | FString GetSourceImageFilePath() const; 38 | 39 | // Sets the path of the image file that will be the source to restore. 40 | void SetSourceImageFilePath(const FString& InSourceImageFilePath); 41 | 42 | // Returns whether a valid image file path is specified. 43 | bool HasValidSourceImageFilePath() const; 44 | 45 | // Generates a File Types string from the image file types. 46 | void SetFileTypesFromImageFormat(const EDesiredImageFormat ImageFormat); 47 | 48 | public: 49 | // The title that appears in the dialog window that lets the user specify the file to use for the restore. 50 | FString DialogTitle; 51 | 52 | // The path to the directory that is first opened in a dialog window that allows the user to specify the files to use for restoration. 53 | FString DefaultPath; 54 | 55 | // The path to the file that is first opened in a dialog window that allows the user to specify the files to use for restoration. 56 | FString DefaultFile; 57 | 58 | // The file type that you can select in the dialog window where you can specify the file that the user will use for the restore. 59 | FString FileTypes; 60 | 61 | // The widget to search for a graph editor to draw on. 62 | TSharedPtr SearchTarget; 63 | 64 | private: 65 | // The path of the image file that will be the source to restore. 66 | TOptional SourceImageFilePath; 67 | }; 68 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/WidgetPrinter/Public/WidgetPrinter/Types/SupportedWidget.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | class SWidget; 8 | class UWidgetPrinter; 9 | 10 | namespace GraphPrinter 11 | { 12 | /** 13 | * A struct of information about widgets supported by one of the printers. 14 | */ 15 | struct WIDGETPRINTER_API FSupportedWidget 16 | { 17 | public: 18 | // Constructor. 19 | FSupportedWidget(const TSharedRef& InWidget, const FString& InDisplayName, const int32 InPriority); 20 | 21 | // Returns whether the widget that this data has is enabled. 22 | bool IsValid() const; 23 | 24 | // Returns the unique ID to identify data. 25 | const FGuid& GetIdentifier() const; 26 | 27 | // Returns the supported widget instance. 28 | TSharedPtr GetWidget() const; 29 | 30 | // Returns the name displayed on the editor UI. 31 | const FText& GetDisplayName() const; 32 | 33 | // Overload operators for use with arrays. 34 | bool operator==(const FSupportedWidget& Other) const; 35 | bool operator<(const FSupportedWidget& Other) const; 36 | 37 | private: 38 | // The unique ID to identify data. 39 | FGuid Identifier; 40 | 41 | // The supported widget instance. 42 | TWeakPtr Widget; 43 | 44 | // The name displayed on the editor UI. 45 | FText DisplayName; 46 | 47 | // The priority of the corresponding printer. 48 | int32 Priority; 49 | }; 50 | } 51 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/WidgetPrinter/Public/WidgetPrinter/Utilities/CastSlateWidget.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | namespace GraphPrinter 8 | { 9 | namespace Private 10 | { 11 | /** 12 | * Cast function for classes that inherit from SWidget. 13 | */ 14 | template 15 | TSharedPtr CastSlateWidget(TSharedPtr FromPtr, const FName& ToClassName) 16 | { 17 | static_assert(TIsDerivedFrom::IsDerived, "This implementation wasn't tested for a filter that isn't a child of SWidget."); 18 | static_assert(TIsDerivedFrom::IsDerived, "This implementation wasn't tested for a filter that isn't a child of SWidget."); 19 | 20 | if (FromPtr.IsValid()) 21 | { 22 | if (FromPtr->GetType() == ToClassName) 23 | { 24 | return StaticCastSharedPtr(FromPtr); 25 | } 26 | } 27 | 28 | return nullptr; 29 | } 30 | } 31 | } 32 | 33 | #define GP_CAST_SLATE_WIDGET(ToClass, FromPtr) GraphPrinter::Private::CastSlateWidget(FromPtr, #ToClass) 34 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/WidgetPrinter/Public/WidgetPrinter/Utilities/WidgetPrinterSettings.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GraphPrinterGlobals/Utilities/GraphPrinterSettings.h" 7 | #include "GraphPrinterGlobals/GraphPrinterGlobals.h" 8 | #include "Engine/EngineTypes.h" 9 | #if UE_5_02_OR_LATER 10 | #include "Engine/TextureDefines.h" 11 | #endif 12 | #include "WidgetPrinterSettings.generated.h" 13 | 14 | #if !UE_5_02_OR_LATER 15 | enum TextureFilter; 16 | #endif 17 | enum class EDesiredImageFormat : uint8; 18 | 19 | /** 20 | * A class that sets the default values for UPrintWidgetOptions from the editor preferences. 21 | */ 22 | UCLASS() 23 | class WIDGETPRINTER_API UWidgetPrinterSettings : public UGraphPrinterSettings 24 | { 25 | GENERATED_BODY() 26 | 27 | public: 28 | // Whether to embed the widget information in the image file. 29 | // When this option is enabled, the image formats that can be selected are limited. 30 | UPROPERTY(EditAnywhere, Config, Category = "Image") 31 | bool bIsIncludeWidgetInfoInImageFile; 32 | 33 | // The desired output image format to write to disk. 34 | UPROPERTY(EditAnywhere, Config, Category = "Image") 35 | EDesiredImageFormat Format; 36 | 37 | // The image format specific compression setting. Either 0 (Default) or 1 (Uncompressed) for EXRs, or a value between 0 and 100. 38 | UPROPERTY(EditAnywhere, Config, Category = "Image", meta = (UIMin = 0, UIMax = 100)) 39 | int32 CompressionQuality; 40 | 41 | // The texture filtering mode to use when outputting. 42 | UPROPERTY(EditAnywhere, Config, Category = "Image") 43 | TEnumAsByte FilteringMode; 44 | 45 | // Whether to output the drawing result affected by the gamma value. 46 | UPROPERTY(EditAnywhere, Config, Category = "Image") 47 | bool bUseGamma; 48 | 49 | // The maximum size of the output image. 50 | // There is no limit at (0.f, 0.f). 51 | // If set it too high, you may run out of video memory and crash. 52 | UPROPERTY(EditAnywhere, Config, Category = "Image") 53 | FVector2D MaxImageSize; 54 | 55 | // The drawing scale of the output image. 56 | // Decrease the value if you want to draw a graph larger than MaxImageSize. 57 | // Decreasing the value may cause defects in the drawing result. 58 | UPROPERTY(EditAnywhere, Config, Category = "Image", meta = (ClampMin = 0.1f, ClampMax = 1.f, UIMin = 0.1f, UIMax = 1.f)) 59 | float RenderingScale; 60 | 61 | // Whether to overwrite the image if it already exists when export. 62 | UPROPERTY(EditAnywhere, Config, Category = "File") 63 | bool bCanOverwriteFileWhenExport; 64 | 65 | // The directory path where the image file is output. 66 | UPROPERTY(EditAnywhere, Config, Category = "File") 67 | FDirectoryPath OutputDirectory; 68 | 69 | public: 70 | // Constructor. 71 | UWidgetPrinterSettings(); 72 | 73 | // UObject interface. 74 | virtual void PostInitProperties() override; 75 | virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override; 76 | #if UE_4_25_OR_LATER 77 | virtual bool CanEditChange(const FProperty* InProperty) const override; 78 | #else 79 | virtual bool CanEditChange(const UProperty* InProperty) const override; 80 | #endif 81 | // End of UObject interface. 82 | 83 | // UGraphPrinterSettings interface. 84 | virtual FString GetSettingsName() const override; 85 | // End of UGraphPrinterSettings interface. 86 | 87 | protected: 88 | // Functions called when the value changes. 89 | void ModifyFormat(); 90 | void ModifyCompressionQuality(); 91 | void ModifyMaxImageSize(); 92 | }; 93 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/WidgetPrinter/Public/WidgetPrinter/Utilities/WidgetPrinterUtils.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | class SWidget; 8 | class SWindow; 9 | class SOverlay; 10 | 11 | namespace GraphPrinter 12 | { 13 | /** 14 | * A utility class that defines utility functions used in widget printer classes. 15 | */ 16 | class WIDGETPRINTER_API FWidgetPrinterUtils 17 | { 18 | public: 19 | // Enumerates all widgets that are children of SearchTarget. 20 | // if Predicate returns false, stop recursive process. 21 | static void EnumerateChildWidgets( 22 | const TSharedPtr& SearchTarget, 23 | const TFunction& ChildWidget)>& Predicate 24 | ); 25 | 26 | // Enumerates all widgets that are parents of SearchTarget. 27 | // if Predicate returns false, stop recursive process. 28 | static void EnumerateParentWidgets( 29 | const TSharedPtr& SearchTarget, 30 | const TFunction& ParentWidget)>& Predicate 31 | ); 32 | 33 | // Finds the docking tab stack that contains the specified dock tab. 34 | static TSharedPtr FindNearestParentDockingTabStack(const TSharedPtr& SearchTarget); 35 | 36 | // Returns the toolkit host of the Asset Editor that contains the specified tab. 37 | static TSharedPtr FindNearestParentStandaloneAssetEditorToolkitHost(const TSharedPtr& SearchTarget); 38 | 39 | // Finds the widget that is the overlay and nearest parent of SearchTarget. 40 | static TSharedPtr FindNearestChildOverlay(const TSharedPtr& SearchTarget); 41 | 42 | // Returns the nearest docking tab stack from the widget under the mouse cursor. 43 | // Returns nullptr if the widget under the mouse cursor belongs to a menu stack window. 44 | static TSharedPtr GetMostSuitableSearchTarget(); 45 | }; 46 | } 47 | -------------------------------------------------------------------------------- /Plugins/GraphPrinter/Source/WidgetPrinter/WidgetPrinter.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2025 Naotsun. All Rights Reserved. 2 | 3 | using System.IO; 4 | using UnrealBuildTool; 5 | 6 | public class WidgetPrinter : ModuleRules 7 | { 8 | public WidgetPrinter(ReadOnlyTargetRules Target) : base(Target) 9 | { 10 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 11 | #if UE_5_2_OR_LATER 12 | IncludeOrderVersion = EngineIncludeOrderVersion.Latest; 13 | #endif 14 | 15 | PublicDependencyModuleNames.AddRange( 16 | new string[] 17 | { 18 | "Core", 19 | "ImageWriteQueue", 20 | } 21 | ); 22 | 23 | PrivateDependencyModuleNames.AddRange( 24 | new string[] 25 | { 26 | "CoreUObject", 27 | "UMG", 28 | "Slate", 29 | "SlateCore", 30 | "Engine", 31 | "UnrealEd", 32 | "MainFrame", 33 | "RenderCore", 34 | 35 | "GraphPrinterGlobals", 36 | "TextChunkHelper", 37 | "ClipboardImageExtension", 38 | } 39 | ); 40 | 41 | PublicIncludePaths.AddRange( 42 | new string[] 43 | { 44 | #if UE_5_2_OR_LATER 45 | // In UHT for UE5.2 and later, when you use PublicIncludePaths, the base path of the module's include will be replaced with the first value, so add the correct base path of the include first. 46 | Path.Combine(ModuleDirectory, ".."), 47 | #endif 48 | // To use SDockingTabStack. 49 | Path.Combine(EngineDirectory, "Source", "Runtime", "Slate", "Private"), 50 | 51 | // To use SStandaloneAssetEditorToolkitHost. 52 | Path.Combine(EngineDirectory, "Source", "Editor", "UnrealEd", "Private"), 53 | } 54 | ); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Please refer to this repository for the documentation of this plugin. 2 | このプラグインのドキュメントについてはこちらのリポジトリを参照してください。 3 | 4 | https://github.com/Naotsun19B/GraphPrinter-Document 5 | -------------------------------------------------------------------------------- /Source/GraphPrinterPlugin.Target.cs: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | using System.Collections.Generic; 5 | 6 | public class GraphPrinterPluginTarget : TargetRules 7 | { 8 | public GraphPrinterPluginTarget( TargetInfo Target) : base(Target) 9 | { 10 | Type = TargetType.Game; 11 | DefaultBuildSettings = BuildSettingsVersion.Latest; 12 | #if UE_5_2_OR_LATER 13 | IncludeOrderVersion = EngineIncludeOrderVersion.Latest; 14 | #endif 15 | ExtraModuleNames.AddRange( new string[] { "GraphPrinterPlugin" } ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Source/GraphPrinterPlugin/GraphPrinterPlugin.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class GraphPrinterPlugin : ModuleRules 6 | { 7 | public GraphPrinterPlugin(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 10 | 11 | PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" }); 12 | 13 | PrivateDependencyModuleNames.AddRange(new string[] { }); 14 | 15 | // Uncomment if you are using Slate UI 16 | // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" }); 17 | 18 | // Uncomment if you are using online features 19 | // PrivateDependencyModuleNames.Add("OnlineSubsystem"); 20 | 21 | // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/GraphPrinterPlugin/GraphPrinterPlugin.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "GraphPrinterPlugin.h" 4 | #include "Modules/ModuleManager.h" 5 | 6 | IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, GraphPrinterPlugin, "GraphPrinterPlugin" ); 7 | -------------------------------------------------------------------------------- /Source/GraphPrinterPlugin/GraphPrinterPlugin.h: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | -------------------------------------------------------------------------------- /Source/GraphPrinterPluginEditor.Target.cs: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | using System.Collections.Generic; 5 | 6 | public class GraphPrinterPluginEditorTarget : TargetRules 7 | { 8 | public GraphPrinterPluginEditorTarget( TargetInfo Target) : base(Target) 9 | { 10 | Type = TargetType.Editor; 11 | DefaultBuildSettings = BuildSettingsVersion.Latest; 12 | #if UE_5_2_OR_LATER 13 | IncludeOrderVersion = EngineIncludeOrderVersion.Latest; 14 | #endif 15 | ExtraModuleNames.AddRange( new string[] { "GraphPrinterPlugin" } ); 16 | } 17 | } 18 | --------------------------------------------------------------------------------