├── .gitignore ├── Adventure.uplugin ├── Config ├── DefaultAdventure.ini └── FilterPlugin.ini ├── Content ├── Icons │ ├── T_AdventureAssetIcon.uasset │ └── icon_class_SlateBrush_64x.uasset └── Widget │ ├── WBP_AdventureEntry.uasset │ ├── WBP_AdventureGiverEntry.uasset │ ├── WBP_AdventureGiverWidget.uasset │ ├── WBP_AdventureList.uasset │ ├── WBP_ObjectiveEntry.uasset │ └── WBP_ObjectiveList.uasset ├── LICENSE ├── README.md ├── Resources └── Icon128.png └── Source ├── Adventure ├── Adventure.Build.cs ├── AdventureGameplayTags.cpp ├── AdventureGameplayTags.h ├── AdventureLogChannels.cpp ├── AdventureLogChannels.h ├── Private │ ├── AdventureAsset.cpp │ ├── AdventureBlueprintGeneratedClass.cpp │ ├── AdventureComponent.cpp │ ├── AdventureGlobals.cpp │ ├── AdventureInterface.cpp │ ├── AdventureModule.cpp │ ├── AdventurePluginSettings.cpp │ ├── AdventureSaveObject.cpp │ ├── AdventureSharedComponent.cpp │ ├── FAdventureGraphNodeMinimal.cpp │ ├── Library │ │ └── AdventureBlueprintLibrary.cpp │ └── Volumes │ │ ├── AdventureObjectiveTriggerVolume.cpp │ │ ├── AdventureStartTriggerVolume.cpp │ │ └── AdventureTriggerBoxVolume.cpp └── Public │ ├── AdventureAsset.h │ ├── AdventureBlueprintGeneratedClass.h │ ├── AdventureComponent.h │ ├── AdventureGlobals.h │ ├── AdventureInterface.h │ ├── AdventureMacros.h │ ├── AdventureModule.h │ ├── AdventurePluginSettings.h │ ├── AdventureSaveObject.h │ ├── AdventureSharedComponent.h │ ├── FAdventureGraphNodeMinimal.h │ ├── Library │ └── AdventureBlueprintLibrary.h │ └── Volumes │ ├── AdventureObjectiveTriggerVolume.h │ ├── AdventureStartTriggerVolume.h │ └── AdventureTriggerBoxVolume.h ├── AdventureEditor ├── AdventureEditor.Build.cs ├── Private │ ├── AdventureEditorModule.cpp │ ├── AdventureMessageLogEditor.cpp │ ├── AdventureMessageLogEditor.h │ ├── AdventureStyle.cpp │ ├── AssetTools │ │ ├── FAssetTypeActions_AdventureAsset.cpp │ │ ├── FAssetTypeActions_AdventureAsset.h │ │ ├── FAssetTypeActions_AdventureBase.cpp │ │ ├── FAssetTypeActions_AdventureBase.h │ │ ├── FAssetTypeActions_AdventureSaveObject.cpp │ │ └── FAssetTypeActions_AdventureSaveObject.h │ └── Factory │ │ ├── AdventureAssetActorFactory.cpp │ │ ├── AdventureAssetActorFactory.h │ │ ├── AdventureAssetFactory.cpp │ │ ├── AdventureAssetFactory.h │ │ ├── AdventureClassPicker.cpp │ │ ├── AdventureClassPicker.h │ │ ├── AdventureSaveObjectFactory.cpp │ │ └── AdventureSaveObjectFactory.h └── Public │ ├── AdventureEditorModule.h │ └── AdventureStyle.h ├── AdventureGraphEditor ├── AdventureGraphEditor.Build.cs ├── Private │ ├── AdventureBlueprintCompiler.cpp │ ├── AdventureBlueprintCompiler.h │ ├── AdventureBlueprintEditorToolbar.cpp │ ├── AdventureBlueprintEditorToolbar.h │ ├── AdventureEdGraph.cpp │ ├── AdventureEdGraph.h │ ├── AdventureEditorTabFactories.cpp │ ├── AdventureEditorTabFactories.h │ ├── AdventureGraphEditor.cpp │ ├── AdventureGraphEditor.h │ ├── AdventureGraphEditorModule.cpp │ ├── AdventureGraphNodes │ │ ├── K2Node_AbandonAdventure.cpp │ │ ├── K2Node_AbandonAdventure.h │ │ ├── K2Node_AdventureState.cpp │ │ ├── K2Node_AdventureState.h │ │ ├── K2Node_BreakObjective.cpp │ │ ├── K2Node_BreakObjective.h │ │ ├── K2Node_CompleteAdventure.cpp │ │ ├── K2Node_CompleteAdventure.h │ │ ├── K2Node_ConstructAdventureAsset.cpp │ │ ├── K2Node_ConstructAdventureAsset.h │ │ ├── K2Node_FailAdventure.cpp │ │ ├── K2Node_FailAdventure.h │ │ ├── K2Node_MakeObjective.cpp │ │ ├── K2Node_MakeObjective.h │ │ ├── K2Node_Root.cpp │ │ └── K2Node_Root.h │ ├── AdventureGraphSchema.cpp │ ├── AdventureGraphSchema.h │ ├── BlueprintAssets │ │ ├── AdventureAssetBlueprint.cpp │ │ └── AdventureSaveObjectBlueprint.cpp │ ├── FAdventureEditorApplicationMode.cpp │ ├── FAdventureEditorApplicationMode.h │ ├── FAdventureEditorCommands.cpp │ ├── FAdventureEditorCommands.h │ ├── ObjectiveDetailCustomization.cpp │ └── ObjectiveDetailCustomization.h └── Public │ ├── AdventureGraphEditorModule.h │ └── BlueprintAssets │ ├── AdventureAssetBlueprint.h │ └── AdventureSaveObjectBlueprint.h ├── AdventureTasks ├── AdventureTasks.Build.cs ├── Private │ ├── AdventureTasksModule.cpp │ └── Nodes │ │ ├── AdventureTask.cpp │ │ ├── AdventureTask_AddObjective.cpp │ │ ├── AdventureTask_ListenActiveAdventuresModified.cpp │ │ ├── AdventureTask_ListenForAdventureState.cpp │ │ ├── AdventureTask_ListenForLoadStartFinished.cpp │ │ ├── AdventureTask_ListenForSaveStartFinished.cpp │ │ ├── AdventureTask_ListenObjectiveEntryChanges.cpp │ │ └── AdventureTask_LoadChainedAdventures.cpp └── Public │ ├── AdventureTasksModule.h │ └── Nodes │ ├── AdventureTask.h │ ├── AdventureTask_AddObjective.h │ ├── AdventureTask_ListenActiveAdventuresModified.h │ ├── AdventureTask_ListenForAdventureState.h │ ├── AdventureTask_ListenForLoadStartFinished.h │ ├── AdventureTask_ListenForSaveStartFinished.h │ ├── AdventureTask_ListenObjectiveEntryChanges.h │ └── AdventureTask_LoadChainedAdventures.h └── AdventureTasksEditor ├── AdventureTasksEditor.Build.cs ├── Private ├── AdventureTasksEditorModule.cpp └── AdventureTasksNodes │ ├── K2Node_AddObjective.cpp │ ├── K2Node_AddObjective.h │ ├── K2Node_AppendObjective.cpp │ ├── K2Node_AppendObjective.h │ ├── K2Node_LatentAdventureTaskCall.cpp │ ├── K2Node_LatentAdventureTaskCall.h │ └── Slate │ ├── SGraphNode_AddObjective.cpp │ └── SGraphNode_AddObjective.h └── Public └── AdventureTasksEditorModule.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Visual Studio 2015 user specific files 2 | .vs/ 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | 22 | # Compiled Static libraries 23 | *.lai 24 | *.la 25 | *.a 26 | *.lib 27 | 28 | # Executables 29 | *.exe 30 | *.out 31 | *.app 32 | *.ipa 33 | 34 | # These project files can be generated by the engine 35 | *.xcodeproj 36 | *.xcworkspace 37 | *.sln 38 | *.suo 39 | *.opensdf 40 | *.sdf 41 | *.VC.db 42 | *.VC.opendb 43 | 44 | # Precompiled Assets 45 | SourceArt/**/*.png 46 | SourceArt/**/*.tga 47 | 48 | # Binary Files 49 | Binaries/* 50 | Plugins/*/Binaries/* 51 | 52 | # Builds 53 | Build/* 54 | 55 | # Whitelist PakBlacklist-.txt files 56 | !Build/*/ 57 | Build/*/** 58 | !Build/*/PakBlacklist*.txt 59 | 60 | # Don't ignore icon files in Build 61 | !Build/**/*.ico 62 | 63 | # Built data for maps 64 | *_BuiltData.uasset 65 | 66 | # Configuration files generated by the Editor 67 | Saved/* 68 | 69 | # Compiled source files for the engine to use 70 | Intermediate/* 71 | Plugins/*/Intermediate/* 72 | 73 | # Cache files for the editor to use 74 | DerivedDataCache/* 75 | -------------------------------------------------------------------------------- /Adventure.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "Version": 1, 4 | "VersionName": "1.0", 5 | "FriendlyName": "Adventure", 6 | "Description": "", 7 | "Category": "Other", 8 | "CreatedBy": "OlssonDev", 9 | "CreatedByURL": "", 10 | "DocsURL": "", 11 | "MarketplaceURL": "", 12 | "SupportURL": "", 13 | "CanContainContent": true, 14 | "IsBetaVersion": false, 15 | "IsExperimentalVersion": false, 16 | "Installed": false, 17 | "Modules": [ 18 | { 19 | "Name": "Adventure", 20 | "Type": "Runtime", 21 | "LoadingPhase": "Default", 22 | "PlatformAllowList": [ 23 | "Win64" 24 | ] 25 | }, 26 | { 27 | "Name": "AdventureEditor", 28 | "Type": "UncookedOnly", 29 | "LoadingPhase": "PostEngineInit", 30 | "PlatformAllowList": [ 31 | "Win64" 32 | ] 33 | }, 34 | { 35 | "Name": "AdventureGraphEditor", 36 | "Type": "UncookedOnly", 37 | "LoadingPhase": "PreDefault" 38 | }, 39 | { 40 | "Name": "AdventureTasks", 41 | "Type": "Runtime", 42 | "LoadingPhase": "PreDefault" 43 | }, 44 | { 45 | "Name": "AdventureTasksEditor", 46 | "Type": "UncookedOnly", 47 | "LoadingPhase": "PreDefault" 48 | } 49 | ] 50 | } -------------------------------------------------------------------------------- /Config/DefaultAdventure.ini: -------------------------------------------------------------------------------- 1 | [CoreRedirects] 2 | +PropertyRedirects=(OldName="/Script/Adventure.AdventureAsset.CurrentObjectives",NewName="/Script/Adventure.AdventureAsset.RegisteredObjectiveHandlers") -------------------------------------------------------------------------------- /Config/FilterPlugin.ini: -------------------------------------------------------------------------------- 1 | [FilterPlugin] 2 | ; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and 3 | ; may include "...", "*", and "?" wildcards to match directories, files, and individual characters respectively. 4 | ; 5 | ; Examples: 6 | ; /README.txt 7 | ; /Extras/... 8 | ; /Binaries/ThirdParty/*.dll 9 | -------------------------------------------------------------------------------- /Content/Icons/T_AdventureAssetIcon.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OlssonDev/Adventure/e3ca6d6d85f63f848a93d21c6d602f37ce65872c/Content/Icons/T_AdventureAssetIcon.uasset -------------------------------------------------------------------------------- /Content/Icons/icon_class_SlateBrush_64x.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OlssonDev/Adventure/e3ca6d6d85f63f848a93d21c6d602f37ce65872c/Content/Icons/icon_class_SlateBrush_64x.uasset -------------------------------------------------------------------------------- /Content/Widget/WBP_AdventureEntry.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OlssonDev/Adventure/e3ca6d6d85f63f848a93d21c6d602f37ce65872c/Content/Widget/WBP_AdventureEntry.uasset -------------------------------------------------------------------------------- /Content/Widget/WBP_AdventureGiverEntry.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OlssonDev/Adventure/e3ca6d6d85f63f848a93d21c6d602f37ce65872c/Content/Widget/WBP_AdventureGiverEntry.uasset -------------------------------------------------------------------------------- /Content/Widget/WBP_AdventureGiverWidget.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OlssonDev/Adventure/e3ca6d6d85f63f848a93d21c6d602f37ce65872c/Content/Widget/WBP_AdventureGiverWidget.uasset -------------------------------------------------------------------------------- /Content/Widget/WBP_AdventureList.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OlssonDev/Adventure/e3ca6d6d85f63f848a93d21c6d602f37ce65872c/Content/Widget/WBP_AdventureList.uasset -------------------------------------------------------------------------------- /Content/Widget/WBP_ObjectiveEntry.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OlssonDev/Adventure/e3ca6d6d85f63f848a93d21c6d602f37ce65872c/Content/Widget/WBP_ObjectiveEntry.uasset -------------------------------------------------------------------------------- /Content/Widget/WBP_ObjectiveList.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OlssonDev/Adventure/e3ca6d6d85f63f848a93d21c6d602f37ce65872c/Content/Widget/WBP_ObjectiveList.uasset -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Oscar Olsson 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Adventure 2 | Adventure was a passion project of mine to make an advanced quest editor in Unreal Engine, using my custom Blueprint graph. 3 | 4 | It can create branching quests very easily with many different conditions. It also supports multiplayer out-of-the-box. 5 | 6 | ![AdventureTaskObjectiveGIF](https://github.com/OlssonDev/Adventure/assets/101010793/eb636552-539f-4668-b8f2-0842a8d1620c) 7 | ![Adventure_11](https://github.com/OlssonDev/Adventure/assets/101010793/ebead749-60a9-4998-87e7-d9c89f1af360) 8 | 9 | # State of the plugin 10 | 11 | It's not currently maintained, but it works, just wanted to put it out there as a learning resource for anyone wanting to learn more about making your own custom graphs/node systems in Unreal Engine 5. 12 | -------------------------------------------------------------------------------- /Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OlssonDev/Adventure/e3ca6d6d85f63f848a93d21c6d602f37ce65872c/Resources/Icon128.png -------------------------------------------------------------------------------- /Source/Adventure/Adventure.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class Adventure : ModuleRules 6 | { 7 | public Adventure(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 10 | 11 | PublicDependencyModuleNames.AddRange( 12 | new string[] 13 | { 14 | "Core", 15 | "DeveloperSettings", 16 | "Engine", 17 | "GameplayTags", 18 | "NetCore", 19 | } 20 | ); 21 | 22 | 23 | PrivateDependencyModuleNames.AddRange( 24 | new string[] 25 | { 26 | "CoreUObject", 27 | "UMG", 28 | "Slate", 29 | "SlateCore", 30 | "MessageLog", 31 | } 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Source/Adventure/AdventureGameplayTags.cpp: -------------------------------------------------------------------------------- 1 | #include "AdventureGameplayTags.h" 2 | #include "GameplayTagsManager.h" 3 | 4 | FAdventureGameplayTags FAdventureGameplayTags::AdventureGameplayTags; 5 | 6 | FGameplayTag FAdventureGameplayTags::FindTagByString(FString TagString, bool bMatchPartialString) 7 | { 8 | const UGameplayTagsManager& Manager = UGameplayTagsManager::Get(); 9 | FGameplayTag Tag = Manager.RequestGameplayTag(FName(*TagString), false); 10 | 11 | if (!Tag.IsValid() && bMatchPartialString) 12 | { 13 | FGameplayTagContainer AllTags; 14 | Manager.RequestAllGameplayTags(AllTags, true); 15 | 16 | for (const FGameplayTag TestTag : AllTags) 17 | { 18 | if (TestTag.ToString().Contains(TagString)) 19 | { 20 | UE_LOG(LogTemp, Display, TEXT("Could not find exact match for tag [%s] but found partial match on tag [%s]."), *TagString, *TestTag.ToString()); 21 | Tag = TestTag; 22 | break; 23 | } 24 | } 25 | } 26 | 27 | return Tag; 28 | } 29 | 30 | void FAdventureGameplayTags::AddTags() 31 | { 32 | AddTag(Adventure_Objective_CanBePreCompleted, "Adventure.Objective.CanBePreCompleted", "If the Adventure Objective can be pre-completed."); 33 | AddTag(Adventure_Objective_IsOptional, "Adventure.Objective.IsOptional", "If the Adventure Objective is optional."); 34 | AddTag(Adventure_Objective_HasFailed, "Adventure.Objective.HasFailed", "If the Adventure Objective has failed."); 35 | AddTag(Adventure_Objective_IsTimed, "Adventure.Objective.IsTimed", "If the adventure objective is timed"); 36 | 37 | AddTag(Adventure_NoAutoComplete, "Adventure.NoAutoComplete", "If the Adventure should skip the auto complete part when we remove the Adventures and add it to completed adventures list"); 38 | } 39 | 40 | void FAdventureGameplayTags::AddTag(FGameplayTag& OutTag, const ANSICHAR* TagName, const ANSICHAR* TagComment) 41 | { 42 | OutTag = UGameplayTagsManager::Get().AddNativeGameplayTag(FName(TagName), FString(TEXT("(Native) ")) + FString(TagComment)); 43 | } -------------------------------------------------------------------------------- /Source/Adventure/AdventureGameplayTags.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "GameplayTagContainer.h" 3 | 4 | struct ADVENTURE_API FAdventureGameplayTags : public FGameplayTagNativeAdder 5 | { 6 | static FAdventureGameplayTags& Get() { return AdventureGameplayTags; } 7 | static FGameplayTag FindTagByString(FString TagString, bool bMatchPartialString = false); 8 | 9 | public: 10 | 11 | virtual void AddTags() override; 12 | 13 | protected: 14 | 15 | void AddTag(FGameplayTag& OutTag, const ANSICHAR* TagName, const ANSICHAR* TagComment); 16 | 17 | public: 18 | 19 | FGameplayTag Adventure_Objective_CanBePreCompleted; 20 | FGameplayTag Adventure_Objective_IsOptional; 21 | FGameplayTag Adventure_Objective_HasFailed; 22 | FGameplayTag Adventure_Objective_IsTimed; 23 | FGameplayTag Adventure_NoAutoComplete; 24 | 25 | private: 26 | 27 | static FAdventureGameplayTags AdventureGameplayTags; 28 | }; 29 | -------------------------------------------------------------------------------- /Source/Adventure/AdventureLogChannels.cpp: -------------------------------------------------------------------------------- 1 | #include "AdventureLogChannels.h" 2 | #include "AdventureMacros.h" 3 | #include "Misc/UObjectToken.h" 4 | 5 | DEFINE_LOG_CATEGORY(LogAdventure); 6 | 7 | FString GetClientServerContextString(UObject* ContextObject) 8 | { 9 | ENetRole Role = ROLE_None; 10 | 11 | if (AActor* Actor = Cast(ContextObject)) 12 | { 13 | Role = Actor->GetLocalRole(); 14 | } 15 | else if (UActorComponent* Component = Cast(ContextObject)) 16 | { 17 | Role = Component->GetOwnerRole(); 18 | } 19 | 20 | if (Role != ROLE_None) 21 | { 22 | return (Role == ROLE_Authority) ? TEXT("Server") : TEXT("Client"); 23 | } 24 | else 25 | { 26 | #if WITH_EDITOR 27 | if (GIsEditor) 28 | { 29 | extern ENGINE_API FString GPlayInEditorContextString; 30 | return GPlayInEditorContextString; 31 | } 32 | #endif 33 | } 34 | 35 | return TEXT("[]"); 36 | } 37 | 38 | FAdventureLogMessages::FLogMessageDelegate FAdventureLogMessages::LogMessageDelegate; 39 | 40 | void FAdventureLogMessages::LogMessage(const TSharedRef& Message) 41 | { 42 | if (LogMessageDelegate.IsBound()) 43 | { 44 | LogMessageDelegate.Broadcast(Message); 45 | } 46 | else 47 | { 48 | ADVENTURE_MESSAGELOG_ADD(Message); 49 | } 50 | } 51 | 52 | void FAdventureLogMessages::LogMessage(const FText& Message, EMessageSeverity::Type Severity, const UObject* Object) 53 | { 54 | TSharedRef NewMessage = FTokenizedMessage::Create(Severity); 55 | if (IsValid(Object)) 56 | { 57 | NewMessage->AddToken(FUObjectToken::Create(Object)); 58 | NewMessage->AddToken(FTextToken::Create(FText::FromString(": "))); 59 | } 60 | NewMessage->AddToken(FTextToken::Create(Message)); 61 | LogMessage(NewMessage); 62 | } 63 | -------------------------------------------------------------------------------- /Source/Adventure/AdventureLogChannels.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CoreMinimal.h" 4 | #include "Logging/TokenizedMessage.h" 5 | 6 | ADVENTURE_API DECLARE_LOG_CATEGORY_EXTERN(LogAdventure, Log, All); 7 | 8 | #define LogAdventure(Verbosity, Format, ...) UE_LOG(LogAdventure, Verbosity, Format, ##__VA_ARGS__) 9 | 10 | ADVENTURE_API FString GetClientServerContextString(UObject* ContextObject = nullptr); 11 | 12 | struct ADVENTURE_API FAdventureLogMessages 13 | { 14 | DECLARE_MULTICAST_DELEGATE_OneParam(FLogMessageDelegate, const TSharedRef&); 15 | static FLogMessageDelegate LogMessageDelegate; 16 | 17 | static void LogMessage(const TSharedRef& Message); 18 | static void LogMessage(const FText& Message, EMessageSeverity::Type Severity, const UObject* Object = nullptr); 19 | 20 | public: 21 | 22 | static void Error(const FString& Message, const UObject* Object = nullptr) 23 | { 24 | Error(FText::FromString(Message), Object); 25 | } 26 | static void Error(const FText& Message, const UObject* Object = nullptr) 27 | { 28 | LogMessage(Message, EMessageSeverity::Error, Object); 29 | } 30 | 31 | static void Warning(const FString& Message, const UObject* Object = nullptr) 32 | { 33 | Warning(FText::FromString(Message), Object); 34 | } 35 | static void Warning(const FText& Message, const UObject* Object = nullptr) 36 | { 37 | LogMessage(Message, EMessageSeverity::Warning, Object); 38 | } 39 | 40 | static void Info(const FString& Message, const UObject* Object = nullptr) 41 | { 42 | Info(FText::FromString(Message), Object); 43 | } 44 | static void Info(const FText& Message, const UObject* Object = nullptr) 45 | { 46 | LogMessage(Message, EMessageSeverity::Info, Object); 47 | } 48 | }; 49 | -------------------------------------------------------------------------------- /Source/Adventure/Private/AdventureAsset.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureAsset.h" 5 | #include "AdventureComponent.h" 6 | #include "AdventureGlobals.h" 7 | #include "Adventure/AdventureGameplayTags.h" 8 | #include "Engine/AssetManager.h" 9 | #include "Net/UnrealNetwork.h" 10 | 11 | #define LOCTEXT_NAMESPACE "Adventure" 12 | 13 | UAdventureAsset::UAdventureAsset() 14 | { 15 | AdventureTitle = LOCTEXT("AdventureTitle_DefaultValue", "My New Adventure"); 16 | AdventureDescription = LOCTEXT("AdventureDescription_DefaultValue", "Description of your quest"); 17 | } 18 | 19 | void UAdventureAsset::OnCompleteAdventure() 20 | { 21 | SetAdventureState(EAdventureState::Completed); 22 | K2_OnAdventureCompleted(); 23 | 24 | LoadChainedAdventures(FOnChainedAdventuresLoaded::CreateWeakLambda(this, [this](TArray> LoadedAdventures) 25 | { 26 | UAdventureComponent* AdventureComponent = GetOwningAdventureComponent(); 27 | check(AdventureComponent) 28 | 29 | for (TSubclassOf AdventureToStart : LoadedAdventures) 30 | { 31 | AdventureComponent->StartAdventure(AdventureToStart); 32 | } 33 | })); 34 | } 35 | 36 | void UAdventureAsset::OnFailAdventure() 37 | { 38 | SetAdventureState(EAdventureState::Failed); 39 | } 40 | 41 | void UAdventureAsset::OnAdvandonAdventure() 42 | { 43 | SetAdventureState(EAdventureState::Abandoned); 44 | } 45 | 46 | void UAdventureAsset::AdventureBeginPlay() 47 | { 48 | K2_OnAdventureBeginPlay(); 49 | } 50 | 51 | void UAdventureAsset::InitializeAdventure() 52 | { 53 | if (!bHasInit) 54 | { 55 | bHasInit = true; 56 | K2_OnAdventureInitialized(); 57 | } 58 | } 59 | 60 | void UAdventureAsset::K2_FailAdventure(bool bRestart) 61 | { 62 | FailAdventure(bRestart); 63 | } 64 | 65 | void UAdventureAsset::FailAdventure(bool bRestart) 66 | { 67 | GetOwningAdventureComponent()->FailAdventure(this, bRestart); 68 | K2_OnAdventureFailed(); 69 | } 70 | 71 | void UAdventureAsset::K2_CompleteAdventure() 72 | { 73 | CompleteAdventure(); 74 | } 75 | 76 | void UAdventureAsset::CompleteAdventure() 77 | { 78 | GetOwningAdventureComponent()->CompleteAdventure(this); 79 | } 80 | 81 | void UAdventureAsset::K2_AbandonAdventure() 82 | { 83 | AbandonAdventure(); 84 | } 85 | 86 | void UAdventureAsset::AbandonAdventure() 87 | { 88 | GetOwningAdventureComponent()->AbandonAdventure(this); 89 | } 90 | 91 | UAdventureComponent* UAdventureAsset::GetOwningAdventureComponent() const 92 | { 93 | if (AActor* OwningActor = GetOwningActor()) 94 | { 95 | return UAdventureGlobals::GetAdventureComponentFromActor(OwningActor, true); 96 | } 97 | return nullptr; 98 | } 99 | 100 | bool UAdventureAsset::HasCompletedCurrentObjectives() 101 | { 102 | for (FAdventureObjectiveEntry CurrentObjective : ObjectiveList.GetEntries()) 103 | { 104 | if (!CurrentObjective.IsCompleted()) 105 | { 106 | return false; 107 | } 108 | } 109 | return true; 110 | } 111 | 112 | void UAdventureAsset::UpdateObjective(FName Argument) 113 | { 114 | UpdateObjective(Argument, 1); 115 | } 116 | 117 | void UAdventureAsset::UpdateObjective(FName Argument, int32 Quantity) 118 | { 119 | ObjectiveList.UpdateEntry(Argument, Quantity); 120 | } 121 | 122 | void UAdventureAsset::FailObjective(FName Argument) 123 | { 124 | FGameplayTag HasFailedTag = FAdventureGameplayTags::Get().Adventure_Objective_HasFailed; 125 | ObjectiveList.AddConditionTag(Argument, HasFailedTag); 126 | } 127 | 128 | void UAdventureAsset::SetAdventureState(EAdventureState NewAdventureState) 129 | { 130 | if (NewAdventureState != AdventureState) 131 | { 132 | AdventureState = NewAdventureState; 133 | OnRep_AdventureState(); 134 | } 135 | } 136 | 137 | void UAdventureAsset::LoadChainedAdventures(FOnChainedAdventuresLoaded OnChainedAdventuresLoaded) 138 | { 139 | if (ChainedAdventures.Num()) 140 | { 141 | TArray PathsToLoad; 142 | for (TSoftClassPtr SoftClassPtr : ChainedAdventures) 143 | { 144 | PathsToLoad.AddUnique(SoftClassPtr.ToSoftObjectPath()); 145 | } 146 | 147 | UAssetManager::GetStreamableManager().RequestAsyncLoad(PathsToLoad, FStreamableDelegate::CreateWeakLambda(this, [this, OnChainedAdventuresLoaded] 148 | { 149 | TArray> LoadedAdventures; 150 | for (TSoftClassPtr SoftClassPtr : ChainedAdventures) 151 | { 152 | LoadedAdventures.Add(SoftClassPtr.Get()); 153 | } 154 | 155 | OnChainedAdventuresLoaded.ExecuteIfBound(LoadedAdventures); 156 | })); 157 | } 158 | } 159 | 160 | void UAdventureAsset::OnRep_AdventureState() 161 | { 162 | OnAdventureStateModified.Broadcast(AdventureState); 163 | K2_OnNewAdventureState(AdventureState); 164 | } 165 | 166 | void UAdventureAsset::AddConditionTagWithName(FName Argument, FGameplayTag NewConditionTag) 167 | { 168 | ObjectiveList.AddConditionTag(Argument, NewConditionTag); 169 | } 170 | 171 | void UAdventureAsset::AddConditionTagWithTag(FGameplayTag Argument, FGameplayTag NewConditionTag) 172 | { 173 | AddConditionTagWithName(Argument.GetTagName(), NewConditionTag); 174 | } 175 | 176 | bool UAdventureAsset::IsLoadingSaveFile() const 177 | { 178 | return GetOwningAdventureComponent()->IsLoadingSaveFile; 179 | } 180 | 181 | AActor* UAdventureAsset::GetOwningActor() const 182 | { 183 | return GetTypedOuter(); 184 | } 185 | 186 | APawn* UAdventureAsset::GetOwningPawn() const 187 | { 188 | return GetTypedOuter(); 189 | } 190 | 191 | void UAdventureAsset::GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const 192 | { 193 | Super::GetLifetimeReplicatedProps(OutLifetimeProps); 194 | DOREPLIFETIME(ThisClass, AdventureState); 195 | DOREPLIFETIME(ThisClass, ObjectiveList); 196 | if (const UBlueprintGeneratedClass* BPClass = Cast(GetClass())) 197 | { 198 | BPClass->GetLifetimeBlueprintReplicationList(OutLifetimeProps); 199 | } 200 | } 201 | 202 | int32 UAdventureAsset::GetFunctionCallspace(UFunction* Function, FFrame* Stack) 203 | { 204 | if (HasAnyFlags(RF_ClassDefaultObject) || !IsSupportedForNetworking()) 205 | { 206 | return GEngine->GetGlobalFunctionCallspace(Function, this, Stack); 207 | } 208 | check(GetOuter() != nullptr); 209 | return GetOuter()->GetFunctionCallspace(Function, Stack); 210 | } 211 | 212 | bool UAdventureAsset::CallRemoteFunction(UFunction* Function, void* Parms, FOutParmRec* OutParms, FFrame* Stack) 213 | { 214 | check(!HasAnyFlags(RF_ClassDefaultObject)); 215 | AActor* Owner = GetOwningActor(); 216 | UNetDriver* NetDriver = Owner->GetNetDriver(); 217 | if (NetDriver) 218 | { 219 | NetDriver->ProcessRemoteFunction(Owner, Function, Parms, OutParms, Stack, this); 220 | return true; 221 | } 222 | return false; 223 | } 224 | 225 | FPrimaryAssetId UAdventureAsset::GetPrimaryAssetId() const 226 | { 227 | return FPrimaryAssetId("AdventureAsset", GetFName()); 228 | } 229 | 230 | void UAdventureAsset::AddNewObjectiveList(TArray NewObjectives, int64& NewObjectiveUniqueID) 231 | { 232 | NewObjectiveUniqueID = GetNextObjectiveListUniqueID(); 233 | for (FAdventureObjectiveEntry NewObjective : NewObjectives) 234 | { 235 | AddObjectiveToActiveList(NewObjectiveUniqueID, NewObjective); 236 | } 237 | } 238 | 239 | void UAdventureAsset::AddObjectiveToActiveList(int64 ObjectiveListID, FAdventureObjectiveEntry NewObjective) 240 | { 241 | NewObjective.ObjectiveUniqueID = ObjectiveListID; 242 | ObjectiveList.AddEntry(NewObjective); 243 | 244 | if (const auto* FoundEntry = GetOwningAdventureComponent()->ObjectivesList.Find(NewObjective.Argument)) 245 | { 246 | ObjectiveList.UpdateEntry(NewObjective.Argument, FMath::Clamp(NewObjective.CurrentProgress + *FoundEntry, 0, NewObjective.Quantity)); 247 | } 248 | } 249 | 250 | TArray UAdventureAsset::MakeObjectiveArray(TArray ObjectiveArray, FAdventureObjectiveEntry ObjectiveEntry) 251 | { 252 | if (ObjectiveArray.Num()) 253 | { 254 | ObjectiveArray.Add(ObjectiveEntry); 255 | return ObjectiveArray; 256 | } 257 | 258 | TArray NewList; 259 | NewList.Add(ObjectiveEntry); 260 | return NewList; 261 | } 262 | 263 | UWorld* UAdventureAsset::GetWorld() const 264 | { 265 | if (GetOuter() == nullptr) 266 | { 267 | return nullptr; 268 | } 269 | 270 | if (Cast(GetOuter()) != nullptr) 271 | { 272 | return Cast(GetOuter()->GetOuter()); 273 | } 274 | 275 | return GetOwningActor()->GetWorld(); 276 | } 277 | 278 | #undef LOCTEXT_NAMESPACE 279 | 280 | -------------------------------------------------------------------------------- /Source/Adventure/Private/AdventureBlueprintGeneratedClass.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureBlueprintGeneratedClass.h" 5 | -------------------------------------------------------------------------------- /Source/Adventure/Private/AdventureGlobals.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureGlobals.h" 5 | #include "AdventureComponent.h" 6 | #include "AdventureInterface.h" 7 | #include "AdventureMacros.h" 8 | 9 | #define LOCTEXT_NAMESPACE "AdventureGlobals" 10 | 11 | UAdventureComponent* UAdventureGlobals::GetAdventureComponentFromActor(AActor* Actor, bool bSearchForComponent) 12 | { 13 | check(Actor) 14 | 15 | if (!IsValid(Actor)) 16 | { 17 | ADVENTURE_ERROR("Failed to get Adventure Component from Actor. Reason: Actor reference was invalid.") 18 | return nullptr; 19 | } 20 | 21 | if (IAdventureInterface* AdventureInterface = Cast(Actor)) 22 | { 23 | return AdventureInterface->GetAdventureComponent(); 24 | } 25 | 26 | if (bSearchForComponent) 27 | { 28 | if (UAdventureComponent* FoundComponent = Actor->FindComponentByClass()) 29 | { 30 | return FoundComponent; 31 | } 32 | } 33 | 34 | ADVENTURE_ERROR(FString::Printf(TEXT("Failed to get Adventure Component from Actor. Reason: Couldn't find a Adventure Component in %s"), *Actor->GetClass()->GetName())); 35 | return nullptr; 36 | } 37 | 38 | #undef LOCTEXT_NAMESPACE 39 | -------------------------------------------------------------------------------- /Source/Adventure/Private/AdventureInterface.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureInterface.h" 5 | 6 | UAdventureComponent* IAdventureInterface::GetAdventureComponent() const 7 | { 8 | return nullptr; 9 | } 10 | -------------------------------------------------------------------------------- /Source/Adventure/Private/AdventureModule.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "AdventureModule.h" 4 | #include "MessageLogModule.h" 5 | #include "Adventure/AdventureGameplayTags.h" 6 | #define LOCTEXT_NAMESPACE "FAdventureModule" 7 | 8 | void FAdventureModule::StartupModule() 9 | { 10 | FMessageLogModule& MessageLogModule = FModuleManager::LoadModuleChecked("MessageLog"); 11 | if (!MessageLogModule.IsRegisteredLogListing("LogAdventure")) 12 | { 13 | MessageLogModule.RegisterLogListing("LogAdventure", LOCTEXT("AdventureLabel", "Adventure")); 14 | } 15 | } 16 | 17 | void FAdventureModule::ShutdownModule() 18 | { 19 | 20 | } 21 | 22 | #undef LOCTEXT_NAMESPACE 23 | 24 | IMPLEMENT_MODULE(FAdventureModule, Adventure) 25 | -------------------------------------------------------------------------------- /Source/Adventure/Private/AdventurePluginSettings.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventurePluginSettings.h" 5 | #include "AdventureAsset.h" 6 | #include "AdventureSaveObject.h" 7 | 8 | UAdventurePluginSettings::UAdventurePluginSettings() 9 | { 10 | DefaultAdventureClass = UAdventureAsset::StaticClass(); 11 | DefaultSaveObjectClass = UAdventureSaveObject::StaticClass(); 12 | } 13 | -------------------------------------------------------------------------------- /Source/Adventure/Private/AdventureSaveObject.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureSaveObject.h" 5 | 6 | #include "AdventureMacros.h" 7 | #include "Kismet/GameplayStatics.h" 8 | 9 | void UAdventureSaveObject::SaveToDisk() 10 | { 11 | if (!SlotName.IsEmpty()) 12 | { 13 | UGameplayStatics::SaveGameToSlot(this, SlotName, 0); 14 | } 15 | else 16 | { 17 | ADVENTURE_ERROR("Can't Save Adventure Save Object. Reason: Slot name is empty."); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Source/Adventure/Private/AdventureSharedComponent.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureSharedComponent.h" 5 | 6 | #include "Net/UnrealNetwork.h" 7 | 8 | UAdventureSharedComponent::UAdventureSharedComponent() 9 | { 10 | PrimaryComponentTick.bCanEverTick = true; 11 | } 12 | 13 | void UAdventureSharedComponent::GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const 14 | { 15 | UActorComponent::GetLifetimeReplicatedProps(OutLifetimeProps); 16 | DOREPLIFETIME(ThisClass, ActiveAdventures); 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /Source/Adventure/Private/FAdventureGraphNodeMinimal.cpp: -------------------------------------------------------------------------------- 1 | #include "FAdventureGraphNodeMinimal.h" 2 | #include "Adventure/AdventureGameplayTags.h" 3 | #include "Adventure/AdventureLogChannels.h" 4 | 5 | bool FAdventureObjectiveEntry::IsCompleted() const 6 | { 7 | return CurrentProgress >= Quantity; 8 | } 9 | 10 | void FAdventureObjectiveEntry::ResetObjective() 11 | { 12 | CurrentProgress = 0; 13 | } 14 | 15 | FName FAdventureObjectiveEntry::GetArgumentAsName() 16 | { 17 | return Argument; 18 | } 19 | 20 | FGameplayTag FAdventureObjectiveEntry::GetArgumentAsGameplayTag() 21 | { 22 | return FGameplayTag::RequestGameplayTag(Argument); 23 | } 24 | 25 | bool FAdventureObjectiveEntry::IsOptional() 26 | { 27 | return OptionalTags.HasTag(FAdventureGameplayTags::Get().Adventure_Objective_IsOptional); 28 | } 29 | 30 | bool FAdventureObjectiveEntry::CanBePreCompleted() 31 | { 32 | return OptionalTags.HasTag(FAdventureGameplayTags::Get().Adventure_Objective_CanBePreCompleted); 33 | } 34 | 35 | void FAdventureObjectiveList::PreReplicatedRemove(const TArrayView RemovedIndices, int32 FinalSize) 36 | { 37 | for (int32 Index : RemovedIndices) 38 | { 39 | BroadcastChangeMessage(Index); 40 | } 41 | } 42 | 43 | void FAdventureObjectiveList::PostReplicatedAdd(const TArrayView AddedIndices, int32 FinalSize) 44 | { 45 | for (int32 Index : AddedIndices) 46 | { 47 | BroadcastChangeMessage(Index); 48 | } 49 | } 50 | 51 | void FAdventureObjectiveList::PostReplicatedChange(const TArrayView ChangedIndices, int32 FinalSize) 52 | { 53 | for (int32 Index : ChangedIndices) 54 | { 55 | BroadcastChangeMessage(Index); 56 | } 57 | } 58 | 59 | void FAdventureObjectiveList::AddEntry(FAdventureObjectiveEntry InNewEntry) 60 | { 61 | FAdventureObjectiveEntry& NewEntry = Entries.AddDefaulted_GetRef(); 62 | NewEntry = InNewEntry; 63 | MarkItemDirty(NewEntry); 64 | BroadcastChangeMessage(Entries.Num() - 1); 65 | UE_LOG(LogAdventure, Log, TEXT("Successfully added an objective with Argument: %s"), *InNewEntry.Argument.ToString()) 66 | } 67 | 68 | void FAdventureObjectiveList::RemoveEntryWithArgument(FName Argument) 69 | { 70 | int32 Index = 0; 71 | for (auto EntryIt = Entries.CreateIterator(); EntryIt; ++EntryIt) 72 | { 73 | FAdventureObjectiveEntry& Entry = *EntryIt; 74 | if (Entry.Argument == Argument) 75 | { 76 | EntryIt.RemoveCurrent(); 77 | MarkArrayDirty(); 78 | BroadcastChangeMessage(Index); 79 | 80 | return; 81 | } 82 | 83 | Index++; 84 | } 85 | } 86 | 87 | void FAdventureObjectiveList::UpdateEntry(FName Argument, int32 Quantity) 88 | { 89 | //Quantity should never be 0. 90 | ensureAlways(Quantity > 0); 91 | for (int32 i = 0; i < Entries.Num(); i++ ) 92 | { 93 | FAdventureObjectiveEntry& Entry = Entries[i]; 94 | if (Entry.Argument == Argument) 95 | { 96 | int32 NewQuantity = Entry.CurrentProgress + Quantity; 97 | Entry.CurrentProgress = FMath::Clamp(NewQuantity, 0, NewQuantity); 98 | 99 | ObjectiveStepCompleted.Broadcast(Entry); 100 | MarkItemDirty(Entry); 101 | BroadcastChangeMessage(i); 102 | 103 | if (ObjectiveListCompleted(Entry.ObjectiveUniqueID)) 104 | { 105 | ObjectiveCompleted.Broadcast(Entry.ObjectiveUniqueID); 106 | return; 107 | } 108 | } 109 | } 110 | } 111 | 112 | void FAdventureObjectiveList::AddConditionTag(FName Argument, FGameplayTag NewConditionTag) 113 | { 114 | int32 Index = 0; 115 | for (FAdventureObjectiveEntry& Entry : Entries) 116 | { 117 | if (Entry.Argument == Argument) 118 | { 119 | int32 ConditionTagsAmount = Entry.ConditionTags.Num(); 120 | Entry.ConditionTags.AddTag(NewConditionTag); 121 | 122 | //Just mark it as dirty if we actually added a tag 123 | if (ConditionTagsAmount != Entry.ConditionTags.Num()) 124 | { 125 | MarkItemDirty(Entry); 126 | ObjectiveConditionTagsUpdated.Broadcast(Entry, Index); 127 | } 128 | 129 | return; 130 | } 131 | 132 | Index++; 133 | } 134 | } 135 | 136 | bool FAdventureObjectiveList::ObjectiveListCompleted(int64 ObjectiveUniqueID) 137 | { 138 | for (FAdventureObjectiveEntry Entry : Entries) 139 | { 140 | if (ObjectiveUniqueID == Entry.ObjectiveUniqueID && Entry.IsCompleted() == false) 141 | { 142 | if (Entry.IsOptional() == false) 143 | { 144 | return false; 145 | } 146 | } 147 | } 148 | 149 | return true; 150 | } 151 | 152 | TArray FAdventureObjectiveList::GetEntries() 153 | { 154 | return Entries; 155 | } 156 | 157 | void FAdventureObjectiveList::BroadcastChangeMessage(int32 Index) 158 | { 159 | #if !UE_SERVER 160 | ObjectiveEntryUpdated.Broadcast(Entries[Index], Index); 161 | #endif 162 | } 163 | 164 | void FAdventureObjectiveList::Append(TArray ObjectiveList) 165 | { 166 | for (FAdventureObjectiveEntry ObjectiveToAdd : ObjectiveList) 167 | { 168 | AddEntry(ObjectiveToAdd); 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /Source/Adventure/Private/Library/AdventureBlueprintLibrary.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "Library/AdventureBlueprintLibrary.h" 5 | #include "AdventureAsset.h" 6 | #include "AdventureComponent.h" 7 | #include "AdventureGlobals.h" 8 | #include "FAdventureGraphNodeMinimal.h" 9 | #include "GameplayTagsManager.h" 10 | #include "GameFramework/GameStateBase.h" 11 | #include "GameFramework/PlayerState.h" 12 | 13 | #define LOCTEXT_NAMESPACE "AdventureBlueprintLibrary" 14 | 15 | UAdventureComponent* UAdventureBlueprintLibrary::GetAdventureComponent(AActor* ActorToGetFrom) 16 | { 17 | return UAdventureGlobals::GetAdventureComponentFromActor(ActorToGetFrom, true); 18 | } 19 | 20 | UAdventureComponent* UAdventureBlueprintLibrary::GetAdventureComponentFromGameState(UObject* WorldContextObject) 21 | { 22 | return GetAdventureComponent(WorldContextObject->GetWorld()->GetGameState());; 23 | } 24 | 25 | UAdventureComponent* UAdventureBlueprintLibrary::GetAdventureComponentFromPlayerState(APawn* Character) 26 | { 27 | return GetAdventureComponent(Character->GetPlayerState()); 28 | } 29 | 30 | UAdventureAsset* UAdventureBlueprintLibrary::FinishSpawningAdventureOnActor(UAdventureAsset* AdventureToStart) 31 | { 32 | if (IsValid(AdventureToStart)) 33 | { 34 | AdventureToStart->GetOwningAdventureComponent()->FinishConstructAdventure(AdventureToStart); 35 | } 36 | 37 | return nullptr; 38 | } 39 | 40 | UAdventureAsset* UAdventureBlueprintLibrary::BeginSpawningAdventureOnActor(AActor* ActorToUse, TSubclassOf AdventureToStart) 41 | { 42 | if (UAdventureComponent* AdventureComponent = GetAdventureComponent(ActorToUse)) 43 | { 44 | return AdventureComponent->BeginConstructAdventure(AdventureToStart); 45 | } 46 | 47 | return nullptr; 48 | } 49 | 50 | void UAdventureBlueprintLibrary::UpdateObjectiveWithName(AActor* AdventureComponentOwner, const FName Argument, int32 Quantity) 51 | { 52 | if (UAdventureComponent* AdventureComponent = GetAdventureComponent(AdventureComponentOwner)) 53 | { 54 | AdventureComponent->UpdateObjective(Argument, Quantity); 55 | } 56 | } 57 | 58 | void UAdventureBlueprintLibrary::UpdateObjectiveWithTag(AActor* AdventureComponentOwner, const FGameplayTag Argument, int32 Quantity) 59 | { 60 | UpdateObjectiveWithName(AdventureComponentOwner, Argument.GetTagName(), Quantity); 61 | } 62 | 63 | void UAdventureBlueprintLibrary::FailObjective(AActor* AdventureComponentOwner, const FName Argument) 64 | { 65 | if (IsValid(AdventureComponentOwner) && !Argument.IsNone()) 66 | { 67 | if (UAdventureComponent* AdventureComponent = GetAdventureComponent(AdventureComponentOwner)) 68 | { 69 | AdventureComponent->FailObjective(Argument); 70 | return; 71 | } 72 | } 73 | 74 | check(AdventureComponentOwner) 75 | check(!Argument.IsNone()) 76 | } 77 | 78 | void UAdventureBlueprintLibrary::AbandonAdventure(AActor* AdventureComponentOwner, UAdventureAsset* AdventureToAbandon) 79 | { 80 | if (IsValid(AdventureComponentOwner) && IsValid(AdventureToAbandon)) 81 | { 82 | if (UAdventureComponent* AdventureComponent = GetAdventureComponent(AdventureComponentOwner)) 83 | { 84 | AdventureComponent->AbandonAdventure(AdventureToAbandon); 85 | } 86 | } 87 | } 88 | 89 | void UAdventureBlueprintLibrary::RestartAdventure(AActor* AdventureComponentOwner, UAdventureAsset* AdventureToRestart) 90 | { 91 | if (IsValid(AdventureComponentOwner) && IsValid(AdventureToRestart)) 92 | { 93 | if (UAdventureComponent* AdventureComponent = GetAdventureComponent(AdventureComponentOwner)) 94 | { 95 | AdventureComponent->RestartAdventure(AdventureToRestart); 96 | } 97 | } 98 | 99 | check(AdventureComponentOwner) 100 | check(AdventureToRestart) 101 | } 102 | 103 | void UAdventureBlueprintLibrary::AddConditionTagWithName(AActor* AdventureComponentOwner, FName Argument, FGameplayTag NewConditionTag) 104 | { 105 | if (IsValid(AdventureComponentOwner)) 106 | { 107 | if (UAdventureComponent* AdventureComponent = GetAdventureComponent(AdventureComponentOwner)) 108 | { 109 | AdventureComponent->AddConditionTag(Argument, NewConditionTag); 110 | } 111 | } 112 | } 113 | 114 | void UAdventureBlueprintLibrary::AddConditionTagWithTag(AActor* AdventureComponentOwner, FGameplayTag Argument, FGameplayTag NewConditionTag) 115 | { 116 | AddConditionTagWithName(AdventureComponentOwner, Argument.GetTagName(), NewConditionTag); 117 | } 118 | 119 | FAdventureObjectiveEntry UAdventureBlueprintLibrary::MakeObjectiveWithName(FName Argument, FText Description, int32 Quantity, FGameplayTagContainer OptionalTags, int32 Timer) 120 | { 121 | FAdventureObjectiveEntry NewObjective; 122 | NewObjective.Argument = Argument; 123 | NewObjective.Description = Description; 124 | NewObjective.Quantity = Quantity; 125 | NewObjective.OptionalTags = OptionalTags; 126 | NewObjective.Timer = Timer; 127 | return NewObjective; 128 | } 129 | 130 | FAdventureObjectiveEntry UAdventureBlueprintLibrary::MakeObjectiveWithTag(FGameplayTag Argument, FText Description, int32 Quantity, FGameplayTagContainer OptionalTags, bool IsTimed, int32 Timer) 131 | { 132 | return MakeObjectiveWithName(Argument.GetTagName(), Description, Quantity, OptionalTags, Timer); 133 | } 134 | 135 | void UAdventureBlueprintLibrary::BreakObjectiveWithName(const FAdventureObjectiveEntry& ObjectiveInfo, FName& Argument,FText& Description, int32& Quantity, int32& CurrentProgress, FGameplayTagContainer& OptionalTags, int32& Timer) 136 | { 137 | Argument = ObjectiveInfo.Argument; 138 | Description = ObjectiveInfo.Description; 139 | Quantity = ObjectiveInfo.Quantity; 140 | CurrentProgress = ObjectiveInfo.CurrentProgress; 141 | OptionalTags = ObjectiveInfo.OptionalTags; 142 | Timer = ObjectiveInfo.Timer; 143 | } 144 | 145 | void UAdventureBlueprintLibrary::BreakObjectiveWithTag(const FAdventureObjectiveEntry& ObjectiveInfo, FGameplayTag& Argument,FText& Description, int32& Quantity, int32& CurrentProgress, FGameplayTagContainer& OptionalTags, int32& Timer) 146 | { 147 | FName ArgumentParam; 148 | BreakObjectiveWithName(ObjectiveInfo, ArgumentParam, Description, Quantity, CurrentProgress, OptionalTags, Timer); 149 | Argument = FGameplayTag::RequestGameplayTag(ObjectiveInfo.Argument); 150 | check(Argument.IsValid()) 151 | } 152 | 153 | #undef LOCTEXT_NAMESPACE 154 | -------------------------------------------------------------------------------- /Source/Adventure/Private/Volumes/AdventureObjectiveTriggerVolume.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "Volumes/AdventureObjectiveTriggerVolume.h" 5 | 6 | #include "AdventureComponent.h" 7 | 8 | AAdventureObjectiveTriggerVolume::AAdventureObjectiveTriggerVolume() 9 | { 10 | 11 | } 12 | 13 | void AAdventureObjectiveTriggerVolume::RunAdventureComponentOperation(UAdventureComponent* AdventureComponent) 14 | { 15 | check(AdventureComponent) 16 | AdventureComponent->UpdateObjective(ObjectiveArgument); 17 | } 18 | -------------------------------------------------------------------------------- /Source/Adventure/Private/Volumes/AdventureStartTriggerVolume.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "Volumes/AdventureStartTriggerVolume.h" 5 | 6 | #include "AdventureComponent.h" 7 | 8 | 9 | AAdventureStartTriggerVolume::AAdventureStartTriggerVolume() 10 | { 11 | 12 | } 13 | 14 | void AAdventureStartTriggerVolume::RunAdventureComponentOperation(UAdventureComponent* AdventureComponent) 15 | { 16 | check(AdventureComponent) 17 | AdventureComponent->StartAdventure(AdventureToStart); 18 | } 19 | 20 | -------------------------------------------------------------------------------- /Source/Adventure/Private/Volumes/AdventureTriggerBoxVolume.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "Volumes/AdventureTriggerBoxVolume.h" 5 | #include "Components/BoxComponent.h" 6 | #include "AdventureComponent.h" 7 | #include "AdventureGlobals.h" 8 | #include "GameFramework/PlayerState.h" 9 | #include "Components/BillboardComponent.h" 10 | #include "GameFramework/Character.h" 11 | #include "GameFramework/GameState.h" 12 | 13 | 14 | AAdventureTriggerBoxVolume::AAdventureTriggerBoxVolume() 15 | { 16 | PrimaryActorTick.bCanEverTick = false; 17 | 18 | TriggerBoxVolume = CreateDefaultSubobject("TriggerBoxVolume"); 19 | TriggerBoxVolume->SetBoxExtent(FVector(400.f)); 20 | SetRootComponent(TriggerBoxVolume); 21 | 22 | AdventureIconBillboard = CreateDefaultSubobject("Adventure Icon Billboard"); 23 | AdventureIconBillboard->SetupAttachment(TriggerBoxVolume); 24 | AdventureIconBillboard->SetWorldScale3D(FVector(4.0f)); 25 | 26 | static ConstructorHelpers::FObjectFinder StaticTexture(TEXT("/Adventure/Icons/T_AdventureAssetIcon.T_AdventureAssetIcon")); 27 | AdventureIconBillboard->SetSprite(StaticTexture.Object); 28 | } 29 | 30 | void AAdventureTriggerBoxVolume::BeginPlay() 31 | { 32 | Super::BeginPlay(); 33 | 34 | if (HasAuthority()) 35 | { 36 | TriggerBoxVolume->OnComponentBeginOverlap.AddDynamic(this, &AAdventureTriggerBoxVolume::OnComponentOverlapped); 37 | } 38 | } 39 | 40 | void AAdventureTriggerBoxVolume::OnComponentOverlapped(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) 41 | { 42 | if (HasAuthority()) 43 | { 44 | UAdventureComponent* AdventureComponent = nullptr; 45 | 46 | auto FindComponent = [](AActor* Actor) 47 | { 48 | return UAdventureGlobals::GetAdventureComponentFromActor(Actor, true); 49 | }; 50 | 51 | switch (GetterSettings) 52 | { 53 | case CharacterOrPawn: 54 | { 55 | if (APawn* Pawn = Cast(OtherActor)) 56 | { 57 | AdventureComponent = FindComponent(OtherActor); 58 | } 59 | break; 60 | } 61 | 62 | case PlayerController: 63 | { 64 | if (APawn* Pawn = Cast(OtherActor)) 65 | { 66 | AdventureComponent = FindComponent(Pawn->Controller); 67 | } 68 | break; 69 | } 70 | 71 | case PlayerState: 72 | { 73 | if (APawn* Pawn = Cast(OtherActor)) 74 | { 75 | AdventureComponent = FindComponent(Pawn->GetPlayerState()); 76 | } 77 | break; 78 | } 79 | 80 | case GameState: 81 | { 82 | AdventureComponent = FindComponent(GetWorld()->GetGameState()); 83 | break; 84 | } 85 | 86 | case GameMode: 87 | { 88 | AdventureComponent = FindComponent(GetWorld()->GetAuthGameMode()); 89 | break; 90 | } 91 | 92 | default: 93 | { 94 | break; 95 | }; 96 | } 97 | 98 | if (IsValid(AdventureComponent)) 99 | { 100 | RunAdventureComponentOperation(AdventureComponent); 101 | } 102 | } 103 | } 104 | 105 | -------------------------------------------------------------------------------- /Source/Adventure/Public/AdventureBlueprintGeneratedClass.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | #include "CoreMinimal.h" 5 | #include "AdventureBlueprintGeneratedClass.generated.h" 6 | 7 | UCLASS() 8 | class ADVENTURE_API UAdventureBlueprintGeneratedClass : public UBlueprintGeneratedClass 9 | { 10 | GENERATED_BODY() 11 | }; 12 | -------------------------------------------------------------------------------- /Source/Adventure/Public/AdventureGlobals.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "UObject/Object.h" 7 | #include "AdventureGlobals.generated.h" 8 | 9 | 10 | UCLASS() 11 | class ADVENTURE_API UAdventureGlobals : public UObject 12 | { 13 | GENERATED_BODY() 14 | 15 | public: 16 | 17 | /** Searches the passed in actor for an Adventure Component, will use IAdventureInterface or fall back to a component search */ 18 | static class UAdventureComponent* GetAdventureComponentFromActor(AActor* Actor, bool bSearchForComponent=false); 19 | 20 | }; 21 | -------------------------------------------------------------------------------- /Source/Adventure/Public/AdventureInterface.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "UObject/Interface.h" 7 | #include "AdventureInterface.generated.h" 8 | 9 | class UAdventureComponent; 10 | 11 | UINTERFACE() 12 | class UAdventureInterface : public UInterface 13 | { 14 | GENERATED_BODY() 15 | }; 16 | 17 | 18 | class ADVENTURE_API IAdventureInterface 19 | { 20 | GENERATED_BODY() 21 | 22 | public: 23 | 24 | //Get the adventure component 25 | virtual UAdventureComponent* GetAdventureComponent() const; 26 | }; 27 | -------------------------------------------------------------------------------- /Source/Adventure/Public/AdventureMacros.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CoreMinimal.h" 4 | #include "Adventure/AdventureLogChannels.h" 5 | 6 | #define ADVENTURE_MESSAGELOG() (FMessageLog("LogAdventure")) 7 | 8 | #define ADVENTURE_MESSAGELOG_ADD(x) (FMessageLog("LogAdventure").AddMessage(x)); 9 | 10 | #define ADVENTURE_ERROR(x) (FAdventureLogMessages::Error(x)); 11 | 12 | #define ADVENTURE_WARNING(x) (FAdventureLogMessages::Warning(x)); 13 | 14 | #define ADVENTURE_INFO(x) (FAdventureLogMessages::Info(x)); 15 | -------------------------------------------------------------------------------- /Source/Adventure/Public/AdventureModule.h: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/ModuleManager.h" 7 | 8 | class FAdventureModule : public IModuleInterface 9 | { 10 | public: 11 | 12 | /** IModuleInterface implementation */ 13 | virtual void StartupModule() override; 14 | virtual void ShutdownModule() override; 15 | }; 16 | -------------------------------------------------------------------------------- /Source/Adventure/Public/AdventurePluginSettings.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "AdventurePluginSettings.generated.h" 7 | 8 | UCLASS(Config=Game, DefaultConfig, meta = (DisplayName="Adventure Settings")) 9 | class ADVENTURE_API UAdventurePluginSettings : public UDeveloperSettings 10 | { 11 | GENERATED_BODY() 12 | 13 | UAdventurePluginSettings(); 14 | 15 | public: 16 | 17 | //Gets the adventure settings 18 | static const UAdventurePluginSettings* Get() { return GetDefault(); } 19 | 20 | //Is the plugin using gameplay tags? 21 | static bool IsUsingGameplayTags() { return Get()->bUseGameplayTag; } 22 | 23 | public: 24 | 25 | //The default Adventure Asset class when making a new Adventure Asset. You can change this if you want to your project's parent class. 26 | UPROPERTY(config, EditAnywhere, Category="Adventure", meta = (AllowAbstract="True")) 27 | TSubclassOf DefaultAdventureClass; 28 | 29 | //The default save object the Adventure Component will use to save. 30 | UPROPERTY(config, EditAnywhere, Category="Adventure") 31 | TSubclassOf DefaultSaveObjectClass; 32 | 33 | //If the plugin should use Gameplay Tag as the default argument in Make/Break Objective instead of Name. 34 | //This will not convert current placed nodes to GameplayTag or vice versa, to avoid data loss. 35 | //Just make a new Make/Break Objective node and the Argument pin will appear as GameplayTag. 36 | UPROPERTY(config, EditAnywhere, Category="Adventure Graph", DisplayName = "Use Gameplay Tag As Default", meta=(ConsoleVariable="adventure.UseGameplayTag")) 37 | uint32 bUseGameplayTag:1; 38 | 39 | }; 40 | -------------------------------------------------------------------------------- /Source/Adventure/Public/AdventureSaveObject.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GameFramework/SaveGame.h" 7 | #include "AdventureSaveObject.generated.h" 8 | 9 | USTRUCT(BlueprintType) 10 | struct FSavedActiveAdventure 11 | { 12 | GENERATED_BODY() 13 | 14 | UPROPERTY(BlueprintReadOnly) 15 | TSubclassOf SavedActiveAdventure; 16 | 17 | UPROPERTY(BlueprintReadOnly) 18 | TArray SavedActiveAdventureData; 19 | 20 | FSavedActiveAdventure() 21 | { 22 | SavedActiveAdventure = nullptr; 23 | SavedActiveAdventureData.Empty(); 24 | } 25 | 26 | FSavedActiveAdventure(TSubclassOf InSavedActiveAdventure, TArray InSavedActiveAdventureData) 27 | { 28 | SavedActiveAdventure = InSavedActiveAdventure; 29 | SavedActiveAdventureData = InSavedActiveAdventureData; 30 | } 31 | }; 32 | 33 | UCLASS() 34 | class ADVENTURE_API UAdventureSaveObject : public USaveGame 35 | { 36 | GENERATED_BODY() 37 | 38 | public: 39 | 40 | //Saves the adventure save object 41 | UFUNCTION(BlueprintCallable, Category = "Adventutre Save Object") 42 | void SaveToDisk(); 43 | 44 | public: 45 | 46 | UPROPERTY(BlueprintReadOnly, Category = "Adventure Save Object", SaveGame) 47 | FString SlotName; 48 | 49 | UPROPERTY(BlueprintReadOnly, Category = "Adventure Save Object", SaveGame) 50 | TArray AdventureComponentSaveData; 51 | 52 | UPROPERTY(BlueprintReadOnly, Category = "Adventure Save Object", SaveGame) 53 | TArray SavedActiveAdventures; 54 | }; 55 | -------------------------------------------------------------------------------- /Source/Adventure/Public/AdventureSharedComponent.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "AdventureComponent.h" 7 | #include "Components/ActorComponent.h" 8 | #include "AdventureSharedComponent.generated.h" 9 | 10 | /** 11 | * Adventure Shared Component is the same functionality as the vanilla Adventure Component, just that all Adventures are shared among all client. 12 | * The vanilla version shares only the Adventures between the owning client of the Actor. 13 | */ 14 | UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent), DisplayName = "Adventure Shared Component") 15 | class ADVENTURE_API UAdventureSharedComponent : public UAdventureComponent 16 | { 17 | GENERATED_BODY() 18 | 19 | public: 20 | 21 | UAdventureSharedComponent(); 22 | 23 | //UObject interface implementation 24 | virtual void GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const override; 25 | //End of implementation 26 | }; 27 | -------------------------------------------------------------------------------- /Source/Adventure/Public/FAdventureGraphNodeMinimal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "GameplayTagContainer.h" 4 | #include "FAdventureGraphNodeMinimal.generated.h" 5 | 6 | class UAdventureAsset; 7 | 8 | UENUM(BlueprintType) 9 | enum EAdventureState 10 | { 11 | Completed, 12 | Failed, 13 | Ongoing, 14 | Abandoned 15 | }; 16 | 17 | USTRUCT(BlueprintType, meta = (HasNativeMake="AdventureBlueprintLibrary.MakeObjectiveWithName", HasNativeBreak="AdventureBlueprintLibrary.BreakObjectiveWithName")) 18 | struct FAdventureObjectiveEntry : public FFastArraySerializerItem 19 | { 20 | GENERATED_BODY() 21 | 22 | //The name that will be used to update objectives. 23 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Objective Settings - Objectives", NotReplicated) 24 | FName Argument; 25 | 26 | #if WITH_EDITORONLY_DATA 27 | 28 | //This is only for editor purposes. You can use GameplayTags to update objectives in the plugin 29 | //But this is only in editor and in the end it uses the FName instead. 30 | 31 | //The Gameplay Tag that will be used to update objectives. 32 | UPROPERTY(NotReplicated, EditAnywhere, DisplayName = "Argument", Category = "Objective Settings - Objectives") 33 | FGameplayTag ArgumentTag; 34 | 35 | #endif 36 | 37 | //The description of this objective 38 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Objective Settings - Objectives") 39 | FText Description; 40 | 41 | //The amount of times we need to complete this action to move on to the next part of the Adventure 42 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Objective Settings - Objectives", meta = (ClampMin = 1)) 43 | int32 Quantity = 1; 44 | 45 | //How many times this objective has been completed. 46 | UPROPERTY(BlueprintReadOnly, Category = "Objective Settings - Objectives") 47 | int32 CurrentProgress = 0; 48 | 49 | //Optional tags for tagging your objectives 50 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Objective Settings - Objectives") 51 | FGameplayTagContainer OptionalTags; 52 | 53 | //Tags to change the condition of this objective. Like if it the objective has failed. 54 | UPROPERTY(BlueprintReadWrite, Category = "Objective Settings - Objectives") 55 | FGameplayTagContainer ConditionTags; 56 | 57 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Objective Settings - Objectives") 58 | int32 Timer = 0; 59 | 60 | UPROPERTY() 61 | int64 ObjectiveUniqueID; 62 | 63 | FAdventureObjectiveEntry() 64 | { 65 | OptionalTags.Reset(); 66 | Argument = {}; 67 | Quantity = 1; 68 | } 69 | 70 | //Checks if this objective has been completed 71 | bool IsCompleted() const; 72 | 73 | //Resets this objective 74 | void ResetObjective(); 75 | 76 | //Get the argument as FName 77 | FName GetArgumentAsName(); 78 | 79 | //Get the argument as GameplayTag 80 | FGameplayTag GetArgumentAsGameplayTag(); 81 | 82 | //If this objective is optional 83 | bool IsOptional(); 84 | 85 | //If this objective can be pre-completed 86 | bool CanBePreCompleted(); 87 | 88 | bool operator == (const FAdventureObjectiveEntry& Other) const 89 | { 90 | return Argument == Other.Argument 91 | && Quantity == Other.Quantity 92 | && CurrentProgress == Other.CurrentProgress 93 | && ConditionTags == Other.ConditionTags 94 | && OptionalTags == Other.OptionalTags; 95 | } 96 | 97 | bool operator != (const FAdventureObjectiveEntry& Other) const 98 | { 99 | return Argument != Other.Argument 100 | || Quantity != Other.Quantity 101 | || CurrentProgress != Other.CurrentProgress 102 | || ConditionTags != Other.ConditionTags 103 | || OptionalTags != Other.OptionalTags; 104 | } 105 | }; 106 | 107 | DECLARE_MULTICAST_DELEGATE_OneParam(FObjectiveStepCompleted, FAdventureObjectiveEntry) 108 | DECLARE_MULTICAST_DELEGATE_OneParam(FObjectiveListCompleted, int64) 109 | DECLARE_MULTICAST_DELEGATE_TwoParams(FObjectiveEntryUpdated, FAdventureObjectiveEntry, int32) 110 | 111 | USTRUCT(BlueprintType) 112 | struct FAdventureObjectiveList : public FFastArraySerializer 113 | { 114 | GENERATED_BODY() 115 | 116 | //~FFastArraySerializer implementation 117 | void PreReplicatedRemove(const TArrayView RemovedIndices, int32 FinalSize); 118 | void PostReplicatedAdd(const TArrayView AddedIndices, int32 FinalSize); 119 | void PostReplicatedChange(const TArrayView ChangedIndices, int32 FinalSize); 120 | //~End of FFastArraySerializer implementation 121 | 122 | void AddEntry(FAdventureObjectiveEntry NewEntry); 123 | void RemoveEntryWithArgument(FName Argument); 124 | void UpdateEntry(FName Argument, int32 Quantity); 125 | 126 | void AddConditionTag(FName Argument, FGameplayTag NewConditionTag); 127 | 128 | bool ObjectiveListCompleted(int64 ObjectiveUniqueID); 129 | 130 | TArray GetEntries(); 131 | 132 | bool NetDeltaSerialize(FNetDeltaSerializeInfo& DeltaParms) 133 | { 134 | return FastArrayDeltaSerialize(Entries, DeltaParms, *this); 135 | } 136 | 137 | void BroadcastChangeMessage(int32 Index); 138 | void Append(TArray ObjectiveList); 139 | 140 | private: 141 | 142 | // Replicated list of items 143 | UPROPERTY() 144 | TArray Entries; 145 | 146 | public: 147 | 148 | FObjectiveListCompleted ObjectiveCompleted; 149 | FObjectiveStepCompleted ObjectiveStepCompleted; 150 | FObjectiveEntryUpdated ObjectiveConditionTagsUpdated; 151 | FObjectiveEntryUpdated ObjectiveEntryUpdated; 152 | 153 | }; 154 | 155 | template<> 156 | struct TStructOpsTypeTraits : public TStructOpsTypeTraitsBase2 157 | { 158 | enum 159 | { 160 | WithNetDeltaSerializer = true, 161 | }; 162 | }; 163 | 164 | -------------------------------------------------------------------------------- /Source/Adventure/Public/Volumes/AdventureObjectiveTriggerVolume.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "AdventureTriggerBoxVolume.h" 7 | #include "AdventureObjectiveTriggerVolume.generated.h" 8 | 9 | UCLASS() 10 | class ADVENTURE_API AAdventureObjectiveTriggerVolume : public AAdventureTriggerBoxVolume 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | 16 | AAdventureObjectiveTriggerVolume(); 17 | 18 | //AAdventureTriggerBoxVolume interface implementation 19 | virtual void RunAdventureComponentOperation(UAdventureComponent* AdventureComponent) override; 20 | //End of implementation 21 | 22 | public: 23 | 24 | //The argument to update once this volume has been overlapped 25 | UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Adventure Trigger Volume - Objective Argument") 26 | FName ObjectiveArgument; 27 | 28 | }; 29 | -------------------------------------------------------------------------------- /Source/Adventure/Public/Volumes/AdventureStartTriggerVolume.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "AdventureTriggerBoxVolume.h" 7 | #include "AdventureStartTriggerVolume.generated.h" 8 | 9 | UCLASS() 10 | class ADVENTURE_API AAdventureStartTriggerVolume : public AAdventureTriggerBoxVolume 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | 16 | AAdventureStartTriggerVolume(); 17 | 18 | //AAdventureTriggerBoxVolume interface implementation 19 | virtual void RunAdventureComponentOperation(UAdventureComponent* AdventureComponent) override; 20 | //End of implementation 21 | 22 | public: 23 | 24 | //Which adventure should start when overlapping this volume 25 | UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Adventure Trigger Volume - Class") 26 | TSubclassOf AdventureToStart; 27 | }; 28 | -------------------------------------------------------------------------------- /Source/Adventure/Public/Volumes/AdventureTriggerBoxVolume.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GameFramework/Actor.h" 7 | #include "AdventureTriggerBoxVolume.generated.h" 8 | 9 | UENUM() 10 | enum EAdventureComponentGetterSettings 11 | { 12 | //Get from overlapping character/pawn 13 | CharacterOrPawn, 14 | //Get from overlapping character/pawn player controller 15 | PlayerController, 16 | //Get from overlapping character/pawn player state 17 | PlayerState, 18 | //Get from Game State 19 | GameState, 20 | //Get from Game Mode 21 | GameMode, 22 | }; 23 | 24 | class UAdventureComponent; 25 | 26 | UCLASS(hidecategories=(Advanced, Collision, Volume, Brush, Attachment, Input, Replication, Rendering, Actor, LOD, Cooking), ConversionRoot, Abstract) 27 | class ADVENTURE_API AAdventureTriggerBoxVolume : public AActor 28 | { 29 | GENERATED_BODY() 30 | 31 | public: 32 | 33 | AAdventureTriggerBoxVolume(); 34 | 35 | public: 36 | 37 | UPROPERTY() 38 | class UBoxComponent* TriggerBoxVolume; 39 | 40 | UPROPERTY() 41 | class UBillboardComponent* AdventureIconBillboard; 42 | 43 | //Which actor should the volume try to get the Adventure Component from when this volume has been overlapped? 44 | UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Adventure Trigger Volume - Getter Settings") 45 | TEnumAsByte GetterSettings; 46 | 47 | protected: 48 | 49 | UFUNCTION() 50 | virtual void OnComponentOverlapped(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult); 51 | 52 | virtual void BeginPlay() override; 53 | virtual void RunAdventureComponentOperation(UAdventureComponent* AdventureComponent) {}; 54 | }; 55 | -------------------------------------------------------------------------------- /Source/AdventureEditor/AdventureEditor.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class AdventureEditor : ModuleRules 6 | { 7 | public AdventureEditor(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 10 | 11 | PrivateIncludePathModuleNames.AddRange( 12 | new string[] { 13 | "AssetRegistry", 14 | "AssetTools", 15 | "PropertyEditor", 16 | "ContentBrowser", 17 | "MessageLog", 18 | } 19 | ); 20 | 21 | PublicDependencyModuleNames.AddRange( 22 | new string[] 23 | { 24 | "Core", 25 | "CoreUObject", 26 | "Engine", 27 | "InputCore", 28 | "EditorStyle", 29 | "PlacementMode" 30 | } 31 | ); 32 | 33 | 34 | PrivateDependencyModuleNames.AddRange( 35 | new string[] 36 | { 37 | "SlateCore", 38 | "Slate", 39 | "CoreUObject", 40 | "ApplicationCore", 41 | "Engine", 42 | "RenderCore", 43 | "InputCore", 44 | "ClassViewer", 45 | "Adventure", 46 | "AssetTools", 47 | "UnrealEd", 48 | "Kismet", 49 | "AdventureGraphEditor" 50 | } 51 | ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Source/AdventureEditor/Private/AdventureEditorModule.cpp: -------------------------------------------------------------------------------- 1 | #include "AdventureEditorModule.h" 2 | #include "AdventureMacros.h" 3 | #include "AdventureMessageLogEditor.h" 4 | #include "AdventureStyle.h" 5 | #include "MessageLogInitializationOptions.h" 6 | #include "MessageLogModule.h" 7 | #include "ActorFactories/ActorFactoryBlueprint.h" 8 | #include "Adventure/AdventureLogChannels.h" 9 | #include "AssetTools/FAssetTypeActions_AdventureAsset.h" 10 | #include "AssetTools/FAssetTypeActions_AdventureSaveObject.h" 11 | #include "Factory/AdventureAssetActorFactory.h" 12 | #include "Logging/MessageLog.h" 13 | #include "Volumes/AdventureObjectiveTriggerVolume.h" 14 | #include "Volumes/AdventureStartTriggerVolume.h" 15 | 16 | #define LOCTEXT_NAMESPACE "FAdventureEditorModule" 17 | 18 | uint32 FAdventureEditorModule::AdventureCategory; 19 | 20 | void FAdventureEditorModule::StartupModule() 21 | { 22 | FAdventureStyle::Initialize(); 23 | 24 | { 25 | IAssetTools& AssetTools = FModuleManager::LoadModuleChecked("AssetTools").Get(); 26 | AdventureCategory = AssetTools.RegisterAdvancedAssetCategory(FName(TEXT("Adventure")), LOCTEXT("AdventureCategory", "Adventure")); 27 | RegisterAssetTypeAction(AssetTools, MakeShareable(new FAssetTypeActions_AdventureAsset())); 28 | RegisterAssetTypeAction(AssetTools, MakeShareable(new FAssetTypeActions_AdventureSaveObject())); 29 | } 30 | 31 | RegisterPlacementModeExtensions(); 32 | 33 | //Register the Adventure message log tab 34 | { 35 | FMessageLogModule& MessageLogModule = FModuleManager::LoadModuleChecked("MessageLog"); 36 | FMessageLogInitializationOptions InitOptions; 37 | InitOptions.bShowPages = true; 38 | InitOptions.bAllowClear = true; 39 | InitOptions.bShowInLogWindow = true; 40 | MessageLogModule.RegisterLogListing("Adventure", LOCTEXT("Adventure", "Adventure"), InitOptions); 41 | OnPostWorldCreationHandle = FWorldDelegates::OnPostWorldCreation.AddStatic(&FAdventureEditorModule::OnPostWorldCreation); 42 | OnWorldCleanUpHandle = FWorldDelegates::OnWorldCleanup.AddStatic(&FAdventureEditorModule::OnWorldCleanUp); 43 | 44 | //Register the message log editor 45 | { 46 | FAdventureLogMessages::LogMessageDelegate.AddStatic(&AdventureMessageLogEditor::LogMessage); 47 | } 48 | } 49 | } 50 | 51 | void FAdventureEditorModule::RegisterAssetTypeAction(IAssetTools& AssetTools, TSharedRef Action) 52 | { 53 | AssetTools.RegisterAssetTypeActions(Action); 54 | CreatedAssetTypeActions.Add(Action); 55 | } 56 | 57 | void FAdventureEditorModule::RegisterPlacementModeExtensions() 58 | { 59 | if (GEditor) 60 | { 61 | IPlacementModeModule& PlacementModeModule = IPlacementModeModule::Get(); 62 | PlacementModeModule.RegisterPlacementCategory(PlacementCategoryInfo); 63 | 64 | PlacementModeModule.RegisterPlaceableItem(PlacementCategoryInfo.UniqueHandle, MakeShared( 65 | *UActorFactoryBlueprint::StaticClass(), 66 | AAdventureObjectiveTriggerVolume::StaticClass(), 67 | NAME_None, 68 | NAME_None, 69 | TOptional(), 70 | TOptional(), 71 | NSLOCTEXT("PlacementMode", "Trigger Objective Volume", "Objective Trigger Volume") 72 | )); 73 | 74 | PlacementModeModule.RegisterPlaceableItem(PlacementCategoryInfo.UniqueHandle, MakeShared( 75 | *UActorFactoryBlueprint::StaticClass(), 76 | AAdventureStartTriggerVolume::StaticClass(), 77 | NAME_None, 78 | NAME_None, 79 | TOptional(), 80 | TOptional(), 81 | NSLOCTEXT("PlacementMode", "Start Adventure Volume", "Start Adventure Volume") 82 | )); 83 | 84 | PlacementModeModule.RegenerateItemsForCategory(FBuiltInPlacementCategories::AllClasses()); 85 | 86 | UActorFactory* NewFactory = NewObject(GetTransientPackage(), UAdventureAssetActorFactory::StaticClass()); 87 | GEditor->ActorFactories.Add(NewFactory); 88 | } 89 | } 90 | 91 | void FAdventureEditorModule::OnPostWorldCreation(UWorld* InWorld) 92 | { 93 | // clearing out messages from the world being cleaned up 94 | ADVENTURE_MESSAGELOG().NewPage(FText::FromString("AdventureSession_" + FString(__TIME__))); 95 | } 96 | 97 | void FAdventureEditorModule::OnWorldCleanUp(UWorld*, bool, bool) 98 | { 99 | //Open the Adventure message log if there are warning messages 100 | ADVENTURE_MESSAGELOG().Open(EMessageSeverity::Info, false); 101 | } 102 | 103 | void FAdventureEditorModule::ShutdownModule() 104 | { 105 | FAdventureStyle::Shutdown(); 106 | 107 | if (FModuleManager::Get().IsModuleLoaded("AssetTools")) 108 | { 109 | // Unregister our custom created assets from the AssetTools 110 | IAssetTools& AssetTools = FModuleManager::GetModuleChecked("AssetTools").Get(); 111 | for (int32 i = 0; i < CreatedAssetTypeActions.Num(); ++i) 112 | { 113 | AssetTools.UnregisterAssetTypeActions(CreatedAssetTypeActions[i].ToSharedRef()); 114 | } 115 | } 116 | 117 | CreatedAssetTypeActions.Empty(); 118 | } 119 | 120 | IMPLEMENT_MODULE(FAdventureEditorModule, AdventureEditor); 121 | 122 | #undef LOCTEXT_NAMESPACE 123 | -------------------------------------------------------------------------------- /Source/AdventureEditor/Private/AdventureMessageLogEditor.cpp: -------------------------------------------------------------------------------- 1 | #include "AdventureMessageLogEditor.h" 2 | 3 | #include "AdventureMacros.h" 4 | #include "Kismet2/KismetDebugUtilities.h" 5 | #include "Kismet2/KismetEditorUtilities.h" 6 | #include "Misc/UObjectToken.h" 7 | 8 | void AdventureMessageLogEditor::LogMessage(const TSharedRef& Message) 9 | { 10 | struct Local 11 | { 12 | static void OnMessageLogLinkActivated(const class TSharedRef& Token) 13 | { 14 | if (Token->GetType() == EMessageToken::Object) 15 | { 16 | const TSharedRef UObjectToken = StaticCastSharedRef(Token); 17 | if (UObjectToken->GetObject().IsValid()) 18 | { 19 | FKismetEditorUtilities::BringKismetToFocusAttentionOnObject(UObjectToken->GetObject().Get()); 20 | } 21 | } 22 | } 23 | }; 24 | 25 | const TArray& ScriptStack = FBlueprintContextTracker::Get().GetScriptStack(); 26 | 27 | TArray> ReversedTokens; 28 | if (ScriptStack.Num() > 0) 29 | { 30 | const FFrame& StackFrame = *ScriptStack.Last(); 31 | UClass* ClassContainingCode = FKismetDebugUtilities::FindClassForNode(nullptr, StackFrame.Node); 32 | UBlueprint* BlueprintObj = (ClassContainingCode ? Cast(ClassContainingCode->ClassGeneratedBy) : NULL); 33 | if (BlueprintObj) 34 | { 35 | const int32 BreakpointOffset = StackFrame.Code - StackFrame.Node->Script.GetData() - 1; 36 | 37 | ReversedTokens.Add(FUObjectToken::Create(BlueprintObj, FText::FromString(BlueprintObj->GetName())) 38 | ->OnMessageTokenActivated(FOnMessageTokenActivated::CreateStatic(&Local::OnMessageLogLinkActivated)) 39 | ); 40 | ReversedTokens.Add(FTextToken::Create(FText::FromString("Blueprint: "))); 41 | 42 | // NOTE: StackFrame.Node is not a blueprint node like you may think ("Node" has some legacy meaning) 43 | ReversedTokens.Add(FUObjectToken::Create(StackFrame.Node, StackFrame.Node->GetDisplayNameText()) 44 | ->OnMessageTokenActivated(FOnMessageTokenActivated::CreateStatic(&Local::OnMessageLogLinkActivated)) 45 | ); 46 | ReversedTokens.Add(FTextToken::Create(FText::FromString("Function: "))); 47 | 48 | #if WITH_EDITORONLY_DATA // to protect access to GeneratedClass->DebugData 49 | UBlueprintGeneratedClass* GeneratedClass = Cast(ClassContainingCode); 50 | if ((GeneratedClass != NULL) && GeneratedClass->DebugData.IsValid()) 51 | { 52 | UEdGraphNode* BlueprintNode = GeneratedClass->DebugData.FindSourceNodeFromCodeLocation(StackFrame.Node, BreakpointOffset, true); 53 | // if instead, there is a node we can point to... 54 | if (BlueprintNode != NULL) 55 | { 56 | ReversedTokens.Add(FUObjectToken::Create(BlueprintNode->GetGraph(), FText::FromString(GetNameSafe(BlueprintNode->GetGraph()))) 57 | ->OnMessageTokenActivated(FOnMessageTokenActivated::CreateStatic(&Local::OnMessageLogLinkActivated)) 58 | ); 59 | ReversedTokens.Add(FTextToken::Create(FText::FromString("Graph: "))); 60 | 61 | ReversedTokens.Add(FUObjectToken::Create(BlueprintNode, BlueprintNode->GetNodeTitle(ENodeTitleType::ListView)) 62 | ->OnMessageTokenActivated(FOnMessageTokenActivated::CreateStatic(&Local::OnMessageLogLinkActivated)) 63 | ); 64 | ReversedTokens.Add(FTextToken::Create(FText::FromString("Node: "))); 65 | } 66 | } 67 | #endif // WITH_EDITORONLY_DATA 68 | } 69 | } 70 | for (int32 Index = ReversedTokens.Num() - 1; Index >= 0; --Index) 71 | { 72 | Message->AddToken(ReversedTokens[Index].ToSharedRef()); 73 | } 74 | 75 | ADVENTURE_MESSAGELOG_ADD(Message) 76 | } 77 | -------------------------------------------------------------------------------- /Source/AdventureEditor/Private/AdventureMessageLogEditor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace AdventureMessageLogEditor 4 | { 5 | void LogMessage(const TSharedRef& Message); 6 | }; 7 | -------------------------------------------------------------------------------- /Source/AdventureEditor/Private/AdventureStyle.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureStyle.h" 5 | #include "Styling/SlateStyle.h" 6 | #include "Styling/SlateStyleRegistry.h" 7 | 8 | TSharedPtr< FSlateStyleSet > FAdventureStyle::AdventureStyleInstance = NULL; 9 | 10 | void FAdventureStyle::Initialize() 11 | { 12 | if ( !AdventureStyleInstance.IsValid() ) 13 | { 14 | AdventureStyleInstance = Create(); 15 | } 16 | } 17 | 18 | void FAdventureStyle::Shutdown() 19 | { 20 | FSlateStyleRegistry::UnRegisterSlateStyle(*AdventureStyleInstance.Get()); 21 | ensure( AdventureStyleInstance.IsUnique() ); 22 | AdventureStyleInstance.Reset(); 23 | } 24 | 25 | FName FAdventureStyle::GetStyleSetName() 26 | { 27 | static FName StyleSetName(TEXT("UMGStyle")); 28 | return StyleSetName; 29 | } 30 | 31 | #define IMAGE_BRUSH( RelativePath, ... ) FSlateImageBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ ) 32 | #define BOX_BRUSH( RelativePath, ... ) FSlateBoxBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ ) 33 | #define BORDER_BRUSH( RelativePath, ... ) FSlateBorderBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ ) 34 | #define IMAGE_BRUSH_SVG( RelativePath, ... ) FSlateVectorImageBrush(Style->RootToContentDir(RelativePath, TEXT(".svg")), __VA_ARGS__) 35 | 36 | const FVector2D Icon16x16(16.0f, 16.0f); 37 | const FVector2D Icon20x20(20.0f, 20.0f); 38 | const FVector2D Icon40x40(40.0f, 40.0f); 39 | const FVector2D Icon64x64(64.0f, 64.0f); 40 | 41 | TSharedRef< FSlateStyleSet > FAdventureStyle::Create() 42 | { 43 | TSharedRef< FSlateStyleSet > Style = MakeShareable(new FSlateStyleSet("AdventureStyle")); 44 | Style->SetContentRoot(FPaths::EngineContentDir() / TEXT("Editor/Slate")); 45 | Style->SetCoreContentRoot(FPaths::EngineContentDir() / TEXT("Slate")); 46 | 47 | #if ENGINE_MAJOR_VERSION == 5 48 | 49 | Style->Set(FName(TEXT("ClassThumbnail.AdventureAssetBlueprint")), new IMAGE_BRUSH_SVG("Starship/AssetIcons/SlateBrushAsset_64", Icon64x64)); 50 | Style->Set(FName(TEXT("ClassIcon.AdventureAssetBlueprint")), new IMAGE_BRUSH_SVG("Starship/AssetIcons/SlateBrushAsset_16", Icon16x16)); 51 | 52 | Style->Set(FName(TEXT("ClassThumbnail.AdventureAsset")), new IMAGE_BRUSH_SVG("Starship/AssetIcons/SlateBrushAsset_64", Icon64x64)); 53 | Style->Set(FName(TEXT("ClassIcon.AdventureAsset")), new IMAGE_BRUSH_SVG("Starship/AssetIcons/SlateBrushAsset_16", Icon16x16)); 54 | 55 | Style->Set(FName(TEXT("ClassThumbnail.AdventureTriggerBoxVolume")), new IMAGE_BRUSH_SVG("Starship/AssetIcons/TriggerBox_64", Icon64x64)); 56 | Style->Set(FName(TEXT("ClassIcon.AdventureTriggerBoxVolume")), new IMAGE_BRUSH_SVG("Starship/AssetIcons/TriggerBox_16", Icon16x16)); 57 | 58 | #endif 59 | 60 | #if ENGINE_MAJOR_VERSION == 4 61 | 62 | Style->Set(FName(TEXT("ClassThumbnail.AdventureTriggerBoxVolume")), new IMAGE_BRUSH("Icons/AssetIcons/TriggerBox_64x", Icon64x64)); 63 | Style->Set(FName(TEXT("ClassIcon.AdventureTriggerBoxVolume")), new IMAGE_BRUSH("Icons/AssetIcons/TriggerBox_16x", Icon16x16)); 64 | 65 | Style->Set(FName(TEXT("ClassThumbnail.AdventureTriggerSphereVolume")), new IMAGE_BRUSH("Icons/AssetIcons/TriggerSphere_64x", Icon64x64)); 66 | Style->Set(FName(TEXT("ClassIcon.AdventureTriggerSphereVolume")), new IMAGE_BRUSH("Icons/AssetIcons/TriggerSphere_16x", Icon16x16)); 67 | 68 | Style->Set(FName(TEXT("ClassThumbnail.AdventureAssetBlueprint")), new IMAGE_BRUSH("Icons/AssetIcons/SlateBrushAsset_64x", Icon64x64)); 69 | Style->Set(FName(TEXT("ClassIcon.AdventureAssetBlueprint")), new IMAGE_BRUSH("Icons/AssetIcons/SlateBrushAsset_16x", Icon16x16)); 70 | 71 | Style->Set(FName(TEXT("ClassThumbnail.AdventureAsset")), new IMAGE_BRUSH("Icons/AssetIcons/SlateBrushAsset_64x", Icon64x64)); 72 | Style->Set(FName(TEXT("ClassIcon.AdventureAsset")), new IMAGE_BRUSH("Icons/AssetIcons/SlateBrushAsset_16x", Icon16x16)); 73 | 74 | #endif 75 | 76 | 77 | FSlateStyleRegistry::RegisterSlateStyle(*Style); 78 | return Style; 79 | } 80 | 81 | #undef IMAGE_BRUSH 82 | #undef BOX_BRUSH 83 | #undef BORDER_BRUSH 84 | 85 | void FAdventureStyle::ReloadTextures() 86 | { 87 | FSlateApplication::Get().GetRenderer()->ReloadTextureResources(); 88 | } 89 | 90 | const ISlateStyle& FAdventureStyle::Get() 91 | { 92 | return *AdventureStyleInstance; 93 | } -------------------------------------------------------------------------------- /Source/AdventureEditor/Private/AssetTools/FAssetTypeActions_AdventureAsset.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "FAssetTypeActions_AdventureAsset.h" 5 | 6 | #include "AdventureAsset.h" 7 | #include "AdventureGraphEditorModule.h" 8 | #include "BlueprintAssets/AdventureAssetBlueprint.h" 9 | #include "Factory/AdventureAssetFactory.h" 10 | 11 | #define LOCTEXT_NAMESPACE "FAssetTypeActions_AdventureAsset" 12 | 13 | FAssetTypeActions_AdventureAsset::FAssetTypeActions_AdventureAsset() 14 | { 15 | 16 | } 17 | 18 | FText FAssetTypeActions_AdventureAsset::GetName() const 19 | { 20 | return NSLOCTEXT("AssetTypeActions_AdventureAsset", "AssetTypeActions_AdventureAsset", "Adventure Asset"); 21 | } 22 | 23 | UClass* FAssetTypeActions_AdventureAsset::GetSupportedClass() const 24 | { 25 | return UAdventureAssetBlueprint::StaticClass(); 26 | } 27 | 28 | void FAssetTypeActions_AdventureAsset::OpenAssetEditor(const TArray& InObjects, TSharedPtr EditWithinLevelEditor) 29 | { 30 | if (IAdventureGraphEditorModule* AdventureEditorModule = &FModuleManager::LoadModuleChecked("AdventureGraphEditor")) 31 | { 32 | for (auto ObjIt = InObjects.CreateConstIterator(); ObjIt; ++ObjIt) 33 | { 34 | AdventureEditorModule->CreateAdventureEditor(EditWithinLevelEditor.IsValid() ? EToolkitMode::WorldCentric : EToolkitMode::Standalone, EditWithinLevelEditor, CastChecked(*ObjIt)); 35 | } 36 | } 37 | } 38 | 39 | UFactory* FAssetTypeActions_AdventureAsset::GetFactoryForBlueprintType(UBlueprint* InBlueprint) const 40 | { 41 | UAdventureAssetFactory* AdventureAssetFactory = NewObject(); 42 | AdventureAssetFactory->ParentClass = TSubclassOf(*InBlueprint->GeneratedClass); 43 | return AdventureAssetFactory; 44 | } 45 | 46 | #undef LOCTEXT_NAMESPACE 47 | -------------------------------------------------------------------------------- /Source/AdventureEditor/Private/AssetTools/FAssetTypeActions_AdventureAsset.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "AdventureEditorModule.h" 7 | #include "AssetTypeActions_Base.h" 8 | #include "FAssetTypeActions_AdventureBase.h" 9 | 10 | class FAssetTypeActions_AdventureAsset : public FAssetTypeActions_AdventureBase 11 | { 12 | public: 13 | 14 | FAssetTypeActions_AdventureAsset(); 15 | 16 | // IAssetTypeActions interface 17 | virtual FText GetName() const override; 18 | virtual UClass* GetSupportedClass() const override; 19 | virtual void OpenAssetEditor(const TArray& InObjects, TSharedPtr EditWithinLevelEditor = TSharedPtr()) override; 20 | virtual UFactory* GetFactoryForBlueprintType(UBlueprint* InBlueprint) const override; 21 | // End of IAssetTypeActions interface 22 | }; 23 | -------------------------------------------------------------------------------- /Source/AdventureEditor/Private/AssetTools/FAssetTypeActions_AdventureBase.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "FAssetTypeActions_AdventureBase.h" 5 | #include "AdventureEditorModule.h" 6 | 7 | FAssetTypeActions_AdventureBase::FAssetTypeActions_AdventureBase() 8 | { 9 | 10 | } 11 | 12 | FColor FAssetTypeActions_AdventureBase::GetTypeColor() const 13 | { 14 | return FColor::Emerald; 15 | } 16 | 17 | uint32 FAssetTypeActions_AdventureBase::GetCategories() 18 | { 19 | return FModuleManager::LoadModuleChecked("AdventureEditor").AdventureCategory; 20 | } 21 | -------------------------------------------------------------------------------- /Source/AdventureEditor/Private/AssetTools/FAssetTypeActions_AdventureBase.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "AssetTypeActions/AssetTypeActions_Blueprint.h" 7 | 8 | /** 9 | * 10 | */ 11 | class FAssetTypeActions_AdventureBase : public FAssetTypeActions_Blueprint 12 | { 13 | public: 14 | 15 | FAssetTypeActions_AdventureBase(); 16 | 17 | // IAssetTypeActions interface 18 | virtual FColor GetTypeColor() const override; 19 | virtual uint32 GetCategories() override; 20 | // End of IAssetTypeActions interface 21 | }; 22 | -------------------------------------------------------------------------------- /Source/AdventureEditor/Private/AssetTools/FAssetTypeActions_AdventureSaveObject.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "FAssetTypeActions_AdventureSaveObject.h" 5 | #include "AdventureSaveObject.h" 6 | #include "BlueprintAssets/AdventureSaveObjectBlueprint.h" 7 | #include "Factory/AdventureSaveObjectFactory.h" 8 | 9 | #define LOCTEXT_NAMESPACE "AssetTypeActions_AdventureSaveObject" 10 | 11 | FAssetTypeActions_AdventureSaveObject::FAssetTypeActions_AdventureSaveObject() 12 | { 13 | } 14 | 15 | FText FAssetTypeActions_AdventureSaveObject::GetName() const 16 | { 17 | return LOCTEXT("AssetTypeActions_AdventureSaveObject_Name", "Custom Save Object"); 18 | } 19 | 20 | UClass* FAssetTypeActions_AdventureSaveObject::GetSupportedClass() const 21 | { 22 | return UAdventureSaveObjectBlueprint::StaticClass(); 23 | } 24 | 25 | const TArray& FAssetTypeActions_AdventureSaveObject::GetSubMenus() const 26 | { 27 | static const TArray SubMenus 28 | { 29 | NSLOCTEXT("AssetTypeActions", "AssetTypeActions_AdventureSaveObject", "Save") 30 | }; 31 | 32 | return SubMenus; 33 | } 34 | 35 | UFactory* FAssetTypeActions_AdventureSaveObject::GetFactoryForBlueprintType(UBlueprint* InBlueprint) const 36 | { 37 | UAdventureSaveObjectFactory* AdventureAssetFactory = NewObject(); 38 | AdventureAssetFactory->ParentClass = TSubclassOf(*InBlueprint->GeneratedClass); 39 | return AdventureAssetFactory; 40 | } 41 | 42 | #undef LOCTEXT_NAMESPACE 43 | -------------------------------------------------------------------------------- /Source/AdventureEditor/Private/AssetTools/FAssetTypeActions_AdventureSaveObject.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "FAssetTypeActions_AdventureBase.h" 7 | 8 | class FAssetTypeActions_AdventureSaveObject : public FAssetTypeActions_AdventureBase 9 | { 10 | public: 11 | 12 | FAssetTypeActions_AdventureSaveObject(); 13 | 14 | // IAssetTypeActions interface 15 | virtual FText GetName() const override; 16 | virtual UClass* GetSupportedClass() const override; 17 | virtual const TArray& GetSubMenus() const override; 18 | virtual UFactory* GetFactoryForBlueprintType(UBlueprint* InBlueprint) const override; 19 | // End of IAssetTypeActions interface 20 | }; 21 | -------------------------------------------------------------------------------- /Source/AdventureEditor/Private/Factory/AdventureAssetActorFactory.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureAssetActorFactory.h" 5 | #include "AdventureAsset.h" 6 | #include "BlueprintAssets/AdventureAssetBlueprint.h" 7 | #include "Volumes/AdventureStartTriggerVolume.h" 8 | 9 | #define LOCTEXT_NAMESPACE "AdventureAssetActorFactory" 10 | 11 | UAdventureAssetActorFactory::UAdventureAssetActorFactory(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) 12 | { 13 | DisplayName = LOCTEXT("AdventureAssetDisplayName", "Adventure Asset"); 14 | NewActorClass = AAdventureStartTriggerVolume::StaticClass(); 15 | bUseSurfaceOrientation = true; 16 | } 17 | 18 | bool UAdventureAssetActorFactory::CanCreateActorFrom(const FAssetData& AssetData, FText& OutErrorMsg) 19 | { 20 | if (!AssetData.IsValid() || !AssetData.GetClass()->IsChildOf(UAdventureAssetBlueprint::StaticClass())) 21 | { 22 | return false; 23 | } 24 | 25 | return true; 26 | } 27 | 28 | void UAdventureAssetActorFactory::PostSpawnActor(UObject* Asset, AActor* NewActor) 29 | { 30 | Super::PostSpawnActor(Asset, NewActor); 31 | 32 | UAdventureAssetBlueprint* AdventureAsset = CastChecked(Asset); 33 | AAdventureStartTriggerVolume* AdventureTriggerVolume = CastChecked( NewActor ); 34 | AdventureTriggerVolume->AdventureToStart = AdventureAsset->GeneratedClass; 35 | } 36 | 37 | UObject* UAdventureAssetActorFactory::GetAssetFromActorInstance(AActor* ActorInstance) 38 | { 39 | check(ActorInstance->IsA(NewActorClass)); 40 | AAdventureStartTriggerVolume* AdventureTrigger = CastChecked(ActorInstance); 41 | return AdventureTrigger->AdventureToStart; 42 | } 43 | 44 | FQuat UAdventureAssetActorFactory::AlignObjectToSurfaceNormal(const FVector& InSurfaceNormal, const FQuat& ActorRotation) const 45 | { 46 | return FindActorAlignmentRotation(ActorRotation, FVector(0.f, 0.f, 1.f), InSurfaceNormal); 47 | } 48 | 49 | #undef LOCTEXT_NAMESPACE 50 | -------------------------------------------------------------------------------- /Source/AdventureEditor/Private/Factory/AdventureAssetActorFactory.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "ActorFactories/ActorFactory.h" 7 | #include "UObject/Object.h" 8 | #include "AdventureAssetActorFactory.generated.h" 9 | 10 | UCLASS(MinimalAPI, config=Editor) 11 | class UAdventureAssetActorFactory : public UActorFactory 12 | { 13 | GENERATED_UCLASS_BODY() 14 | 15 | //~ Begin UActorFactory Interface 16 | virtual bool CanCreateActorFrom( const FAssetData& AssetData, FText& OutErrorMsg ) override; 17 | virtual void PostSpawnActor( UObject* Asset, AActor* NewActor) override; 18 | virtual UObject* GetAssetFromActorInstance(AActor* ActorInstance) override; 19 | virtual FQuat AlignObjectToSurfaceNormal(const FVector& InSurfaceNormal, const FQuat& ActorRotation) const override; 20 | //~ End UActorFactory Interface 21 | }; 22 | -------------------------------------------------------------------------------- /Source/AdventureEditor/Private/Factory/AdventureAssetFactory.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #include "Factory/AdventureAssetFactory.h" 4 | #include "BlueprintEditorSettings.h" 5 | #include "BlueprintAssets/AdventureAssetBlueprint.h" 6 | #include "AdventureAsset.h" 7 | #include "AdventureBlueprintGeneratedClass.h" 8 | #include "AdventureClassPicker.h" 9 | #include "AdventurePluginSettings.h" 10 | #include "Kismet2/KismetEditorUtilities.h" 11 | #include "Widgets/Layout/SUniformGridPanel.h" 12 | 13 | #define LOCTEXT_NAMESPACE "AdventureAssetFactory" 14 | 15 | UAdventureAssetFactory::UAdventureAssetFactory(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) 16 | { 17 | bCreateNew = true; 18 | bEditAfterNew = true; 19 | SupportedClass = UAdventureAssetBlueprint::StaticClass(); 20 | ParentClass = UAdventureAsset::StaticClass(); 21 | } 22 | 23 | UObject* UAdventureAssetFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn, FName CallingContext) 24 | { 25 | return FKismetEditorUtilities::CreateBlueprint(ParentClass, InParent, Name, EBlueprintType::BPTYPE_Normal, UAdventureAssetBlueprint::StaticClass(), UAdventureBlueprintGeneratedClass::StaticClass(), CallingContext); 26 | } 27 | 28 | UObject* UAdventureAssetFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) 29 | { 30 | return FactoryCreateNew(Class, InParent, Name, Flags, Context, Warn, NAME_None); 31 | } 32 | 33 | bool UAdventureAssetFactory::ConfigureProperties() 34 | { 35 | if (auto NewClass = GetDefault()->DefaultAdventureClass) 36 | { 37 | ParentClass = NewClass; 38 | } 39 | 40 | TSharedRef Dialog = SNew(SAdventureClassPicker); 41 | return Dialog->ConfigureProperties(this); 42 | } 43 | 44 | bool UAdventureAssetFactory::CanCreateNew() const 45 | { 46 | return true; 47 | } 48 | 49 | FString UAdventureAssetFactory::GetDefaultNewAssetName() const 50 | { 51 | return FString(TEXT("ADV_NewAdventure")); 52 | } 53 | 54 | FText UAdventureAssetFactory::GetToolTip() const 55 | { 56 | return LOCTEXT("Adventure Tooltip", "Adventure provides a intuitive, node-based interface to create both simple and complex missions and quests."); 57 | } 58 | 59 | FText UAdventureAssetFactory::GetDisplayName() const 60 | { 61 | return LOCTEXT("Adventure Text", "Adventure"); 62 | } 63 | 64 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Source/AdventureEditor/Private/Factory/AdventureAssetFactory.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Factories/BlueprintFactory.h" 7 | #include "AdventureAssetFactory.generated.h" 8 | 9 | UCLASS() 10 | class UAdventureAssetFactory : public UBlueprintFactory 11 | { 12 | GENERATED_UCLASS_BODY() 13 | 14 | // UFactory interface 15 | virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn, FName CallingContext) override; 16 | virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override; 17 | virtual bool ConfigureProperties() override; 18 | virtual bool CanCreateNew() const override; 19 | virtual FString GetDefaultNewAssetName() const override; 20 | virtual FText GetToolTip() const override; 21 | virtual FText GetDisplayName() const override; 22 | // End of UFactory interface 23 | 24 | }; 25 | -------------------------------------------------------------------------------- /Source/AdventureEditor/Private/Factory/AdventureClassPicker.cpp: -------------------------------------------------------------------------------- 1 | #include "AdventureClassPicker.h" 2 | 3 | #include "ClassViewerModule.h" 4 | #include "EditorStyleSet.h" 5 | #include "IDocumentation.h" 6 | #include "SlateOptMacros.h" 7 | #include "Factories/BlueprintFactory.h" 8 | #include "Widgets/Layout/SUniformGridPanel.h" 9 | 10 | BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION 11 | 12 | #define LOCTEXT_NAMESPACE "SAdventureClassPicker" 13 | 14 | void SAdventureClassPicker::Construct(const FArguments& InArgs) 15 | { 16 | 17 | } 18 | 19 | bool SAdventureClassPicker::ConfigureProperties(TWeakObjectPtr InAdventureObjectiveBlueprintFactory) 20 | { 21 | bOkClicked = false; 22 | BlueprintFactory = InAdventureObjectiveBlueprintFactory; 23 | 24 | ChildSlot 25 | [ 26 | SNew(SBorder) 27 | .Visibility(EVisibility::Visible) 28 | .BorderImage(FEditorStyle::GetBrush("Menu.Background")) 29 | [ 30 | SNew(SBox) 31 | .Visibility(EVisibility::Visible) 32 | .WidthOverride(1500.0f) 33 | [ 34 | SNew(SVerticalBox) 35 | + SVerticalBox::Slot() 36 | .FillHeight(1) 37 | [ 38 | SNew(SBorder) 39 | .BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder")) 40 | .Content() 41 | [ 42 | SAssignNew(ParentClassContainer, SVerticalBox) 43 | ] 44 | ] 45 | + SVerticalBox::Slot() 46 | .AutoHeight() 47 | .HAlign(HAlign_Center) 48 | .VAlign(VAlign_Bottom) 49 | .Padding(8) 50 | [ 51 | SNew(SButton) 52 | .HAlign(HAlign_Center) 53 | .ContentPadding(FEditorStyle::GetMargin("StandardDialog.ContentPadding")) 54 | .OnClicked(this, &SAdventureClassPicker::BaseClassedClicked) 55 | .Text(LOCTEXT("CreateAdventureBlueprintBaseClass", "Create from Base Class")) 56 | .ToolTip(IDocumentation::Get()->CreateToolTip( 57 | LOCTEXT("CreateAssetFromBaseClassButton_Tooltip", "Creates an asset based on the base class set in Project Settings -> Adventure Settings."), 58 | NULL, 59 | TEXT("Shared/Editors/BlueprintEditor"), 60 | TEXT("AdventureMode"))) 61 | ] 62 | // Ok/Cancel buttons 63 | + SVerticalBox::Slot() 64 | .AutoHeight() 65 | .HAlign(HAlign_Center) 66 | .VAlign(VAlign_Bottom) 67 | .Padding(8) 68 | [ 69 | SNew(SUniformGridPanel) 70 | .SlotPadding(FEditorStyle::GetMargin("StandardDialog.SlotPadding")) 71 | .MinDesiredSlotWidth(FEditorStyle::GetFloat("StandardDialog.MinDesiredSlotWidth")) 72 | .MinDesiredSlotHeight(FEditorStyle::GetFloat("StandardDialog.MinDesiredSlotHeight")) 73 | + SUniformGridPanel::Slot(0, 0) 74 | [ 75 | SNew(SButton) 76 | .HAlign(HAlign_Center) 77 | .ContentPadding(FEditorStyle::GetMargin("StandardDialog.ContentPadding")) 78 | .OnClicked(this, &SAdventureClassPicker::OkClicked) 79 | .Text(LOCTEXT("AdventureClassPickerOk", "OK")) 80 | ] 81 | + SUniformGridPanel::Slot(1, 0) 82 | [ 83 | SNew(SButton) 84 | .HAlign(HAlign_Center) 85 | .ContentPadding(FEditorStyle::GetMargin("StandardDialog.ContentPadding")) 86 | .OnClicked(this, &SAdventureClassPicker::CancelClicked) 87 | .Text(LOCTEXT("AdventureClassPickerCancel", "Cancel")) 88 | ] 89 | ] 90 | ] 91 | ] 92 | ]; 93 | 94 | MakeParentClassPicker(); 95 | 96 | TSharedRef Window = SNew(SWindow) 97 | .Title(FText::Format(LOCTEXT("CreateAdventureBlueprintOptions", "Create New {0}"), BlueprintFactory->GetDisplayName())) 98 | .ClientSize(FVector2D(400, 700)) 99 | .SupportsMinimize(false).SupportsMaximize(false) 100 | [ 101 | AsShared() 102 | ]; 103 | 104 | PickerWindow = Window; 105 | 106 | GEditor->EditorAddModalWindow(Window); 107 | BlueprintFactory.Reset(); 108 | return bOkClicked; 109 | } 110 | 111 | FReply SAdventureClassPicker::BaseClassedClicked() 112 | { 113 | CloseDialog(true); 114 | return FReply::Handled(); 115 | } 116 | 117 | FReply SAdventureClassPicker::OkClicked() 118 | { 119 | if (BlueprintFactory.IsValid()) 120 | { 121 | BlueprintFactory->ParentClass = ParentClass.Get(); 122 | } 123 | 124 | CloseDialog(true); 125 | 126 | return FReply::Handled(); 127 | } 128 | 129 | void SAdventureClassPicker::CloseDialog(bool bWasPicked) 130 | { 131 | bOkClicked = bWasPicked; 132 | if (PickerWindow.IsValid()) 133 | { 134 | PickerWindow.Pin()->RequestDestroyWindow(); 135 | } 136 | } 137 | 138 | FReply SAdventureClassPicker::CancelClicked() 139 | { 140 | CloseDialog(); 141 | return FReply::Handled(); 142 | } 143 | 144 | FReply SAdventureClassPicker::OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent) 145 | { 146 | if (InKeyEvent.GetKey() == EKeys::Escape) 147 | { 148 | CloseDialog(); 149 | return FReply::Handled(); 150 | } 151 | 152 | if (InKeyEvent.GetKey() == EKeys::Enter) 153 | { 154 | if (ClassPicked) 155 | { 156 | CloseDialog(true); 157 | } 158 | else 159 | { 160 | BaseClassedClicked(); 161 | } 162 | } 163 | 164 | return SWidget::OnKeyDown(MyGeometry, InKeyEvent); 165 | } 166 | 167 | bool AdventureClassPickerFilter::IsClassAllowed(const FClassViewerInitializationOptions& InInitOptions, const UClass* InClass, TSharedRef InFilterFuncs) 168 | { 169 | return InFilterFuncs->IfInChildOfClassesSet(AllowedChildrenOfClasses, InClass) != EFilterReturn::Failed; 170 | } 171 | 172 | bool AdventureClassPickerFilter::IsUnloadedClassAllowed(const FClassViewerInitializationOptions& InInitOptions, const TSharedRef InUnloadedClassData, TSharedRef InFilterFuncs) 173 | { 174 | return InFilterFuncs->IfInChildOfClassesSet(AllowedChildrenOfClasses, InUnloadedClassData) != EFilterReturn::Failed; 175 | } 176 | 177 | void SAdventureClassPicker::MakeParentClassPicker() 178 | { 179 | FClassViewerModule& ClassViewerModule = FModuleManager::LoadModuleChecked("ClassViewer"); 180 | 181 | FClassViewerInitializationOptions Options; 182 | Options.Mode = EClassViewerMode::ClassPicker; 183 | Options.bIsBlueprintBaseOnly = true; 184 | 185 | TSharedPtr Filter = MakeShareable(new AdventureClassPickerFilter); 186 | 187 | Filter->AllowedChildrenOfClasses.Add(BlueprintFactory->ParentClass); 188 | Options.ClassFilter = Filter; 189 | Options.NameTypeToDisplay = EClassViewerNameTypeToDisplay::DisplayName; 190 | 191 | ParentClassContainer->ClearChildren(); 192 | ParentClassContainer->AddSlot() 193 | .AutoHeight() 194 | [ 195 | SNew(STextBlock) 196 | .Text(LOCTEXT("ParentClass", "Search for Class:")) 197 | .ShadowOffset(FVector2D(1.0f, 1.0f)) 198 | ]; 199 | 200 | ParentClassContainer->AddSlot() 201 | [ 202 | ClassViewerModule.CreateClassViewer(Options, FOnClassPicked::CreateSP(this, &SAdventureClassPicker::OnClassPicked)) 203 | ]; 204 | } 205 | 206 | void SAdventureClassPicker::OnClassPicked(UClass* ChosenClass) 207 | { 208 | ParentClass = ChosenClass; 209 | } 210 | 211 | #undef LOCTEXT_NAMESPACE 212 | 213 | END_SLATE_FUNCTION_BUILD_OPTIMIZATION 214 | -------------------------------------------------------------------------------- /Source/AdventureEditor/Private/Factory/AdventureClassPicker.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ClassViewerFilter.h" 3 | 4 | class UBlueprintFactory; 5 | 6 | class SAdventureClassPicker: public SCompoundWidget 7 | { 8 | public: 9 | 10 | SLATE_BEGIN_ARGS(SAdventureClassPicker){} 11 | SLATE_END_ARGS() 12 | 13 | /** Constructs this widget with InArgs */ 14 | void Construct(const FArguments& InArgs); 15 | 16 | /** Sets properties for the supplied BlueprintFactory */ 17 | bool ConfigureProperties(TWeakObjectPtr InAdventureObjectiveBlueprintFactory); 18 | 19 | /** Creates the combo menu for the parent class */ 20 | void MakeParentClassPicker(); 21 | 22 | /** Handler for when a parent class is selected */ 23 | void OnClassPicked(UClass* ChosenClass); 24 | 25 | FReply BaseClassedClicked(); 26 | 27 | /** Handler for when ok is clicked */ 28 | FReply OkClicked(); 29 | 30 | void CloseDialog(bool bWasPicked = false); 31 | 32 | /** Handler for when cancel is clicked */ 33 | FReply CancelClicked(); 34 | 35 | virtual FReply OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent) override; 36 | 37 | private: 38 | 39 | /** The factory for which we are setting up properties */ 40 | TWeakObjectPtr BlueprintFactory; 41 | 42 | /** A pointer to the window that is asking the user to select a parent class */ 43 | TWeakPtr PickerWindow; 44 | 45 | /** The container for the Parent Class picker */ 46 | TSharedPtr ParentClassContainer; 47 | 48 | /** The selected class */ 49 | TWeakObjectPtr ParentClass; 50 | 51 | /** True if Ok was clicked */ 52 | bool bOkClicked; 53 | bool ClassPicked = false; 54 | }; 55 | 56 | class AdventureClassPickerFilter : public IClassViewerFilter 57 | { 58 | public: 59 | /** All children of these classes will be included unless filtered out by another setting. */ 60 | TSet AllowedChildrenOfClasses; 61 | 62 | AdventureClassPickerFilter() {} 63 | 64 | virtual bool IsClassAllowed(const FClassViewerInitializationOptions& InInitOptions, const UClass* InClass, TSharedRef< FClassViewerFilterFuncs > InFilterFuncs) override; 65 | virtual bool IsUnloadedClassAllowed(const FClassViewerInitializationOptions& InInitOptions, const TSharedRef< const IUnloadedBlueprintData > InUnloadedClassData, TSharedRef< FClassViewerFilterFuncs > InFilterFuncs) override; 66 | }; -------------------------------------------------------------------------------- /Source/AdventureEditor/Private/Factory/AdventureSaveObjectFactory.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureSaveObjectFactory.h" 5 | 6 | #include "AdventureSaveObject.h" 7 | #include "BlueprintAssets/AdventureSaveObjectBlueprint.h" 8 | #include "Kismet2/KismetEditorUtilities.h" 9 | 10 | #define LOCTEXT_NAMESPACE "AdventureSaveObjectFactory" 11 | 12 | UAdventureSaveObjectFactory::UAdventureSaveObjectFactory(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) 13 | { 14 | bCreateNew = true; 15 | bEditAfterNew = true; 16 | #if ENGINE_MAJOR_VERSION == 5 17 | bSkipClassPicker = true; 18 | #endif 19 | SupportedClass = UAdventureSaveObjectBlueprint::StaticClass(); 20 | ParentClass = UAdventureSaveObject::StaticClass(); 21 | } 22 | 23 | bool UAdventureSaveObjectFactory::ConfigureProperties() 24 | { 25 | #if ENGINE_MAJOR_VERSION == 4 26 | return true; 27 | #endif 28 | return Super::ConfigureProperties(); 29 | } 30 | 31 | UObject* UAdventureSaveObjectFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn, FName CallingContext) 32 | { 33 | return FKismetEditorUtilities::CreateBlueprint(ParentClass, InParent, Name, EBlueprintType::BPTYPE_Normal, UAdventureSaveObjectBlueprint::StaticClass(), UBlueprintGeneratedClass::StaticClass(), CallingContext); 34 | } 35 | 36 | UObject* UAdventureSaveObjectFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) 37 | { 38 | return Super::FactoryCreateNew(Class, InParent, Name, Flags, Context, Warn); 39 | } 40 | 41 | FText UAdventureSaveObjectFactory::GetToolTip() const 42 | { 43 | return LOCTEXT("AdventureSaveObjectFactory_Tooltip", "Create a custom save object class. Assign the class in Project Settings -> Adventure Settings -> Default Save Object Class."); 44 | } 45 | 46 | FText UAdventureSaveObjectFactory::GetDisplayName() const 47 | { 48 | return LOCTEXT("AdventureSaveObjectFactory_Name", "Custom Save Object"); 49 | } 50 | 51 | #undef LOCTEXT_NAMESPACE 52 | -------------------------------------------------------------------------------- /Source/AdventureEditor/Private/Factory/AdventureSaveObjectFactory.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Factories/BlueprintFactory.h" 7 | #include "UObject/Object.h" 8 | #include "AdventureSaveObjectFactory.generated.h" 9 | 10 | /** 11 | * 12 | */ 13 | UCLASS() 14 | class UAdventureSaveObjectFactory : public UBlueprintFactory 15 | { 16 | GENERATED_UCLASS_BODY() 17 | 18 | public: 19 | 20 | // UFactory interface 21 | virtual bool ConfigureProperties() override; 22 | virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn, FName CallingContext) override; 23 | virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override; 24 | virtual FText GetToolTip() const override; 25 | virtual FText GetDisplayName() const override; 26 | //End of implementation 27 | }; 28 | -------------------------------------------------------------------------------- /Source/AdventureEditor/Public/AdventureEditorModule.h: -------------------------------------------------------------------------------- 1 | // YourModuleNameModule.h 2 | #pragma once 3 | 4 | #include "CoreMinimal.h" 5 | #include "IPlacementModeModule.h" 6 | #include "Modules/ModuleInterface.h" 7 | 8 | class UAdventureAssetBlueprint; 9 | class IAssetTools; 10 | class IAssetTypeActions; 11 | 12 | class FAdventureEditorModule : public IModuleInterface 13 | { 14 | virtual void ShutdownModule() override; 15 | virtual void StartupModule() override; 16 | 17 | void RegisterAssetTypeAction(IAssetTools& AssetTools, TSharedRef Action); 18 | 19 | void RegisterPlacementModeExtensions(); 20 | 21 | public: 22 | 23 | TArray> CreatedAssetTypeActions; 24 | 25 | static uint32 AdventureCategory; 26 | 27 | FPlacementCategoryInfo PlacementCategoryInfo = FPlacementCategoryInfo(NSLOCTEXT("PlacementModeAdventure", "Adventure", "Adventure"), "Adventure", TEXT("PMAdventure"), 25); 28 | 29 | #if WITH_UNREAL_DEVELOPER_TOOLS 30 | static void OnPostWorldCreation(UWorld* InWorld); 31 | static void OnWorldCleanUp(UWorld*, bool, bool); 32 | FDelegateHandle OnPostWorldCreationHandle; 33 | FDelegateHandle OnWorldCleanUpHandle; 34 | #endif // WITH_UNREAL_DEVELOPER_TOOLS 35 | 36 | }; 37 | -------------------------------------------------------------------------------- /Source/AdventureEditor/Public/AdventureStyle.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Styling/SlateStyle.h" 7 | 8 | class ADVENTUREEDITOR_API FAdventureStyle 9 | { 10 | public: 11 | 12 | static void Initialize(); 13 | static void Shutdown(); 14 | static void ReloadTextures(); 15 | static const ISlateStyle& Get(); 16 | static FName GetStyleSetName(); 17 | 18 | private: 19 | 20 | static TSharedRef Create(); 21 | static TSharedPtr AdventureStyleInstance; 22 | }; 23 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/AdventureGraphEditor.Build.cs: -------------------------------------------------------------------------------- 1 | using UnrealBuildTool; 2 | 3 | public class AdventureGraphEditor : ModuleRules 4 | { 5 | public AdventureGraphEditor(ReadOnlyTargetRules Target) : base(Target) 6 | { 7 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 8 | 9 | PublicDependencyModuleNames.AddRange( 10 | new string[] 11 | { 12 | "Core" 13 | } 14 | ); 15 | 16 | PrivateDependencyModuleNames.AddRange( 17 | new string[] 18 | { 19 | "CoreUObject", 20 | "Engine", 21 | "Slate", 22 | "Kismet", 23 | "SlateCore", 24 | "Adventure", 25 | "KismetCompiler", 26 | "UnrealEd", 27 | "BlueprintGraph", 28 | "GraphEditor", 29 | "SlateCore", 30 | "ToolMenus", 31 | "EditorStyle", 32 | "AdventureTasks" 33 | } 34 | ); 35 | } 36 | } -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureBlueprintCompiler.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureBlueprintCompiler.h" 5 | #include "BlueprintAssets/AdventureAssetBlueprint.h" 6 | #include "AdventureAsset.h" 7 | #include "AdventureBlueprintGeneratedClass.h" 8 | #include "Kismet2/BlueprintEditorUtils.h" 9 | #include "Kismet2/KismetReinstanceUtilities.h" 10 | 11 | #define LOCTEXT_NAMESPACE "AdventureCompilerContext" 12 | 13 | bool FAdventureBlueprintCompiler::CanCompile(const UBlueprint* Blueprint) 14 | { 15 | return Cast(Blueprint) != nullptr; 16 | } 17 | 18 | void FAdventureBlueprintCompiler::Compile(UBlueprint* Blueprint, const FKismetCompilerOptions& CompileOptions, FCompilerResultsLog& Results) 19 | { 20 | if (UAdventureAssetBlueprint* QuestBlueprint = CastChecked(Blueprint)) 21 | { 22 | FAdventureCompilerContext Compiler(QuestBlueprint, Results, CompileOptions); 23 | Compiler.Compile(); 24 | check(Compiler.NewClass); 25 | } 26 | } 27 | 28 | bool FAdventureBlueprintCompiler::GetBlueprintTypesForClass(UClass* ParentClass, UClass*& OutBlueprintClass, UClass*& OutBlueprintGeneratedClass) const 29 | { 30 | if (ParentClass == UAdventureAsset::StaticClass() || ParentClass->IsChildOf(UAdventureAsset::StaticClass())) 31 | { 32 | OutBlueprintClass = UAdventureAssetBlueprint::StaticClass(); 33 | OutBlueprintGeneratedClass = UAdventureBlueprintGeneratedClass::StaticClass(); 34 | return true; 35 | } 36 | 37 | return false; 38 | } 39 | 40 | FAdventureBlueprintCompiler::FAdventureBlueprintCompiler() 41 | { 42 | } 43 | 44 | FAdventureCompilerContext::FAdventureCompilerContext(UAdventureAssetBlueprint* SourceAdventureBP, FCompilerResultsLog& InMessageLog, const FKismetCompilerOptions& InCompilerOptions) : Super(SourceAdventureBP, InMessageLog, InCompilerOptions) 45 | { 46 | } 47 | 48 | void FAdventureCompilerContext::FinishCompilingClass(UClass* Class) 49 | { 50 | FKismetCompilerContext::FinishCompilingClass(Class); 51 | } 52 | 53 | void FAdventureCompilerContext::EnsureProperGeneratedClass(UClass*& TargetUClass) 54 | { 55 | if (TargetUClass && !((UObject*)TargetUClass)->IsA(UAdventureBlueprintGeneratedClass::StaticClass())) 56 | { 57 | FKismetCompilerUtilities::ConsignToOblivion(TargetUClass, Blueprint->bIsRegeneratingOnLoad); 58 | TargetUClass = nullptr; 59 | } 60 | } 61 | 62 | void FAdventureCompilerContext::SpawnNewClass(const FString& NewClassName) 63 | { 64 | NewAdventureBlueprintClass = FindObject(Blueprint->GetOutermost(), *NewClassName); 65 | 66 | if ( NewAdventureBlueprintClass == nullptr ) 67 | { 68 | NewAdventureBlueprintClass = NewObject(Blueprint->GetOutermost(), FName(*NewClassName), RF_Public | RF_Transactional); 69 | } 70 | else 71 | { 72 | // Already existed, but wasn't linked in the Blueprint yet due to load ordering issues 73 | FBlueprintCompileReinstancer::Create(NewAdventureBlueprintClass); 74 | } 75 | 76 | NewClass = NewAdventureBlueprintClass; 77 | } 78 | 79 | void FAdventureCompilerContext::CompileFunction(FKismetFunctionContext& Context) 80 | { 81 | FKismetCompilerContext::CompileFunction(Context); 82 | } 83 | 84 | #undef LOCTEXT_NAMESPACE 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureBlueprintCompiler.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "KismetCompiler.h" 7 | #include "KismetCompilerModule.h" 8 | 9 | class UAdventureAssetBlueprint; 10 | 11 | //Currently empty. Maybe need it in the future. Mostly for future proofing. 12 | class FAdventureBlueprintCompiler : public IBlueprintCompiler 13 | { 14 | public: 15 | 16 | virtual bool CanCompile(const UBlueprint* Blueprint) override; 17 | virtual void Compile(UBlueprint* Blueprint, const FKismetCompilerOptions& CompileOptions, FCompilerResultsLog& Results) override; 18 | virtual bool GetBlueprintTypesForClass(UClass* ParentClass, UClass*& OutBlueprintClass, UClass*& OutBlueprintGeneratedClass) const override; 19 | 20 | FAdventureBlueprintCompiler(); 21 | }; 22 | 23 | class FAdventureCompilerContext : public FKismetCompilerContext 24 | { 25 | public: 26 | 27 | FAdventureCompilerContext(UAdventureAssetBlueprint* SourceAdventureBP, FCompilerResultsLog& InMessageLog, const FKismetCompilerOptions& InCompilerOptions); 28 | 29 | virtual void FinishCompilingClass(UClass* Class) override; 30 | virtual void EnsureProperGeneratedClass(UClass*& TargetClass) override; 31 | virtual void SpawnNewClass(const FString& NewClassName) override; 32 | virtual void CompileFunction(FKismetFunctionContext& Context) override; 33 | 34 | protected: 35 | 36 | typedef FKismetCompilerContext Super; 37 | 38 | class UAdventureBlueprintGeneratedClass* NewAdventureBlueprintClass; 39 | }; 40 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureBlueprintEditorToolbar.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureBlueprintEditorToolbar.h" 5 | 6 | #include "AdventureGraphEditor.h" 7 | #include "BlueprintEditorContext.h" 8 | #include "EditorStyleSet.h" 9 | #include "FAdventureEditorCommands.h" 10 | #include "IDocumentation.h" 11 | #include "SBlueprintEditorToolbar.h" 12 | #include "ToolMenu.h" 13 | #include "ToolMenuMisc.h" 14 | #include "Kismet2/BlueprintEditorUtils.h" 15 | #include "Widgets/Layout/SSpacer.h" 16 | #include "WorkflowOrientedApp/SModeWidget.h" 17 | 18 | #define LOCTEXT_NAMESPACE "Adventure" 19 | 20 | FAdventureBlueprintEditorToolbar::FAdventureBlueprintEditorToolbar(TSharedPtr& InWidgetEditor) 21 | : WidgetEditor(InWidgetEditor) 22 | { 23 | } 24 | 25 | void FAdventureBlueprintEditorToolbar::AddAdventureBlueprintEditorModesToolbar(TSharedPtr Extender) 26 | { 27 | Extender->AddToolBarExtension("Asset",EExtensionHook::After,WidgetEditor.Pin()->GetToolkitCommands(), 28 | FToolBarExtensionDelegate::CreateSP(this, &FAdventureBlueprintEditorToolbar::FillWidgetBlueprintEditorModesToolbar)); 29 | } 30 | 31 | void FAdventureBlueprintEditorToolbar::AddAdventureGraphAssetCreatorButtons(TSharedPtr Extender) 32 | { 33 | Extender->AddToolBarExtension("Asset",EExtensionHook::After,WidgetEditor.Pin()->GetToolkitCommands(), 34 | FToolBarExtensionDelegate::CreateSP(this, &FAdventureBlueprintEditorToolbar::FillWidgetAssetCreatorButtons)); 35 | } 36 | 37 | void FAdventureBlueprintEditorToolbar::FillWidgetBlueprintEditorModesToolbar(FToolBarBuilder& ToolbarBuilder) 38 | { 39 | TSharedPtr BlueprintEditorPtr = WidgetEditor.Pin(); 40 | UBlueprint* BlueprintObj = BlueprintEditorPtr->GetBlueprintObj(); 41 | 42 | if(!BlueprintObj || (!FBlueprintEditorUtils::IsLevelScriptBlueprint(BlueprintObj) && !FBlueprintEditorUtils::IsInterfaceBlueprint(BlueprintObj) && !BlueprintObj->bIsNewlyCreated)) 43 | { 44 | const TAttribute GetActiveMode(BlueprintEditorPtr.ToSharedRef(), &FBlueprintEditor::GetCurrentMode); 45 | const FOnModeChangeRequested SetActiveMode = FOnModeChangeRequested::CreateSP(BlueprintEditorPtr.ToSharedRef(), &FBlueprintEditor::SetCurrentMode); 46 | 47 | // Left side padding 48 | BlueprintEditorPtr->AddToolbarWidget(SNew(SSpacer).Size(FVector2D(4.0f, 1.0f))); 49 | 50 | BlueprintEditorPtr->AddToolbarWidget( 51 | SNew(SModeWidget, FAdventureBlueprintApplicationModes::GetLocalizedMode(FAdventureBlueprintApplicationModes::AdventureMode), FAdventureBlueprintApplicationModes::AdventureMode) 52 | .OnGetActiveMode(GetActiveMode) 53 | .OnSetActiveMode(SetActiveMode) 54 | .ToolTip(IDocumentation::Get()->CreateToolTip( 55 | LOCTEXT("DesignerModeButtonTooltip", "Switch to Adventure Graph"), 56 | NULL, 57 | TEXT("Shared/Editors/BlueprintEditor"), 58 | TEXT("AdventureMode"))) 59 | .IconImage(FEditorStyle::GetBrush("UMGEditor.SwitchToDesigner")) 60 | .AddMetaData(FTagMetaData(TEXT("DesignerMode"))) 61 | ); 62 | 63 | BlueprintEditorPtr->AddToolbarWidget(SNew(SSpacer).Size(FVector2D(10.0f, 1.0f))); 64 | 65 | BlueprintEditorPtr->AddToolbarWidget( 66 | SNew(SModeWidget, FAdventureBlueprintApplicationModes::GetLocalizedMode(FAdventureBlueprintApplicationModes::GraphMode), FAdventureBlueprintApplicationModes::GraphMode) 67 | .OnGetActiveMode(GetActiveMode) 68 | .OnSetActiveMode(SetActiveMode) 69 | .CanBeSelected(BlueprintEditorPtr.Get(), &FBlueprintEditor::IsEditingSingleBlueprint) 70 | .ToolTip(IDocumentation::Get()->CreateToolTip( 71 | LOCTEXT("GraphModeButtonTooltip", "Switch to Graph Editing Mode"), 72 | NULL, 73 | TEXT("Shared/Editors/BlueprintEditor"), 74 | TEXT("GraphMode"))) 75 | .ToolTipText(LOCTEXT("GraphModeButtonTooltip", "Switch to Graph Editing Mode")) 76 | .IconImage(FEditorStyle::GetBrush("FullBlueprintEditor.SwitchToScriptingMode")) 77 | .AddMetaData(FTagMetaData(TEXT("GraphMode"))) 78 | ); 79 | 80 | 81 | BlueprintEditorPtr->AddToolbarWidget(SNew(SSpacer).Size(FVector2D(10.0f, 1.0f))); 82 | } 83 | } 84 | 85 | void FAdventureBlueprintEditorToolbar::FillWidgetAssetCreatorButtons(FToolBarBuilder& ToolbarBuilder) 86 | { 87 | TSharedPtr BlueprintEditorPtr = WidgetEditor.Pin(); 88 | UBlueprint* BlueprintObj = BlueprintEditorPtr->GetBlueprintObj(); 89 | 90 | ToolbarBuilder.EndSection(); 91 | } 92 | 93 | 94 | void FAdventureBlueprintEditorToolbar::AddAdventureButtons(UToolMenu* InMenu) const 95 | { 96 | FToolMenuSection& Section = InMenu->AddSection("AdventureSection"); 97 | Section.InsertPosition = FToolMenuInsert("Asset", EToolMenuInsertType::Before); 98 | 99 | Section.AddDynamicEntry("Adventure Settings", FNewToolMenuSectionDelegate::CreateLambda([](FToolMenuSection& InSection) 100 | { 101 | const UBlueprintEditorToolMenuContext* Context = InSection.FindContext(); 102 | if (Context && Context->BlueprintEditor.IsValid() && Context->GetBlueprintObj()) 103 | { 104 | const TSharedPtr BlueprintEditorToolbar = Context->BlueprintEditor.Pin()->GetToolbarBuilder(); 105 | if (BlueprintEditorToolbar.IsValid()) 106 | { 107 | InSection.AddEntry(FToolMenuEntry::InitToolBarButton( 108 | FAdventureEditorCommands::Get().AdventureSettings, 109 | TAttribute(), 110 | TAttribute(), 111 | FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.GameSettings") 112 | )); 113 | } 114 | } 115 | })); 116 | } 117 | 118 | #undef LOCTEXT_NAMESPACE 119 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureBlueprintEditorToolbar.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "UMGEditor/Private/WidgetBlueprintEditorToolbar.h" 7 | 8 | class IAdventureGraphEditor; 9 | class FExtender; 10 | class FToolBarBuilder; 11 | class UToolMenu; 12 | 13 | class FAdventureBlueprintEditorToolbar : public TSharedFromThis 14 | { 15 | 16 | public: 17 | 18 | FAdventureBlueprintEditorToolbar(TSharedPtr& InWidgetEditor); 19 | 20 | void AddAdventureBlueprintEditorModesToolbar(TSharedPtr Extender); 21 | void AddAdventureGraphAssetCreatorButtons(TSharedPtr Extender); 22 | void FillWidgetBlueprintEditorModesToolbar(FToolBarBuilder& ToolbarBuilder); 23 | void FillWidgetAssetCreatorButtons(FToolBarBuilder& ToolbarBuilder); 24 | 25 | void AddAdventureButtons(UToolMenu* InMenu) const; 26 | 27 | TWeakPtr WidgetEditor; 28 | }; 29 | 30 | struct FAdventureBlueprintApplicationModes 31 | { 32 | static const FName AdventureMode; 33 | static const FName GraphMode; 34 | 35 | static FText GetLocalizedMode(const FName InMode) 36 | { 37 | static TMap< FName, FText > LocModes; 38 | 39 | if ( LocModes.Num() == 0 ) 40 | { 41 | LocModes.Add(AdventureMode, NSLOCTEXT("AdventureBlueprintModes", "Adventure", "Adventure")); 42 | LocModes.Add(GraphMode, NSLOCTEXT("AdventureBlueprintModes", "GraphMode", "Graph")); 43 | } 44 | 45 | check(InMode != NAME_None); 46 | const FText* OutDesc = LocModes.Find(InMode); 47 | check(OutDesc); 48 | 49 | return *OutDesc; 50 | } 51 | 52 | private: 53 | 54 | FAdventureBlueprintApplicationModes() {} 55 | }; 56 | 57 | const FName FAdventureBlueprintApplicationModes::AdventureMode("AdventureEditorMode"); 58 | const FName FAdventureBlueprintApplicationModes::GraphMode("GraphName"); 59 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureEdGraph.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureEdGraph.h" 5 | 6 | UAdventureEdGraph::UAdventureEdGraph() 7 | { 8 | bAllowDeletion = false; 9 | bAllowRenaming = false; 10 | } 11 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureEdGraph.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "EdGraph/EdGraph.h" 7 | #include "AdventureEdGraph.generated.h" 8 | 9 | class UAdventureAsset; 10 | 11 | UCLASS() 12 | class UAdventureEdGraph : public UEdGraph 13 | { 14 | GENERATED_BODY() 15 | 16 | public: 17 | 18 | UAdventureEdGraph(); 19 | }; 20 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureEditorTabFactories.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureEditorTabFactories.h" 5 | #include "AdventureGraphEditor.h" 6 | #include "EditorStyleSet.h" 7 | #include "BlueprintAssets/AdventureAssetBlueprint.h" 8 | #include "Widgets/Docking/SDockTab.h" 9 | 10 | #define LOCTEXT_NAMESPACE "AdventureEditorTabFactories" 11 | 12 | FAdventureEditorTabFactory::FAdventureEditorTabFactory(TSharedPtr InAdventureEditor) : FDocumentTabFactoryForObjects("AdventureEditor_Properties", InAdventureEditor), AdventureEditor(InAdventureEditor) 13 | { 14 | 15 | } 16 | 17 | void FAdventureEditorTabFactory::OnTabActivated(TSharedPtr Tab) const 18 | { 19 | check(AdventureEditor.IsValid()); 20 | TSharedRef GraphEditor = StaticCastSharedRef(Tab->GetContent()); 21 | AdventureEditor.Pin()->OnGraphEditorFocused(GraphEditor); 22 | } 23 | 24 | void FAdventureEditorTabFactory::OnTabRefreshed(TSharedPtr Tab) const 25 | { 26 | TSharedRef GraphEditor = StaticCastSharedRef(Tab->GetContent()); 27 | GraphEditor->NotifyGraphChanged(); 28 | } 29 | 30 | TAttribute FAdventureEditorTabFactory::ConstructTabNameForObject(UEdGraph* DocumentID) const 31 | { 32 | return TAttribute(FText::FromString(DocumentID->GetName())); 33 | } 34 | 35 | TSharedRef FAdventureEditorTabFactory::CreateTabBodyForObject(const FWorkflowTabSpawnInfo& Info, UEdGraph* DocumentID) const 36 | { 37 | return OnCreateGraphEditorWidget.Execute(DocumentID); 38 | } 39 | 40 | const FSlateBrush* FAdventureEditorTabFactory::GetTabIconForObject(const FWorkflowTabSpawnInfo& Info, UEdGraph* DocumentID) const 41 | { 42 | return FEditorStyle::GetBrush(TEXT("UMGEditor.SwitchToDesigner")); 43 | } 44 | 45 | void FAdventureEditorTabFactory::SaveState(TSharedPtr Tab, TSharedPtr Payload) const 46 | { 47 | FVector2D ViewLocation; 48 | float ZoomAmount; 49 | StaticCastSharedRef(Tab->GetContent())->GetViewLocation(ViewLocation, ZoomAmount); 50 | AdventureEditor.Pin()->AdventureBlueprint->LastEditedDocuments.Add(FEditedDocumentInfo(FTabPayload_UObject::CastChecked(Payload), ViewLocation, ZoomAmount)); 51 | } 52 | 53 | #undef LOCTEXT_NAMESPACE 54 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureEditorTabFactories.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GraphEditor.h" 7 | #include "WorkflowOrientedApp/WorkflowUObjectDocuments.h" 8 | 9 | struct FAdventureEditorTabFactory : public FDocumentTabFactoryForObjects 10 | { 11 | public: 12 | 13 | DECLARE_DELEGATE_RetVal_OneParam(TSharedRef, FOnCreateGraphEditorWidget, UEdGraph*); 14 | 15 | FAdventureEditorTabFactory(TSharedPtr InAdventureEditor); 16 | 17 | virtual void OnTabActivated(TSharedPtr Tab) const override; 18 | virtual void OnTabRefreshed(TSharedPtr Tab) const override; 19 | 20 | protected: 21 | 22 | virtual TAttribute ConstructTabNameForObject(UEdGraph* DocumentID) const override; 23 | virtual TSharedRef CreateTabBodyForObject(const FWorkflowTabSpawnInfo& Info, UEdGraph* DocumentID) const override; 24 | virtual const FSlateBrush* GetTabIconForObject(const FWorkflowTabSpawnInfo& Info, UEdGraph* DocumentID) const override; 25 | virtual void SaveState(TSharedPtr Tab, TSharedPtr Payload) const override; 26 | 27 | protected: 28 | 29 | TWeakPtr AdventureEditor; 30 | FOnCreateGraphEditorWidget OnCreateGraphEditorWidget; 31 | 32 | }; -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphEditor.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include 7 | 8 | class IAdventureGraphEditor : public FBlueprintEditor 9 | { 10 | public: 11 | 12 | void InitAdventureEditor(const EToolkitMode::Type Mode, const TSharedPtr< class IToolkitHost >& InitToolkitHost, class UAdventureAssetBlueprint* InAdventureAsset); 13 | void InitEventGraph() const; 14 | 15 | void CreateAdventureGraph() const; 16 | 17 | // Begin FBlueprintEditor 18 | virtual void RegisterApplicationModes(const TArray& InBlueprints, bool bShouldOpenInDefaultsMode, bool bNewlyCreated = false) override; 19 | virtual void JumpToHyperlink(const UObject* ObjectReference, bool bRequestRename) override; 20 | virtual bool IsInAScriptingMode() const override; 21 | virtual TSharedPtr OpenGraphAndBringToFront(UEdGraph* Graph, bool bSetFocus = true) override; 22 | virtual FGraphAppearanceInfo GetGraphAppearance(class UEdGraph* InGraph) const override; 23 | virtual TSubclassOf GetDefaultSchemaClass() const override; 24 | virtual void RegisterTabSpawners(const TSharedRef& TabManager) override; 25 | virtual bool CanAddNewLocalVariable() const override; 26 | virtual UBlueprint* GetBlueprintObj() const override; 27 | virtual void SetCurrentMode(FName NewMode) override; 28 | // End FBlueprintEditor 29 | 30 | void OpenAdventureSettings(); 31 | bool CanModifyAdventureSettings(); 32 | void CreateNewClass(UClass* InClass) const; 33 | 34 | UAdventureAssetBlueprint* GetAdventureBlueprintObj() const; 35 | 36 | static FText GetLocalizedMode(FName InMode); 37 | 38 | public: 39 | 40 | UPROPERTY() 41 | class UAdventureAssetBlueprint* AdventureBlueprint = nullptr; 42 | 43 | TSharedPtr AdventureToolbar; 44 | 45 | private: 46 | 47 | /** Palette of Adventure Functions */ 48 | TSharedPtr Palette; 49 | 50 | /** The tab ids for the material editor */ 51 | static const FName PaletteTabId; 52 | }; 53 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphEditorModule.cpp: -------------------------------------------------------------------------------- 1 |  2 | #define LOCTEXT_NAMESPACE "FAdventureGraphEditorModule" 3 | 4 | #include "AdventureGraphEditorModule.h" 5 | #include "AdventureGraphEditor.h" 6 | #include "EdGraphUtilities.h" 7 | #include "FAdventureEditorCommands.h" 8 | #include "ObjectiveDetailCustomization.h" 9 | #include "AdventureBlueprintCompiler.h" 10 | #include "BlueprintAssets/AdventureAssetBlueprint.h" 11 | 12 | class FAdventureGraphEditorModule : public IAdventureGraphEditorModule 13 | { 14 | 15 | public: 16 | 17 | FAdventureBlueprintCompiler AdventureBlueprintCompiler; 18 | TSharedPtr MenuExtensibilityManager; 19 | TSharedPtr ToolBarExtensibilityManager; 20 | TSharedPtr GraphPanelNodeFactory_AdventureGraph = nullptr; 21 | 22 | virtual void StartupModule() override 23 | { 24 | FKismetCompilerContext::RegisterCompilerForBP(UAdventureAssetBlueprint::StaticClass(), [](UBlueprint* InBlueprint, FCompilerResultsLog& InMessageLog, const FKismetCompilerOptions& InCompileOptions) 25 | { 26 | return MakeShared(CastChecked(InBlueprint), InMessageLog, InCompileOptions); 27 | }); 28 | 29 | IKismetCompilerInterface& KismetCompilerModule = FModuleManager::LoadModuleChecked("KismetCompiler"); 30 | KismetCompilerModule.GetCompilers().Add(&AdventureBlueprintCompiler); 31 | 32 | FAdventureEditorCommands::Register(); 33 | MenuExtensibilityManager = MakeShareable(new FExtensibilityManager); 34 | ToolBarExtensibilityManager = MakeShareable(new FExtensibilityManager); 35 | 36 | 37 | // Register the details customizer 38 | FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked("PropertyEditor"); 39 | PropertyModule.RegisterCustomPropertyTypeLayout("AdventureObjectiveEntry", FOnGetPropertyTypeCustomizationInstance::CreateStatic(&FObjectiveDetailCustomization::MakeInstance)); 40 | }; 41 | 42 | virtual void ShutdownModule() override 43 | { 44 | 45 | } 46 | 47 | virtual void CreateAdventureEditor(const EToolkitMode::Type Mode, const TSharedPtr< class IToolkitHost >& InitToolkitHost, UAdventureAssetBlueprint* AdventureAsset) override 48 | { 49 | TSharedRef NewAdventureEditor(new IAdventureGraphEditor()); 50 | NewAdventureEditor->InitAdventureEditor(Mode, InitToolkitHost, AdventureAsset); 51 | } 52 | 53 | 54 | virtual TSharedPtr GetMenuExtensibilityManager() override { return MenuExtensibilityManager; } 55 | virtual TSharedPtr GetToolBarExtensibilityManager() override { return ToolBarExtensibilityManager; } 56 | 57 | }; 58 | 59 | #undef LOCTEXT_NAMESPACE 60 | 61 | IMPLEMENT_MODULE(FAdventureGraphEditorModule, AdventureGraphEditor) -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphNodes/K2Node_AbandonAdventure.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureGraphNodes/K2Node_AbandonAdventure.h" 5 | #include "BlueprintActionDatabaseRegistrar.h" 6 | #include "AdventureAsset.h" 7 | 8 | #define LOCTEXT_NAMESPACE "UK2Node_AbandonAdventure" 9 | 10 | UK2Node_AbandonAdventure::UK2Node_AbandonAdventure() 11 | { 12 | FunctionReference.SetFromField(UAdventureAsset::StaticClass()->FindFunctionByName(GET_FUNCTION_NAME_CHECKED(UAdventureAsset, K2_AbandonAdventure)), true); 13 | } 14 | 15 | FLinearColor UK2Node_AbandonAdventure::GetNodeTitleColor() const 16 | { 17 | return FLinearColor::Gray; 18 | } 19 | 20 | #undef LOCTEXT_NAMESPACE 21 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphNodes/K2Node_AbandonAdventure.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "K2Node_AdventureState.h" 7 | #include "K2Node_AbandonAdventure.generated.h" 8 | 9 | UCLASS() 10 | class ADVENTUREGRAPHEDITOR_API UK2Node_AbandonAdventure : public UK2Node_AdventureState 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | 16 | UK2Node_AbandonAdventure(); 17 | 18 | //Start of UEdGraphNode interface implementation 19 | virtual FLinearColor GetNodeTitleColor() const override; 20 | //End of implementation 21 | }; 22 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphNodes/K2Node_AdventureState.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureGraphNodes/K2Node_AdventureState.h" 5 | #include "AdventureGraphSchema.h" 6 | #include "BlueprintActionDatabaseRegistrar.h" 7 | #include "BlueprintNodeSpawner.h" 8 | 9 | #define LOCTEXT_NAMESPACE "UK2Node_AdventureState" 10 | 11 | FSlateIcon UK2Node_AdventureState::GetIconAndTint(FLinearColor& OutColor) const 12 | { 13 | return FSlateIcon("EditorStyle", "ClassIcon.SlateBrushAsset"); 14 | } 15 | 16 | FText UK2Node_AdventureState::GetMenuCategory() const 17 | { 18 | return LOCTEXT("K2Node_AdventureState_Category", "Adventure Graph | Tasks"); 19 | } 20 | 21 | bool UK2Node_AdventureState::CanCreateUnderSpecifiedSchema(const UEdGraphSchema* Schema) const 22 | { 23 | return Schema->GetClass() == UAdventureGraphSchema::StaticClass(); 24 | } 25 | 26 | void UK2Node_AdventureState::GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const 27 | { 28 | UClass* ActionKey = GetClass(); 29 | if (ActionRegistrar.IsOpenForRegistration(ActionKey)) 30 | { 31 | UBlueprintNodeSpawner* NodeSpawner = UBlueprintNodeSpawner::Create(GetClass()); 32 | ActionRegistrar.AddBlueprintAction(ActionKey, NodeSpawner); 33 | } 34 | } 35 | 36 | #undef LOCTEXT_NAMESPACE 37 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphNodes/K2Node_AdventureState.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "K2Node_CallFunction.h" 7 | #include "K2Node_AdventureState.generated.h" 8 | 9 | UCLASS() 10 | class ADVENTUREGRAPHEDITOR_API UK2Node_AdventureState : public UK2Node_CallFunction 11 | { 12 | GENERATED_BODY() 13 | 14 | //Start of UEdGraphNode implementation 15 | virtual FSlateIcon GetIconAndTint(FLinearColor& OutColor) const override; 16 | virtual FText GetMenuCategory() const override; 17 | virtual bool CanCreateUnderSpecifiedSchema(const UEdGraphSchema* Schema) const override; 18 | virtual void GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const override; 19 | //End of implementation 20 | }; 21 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphNodes/K2Node_BreakObjective.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureGraphNodes/K2Node_BreakObjective.h" 5 | #include "BlueprintActionDatabaseRegistrar.h" 6 | #include "BlueprintNodeSpawner.h" 7 | #include "AdventurePluginSettings.h" 8 | #include "Library/AdventureBlueprintLibrary.h" 9 | 10 | UK2Node_BreakObjective::UK2Node_BreakObjective() 11 | { 12 | FunctionReference.SetFromField(UAdventureBlueprintLibrary::StaticClass()->FindFunctionByName(GET_FUNCTION_NAME_CHECKED(UAdventureBlueprintLibrary, BreakObjectiveWithName)), false); 13 | } 14 | 15 | void UK2Node_BreakObjective::PostPlacedNewNode() 16 | { 17 | Super::PostPlacedNewNode(); 18 | 19 | if (UAdventurePluginSettings::IsUsingGameplayTags()) 20 | { 21 | FunctionReference.SetFromField(UAdventureBlueprintLibrary::StaticClass()->FindFunctionByName(GET_FUNCTION_NAME_CHECKED(UAdventureBlueprintLibrary, BreakObjectiveWithTag)), false); 22 | } 23 | else 24 | { 25 | FunctionReference.SetFromField(UAdventureBlueprintLibrary::StaticClass()->FindFunctionByName(GET_FUNCTION_NAME_CHECKED(UAdventureBlueprintLibrary, BreakObjectiveWithName)), false); 26 | } 27 | 28 | ReconstructNode(); 29 | } 30 | 31 | FSlateIcon UK2Node_BreakObjective::GetIconAndTint(FLinearColor& OutColor) const 32 | { 33 | #if ENGINE_MAJOR_VERSION == 4 34 | static const FSlateIcon Icon = FSlateIcon("EditorStyle", "ClassIcon.StringTable"); 35 | return Icon; 36 | #endif 37 | 38 | #if ENGINE_MAJOR_VERSION == 5 39 | static const FSlateIcon Icon = FSlateIcon("EditorStyle", "ClassIcon.StringTable"); 40 | return Icon; 41 | #endif 42 | } 43 | 44 | void UK2Node_BreakObjective::GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const 45 | { 46 | Super::GetMenuActions(ActionRegistrar); 47 | 48 | const UClass* ActionKey = GetClass(); 49 | if (ActionRegistrar.IsOpenForRegistration(ActionKey)) 50 | { 51 | UBlueprintNodeSpawner* NodeSpawner = UBlueprintNodeSpawner::Create(GetClass()); 52 | ActionRegistrar.AddBlueprintAction(ActionKey, NodeSpawner); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphNodes/K2Node_BreakObjective.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "K2Node_CallFunction.h" 7 | #include "K2Node_BreakObjective.generated.h" 8 | 9 | UCLASS() 10 | class ADVENTUREGRAPHEDITOR_API UK2Node_BreakObjective : public UK2Node_CallFunction 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | 16 | UK2Node_BreakObjective(); 17 | 18 | //UEdGraphNode interface implementation 19 | virtual void PostPlacedNewNode() override; 20 | virtual FSlateIcon GetIconAndTint(FLinearColor& OutColor) const override; 21 | virtual void GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const override; 22 | //End of implementation 23 | }; 24 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphNodes/K2Node_CompleteAdventure.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureGraphNodes/K2Node_CompleteAdventure.h" 5 | #include "BlueprintActionDatabaseRegistrar.h" 6 | #include "AdventureAsset.h" 7 | 8 | #define LOCTEXT_NAMESPACE "UAdventureGraphNode_Complete" 9 | 10 | UK2Node_CompleteAdventure::UK2Node_CompleteAdventure() 11 | { 12 | FunctionReference.SetFromField(UAdventureAsset::StaticClass()->FindFunctionByName(GET_FUNCTION_NAME_CHECKED(UAdventureAsset, K2_CompleteAdventure)), true); 13 | } 14 | 15 | FLinearColor UK2Node_CompleteAdventure::GetNodeTitleColor() const 16 | { 17 | return FColor::Green; 18 | } 19 | 20 | #undef LOCTEXT_NAMESPACE 21 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphNodes/K2Node_CompleteAdventure.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "K2Node_AdventureState.h" 7 | #include "K2Node_CompleteAdventure.generated.h" 8 | 9 | UCLASS() 10 | class ADVENTUREGRAPHEDITOR_API UK2Node_CompleteAdventure : public UK2Node_AdventureState 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | 16 | UK2Node_CompleteAdventure(); 17 | 18 | //Start of UEdGraphNode interface implementation 19 | virtual FLinearColor GetNodeTitleColor() const override; 20 | //End of implementation 21 | 22 | }; 23 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphNodes/K2Node_ConstructAdventureAsset.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureGraphNodes/K2Node_ConstructAdventureAsset.h" 5 | #include "BlueprintActionDatabaseRegistrar.h" 6 | #include "BlueprintNodeSpawner.h" 7 | #include "K2Node_CallFunction.h" 8 | #include "KismetCompiler.h" 9 | #include "AdventureAsset.h" 10 | #include "Library/AdventureBlueprintLibrary.h" 11 | 12 | #define LOCTEXT_NAMESPACE "K2Node_ConstructAdventureAsset" 13 | 14 | UClass* UK2Node_ConstructAdventureAsset::GetClassPinBaseClass() const 15 | { 16 | return UAdventureAsset::StaticClass(); 17 | } 18 | 19 | bool UK2Node_ConstructAdventureAsset::IsSpawnVarPin(UEdGraphPin* Pin) const 20 | { 21 | return Super::IsSpawnVarPin(Pin) && Pin->PinName != "ActorToUse"; 22 | } 23 | 24 | FText UK2Node_ConstructAdventureAsset::GetBaseNodeTitle() const 25 | { 26 | return LOCTEXT("CreateAdventure_BaseTitle", "Start Adventure On Actor"); 27 | } 28 | 29 | void UK2Node_ConstructAdventureAsset::AllocateDefaultPins() 30 | { 31 | Super::AllocateDefaultPins(); 32 | 33 | UEdGraphPin* OwningPlayerPin = CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Object, AActor::StaticClass(), "ActorToUse"); 34 | SetPinToolTip(*OwningPlayerPin, LOCTEXT("OwningPlayerPinDescription", "The actor that will start this Adventure.")); 35 | } 36 | 37 | void UK2Node_ConstructAdventureAsset::ReallocatePinsDuringReconstruction(TArray& OldPins) 38 | { 39 | Super::ReallocatePinsDuringReconstruction(OldPins); 40 | } 41 | 42 | FText UK2Node_ConstructAdventureAsset::GetNodeTitleFormat() const 43 | { 44 | return LOCTEXT("CreateAdventure_TitleFormat", "Start {ClassName} On Actor"); 45 | } 46 | 47 | FText UK2Node_ConstructAdventureAsset::GetTooltipText() const 48 | { 49 | return LOCTEXT("CreateAdventure_Tooltip", "Starts an Adventure on the given Actor, if it has a AdventureComponent attached. You can expose variables from the Adventure blueprint to this node for more dynamic quests."); 50 | } 51 | 52 | FText UK2Node_ConstructAdventureAsset::GetMenuCategory() const 53 | { 54 | return LOCTEXT("K2Node_ConstructAdventureAsset_MenuCategory", "Adventure | Tasks"); 55 | } 56 | 57 | FSlateIcon UK2Node_ConstructAdventureAsset::GetIconAndTint(FLinearColor& OutColor) const 58 | { 59 | #if ENGINE_MAJOR_VERSION == 4 60 | static const FSlateIcon Icon = FSlateIcon("EditorStyle", "ClassIcon.StringTable"); 61 | return Icon; 62 | #endif 63 | 64 | #if ENGINE_MAJOR_VERSION == 5 65 | static const FSlateIcon Icon = FSlateIcon("EditorStyle", "Starship/AssetIcons/StringTable_16"); 66 | return Icon; 67 | #endif 68 | } 69 | 70 | void UK2Node_ConstructAdventureAsset::GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const 71 | { 72 | UClass* ActionKey = GetClass(); 73 | if (ActionRegistrar.IsOpenForRegistration(ActionKey)) 74 | { 75 | UBlueprintNodeSpawner* NodeSpawner = UBlueprintNodeSpawner::Create(GetClass()); 76 | ActionRegistrar.AddBlueprintAction(ActionKey, NodeSpawner); 77 | } 78 | } 79 | 80 | void UK2Node_ConstructAdventureAsset::ExpandNode(FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph) 81 | { 82 | Super::ExpandNode(CompilerContext, SourceGraph); 83 | 84 | static const FName BeginSpawningBlueprintFuncName = GET_FUNCTION_NAME_CHECKED(UAdventureBlueprintLibrary, BeginSpawningAdventureOnActor); 85 | static const FName AdventureClassNameParam(TEXT("AdventureToStart")); 86 | static const FName ActorToUsePtrParam(TEXT("ActorToUse")); 87 | 88 | static const FName FinishSpawningFuncName = GET_FUNCTION_NAME_CHECKED(UAdventureBlueprintLibrary, FinishSpawningAdventureOnActor); 89 | static const FName AdventurePtrParam(TEXT("AdventureToStart")); 90 | 91 | UK2Node_ConstructAdventureAsset* SpawnNode = this; 92 | UEdGraphPin* SpawnNodeExec = SpawnNode->GetExecPin(); 93 | UEdGraphPin* SpawnActorToUsePin = SpawnNode->FindPin(ActorToUsePtrParam); 94 | UEdGraphPin* SpawnClassPin = SpawnNode->GetClassPin(); 95 | UEdGraphPin* SpawnNodeThen = SpawnNode->GetThenPin(); 96 | UEdGraphPin* SpawnNodeResult = SpawnNode->GetResultPin(); 97 | 98 | // Cache the class to spawn. Note, this is the compile time class that the pin was set to or the variable type it was connected to. Runtime it could be a child. 99 | UClass* ClassToSpawn = GetClassToSpawn(); 100 | 101 | UClass* SpawnClass = (SpawnClassPin != NULL) ? Cast(SpawnClassPin->DefaultObject) : NULL; 102 | if (!SpawnClassPin || ((0 == SpawnClassPin->LinkedTo.Num()) && (NULL == SpawnClass))) 103 | { 104 | CompilerContext.MessageLog.Error(*LOCTEXT("SpawnAdventureNodeMissingClass_NoClassError", "@@ must have a valid Adventure assigned to @@.").ToString(), SpawnNode, SpawnClassPin); 105 | SpawnNode->BreakAllNodeLinks(); 106 | return; 107 | } 108 | 109 | if (SpawnClass == UAdventureAsset::StaticClass()) 110 | { 111 | CompilerContext.MessageLog.Error(*LOCTEXT("SpawnActorNodeMissingClass_BaseClassError", "@@ can't use the Adventure Base Class to start an Adventure. Assign a child class of Adventure to @@ instead.").ToString(), SpawnNode, SpawnClassPin); 112 | SpawnNode->BreakAllNodeLinks(); 113 | return; 114 | } 115 | 116 | if (SpawnActorToUsePin->LinkedTo.Num() == false) 117 | { 118 | CompilerContext.MessageLog.Error(*LOCTEXT("SpawnActorNodeMissingClass_NoSpawnActor", "@@ must have a valid reference assigned to @@").ToString(), SpawnNode, SpawnActorToUsePin); 119 | SpawnNode->BreakAllNodeLinks(); 120 | return; 121 | } 122 | 123 | UK2Node_CallFunction* CallBeginSpawnNode = CompilerContext.SpawnIntermediateNode(SpawnNode, SourceGraph); 124 | CallBeginSpawnNode->FunctionReference.SetExternalMember(BeginSpawningBlueprintFuncName, UAdventureBlueprintLibrary::StaticClass()); 125 | CallBeginSpawnNode->AllocateDefaultPins(); 126 | 127 | UEdGraphPin* CallBeginExec = CallBeginSpawnNode->GetExecPin(); 128 | UEdGraphPin* CallBeginActorToUsePtr = CallBeginSpawnNode->FindPin(ActorToUsePtrParam); 129 | UEdGraphPin* CallBeginActorClassPin = CallBeginSpawnNode->FindPin(AdventureClassNameParam); 130 | UEdGraphPin* CallBeginResult = CallBeginSpawnNode->GetReturnValuePin(); 131 | 132 | // Move 'exec' connection from spawn node to 'begin spawn' 133 | CompilerContext.MovePinLinksToIntermediate(*SpawnNodeExec, *CallBeginExec); 134 | 135 | if(SpawnClassPin->LinkedTo.Num() > 0) 136 | { 137 | // Copy the 'blueprint' connection from the spawn node to 'begin spawn' 138 | CompilerContext.MovePinLinksToIntermediate(*SpawnClassPin, *CallBeginActorClassPin); 139 | } 140 | else 141 | { 142 | // Copy blueprint literal onto begin spawn call 143 | CallBeginActorClassPin->DefaultObject = SpawnClass; 144 | } 145 | 146 | // Copy the ActorToUse connection from the spawn node to 'begin spawn' 147 | if (SpawnActorToUsePin) 148 | { 149 | CompilerContext.MovePinLinksToIntermediate(*SpawnActorToUsePin, *CallBeginActorToUsePtr); 150 | } 151 | 152 | UK2Node_CallFunction* CallFinishSpawnNode = CompilerContext.SpawnIntermediateNode(SpawnNode, SourceGraph); 153 | CallFinishSpawnNode->FunctionReference.SetExternalMember(FinishSpawningFuncName, UAdventureBlueprintLibrary::StaticClass()); 154 | CallFinishSpawnNode->AllocateDefaultPins(); 155 | 156 | UEdGraphPin* CallFinishExec = CallFinishSpawnNode->GetExecPin(); 157 | UEdGraphPin* CallFinishThen = CallFinishSpawnNode->GetThenPin(); 158 | UEdGraphPin* CallFinishActor = CallFinishSpawnNode->FindPin(AdventurePtrParam); 159 | UEdGraphPin* CallFinishResult = CallFinishSpawnNode->GetReturnValuePin(); 160 | 161 | // Move 'then' connection from spawn node to 'finish spawn' 162 | CompilerContext.MovePinLinksToIntermediate(*SpawnNodeThen, *CallFinishThen); 163 | 164 | // Connect output actor from 'begin' to 'finish' 165 | CallBeginResult->MakeLinkTo(CallFinishActor); 166 | 167 | // Move result connection from spawn node to 'finish spawn' 168 | CallFinishResult->PinType = SpawnNodeResult->PinType; // Copy type so it uses the right actor subclass 169 | CompilerContext.MovePinLinksToIntermediate(*SpawnNodeResult, *CallFinishResult); 170 | 171 | UEdGraphPin* LastThen = FKismetCompilerUtilities::GenerateAssignmentNodes(CompilerContext, SourceGraph, CallBeginSpawnNode, SpawnNode, CallBeginResult, ClassToSpawn ); 172 | 173 | // Make exec connection between 'then' on last node and 'finish' 174 | LastThen->MakeLinkTo(CallFinishExec); 175 | 176 | // Break any links to the expanded node 177 | SpawnNode->BreakAllNodeLinks(); 178 | } 179 | 180 | #undef LOCTEXT_NAMESPACE 181 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphNodes/K2Node_ConstructAdventureAsset.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "K2Node_ConstructObjectFromClass.h" 7 | #include "K2Node_ConstructAdventureAsset.generated.h" 8 | 9 | UCLASS() 10 | class ADVENTUREGRAPHEDITOR_API UK2Node_ConstructAdventureAsset : public UK2Node_ConstructObjectFromClass 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | 16 | //Start of UK2Node_ConstructObjectFromClass interface implementation 17 | virtual UClass* GetClassPinBaseClass() const override; 18 | virtual bool IsSpawnVarPin(UEdGraphPin* Pin) const override; 19 | //End of implementation 20 | 21 | //UEdGraphNode interface implementation 22 | virtual FText GetBaseNodeTitle() const override; 23 | virtual void AllocateDefaultPins() override; 24 | virtual void ReallocatePinsDuringReconstruction(TArray& OldPins) override; 25 | virtual FText GetNodeTitleFormat() const override; 26 | virtual FText GetTooltipText() const override; 27 | virtual FText GetMenuCategory() const override; 28 | virtual FSlateIcon GetIconAndTint(FLinearColor& OutColor) const override; 29 | virtual void GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const override; 30 | //End of implementation 31 | 32 | //Start of UK2Node implementation 33 | virtual void ExpandNode(FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph) override; 34 | //End of implementation 35 | }; 36 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphNodes/K2Node_FailAdventure.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureGraphNodes/K2Node_FailAdventure.h" 5 | #include "BlueprintActionDatabaseRegistrar.h" 6 | #include "AdventureAsset.h" 7 | 8 | 9 | #define LOCTEXT_NAMESPACE "AdventureGraphNode_Fail" 10 | 11 | UK2Node_FailAdventure::UK2Node_FailAdventure() 12 | { 13 | FunctionReference.SetFromField(UAdventureAsset::StaticClass()->FindFunctionByName(GET_FUNCTION_NAME_CHECKED(UAdventureAsset, K2_FailAdventure)), true); 14 | } 15 | FLinearColor UK2Node_FailAdventure::GetNodeTitleColor() const 16 | { 17 | return FColor::Orange; 18 | } 19 | 20 | #undef LOCTEXT_NAMESPACE 21 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphNodes/K2Node_FailAdventure.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "K2Node_AdventureState.h" 7 | #include "K2Node_FailAdventure.generated.h" 8 | 9 | UCLASS() 10 | class ADVENTUREGRAPHEDITOR_API UK2Node_FailAdventure : public UK2Node_AdventureState 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | 16 | UK2Node_FailAdventure(); 17 | 18 | //Start of UEdGraphNode implementation 19 | virtual FLinearColor GetNodeTitleColor() const override; 20 | //End of implementation 21 | 22 | }; 23 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphNodes/K2Node_MakeObjective.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureGraphNodes/K2Node_MakeObjective.h" 5 | #include "BlueprintActionDatabaseRegistrar.h" 6 | #include "BlueprintNodeSpawner.h" 7 | #include "KismetCompiler.h" 8 | #include "ToolMenu.h" 9 | #include "AdventurePluginSettings.h" 10 | #include "Kismet2/BlueprintEditorUtils.h" 11 | #include "Library/AdventureBlueprintLibrary.h" 12 | 13 | #define LOCTEXT_NAMESPACE "K2Node_MakeObjective" 14 | 15 | static const FName PN_Argument = GET_MEMBER_NAME_CHECKED(FAdventureObjectiveEntry, Argument); 16 | static const FName PN_Quantity = GET_MEMBER_NAME_CHECKED(FAdventureObjectiveEntry, Quantity); 17 | 18 | UK2Node_MakeObjective::UK2Node_MakeObjective() 19 | { 20 | FunctionReference.SetFromField(UAdventureBlueprintLibrary::StaticClass()->FindFunctionByName(GET_FUNCTION_NAME_CHECKED(UAdventureBlueprintLibrary, MakeObjectiveWithName)), false); 21 | } 22 | 23 | void UK2Node_MakeObjective::GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const 24 | { 25 | const UClass* ActionKey = GetClass(); 26 | if (ActionRegistrar.IsOpenForRegistration(ActionKey)) 27 | { 28 | UBlueprintNodeSpawner* NodeSpawner = UBlueprintNodeSpawner::Create(GetClass()); 29 | ActionRegistrar.AddBlueprintAction(ActionKey, NodeSpawner); 30 | } 31 | } 32 | 33 | FSlateIcon UK2Node_MakeObjective::GetIconAndTint(FLinearColor& OutColor) const 34 | { 35 | #if ENGINE_MAJOR_VERSION == 4 36 | static const FSlateIcon Icon = FSlateIcon("EditorStyle", "ClassIcon.StringTable"); 37 | return Icon; 38 | #endif 39 | 40 | #if ENGINE_MAJOR_VERSION == 5 41 | static const FSlateIcon Icon = FSlateIcon("EditorStyle", "ClassIcon.StringTable"); 42 | return Icon; 43 | #endif 44 | } 45 | 46 | FText UK2Node_MakeObjective::GetNodeTitle(ENodeTitleType::Type TitleType) const 47 | { 48 | return LOCTEXT("K2Node_MakeObjectiveTitle", "Make Objective"); 49 | } 50 | 51 | bool UK2Node_MakeObjective::IsNodePure() const 52 | { 53 | return true; 54 | } 55 | 56 | void UK2Node_MakeObjective::AllocateDefaultPins() 57 | { 58 | Super::AllocateDefaultPins(); 59 | 60 | if (UEdGraphPin* QuantityPin = FindPin(PN_Quantity)) 61 | { 62 | QuantityPin->DefaultValue = "1"; 63 | } 64 | 65 | if (UEdGraphPin* ObjectiveArgumentPin = FindPin(PN_Argument)) 66 | { 67 | if (UAdventurePluginSettings::IsUsingGameplayTags() == false) 68 | { 69 | ObjectiveArgumentPin->DefaultValue = "My Objective Argument"; 70 | } 71 | 72 | ObjectiveArgumentPin->SetSavePinIfOrphaned(false); 73 | } 74 | } 75 | 76 | void UK2Node_MakeObjective::ExpandNode(FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph) 77 | { 78 | if (UEdGraphPin* QuantityPin = FindPin(PN_Quantity)) 79 | { 80 | if (QuantityPin->DefaultValue == "0" && QuantityPin->LinkedTo.Num() == 0) 81 | { 82 | CompilerContext.MessageLog.Warning(*LOCTEXT("MakeObjective_BadQuantity", "@@ is set to 0. This objective will not run correctly.").ToString(), QuantityPin); 83 | } 84 | } 85 | 86 | if (UEdGraphPin* ObjectiveArgumentPin = FindPin(PN_Argument)) 87 | { 88 | if (ObjectiveArgumentPin->LinkedTo.Num() == 0) 89 | { 90 | if (ObjectiveArgumentPin->DefaultValue == "None") 91 | { 92 | CompilerContext.MessageLog.Error(*LOCTEXT("MakeObjective_InvalidObjectiveArgument_None", "@@ can't be set as None.").ToString(), ObjectiveArgumentPin); 93 | return; 94 | } 95 | 96 | if (ObjectiveArgumentPin->DefaultValue.IsEmpty()) 97 | { 98 | CompilerContext.MessageLog.Error(*LOCTEXT("MakeObjective_InvalidObjectiveArgument_Empty", "@@ can't be empty.").ToString(), ObjectiveArgumentPin); 99 | return; 100 | } 101 | } 102 | } 103 | 104 | Super::ExpandNode(CompilerContext, SourceGraph); 105 | } 106 | 107 | void UK2Node_MakeObjective::PostPlacedNewNode() 108 | { 109 | Super::PostPlacedNewNode(); 110 | 111 | if (UAdventurePluginSettings::IsUsingGameplayTags()) 112 | { 113 | FunctionReference.SetFromField(UAdventureBlueprintLibrary::StaticClass()->FindFunctionByName(GET_FUNCTION_NAME_CHECKED(UAdventureBlueprintLibrary, MakeObjectiveWithTag)), false); 114 | } 115 | else 116 | { 117 | FunctionReference.SetFromField(UAdventureBlueprintLibrary::StaticClass()->FindFunctionByName(GET_FUNCTION_NAME_CHECKED(UAdventureBlueprintLibrary, MakeObjectiveWithName)), false); 118 | } 119 | 120 | ReconstructNode(); 121 | } 122 | 123 | #undef LOCTEXT_NAMESPACE 124 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphNodes/K2Node_MakeObjective.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "K2Node_CallFunction.h" 7 | #include "K2Node_MakeObjective.generated.h" 8 | 9 | //Creates a objective with a localized description. 10 | UCLASS() 11 | class ADVENTUREGRAPHEDITOR_API UK2Node_MakeObjective : public UK2Node_CallFunction 12 | { 13 | GENERATED_BODY() 14 | 15 | public: 16 | 17 | UK2Node_MakeObjective(); 18 | 19 | virtual void GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const override; 20 | virtual FSlateIcon GetIconAndTint(FLinearColor& OutColor) const override; 21 | virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const override; 22 | virtual bool IsNodePure() const override; 23 | virtual void AllocateDefaultPins() override; 24 | virtual void ExpandNode(FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph) override; 25 | virtual void PostPlacedNewNode() override; 26 | 27 | 28 | }; -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphNodes/K2Node_Root.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureGraphNodes/K2Node_Root.h" 5 | #include "KismetCompiler.h" 6 | #include "AdventureAsset.h" 7 | 8 | #define LOCTEXT_NAMESPACE "AdventureGraphNode_Root" 9 | 10 | UK2Node_Root::UK2Node_Root() 11 | { 12 | bOverrideFunction = true; 13 | EventReference.SetFromField(UAdventureAsset::StaticClass()->FindFunctionByName(GET_FUNCTION_NAME_CHECKED(UAdventureAsset, K2_OnAdventureBeginPlay)), true); 14 | } 15 | 16 | FLinearColor UK2Node_Root::GetNodeTitleColor() const 17 | { 18 | return FLinearColor::Red; 19 | } 20 | 21 | FSlateIcon UK2Node_Root::GetIconAndTint(FLinearColor& OutColor) const 22 | { 23 | static const FSlateIcon Icon = FSlateIcon("EditorStyle", "ClassIcon.K2Node_Event"); 24 | return Icon; 25 | } 26 | 27 | void UK2Node_Root::AllocateDefaultPins() 28 | { 29 | Super::AllocateDefaultPins(); 30 | FindPin(DelegateOutputName)->SafeSetHidden(true); 31 | } 32 | 33 | void UK2Node_Root::PostPlacedNewNode() 34 | { 35 | Super::PostPlacedNewNode(); 36 | } 37 | 38 | #undef LOCTEXT_NAMESPACE 39 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphNodes/K2Node_Root.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "K2Node_Event.h" 7 | #include "K2Node_Root.generated.h" 8 | 9 | /** 10 | * 11 | */ 12 | UCLASS() 13 | class ADVENTUREGRAPHEDITOR_API UK2Node_Root : public UK2Node_Event 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | 19 | UK2Node_Root(); 20 | 21 | //Begin UEdGraphNode implementation 22 | virtual bool CanUserDeleteNode() const override 23 | { 24 | return false; 25 | }; 26 | virtual bool CanDuplicateNode() const override 27 | { 28 | return false; 29 | }; 30 | virtual bool IsNodeRootSet() const override 31 | { 32 | return true; 33 | }; 34 | 35 | virtual void AllocateDefaultPins() override; 36 | virtual void GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const override {}; 37 | 38 | virtual void PostPlacedNewNode() override; 39 | virtual FLinearColor GetNodeTitleColor() const override;; 40 | virtual FSlateIcon GetIconAndTint(FLinearColor& OutColor) const override; 41 | //End of implementation 42 | }; 43 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphSchema.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "AdventureGraphSchema.h" 5 | 6 | #include "AdventureEdGraph.h" 7 | #include "EdGraphSchema_K2_Actions.h" 8 | #include "ToolMenu.h" 9 | #include "AdventureGraphNodes/K2Node_Root.h" 10 | #include "AdventureAsset.h" 11 | #include "Kismet2/BlueprintEditorUtils.h" 12 | 13 | #define LOCTEXT_NAMESPACE "AdventureSchema" 14 | 15 | FName UAdventureGraphSchema::GetParentContextMenuName() const 16 | { 17 | return "Adventure Graph"; 18 | } 19 | 20 | void UAdventureGraphSchema::CreateDefaultNodesForGraph(UEdGraph& Graph) const 21 | { 22 | if (Cast(&Graph)) 23 | { 24 | FGraphNodeCreator RootNodeCreator(Graph); 25 | UK2Node_Root* RootNode = RootNodeCreator.CreateNode(); 26 | RootNode->SetMakeCommentBubbleVisible(true); 27 | RootNode->OnUpdateCommentText("Drag out pin to build functionality for the Adventure."); 28 | RootNodeCreator.Finalize(); 29 | SetNodeMetaData(RootNode, FNodeMetadata::DefaultGraphNode); 30 | 31 | FGraphNodeCreator AdventureCompletedNodeCreator(Graph); 32 | UK2Node_Event* AdventureCompletedNode = AdventureCompletedNodeCreator.CreateNode(); 33 | AdventureCompletedNode->NodePosY += 150.f; 34 | AdventureCompletedNode->EventReference.SetFromField(UAdventureAsset::StaticClass()->FindFunctionByName(GET_FUNCTION_NAME_CHECKED(UAdventureAsset, K2_OnAdventureCompleted)), true); 35 | AdventureCompletedNode->SetMakeCommentBubbleVisible(true); 36 | AdventureCompletedNode->MakeAutomaticallyPlacedGhostNode(); 37 | AdventureCompletedNode->bOverrideFunction = true; 38 | AdventureCompletedNodeCreator.Finalize(); 39 | 40 | FGraphNodeCreator AdventureFailedNodeCreator(Graph); 41 | UK2Node_Event* AdventureFailedNode = AdventureFailedNodeCreator.CreateNode(); 42 | AdventureFailedNode->NodePosY += 300.f; 43 | AdventureFailedNode->EventReference.SetFromField(UAdventureAsset::StaticClass()->FindFunctionByName(GET_FUNCTION_NAME_CHECKED(UAdventureAsset, K2_OnAdventureFailed)), true); 44 | AdventureFailedNode->SetMakeCommentBubbleVisible(true); 45 | AdventureFailedNode->MakeAutomaticallyPlacedGhostNode(); 46 | AdventureFailedNode->bOverrideFunction = true; 47 | AdventureFailedNodeCreator.Finalize(); 48 | 49 | FGraphNodeCreator NewAdventureStateNodeCreator(Graph); 50 | UK2Node_Event* NewAdventureStateNode = NewAdventureStateNodeCreator.CreateNode(); 51 | NewAdventureStateNode->NodePosY += 450.f; 52 | NewAdventureStateNode->EventReference.SetFromField(UAdventureAsset::StaticClass()->FindFunctionByName(GET_FUNCTION_NAME_CHECKED(UAdventureAsset, K2_OnNewAdventureState)), true); 53 | NewAdventureStateNode->SetMakeCommentBubbleVisible(true); 54 | NewAdventureStateNode->MakeAutomaticallyPlacedGhostNode(); 55 | NewAdventureStateNode->bOverrideFunction = true; 56 | NewAdventureStateNodeCreator.Finalize(); 57 | 58 | FGraphNodeCreator NewAdventureInitNodeCreator(Graph); 59 | UK2Node_Event* NewAdventureInitNode = NewAdventureInitNodeCreator.CreateNode(); 60 | NewAdventureInitNode->NodePosY += 600.f; 61 | NewAdventureInitNode->EventReference.SetFromField(UAdventureAsset::StaticClass()->FindFunctionByName(GET_FUNCTION_NAME_CHECKED(UAdventureAsset, K2_OnAdventureInitialized)), true); 62 | NewAdventureInitNode->SetMakeCommentBubbleVisible(true); 63 | NewAdventureInitNode->MakeAutomaticallyPlacedGhostNode(); 64 | NewAdventureInitNode->bOverrideFunction = true; 65 | NewAdventureInitNodeCreator.Finalize(); 66 | 67 | SetNodeMetaData(RootNode, FNodeMetadata::DefaultGraphNode); 68 | } 69 | else 70 | { 71 | Super::CreateDefaultNodesForGraph(Graph); 72 | } 73 | } 74 | 75 | void UAdventureGraphSchema::GetGraphDisplayInformation(const UEdGraph& Graph, FGraphDisplayInfo& DisplayInfo) const 76 | { 77 | if (Cast(&Graph)) 78 | { 79 | DisplayInfo.PlainName = FText::FromString(Graph.GetName()); 80 | DisplayInfo.DisplayName = DisplayInfo.PlainName; 81 | DisplayInfo.Tooltip = LOCTEXT("GraphTooltip_AdventureGraph", "Graph used to plan and create your Adventure"); 82 | } 83 | else 84 | { 85 | Super::GetGraphDisplayInformation(Graph, DisplayInfo); 86 | } 87 | } 88 | 89 | void UAdventureGraphSchema::GetPaletteActions(FGraphActionMenuBuilder& ActionMenuBuilder) 90 | { 91 | //Will implement 92 | } 93 | 94 | #if ENGINE_MAJOR_VERSION == 5 95 | FText UAdventureGraphSchema::GetGraphCategory(const UEdGraph* InGraph) const 96 | { 97 | return FText::FromString("Graphs"); 98 | } 99 | #endif 100 | 101 | #if ENGINE_MAJOR_VERSION == 5 102 | FReply UAdventureGraphSchema::TrySetGraphCategory(const UEdGraph* InGraph, const FText& InCategory) 103 | { 104 | return FReply::Handled(); 105 | } 106 | #endif 107 | 108 | #undef LOCTEXT_NAMESPACE 109 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/AdventureGraphSchema.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "EdGraphSchema_K2.h" 7 | #include "AdventureGraphSchema.generated.h" 8 | 9 | UCLASS() 10 | class UAdventureGraphSchema : public UEdGraphSchema_K2 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | 16 | //UEDGraphSchema Interface Implementation 17 | virtual FName GetParentContextMenuName() const override; 18 | virtual void CreateDefaultNodesForGraph(UEdGraph& Graph) const override; 19 | virtual void GetGraphDisplayInformation(const UEdGraph& Graph, FGraphDisplayInfo& DisplayInfo) const override; 20 | 21 | #if ENGINE_MAJOR_VERSION == 5 22 | virtual FReply TrySetGraphCategory(const UEdGraph* InGraph, const FText& InCategory) override; 23 | virtual FText GetGraphCategory(const UEdGraph* InGraph) const override; 24 | #endif 25 | //End of implementation 26 | 27 | void GetPaletteActions(FGraphActionMenuBuilder& ActionMenuBuilder); 28 | }; 29 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/BlueprintAssets/AdventureAssetBlueprint.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "BlueprintAssets/AdventureAssetBlueprint.h" 5 | #include "AdventureBlueprintGeneratedClass.h" 6 | 7 | UAdventureAssetBlueprint::UAdventureAssetBlueprint() 8 | { 9 | 10 | } 11 | 12 | bool UAdventureAssetBlueprint::SupportedByDefaultBlueprintFactory() const 13 | { 14 | return false; 15 | } 16 | 17 | UClass* UAdventureAssetBlueprint::GetBlueprintClass() const 18 | { 19 | return UAdventureBlueprintGeneratedClass::StaticClass(); 20 | } 21 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/BlueprintAssets/AdventureSaveObjectBlueprint.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "BlueprintAssets/AdventureSaveObjectBlueprint.h" 5 | 6 | UAdventureSaveObjectBlueprint::UAdventureSaveObjectBlueprint() 7 | { 8 | 9 | } 10 | 11 | bool UAdventureSaveObjectBlueprint::SupportedByDefaultBlueprintFactory() const 12 | { 13 | return false; 14 | } 15 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/FAdventureEditorApplicationMode.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "FAdventureEditorApplicationMode.h" 5 | #include "AdventureBlueprintEditorToolbar.h" 6 | #include "AdventureGraphEditor.h" 7 | #include "AdventureGraphEditorModule.h" 8 | #include "SBlueprintEditorToolbar.h" 9 | #include "ToolMenu.h" 10 | 11 | FAdventureEditorApplicationMode::FAdventureEditorApplicationMode(TSharedPtr InAdventureEditor) : FAdventureBlueprintApplicationMode(InAdventureEditor, FAdventureBlueprintApplicationModes::AdventureMode) 12 | { 13 | } 14 | 15 | void FAdventureBlueprintApplicationMode::PostActivateMode() 16 | { 17 | FBlueprintEditorApplicationMode::PostActivateMode(); 18 | 19 | if (UToolMenu* Toolbar = AdventureBlueprintEditor.Pin()->RegisterModeToolbarIfUnregistered(GetModeName())) 20 | { 21 | RegisterToolbarMenus(Toolbar, GetBlueprintEditor()); 22 | } 23 | ; 24 | 25 | IAdventureGraphEditorModule& AdventureGraphEditorModule = FModuleManager::LoadModuleChecked("AdventureGraphEditor"); 26 | ToolbarExtender = AdventureGraphEditorModule.GetToolBarExtensibilityManager()->GetAllExtenders(); 27 | 28 | // AdventureBlueprintEditor.Pin()->AdventureToolbar->AddAdventureBlueprintEditorModesToolbar(ToolbarExtender); 29 | } 30 | 31 | void FAdventureEditorApplicationMode::PostActivateMode() 32 | { 33 | FAdventureBlueprintApplicationMode::PostActivateMode(); 34 | 35 | GetBlueprintEditor()->CreateAdventureGraph(); 36 | AdventureBlueprintEditor.Pin()->AdventureToolbar->AddAdventureGraphAssetCreatorButtons(ToolbarExtender); 37 | } 38 | 39 | void FAdventureEditorApplicationMode::RegisterToolbarMenus(UToolMenu* Toolbar, TSharedPtr InAdventureEditor) 40 | { 41 | FAdventureBlueprintApplicationMode::RegisterToolbarMenus(Toolbar, InAdventureEditor); 42 | // InAdventureEditor->AdventureToolbar->AddAdventureButtons(Toolbar); 43 | } 44 | 45 | FAdventureBlueprintGraphApplicationMode::FAdventureBlueprintGraphApplicationMode(TSharedPtr InAdventureEditor) : FAdventureBlueprintApplicationMode(InAdventureEditor, FAdventureBlueprintApplicationModes::GraphMode) 46 | { 47 | 48 | } 49 | 50 | void FAdventureBlueprintGraphApplicationMode::PostActivateMode() 51 | { 52 | FAdventureBlueprintApplicationMode::PostActivateMode(); 53 | GetBlueprintEditor()->InitEventGraph(); 54 | } 55 | 56 | void FAdventureBlueprintGraphApplicationMode::RegisterToolbarMenus(UToolMenu* Toolbar, TSharedPtr InAdventureEditor) 57 | { 58 | FAdventureBlueprintApplicationMode::RegisterToolbarMenus(Toolbar, InAdventureEditor); 59 | } 60 | 61 | 62 | FAdventureBlueprintApplicationMode::FAdventureBlueprintApplicationMode(TSharedPtr InAdventureEditor, FName InModeName) : FBlueprintEditorApplicationMode(InAdventureEditor, InModeName, FAdventureBlueprintApplicationModes::GetLocalizedMode, false, false), AdventureBlueprintEditor(InAdventureEditor) 63 | { 64 | 65 | } 66 | 67 | UAdventureAssetBlueprint* FAdventureBlueprintApplicationMode::GetBlueprint() const 68 | { 69 | if (const IAdventureGraphEditor* Editor = AdventureBlueprintEditor.Pin().Get()) 70 | { 71 | return Editor->GetAdventureBlueprintObj(); 72 | } 73 | 74 | return nullptr; 75 | } 76 | 77 | TSharedPtr FAdventureBlueprintApplicationMode::GetBlueprintEditor() const 78 | { 79 | return AdventureBlueprintEditor.Pin(); 80 | } 81 | 82 | void FAdventureBlueprintApplicationMode::RegisterToolbarMenus(UToolMenu* Toolbar, TSharedPtr InAdventureEditor) 83 | { 84 | InAdventureEditor->GetToolbarBuilder()->AddCompileToolbar(Toolbar); 85 | InAdventureEditor->GetToolbarBuilder()->AddScriptingToolbar(Toolbar); 86 | InAdventureEditor->GetToolbarBuilder()->AddBlueprintGlobalOptionsToolbar(Toolbar); 87 | InAdventureEditor->GetToolbarBuilder()->AddDebuggingToolbar(Toolbar); 88 | } 89 | 90 | void FAdventureBlueprintApplicationMode::RegisterTabFactories(TSharedPtr InTabManager) 91 | { 92 | FBlueprintEditorApplicationMode::RegisterTabFactories(InTabManager); 93 | GetBlueprintEditor()->PushTabFactories(TabFactories); 94 | } 95 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/FAdventureEditorApplicationMode.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "BlueprintEditorModes.h" 7 | 8 | class FAdventureBlueprintApplicationMode : public FBlueprintEditorApplicationMode 9 | { 10 | public: 11 | 12 | FAdventureBlueprintApplicationMode(TSharedPtr InAdventureEditor, FName InModeName); 13 | 14 | protected: 15 | 16 | class UAdventureAssetBlueprint* GetBlueprint() const; 17 | TSharedPtr GetBlueprintEditor() const; 18 | 19 | //FBlueprintEditorApplicationMode implementation 20 | virtual void RegisterToolbarMenus(UToolMenu* Toolbar, TSharedPtr InAdventureEditor); 21 | virtual void RegisterTabFactories(TSharedPtr InTabManager) override; 22 | virtual void PostActivateMode() override; 23 | //End of implementation 24 | 25 | protected: 26 | 27 | TWeakPtr AdventureBlueprintEditor; 28 | FWorkflowAllowedTabSet TabFactories; 29 | }; 30 | 31 | class FAdventureEditorApplicationMode : public FAdventureBlueprintApplicationMode 32 | { 33 | 34 | public: 35 | 36 | FAdventureEditorApplicationMode(TSharedPtr InAdventureEditor); 37 | 38 | //FBlueprintEditorApplicationMode implementation 39 | virtual void PostActivateMode() override; 40 | virtual void RegisterToolbarMenus(UToolMenu* Toolbar, TSharedPtr InAdventureEditor) override; 41 | //End of implementation 42 | }; 43 | 44 | class FAdventureBlueprintGraphApplicationMode : public FAdventureBlueprintApplicationMode 45 | { 46 | 47 | public: 48 | 49 | FAdventureBlueprintGraphApplicationMode(TSharedPtr InAdventureEditor); 50 | 51 | //FBlueprintEditorApplicationMode implementation 52 | virtual void PostActivateMode() override; 53 | virtual void RegisterToolbarMenus(UToolMenu* Toolbar, TSharedPtr InAdventureEditor) override; 54 | //End of implementation 55 | }; 56 | 57 | 58 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/FAdventureEditorCommands.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "FAdventureEditorCommands.h" 5 | 6 | #define LOCTEXT_NAMESPACE "AdventureEditorCommands" 7 | 8 | void FAdventureEditorCommands::RegisterCommands() 9 | { 10 | UI_COMMAND(AdventureSettings, "Adventure Settings", "Adventure Settings", EUserInterfaceActionType::Button, FInputChord()); 11 | } 12 | 13 | #undef LOCTEXT_NAMESPACE 14 | 15 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/FAdventureEditorCommands.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | class FAdventureEditorCommands : public TCommands 8 | { 9 | public: 10 | 11 | FAdventureEditorCommands() 12 | : TCommands("AdventureEditorCommands", NSLOCTEXT("Contexts", "AdventureEditorCommands", "Adventure Editor Commands"), NAME_None, FEditorStyle::GetStyleSetName()) 13 | { 14 | } 15 | 16 | TSharedPtr AdventureSettings; 17 | TSharedPtr ChangeToMultipleObjectives; 18 | 19 | /** Initialize commands */ 20 | virtual void RegisterCommands() override; 21 | }; 22 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/ObjectiveDetailCustomization.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "ObjectiveDetailCustomization.h" 5 | #include "DetailLayoutBuilder.h" 6 | #include "DetailWidgetRow.h" 7 | #include "IDetailChildrenBuilder.h" 8 | #include "IPropertyUtilities.h" 9 | #include "FAdventureGraphNodeMinimal.h" 10 | #include "Kismet2/BlueprintEditorUtils.h" 11 | 12 | #define LOCTEXT_NAMESPACE "FObjectiveDetailCustomization" 13 | 14 | FObjectiveDetailCustomization::FObjectiveDetailCustomization() 15 | { 16 | } 17 | 18 | void FObjectiveDetailCustomization::CustomizeHeader(TSharedRef PropertyHandle, FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& CustomizationUtils) 19 | { 20 | StructPropertyHandle = PropertyHandle; 21 | HeaderRow 22 | .NameContent() 23 | [ 24 | SNew(STextBlock) 25 | .Font(IDetailLayoutBuilder::GetDetailFont()) 26 | .Text(LOCTEXT("ObjectiveInfo_HeaderName", "Objective Info")) 27 | ]; 28 | } 29 | 30 | void FObjectiveDetailCustomization::CustomizeChildren(TSharedRef PropertyHandle, IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils) 31 | { 32 | StructCustomization = &StructCustomizationUtils; 33 | 34 | TMap> PropertyHandles; 35 | uint32 NumChildren; 36 | StructPropertyHandle->GetNumChildren(NumChildren); 37 | 38 | for (uint32 ChildIndex = 0; ChildIndex < NumChildren; ++ChildIndex) 39 | { 40 | TSharedRef ChildHandle = StructPropertyHandle->GetChildHandle(ChildIndex).ToSharedRef(); 41 | const FName PropertyName = ChildHandle->GetProperty()->GetFName(); 42 | PropertyHandles.Add(PropertyName, ChildHandle); 43 | } 44 | 45 | ArgumentNameProperty = PropertyHandles.Find(GET_MEMBER_NAME_CHECKED(FAdventureObjectiveEntry, Argument))->ToSharedRef(); 46 | ArgumentTagProperty = PropertyHandles.Find(GET_MEMBER_NAME_CHECKED(FAdventureObjectiveEntry, ArgumentTag))->ToSharedRef(); 47 | 48 | /*const FText DisplayName = StructPropertyHandle->GetPropertyDisplayName(); 49 | FDetailWidgetRow& ArgumentRow = StructBuilder.AddCustomRow(DisplayName); 50 | ArgumentRow 51 | .NameContent() 52 | [ 53 | SNew(SHorizontalBox) 54 | + SHorizontalBox::Slot() 55 | .HAlign(EHorizontalAlignment::HAlign_Left) 56 | .VAlign(EVerticalAlignment::VAlign_Center) 57 | .AutoWidth() 58 | [ 59 | SNew(SCheckBox) 60 | .IsChecked(this, &FObjectiveDetailCustomization::GetCheckBoxState) 61 | .OnCheckStateChanged(this, &FObjectiveDetailCustomization::OnCheckBoxNewState) 62 | ] 63 | + SHorizontalBox::Slot() 64 | .HAlign(EHorizontalAlignment::HAlign_Left) 65 | .VAlign(EVerticalAlignment::VAlign_Center) 66 | .AutoWidth() 67 | [ 68 | SNew(STextBlock) 69 | .Font(IDetailLayoutBuilder::GetDetailFont()) 70 | .ToolTip(IDocumentation::Get()->CreateToolTip( 71 | LOCTEXT("UseTagArgumentText", "If true, the argument will be a Gameplay Tag instead, otherwise it's Name. Using Gameplay OptionalTags can be enabled by default in the Project Settings under Adventure Settings."), 72 | NULL, 73 | TEXT("Shared/Editors/BlueprintEditor"), 74 | TEXT("AdventureMode"))) 75 | .Text(LOCTEXT("ObjectiveInfo_UseNameAsArgument", "Use Tag Argument")) 76 | ] 77 | ];*/ 78 | 79 | bool UseGameplayTagAsDefault = UAdventurePluginSettings::IsUsingGameplayTags(); 80 | 81 | IDetailPropertyRow& ArgumentNameRow = StructBuilder.AddProperty(ArgumentNameProperty.ToSharedRef()); 82 | ArgumentNameRow.Visibility(UseGameplayTagAsDefault ? EVisibility::Collapsed : EVisibility::Visible); 83 | 84 | IDetailPropertyRow& ArgumentTagRow = StructBuilder.AddProperty(ArgumentTagProperty.ToSharedRef()); 85 | ArgumentTagRow.Visibility(UseGameplayTagAsDefault ? EVisibility::Visible : EVisibility::Collapsed); 86 | 87 | ArgumentTagProperty->SetOnPropertyValueChanged(FSimpleDelegate::CreateLambda([this] 88 | { 89 | if (ArgumentTagProperty.IsValid() && ArgumentTagProperty->GetProperty()) 90 | { 91 | TArray RawStructData; 92 | ArgumentTagProperty->AccessRawData(RawStructData); 93 | 94 | if (RawStructData.Num() > 0) 95 | { 96 | FGameplayTag* Tag = (FGameplayTag*)(RawStructData[0]); 97 | ArgumentNameProperty->SetValue(Tag->GetTagName()); 98 | } 99 | } 100 | })); 101 | 102 | for (auto Property : PropertyHandles) 103 | { 104 | TSharedRef RefProperty = Property.Value.ToSharedRef(); 105 | 106 | if (RefProperty != bUseTagAsArgumentProperty && RefProperty != ArgumentTagProperty && RefProperty != ArgumentNameProperty) 107 | { 108 | StructBuilder.AddProperty(RefProperty); 109 | } 110 | } 111 | } 112 | 113 | void FObjectiveDetailCustomization::OnCheckBoxNewState(ECheckBoxState NewState) 114 | { 115 | bUseTagAsArgumentProperty->SetValue(NewState == ECheckBoxState::Checked); 116 | StructCustomization->GetPropertyUtilities()->ForceRefresh(); 117 | } 118 | 119 | ECheckBoxState FObjectiveDetailCustomization::GetCheckBoxState() const 120 | { 121 | bool UseGameplayTag; 122 | bUseTagAsArgumentProperty->GetValue(UseGameplayTag); 123 | 124 | return UseGameplayTag ? ECheckBoxState::Checked : ECheckBoxState::Unchecked; 125 | } 126 | 127 | #undef LOCTEXT_NAMESPACE 128 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Private/ObjectiveDetailCustomization.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "IDetailPropertyRow.h" 7 | 8 | class FObjectiveDetailCustomization : public IPropertyTypeCustomization 9 | { 10 | public: 11 | 12 | FObjectiveDetailCustomization(); 13 | 14 | /** Makes a new instance of this detail layout class for a specific detail view requesting it */ 15 | static TSharedRef MakeInstance() 16 | { 17 | return MakeShareable(new FObjectiveDetailCustomization); 18 | } 19 | 20 | // IPropertyTypeCustomization interface 21 | virtual void CustomizeHeader(TSharedRef StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override; 22 | virtual void CustomizeChildren(TSharedRef StructPropertyHandle, class IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override; 23 | // End of IPropertyTypeCustomization interface 24 | 25 | private: 26 | 27 | void OnCheckBoxNewState(ECheckBoxState NewState); 28 | ECheckBoxState GetCheckBoxState() const; 29 | 30 | private: 31 | 32 | TSharedPtr bUseTagAsArgumentProperty; 33 | TSharedPtr ArgumentNameProperty; 34 | TSharedPtr ArgumentTagProperty; 35 | 36 | /** Cached property handle */ 37 | TSharedPtr StructPropertyHandle; 38 | IPropertyTypeCustomizationUtils* StructCustomization; 39 | }; 40 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Public/AdventureGraphEditorModule.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CoreMinimal.h" 4 | #include "Modules/ModuleInterface.h" 5 | 6 | class UAdventureAssetBlueprint; 7 | 8 | class IAdventureGraphEditorModule : public IModuleInterface, public IHasMenuExtensibility, public IHasToolBarExtensibility 9 | { 10 | public: 11 | 12 | virtual void CreateAdventureEditor(const EToolkitMode::Type Mode, const TSharedPtr< class IToolkitHost >& InitToolkitHost, UAdventureAssetBlueprint* AdventureAsset) {}; 13 | 14 | virtual TSharedPtr GetMenuExtensibilityManager() override { return nullptr; } 15 | virtual TSharedPtr GetToolBarExtensibilityManager() override { return nullptr; } 16 | 17 | }; 18 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Public/BlueprintAssets/AdventureAssetBlueprint.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "AdventureAssetBlueprint.generated.h" 7 | 8 | UCLASS(BlueprintType) 9 | class ADVENTUREGRAPHEDITOR_API UAdventureAssetBlueprint : public UBlueprint 10 | { 11 | GENERATED_BODY() 12 | 13 | public: 14 | 15 | UAdventureAssetBlueprint(); 16 | 17 | //UBlueprint Interface 18 | virtual bool SupportedByDefaultBlueprintFactory() const override; 19 | virtual UClass* GetBlueprintClass() const override; 20 | //End of UBlueprintInterface 21 | 22 | public: 23 | 24 | /** Graph for adventure asset */ 25 | UPROPERTY() 26 | class UEdGraph* AdventureGraph; 27 | 28 | }; 29 | -------------------------------------------------------------------------------- /Source/AdventureGraphEditor/Public/BlueprintAssets/AdventureSaveObjectBlueprint.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "AdventureSaveObjectBlueprint.generated.h" 7 | 8 | UCLASS() 9 | class ADVENTUREGRAPHEDITOR_API UAdventureSaveObjectBlueprint : public UBlueprint 10 | { 11 | GENERATED_BODY() 12 | 13 | public: 14 | 15 | UAdventureSaveObjectBlueprint(); 16 | 17 | //UBlueprint Interface 18 | virtual bool SupportedByDefaultBlueprintFactory() const override; 19 | //End of UBlueprintInterface 20 | }; 21 | -------------------------------------------------------------------------------- /Source/AdventureTasks/AdventureTasks.Build.cs: -------------------------------------------------------------------------------- 1 | using UnrealBuildTool; 2 | 3 | public class AdventureTasks : ModuleRules 4 | { 5 | public AdventureTasks(ReadOnlyTargetRules Target) : base(Target) 6 | { 7 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 8 | 9 | PublicDependencyModuleNames.AddRange( 10 | new string[] 11 | { 12 | "Core", 13 | "Adventure", 14 | "GameplayTags" 15 | } 16 | ); 17 | 18 | PrivateDependencyModuleNames.AddRange( 19 | new string[] 20 | { 21 | "CoreUObject", 22 | "Engine", 23 | "Slate", 24 | "SlateCore" 25 | } 26 | ); 27 | } 28 | } -------------------------------------------------------------------------------- /Source/AdventureTasks/Private/AdventureTasksModule.cpp: -------------------------------------------------------------------------------- 1 | #include "AdventureTasksModule.h" 2 | 3 | #define LOCTEXT_NAMESPACE "FAdventureTasksModule" 4 | 5 | void FAdventureTasksModule::StartupModule() 6 | { 7 | } 8 | 9 | void FAdventureTasksModule::ShutdownModule() 10 | { 11 | 12 | } 13 | 14 | #undef LOCTEXT_NAMESPACE 15 | 16 | IMPLEMENT_MODULE(FAdventureTasksModule, AdventureTasks) -------------------------------------------------------------------------------- /Source/AdventureTasks/Private/Nodes/AdventureTask.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "Nodes/AdventureTask.h" 5 | 6 | 7 | void UAdventureTask::ActivateTask() 8 | { 9 | RegisterTaskToGameInstance(); 10 | } 11 | 12 | void UAdventureTask::DeactivateTask() 13 | { 14 | UnRegisterTaskFromGameInstance(); 15 | } 16 | 17 | void UAdventureTask::RegisterTaskToGameInstance() 18 | { 19 | UWorld* FoundWorld = GEngine->GetWorldFromContextObject(GetOuter(), EGetWorldErrorMode::LogAndReturnNull); 20 | check(FoundWorld) 21 | 22 | if (FoundWorld && FoundWorld->GetGameInstance()) 23 | { 24 | UGameInstance* GameInstance = FoundWorld->GetGameInstance(); 25 | GameInstance->RegisterReferencedObject(this); 26 | OwningGameInstance = GameInstance; 27 | } 28 | } 29 | 30 | void UAdventureTask::UnRegisterTaskFromGameInstance() 31 | { 32 | ensureAlways(OwningGameInstance); 33 | if (IsValid(OwningGameInstance)) 34 | { 35 | OwningGameInstance->UnregisterReferencedObject(this); 36 | } 37 | #if ENGINE_MAJOR_VERSION == 4 38 | MarkPendingKill(); 39 | #else 40 | MarkAsGarbage(); 41 | #endif 42 | } 43 | -------------------------------------------------------------------------------- /Source/AdventureTasks/Private/Nodes/AdventureTask_AddObjective.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "Nodes/AdventureTask_AddObjective.h" 5 | 6 | #include "AdventureAsset.h" 7 | 8 | void UAdventureTask_AddObjective::ActivateTask() 9 | { 10 | Super::ActivateTask(); 11 | 12 | UAdventureAsset* OwningAdventure = CastChecked(GetOuter()); 13 | OwningAdventure->ObjectiveList.ObjectiveStepCompleted.AddUObject(this, &ThisClass::ObjectiveStepCompleted); 14 | OwningAdventure->ObjectiveList.ObjectiveConditionTagsUpdated.AddUObject(this, &ThisClass::ObjectiveConditionTagsUpdated); 15 | OwningAdventure->ObjectiveList.ObjectiveCompleted.AddUObject(this, &ThisClass::ObjectiveCompleted); 16 | OwningAdventure->AddNewObjectiveList(NewObjectives, ObjectiveUniqueID); 17 | NewObjectives.Empty(); 18 | } 19 | 20 | UAdventureTask_AddObjective* UAdventureTask_AddObjective::AddObjective(UObject* AdventureContextObject) 21 | { 22 | if (IsValid(AdventureContextObject)) 23 | { 24 | return NewObject(AdventureContextObject); 25 | } 26 | return nullptr; 27 | } 28 | 29 | void UAdventureTask_AddObjective::PopulateObjective(TArray InNewObjectives) 30 | { 31 | NewObjectives = InNewObjectives; 32 | } 33 | 34 | void UAdventureTask_AddObjective::ObjectiveStepCompleted(FAdventureObjectiveEntry CompletedStep) 35 | { 36 | if (IsMatchingID(CompletedStep)) 37 | { 38 | OnObjectiveStepCompleted.Broadcast(CompletedStep); 39 | } 40 | } 41 | 42 | void UAdventureTask_AddObjective::ObjectiveConditionTagsUpdated(FAdventureObjectiveEntry UpdatedEntry, int32 Index) 43 | { 44 | if (IsMatchingID(UpdatedEntry)) 45 | { 46 | OnConditionTagsModified.Broadcast(UpdatedEntry); 47 | } 48 | } 49 | 50 | void UAdventureTask_AddObjective::ObjectiveCompleted(int64 InObjectiveUniqueID) 51 | { 52 | if (InObjectiveUniqueID == ObjectiveUniqueID) 53 | { 54 | OnObjectiveListFinished.Broadcast(); 55 | DeactivateTask(); 56 | } 57 | } 58 | 59 | 60 | -------------------------------------------------------------------------------- /Source/AdventureTasks/Private/Nodes/AdventureTask_ListenActiveAdventuresModified.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "Nodes/AdventureTask_ListenActiveAdventuresModified.h" 5 | #include "AdventureComponent.h" 6 | #include "AdventureGlobals.h" 7 | 8 | void UAdventureTask_ListenActiveAdventuresModified::ActivateTask() 9 | { 10 | Super::ActivateTask(); 11 | 12 | AdventureComponent->ActiveAdventuresModified.AddUObject(this, &ThisClass::OnActiveAdventuresModified); 13 | } 14 | 15 | void UAdventureTask_ListenActiveAdventuresModified::OnActiveAdventuresModified(TArray ActiveAdventures) 16 | { 17 | OnChanged.Broadcast(ActiveAdventures); 18 | } 19 | 20 | UAdventureTask_ListenActiveAdventuresModified* UAdventureTask_ListenActiveAdventuresModified::ListenForActiveAdventureChanges(AActor* AdventureComponentOwner) 21 | { 22 | if (UAdventureComponent* AdventureComponent = UAdventureGlobals::GetAdventureComponentFromActor(AdventureComponentOwner, true)) 23 | { 24 | UAdventureTask_ListenActiveAdventuresModified* ListenActiveAdventuresModified = NewObject(AdventureComponentOwner); 25 | ListenActiveAdventuresModified->AdventureComponent = AdventureComponent; 26 | return ListenActiveAdventuresModified; 27 | } 28 | 29 | return nullptr; 30 | } 31 | -------------------------------------------------------------------------------- /Source/AdventureTasks/Private/Nodes/AdventureTask_ListenForAdventureState.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "Nodes/AdventureTask_ListenForAdventureState.h" 5 | 6 | #include "AdventureAsset.h" 7 | 8 | void UAdventureTask_ListenForAdventureState::ActivateTask() 9 | { 10 | Super::ActivateTask(); 11 | AdventureAsset->OnAdventureStateModified.AddUObject(this, &UAdventureTask_ListenForAdventureState::NewState); 12 | } 13 | 14 | void UAdventureTask_ListenForAdventureState::NewState(TEnumAsByte NewAdventureState) 15 | { 16 | OnStateChanged.Broadcast(NewAdventureState); 17 | } 18 | 19 | UAdventureTask_ListenForAdventureState* UAdventureTask_ListenForAdventureState::ListenForAdventureStateChanges(UAdventureAsset* Adventure) 20 | { 21 | if (IsValid(Adventure)) 22 | { 23 | UAdventureTask_ListenForAdventureState* ListenForAdventureState = NewObject(Adventure); 24 | ListenForAdventureState->AdventureAsset = Adventure; 25 | return ListenForAdventureState; 26 | } 27 | 28 | return nullptr; 29 | } 30 | -------------------------------------------------------------------------------- /Source/AdventureTasks/Private/Nodes/AdventureTask_ListenForLoadStartFinished.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "Nodes/AdventureTask_ListenForLoadStartFinished.h" 5 | #include "AdventureComponent.h" 6 | #include "AdventureGlobals.h" 7 | 8 | void UAdventureTask_ListenForLoadStartFinished::ActivateTask() 9 | { 10 | Super::ActivateTask(); 11 | PreLoadHandle = AdventureComponent->LoadingAdventureComponent.AddUObject(this, &ThisClass::AdventureComponentPreLoad); 12 | LoadFinishedHandle = AdventureComponent->FinishedLoadingAdventureComponent.AddUObject(this, &ThisClass::AdventureComponentLoadFinished); 13 | } 14 | 15 | void UAdventureTask_ListenForLoadStartFinished::DeactivateTask() 16 | { 17 | Super::DeactivateTask(); 18 | AdventureComponent->LoadingAdventureComponent.Remove(PreLoadHandle); 19 | AdventureComponent->FinishedLoadingAdventureComponent.Remove(LoadFinishedHandle); 20 | } 21 | 22 | UAdventureTask_ListenForLoadStartFinished* UAdventureTask_ListenForLoadStartFinished::ListenForLoadStartAndFinish(AActor* AdventureComponentOwner) 23 | { 24 | if (UAdventureComponent* AdventureComponent = UAdventureGlobals::GetAdventureComponentFromActor(AdventureComponentOwner, true)) 25 | { 26 | UAdventureTask_ListenForLoadStartFinished* ListenForAdventureState = NewObject(AdventureComponentOwner); 27 | ListenForAdventureState->AdventureComponent = AdventureComponent; 28 | return ListenForAdventureState; 29 | } 30 | 31 | return nullptr; 32 | } 33 | 34 | void UAdventureTask_ListenForLoadStartFinished::AdventureComponentPreLoad() 35 | { 36 | OnPreLoad.Broadcast(); 37 | } 38 | 39 | void UAdventureTask_ListenForLoadStartFinished::AdventureComponentLoadFinished() 40 | { 41 | OnLoadFinished.Broadcast(); 42 | } 43 | -------------------------------------------------------------------------------- /Source/AdventureTasks/Private/Nodes/AdventureTask_ListenForSaveStartFinished.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "Nodes/AdventureTask_ListenForSaveStartFinished.h" 5 | 6 | #include "AdventureComponent.h" 7 | #include "AdventureGlobals.h" 8 | 9 | void UAdventureTask_ListenForSaveStartFinished::ActivateTask() 10 | { 11 | Super::ActivateTask(); 12 | 13 | AdventureComponent->SavingAdventureComponent.AddUObject(this, &ThisClass::AdventureComponentPreSave); 14 | AdventureComponent->FinishedSavingAdventureComponent.AddUObject(this, &ThisClass::AdventureComponentSaveFinished); 15 | } 16 | 17 | UAdventureTask_ListenForSaveStartFinished* UAdventureTask_ListenForSaveStartFinished::ListenForSaveStartAndFinish(AActor* AdventureComponentOwner) 18 | { 19 | if (UAdventureComponent* AdventureComponent = UAdventureGlobals::GetAdventureComponentFromActor(AdventureComponentOwner, true)) 20 | { 21 | UAdventureTask_ListenForSaveStartFinished* ListenForAdventureState = NewObject(AdventureComponentOwner); 22 | ListenForAdventureState->AdventureComponent = AdventureComponent; 23 | return ListenForAdventureState; 24 | } 25 | 26 | return nullptr; 27 | } 28 | 29 | void UAdventureTask_ListenForSaveStartFinished::AdventureComponentPreSave() 30 | { 31 | OnPreSave.Broadcast(); 32 | } 33 | 34 | void UAdventureTask_ListenForSaveStartFinished::AdventureComponentSaveFinished() 35 | { 36 | OnSaveFinished.Broadcast(); 37 | } 38 | -------------------------------------------------------------------------------- /Source/AdventureTasks/Private/Nodes/AdventureTask_ListenObjectiveEntryChanges.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "Nodes/AdventureTask_ListenObjectiveEntryChanges.h" 5 | #include "AdventureAsset.h" 6 | 7 | void UAdventureTask_ListenObjectiveEntryChanges::ActivateTask() 8 | { 9 | Super::ActivateTask(); 10 | AdventureAsset->ObjectiveList.ObjectiveEntryUpdated.AddUObject(this, &UAdventureTask_ListenObjectiveEntryChanges::OnObjectiveEntryChanged); 11 | } 12 | 13 | UAdventureTask_ListenObjectiveEntryChanges* UAdventureTask_ListenObjectiveEntryChanges::ListenObjectiveEntryChanges(UAdventureAsset* Adventure) 14 | { 15 | if (IsValid(Adventure)) 16 | { 17 | UAdventureTask_ListenObjectiveEntryChanges* ListenObjectiveEntryChangesTask = NewObject(Adventure, StaticClass()); 18 | ListenObjectiveEntryChangesTask->AdventureAsset = Adventure; 19 | return ListenObjectiveEntryChangesTask; 20 | } 21 | 22 | return nullptr; 23 | } 24 | 25 | void UAdventureTask_ListenObjectiveEntryChanges::OnObjectiveEntryChanged(FAdventureObjectiveEntry Entry, int32 Index) 26 | { 27 | OnChanged.Broadcast(Entry, Index); 28 | } 29 | -------------------------------------------------------------------------------- /Source/AdventureTasks/Private/Nodes/AdventureTask_LoadChainedAdventures.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "Nodes/AdventureTask_LoadChainedAdventures.h" 5 | #include "AdventureAsset.h" 6 | 7 | void UAdventureTask_LoadChainedAdventures::ActivateTask() 8 | { 9 | Super::ActivateTask(); 10 | 11 | AdventureAsset->LoadChainedAdventures(FOnChainedAdventuresLoaded::CreateWeakLambda(this, [this](TArray> LoadedChainedAdventures) 12 | { 13 | OnLoaded.Broadcast(LoadedChainedAdventures); 14 | })); 15 | } 16 | 17 | UAdventureTask_LoadChainedAdventures* UAdventureTask_LoadChainedAdventures::LoadChainedAdventures(UAdventureAsset* Adventure) 18 | { 19 | if (IsValid(Adventure)) 20 | { 21 | UAdventureTask_LoadChainedAdventures* LoadChainedAdventures = NewObject(Adventure); 22 | LoadChainedAdventures->AdventureAsset = Adventure; 23 | return LoadChainedAdventures; 24 | } 25 | 26 | return nullptr; 27 | } 28 | -------------------------------------------------------------------------------- /Source/AdventureTasks/Public/AdventureTasksModule.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CoreMinimal.h" 4 | #include "Modules/ModuleManager.h" 5 | 6 | class FAdventureTasksModule : public IModuleInterface 7 | { 8 | public: 9 | virtual void StartupModule() override; 10 | virtual void ShutdownModule() override; 11 | }; 12 | -------------------------------------------------------------------------------- /Source/AdventureTasks/Public/Nodes/AdventureTask.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "AdventureTask.generated.h" 7 | 8 | //Base class for all UBlueprintAsyncActionBase like events. 9 | UCLASS(Abstract, BlueprintType, meta = (ExposedAsyncProxy=AdventureTask)) 10 | class ADVENTURETASKS_API UAdventureTask : public UObject 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | 16 | UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly) 17 | virtual void ActivateTask(); 18 | 19 | //Unregisters this async task and will get garbage collected 20 | UFUNCTION(BlueprintCallable) 21 | virtual void DeactivateTask(); 22 | 23 | protected: 24 | 25 | //Register the task so it doesn't get garbage collected 26 | virtual void RegisterTaskToGameInstance(); 27 | 28 | //Unregister this task 29 | virtual void UnRegisterTaskFromGameInstance(); 30 | 31 | protected: 32 | 33 | UPROPERTY() 34 | UGameInstance* OwningGameInstance; 35 | 36 | UPROPERTY() 37 | TWeakObjectPtr AdventureAsset; 38 | }; 39 | -------------------------------------------------------------------------------- /Source/AdventureTasks/Public/Nodes/AdventureTask_AddObjective.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "AdventureTask.h" 7 | #include "AdventureTask_ListenObjectiveEntryChanges.h" 8 | #include "AdventureTask_AddObjective.generated.h" 9 | 10 | UCLASS() 11 | class ADVENTURETASKS_API UAdventureTask_AddObjective : public UAdventureTask 12 | { 13 | GENERATED_BODY() 14 | 15 | protected: 16 | 17 | //UAdventureTask interface implementation 18 | virtual void ActivateTask() override; 19 | //End of implementation 20 | 21 | public: 22 | 23 | //Add a new objective or multiple objectives to the Adventure. 24 | UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly, Category = "Adventure Task | Objectives", meta =(WorldContext=AdventureContextObject)) 25 | static UAdventureTask_AddObjective* AddObjective(UObject* AdventureContextObject); 26 | 27 | //Just a template for the UK2Node_AddObjective 28 | UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly) 29 | void PopulateObjective(TArray NewObjectives); 30 | 31 | //Get the unique ID for this objective 32 | UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Adventure Task | Objectives", meta = (CompactNodeTitle=UniqueID)) 33 | int64 GetObjectiveUniqueID() 34 | { 35 | return ObjectiveUniqueID; 36 | } 37 | 38 | private: 39 | 40 | void ObjectiveStepCompleted(FAdventureObjectiveEntry CompletedStep); 41 | void ObjectiveConditionTagsUpdated(FAdventureObjectiveEntry UpdatedEntry, int32 Index); 42 | void ObjectiveCompleted(int64 ObjectiveUniqueID); 43 | 44 | bool IsMatchingID(FAdventureObjectiveEntry Entry) 45 | { 46 | return Entry.ObjectiveUniqueID == ObjectiveUniqueID; 47 | }; 48 | 49 | public: 50 | 51 | TArray NewObjectives; 52 | 53 | DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FK2OnObjectiveStepCompleted, FAdventureObjectiveEntry, ObjectiveStep); 54 | UPROPERTY(BlueprintAssignable) 55 | FK2OnObjectiveStepCompleted OnObjectiveStepCompleted; 56 | 57 | UPROPERTY(BlueprintAssignable) 58 | FK2OnObjectiveStepCompleted OnConditionTagsModified; 59 | 60 | DECLARE_DYNAMIC_MULTICAST_DELEGATE(FK2OnObjectiveListCompleted); 61 | UPROPERTY(BlueprintAssignable) 62 | FK2OnObjectiveListCompleted OnObjectiveListFinished; 63 | 64 | private: 65 | 66 | int64 ObjectiveUniqueID; 67 | 68 | }; 69 | -------------------------------------------------------------------------------- /Source/AdventureTasks/Public/Nodes/AdventureTask_ListenActiveAdventuresModified.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "AdventureTask.h" 7 | #include "AdventureComponent.h" 8 | #include "AdventureTask_ListenActiveAdventuresModified.generated.h" 9 | 10 | class UAdventureComponent; 11 | 12 | DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnActiveAdventuresModified, const TArray&, NewAdventure); 13 | 14 | UCLASS() 15 | class ADVENTURETASKS_API UAdventureTask_ListenActiveAdventuresModified : public UAdventureTask 16 | { 17 | GENERATED_BODY() 18 | 19 | public: 20 | 21 | //UAdventureTask interface implementation 22 | virtual void ActivateTask() override; 23 | //End of implementation 24 | 25 | //Listen for changes made to the Active Adventures array in Adventure Component. Can listen from both server and client. 26 | UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true"), Category = "Adventure | Tasks") 27 | static UAdventureTask_ListenActiveAdventuresModified* ListenForActiveAdventureChanges(AActor* AdventureComponentOwner); 28 | 29 | private: 30 | 31 | UFUNCTION() 32 | void OnActiveAdventuresModified(TArray ActiveAdventures); 33 | 34 | public: 35 | 36 | UPROPERTY(BlueprintAssignable) 37 | FOnActiveAdventuresModified OnChanged; 38 | 39 | private: 40 | 41 | UPROPERTY() 42 | TWeakObjectPtr AdventureComponent; 43 | 44 | }; 45 | -------------------------------------------------------------------------------- /Source/AdventureTasks/Public/Nodes/AdventureTask_ListenForAdventureState.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "AdventureTask.h" 7 | #include "AdventureAsset.h" 8 | #include "FAdventureGraphNodeMinimal.h" 9 | #include "AdventureTask_ListenForAdventureState.generated.h" 10 | 11 | DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnAdventureStateModified, TEnumAsByte, NewState); 12 | 13 | UCLASS() 14 | class ADVENTURETASKS_API UAdventureTask_ListenForAdventureState : public UAdventureTask 15 | { 16 | GENERATED_BODY() 17 | 18 | public: 19 | 20 | //UAdventureTask interface implementation 21 | virtual void ActivateTask() override; 22 | //End of implementation 23 | 24 | //Listen for changes made to the Adventure State enum in an Adventure. Can listen from both server and client. 25 | UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true", WorldContextObject = "AdventureAsset"), Category = "Adventure | Tasks") 26 | static UAdventureTask_ListenForAdventureState* ListenForAdventureStateChanges(UAdventureAsset* Adventure); 27 | 28 | private: 29 | 30 | UFUNCTION() 31 | void NewState(TEnumAsByte NewState); 32 | 33 | public: 34 | 35 | UPROPERTY(BlueprintAssignable) 36 | FOnAdventureStateModified OnStateChanged; 37 | }; 38 | -------------------------------------------------------------------------------- /Source/AdventureTasks/Public/Nodes/AdventureTask_ListenForLoadStartFinished.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "AdventureMacros.h" 7 | #include "AdventureTask.h" 8 | #include "AdventureTask_ListenForSaveStartFinished.h" 9 | #include "AdventureTask_ListenForLoadStartFinished.generated.h" 10 | 11 | class UAdventureComponent; 12 | 13 | UCLASS() 14 | class ADVENTURETASKS_API UAdventureTask_ListenForLoadStartFinished : public UAdventureTask 15 | { 16 | GENERATED_BODY() 17 | 18 | public: 19 | 20 | //UAdventureTask interface implementation 21 | virtual void ActivateTask() override; 22 | virtual void DeactivateTask() override; 23 | //End of implementation 24 | 25 | //Listen for changes made to the Adventure State enum in an Adventure. Can listen from both server and client. 26 | UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true"), Category = "Adventure | Tasks") 27 | static UAdventureTask_ListenForLoadStartFinished* ListenForLoadStartAndFinish(AActor* AdventureComponentOwner); 28 | 29 | void AdventureComponentPreLoad(); 30 | void AdventureComponentLoadFinished(); 31 | 32 | public: 33 | 34 | UPROPERTY() 35 | TWeakObjectPtr AdventureComponent; 36 | 37 | UPROPERTY(BlueprintAssignable) 38 | FSimpleDynamicMulticastDelegate OnPreLoad; 39 | 40 | UPROPERTY(BlueprintAssignable) 41 | FSimpleDynamicMulticastDelegate OnLoadFinished; 42 | 43 | FDelegateHandle PreLoadHandle; 44 | FDelegateHandle LoadFinishedHandle; 45 | }; 46 | -------------------------------------------------------------------------------- /Source/AdventureTasks/Public/Nodes/AdventureTask_ListenForSaveStartFinished.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "AdventureTask.h" 7 | #include "AdventureTask_ListenForSaveStartFinished.generated.h" 8 | 9 | class UAdventureComponent; 10 | 11 | DECLARE_DYNAMIC_MULTICAST_DELEGATE(FSimpleDynamicMulticastDelegate); 12 | 13 | UCLASS() 14 | class ADVENTURETASKS_API UAdventureTask_ListenForSaveStartFinished : public UAdventureTask 15 | { 16 | GENERATED_BODY() 17 | 18 | public: 19 | 20 | //UAdventureTask interface implementation 21 | virtual void ActivateTask() override; 22 | //End of implementation 23 | 24 | //Listen for changes made to the Adventure State enum in an Adventure. Can listen from both server and client. 25 | UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true"), Category = "Adventure | Tasks") 26 | static UAdventureTask_ListenForSaveStartFinished* ListenForSaveStartAndFinish(AActor* AdventureComponentOwner); 27 | 28 | void AdventureComponentPreSave(); 29 | void AdventureComponentSaveFinished(); 30 | 31 | public: 32 | 33 | UPROPERTY() 34 | TWeakObjectPtr AdventureComponent; 35 | 36 | UPROPERTY(BlueprintAssignable) 37 | FSimpleDynamicMulticastDelegate OnPreSave; 38 | 39 | UPROPERTY(BlueprintAssignable) 40 | FSimpleDynamicMulticastDelegate OnSaveFinished; 41 | }; 42 | -------------------------------------------------------------------------------- /Source/AdventureTasks/Public/Nodes/AdventureTask_ListenObjectiveEntryChanges.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "AdventureTask.h" 7 | #include "FAdventureGraphNodeMinimal.h" 8 | #include "AdventureTask_ListenObjectiveEntryChanges.generated.h" 9 | 10 | DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnObjectiveEntryChanged, FAdventureObjectiveEntry, ObjectiveEntry, int32, Index); 11 | 12 | UCLASS() 13 | class ADVENTURETASKS_API UAdventureTask_ListenObjectiveEntryChanges : public UAdventureTask 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | 19 | //UAdventureTask interface implementation 20 | virtual void ActivateTask() override; 21 | //End of implementation 22 | 23 | UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true"), DisplayName = "Listen For Objective Changes", Category = "Adventure | Tasks") 24 | static UAdventureTask_ListenObjectiveEntryChanges* ListenObjectiveEntryChanges(UAdventureAsset* Adventure); 25 | 26 | public: 27 | 28 | void OnObjectiveEntryChanged(FAdventureObjectiveEntry Entry, int32 Index); 29 | 30 | public: 31 | 32 | UPROPERTY(BlueprintAssignable) 33 | FOnObjectiveEntryChanged OnChanged; 34 | 35 | }; 36 | -------------------------------------------------------------------------------- /Source/AdventureTasks/Public/Nodes/AdventureTask_LoadChainedAdventures.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "AdventureTask.h" 7 | #include "AdventureTask_LoadChainedAdventures.generated.h" 8 | 9 | DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnLoaded, const TArray>&, LoadedChainedAdventures); 10 | 11 | class UAdventureAsset; 12 | 13 | UCLASS() 14 | class ADVENTURETASKS_API UAdventureTask_LoadChainedAdventures : public UAdventureTask 15 | { 16 | GENERATED_BODY() 17 | 18 | public: 19 | 20 | //UAdventureTask interface implementation 21 | virtual void ActivateTask() override; 22 | //End of implementation 23 | 24 | UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true", WorldContextObject = "AdventureAsset"), Category = "Adventure | Tasks") 25 | static UAdventureTask_LoadChainedAdventures* LoadChainedAdventures(UAdventureAsset* Adventure); 26 | 27 | public: 28 | 29 | UPROPERTY(BlueprintAssignable) 30 | FOnLoaded OnLoaded; 31 | }; 32 | -------------------------------------------------------------------------------- /Source/AdventureTasksEditor/AdventureTasksEditor.Build.cs: -------------------------------------------------------------------------------- 1 | using UnrealBuildTool; 2 | 3 | public class AdventureTasksEditor : ModuleRules 4 | { 5 | public AdventureTasksEditor(ReadOnlyTargetRules Target) : base(Target) 6 | { 7 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 8 | 9 | PublicDependencyModuleNames.AddRange( 10 | new string[] 11 | { 12 | "Core", 13 | "UnrealEd", 14 | } 15 | ); 16 | 17 | PrivateDependencyModuleNames.AddRange( 18 | new string[] 19 | { 20 | "CoreUObject", 21 | "Engine", 22 | "Slate", 23 | "SlateCore", 24 | "AdventureTasks", 25 | "Adventure", 26 | "GraphEditor", 27 | "BlueprintGraph", 28 | "AdventureGraphEditor", 29 | "ToolMenus", 30 | "KismetCompiler" 31 | } 32 | ); 33 | } 34 | } -------------------------------------------------------------------------------- /Source/AdventureTasksEditor/Private/AdventureTasksEditorModule.cpp: -------------------------------------------------------------------------------- 1 | #include "AdventureTasksEditorModule.h" 2 | 3 | #include "AdventureTasksNodes/K2Node_AddObjective.h" 4 | #include "AdventureTasksNodes/Slate/SGraphNode_AddObjective.h" 5 | 6 | #define LOCTEXT_NAMESPACE "FAdventureTasksEditorModule" 7 | 8 | class FGraphPanelNodeFactory_AdventureTasks final : public FGraphPanelNodeFactory 9 | { 10 | virtual TSharedPtr CreateNode(UEdGraphNode* Node) const override 11 | { 12 | if (UK2Node_AddObjective* BTNode = Cast(Node)) 13 | { 14 | return SNew(SGraphNode_AddObjective, BTNode); 15 | } 16 | 17 | return nullptr; 18 | } 19 | }; 20 | 21 | void FAdventureTasksEditorModule::StartupModule() 22 | { 23 | FEdGraphUtilities::RegisterVisualNodeFactory(MakeShareable(new FGraphPanelNodeFactory_AdventureTasks())); 24 | } 25 | 26 | void FAdventureTasksEditorModule::ShutdownModule() 27 | { 28 | 29 | } 30 | 31 | #undef LOCTEXT_NAMESPACE 32 | 33 | IMPLEMENT_MODULE(FAdventureTasksEditorModule, AdventureTasksEditor) -------------------------------------------------------------------------------- /Source/AdventureTasksEditor/Private/AdventureTasksNodes/K2Node_AddObjective.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "K2Node_AddPinInterface.h" 7 | #include "K2Node_BaseAsyncTask.h" 8 | #include "K2Node_LatentAdventureTaskCall.h" 9 | #include "K2Node_AddObjective.generated.h" 10 | 11 | UCLASS() 12 | class UK2Node_AddObjective : public UK2Node_LatentAdventureTaskCall, public IK2Node_AddPinInterface 13 | { 14 | GENERATED_BODY() 15 | 16 | public: 17 | 18 | UK2Node_AddObjective(const FObjectInitializer& ObjectInitializer); 19 | 20 | //UK2Node_LatentAdventureTaskCall interface implementation 21 | virtual bool IsHandling(TSubclassOf TaskClass) const override; 22 | //End of implementation 23 | 24 | //UK2Node interface implementation 25 | virtual void GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const override; 26 | virtual void ReallocatePinsDuringReconstruction(TArray& OldPins) override; 27 | virtual FSlateIcon GetIconAndTint(FLinearColor& OutColor) const override; 28 | virtual bool IsCompatibleWithGraph(UEdGraph const* Graph) const override; 29 | virtual void AllocateDefaultPins() override; 30 | virtual void GetNodeContextMenuActions(UToolMenu* Menu, UGraphNodeContextMenuContext* Context) const override; 31 | virtual void RemoveInputPin(UEdGraphPin* Pin) override; 32 | virtual void ExpandNode(FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph) override; 33 | //End of implementation 34 | 35 | //UK2Node_AddPinInterface implementation 36 | virtual void AddInputPin() override; 37 | virtual bool CanAddPin() const override; 38 | //End of implementation 39 | 40 | void AddInputPin_Internal(int32 Index); 41 | void ChangeInputMode(); 42 | bool CanRemoveInputPin(const UEdGraphPin* PinToRemove) const; 43 | FName GetPinName(int32 Index); 44 | void CreateObjectivesArray(); 45 | 46 | void SetUserCreatedPinsVisibility(bool IsVisible); 47 | void SetArrayInputVisibility(bool bVisible); 48 | void ResetToDefaultInput(); 49 | 50 | public: 51 | 52 | UPROPERTY() 53 | bool bUseArray = false; 54 | 55 | /** The number of additional input pins to generate for this node (2 base pins are not included) */ 56 | UPROPERTY() 57 | int32 NumAdditionalInputs; 58 | 59 | UPROPERTY() 60 | TArray UserCreatedObjectivePins; 61 | 62 | private: 63 | 64 | static const FName NAME_ObjectivesArray; 65 | }; -------------------------------------------------------------------------------- /Source/AdventureTasksEditor/Private/AdventureTasksNodes/K2Node_AppendObjective.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "K2Node_AppendObjective.h" 5 | #include "AdventureAsset.h" 6 | 7 | const FName UK2Node_AppendObjective::NAME_ObjectiveArray(TEXT("ObjectiveArray")); 8 | const FName UK2Node_AppendObjective::NAME_ObjectiveInfo(TEXT("ObjectiveEntry")); 9 | 10 | UK2Node_AppendObjective::UK2Node_AppendObjective() 11 | { 12 | FunctionReference.SetFromField(UAdventureAsset::StaticClass()->FindFunctionByName(GET_FUNCTION_NAME_CHECKED(UAdventureAsset, MakeObjectiveArray)), true); 13 | } 14 | 15 | UEdGraphPin* UK2Node_AppendObjective::GetObjectiveArrayPin() 16 | { 17 | return FindPin(NAME_ObjectiveArray); 18 | } 19 | 20 | UEdGraphPin* UK2Node_AppendObjective::GetObjectivePin() 21 | { 22 | return FindPin(NAME_ObjectiveInfo); 23 | } 24 | -------------------------------------------------------------------------------- /Source/AdventureTasksEditor/Private/AdventureTasksNodes/K2Node_AppendObjective.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "K2Node_CallFunction.h" 7 | #include "K2Node_AppendObjective.generated.h" 8 | 9 | 10 | UCLASS() 11 | class UK2Node_AppendObjective : public UK2Node_CallFunction 12 | { 13 | GENERATED_BODY() 14 | 15 | public: 16 | 17 | UK2Node_AppendObjective(); 18 | 19 | UEdGraphPin* GetObjectiveArrayPin(); 20 | UEdGraphPin* GetObjectivePin(); 21 | 22 | private: 23 | 24 | static const FName NAME_ObjectiveArray; 25 | static const FName NAME_ObjectiveInfo; 26 | 27 | }; 28 | -------------------------------------------------------------------------------- /Source/AdventureTasksEditor/Private/AdventureTasksNodes/K2Node_LatentAdventureTaskCall.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "K2Node_LatentAdventureTaskCall.h" 5 | #include "BlueprintActionDatabaseRegistrar.h" 6 | #include "BlueprintFunctionNodeSpawner.h" 7 | #include "BlueprintNodeSpawner.h" 8 | #include "AdventureTasks/Public/Nodes/AdventureTask.h" 9 | #include "BlueprintAssets/AdventureAssetBlueprint.h" 10 | #include "Kismet2/BlueprintEditorUtils.h" 11 | 12 | #define LOCTEXT_NAMESPACE "K2Node_LatentAdventureTaskCall" 13 | 14 | TArray > UK2Node_LatentAdventureTaskCall::NodeClasses; 15 | 16 | UK2Node_LatentAdventureTaskCall::UK2Node_LatentAdventureTaskCall(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) 17 | { 18 | ProxyActivateFunctionName = GET_FUNCTION_NAME_CHECKED(UAdventureTask, ActivateTask); 19 | } 20 | 21 | void UK2Node_LatentAdventureTaskCall::GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const 22 | { 23 | struct GetMenuActions_Utils 24 | { 25 | static void SetNodeFunc(UEdGraphNode* NewNode, bool /*bIsTemplateNode*/, TWeakObjectPtr FunctionPtr) 26 | { 27 | UK2Node_LatentAdventureTaskCall* AsyncTaskNode = CastChecked(NewNode); 28 | if (FunctionPtr.IsValid()) 29 | { 30 | UFunction* Func = FunctionPtr.Get(); 31 | FObjectProperty* ReturnProp = CastFieldChecked(Func->GetReturnProperty()); 32 | 33 | AsyncTaskNode->ProxyFactoryFunctionName = Func->GetFName(); 34 | AsyncTaskNode->ProxyFactoryClass = Func->GetOuterUClass(); 35 | AsyncTaskNode->ProxyClass = ReturnProp->PropertyClass; 36 | } 37 | } 38 | }; 39 | 40 | UClass* NodeClass = GetClass(); 41 | ActionRegistrar.RegisterClassFactoryActions( FBlueprintActionDatabaseRegistrar::FMakeFuncSpawnerDelegate::CreateLambda([NodeClass](const UFunction* FactoryFunc)->UBlueprintNodeSpawner* 42 | { 43 | UBlueprintNodeSpawner* NodeSpawner = nullptr; 44 | UClass* FuncClass = FactoryFunc->GetOwnerClass(); 45 | if (!UK2Node_LatentAdventureTaskCall::HasDedicatedNodeClass(FuncClass)) 46 | { 47 | NodeSpawner = UBlueprintFunctionNodeSpawner::Create(FactoryFunc); 48 | check(NodeSpawner != nullptr); 49 | NodeSpawner->NodeClass = NodeClass; 50 | 51 | TWeakObjectPtr FunctionPtr = MakeWeakObjectPtr(const_cast(FactoryFunc)); 52 | NodeSpawner->CustomizeNodeDelegate = UBlueprintNodeSpawner::FCustomizeNodeDelegate::CreateStatic(GetMenuActions_Utils::SetNodeFunc, FunctionPtr); 53 | } 54 | return NodeSpawner; 55 | }) ); 56 | } 57 | 58 | void UK2Node_LatentAdventureTaskCall::RegisterSpecializedTaskNodeClass(TSubclassOf NodeClass) 59 | { 60 | if (NodeClass) 61 | { 62 | NodeClasses.AddUnique(*NodeClass); 63 | } 64 | } 65 | 66 | bool UK2Node_LatentAdventureTaskCall::HasDedicatedNodeClass(TSubclassOf TaskClass) 67 | { 68 | for (const TWeakObjectPtr& NodeClass : NodeClasses) 69 | { 70 | if (NodeClass.IsValid()) 71 | { 72 | UK2Node_LatentAdventureTaskCall* NodeCDO = NodeClass->GetDefaultObject(); 73 | if (NodeCDO && NodeCDO->IsHandling(TaskClass)) 74 | { 75 | return true; 76 | } 77 | } 78 | } 79 | return false; 80 | } 81 | 82 | #undef LOCTEXT_NAMESPACE 83 | -------------------------------------------------------------------------------- /Source/AdventureTasksEditor/Private/AdventureTasksNodes/K2Node_LatentAdventureTaskCall.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "K2Node_BaseAsyncTask.h" 7 | #include "K2Node_LatentAdventureTaskCall.generated.h" 8 | 9 | class UAdventureTask; 10 | UCLASS() 11 | class ADVENTURETASKSEDITOR_API UK2Node_LatentAdventureTaskCall : public UK2Node_BaseAsyncTask 12 | { 13 | GENERATED_BODY() 14 | 15 | public: 16 | 17 | UK2Node_LatentAdventureTaskCall(const FObjectInitializer& ObjectInitializer); 18 | 19 | // UEdGraphNode interface 20 | virtual void GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const override; 21 | // End of UEdGraphNode interface 22 | 23 | public: 24 | 25 | static void RegisterSpecializedTaskNodeClass(TSubclassOf NodeClass); 26 | 27 | protected: 28 | 29 | static bool HasDedicatedNodeClass(TSubclassOf TaskClass); 30 | virtual bool IsHandling(TSubclassOf TaskClass) const { return true; } 31 | 32 | private: 33 | 34 | static TArray> NodeClasses; 35 | }; 36 | -------------------------------------------------------------------------------- /Source/AdventureTasksEditor/Private/AdventureTasksNodes/Slate/SGraphNode_AddObjective.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "SGraphNode_AddObjective.h" 5 | #include "GraphEditorSettings.h" 6 | #include "K2Node.h" 7 | #include "K2Node_AddPinInterface.h" 8 | #include "ScopedTransaction.h" 9 | #include "AdventureTasksNodes/K2Node_AddObjective.h" 10 | 11 | #define LOCTEXT_NAMESPACE "SGraphNode_CreateObjective" 12 | 13 | void SGraphNode_AddObjective::Construct(const FArguments& InArgs, UK2Node* InNode) 14 | { 15 | ensure(InNode == nullptr || InNode->GetClass()->ImplementsInterface(UK2Node_AddPinInterface::StaticClass())); 16 | GraphNode = InNode; 17 | SetCursor( EMouseCursor::CardinalCross ); 18 | UpdateGraphNode(); 19 | } 20 | 21 | FText SGraphNode_AddObjective::GetInputModeButtonText() 22 | { 23 | if (GetOwningNode()->bUseArray) 24 | { 25 | return LOCTEXT("SGraphNode_CreateObjective_RestoreDefault", "Restore To Default Input"); 26 | } 27 | return LOCTEXT("SGraphNode_CreateObjective_SwitchArray", "Convert To Array Input"); 28 | } 29 | 30 | UK2Node_AddObjective* SGraphNode_AddObjective::GetOwningNode() 31 | { 32 | return CastChecked(GraphNode); 33 | } 34 | 35 | void SGraphNode_AddObjective::CreateOutputSideAddButton(TSharedPtr OutputBox) 36 | { 37 | TSharedRef AddPinButton = AddPinButtonContent( 38 | NSLOCTEXT("SequencerNode", "SGraphNode_CreateObjective_AddPinButtonText", "Add Objective Pin"), 39 | NSLOCTEXT("SequencerNode", "SGraphNode_CreateObjective_AddPinButtonToolTip", "Add new objective")); 40 | 41 | FMargin AddPinPadding = Settings->GetOutputPinPadding(); 42 | AddPinPadding.Top += 6.0f; 43 | 44 | OutputBox->AddSlot() 45 | .AutoHeight() 46 | .VAlign(VAlign_Center) 47 | .HAlign(HAlign_Right) 48 | .Padding(AddPinPadding) 49 | [ 50 | AddPinButton 51 | ]; 52 | 53 | AddPinButton->SetVisibility(GetOwningNode()->bUseArray ? EVisibility::Collapsed : EVisibility::Visible); 54 | } 55 | 56 | FReply SGraphNode_AddObjective::OnAddPin() 57 | { 58 | IK2Node_AddPinInterface* AddPinNode = Cast(GraphNode); 59 | ensure(AddPinNode); 60 | if (AddPinNode && AddPinNode->CanAddPin()) 61 | { 62 | FScopedTransaction Transaction(NSLOCTEXT("SequencerNode", "AddPinTransaction", "Add Pin")); 63 | 64 | AddPinNode->AddInputPin(); 65 | UpdateGraphNode(); 66 | GraphNode->GetGraph()->NotifyGraphChanged(); 67 | } 68 | 69 | return FReply::Handled(); 70 | } 71 | 72 | EVisibility SGraphNode_AddObjective::IsAddPinButtonVisible() const 73 | { 74 | return EVisibility::Visible; 75 | } 76 | 77 | #undef LOCTEXT_NAMESPACE 78 | -------------------------------------------------------------------------------- /Source/AdventureTasksEditor/Private/AdventureTasksNodes/Slate/SGraphNode_AddObjective.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "KismetNodes/SGraphNodeK2Base.h" 7 | 8 | class UK2Node; 9 | 10 | class SGraphNode_AddObjective : public SGraphNodeK2Base 11 | { 12 | public: 13 | SLATE_BEGIN_ARGS(SGraphNode_AddObjective){} 14 | SLATE_END_ARGS() 15 | 16 | void Construct( const FArguments& InArgs, UK2Node* InNode ); 17 | 18 | FText GetInputModeButtonText(); 19 | 20 | //Gets the construct adventure objective node 21 | class UK2Node_AddObjective* GetOwningNode(); 22 | 23 | protected: 24 | 25 | // SGraphNode interface 26 | virtual void CreateOutputSideAddButton(TSharedPtr OutputBox) override; 27 | virtual FReply OnAddPin() override; 28 | virtual EVisibility IsAddPinButtonVisible() const override; 29 | // End of SGraphNode interface 30 | 31 | }; 32 | -------------------------------------------------------------------------------- /Source/AdventureTasksEditor/Public/AdventureTasksEditorModule.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CoreMinimal.h" 4 | #include "EdGraphUtilities.h" 5 | #include "Modules/ModuleManager.h" 6 | 7 | class FAdventureTasksEditorModule : public IModuleInterface 8 | { 9 | public: 10 | virtual void StartupModule() override; 11 | virtual void ShutdownModule() override; 12 | }; 13 | --------------------------------------------------------------------------------