[LYN-8041] Enable relocation of the Project Game Release Layout (#5380)
* Enable relocation of the Project Game Release Layout Relocating the Project Game Release Layout to another directory on the file system failed due to the querying of the engine root failing due to the ComponentApplication::m_engineRoot not using the project path stored in the SettingsRegisry if the engine root cannot be detected Removed the ApplicationRequestBus GetEngineRoot function. The ComponentApplicationRequestBus has a function of the same name that returns the same path. Removed the deprecated GetAppRoot function. The path it returns has no defined value. It was not the engine root or the project root. Removed unused CFileUtil and CFileUtil_impl functions that were invoking the ApplicationREquestBus GetEngineRoot function. On the way to update the functions it was discovered that they aren't called Added a CalculateBranchToken overload that can populate a fixed_string to avoid heap allocations Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Protect against an empty list of artifacts to remove when generating the engine.pak Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
d053a03b5f
commit
5fc4551ac0
@@ -23,9 +23,9 @@
|
||||
// AzCore
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
// AzFramework
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
|
||||
// AzQtComponents
|
||||
#include <AzQtComponents/Utilities/DesktopUtilities.h>
|
||||
@@ -62,84 +62,6 @@ CAutoRestorePrimaryCDRoot::~CAutoRestorePrimaryCDRoot()
|
||||
QDir::setCurrent(GetIEditor()->GetPrimaryCDFolder());
|
||||
}
|
||||
|
||||
bool CFileUtil::CompileLuaFile(const char* luaFilename)
|
||||
{
|
||||
QString luaFile = luaFilename;
|
||||
|
||||
if (luaFile.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if this file is in Archive.
|
||||
{
|
||||
CCryFile file;
|
||||
if (file.Open(luaFilename, "rb"))
|
||||
{
|
||||
// Check if in pack.
|
||||
if (file.IsInPak())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
luaFile = Path::GamePathToFullPath(luaFilename);
|
||||
|
||||
// First try compiling script and see if it have any errors.
|
||||
QString LuaCompiler;
|
||||
QString CompilerOutput;
|
||||
|
||||
// Create the filepath of the lua compiler
|
||||
QString szExeFileName = qApp->applicationFilePath();
|
||||
QString exePath = Path::GetPath(szExeFileName);
|
||||
|
||||
#if defined(AZ_PLATFORM_WINDOWS)
|
||||
const char* luaCompiler = "LuaCompiler.exe";
|
||||
#else
|
||||
const char* luaCompiler = "lua";
|
||||
#endif
|
||||
LuaCompiler = Path::AddPathSlash(exePath) + luaCompiler + " ";
|
||||
|
||||
AZStd::string path = luaFile.toUtf8().data();
|
||||
EBUS_EVENT(AzFramework::ApplicationRequests::Bus, NormalizePath, path);
|
||||
|
||||
QString finalPath = path.c_str();
|
||||
finalPath = "\"" + finalPath + "\"";
|
||||
|
||||
// Add the name of the Lua file
|
||||
QString cmdLine = LuaCompiler + finalPath;
|
||||
|
||||
// Execute the compiler and capture the output
|
||||
if (!GetIEditor()->ExecuteConsoleApp(cmdLine, CompilerOutput))
|
||||
{
|
||||
QMessageBox::critical(QApplication::activeWindow(), QString(), QObject::tr("Error while executing '%1', make sure the file is in" \
|
||||
" your Primary CD folder !").arg(luaCompiler));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check return string
|
||||
if (!CompilerOutput.isEmpty())
|
||||
{
|
||||
// Errors while compiling file.
|
||||
|
||||
// Show output from Lua compiler
|
||||
if (QMessageBox::critical(QApplication::activeWindow(), QObject::tr("Lua Compiler"),
|
||||
QObject::tr("Error output from Lua compiler:\r\n%1\r\nDo you want to edit the file ?").arg(CompilerOutput), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
|
||||
{
|
||||
int line = 0;
|
||||
int index = CompilerOutput.indexOf("at line");
|
||||
if (index >= 0)
|
||||
{
|
||||
azsscanf(CompilerOutput.mid(index).toUtf8().data(), "at line %d", &line);
|
||||
}
|
||||
// Open the Lua file for editing
|
||||
EditTextFile(luaFile.toUtf8().data(), line);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CFileUtil::ExtractFile(QString& file, bool bMsgBoxAskForExtraction, const char* pDestinationFilename)
|
||||
{
|
||||
@@ -205,7 +127,7 @@ void CFileUtil::EditTextFile(const char* txtFile, int line, IFileUtil::ETextFile
|
||||
{
|
||||
QString file = txtFile;
|
||||
|
||||
QString fullPathName = Path::GamePathToFullPath(file);
|
||||
QString fullPathName = Path::GamePathToFullPath(file);
|
||||
ExtractFile(fullPathName);
|
||||
QString cmd(fullPathName);
|
||||
#if defined (AZ_PLATFORM_WINDOWS)
|
||||
@@ -301,64 +223,6 @@ void CFileUtil::EditTextureFile(const char* textureFile, [[maybe_unused]] bool b
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CFileUtil::EditMayaFile(const char* filepath, const bool bExtractFromPak, const bool bUseGameFolder)
|
||||
{
|
||||
QString dosFilepath = PathUtil::ToDosPath(filepath).c_str();
|
||||
if (bExtractFromPak)
|
||||
{
|
||||
ExtractFile(dosFilepath);
|
||||
}
|
||||
|
||||
if (bUseGameFolder)
|
||||
{
|
||||
const QString sGameFolder = Path::GetEditingGameDataFolder().c_str();
|
||||
int nLength = sGameFolder.toUtf8().count();
|
||||
if (azstrnicmp(filepath, sGameFolder.toUtf8().data(), nLength) != 0)
|
||||
{
|
||||
dosFilepath = sGameFolder + '\\' + filepath;
|
||||
}
|
||||
|
||||
dosFilepath = PathUtil::ToDosPath(dosFilepath.toUtf8().data()).c_str();
|
||||
}
|
||||
|
||||
const char* engineRoot;
|
||||
EBUS_EVENT_RESULT(engineRoot, AzFramework::ApplicationRequests::Bus, GetEngineRoot);
|
||||
|
||||
const QString fullPath = QString(engineRoot) + '\\' + dosFilepath;
|
||||
|
||||
if (gSettings.animEditor.isEmpty())
|
||||
{
|
||||
AzQtComponents::ShowFileOnDesktop(fullPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!QProcess::startDetached(gSettings.animEditor, { fullPath }))
|
||||
{
|
||||
CryMessageBox("Can't open the file. You can specify a source editor in Sandbox Preferences or create an association in Windows.", "Cannot open file!", MB_OK | MB_ICONERROR);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CFileUtil::EditFile(const char* filePath, const bool bExtrackFromPak, const bool bUseGameFolder)
|
||||
{
|
||||
QString extension = filePath;
|
||||
extension.remove(0, extension.lastIndexOf('.'));
|
||||
|
||||
if (extension.compare(".ma") == 0)
|
||||
{
|
||||
return EditMayaFile(filePath, bExtrackFromPak, bUseGameFolder);
|
||||
}
|
||||
else if ((extension.compare(".bspace") == 0) || (extension.compare(".comb") == 0))
|
||||
{
|
||||
EditTextFile(filePath, 0, IFileUtil::FILE_TYPE_BSPACE);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CFileUtil::CalculateDccFilename(const QString& assetFilename, QString& dccFilename)
|
||||
|
||||
Reference in New Issue
Block a user