Files
UnrealEngineUWP/Engine/Source/Editor/GameProjectGeneration/Private/GameProjectGenerationModule.cpp
Jamie Dale 55c3728d11 Added support for showing game and engine classes in the Content Browser
UE-7184 - Show game c++ classes and engine c++ classes in the content browser

The Content Browser now has extra entries for "Game C++ Classes" and "Engine C++ Classes" (with "Game" and "Engine" being renamed to "Game Content" and "Engine Content" respectively). These new folders serve as hosts for the list of available C++ modules, with each module internally mirroring the folder structure on disk.

For example:
- Game C++ Classes
    - ShooterGame
        - Classes
            - Bots
                - ShooterBot
                - ShooterAIController
                - [...]
            - [...]

The Content Browser allows you to navigate and search these classes like you can with assets, and provides convenient access to either edit an existing class, or create a new class (either within a selected folder, or derived from a selected class).

As the Content Browser only shows you known UClass types, any new classes need to be compiled into a loaded module before they will appear. This means that adding a new class will now automatically hot-reload your target module. Should you prefer to handle building and loading your modules manually, you can disable the automatic hot-reload via "Editor Settings" -> "Miscellaneous" -> "Hot Reload" -> "Automatically Hot Reload New Classes" (see UEditorUserSettings::bAutomaticallyHotReloadNewClasses).

[CL 2409386 by Jamie Dale in Main branch]
2015-01-16 15:39:47 -05:00

