3dec5d3b71
* LYN-2537 Moved the Engine and Editor folder to be within the EngineAssets folder * Fixed Documentation in bootstrap.cfg to correct the path to the user project specific registry file * Adding a newline to the output of AssetCatalog 'Registering asset..., but type is not set' message * Updating the AssetProcessorPlatformConfig.setreg Scan Folder to detect the @ENGINEROOT@/EngineAssets/Engine path for engine runtime assets and @ENGINEROOT@/EngineAssets/Editor path for engine tool assets * Updating references to Icons and other assets to account for moving the Engine and Editor folder under a single EngineAssets folder * Moving the Engine Settings Registry folder from Engine/Registry -> Registry * Removed the LY_PROJECT_CMAKE_PATH define as it is not portable to other locations. It is hard coded to the project location that was used for the CMake configuration. Furthermore it paths with backslashes within it are treated as escape characters and not a path separator * Updated the LyTestTools asset_processor.py script to copy the exclude.filetag from the EngineAssets/Engine directory now * Fixed Atom Shader Preprocessing when running using an External Project * Updated the TSGenerateAction.cpp to fix the build error with using a renamed variable * Updated the Install_Common.cmake ly_setup_others function to install the EngineAssets directory and the each of the Gem's Assets directory while maintaining the relative directory structure to the Engine Root Also updated the install step to install the Registry folder at the engine root * Fixed the copying of the Registry folder to be in the install root, instead of under a second 'Registry' folder * Moving the AssetProcessorPlatformConfig.setreg file over to the Registry folder * Updated the LyTestTools and C++ code to point that the new location of the AssetProcessorPlatformConfig.setreg file inside of the Registry folder * Renamed Test AssetProcessor*Config.ini files to have the .setreg extension * Converted the AssetProcessor test setreg files from ini format to json format using the SerializeContextTools convert-ini command * Updated the AssetProcessor CMakeLists.txt to copy over the test setreg files to the build folder * Updated the assetprocessor test file list to point at the renamed AsssetProcessor*Config setreg filenames * Removed the Output Prefix code from the AssetProcessor. The complexity that it brought to the AP code is not needed, as users can replicate the behavior by just moving there assets underneath a another folder, underneath the scan folder * Adding back support to read the AssetProcessorPlatformConfig.setreg file from the asset root. This is only needed for C++ UnitTests as they run in an environment where the accessing the Engine Settings Registry is not available * Updating the Install_common.cmake logic to copy any "Assets" folder to the install layout. The Script has also been updated to copy over the "Assets" folder in the Engine Root to the install layout instead of an "EngineAssets" folder * Updating References to EngineAssets source asset folder in code to be the Assets source folder * Moved the Engine Source Asset folder of 'EngineAssets' to a new folder name of 'Assets'. This is inline with the naming scheme we use for Gem asset folders * Adding the EngineFinder.cmake to the AutomatedTesting project to allow it to work in a project centric manner * Updating the LyTestTools copy_assets_to_project function to be able to copy assets with folders to the temporary project root Fixed an issue in LyTestTools where the temporary log directory could have shutil.rmtree being called twice on it leading to an exception which fails an automated test Updated the asset_procesor_gui_tests_2 AddScanFolder test to not use the output prefix, but instead place the source asset root into a subdirectory * Correct the AssetProcessorPlatformConfig Scan Folders for the EngineAssets directory to point at the Assets directory * Updated the asset procesor batch dependency test scan folder to point at the 'Assets' folder instead of 'EngineAssets'
166 lines
6.1 KiB
C++
166 lines
6.1 KiB
C++
/*
|
|
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
|
* its licensors.
|
|
*
|
|
* For complete copyright and license terms please see the LICENSE at the root of this
|
|
* distribution (the "License"). All use of this software is governed by the License,
|
|
* or, if provided, by the license below or the license accompanying this file. Do not
|
|
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
*
|
|
*/
|
|
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
|
|
|
#pragma once
|
|
// The aim of IResourceSelectorHost is to unify resource selection dialogs in a one
|
|
// API that can be reused with plugins. It also makes possible to register new
|
|
// resource selectors dynamically, e.g. inside plugins.
|
|
//
|
|
// Here is how new selectors are created. In your implementation file you add handler function:
|
|
//
|
|
// #include "IResourceSelectorHost.h"
|
|
//
|
|
// QString SoundFileSelector(const SResourceSelectorContext& x, const QString& previousValue)
|
|
// {
|
|
// CMyModalDialog dialog(CWnd::FromHandle(x.parentWindow));
|
|
// ...
|
|
// return previousValue;
|
|
// }
|
|
// REGISTER_RESOURCE_SELECTOR("Sound", SoundFileSelector, "Icons/sound_16x16.png")
|
|
//
|
|
// To expose it to serialization:
|
|
//
|
|
// #include "Serialization/Decorators/Resources.h"
|
|
// template<class TString>
|
|
// ResourceSelector<TString> SoundName(TString& s) { return ResourceSelector<TString>(s, "Sound"); }
|
|
//
|
|
// To use in serialization:
|
|
//
|
|
// ar(Serialization::SoundName(soundString), "soundString", "Sound String");
|
|
//
|
|
// Here is how it can be invoked directly:
|
|
//
|
|
// SResourceSelectorContext x;
|
|
// x.parentWindow = parent.GetSafeHwnd();
|
|
// x.typeName = "Sound";
|
|
// string newValue = GetIEditor()->GetResourceSelector()->SelectResource(x, previousValue).c_str();
|
|
//
|
|
// If you have your own resource selectors in the plugin you will need to run
|
|
//
|
|
// RegisterModuleResourceSelectors(GetIEditor()->GetResourceSelector())
|
|
//
|
|
// during plugin initialization.
|
|
//
|
|
// If you want to be able to pass some custom context to the selector (e.g. source of the information for the
|
|
// list of items or something similar) then you can add a poitner argument to your selector function, i.e.:
|
|
//
|
|
// QString SoundFileSelector(const SResourceSelectorContext& x, const QString& previousValue,
|
|
// SoundFileList* list) // your context argument
|
|
//
|
|
// And provide this value through serialization context:
|
|
//
|
|
// struct SourceFileList
|
|
// {
|
|
// void Serialize(IArchive& ar)
|
|
// {
|
|
// Serialization::SContext<SourceFileList> context(ar, this);
|
|
// ...
|
|
// }
|
|
// }
|
|
|
|
#include <Serialization/TypeID.h>
|
|
#include <QString>
|
|
|
|
class QWidget;
|
|
|
|
struct SResourceSelectorContext
|
|
{
|
|
const char* typeName;
|
|
|
|
// use either parentWidget or parentWindow (not both) until everything porting to QWidget.
|
|
QWidget* parentWidget;
|
|
|
|
unsigned int entityId;
|
|
void* contextObject;
|
|
Serialization::TypeID contextObjectType;
|
|
|
|
SResourceSelectorContext()
|
|
: parentWidget(0)
|
|
, typeName(0)
|
|
, entityId(0)
|
|
, contextObject()
|
|
{
|
|
}
|
|
};
|
|
|
|
// TResourceSelecitonFunction is used to declare handlers for specific types.
|
|
//
|
|
// For canceled dialogs previousValue should be returned.
|
|
typedef QString (* TResourceSelectionFunction)(const SResourceSelectorContext& selectorContext, const QString& previousValue);
|
|
typedef QString (* TResourceSelectionFunctionWithContext)(const SResourceSelectorContext& selectorContext, const QString& previousValue, void* contextObject);
|
|
|
|
struct SStaticResourceSelectorEntry;
|
|
|
|
// See note at the beginning of the file.
|
|
struct IResourceSelectorHost
|
|
{
|
|
virtual ~IResourceSelectorHost() = default;
|
|
virtual QString SelectResource(const SResourceSelectorContext& context, const QString& previousValue) = 0;
|
|
virtual const char* ResourceIconPath(const char* typeName) const = 0;
|
|
virtual Serialization::TypeID ResourceContextType(const char* typeName) const = 0;
|
|
|
|
virtual void RegisterResourceSelector(const SStaticResourceSelectorEntry* entry) = 0;
|
|
|
|
// secondary responsibility of this class is to store global selections
|
|
virtual void SetGlobalSelection(const char* resourceType, const char* value) = 0;
|
|
virtual const char* GetGlobalSelection(const char* resourceType) const = 0;
|
|
};
|
|
|
|
// ---------------------------------------------------------------------------
|
|
#define INTERNAL_RSH_COMBINE_UTIL(A, B) A##B
|
|
#define INTERNAL_RSH_COMBINE(A, B) INTERNAL_RSH_COMBINE_UTIL(A, B)
|
|
#define REGISTER_RESOURCE_SELECTOR(name, function, icon) \
|
|
static SStaticResourceSelectorEntry INTERNAL_RSH_COMBINE(selector_##function, __LINE__)((name), (function), (icon));
|
|
|
|
struct SStaticResourceSelectorEntry
|
|
{
|
|
const char* typeName;
|
|
TResourceSelectionFunction function;
|
|
TResourceSelectionFunctionWithContext functionWithContext;
|
|
const char* iconPath;
|
|
Serialization::TypeID contextType;
|
|
|
|
static SStaticResourceSelectorEntry*& GetFirst() { static SStaticResourceSelectorEntry* first; return first; }
|
|
SStaticResourceSelectorEntry* next;
|
|
|
|
SStaticResourceSelectorEntry(const char* typeName, TResourceSelectionFunction function, const char* icon)
|
|
: typeName(typeName)
|
|
, function(function)
|
|
, functionWithContext()
|
|
, iconPath(icon)
|
|
{
|
|
next = GetFirst();
|
|
GetFirst() = this;
|
|
}
|
|
|
|
template<class T>
|
|
SStaticResourceSelectorEntry(const char* typeName, QString (*function)(const SResourceSelectorContext&, const QString& previousValue, T * context), const char* icon)
|
|
: typeName(typeName)
|
|
, function()
|
|
, functionWithContext(TResourceSelectionFunctionWithContext(function))
|
|
, iconPath(icon)
|
|
{
|
|
contextType = Serialization::TypeID::get<T>();
|
|
next = GetFirst();
|
|
GetFirst() = this;
|
|
}
|
|
};
|
|
|
|
inline void RegisterModuleResourceSelectors(IResourceSelectorHost* editorResourceSelector)
|
|
{
|
|
for (SStaticResourceSelectorEntry* current = SStaticResourceSelectorEntry::GetFirst(); current != 0; current = current->next)
|
|
{
|
|
editorResourceSelector->RegisterResourceSelector(current);
|
|
}
|
|
}
|