b1c82fc045
* Updated references to Engine.pak to be lowercase engine.pak This makes the engine.pak file consistent with naming scheme of other pak files such as assets.pak. It will also help avoid issues with mounting the file on Linux. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Engine.pak now loads correctly in release builds. The check for the file existing was failing in release builds because it was only checking inside packs. OpenPack first checks if the file exists, anyways, so it was safe to remove. Signed-off-by: stankowi <4838196+AMZN-stankowi@users.noreply.github.com> Co-authored-by: stankowi <4838196+AMZN-stankowi@users.noreply.github.com>
126 lines
5.8 KiB
C++
126 lines
5.8 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
|
|
#include "GameApplication.h"
|
|
#include <AzCore/IO/Path/Path.h>
|
|
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
|
#include <AzCore/Utils/Utils.h>
|
|
|
|
#include <AzFramework/Archive/Archive.h>
|
|
#include <AzFramework/TargetManagement/TargetManagementComponent.h>
|
|
#include <AzGameFramework/AzGameFrameworkModule.h>
|
|
|
|
namespace AzGameFramework
|
|
{
|
|
GameApplication::GameApplication()
|
|
{
|
|
}
|
|
|
|
GameApplication::GameApplication(int argc, char** argv)
|
|
: Application(&argc, &argv)
|
|
{
|
|
// In the Launcher Applications the Settings Registry
|
|
// can read from the FileIOBase instance if available
|
|
m_settingsRegistry->SetUseFileIO(true);
|
|
|
|
// Attempt to mount the engine pak from the Executable Directory
|
|
// at the Assets alias, otherwise to attempting to mount the engine pak
|
|
// from the Cache folder
|
|
AZ::IO::FixedMaxPath enginePakPath = AZ::Utils::GetExecutableDirectory();
|
|
enginePakPath /= "engine.pak";
|
|
if (!m_archive->OpenPack("@assets@", enginePakPath.Native()))
|
|
{
|
|
enginePakPath.clear();
|
|
if (m_settingsRegistry->Get(enginePakPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_CacheRootFolder))
|
|
{
|
|
// fall back to checking Project Cache Root.
|
|
enginePakPath /= "engine.pak";
|
|
m_archive->OpenPack("@assets@", enginePakPath.Native());
|
|
}
|
|
}
|
|
}
|
|
|
|
GameApplication::~GameApplication()
|
|
{
|
|
}
|
|
|
|
void GameApplication::StartCommon(AZ::Entity* systemEntity)
|
|
{
|
|
AzFramework::Application::StartCommon(systemEntity);
|
|
}
|
|
|
|
void GameApplication::MergeSettingsToRegistry(AZ::SettingsRegistryInterface& registry)
|
|
{
|
|
AZ::SettingsRegistryInterface::Specializations specializations;
|
|
Application::SetSettingsRegistrySpecializations(specializations);
|
|
specializations.Append("game");
|
|
|
|
AZStd::vector<char> scratchBuffer;
|
|
|
|
#if defined(AZ_DEBUG_BUILD) || defined(AZ_PROFILE_BUILD)
|
|
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_O3deUserRegistry(registry, AZ_TRAIT_OS_PLATFORM_CODENAME, specializations, &scratchBuffer);
|
|
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(registry, m_commandLine, false);
|
|
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_ProjectUserRegistry(registry, AZ_TRAIT_OS_PLATFORM_CODENAME, specializations, &scratchBuffer);
|
|
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(registry, m_commandLine, false);
|
|
#endif
|
|
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(registry);
|
|
|
|
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_TargetBuildDependencyRegistry(registry, AZ_TRAIT_OS_PLATFORM_CODENAME, specializations, &scratchBuffer);
|
|
|
|
#if AZ_TRAIT_OS_IS_HOST_OS_PLATFORM && (defined (AZ_DEBUG_BUILD) || defined(AZ_PROFILE_BUILD))
|
|
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_EngineRegistry(registry, AZ_TRAIT_OS_PLATFORM_CODENAME, specializations, &scratchBuffer);
|
|
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_GemRegistries(registry, AZ_TRAIT_OS_PLATFORM_CODENAME, specializations, &scratchBuffer);
|
|
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_ProjectRegistry(registry, AZ_TRAIT_OS_PLATFORM_CODENAME, specializations, &scratchBuffer);
|
|
#endif
|
|
|
|
// Used the lowercase the platform name since the bootstrap.game.<config>.<platform>.setreg is being loaded
|
|
// from the asset cache root where all the files are in lowercased from regardless of the filesystem case-sensitivity
|
|
static constexpr char filename[] = "bootstrap.game." AZ_BUILD_CONFIGURATION_TYPE "." AZ_TRAIT_OS_PLATFORM_CODENAME_LOWER ".setreg";
|
|
|
|
AZ::IO::FixedMaxPath cacheRootPath;
|
|
if (registry.Get(cacheRootPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_CacheRootFolder))
|
|
{
|
|
cacheRootPath /= filename;
|
|
registry.MergeSettingsFile(cacheRootPath.Native(), AZ::SettingsRegistryInterface::Format::JsonMergePatch, "", &scratchBuffer);
|
|
}
|
|
|
|
#if defined(AZ_DEBUG_BUILD) || defined(AZ_PROFILE_BUILD)
|
|
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_O3deUserRegistry(registry, AZ_TRAIT_OS_PLATFORM_CODENAME, specializations, &scratchBuffer);
|
|
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(registry, m_commandLine, false);
|
|
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_ProjectUserRegistry(registry, AZ_TRAIT_OS_PLATFORM_CODENAME, specializations, &scratchBuffer);
|
|
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(registry, m_commandLine, true);
|
|
#endif
|
|
// Update the Runtime file paths in case the "{BootstrapSettingsRootKey}/assets" key was overriden by a setting registry
|
|
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(registry);
|
|
}
|
|
|
|
AZ::ComponentTypeList GameApplication::GetRequiredSystemComponents() const
|
|
{
|
|
AZ::ComponentTypeList components = Application::GetRequiredSystemComponents();
|
|
|
|
#if !defined(_RELEASE)
|
|
components.emplace_back(azrtti_typeid<AzFramework::TargetManagementComponent>());
|
|
#endif
|
|
|
|
return components;
|
|
}
|
|
|
|
void GameApplication::CreateStaticModules(AZStd::vector<AZ::Module*>& outModules)
|
|
{
|
|
AzFramework::Application::CreateStaticModules(outModules);
|
|
|
|
outModules.emplace_back(aznew AzGameFrameworkModule());
|
|
}
|
|
|
|
void GameApplication::QueryApplicationType(AZ::ApplicationTypeQuery& appType) const
|
|
{
|
|
appType.m_maskValue = AZ::ApplicationTypeQuery::Masks::Game;
|
|
};
|
|
|
|
} // namespace AzGameFramework
|