├── .gitignore ├── CheatSheet.uplugin ├── Config └── FilterPlugin.ini ├── Content ├── Fonts │ ├── Titillium-Regular.uasset │ └── Titillium-Regular_Font.uasset └── UI │ ├── Entries │ ├── UI_CS_CategoryEntry.uasset │ └── UI_CS_CheatEntry.uasset │ ├── Textures │ ├── T_CheatSheetIcon.uasset │ ├── T_CheatSheet_CategoryIcon.uasset │ ├── T_CheatSheet_GeneralIcon.uasset │ └── T_CheatSheet_TipIcon.uasset │ ├── Tips │ ├── UI_CheatSheet_ControlTip.uasset │ └── UI_CheatSheet_CurrentTooltip.uasset │ ├── UI_CS_CheatCategory.uasset │ ├── UI_CS_CheatView.uasset │ └── UI_CS_HomeScreen.uasset ├── LICENSE ├── Resources ├── BuilderIcon64.png ├── Icon128.png ├── Icon64.png └── Titillium-Regular.otf └── Source ├── CheatSheet ├── CheatSheet.Build.cs ├── Private │ └── CheatSheet.cpp └── Public │ ├── CheatSheet.h │ ├── CheatSheetInterface.h │ └── Settings │ └── CheatSheetSettings.h ├── CheatSheetEditor ├── CheatSheetEditor.Build.cs ├── Private │ ├── Actions │ │ ├── CachedCheatAssetActions.cpp │ │ └── CachedCheatBuilderActions.cpp │ ├── CheatSheetEditor.cpp │ └── Factories │ │ ├── CachedCheatBuilderFactory.cpp │ │ └── CachedCheatFactory.cpp └── Public │ ├── Actions │ ├── CachedCheatAssetActions.h │ └── CachedCheatBuilderActions.h │ ├── CheatSheetEditor.h │ └── Factories │ ├── CachedCheatBuilderFactory.h │ └── CachedCheatFactory.h ├── CheatSheetTypes ├── CheatSheetTypes.Build.cs ├── Private │ └── Categories │ │ ├── CheatCategory.cpp │ │ └── CheatMap.cpp └── Public │ ├── Categories │ ├── CachedCheat.h │ ├── CachedCheatAsset.h │ ├── CachedCheatBuilder.h │ ├── CheatCategory.h │ └── CheatMap.h │ └── CheatSheetTypes.cpp └── CheatSheetUI ├── CheatSheetUI.Build.cs ├── Private ├── CheatSheetUI.cpp └── UI │ ├── Entries │ ├── UI_CategoryEntry.cpp │ └── UI_CheatEntry.cpp │ ├── Tips │ ├── UI_ControlTip.cpp │ └── UI_CurrentTooltip.cpp │ ├── UI_CheatCategory.cpp │ ├── UI_CheatSheetHome.cpp │ └── UI_CheatView.cpp └── Public ├── CheatSheetUI.h └── UI ├── CheatEntryInterface.h ├── Entries ├── UI_CategoryEntry.h ├── UI_CheatEntry.h └── UI_CheatEntryBase.h ├── Tips ├── UI_ControlTip.h └── UI_CurrentTooltip.h ├── UI_CheatCategory.h ├── UI_CheatSheetHome.h └── UI_CheatView.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 | -------------------------------------------------------------------------------- /CheatSheet.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "Version": 1, 4 | "VersionName": "1.0", 5 | "FriendlyName": "CheatSheet", 6 | "Description": "Plugin to provide runtime access to all cheats in the Cheat Manager", 7 | "Category": "Other", 8 | "CreatedBy": "Tom Shinton", 9 | "CreatedByURL": "tomshinton.wordpress.com", 10 | "DocsURL": "", 11 | "MarketplaceURL": "", 12 | "SupportURL": "", 13 | "CanContainContent": true, 14 | "IsBetaVersion": true, 15 | "Installed": false, 16 | "Modules": [ 17 | { 18 | "Name": "CheatSheet", 19 | "Type": "Runtime", 20 | "LoadingPhase": "Default", 21 | "WhitelistPlatforms": [ 22 | "Win64", 23 | "Win32" 24 | ] 25 | }, 26 | { 27 | "Name": "CheatSheetUI", 28 | "Type": "Runtime", 29 | "LoadingPhase": "Default", 30 | "WhitelistPlatforms": [ 31 | "Win64", 32 | "Win32" 33 | ] 34 | }, 35 | { 36 | "Name": "CheatSheetTypes", 37 | "Type": "Runtime", 38 | "LoadingPhase": "Default", 39 | "WhitelistPlatforms": [ 40 | "Win64", 41 | "Win32" 42 | ] 43 | }, 44 | { 45 | "Name": "CheatSheetEditor", 46 | "Type": "Editor", 47 | "LoadingPhase": "PostEngineInit", 48 | "WhitelistPlatforms": [ 49 | "Win64", 50 | "Win32" 51 | ] 52 | } 53 | ] 54 | } -------------------------------------------------------------------------------- /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/Fonts/Titillium-Regular.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomshinton/CheatSheetPlugin/2d2f8d7b7b6370a2815315c0bb21c613a915ee39/Content/Fonts/Titillium-Regular.uasset -------------------------------------------------------------------------------- /Content/Fonts/Titillium-Regular_Font.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomshinton/CheatSheetPlugin/2d2f8d7b7b6370a2815315c0bb21c613a915ee39/Content/Fonts/Titillium-Regular_Font.uasset -------------------------------------------------------------------------------- /Content/UI/Entries/UI_CS_CategoryEntry.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomshinton/CheatSheetPlugin/2d2f8d7b7b6370a2815315c0bb21c613a915ee39/Content/UI/Entries/UI_CS_CategoryEntry.uasset -------------------------------------------------------------------------------- /Content/UI/Entries/UI_CS_CheatEntry.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomshinton/CheatSheetPlugin/2d2f8d7b7b6370a2815315c0bb21c613a915ee39/Content/UI/Entries/UI_CS_CheatEntry.uasset -------------------------------------------------------------------------------- /Content/UI/Textures/T_CheatSheetIcon.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomshinton/CheatSheetPlugin/2d2f8d7b7b6370a2815315c0bb21c613a915ee39/Content/UI/Textures/T_CheatSheetIcon.uasset -------------------------------------------------------------------------------- /Content/UI/Textures/T_CheatSheet_CategoryIcon.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomshinton/CheatSheetPlugin/2d2f8d7b7b6370a2815315c0bb21c613a915ee39/Content/UI/Textures/T_CheatSheet_CategoryIcon.uasset -------------------------------------------------------------------------------- /Content/UI/Textures/T_CheatSheet_GeneralIcon.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomshinton/CheatSheetPlugin/2d2f8d7b7b6370a2815315c0bb21c613a915ee39/Content/UI/Textures/T_CheatSheet_GeneralIcon.uasset -------------------------------------------------------------------------------- /Content/UI/Textures/T_CheatSheet_TipIcon.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomshinton/CheatSheetPlugin/2d2f8d7b7b6370a2815315c0bb21c613a915ee39/Content/UI/Textures/T_CheatSheet_TipIcon.uasset -------------------------------------------------------------------------------- /Content/UI/Tips/UI_CheatSheet_ControlTip.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomshinton/CheatSheetPlugin/2d2f8d7b7b6370a2815315c0bb21c613a915ee39/Content/UI/Tips/UI_CheatSheet_ControlTip.uasset -------------------------------------------------------------------------------- /Content/UI/Tips/UI_CheatSheet_CurrentTooltip.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomshinton/CheatSheetPlugin/2d2f8d7b7b6370a2815315c0bb21c613a915ee39/Content/UI/Tips/UI_CheatSheet_CurrentTooltip.uasset -------------------------------------------------------------------------------- /Content/UI/UI_CS_CheatCategory.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomshinton/CheatSheetPlugin/2d2f8d7b7b6370a2815315c0bb21c613a915ee39/Content/UI/UI_CS_CheatCategory.uasset -------------------------------------------------------------------------------- /Content/UI/UI_CS_CheatView.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomshinton/CheatSheetPlugin/2d2f8d7b7b6370a2815315c0bb21c613a915ee39/Content/UI/UI_CS_CheatView.uasset -------------------------------------------------------------------------------- /Content/UI/UI_CS_HomeScreen.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomshinton/CheatSheetPlugin/2d2f8d7b7b6370a2815315c0bb21c613a915ee39/Content/UI/UI_CS_HomeScreen.uasset -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Tom Shinton 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 | -------------------------------------------------------------------------------- /Resources/BuilderIcon64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomshinton/CheatSheetPlugin/2d2f8d7b7b6370a2815315c0bb21c613a915ee39/Resources/BuilderIcon64.png -------------------------------------------------------------------------------- /Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomshinton/CheatSheetPlugin/2d2f8d7b7b6370a2815315c0bb21c613a915ee39/Resources/Icon128.png -------------------------------------------------------------------------------- /Resources/Icon64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomshinton/CheatSheetPlugin/2d2f8d7b7b6370a2815315c0bb21c613a915ee39/Resources/Icon64.png -------------------------------------------------------------------------------- /Resources/Titillium-Regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomshinton/CheatSheetPlugin/2d2f8d7b7b6370a2815315c0bb21c613a915ee39/Resources/Titillium-Regular.otf -------------------------------------------------------------------------------- /Source/CheatSheet/CheatSheet.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class CheatSheet : ModuleRules 6 | { 7 | public CheatSheet(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 10 | 11 | PrivateDependencyModuleNames.AddRange( 12 | new string[] 13 | { 14 | "Core", 15 | "CoreUObject", 16 | "Engine", 17 | "InputCore", 18 | "UMG", 19 | "DeveloperSettings", 20 | "CheatSheetTypes", 21 | "CheatSheetUI" 22 | }); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Source/CheatSheet/Private/CheatSheet.cpp: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #include "CheatSheet/Public/CheatSheet.h" 4 | #include "CheatSheet/Public/Settings/CheatSheetSettings.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #define LOCTEXT_NAMESPACE "FCheatSheetModule" 19 | 20 | DEFINE_LOG_CATEGORY_STATIC(CheatSheetLog, Log, Log); 21 | 22 | FCheatSheetModule::FCheatSheetModule() 23 | : CachedSettings(GetMutableDefault()) 24 | , HomeScreen(nullptr) 25 | , WeakPlayerController(nullptr) 26 | , WeakCheatManager(nullptr) 27 | , IsHomeScreenVisible(false) 28 | , Map() 29 | , OnCheatMapBuilt() 30 | , WeakInputComponent(nullptr) 31 | {} 32 | 33 | void FCheatSheetModule::StartupModule() 34 | { 35 | UE_LOG(CheatSheetLog, Log, TEXT("Spinning up CheatSheet")); 36 | 37 | FGameModeEvents::OnGameModePostLoginEvent().AddLambda([this](AGameModeBase* InGameMode, APlayerController* InNewPlayer) 38 | { 39 | CachedSettings = GetMutableDefault(); 40 | WeakCheatManager = InNewPlayer->CheatManager; 41 | WeakPlayerController = InNewPlayer; 42 | 43 | SetupBindings(*InNewPlayer); 44 | }); 45 | 46 | FWorldDelegates::OnWorldCleanup.AddRaw(this, &FCheatSheetModule::Cleanup); 47 | } 48 | 49 | void FCheatSheetModule::ShutdownModule() 50 | { 51 | UE_LOG(CheatSheetLog, Log, TEXT("Shutting down CheatSheet")); 52 | 53 | Cleanup(nullptr, false, false); 54 | } 55 | 56 | void FCheatSheetModule::AddReferencedObjects(FReferenceCollector& Collector) 57 | { 58 | Collector.AddReferencedObject(CachedSettings); 59 | Collector.AddReferencedObject(HomeScreen); 60 | } 61 | 62 | void FCheatSheetModule::Cleanup(UWorld* InWorld, bool bSessionEnded, bool bCleanupResources) 63 | { 64 | WeakPlayerController = nullptr; 65 | CachedSettings = nullptr; 66 | IsHomeScreenVisible = false; 67 | } 68 | 69 | void FCheatSheetModule::CreateUI() 70 | { 71 | if(TSubclassOf HomeScreenClass = CachedSettings->CheatSheetMenu) 72 | { 73 | HomeScreen = CreateWidget(WeakPlayerController.Get(), HomeScreenClass); 74 | OnCheatMapBuilt.AddUObject(HomeScreen, &UUI_CheatSheetHome::AddMap); 75 | 76 | RebuildCheatMap(); 77 | } 78 | } 79 | 80 | void FCheatSheetModule::SetupBindings(APlayerController& InPlayerController) 81 | { 82 | UInputComponent* NewInputComponent = NewObject(&InPlayerController); 83 | WeakInputComponent = NewInputComponent; 84 | 85 | const TArray Bindings = CachedSettings->GetShowBinding(); 86 | for(const FInputActionKeyMapping& Binding : Bindings) 87 | { 88 | UPlayerInput::AddEngineDefinedActionMapping(Binding); 89 | } 90 | 91 | FInputActionBinding ShowMenuAB(CheatSheetBindingNames::ShowBinding, IE_Pressed); 92 | ShowMenuAB.ActionDelegate.GetDelegateForManualSet().BindRaw(this, &FCheatSheetModule::ToggleListUI); 93 | NewInputComponent->AddActionBinding(ShowMenuAB); 94 | 95 | NewInputComponent->RegisterComponent(); 96 | InPlayerController.PushInputComponent(NewInputComponent); 97 | } 98 | 99 | void FCheatSheetModule::SetupUINavigation() 100 | { 101 | if (UInputComponent* StrongInputComponent = WeakInputComponent.Get()) 102 | { 103 | TArray Bindings; 104 | Bindings.Append(CachedSettings->GetConfirmBinding()); 105 | Bindings.Append(CachedSettings->GetUpBinding()); 106 | Bindings.Append(CachedSettings->GetDownBinding()); 107 | Bindings.Append(CachedSettings->GetBackBinding()); 108 | 109 | for(const FInputActionKeyMapping& Binding : Bindings) 110 | { 111 | UPlayerInput::AddEngineDefinedActionMapping(Binding); 112 | } 113 | 114 | //Up 115 | FInputActionBinding UpAB(CheatSheetBindingNames::UpBinding, IE_Pressed); 116 | UpAB.ActionDelegate.GetDelegateForManualSet().BindUObject(HomeScreen->GetCheatView(), &UUI_CheatView::UpSelection); 117 | StrongInputComponent->AddActionBinding(UpAB); 118 | 119 | //Confirm 120 | FInputActionBinding ConfirmAB(CheatSheetBindingNames::ConfirmBinding, IE_Pressed); 121 | ConfirmAB.ActionDelegate.GetDelegateForManualSet().BindUObject(HomeScreen->GetCheatView(), &UUI_CheatView::ConfirmSelection); 122 | StrongInputComponent->AddActionBinding(ConfirmAB); 123 | 124 | //Down 125 | FInputActionBinding DownAB(CheatSheetBindingNames::DownBinding, IE_Pressed); 126 | DownAB.ActionDelegate.GetDelegateForManualSet().BindUObject(HomeScreen->GetCheatView(), &UUI_CheatView::DownSelection); 127 | StrongInputComponent->AddActionBinding(DownAB); 128 | 129 | //Back 130 | FInputActionBinding BackAB(CheatSheetBindingNames::BackBinding, IE_Pressed); 131 | BackAB.ActionDelegate.GetDelegateForManualSet().BindUObject(HomeScreen, &UUI_CheatSheetHome::ShowPreviousCategory); 132 | StrongInputComponent->AddActionBinding(BackAB); 133 | } 134 | } 135 | 136 | void FCheatSheetModule::UnbindUINavigation() 137 | { 138 | if (UInputComponent* StrongInputComponent = WeakInputComponent.Get()) 139 | { 140 | StrongInputComponent->RemoveActionBinding(CheatSheetBindingNames::UpBinding, IE_Pressed); 141 | StrongInputComponent->RemoveActionBinding(CheatSheetBindingNames::ConfirmBinding, IE_Pressed); 142 | StrongInputComponent->RemoveActionBinding(CheatSheetBindingNames::DownBinding, IE_Pressed); 143 | StrongInputComponent->RemoveActionBinding(CheatSheetBindingNames::BackBinding, IE_Pressed); 144 | } 145 | } 146 | 147 | void FCheatSheetModule::RebuildCheatMap() 148 | { 149 | Map.Reset(); 150 | 151 | //Parse CheatManager, if possible 152 | if (WeakCheatManager.IsValid()) 153 | { 154 | UE_LOG(CheatSheetLog, Log, TEXT("Building CheatSheet from %s"), *WeakCheatManager->GetName()); 155 | 156 | for (TFieldIterator Itr(WeakCheatManager->GetClass(), EFieldIteratorFlags::IncludeSuper); Itr; ++Itr) 157 | { 158 | if (UFunction* Function = *Itr) 159 | { 160 | if ((Function->FunctionFlags & FUNC_Exec) && (Function->NumParms == 0)) 161 | { 162 | Map.AddCheat(FCachedCheat( 163 | *Function->GetName(), 164 | *Function->GetName(), 165 | Function->GetMetaData(TEXT("Category")), 166 | Function->GetMetaData(TEXT("Tooltip")), 167 | Function, 168 | true)); 169 | } 170 | } 171 | } 172 | } 173 | 174 | FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked("AssetRegistry"); 175 | IAssetRegistry& AssetRegistry = AssetRegistryModule.Get(); 176 | 177 | //Find Cheat Assets 178 | { 179 | TArray CheatAssets; 180 | const UClass* CachedCheatClass = UCachedCheatAsset::StaticClass(); 181 | AssetRegistry.GetAssetsByClass(CachedCheatClass->GetFName(), CheatAssets); 182 | 183 | if(CheatAssets.Num() > 0) 184 | { 185 | UE_LOG(CheatSheetLog, Log, TEXT("Autodiscovered %i additional CheatSheets"), CheatAssets.Num()); 186 | } 187 | 188 | for (const FAssetData& Asset : CheatAssets) 189 | { 190 | if (UCachedCheatAsset* CheatAsset = Cast(Asset.GetAsset())) 191 | { 192 | UE_LOG(CheatSheetLog, Log, TEXT("Autodiscovered CheatAssets: %s"), *CheatAsset->CheatString); 193 | Map.AddCheat(CheatAsset->GetCheat()); 194 | } 195 | } 196 | } 197 | 198 | //Find Cheat Builder Assets 199 | { 200 | TSet< FName > DerivedNames; 201 | { 202 | TArray BaseNames; 203 | BaseNames.Add("CachedCheatBuilder"); 204 | TSet Excluded; 205 | AssetRegistry.GetDerivedClassNames(BaseNames, Excluded, DerivedNames); 206 | } 207 | 208 | FARFilter Filter; 209 | Filter.ClassNames.Add(UBlueprint::StaticClass()->GetFName()); 210 | 211 | Filter.bRecursiveClasses = true; 212 | Filter.bRecursivePaths = true; 213 | 214 | TArray< FAssetData > AssetList; 215 | AssetRegistry.GetAssets(Filter, AssetList); 216 | for(const FAssetData& Asset : AssetList) 217 | { 218 | const FAssetTagValueRef Tag = Asset.TagsAndValues.FindTag(TEXT("GeneratedClass")); 219 | if(Tag.IsSet()) 220 | { 221 | const FString ClassObjectPath = FPackageName::ExportTextPathToObjectPath(*Tag.AsString()); 222 | const FString ClassName = FPackageName::ObjectPathToObjectName(ClassObjectPath); 223 | 224 | if(DerivedNames.Contains(*ClassName)) 225 | { 226 | if (UBlueprint* CheatAsset = Cast(Asset.GetAsset())) 227 | { 228 | if (UCachedCheatBuilder* CheatAssetCDO = Cast(CheatAsset->GeneratedClass->GetDefaultObject())) 229 | { 230 | const TArray GeneratedCheats = CheatAssetCDO->Generate(); 231 | for (const FString& GeneratedCheat : GeneratedCheats) 232 | { 233 | Map.AddCheat(FCachedCheat( 234 | GeneratedCheat, 235 | GeneratedCheat, 236 | CheatAssetCDO->Categories, 237 | CheatAssetCDO->Tooltip, 238 | nullptr, 239 | CheatAssetCDO->ShouldCloseAfterExecution)); 240 | } 241 | } 242 | } 243 | } 244 | } 245 | } 246 | } 247 | 248 | //Find Native Cheat Builders 249 | { 250 | for (TObjectIterator ClassIt; ClassIt; ++ClassIt) 251 | { 252 | if (UClass* Class = *ClassIt) 253 | { 254 | if (Class->IsNative() && Class->IsChildOf(UCachedCheatBuilder::StaticClass())) 255 | { 256 | UObject* CDO = Class->GetDefaultObject(); 257 | if (UCachedCheatBuilder* Builder = Cast(CDO)) 258 | { 259 | const TArray GeneratedCheats = Builder->Generate(); 260 | for (const FString& GeneratedCheat : GeneratedCheats) 261 | { 262 | Map.AddCheat(FCachedCheat( 263 | GeneratedCheat, 264 | GeneratedCheat, 265 | Builder->Categories, 266 | Builder->Tooltip, 267 | nullptr, 268 | Builder->ShouldCloseAfterExecution)); 269 | } 270 | } 271 | } 272 | } 273 | } 274 | } 275 | 276 | Map.Sort(); 277 | OnCheatMapBuilt.Broadcast(Map); 278 | } 279 | 280 | void FCheatSheetModule::ToggleListUI() 281 | { 282 | if (UInputComponent* StrongInputComponent = WeakInputComponent.Get()) 283 | { 284 | if (IsHomeScreenVisible) 285 | { 286 | UnbindUINavigation(); 287 | HideList(); 288 | 289 | if(UWorld* World = GWorld) 290 | { 291 | World->GetTimerManager().SetTimerForNextTick(FTimerDelegate::CreateLambda([WeakInputComponent = WeakInputComponent]() 292 | { 293 | if (UInputComponent* StrongInputComponent = WeakInputComponent.Get()) 294 | { 295 | StrongInputComponent->bBlockInput = false; 296 | } 297 | })); 298 | } 299 | } 300 | else 301 | { 302 | StrongInputComponent->bBlockInput = true; 303 | 304 | CreateUI(); 305 | SetupUINavigation(); 306 | ShowList(); 307 | } 308 | } 309 | } 310 | 311 | void FCheatSheetModule::ShowList() 312 | { 313 | HomeScreen->AddToViewport(100); 314 | HomeScreen->InitHomeView(); 315 | IsHomeScreenVisible = true; 316 | } 317 | 318 | void FCheatSheetModule::HideList() 319 | { 320 | HomeScreen->RemoveFromViewport(); 321 | IsHomeScreenVisible = false; 322 | } 323 | 324 | #undef LOCTEXT_NAMESPACE 325 | 326 | IMPLEMENT_MODULE(FCheatSheetModule, CheatSheet) -------------------------------------------------------------------------------- /Source/CheatSheet/Public/CheatSheet.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include 6 | #include "CheatSheet/Public/CheatSheetInterface.h" 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | class APlayerController; 15 | class UCheatManager; 16 | class UCheatSheetSettings; 17 | class UUI_CheatSheetHome; 18 | 19 | DECLARE_EVENT_OneParam(FCheatSheetModule, FOnCheatMapBuilt, const CheatMap&) 20 | 21 | class FCheatSheetModule : public ICheatSheetInterface, 22 | public FGCObject 23 | { 24 | public: 25 | 26 | FCheatSheetModule(); 27 | 28 | void Init(const UWorld::FActorsInitializedParams& InParams); 29 | void Cleanup(UWorld* InWorld, bool bSessionEnded, bool bCleanupResources); 30 | 31 | //IModuleInterface 32 | virtual void StartupModule() override; 33 | virtual void ShutdownModule() override; 34 | //~IModuleInterface 35 | 36 | //FGCObject 37 | virtual void AddReferencedObjects(FReferenceCollector& Collector) override; 38 | //~FGCObject 39 | 40 | private: 41 | 42 | //ICheatSheetInterface 43 | virtual void RebuildCheatMap() override final; 44 | virtual void ToggleListUI() override final; 45 | //~ICheatSheetInterface 46 | 47 | void CreateUI(); 48 | void SetupBindings(APlayerController& InPlayerController); 49 | void SetupUINavigation(); 50 | void UnbindUINavigation(); 51 | 52 | void ShowList(); 53 | void HideList(); 54 | 55 | #if WITH_EDITOR 56 | void DebugPrintCheatMap(); 57 | #endif //WITH_EDITOR 58 | 59 | UCheatSheetSettings* CachedSettings; 60 | UUI_CheatSheetHome* HomeScreen; 61 | 62 | TWeakObjectPtr WeakPlayerController; 63 | TWeakObjectPtr WeakCheatManager; 64 | 65 | bool IsHomeScreenVisible; 66 | 67 | CheatMap Map; 68 | FOnCheatMapBuilt OnCheatMapBuilt; 69 | 70 | TWeakObjectPtr WeakInputComponent; 71 | }; 72 | -------------------------------------------------------------------------------- /Source/CheatSheet/Public/CheatSheetInterface.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | class ICheatSheetInterface : public IModuleInterface 8 | { 9 | public: 10 | 11 | virtual void ToggleListUI() = 0; 12 | virtual void RebuildCheatMap() = 0; 13 | }; -------------------------------------------------------------------------------- /Source/CheatSheet/Public/Settings/CheatSheetSettings.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "CheatSheetSettings.generated.h" 10 | 11 | namespace CheatSheetBindingNames 12 | { 13 | const FName ShowBinding = TEXT("CS_SHOW"); 14 | const FName ConfirmBinding = TEXT("CS_CONFIRM"); 15 | const FName UpBinding = TEXT("CS_UP"); 16 | const FName DownBinding = TEXT("CS_DOWN"); 17 | const FName BackBinding = TEXT("CS_BACK"); 18 | }; 19 | 20 | class UUI_CheatSheetHome; 21 | 22 | UCLASS(config = Game, defaultconfig, meta = (DisplayName = "Cheat Sheet")) 23 | class CHEATSHEET_API UCheatSheetSettings : public UDeveloperSettings 24 | { 25 | GENERATED_BODY() 26 | 27 | public: 28 | 29 | UCheatSheetSettings(const FObjectInitializer& InObjectInitialiser) 30 | : Super(InObjectInitialiser) 31 | , CheatSheetMenu(nullptr) 32 | , ShowBindings() 33 | , ConfirmBindings() 34 | , UpBindings() 35 | , DownBindings() 36 | , BackBindings() 37 | {}; 38 | 39 | UPROPERTY(config, EditDefaultsOnly, Category = "UI") 40 | TSubclassOf CheatSheetMenu; 41 | 42 | UPROPERTY(config, EditDefaultsOnly) 43 | TArray ShowBindings; 44 | 45 | UPROPERTY(config, EditDefaultsOnly) 46 | TArray ConfirmBindings; 47 | 48 | UPROPERTY(config, EditDefaultsOnly) 49 | TArray UpBindings; 50 | 51 | UPROPERTY(config, EditDefaultsOnly) 52 | TArray DownBindings; 53 | 54 | UPROPERTY(config, EditDefaultsOnly) 55 | TArray BackBindings; 56 | 57 | //UDeveloperSettings 58 | virtual FName GetCategoryName() const override { return FName(TEXT("Plugins")); } 59 | //~UDeveloperSettings 60 | 61 | TArray GetShowBinding() 62 | { 63 | for(FInputActionKeyMapping& Mapping : ShowBindings) 64 | { 65 | Mapping.ActionName = CheatSheetBindingNames::ShowBinding; 66 | } 67 | 68 | return ShowBindings; 69 | } 70 | 71 | TArray GetConfirmBinding() 72 | { 73 | for(FInputActionKeyMapping& Mapping : ConfirmBindings) 74 | { 75 | Mapping.ActionName = CheatSheetBindingNames::ConfirmBinding; 76 | } 77 | 78 | return ConfirmBindings; 79 | } 80 | 81 | TArray GetUpBinding() 82 | { 83 | for(FInputActionKeyMapping& Mapping : UpBindings) 84 | { 85 | Mapping.ActionName = CheatSheetBindingNames::UpBinding; 86 | } 87 | 88 | return UpBindings; 89 | } 90 | 91 | TArray GetDownBinding() 92 | { 93 | for(FInputActionKeyMapping& Mapping : DownBindings) 94 | { 95 | Mapping.ActionName = CheatSheetBindingNames::DownBinding; 96 | } 97 | 98 | return DownBindings; 99 | } 100 | 101 | TArray GetBackBinding() 102 | { 103 | for(FInputActionKeyMapping& Mapping : BackBindings) 104 | { 105 | Mapping.ActionName = CheatSheetBindingNames::BackBinding; 106 | } 107 | 108 | return BackBindings; 109 | } 110 | }; 111 | 112 | -------------------------------------------------------------------------------- /Source/CheatSheetEditor/CheatSheetEditor.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class CheatSheetEditor : ModuleRules 6 | { 7 | public CheatSheetEditor(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 10 | 11 | PrivateDependencyModuleNames.AddRange(new string[] 12 | { 13 | "Core", 14 | "CoreUObject", 15 | "CheatSheet", 16 | "CheatSheetTypes", 17 | "DetailCustomizations", 18 | "Engine", 19 | "Projects", 20 | "Slate", 21 | "SlateCore", 22 | "UnrealEd", 23 | "PropertyEditor" 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Source/CheatSheetEditor/Private/Actions/CachedCheatAssetActions.cpp: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #include "CheatSheetEditor/Public/Actions/CachedCheatAssetActions.h" 4 | #include "CheatSheetEditor/Public/CheatSheetEditor.h" 5 | 6 | #include 7 | 8 | #define LOCTEXT_NAMESPACE "CheatSheetAssetActions" 9 | 10 | FCachedCheatAssetActions::FCachedCheatAssetActions(EAssetTypeCategories::Type InAssetCategory) 11 | : AssetCategory(InAssetCategory) 12 | {} 13 | 14 | bool FCachedCheatAssetActions::CanFilter() 15 | { 16 | return true; 17 | } 18 | 19 | uint32 FCachedCheatAssetActions::GetCategories() 20 | { 21 | return AssetCategory; 22 | } 23 | 24 | FText FCachedCheatAssetActions::GetName() const 25 | { 26 | return LOCTEXT("CachedCheatAsset", "Cached Cheat"); 27 | } 28 | 29 | UClass* FCachedCheatAssetActions::GetSupportedClass() const 30 | { 31 | return UCachedCheatAsset::StaticClass(); 32 | } 33 | 34 | FColor FCachedCheatAssetActions::GetTypeColor() const 35 | { 36 | return FColorList::Scarlet; 37 | } 38 | 39 | bool FCachedCheatAssetActions::HasActions(const TArray& InObjects) const 40 | { 41 | return false; 42 | } 43 | 44 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Source/CheatSheetEditor/Private/Actions/CachedCheatBuilderActions.cpp: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #include "CheatSheetEditor/Public/Actions/CachedCheatBuilderActions.h" 4 | #include "CheatSheetEditor/Public/CheatSheetEditor.h" 5 | 6 | #include 7 | 8 | #define LOCTEXT_NAMESPACE "CheatSheetAssetActions" 9 | 10 | FCachedCheatBuilderActions::FCachedCheatBuilderActions(EAssetTypeCategories::Type InAssetCategory) 11 | : AssetCategory(InAssetCategory) 12 | {} 13 | 14 | bool FCachedCheatBuilderActions::CanFilter() 15 | { 16 | return true; 17 | } 18 | 19 | uint32 FCachedCheatBuilderActions::GetCategories() 20 | { 21 | return AssetCategory; 22 | } 23 | 24 | FText FCachedCheatBuilderActions::GetName() const 25 | { 26 | return LOCTEXT("CachedCheatAsset", "Cached Cheat Builder"); 27 | } 28 | 29 | UClass* FCachedCheatBuilderActions::GetSupportedClass() const 30 | { 31 | return UCachedCheatBuilder::StaticClass(); 32 | } 33 | 34 | FColor FCachedCheatBuilderActions::GetTypeColor() const 35 | { 36 | return FColorList::Scarlet; 37 | } 38 | 39 | bool FCachedCheatBuilderActions::HasActions(const TArray& InObjects) const 40 | { 41 | return false; 42 | } 43 | 44 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Source/CheatSheetEditor/Private/CheatSheetEditor.cpp: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #include "CheatSheetEditor/Public/CheatSheetEditor.h" 4 | #include "CheatSheetEditor/Public/Actions/CachedCheatAssetActions.h" 5 | #include "CheatSheetEditor/Public/Actions/CachedCheatBuilderActions.h" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | IMPLEMENT_MODULE(FCheatSheetEditorModule, CheatSheetEditor); 16 | 17 | #define LOCTEXT_NAMESPACE "CheatSheetEditor" 18 | 19 | FCheatSheetEditorModule::FCheatSheetEditorModule() 20 | { 21 | } 22 | 23 | void FCheatSheetEditorModule::StartupModule() 24 | { 25 | RegisterNewAssetCategory(); 26 | RegisterNewAssetIcon(); 27 | 28 | if (ICheatSheetInterface* CheatSheetInterface = FModuleManager::GetModulePtr("CheatSheet")) 29 | { 30 | FCoreUObjectDelegates::OnObjectSaved.AddLambda([CheatSheetInterface](UObject* InNewObject) 31 | { 32 | if (Cast(InNewObject) || Cast(InNewObject)) 33 | { 34 | CheatSheetInterface->RebuildCheatMap(); 35 | } 36 | }); 37 | 38 | FEditorDelegates::OnAssetsDeleted.AddLambda([CheatSheetInterface](const TArray& InDeletedClasses) 39 | { 40 | if (InDeletedClasses.Contains(UCachedCheatAsset::StaticClass()) || InDeletedClasses.Contains(UCachedCheatBuilder::StaticClass())) 41 | { 42 | CheatSheetInterface->RebuildCheatMap(); 43 | } 44 | }); 45 | } 46 | } 47 | 48 | void FCheatSheetEditorModule::ShutdownModule() 49 | { 50 | if (StyleSet.IsValid()) 51 | { 52 | FSlateStyleRegistry::UnRegisterSlateStyle(*StyleSet.Get()); 53 | ensure(StyleSet.IsUnique()); 54 | StyleSet.Reset(); 55 | } 56 | } 57 | 58 | void FCheatSheetEditorModule::RegisterNewAssetCategory() 59 | { 60 | IAssetTools& AssetTools = FModuleManager::LoadModuleChecked("AssetTools").Get(); 61 | EAssetTypeCategories::Type CheatSheetCategoryBit = CheatSheetCategoryBit = AssetTools.RegisterAdvancedAssetCategory(FName(TEXT("CheatSheet")), LOCTEXT("CheatSheetCategory", "Cheat Sheet")); 62 | 63 | TSharedPtr CachedCheatAction = MakeShareable(new FCachedCheatAssetActions(CheatSheetCategoryBit)); 64 | AssetTools.RegisterAssetTypeActions(CachedCheatAction.ToSharedRef()); 65 | 66 | TSharedPtr CachedCheatBuilderAction = MakeShareable(new FCachedCheatBuilderActions(CheatSheetCategoryBit)); 67 | AssetTools.RegisterAssetTypeActions(CachedCheatBuilderAction.ToSharedRef()); 68 | } 69 | 70 | void FCheatSheetEditorModule::RegisterNewAssetIcon() 71 | { 72 | StyleSet = MakeShareable(new FSlateStyleSet("CheatSheetStyle")); 73 | 74 | FString ContentDir = IPluginManager::Get().FindPlugin("CheatSheet")->GetBaseDir(); 75 | StyleSet->SetContentRoot(ContentDir); 76 | 77 | FSlateImageBrush* CachedCheatBrush = new FSlateImageBrush(StyleSet->RootToContentDir(TEXT("Resources/Icon64"), TEXT(".png")), FVector2D(64.f, 64.f)); 78 | FSlateImageBrush* CachedCheatBuilderBrush = new FSlateImageBrush(StyleSet->RootToContentDir(TEXT("Resources/BuilderIcon64"), TEXT(".png")), FVector2D(64.f, 64.f)); 79 | 80 | if (CachedCheatBrush && CachedCheatBuilderBrush) 81 | { 82 | StyleSet->Set("ClassThumbnail.CachedCheatAsset", CachedCheatBrush); 83 | StyleSet->Set("ClassThumbnail.CachedCheatBuilder", CachedCheatBuilderBrush); 84 | FSlateStyleRegistry::RegisterSlateStyle(*StyleSet); 85 | } 86 | } 87 | 88 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Source/CheatSheetEditor/Private/Factories/CachedCheatBuilderFactory.cpp: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #include "CheatSheetEditor/Public/Factories/CachedCheatBuilderFactory.h" 4 | 5 | #include 6 | #include 7 | 8 | UCachedCheatBuilderFactory::UCachedCheatBuilderFactory() 9 | { 10 | SupportedClass = UCachedCheatBuilder::StaticClass(); 11 | bCreateNew = true; 12 | bEditAfterNew = true; 13 | } 14 | 15 | bool UCachedCheatBuilderFactory::ShouldShowInNewMenu() const 16 | { 17 | return true; 18 | } 19 | 20 | UObject* UCachedCheatBuilderFactory::FactoryCreateNew(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) 21 | { 22 | return FKismetEditorUtilities::CreateBlueprint(UCachedCheatBuilder::StaticClass(), InParent, InName, BPTYPE_Normal, UBlueprint::StaticClass(), UBlueprintGeneratedClass::StaticClass()); 23 | } 24 | -------------------------------------------------------------------------------- /Source/CheatSheetEditor/Private/Factories/CachedCheatFactory.cpp: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #include "CheatSheetEditor/Public/Factories/CachedCheatFactory.h" 4 | 5 | #include 6 | 7 | UCachedCheatFactory::UCachedCheatFactory() 8 | { 9 | SupportedClass = UCachedCheatAsset::StaticClass(); 10 | bCreateNew = true; 11 | bEditAfterNew = true; 12 | } 13 | 14 | bool UCachedCheatFactory::ShouldShowInNewMenu() const 15 | { 16 | return true; 17 | } 18 | 19 | UObject* UCachedCheatFactory::FactoryCreateNew(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) 20 | { 21 | if (UCachedCheatAsset* NewCheat = NewObject(InParent, InClass, InName, Flags)) 22 | { 23 | return NewCheat; 24 | } 25 | 26 | return nullptr; 27 | } 28 | -------------------------------------------------------------------------------- /Source/CheatSheetEditor/Public/Actions/CachedCheatAssetActions.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | class ISlateStyle; 8 | 9 | class FCachedCheatAssetActions : public FAssetTypeActions_Base 10 | { 11 | public: 12 | 13 | FCachedCheatAssetActions(EAssetTypeCategories::Type InAssetCategory); 14 | 15 | virtual bool CanFilter() override; 16 | virtual uint32 GetCategories() override; 17 | virtual FText GetName() const override; 18 | virtual UClass* GetSupportedClass() const override; 19 | virtual FColor GetTypeColor() const override; 20 | virtual bool HasActions(const TArray& InObjects) const override; 21 | 22 | private: 23 | 24 | EAssetTypeCategories::Type AssetCategory; 25 | }; 26 | -------------------------------------------------------------------------------- /Source/CheatSheetEditor/Public/Actions/CachedCheatBuilderActions.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | class ISlateStyle; 8 | 9 | class FCachedCheatBuilderActions : public FAssetTypeActions_Base 10 | { 11 | public: 12 | 13 | FCachedCheatBuilderActions(EAssetTypeCategories::Type InAssetCategory); 14 | 15 | virtual bool CanFilter() override; 16 | virtual uint32 GetCategories() override; 17 | virtual FText GetName() const override; 18 | virtual UClass* GetSupportedClass() const override; 19 | virtual FColor GetTypeColor() const override; 20 | virtual bool HasActions(const TArray& InObjects) const override; 21 | 22 | private: 23 | 24 | EAssetTypeCategories::Type AssetCategory; 25 | }; 26 | -------------------------------------------------------------------------------- /Source/CheatSheetEditor/Public/CheatSheetEditor.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | class FCheatSheetEditorModule : public IModuleInterface 11 | { 12 | 13 | public: 14 | 15 | FCheatSheetEditorModule(); 16 | 17 | //IModuleInterface 18 | void StartupModule() override; 19 | void ShutdownModule() override; 20 | //~IModuleInterface 21 | 22 | private: 23 | 24 | void RegisterNewAssetCategory(); 25 | void RegisterNewAssetIcon(); 26 | 27 | TSharedPtr StyleSet; 28 | }; 29 | -------------------------------------------------------------------------------- /Source/CheatSheetEditor/Public/Factories/CachedCheatBuilderFactory.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | #include "CachedCheatBuilderFactory.generated.h" 8 | 9 | UCLASS(hideCategories=Object) 10 | class UCachedCheatBuilderFactory : public UFactory 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | 16 | UCachedCheatBuilderFactory(); 17 | 18 | //UFactory 19 | bool ShouldShowInNewMenu() const override; 20 | UObject* FactoryCreateNew(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override; 21 | //~UFactory 22 | }; 23 | -------------------------------------------------------------------------------- /Source/CheatSheetEditor/Public/Factories/CachedCheatFactory.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | #include "CachedCheatFactory.generated.h" 8 | 9 | UCLASS(hideCategories=Object) 10 | class UCachedCheatFactory : public UFactory 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | 16 | UCachedCheatFactory(); 17 | 18 | //UFactory 19 | bool ShouldShowInNewMenu() const override; 20 | UObject* FactoryCreateNew(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override; 21 | //~UFactory 22 | }; 23 | -------------------------------------------------------------------------------- /Source/CheatSheetTypes/CheatSheetTypes.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class CheatSheetTypes : ModuleRules 6 | { 7 | public CheatSheetTypes(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 10 | 11 | PublicDependencyModuleNames.AddRange( 12 | new string[] 13 | { 14 | "Core", 15 | } 16 | ); 17 | 18 | 19 | PrivateDependencyModuleNames.AddRange( 20 | new string[] 21 | { 22 | "CoreUObject", 23 | "Engine", 24 | "InputCore" 25 | } 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Source/CheatSheetTypes/Private/Categories/CheatCategory.cpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CheatSheetTypes/Public/Categories/CheatCategory.h" 4 | 5 | FCheatCategory::FCheatCategory() 6 | : CategoryName(TEXT("Empty Category")) 7 | , ID(FGuid()) 8 | , ParentID(FGuid()) 9 | , Cheats() 10 | , SubCategories() 11 | , SubCatCallback(nullptr) 12 | {} 13 | 14 | FCheatCategory::FCheatCategory(const FString& InCategoryName, const FGuid& InParentID, const TFunction& InSubCatCallback) 15 | : CategoryName(InCategoryName) 16 | , ID(FGuid::NewGuid()) 17 | , ParentID(InParentID) 18 | , Cheats() 19 | , SubCategories() 20 | , SubCatCallback(InSubCatCallback) 21 | {} 22 | 23 | FString FCheatCategory::GetCategoryName() const 24 | { 25 | return CategoryName; 26 | } 27 | 28 | TArray FCheatCategory::GetSubCategories() const 29 | { 30 | return SubCategories; 31 | } 32 | 33 | TArray& FCheatCategory::GetSubCategoriesAsRef() 34 | { 35 | return SubCategories; 36 | } 37 | 38 | FGuid FCheatCategory::GetCategoryID() const 39 | { 40 | return ID; 41 | } 42 | 43 | FGuid FCheatCategory::GetParentID() const 44 | { 45 | return ParentID; 46 | } 47 | 48 | TArray FCheatCategory::GetCheats() const 49 | { 50 | return Cheats; 51 | } 52 | 53 | void FCheatCategory::AddCheat(FCachedCheat& InCheat) 54 | { 55 | //Remove nested categories like Test/Test 56 | if (InCheat.GetTopLevelCat() == CategoryName) 57 | { 58 | InCheat.PopTopLevel(); 59 | } 60 | 61 | //Are we at the bottom of the list? If so, add the cheat here 62 | if (!InCheat.HasValidCategories()) 63 | { 64 | Cheats.Add(InCheat); 65 | Cheats.Sort(); 66 | 67 | return; 68 | } 69 | else 70 | { 71 | if (FCheatCategory* ExistingCategory = GetExistingTopLevel(InCheat.GetTopLevelCat())) 72 | { 73 | ExistingCategory->AddCheat(InCheat); 74 | } 75 | else 76 | { 77 | FCheatCategory NewCategory(InCheat.GetTopLevelCat(), ID, SubCatCallback); 78 | NewCategory.AddCheat(InCheat); 79 | SubCategories.Add(NewCategory); 80 | 81 | if (SubCatCallback != nullptr) 82 | { 83 | SubCatCallback(NewCategory); 84 | } 85 | } 86 | } 87 | } 88 | 89 | FCheatCategory* FCheatCategory::GetExistingTopLevel(const FString& InCategoryName) 90 | { 91 | return SubCategories.FindByPredicate([&InCategoryName](const FCheatCategory& Category) 92 | { 93 | return Category.GetCategoryName() == InCategoryName; 94 | }); 95 | } 96 | -------------------------------------------------------------------------------- /Source/CheatSheetTypes/Private/Categories/CheatMap.cpp: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #include "CheatSheetTypes/Public/Categories/CheatMap.h" 4 | 5 | DEFINE_LOG_CATEGORY_STATIC(CheatMapLog, Log, Log); 6 | 7 | CheatMap::CheatMap() 8 | : Map() 9 | , FlatMap() 10 | {} 11 | 12 | void CheatMap::AddCheat(FCachedCheat InCheat) 13 | { 14 | if (FCheatCategory* ExistingCategory = const_cast(GetExistingTopLevel(InCheat.GetTopLevelCat()))) 15 | { 16 | ExistingCategory->AddCheat(InCheat); 17 | } 18 | else 19 | { 20 | FCheatCategory NewCategory( 21 | InCheat.GetTopLevelCat(), 22 | FGuid(), 23 | [this](const FCheatCategory& InNewCategory) 24 | { 25 | AddSubcategoryToFlatMap(InNewCategory); 26 | } 27 | ); 28 | 29 | NewCategory.AddCheat(InCheat); 30 | 31 | Map.Add(NewCategory); 32 | FlatMap.Add(NewCategory.GetCategoryID(), NewCategory); 33 | } 34 | } 35 | 36 | void CheatMap::Reset() 37 | { 38 | Map.Empty(); 39 | FlatMap.Empty(); 40 | } 41 | 42 | void CheatMap::Sort() 43 | { 44 | Map.Sort(); 45 | } 46 | 47 | FCheatCategory CheatMap::GetCategoryByID(const FGuid& InCategoryID) const 48 | { 49 | if (FlatMap.Contains(InCategoryID)) 50 | { 51 | return FlatMap[InCategoryID]; 52 | } 53 | 54 | return FCheatCategory(); 55 | } 56 | 57 | TArray CheatMap::GetHistoryFromID(const FGuid& InID) const 58 | { 59 | TArray NewHistory; 60 | GetHistoryFromID(NewHistory, InID); 61 | 62 | return NewHistory; 63 | } 64 | 65 | void CheatMap::GetHistoryFromID(TArray& InExistingHistory, const FGuid& InID) const 66 | { 67 | if (FlatMap.Contains(InID)) 68 | { 69 | const FCheatCategory CurrentCat = FlatMap[InID]; 70 | 71 | InExistingHistory.Add(CurrentCat.GetCategoryName()); 72 | GetHistoryFromID(InExistingHistory, CurrentCat.GetParentID()); 73 | } 74 | else 75 | { 76 | InExistingHistory.Add(TEXT("Home")); 77 | Algo::Reverse(InExistingHistory); 78 | } 79 | } 80 | 81 | const FCheatCategory* CheatMap::GetExistingTopLevel(const FString& InCategoryName) const 82 | { 83 | return Map.FindByPredicate([&InCategoryName](const FCheatCategory& Category) 84 | { 85 | return Category.GetCategoryName() == InCategoryName; 86 | }); 87 | } 88 | 89 | void CheatMap::AddSubcategoryToFlatMap(const FCheatCategory& InNewSubCategory) 90 | { 91 | FlatMap.Add(InNewSubCategory.GetCategoryID(), InNewSubCategory); 92 | 93 | if (FlatMap.Contains(InNewSubCategory.GetParentID())) 94 | { 95 | FlatMap[InNewSubCategory.GetParentID()].GetSubCategoriesAsRef().Add(InNewSubCategory); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /Source/CheatSheetTypes/Public/Categories/CachedCheat.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include "CachedCheat.generated.h" 6 | 7 | namespace CachedCheatStatics 8 | { 9 | const FString Uncategorized = TEXT("Uncategorized"); 10 | const FString CategoryDelim = TEXT("|"); 11 | const FString CommonlyUsed = TEXT("_CommonlyUsed"); 12 | 13 | const FString Error = TEXT("Error"); 14 | } 15 | 16 | USTRUCT(BlueprintType) 17 | struct FCachedCheat 18 | { 19 | GENERATED_BODY() 20 | 21 | public: 22 | 23 | FCachedCheat() 24 | : CheatString() 25 | , DisplayName(TEXT("EmptyCheat")) 26 | , CatConcat() 27 | , Tooltip(TEXT("This is an empty cheat - it will execute nothing")) 28 | , ShouldCloseAfterExecution(true) 29 | , Func(nullptr) 30 | {} 31 | 32 | FCachedCheat(const FString& InCheatString, const FString& InDisplayName, const FString& InCatConcat, const FString& InTooltip, UFunction* InFunc, const bool InShouldCloseAfterExecution) 33 | : CheatString(InCheatString) 34 | , DisplayName(InCheatString) 35 | , CatConcat() 36 | , Tooltip(InTooltip) 37 | , ShouldCloseAfterExecution(InShouldCloseAfterExecution) 38 | , Func(InFunc) 39 | { 40 | CatConcat = ParseCategories(InCatConcat, Func); 41 | }; 42 | 43 | FCachedCheat(const FString& InCheatString, const FString& InDisplayName, const TArray& InCatConcat, const FString& InTooltip, UFunction* InFunc, const bool InShouldCloseAfterExecution) 44 | : CheatString(InCheatString) 45 | , DisplayName(InDisplayName) 46 | , CatConcat(InCatConcat) 47 | , Tooltip(InTooltip) 48 | , ShouldCloseAfterExecution(InShouldCloseAfterExecution) 49 | , Func(InFunc) 50 | {}; 51 | 52 | UPROPERTY(EditAnywhere, BlueprintReadOnly) 53 | FString CheatString; 54 | 55 | FString DisplayName; 56 | TArray CatConcat; 57 | FString Tooltip; 58 | bool ShouldCloseAfterExecution; 59 | 60 | UPROPERTY() 61 | UFunction* Func; 62 | 63 | bool operator<(const FCachedCheat& InOtherCheat) const 64 | { 65 | return DisplayName < InOtherCheat.DisplayName; 66 | } 67 | 68 | public: 69 | 70 | FString GetTopLevelCat() const 71 | { 72 | if (CatConcat.IsValidIndex(0)) 73 | { 74 | return CatConcat[0]; 75 | } 76 | else 77 | { 78 | return CachedCheatStatics::Error; 79 | } 80 | } 81 | void PopTopLevel() 82 | { 83 | if (CatConcat.IsValidIndex(0)) 84 | { 85 | CatConcat.RemoveAt(0); 86 | } 87 | } 88 | bool HasValidCategories() 89 | { 90 | return CatConcat.Num() > 0; 91 | } 92 | 93 | private: 94 | 95 | static TArray ParseCategories(const FString& InCatConcat, UFunction* InFunc = nullptr) 96 | { 97 | TArray Categories; 98 | 99 | if (InCatConcat.IsEmpty()) 100 | { 101 | Categories.Add(CachedCheatStatics::Uncategorized); 102 | 103 | if (InFunc != nullptr) 104 | { 105 | Categories.Add(*InFunc->GetOuterUClass()->GetName()); 106 | } 107 | } 108 | else 109 | { 110 | InCatConcat.ParseIntoArray(Categories, *CachedCheatStatics::CategoryDelim, true); 111 | } 112 | 113 | return Categories; 114 | } 115 | }; 116 | -------------------------------------------------------------------------------- /Source/CheatSheetTypes/Public/Categories/CachedCheatAsset.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | 8 | #include "CachedCheatAsset.generated.h" 9 | 10 | DEFINE_LOG_CATEGORY_STATIC(CachedCheatAssetLog, Log, Log); 11 | 12 | UCLASS(BlueprintType, Blueprintable) 13 | class CHEATSHEETTYPES_API UCachedCheatAsset : public UObject 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | 19 | UCachedCheatAsset() 20 | : CheatString() 21 | , Categories() 22 | , IsCommonlyUsed(false) 23 | , Tooltip() 24 | , DisplayName() 25 | , ShouldCloseAfterExecution(true) 26 | {}; 27 | 28 | FCachedCheat GetCheat() const 29 | { 30 | TArray CleanCategories = Categories; 31 | if (CleanCategories.Num() > 0) 32 | { 33 | for (int32 i = CleanCategories.Num() -1; i >= 0; --i) 34 | { 35 | if (CleanCategories[i].IsEmpty()) 36 | { 37 | CleanCategories.RemoveAt(i); 38 | } 39 | } 40 | } 41 | else 42 | { 43 | CleanCategories.Add(CachedCheatStatics::Uncategorized); 44 | } 45 | 46 | if (IsCommonlyUsed) 47 | { 48 | CleanCategories.Insert(CachedCheatStatics::CommonlyUsed, 0); 49 | } 50 | 51 | return FCachedCheat(CheatString, DisplayName, CleanCategories, Tooltip, nullptr, ShouldCloseAfterExecution); 52 | }; 53 | 54 | 55 | UPROPERTY(EditDefaultsOnly, meta = (Category = "Cheat", Tooltip = "The cheat itself, matches syntax of a console command. Unlike autodiscovery from the CheatManager, this will support params, so Game.DoYourThing 1 is valid here")) 56 | FString CheatString; 57 | 58 | UPROPERTY(EditDefaultsOnly, meta = (Category = "Cheat Meta", Tooltip = "Categories in descending order. For Instance, Root/Category1/Category2")) 59 | TArray Categories; 60 | 61 | UPROPERTY(EditDefaultsOnly, meta = (Category = "Cheat Meta", Tooltip = "Does this Cheat need to be added to the Commonly Used top level category? Typically high traffic cheats")) 62 | bool IsCommonlyUsed; 63 | 64 | UPROPERTY(EditDefaultsOnly, meta = (Category = "Cheat Meta", Tooltip = "What does this cheat actually do?")) 65 | FString Tooltip; 66 | 67 | UPROPERTY(EditDefaultsOnly, meta = (Category = "Cheat Meta", Tooltip = "Readable cheat name")) 68 | FString DisplayName; 69 | 70 | UPROPERTY(EditDefaultsOnly, meta = (Category = "Cheat Meta", Tooltip = "Should we close the CheatSheet once this command has been issued?")) 71 | bool ShouldCloseAfterExecution; 72 | }; 73 | -------------------------------------------------------------------------------- /Source/CheatSheetTypes/Public/Categories/CachedCheatBuilder.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | 8 | #include "CachedCheatBuilder.generated.h" 9 | 10 | DEFINE_LOG_CATEGORY_STATIC(CachedCheatBuilderLog, Log, Log); 11 | 12 | UCLASS(BlueprintType, Blueprintable) 13 | class CHEATSHEETTYPES_API UCachedCheatBuilder : public UObject 14 | { 15 | GENERATED_BODY() 16 | 17 | public: 18 | 19 | UCachedCheatBuilder(const FObjectInitializer& InObjectInitialiser) 20 | : Super(InObjectInitialiser) 21 | {}; 22 | 23 | UFUNCTION(BlueprintNativeEvent, Category = "Generation") 24 | TArray Generate(); 25 | 26 | UPROPERTY(EditDefaultsOnly, meta = (Category = "Cheat Meta", Tooltip = "Categories in descending order. For Instance, Root/Category1/Category2.")) 27 | TArray Categories; 28 | 29 | UPROPERTY(EditDefaultsOnly, meta = (Category = "Cheat Meta", Tooltip = "Does this Cheat need to be added to the Commonly Used top level category? Typically high traffic cheats. As this is a dynamically generated cheat, having a category is highly advised.")) 30 | bool IsCommonlyUsed; 31 | 32 | UPROPERTY(EditDefaultsOnly, meta = (Category = "Cheat Meta", Tooltip = "What does this cheat actually do?")) 33 | FString Tooltip; 34 | 35 | UPROPERTY(EditDefaultsOnly, meta = (Category = "Cheat Meta", Tooltip = "Should we close the CheatSheet once this command has been issued?")) 36 | bool ShouldCloseAfterExecution; 37 | 38 | protected: 39 | 40 | virtual TArray Generate_Implementation() { return TArray(); }; 41 | }; 42 | -------------------------------------------------------------------------------- /Source/CheatSheetTypes/Public/Categories/CheatCategory.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include "CheatSheetTypes/Public/Categories/CachedCheat.h" 6 | 7 | #include "CheatCategory.generated.h" 8 | 9 | DEFINE_LOG_CATEGORY_STATIC(CheatCategoryLog, Log, Log); 10 | 11 | USTRUCT(BlueprintType) 12 | struct FCheatCategory 13 | { 14 | GENERATED_BODY() 15 | 16 | public: 17 | 18 | CHEATSHEETTYPES_API FCheatCategory(); 19 | CHEATSHEETTYPES_API FCheatCategory(const FString& InCategoryName, const FGuid& InParentID, const TFunction& InSubCatCallback); 20 | 21 | CHEATSHEETTYPES_API FString GetCategoryName() const; 22 | CHEATSHEETTYPES_API TArray GetSubCategories() const; 23 | TArray& GetSubCategoriesAsRef(); 24 | CHEATSHEETTYPES_API FGuid GetCategoryID() const; 25 | CHEATSHEETTYPES_API FGuid GetParentID() const; 26 | CHEATSHEETTYPES_API TArray GetCheats() const; 27 | 28 | void AddCheat( FCachedCheat& InCheat); 29 | 30 | bool operator<(const FCheatCategory& InOtherCategory) const 31 | { 32 | return CategoryName < InOtherCategory.CategoryName; 33 | } 34 | 35 | private: 36 | 37 | FCheatCategory* GetExistingTopLevel(const FString& InCategoryName); 38 | 39 | FString CategoryName; 40 | 41 | FGuid ID; 42 | FGuid ParentID; 43 | 44 | TArray Cheats; 45 | 46 | TArray SubCategories; 47 | TFunction SubCatCallback; 48 | }; 49 | -------------------------------------------------------------------------------- /Source/CheatSheetTypes/Public/Categories/CheatMap.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include "CheatSheetTypes/Public/Categories/CheatCategory.h" 6 | 7 | class CheatMap 8 | { 9 | 10 | public: 11 | 12 | CHEATSHEETTYPES_API CheatMap(); 13 | 14 | CHEATSHEETTYPES_API void AddCheat(FCachedCheat InCheat); 15 | 16 | CHEATSHEETTYPES_API void Reset(); 17 | CHEATSHEETTYPES_API void Sort(); 18 | 19 | TArray GetCategories() const { return Map; } 20 | CHEATSHEETTYPES_API FCheatCategory GetCategoryByID(const FGuid& InID) const; 21 | CHEATSHEETTYPES_API TArray GetHistoryFromID(const FGuid& InID) const; 22 | 23 | private: 24 | 25 | void GetHistoryFromID(TArray& InExistingString, const FGuid& InID) const; 26 | const FCheatCategory* GetExistingTopLevel(const FString& InCategoryName) const; 27 | void AddSubcategoryToFlatMap(const FCheatCategory& InNewSubCategory); 28 | 29 | TArray Map; 30 | TMap FlatMap; 31 | }; -------------------------------------------------------------------------------- /Source/CheatSheetTypes/Public/CheatSheetTypes.cpp: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #include 4 | 5 | IMPLEMENT_MODULE(FDefaultModuleImpl, CheatSheetTypes); -------------------------------------------------------------------------------- /Source/CheatSheetUI/CheatSheetUI.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class CheatSheetUI : ModuleRules 6 | { 7 | public CheatSheetUI(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 10 | 11 | PublicDependencyModuleNames.AddRange( 12 | new string[] 13 | { 14 | "Core", 15 | } 16 | ); 17 | 18 | 19 | PrivateDependencyModuleNames.AddRange( 20 | new string[] 21 | { 22 | "CoreUObject", 23 | "Engine", 24 | "InputCore", 25 | "Slate", 26 | "SlateCore", 27 | "UMG", 28 | 29 | "CheatSheetTypes" 30 | } 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Source/CheatSheetUI/Private/CheatSheetUI.cpp: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #include "CheatSheetUI/Public/CheatSheetUI.h" 4 | 5 | DEFINE_LOG_CATEGORY_STATIC(CheatSheetUILog, Log, Log); 6 | 7 | void FCheatSheetUIModule::StartupModule() 8 | { 9 | UE_LOG(CheatSheetUILog, Log, TEXT("Spinning up CheatSheetUI")); 10 | } 11 | 12 | void FCheatSheetUIModule::ShutdownModule() 13 | { 14 | UE_LOG(CheatSheetUILog, Log, TEXT("Shutting down CheatSheetUI")); 15 | } 16 | 17 | IMPLEMENT_MODULE(FCheatSheetUIModule, CheatSheetUI) -------------------------------------------------------------------------------- /Source/CheatSheetUI/Private/UI/Entries/UI_CategoryEntry.cpp: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #include "CheatSheetUI/Public/UI/Entries/UI_CategoryEntry.h" 4 | 5 | #include 6 | 7 | UUI_CategoryEntry::UUI_CategoryEntry(const FObjectInitializer& ObjectInitializer) 8 | : UUI_CheatEntryBase(ObjectInitializer) 9 | , NumSubCategoriesText(nullptr) 10 | , Category(FCheatCategory()) 11 | , RequestCallback(nullptr) 12 | {} 13 | 14 | void UUI_CategoryEntry::ExecuteEntry() 15 | { 16 | if (RequestCallback != nullptr) 17 | { 18 | RequestCallback(Category); 19 | } 20 | } 21 | 22 | void UUI_CategoryEntry::NativeConstruct() 23 | { 24 | Super::NativeConstruct(); 25 | 26 | if (EntryNameText != nullptr) 27 | { 28 | EntryNameText->SetText(FText::FromString(Category.GetCategoryName())); 29 | } 30 | 31 | if (NumSubCategoriesText) 32 | { 33 | const FString SubCategoryTest = FString::Printf(TEXT("(%i)"), Category.GetSubCategories().Num() + Category.GetCheats().Num()); 34 | NumSubCategoriesText->SetText(FText::FromString(SubCategoryTest)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Source/CheatSheetUI/Private/UI/Entries/UI_CheatEntry.cpp: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #include "CheatSheetUI/Public/UI/Entries/UI_CheatEntry.h" 4 | 5 | DEFINE_LOG_CATEGORY_STATIC(CheatEntryLog, Log, Log); 6 | 7 | UUI_CheatEntry::UUI_CheatEntry(const FObjectInitializer& ObjectInitializer) 8 | : Super(ObjectInitializer) 9 | , Cheat(FCachedCheat()) 10 | { 11 | 12 | } 13 | 14 | void UUI_CheatEntry::ExecuteEntry() 15 | { 16 | if (UWorld* World = GetWorld()) 17 | { 18 | if (APlayerController* LocalPlayerController = World->GetFirstPlayerController()) 19 | { 20 | LocalPlayerController->ConsoleCommand(Cheat.CheatString); 21 | OnCheatEntryExecuted.Execute(Cheat); 22 | } 23 | } 24 | } 25 | 26 | const FString UUI_CheatEntry::GetEntryTip() const 27 | { 28 | return Cheat.Tooltip; 29 | } 30 | 31 | void UUI_CheatEntry::NativeConstruct() 32 | { 33 | Super::NativeConstruct(); 34 | 35 | if (EntryNameText != nullptr) 36 | { 37 | if(!Cheat.DisplayName.IsEmpty()) 38 | { 39 | EntryNameText->SetText(FText::FromString(Cheat.DisplayName)); 40 | } 41 | else 42 | { 43 | EntryNameText->SetColorAndOpacity(FSlateColor(FColorList::Scarlet)); 44 | EntryNameText->SetText(FText::FromString(Cheat.CheatString)); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Source/CheatSheetUI/Private/UI/Tips/UI_ControlTip.cpp: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #include "CheatSheetUI/Public/UI/Tips/UI_ControlTip.h" 4 | 5 | #include 6 | 7 | UUI_ControlTip::UUI_ControlTip(const FObjectInitializer& ObjectInitializer) 8 | : Super(ObjectInitializer) 9 | , Action(nullptr) 10 | , Keys(nullptr) 11 | , Mapping() 12 | { 13 | 14 | } 15 | 16 | void UUI_ControlTip::SynchronizeProperties() 17 | { 18 | Super::SynchronizeProperties(); 19 | 20 | if (Action != nullptr) 21 | { 22 | Action->SetText(FText::FromString(*Mapping.ActionName.ToString())); 23 | } 24 | 25 | if (Keys != nullptr) 26 | { 27 | Keys->SetText(FText::FromString(GetChordAsString())); 28 | } 29 | } 30 | 31 | const FString UUI_ControlTip::GetChordAsString() const 32 | { 33 | FString Chord; 34 | 35 | Chord = Mapping.Key.ToString(); 36 | 37 | if (Mapping.bAlt) 38 | { 39 | Chord += TEXT(" + Alt"); 40 | } 41 | 42 | if (Mapping.bCmd) 43 | { 44 | Chord += TEXT(" + Cmd"); 45 | } 46 | 47 | if (Mapping.bCtrl) 48 | { 49 | Chord += TEXT(" + Ctrl"); 50 | } 51 | 52 | if (Mapping.bShift) 53 | { 54 | Chord += TEXT(" + Shift"); 55 | } 56 | 57 | return Chord; 58 | } 59 | -------------------------------------------------------------------------------- /Source/CheatSheetUI/Private/UI/Tips/UI_CurrentTooltip.cpp: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #include "CheatSheetUI/Public/UI/Tips/UI_CurrentTooltip.h" 4 | 5 | UUI_CurrentTooltip::UUI_CurrentTooltip(const FObjectInitializer& ObjectInitializer) 6 | : Super(ObjectInitializer) 7 | , Tooltip(nullptr) 8 | , CurrentTooltip(TEXT("")) 9 | {} 10 | 11 | void UUI_CurrentTooltip::SetTooltip(const FString& InNewTooltip) 12 | { 13 | if (InNewTooltip.IsEmpty()) 14 | { 15 | SetVisibility(ESlateVisibility::Collapsed); 16 | } 17 | else 18 | { 19 | SetVisibility(ESlateVisibility::Visible); 20 | 21 | if (Tooltip != nullptr) 22 | { 23 | Tooltip->SetText(FText::FromString(*InNewTooltip)); 24 | } 25 | } 26 | } 27 | 28 | void UUI_CurrentTooltip::SynchronizeProperties() 29 | { 30 | Super::SynchronizeProperties(); 31 | 32 | if (Tooltip != nullptr) 33 | { 34 | Tooltip->SetText(FText::FromString(*CurrentTooltip)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Source/CheatSheetUI/Private/UI/UI_CheatCategory.cpp: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #include "CheatSheetUI/Public/UI/UI_CheatCategory.h" 4 | 5 | #include 6 | 7 | #include 8 | 9 | UUI_CheatCategory::UUI_CheatCategory(const FObjectInitializer& ObjectInitializer) 10 | : Super(ObjectInitializer) 11 | , CheatCategoryNumber(nullptr) 12 | , CheatCategoryName(nullptr) 13 | , Category(FCheatCategory()) 14 | {} 15 | 16 | void UUI_CheatCategory::NativeConstruct() 17 | { 18 | Super::NativeConstruct(); 19 | 20 | if (CheatCategoryName != nullptr) 21 | { 22 | CheatCategoryName->SetText(FText::FromString(Category.GetCategoryName())); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Source/CheatSheetUI/Private/UI/UI_CheatSheetHome.cpp: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #include "CheatSheetUI/Public/UI/UI_CheatSheetHome.h" 4 | #include "CheatSheetUI/Public/UI/UI_CheatView.h" 5 | #include "CheatSheetUI/Public/UI/Tips/UI_ControlTip.h" 6 | #include "CheatSheetUI/Public/UI/Tips/UI_CurrentTooltip.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "CheatSheet/Public/CheatSheet.h" 14 | 15 | UUI_CheatSheetHome::UUI_CheatSheetHome(const FObjectInitializer& ObjectInitializer) 16 | : Super(ObjectInitializer) 17 | , CheatView(nullptr) 18 | , HistoryReadout(nullptr) 19 | , ControlTipsBox(nullptr) 20 | , CurrentTooltipBox(nullptr) 21 | , InfoBox(nullptr) 22 | , Map() 23 | , History() 24 | , CurrentCategory(FCheatCategory()) 25 | {} 26 | 27 | void UUI_CheatSheetHome::AddMap(const CheatMap& InMap) 28 | { 29 | Map = InMap; 30 | InitHomeView(); 31 | } 32 | 33 | void UUI_CheatSheetHome::InitHomeView() 34 | { 35 | History.Empty(); 36 | CheatView->OnNewCategoryRequested.RemoveAll(this); 37 | 38 | if (CheatView != nullptr) 39 | { 40 | CheatView->OnNewCategoryRequested.AddUObject(this, &UUI_CheatSheetHome::UpdateHistoryReadout); 41 | 42 | if (CurrentTooltipBox != nullptr) 43 | { 44 | CheatView->OnNewSelection.AddWeakLambda(this, [this](const TWeakInterfacePtr& InOldSelection, const TWeakInterfacePtr& InNewSelection) 45 | { 46 | if (ICheatEntryInterface* NewSelection = InNewSelection.Get()) 47 | { 48 | if (ICheatEntryInterface* OldSelection = InOldSelection.Get()) 49 | { 50 | OldSelection->GetOnCheatEntryExecuted().Unbind(); 51 | } 52 | 53 | NewSelection->GetOnCheatEntryExecuted().BindWeakLambda(this, [this, NewSelection = NewSelection](const FCachedCheat& InCheat) 54 | { 55 | if(InCheat.ShouldCloseAfterExecution) 56 | { 57 | ICheatSheetInterface& CheatSheet = FModuleManager::GetModuleChecked("CheatSheet"); 58 | CheatSheet.ToggleListUI(); 59 | } 60 | }); 61 | 62 | const FString EntryTip = NewSelection->GetEntryTip(); 63 | if(!EntryTip.IsEmpty()) 64 | { 65 | InfoBox->SetVisibility(ESlateVisibility::Visible); 66 | CurrentTooltipBox->SetTooltip(NewSelection->GetEntryTip()); 67 | } 68 | else 69 | { 70 | InfoBox->SetVisibility(ESlateVisibility::Hidden); 71 | } 72 | } 73 | }); 74 | } 75 | 76 | if (Map.IsSet()) 77 | { 78 | CheatView->RequestHomeView(Map.GetValue().GetCategories()); 79 | 80 | History.Add(TEXT("Home")); 81 | if (HistoryReadout != nullptr) 82 | { 83 | HistoryReadout->SetText(FText::FromString(GetHistoryAsString(History))); 84 | } 85 | } 86 | } 87 | } 88 | 89 | void UUI_CheatSheetHome::ShowPreviousCategory() 90 | { 91 | if(History.Num() > 1) 92 | { 93 | ShowScreenByID(CurrentCategory.GetParentID()); 94 | } 95 | else 96 | { 97 | ICheatSheetInterface& CheatSheet = FModuleManager::GetModuleChecked("CheatSheet"); 98 | CheatSheet.ToggleListUI(); 99 | } 100 | } 101 | 102 | bool UUI_CheatSheetHome::ShowScreenByID(const FGuid& InID) 103 | { 104 | if (Map.IsSet()) 105 | { 106 | const FCheatCategory FoundCategory = Map.GetValue().GetCategoryByID(InID); 107 | 108 | if (FoundCategory.GetCategoryID().IsValid()) 109 | { 110 | CheatView->RequestViewForCategory(FoundCategory); 111 | return true; 112 | } 113 | else 114 | { 115 | InitHomeView(); 116 | } 117 | } 118 | else 119 | { 120 | InitHomeView(); 121 | } 122 | 123 | return false; 124 | } 125 | 126 | void UUI_CheatSheetHome::UpdateHistoryReadout(const FCheatCategory& InLastRequestedCategory) 127 | { 128 | if (Map.IsSet()) 129 | { 130 | CurrentCategory = InLastRequestedCategory; 131 | History = Map.GetValue().GetHistoryFromID(InLastRequestedCategory.GetCategoryID()); 132 | 133 | if (HistoryReadout != nullptr) 134 | { 135 | HistoryReadout->SetText(FText::FromString(GetHistoryAsString(History))); 136 | } 137 | } 138 | } 139 | 140 | FString UUI_CheatSheetHome::GetHistoryAsString(const TArray& InHistory) 141 | { 142 | FString HistoryAsString; 143 | 144 | for (const FString Category : InHistory) 145 | { 146 | HistoryAsString += FString::Printf(TEXT("/%s"), *Category); 147 | } 148 | 149 | return HistoryAsString; 150 | } 151 | -------------------------------------------------------------------------------- /Source/CheatSheetUI/Private/UI/UI_CheatView.cpp: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #include "CheatSheetUI/Public/UI/UI_CheatView.h" 4 | 5 | #include "CheatSheetUI/Public/UI/Entries/UI_CategoryEntry.h" 6 | #include "CheatSheetUI/Public/UI/Entries/UI_CheatEntry.h" 7 | 8 | #include 9 | #include 10 | 11 | DEFINE_LOG_CATEGORY_STATIC(CheatViewLog, Log, Log); 12 | 13 | UUI_CheatView::UUI_CheatView(const FObjectInitializer& ObjectInitializer) 14 | : Super(ObjectInitializer) 15 | , CategoryBox(nullptr) 16 | , CheatBox(nullptr) 17 | , CheatScrollBox(nullptr) 18 | , CheatCategoryClass(nullptr) 19 | , CheatEntryClass(nullptr) 20 | , Categories() 21 | , OnNewCategoryRequested() 22 | , OnNewSelection() 23 | , RequestCallback(nullptr) 24 | , Entries() 25 | , CurrentSelection() 26 | , CurrentSelectionIndex(0) 27 | , TotalEntries(0) 28 | {} 29 | 30 | void UUI_CheatView::NativeConstruct() 31 | { 32 | Super::NativeConstruct(); 33 | 34 | RequestCallback = [WeakThis = TWeakObjectPtr(this), this](const FCheatCategory& InRequestingCategory) 35 | { 36 | if (WeakThis.IsValid()) 37 | { 38 | RequestViewForCategory(InRequestingCategory); 39 | } 40 | }; 41 | } 42 | 43 | void UUI_CheatView::RequestViewForCategory(const FCheatCategory& InCheatCategory) 44 | { 45 | TotalEntries = 0; 46 | CurrentSelectionIndex = 0; 47 | 48 | if (CategoryBox != nullptr && CheatBox != nullptr) 49 | { 50 | if (CheatCategoryClass != nullptr && CheatEntryClass != nullptr) 51 | { 52 | CategoryBox->ClearChildren(); 53 | CheatBox->ClearChildren(); 54 | 55 | const TArray CachedCategories = InCheatCategory.GetSubCategories(); 56 | for (const FCheatCategory& Category : CachedCategories) 57 | { 58 | UUI_CategoryEntry* NewCategory = CreateWidget(this, CheatCategoryClass); 59 | NewCategory->SetCategory(Category); 60 | NewCategory->SetRequestCallback(RequestCallback); 61 | 62 | CategoryBox->AddChild(NewCategory); 63 | } 64 | 65 | const TArray CachedCheats = InCheatCategory.GetCheats(); 66 | for (const FCachedCheat& Cheat : CachedCheats) 67 | { 68 | UUI_CheatEntry* NewCheat = CreateWidget(this, CheatEntryClass); 69 | NewCheat->SetCheat(Cheat); 70 | CheatBox->AddChild(NewCheat); 71 | } 72 | } 73 | } 74 | 75 | OnNewCategoryRequested.Broadcast(InCheatCategory); 76 | 77 | ApplyEntryNumbers(); 78 | ApplyNewSelectionIndex(); 79 | } 80 | 81 | void UUI_CheatView::RequestHomeView(const TArray& InCheatCategories) 82 | { 83 | TotalEntries = 0; 84 | CurrentSelectionIndex = 0; 85 | 86 | if (CheatCategoryClass != nullptr) 87 | { 88 | if (CheatCategoryClass != nullptr && CheatEntryClass != nullptr) 89 | { 90 | CategoryBox->ClearChildren(); 91 | CheatBox->ClearChildren(); 92 | 93 | for (const FCheatCategory& Category : InCheatCategories) 94 | { 95 | UUI_CategoryEntry* NewCategory = CreateWidget(this, CheatCategoryClass); 96 | NewCategory->SetCategory(Category); 97 | NewCategory->SetRequestCallback(RequestCallback); 98 | 99 | CategoryBox->AddChild(NewCategory); 100 | } 101 | } 102 | } 103 | 104 | ApplyEntryNumbers(); 105 | ApplyNewSelectionIndex(); 106 | } 107 | 108 | void UUI_CheatView::SynchronizeProperties() 109 | { 110 | Super::SynchronizeProperties(); 111 | 112 | RequestHomeView(Categories); 113 | } 114 | 115 | void UUI_CheatView::ConfirmSelection() 116 | { 117 | if (CurrentSelection.IsValid()) 118 | { 119 | CurrentSelection->ExecuteEntry(); 120 | } 121 | } 122 | 123 | void UUI_CheatView::UpSelection() 124 | { 125 | CurrentSelectionIndex == 0 ? CurrentSelectionIndex = TotalEntries - 1 : CurrentSelectionIndex--; 126 | ApplyNewSelectionIndex(); 127 | } 128 | 129 | void UUI_CheatView::DownSelection() 130 | { 131 | CurrentSelectionIndex == TotalEntries - 1 ? CurrentSelectionIndex = 0 : CurrentSelectionIndex++; 132 | ApplyNewSelectionIndex(); 133 | } 134 | 135 | void UUI_CheatView::ApplyEntryNumbers() 136 | { 137 | if (CheatBox != nullptr && CategoryBox != nullptr) 138 | { 139 | for (int32 i = 0; i < CategoryBox->GetChildrenCount(); ++i) 140 | { 141 | UWidget* Child = CategoryBox->GetChildAt(i); 142 | if (ICheatEntryInterface* Entry = Cast(Child)) 143 | { 144 | Entry->SetEntryNumber(TotalEntries); 145 | Entries.Add(TotalEntries, Entry); 146 | 147 | TotalEntries++; 148 | } 149 | } 150 | 151 | for (int32 i = 0; i < CheatBox->GetChildrenCount(); ++i) 152 | { 153 | UWidget* Child = CheatBox->GetChildAt(i); 154 | if (ICheatEntryInterface* Entry = Cast(Child)) 155 | { 156 | Entry->SetEntryNumber(TotalEntries); 157 | Entries.Add(TotalEntries, Entry); 158 | 159 | TotalEntries++; 160 | } 161 | } 162 | } 163 | } 164 | 165 | void UUI_CheatView::ApplyNewSelectionIndex() 166 | { 167 | const TWeakInterfacePtr OldSelection = CurrentSelection; 168 | 169 | if (CurrentSelection.IsValid()) 170 | { 171 | CurrentSelection->SetIsSelected(false); 172 | } 173 | 174 | CurrentSelection = Entries[CurrentSelectionIndex]; 175 | 176 | if (CurrentSelection.IsValid()) 177 | { 178 | CurrentSelection->SetIsSelected(true); 179 | OnNewSelection.Broadcast(OldSelection, CurrentSelection); 180 | 181 | if(CheatScrollBox != nullptr) 182 | { 183 | CheatScrollBox->ScrollWidgetIntoView(&CurrentSelection->GetWidget()); 184 | } 185 | } 186 | } -------------------------------------------------------------------------------- /Source/CheatSheetUI/Public/CheatSheetUI.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include "CheatSheet/Public/CheatSheetInterface.h" 6 | 7 | #include 8 | 9 | class FCheatSheetUIModule : public IModuleInterface 10 | { 11 | public: 12 | 13 | //IModuleInterface 14 | virtual void StartupModule() override; 15 | virtual void ShutdownModule() override; 16 | //~IModuleInterface 17 | }; 18 | -------------------------------------------------------------------------------- /Source/CheatSheetUI/Public/UI/CheatEntryInterface.h: -------------------------------------------------------------------------------- 1 | // Retail Project - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include "CheatEntryInterface.generated.h" 10 | 11 | class UWidget; 12 | 13 | DECLARE_DELEGATE_OneParam(FOnCheatEntryExecuted, const FCachedCheat& /*ExecutedCheat*/); 14 | 15 | UINTERFACE() 16 | class UCheatEntryInterface : public UInterface 17 | { 18 | GENERATED_BODY() 19 | }; 20 | 21 | class ICheatEntryInterface 22 | { 23 | GENERATED_BODY() 24 | 25 | public: 26 | 27 | virtual void ExecuteEntry() = 0; 28 | virtual void SetEntryNumber(const int32 InNewNumber) = 0; 29 | virtual void SetIsSelected(const bool InNewSelection) = 0; 30 | 31 | virtual const FString GetEntryTip() const = 0; 32 | virtual bool ShouldCloseAfterExecution() const = 0; 33 | 34 | virtual UWidget& GetWidget() = 0; 35 | 36 | virtual FOnCheatEntryExecuted& GetOnCheatEntryExecuted() = 0; 37 | }; 38 | 39 | -------------------------------------------------------------------------------- /Source/CheatSheetUI/Public/UI/Entries/UI_CategoryEntry.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include "CheatSheetUI/Public/UI/Entries/UI_CheatEntryBase.h" 6 | #include 7 | 8 | #include "UI_CategoryEntry.generated.h" 9 | 10 | UCLASS(hidedropdown, MinimalAPI) 11 | class UUI_CategoryEntry : public UUI_CheatEntryBase 12 | { 13 | GENERATED_BODY() 14 | 15 | public: 16 | 17 | UUI_CategoryEntry(const FObjectInitializer& ObjectInitializer); 18 | 19 | UPROPERTY(meta = (BindWidget)) 20 | UTextBlock* NumSubCategoriesText; 21 | 22 | void SetCategory(const FCheatCategory& InCheatCategory) { Category = InCheatCategory; }; 23 | void SetRequestCallback(const TFunction& InRequestCallback) { RequestCallback = InRequestCallback; } 24 | 25 | //ICheatEntryInterface 26 | virtual void ExecuteEntry() override; 27 | //~ICheatEntryInterface 28 | 29 | protected: 30 | 31 | void NativeConstruct() override; 32 | 33 | private: 34 | 35 | FCheatCategory Category; 36 | TFunction RequestCallback; 37 | }; 38 | -------------------------------------------------------------------------------- /Source/CheatSheetUI/Public/UI/Entries/UI_CheatEntry.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include "CheatSheetUI/Public/UI/Entries/UI_CheatEntryBase.h" 6 | 7 | #include 8 | #include 9 | 10 | #include "UI_CheatEntry.generated.h" 11 | 12 | class UTextBlock; 13 | 14 | UCLASS(hidedropdown, MinimalAPI) 15 | class UUI_CheatEntry : public UUI_CheatEntryBase 16 | { 17 | GENERATED_BODY() 18 | 19 | public: 20 | 21 | UUI_CheatEntry(const FObjectInitializer& ObjectInitializer); 22 | 23 | void SetCheat(const FCachedCheat& InCheat) { Cheat = InCheat; } 24 | 25 | //ICheatEntryInterface 26 | void ExecuteEntry() override; 27 | virtual const FString GetEntryTip() const override; 28 | virtual bool ShouldCloseAfterExecution() const override { return Cheat.ShouldCloseAfterExecution; }; 29 | //~ICheatEntryInterface 30 | 31 | protected: 32 | 33 | void NativeConstruct() override; 34 | 35 | private: 36 | 37 | FCachedCheat Cheat; 38 | }; 39 | -------------------------------------------------------------------------------- /Source/CheatSheetUI/Public/UI/Entries/UI_CheatEntryBase.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "CheatSheetUI/Public/UI/CheatEntryInterface.h" 10 | 11 | #include "UI_CheatEntryBase.generated.h" 12 | 13 | UCLASS(hidedropdown, MinimalAPI, abstract) 14 | class UUI_CheatEntryBase : public UUserWidget 15 | , public ICheatEntryInterface 16 | { 17 | GENERATED_BODY() 18 | 19 | public: 20 | 21 | UUI_CheatEntryBase(const FObjectInitializer& ObjectInitializer) 22 | : Super(ObjectInitializer) 23 | , EntryNumberText(nullptr) 24 | , EntryNameText(nullptr) 25 | , SelectionBorder(nullptr) 26 | , SelectedColour(FLinearColor()) 27 | , OnCheatEntryExecuted() 28 | , EntryNumber(0) 29 | {}; 30 | 31 | UPROPERTY(meta = (BindWidget)) 32 | UTextBlock* EntryNumberText; 33 | 34 | UPROPERTY(meta = (BindWidget)) 35 | UTextBlock* EntryNameText; 36 | 37 | UPROPERTY(meta = (BindWidget)) 38 | UBorder* SelectionBorder; 39 | 40 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Selection") 41 | FLinearColor SelectedColour; 42 | 43 | //ICheatEntryInterface 44 | virtual void ExecuteEntry() override {}; 45 | virtual FOnCheatEntryExecuted& GetOnCheatEntryExecuted() override final { return OnCheatEntryExecuted; }; 46 | virtual void SetEntryNumber(const int32 InNewNumber) override final 47 | { 48 | EntryNumber = InNewNumber; 49 | 50 | if (EntryNumberText != nullptr) 51 | { 52 | EntryNumberText->SetText(FText::FromString(FString::FromInt(EntryNumber))); 53 | } 54 | } 55 | virtual void SetIsSelected(const bool InNewSelection) override final 56 | { 57 | if (SelectionBorder != nullptr) 58 | { 59 | if (InNewSelection) 60 | { 61 | SelectionBorder->SetBrushColor(SelectedColour); 62 | } 63 | else 64 | { 65 | SelectionBorder->SetBrushColor(FLinearColor(1.f, 1.f, 1.f, 0.f)); 66 | } 67 | } 68 | } 69 | virtual const FString GetEntryTip() const override { return FString(); }; 70 | virtual bool ShouldCloseAfterExecution() const override { return false; }; 71 | virtual UWidget& GetWidget() override { return *Cast(this); }; 72 | //~ICheatEntryInterface 73 | 74 | protected: 75 | 76 | FOnCheatEntryExecuted OnCheatEntryExecuted; 77 | 78 | private: 79 | 80 | int32 EntryNumber; 81 | }; 82 | -------------------------------------------------------------------------------- /Source/CheatSheetUI/Public/UI/Tips/UI_ControlTip.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include "UI_ControlTip.generated.h" 10 | 11 | class UTextBlock; 12 | 13 | UCLASS(hidedropdown, MinimalAPI) 14 | class UUI_ControlTip : public UUserWidget 15 | { 16 | GENERATED_BODY() 17 | 18 | public: 19 | 20 | UUI_ControlTip(const FObjectInitializer& ObjectInitializer); 21 | 22 | UPROPERTY(meta = (BindWidget)) 23 | UTextBlock* Action; 24 | 25 | UPROPERTY(meta = (BindWidget)) 26 | UTextBlock* Keys; 27 | 28 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Categories") 29 | FInputActionKeyMapping Mapping; 30 | 31 | void SynchronizeProperties() override; 32 | 33 | private: 34 | 35 | const FString GetChordAsString() const; 36 | }; 37 | -------------------------------------------------------------------------------- /Source/CheatSheetUI/Public/UI/Tips/UI_CurrentTooltip.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | #include "UI_CurrentTooltip.generated.h" 8 | 9 | class UTextBlock; 10 | 11 | UCLASS(hidedropdown, MinimalAPI) 12 | class UUI_CurrentTooltip: public UUserWidget 13 | { 14 | GENERATED_BODY() 15 | 16 | public: 17 | 18 | UUI_CurrentTooltip(const FObjectInitializer& ObjectInitializer); 19 | 20 | void SetTooltip(const FString& InNewTooltip); 21 | 22 | UPROPERTY(meta = (BindWidget)) 23 | UTextBlock* Tooltip; 24 | 25 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Tooltip") 26 | FString CurrentTooltip; 27 | 28 | private: 29 | 30 | void SynchronizeProperties(); 31 | }; 32 | -------------------------------------------------------------------------------- /Source/CheatSheetUI/Public/UI/UI_CheatCategory.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include "UI_CheatCategory.generated.h" 10 | 11 | class UTextBlock; 12 | 13 | UCLASS(hidedropdown, MinimalAPI) 14 | class UUI_CheatCategory : public UUserWidget 15 | { 16 | GENERATED_BODY() 17 | 18 | public: 19 | 20 | UUI_CheatCategory(const FObjectInitializer& ObjectInitializer); 21 | 22 | UPROPERTY(meta = (BindWidget)) 23 | UTextBlock* CheatCategoryNumber; 24 | 25 | UPROPERTY(meta = (BindWidget)) 26 | UTextBlock* CheatCategoryName; 27 | 28 | void SetCategory(const FCheatCategory& InCheatCategory) { Category = InCheatCategory; }; 29 | 30 | protected: 31 | 32 | void NativeConstruct() override; 33 | 34 | private: 35 | 36 | FCheatCategory Category; 37 | }; 38 | -------------------------------------------------------------------------------- /Source/CheatSheetUI/Public/UI/UI_CheatSheetHome.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include "UI_CheatSheetHome.generated.h" 11 | 12 | class USizeBox; 13 | class UUI_CurrentTooltip; 14 | class UUI_ControlTip; 15 | class UUI_CheatView; 16 | class UVerticalBox; 17 | class UTextBlock; 18 | 19 | UCLASS(hidedropdown, MinimalAPI) 20 | class UUI_CheatSheetHome : public UUserWidget 21 | { 22 | GENERATED_BODY() 23 | 24 | public: 25 | 26 | UUI_CheatSheetHome(const FObjectInitializer& ObjectInitializer); 27 | 28 | CHEATSHEETUI_API void AddMap(const CheatMap& InMap); 29 | CHEATSHEETUI_API UUI_CheatView* GetCheatView() const { return CheatView; } 30 | 31 | CHEATSHEETUI_API void InitHomeView(); 32 | 33 | CHEATSHEETUI_API void ShowPreviousCategory(); 34 | 35 | bool ShowScreenByID(const FGuid& InID); 36 | 37 | protected: 38 | 39 | UPROPERTY(meta = (BindWidget)) 40 | UUI_CheatView* CheatView; 41 | 42 | UPROPERTY(meta = (BindWidget)) 43 | UTextBlock* HistoryReadout; 44 | 45 | UPROPERTY(meta = (BindWidget)) 46 | UVerticalBox* ControlTipsBox; 47 | 48 | UPROPERTY(meta=(BindWidget)) 49 | USizeBox* InfoBox; 50 | 51 | UPROPERTY(meta = (BindWidget)) 52 | UUI_CurrentTooltip* CurrentTooltipBox; 53 | 54 | private: 55 | 56 | void UpdateHistoryReadout(const FCheatCategory& InLastRequestedCategory); 57 | static FString GetHistoryAsString(const TArray& InHistory); 58 | 59 | TOptional Map; 60 | TArray History; 61 | 62 | FCheatCategory CurrentCategory; 63 | }; 64 | -------------------------------------------------------------------------------- /Source/CheatSheetUI/Public/UI/UI_CheatView.h: -------------------------------------------------------------------------------- 1 | // CheatSheet Plugin - Tom Shinton 2019 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | 8 | #include "CheatSheetUI/Public/UI/CheatEntryInterface.h" 9 | 10 | #include "UI_CheatView.generated.h" 11 | 12 | class UScrollBox; 13 | struct FCheatCategory; 14 | 15 | class UUI_CategoryEntry; 16 | class UUI_CheatEntry; 17 | class UVerticalBox; 18 | 19 | DECLARE_EVENT_OneParam(UUI_CheatView, FOnNewCategoryRenderRequested, const FCheatCategory&) 20 | DECLARE_EVENT_TwoParams(UUI_CheatView, FOnNewSelectiom, const TWeakInterfacePtr& /*OldSelection*/, const TWeakInterfacePtr& /*NewSelection*/) 21 | 22 | UCLASS(hidedropdown, MinimalAPI) 23 | class UUI_CheatView : public UUserWidget 24 | { 25 | GENERATED_BODY() 26 | 27 | public: 28 | 29 | UUI_CheatView(const FObjectInitializer& ObjectInitializer); 30 | 31 | UPROPERTY(meta = (BindWidget)) 32 | UVerticalBox* CategoryBox; 33 | 34 | UPROPERTY(meta = (BindWidget)) 35 | UVerticalBox* CheatBox; 36 | 37 | UPROPERTY(meta = (BindWidget)) 38 | UScrollBox* CheatScrollBox; 39 | 40 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Categories") 41 | TSubclassOf CheatCategoryClass; 42 | 43 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Categories") 44 | TSubclassOf CheatEntryClass; 45 | 46 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Categories") 47 | TArray Categories; 48 | 49 | void RequestViewForCategory(const FCheatCategory& InCheatCategory); 50 | void RequestHomeView(const TArray& InCheatCategories); 51 | 52 | void SynchronizeProperties() override; 53 | 54 | CHEATSHEETUI_API void ConfirmSelection(); 55 | CHEATSHEETUI_API void UpSelection(); 56 | CHEATSHEETUI_API void DownSelection(); 57 | 58 | FOnNewCategoryRenderRequested OnNewCategoryRequested; 59 | FOnNewSelectiom OnNewSelection; 60 | 61 | protected: 62 | void NativeConstruct() override; 63 | 64 | private: 65 | 66 | void ApplyEntryNumbers(); 67 | void ApplyNewSelectionIndex(); 68 | 69 | TFunction RequestCallback; 70 | 71 | TMap> Entries; 72 | TWeakInterfacePtr CurrentSelection; 73 | int32 CurrentSelectionIndex; 74 | int32 TotalEntries; 75 | }; 76 | --------------------------------------------------------------------------------