d90a3d46a7
This set of changes enables conversions for singly-nested slices. Multiple nesting hierarchies are only partially supported at this point. Conversion is also significantly more deterministic, which makes it easier to convert single slices without needing to reconvert every slice or level that relies on it as well. Changes: - Added version of Instance::AddInstance() that takes in an alias to allow for deterministic aliases - Added a "SliceConverterEditorEntityContextComponent" that's used to specifically disable entity activation on creation. The disabling is done this way vs adding a new public API, because the disable shouldn't be required in any normal case outside of this tool. - Disabled more AWS gems for the SliceConverter, as they're unneeded and cause issues if they're around in the tool. - Added a small null check to the Camera Controller. - Added the actual support for slice instance conversion. This instantiates the entities, applies the data patches, turns them into a prefab instance, and generates a JSON patch out of the changes.
147 lines
8.6 KiB
C++
147 lines
8.6 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.
|
|
*
|
|
*/
|
|
|
|
#include <AzCore/Debug/Trace.h>
|
|
#include <AzCore/StringFunc/StringFunc.h>
|
|
#include <AzCore/Settings/CommandLine.h>
|
|
#include <Application.h>
|
|
#include <Converter.h>
|
|
#include <Dumper.h>
|
|
#include <SliceConverter.h>
|
|
|
|
|
|
void PrintHelp()
|
|
{
|
|
AZ_Printf("Help", "Serialize Context Tool\n");
|
|
AZ_Printf("Help", " <action> [-config] <action arguments>*\n");
|
|
AZ_Printf("Help", " [opt] -config=<path>: optional path to application's config file. Default is 'config/editor.xml'.\n");
|
|
AZ_Printf("Help", " [opt] -specializations=<prefix>: <comma or semicolon>-separated list of optional Registry project\n");
|
|
AZ_Printf("Help", " specializations, such as 'editor' or 'game' or 'editor;test'. Default is none. \n");
|
|
AZ_Printf("Help", "\n");
|
|
AZ_Printf("Help", " 'help': Print this help\n");
|
|
AZ_Printf("Help", " example: 'help'\n");
|
|
AZ_Printf("Help", "\n");
|
|
AZ_Printf("Help", " 'dumpfiles': Dump the content to a .dump.txt file next to the original file.\n");
|
|
AZ_Printf("Help", " [arg] -files=<path>: ;-separated list of files to verify. Supports wildcards.\n");
|
|
AZ_Printf("Help", " [opt] -output=<path>: Path to the folder to write to instead of next to the original file.\n");
|
|
AZ_Printf("Help", " example: 'dumpfiles -files=folder/*.ext;a.ext;folder/another/z.ext'\n");
|
|
AZ_Printf("Help", "\n");
|
|
AZ_Printf("Help", " 'dumpsc': Dump the content of the Serialize and Edit Context to a JSON file.\n");
|
|
AZ_Printf("Help", " [opt] -output=<path>: Path to the folder to write to instead of next to the original file.\n");
|
|
AZ_Printf("Help", " example: 'dumpsc -output=../TargetFolder/SerializeContext.json\n");
|
|
AZ_Printf("Help", "\n");
|
|
AZ_Printf("Help", " 'convert': Converts a file with an ObjectStream to the new JSON formats.\n");
|
|
AZ_Printf("Help", " [arg] -files=<path>: <comma or semicolon>-separated list of files to verify. Supports wildcards.\n");
|
|
AZ_Printf("Help", " [arg] -ext=<string>: Extension to use for the new file.\n");
|
|
AZ_Printf("Help", " [opt] -dryrun: Processes as normal, but doesn't write files.\n");
|
|
AZ_Printf("Help", " [opt] -skipverify: After conversion the result will not be compared to the original.\n");
|
|
AZ_Printf("Help", " [opt] -keepdefaults: Fields are written if a default value was found.\n");
|
|
AZ_Printf("Help", " [opt] -json-prefix=<prefix>: JSON pointer path prefix to anchor the JSON output underneath.\n");
|
|
AZ_Printf("Help", " On Windows the <prefix> should be in quotes, as \"/\" is treated as command option prefix\n");
|
|
AZ_Printf("Help", " [opt] -json-prefix=prefix: Json pointer path prefix to use as a \"root\" for settings.\n");
|
|
AZ_Printf("Help", " [opt] -verbose: Report additional details during the conversion process.\n");
|
|
AZ_Printf("Help", " example: 'convert -file=*.slice;*.uislice -ext=slice2\n");
|
|
AZ_Printf("Help", "\n");
|
|
AZ_Printf("Help", " 'convertad': Converts an Application Descriptor to the new JSON formats.\n");
|
|
AZ_Printf("Help", " [opt] -dryrun: Processes as normal, but doesn't write files.\n");
|
|
AZ_Printf("Help", " [opt] -skipgems: No module entities will be converted and no data will be written to gems.\n");
|
|
AZ_Printf("Help", " [opt] -skipsystem: No system information is converted and no data will be written to the game registry.\n");
|
|
AZ_Printf("Help", " [opt] -keepdefaults: Fields are written if a default value was found.\n");
|
|
AZ_Printf("Help", " [opt] -json-prefix=<prefix>: JSON pointer path prefix to anchor the JSON output underneath.\n");
|
|
AZ_Printf("Help", " On Windows the <prefix> should be in quotes, as \"/\" is treated as command option prefix\n");
|
|
AZ_Printf("Help", " [opt] -verbose: Report additional details during the conversion process.\n");
|
|
AZ_Printf("Help", " [opt] -regset <setreg_key>=<setreg_value>: Set setreg_value at key setreg_key within the settings registry.\n");
|
|
AZ_Printf("Help", " This can be used for example to override the Active Game Project in the settings registry.\n");
|
|
AZ_Printf("Help", " instead of using the project_path value from the bootstrap.cfg.\n");
|
|
AZ_Printf("Help", R"( Ex. -regset "/Amazon/AzCore/Bootstrap/project_path=AutomatedTesting"\n)");
|
|
AZ_Printf("Help", " This sets the active game project as AutomatedTesting, overrideing the value in the bootstrap.cfg\n");
|
|
AZ_Printf("Help", " example: 'convertad -config=config/game.xml -dryrun\n");
|
|
AZ_Printf("Help", R"( 'convert-ini': Converts windows-style INI file to a json format file.)" "\n");
|
|
AZ_Printf("Help", R"( The converted file is suitable for being loaded into the Settings Registry.)" "\n");
|
|
AZ_Printf("Help", R"( Can be used to convert .cfg/.ini files.)" "\n");
|
|
AZ_Printf("Help", R"( [arg] -files=<path...>: <comma or semicolon>-separated list of files to verify. Supports wildcards.)" "\n");
|
|
AZ_Printf("Help", R"( [opt] -ext=<string>: Extension to use for the new files. default=setreg)" "\n");
|
|
AZ_Printf("Help", R"( [opt] -dryrun: Processes as normal, but doesn't write files.)" "\n");
|
|
AZ_Printf("Help", R"( [opt] -json-prefix=<prefix>: JSON pointer path prefix to anchor the JSON output underneath.)" "\n");
|
|
AZ_Printf("Help", R"( On Windows the <prefix> should be in quotes, as \"/\" is treated as command option prefix)" "\n");
|
|
AZ_Printf("Help", R"( [opt] -verbose: Report additional details during the conversion process.)" "\n");
|
|
AZ_Printf("Help", R"( example: 'convert-ini --files=AssetProcessorPlatformConfig.ini;bootstrap.cfg --ext=setreg)" "\n");
|
|
AZ_Printf("Help", " 'convert-slice': Converts ObjectStream-based slice files or legacy levels to a JSON-based prefab.\n");
|
|
AZ_Printf("Help", " [arg] -files=<path>: <comma or semicolon>-separated list of files to convert. Supports wildcards.\n");
|
|
AZ_Printf("Help", " [opt] -dryrun: Processes as normal, but doesn't write files.\n");
|
|
AZ_Printf("Help", " [opt] -keepdefaults: Fields are written if a default value was found.\n");
|
|
AZ_Printf("Help", " [opt] -verbose: Report additional details during the conversion process.\n");
|
|
AZ_Printf("Help", " example: 'convert-slice -files=*.slice -specializations=editor\n");
|
|
AZ_Printf("Help", " example: 'convert-slice -files=Levels/TestLevel/TestLevel.ly -specializations=editor\n");
|
|
AZ_Printf("Help", "\n");
|
|
}
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
using namespace AZ::SerializeContextTools;
|
|
|
|
bool result = false;
|
|
Application application(argc, argv);
|
|
AZ::ComponentApplication::StartupParameters startupParameters;
|
|
application.Start({}, startupParameters);
|
|
|
|
const AZ::CommandLine* commandLine = application.GetAzCommandLine();
|
|
if (commandLine->GetNumMiscValues() < 1)
|
|
{
|
|
PrintHelp();
|
|
result = true;
|
|
}
|
|
else
|
|
{
|
|
const AZStd::string& action = commandLine->GetMiscValue(0);
|
|
if (AZ::StringFunc::Equal("dumpfiles", action.c_str()))
|
|
{
|
|
result = Dumper::DumpFiles(application);
|
|
}
|
|
else if (AZ::StringFunc::Equal("dumpsc", action.c_str()))
|
|
{
|
|
result = Dumper::DumpSerializeContext(application);
|
|
}
|
|
else if (AZ::StringFunc::Equal("convert", action.c_str()))
|
|
{
|
|
result = Converter::ConvertObjectStreamFiles(application);
|
|
}
|
|
else if (AZ::StringFunc::Equal("convertad", action.c_str()))
|
|
{
|
|
result = Converter::ConvertApplicationDescriptor(application);
|
|
}
|
|
else if (AZ::StringFunc::Equal("convert-ini", action.c_str()))
|
|
{
|
|
result = Converter::ConvertConfigFile(application);
|
|
}
|
|
else if (AZ::StringFunc::Equal("convert-slice", action.c_str()))
|
|
{
|
|
SliceConverter sliceConverter;
|
|
result = sliceConverter.ConvertSliceFiles(application);
|
|
}
|
|
else
|
|
{
|
|
PrintHelp();
|
|
result = true;
|
|
}
|
|
}
|
|
|
|
if (!result)
|
|
{
|
|
AZ_Printf("SerializeContextTools", "Processing didn't complete fully as problems were encountered.\n");
|
|
}
|
|
|
|
application.Destroy();
|
|
|
|
return result ? 0 : -1;
|
|
}
|