164 lines
5.7 KiB
C++

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "GameProjectGenerationPrivatePCH.h"
#include "ModuleManager.h"
#include "GameProjectGenerationModule.h"
#include "TemplateCategory.h"
#include "SourceCodeNavigation.h"
IMPLEMENT_MODULE( FGameProjectGenerationModule, GameProjectGeneration );
DEFINE_LOG_CATEGORY(LogGameProjectGeneration);
#define LOCTEXT_NAMESPACE "GameProjectGeneration"
FName FTemplateCategory::BlueprintCategoryName = "Blueprint";
FName FTemplateCategory::CodeCategoryName = "C++";
void FGameProjectGenerationModule::StartupModule()
{
RegisterTemplateCategory(
FTemplateCategory::BlueprintCategoryName,
LOCTEXT("BlueprintCategory_Name", "Blueprint"),
LOCTEXT("BlueprintCategory_Description", "Blueprint templates require no programming knowledge.\nAll game mechanics can be implemented using Blueprint visual scripting.\nEach template includes a basic set of blueprints to use as a starting point for your game."),
FEditorStyle::GetBrush("GameProjectDialog.BlueprintIcon"),
FEditorStyle::GetBrush("GameProjectDialog.BlueprintImage"));
RegisterTemplateCategory(
FTemplateCategory::CodeCategoryName,
LOCTEXT("CodeCategory_Name", "C++"),
FText::Format(
LOCTEXT("CodeCategory_Description", "C++ templates offer a good example of how to work with some of the core concepts of the Engine from code.\nYou still have the option of adding your own blueprints to the project at a later date if you want.\nChoosing this template type requires you to have {0} installed."),
FSourceCodeNavigation::GetSuggestedSourceCodeIDE()
),
FEditorStyle::GetBrush("GameProjectDialog.CodeIcon"),
FEditorStyle::GetBrush("GameProjectDialog.CodeImage"));
}
void FGameProjectGenerationModule::ShutdownModule()
{
}
TSharedRef<class SWidget> FGameProjectGenerationModule::CreateGameProjectDialog(bool bAllowProjectOpening, bool bAllowProjectCreate)
{
return SNew(SGameProjectDialog)
.AllowProjectOpening(bAllowProjectOpening)
.AllowProjectCreate(bAllowProjectCreate);
}
TSharedRef<class SWidget> FGameProjectGenerationModule::CreateNewClassDialog(const UClass* InClass)
{
return SNew(SNewClassDialog).Class(InClass);
}
void FGameProjectGenerationModule::OpenAddCodeToProjectDialog(const TSharedPtr<SWindow>& InParentWindow)
{
GameProjectUtils::OpenAddCodeToProjectDialog(nullptr, FString(), InParentWindow);
AddCodeToProjectDialogOpenedEvent.Broadcast();
}
void FGameProjectGenerationModule::OpenAddCodeToProjectDialog(const UClass* InClass, const FString& InInitialPath, const TSharedPtr<SWindow>& InParentWindow)
{
GameProjectUtils::OpenAddCodeToProjectDialog(InClass, InInitialPath, InParentWindow);
AddCodeToProjectDialogOpenedEvent.Broadcast();
}
void FGameProjectGenerationModule::TryMakeProjectFileWriteable(const FString& ProjectFile)
{
GameProjectUtils::TryMakeProjectFileWriteable(ProjectFile);
}
void FGameProjectGenerationModule::CheckForOutOfDateGameProjectFile()
{
GameProjectUtils::CheckForOutOfDateGameProjectFile();
}
bool FGameProjectGenerationModule::UpdateGameProject(const FString& ProjectFile, const FString& EngineIdentifier, FText& OutFailReason)
{
return GameProjectUtils::UpdateGameProject(ProjectFile, EngineIdentifier, OutFailReason);
}
bool FGameProjectGenerationModule::UpdateCodeProject(FText& OutFailReason)
{
FScopedSlowTask SlowTask(0, LOCTEXT( "UpdatingCodeProject", "Updating code project..." ) );
SlowTask.MakeDialog();
return GameProjectUtils::GenerateCodeProjectFiles(FPaths::GetProjectFilePath(), OutFailReason);
}
bool FGameProjectGenerationModule::GenerateBasicSourceCode(TArray<FString>& OutCreatedFiles, FText& OutFailReason)
{
return GameProjectUtils::GenerateBasicSourceCode(OutCreatedFiles, OutFailReason);
}
bool FGameProjectGenerationModule::ProjectHasCodeFiles()
{
return GameProjectUtils::ProjectHasCodeFiles();
}
FString FGameProjectGenerationModule::DetermineModuleIncludePath(const FModuleContextInfo& ModuleInfo, const FString& FileRelativeTo)
{
return GameProjectUtils::DetermineModuleIncludePath(ModuleInfo, FileRelativeTo);
}
TArray<FModuleContextInfo> FGameProjectGenerationModule::GetCurrentProjectModules()
{
return GameProjectUtils::GetCurrentProjectModules();
}
bool FGameProjectGenerationModule::IsValidBaseClassForCreation(const UClass* InClass, const FModuleContextInfo& InModuleInfo)
{
return GameProjectUtils::IsValidBaseClassForCreation(InClass, InModuleInfo);
}
bool FGameProjectGenerationModule::IsValidBaseClassForCreation(const UClass* InClass, const TArray<FModuleContextInfo>& InModuleInfoArray)
{
return GameProjectUtils::IsValidBaseClassForCreation(InClass, InModuleInfoArray);
}
void FGameProjectGenerationModule::GetProjectSourceDirectoryInfo(int32& OutNumFiles, int64& OutDirectorySize)
{
GameProjectUtils::GetProjectSourceDirectoryInfo(OutNumFiles, OutDirectorySize);
}
void FGameProjectGenerationModule::CheckAndWarnProjectFilenameValid()
{
GameProjectUtils::CheckAndWarnProjectFilenameValid();
}
void FGameProjectGenerationModule::UpdateSupportedTargetPlatforms(const FName& InPlatformName, const bool bIsSupported)
{
GameProjectUtils::UpdateSupportedTargetPlatforms(InPlatformName, bIsSupported);
}
void FGameProjectGenerationModule::ClearSupportedTargetPlatforms()
{
GameProjectUtils::ClearSupportedTargetPlatforms();
}
bool FGameProjectGenerationModule::RegisterTemplateCategory(FName Type, FText Name, FText Description, const FSlateBrush* Icon, const FSlateBrush* Image)
{
if (TemplateCategories.Contains(Type))
{
return false;
}
FTemplateCategory Category = { Name, Description, Icon, Image, Type };
TemplateCategories.Add(Type, MakeShareable(new FTemplateCategory(Category)));
return true;
}
void FGameProjectGenerationModule::UnRegisterTemplateCategory(FName Type)
{
TemplateCategories.Remove(Type);
}
#undef LOCTEXT_NAMESPACE