|
@@ -278,7 +278,7 @@ void CFileUtil::EditTextureFile(const char* textureFile, [[maybe_unused]] bool b
|
|
|
// Use the Win32 API calls to open the right editor; the OS knows how to do this even better than
|
|
|
// Qt does.
|
|
|
QString fullTexturePathFixedForWindows = QString(fullTexturePath.data()).replace('/', '\\');
|
|
|
- HINSTANCE hInst = ShellExecuteW(NULL, L"open", textureEditorPath.toStdWString().c_str(), fullTexturePathFixedForWindows.toStdWString().c_str(), NULL, SW_SHOWNORMAL);
|
|
|
+ HINSTANCE hInst = ShellExecuteW(nullptr, L"open", textureEditorPath.toStdWString().c_str(), fullTexturePathFixedForWindows.toStdWString().c_str(), nullptr, SW_SHOWNORMAL);
|
|
|
failedToLaunch = ((DWORD_PTR)hInst <= 32);
|
|
|
#elif defined(AZ_PLATFORM_MAC)
|
|
|
failedToLaunch = QProcess::execute(QString("/usr/bin/open"), {"-a", gSettings.textureEditor, QString(fullTexturePath.data()) }) != 0;
|
|
@@ -331,7 +331,7 @@ bool CFileUtil::EditMayaFile(const char* filepath, const bool bExtractFromPak, c
|
|
|
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;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
@@ -347,10 +347,10 @@ bool CFileUtil::EditFile(const char* filePath, const bool bExtrackFromPak, const
|
|
|
else if ((extension.compare(".bspace") == 0) || (extension.compare(".comb") == 0))
|
|
|
{
|
|
|
EditTextFile(filePath, 0, IFileUtil::FILE_TYPE_BSPACE);
|
|
|
- return TRUE;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
- return FALSE;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
@@ -373,7 +373,7 @@ bool CFileUtil::CalculateDccFilename(const QString& assetFilename, QString& dccF
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
bool CFileUtil::ExtractDccFilenameFromAssetDatabase(const QString& assetFilename, QString& dccFilename)
|
|
|
{
|
|
|
- IAssetItemDatabase* pCurrentDatabaseInterface = NULL;
|
|
|
+ IAssetItemDatabase* pCurrentDatabaseInterface = nullptr;
|
|
|
std::vector<IClassDesc*> assetDatabasePlugins;
|
|
|
IEditorClassFactory* pClassFactory = GetIEditor()->GetClassFactory();
|
|
|
pClassFactory->GetClassesByCategory("Asset Item DB", assetDatabasePlugins);
|
|
@@ -591,7 +591,7 @@ inline bool ScanDirectoryFiles(const QString& root, const QString& path, const Q
|
|
|
|
|
|
/*
|
|
|
CFileFind finder;
|
|
|
- BOOL bWorking = finder.FindFile( Path::Make(dir,fileSpec) );
|
|
|
+ bool bWorking = finder.FindFile( Path::Make(dir,fileSpec) );
|
|
|
while (bWorking)
|
|
|
{
|
|
|
bWorking = finder.FindNextFile();
|
|
@@ -662,7 +662,7 @@ inline int ScanDirectoryRecursive(const QString& root, const QString& path, cons
|
|
|
{
|
|
|
/*
|
|
|
CFileFind finder;
|
|
|
- BOOL bWorking = finder.FindFile( Path::Make(dir,"*.*") );
|
|
|
+ bool bWorking = finder.FindFile( Path::Make(dir,"*.*") );
|
|
|
while (bWorking)
|
|
|
{
|
|
|
bWorking = finder.FindNextFile();
|
|
@@ -846,12 +846,12 @@ void BlockAndWait(const bool& opComplete, QWidget* parent, const char* message)
|
|
|
{
|
|
|
// note that 16ms below is not the amount of time to wait, its the maximum time that
|
|
|
// processEvents is allowed to keep processing them if they just keep being emitted.
|
|
|
- // adding a maximum time here means that we get an opportunity to pump the TickBus
|
|
|
+ // adding a maximum time here means that we get an opportunity to pump the TickBus
|
|
|
// periodically even during a flood of events.
|
|
|
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 16);
|
|
|
AZ::TickBus::ExecuteQueuedEvents();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// if we are not the main thread then the above will be done by the main thread, and we can just wait for it to happen.
|
|
|
// its fairly important we don't sleep for really long because this legacy code is often invoked in a blocking loop
|
|
|
// for many items, and in the worst case, any time we spend sleeping here will be added to each item.
|
|
@@ -1205,10 +1205,10 @@ bool CFileUtil::CreatePath(const QString& strPath)
|
|
|
QString strFilename;
|
|
|
QString strExtension;
|
|
|
QString strCurrentDirectoryPath;
|
|
|
- QStringList cstrDirectoryQueue;
|
|
|
+ QStringList cstrDirectoryQueue;
|
|
|
size_t nCurrentPathQueue(0);
|
|
|
size_t nTotalPathQueueElements(0);
|
|
|
- BOOL bnLastDirectoryWasCreated(FALSE);
|
|
|
+ bool bnLastDirectoryWasCreated(false);
|
|
|
|
|
|
if (PathExists(strPath))
|
|
|
{
|
|
@@ -1360,7 +1360,7 @@ IFileUtil::ECopyTreeResult CFileUtil::CopyTree(const QString& strSourceDirectory
|
|
|
nTotal = cFiles.size();
|
|
|
for (nCurrent = 0; nCurrent < nTotal; ++nCurrent)
|
|
|
{
|
|
|
- BOOL bnLastFileWasCopied(FALSE);
|
|
|
+ bool bnLastFileWasCopied(false);
|
|
|
|
|
|
|
|
|
if (eCopyResult == IFileUtil::ETREECOPYUSERCANCELED)
|
|
@@ -1446,7 +1446,7 @@ IFileUtil::ECopyTreeResult CFileUtil::CopyTree(const QString& strSourceDirectory
|
|
|
return eCopyResult;
|
|
|
}
|
|
|
|
|
|
- BOOL bnLastDirectoryWasCreated(FALSE);
|
|
|
+ bool bnLastDirectoryWasCreated(false);
|
|
|
|
|
|
QString sourceName = sourceDir.absoluteFilePath(cDirectories[nCurrent]);
|
|
|
QString targetName = targetDir.absoluteFilePath(cDirectories[nCurrent]);
|
|
@@ -1528,7 +1528,7 @@ IFileUtil::ECopyTreeResult CFileUtil::CopyFile(const QString& strSourceFile, c
|
|
|
CUserOptions oFileOptions;
|
|
|
IFileUtil::ECopyTreeResult eCopyResult(IFileUtil::ETREECOPYOK);
|
|
|
|
|
|
- BOOL bnLastFileWasCopied(FALSE);
|
|
|
+ bool bnLastFileWasCopied(false);
|
|
|
QString name(strSourceFile);
|
|
|
QString strQueryFilename;
|
|
|
QString strFullStargetName;
|
|
@@ -1657,7 +1657,7 @@ IFileUtil::ECopyTreeResult CFileUtil::CopyFile(const QString& strSourceFile, c
|
|
|
}
|
|
|
if (pfnProgress)
|
|
|
{
|
|
|
- pfnProgress(source.size(), totalRead, 0, 0, 0, 0, 0, 0, 0);
|
|
|
+ pfnProgress(source.size(), totalRead, 0, 0, 0, 0, nullptr, nullptr, nullptr);
|
|
|
}
|
|
|
}
|
|
|
if (totalRead != source.size())
|
|
@@ -1741,7 +1741,7 @@ IFileUtil::ECopyTreeResult CFileUtil::MoveTree(const QString& strSourceDirecto
|
|
|
return eCopyResult;
|
|
|
}
|
|
|
|
|
|
- BOOL bnLastFileWasCopied(FALSE);
|
|
|
+ bool bnLastFileWasCopied(false);
|
|
|
QString sourceName(sourceDir.absoluteFilePath(cFiles[nCurrent]));
|
|
|
QString targetName(targetDir.absoluteFilePath(cFiles[nCurrent]));
|
|
|
|
|
@@ -1815,7 +1815,7 @@ IFileUtil::ECopyTreeResult CFileUtil::MoveTree(const QString& strSourceDirecto
|
|
|
nTotal = cDirectories.size();
|
|
|
for (nCurrent = 0; nCurrent < nTotal; ++nCurrent)
|
|
|
{
|
|
|
- BOOL bnLastDirectoryWasCreated(FALSE);
|
|
|
+ bool bnLastDirectoryWasCreated(false);
|
|
|
|
|
|
if (eCopyResult == IFileUtil::ETREECOPYUSERCANCELED)
|
|
|
{
|
|
@@ -1899,76 +1899,25 @@ IFileUtil::ECopyTreeResult CFileUtil::MoveTree(const QString& strSourceDirecto
|
|
|
return eCopyResult;
|
|
|
}
|
|
|
|
|
|
-QString CFileUtil::PopupQMenu(const QString& filename, const QString& fullGamePath, QWidget* parent)
|
|
|
-{
|
|
|
- QStringList extraItemsFront;
|
|
|
- return PopupQMenu(filename, fullGamePath, parent, nullptr, extraItemsFront);
|
|
|
-}
|
|
|
-
|
|
|
-QString CFileUtil::PopupQMenu(const QString& filename, const QString& fullGamePath, QWidget* parent, [[maybe_unused]] bool* pIsSelected, const QStringList& extraItemsFront)
|
|
|
-{
|
|
|
- QStringList extraItemsBack;
|
|
|
- return PopupQMenu(filename, fullGamePath, parent, nullptr, extraItemsFront, extraItemsBack);
|
|
|
-}
|
|
|
-
|
|
|
-QString CFileUtil::PopupQMenu(const QString& filename, const QString& fullGamePath, QWidget* parent, bool* pIsSelected, const QStringList& extraItemsFront, const QStringList& extraItemsBack)
|
|
|
+void CFileUtil::PopulateQMenu(QWidget* caller, QMenu* menu, AZStd::string_view fullGamePath)
|
|
|
{
|
|
|
- QMenu menu;
|
|
|
-
|
|
|
- foreach(QString text, extraItemsFront)
|
|
|
- {
|
|
|
- if (!text.isEmpty())
|
|
|
- {
|
|
|
- menu.addAction(text);
|
|
|
- }
|
|
|
- }
|
|
|
- if (extraItemsFront.count())
|
|
|
- {
|
|
|
- menu.addSeparator();
|
|
|
- }
|
|
|
-
|
|
|
- PopulateQMenu(parent, &menu, filename, fullGamePath, pIsSelected);
|
|
|
- if (extraItemsBack.count())
|
|
|
- {
|
|
|
- menu.addSeparator();
|
|
|
- }
|
|
|
- foreach(QString text, extraItemsBack)
|
|
|
- {
|
|
|
- if (!text.isEmpty())
|
|
|
- {
|
|
|
- menu.addAction(text);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- QAction* result = menu.exec(QCursor::pos());
|
|
|
- return result ? result->text() : QString();
|
|
|
+ PopulateQMenu(caller, menu, fullGamePath, nullptr);
|
|
|
}
|
|
|
|
|
|
-void CFileUtil::PopulateQMenu(QWidget* caller, QMenu* menu, const QString& filename, const QString& fullGamePath)
|
|
|
+void CFileUtil::PopulateQMenu(QWidget* caller, QMenu* menu, AZStd::string_view fullGamePath, bool* isSelected)
|
|
|
{
|
|
|
- PopulateQMenu(caller, menu, filename, fullGamePath, nullptr);
|
|
|
-}
|
|
|
+ // Normalize the full path so we get consistent separators
|
|
|
+ AZStd::string fullFilePath(fullGamePath);
|
|
|
+ AzFramework::StringFunc::Path::Normalize(fullFilePath);
|
|
|
|
|
|
-void CFileUtil::PopulateQMenu(QWidget* caller, QMenu* menu, const QString& filename, const QString& fullGamePath, bool* isSelected)
|
|
|
-{
|
|
|
- QString fullPath;
|
|
|
+ QString fullPath(fullFilePath.c_str());
|
|
|
+ QFileInfo fileInfo(fullPath);
|
|
|
|
|
|
if (isSelected)
|
|
|
{
|
|
|
*isSelected = false;
|
|
|
}
|
|
|
|
|
|
- if (!filename.isEmpty())
|
|
|
- {
|
|
|
- QString path = Path::MakeGamePath(fullGamePath);
|
|
|
- path = Path::AddSlash(path) + filename;
|
|
|
- fullPath = Path::GamePathToFullPath(path);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- fullPath = fullGamePath;
|
|
|
- }
|
|
|
-
|
|
|
uint32 nFileAttr = CFileUtil::GetAttributes(fullPath.toUtf8().data());
|
|
|
|
|
|
QAction* action;
|
|
@@ -2004,21 +1953,13 @@ void CFileUtil::PopulateQMenu(QWidget* caller, QMenu* menu, const QString& filen
|
|
|
|
|
|
action = menu->addAction(QObject::tr("Copy Name To Clipboard"), [=]()
|
|
|
{
|
|
|
- if (filename.isEmpty())
|
|
|
- {
|
|
|
- QFileInfo fi(fullGamePath);
|
|
|
- QString file = fi.completeBaseName();
|
|
|
- QApplication::clipboard()->setText(file);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- QApplication::clipboard()->setText(filename);
|
|
|
- }
|
|
|
+ QString fileName = fileInfo.completeBaseName();
|
|
|
+ QApplication::clipboard()->setText(fileName);
|
|
|
});
|
|
|
|
|
|
action = menu->addAction(QObject::tr("Copy Path To Clipboard"), [fullPath]() { QApplication::clipboard()->setText(fullPath); });
|
|
|
|
|
|
- if (!filename.isEmpty() && GetIEditor()->IsSourceControlAvailable() && nFileAttr != SCC_FILE_ATTRIBUTE_INVALID)
|
|
|
+ if (fileInfo.isFile() && GetIEditor()->IsSourceControlAvailable() && nFileAttr != SCC_FILE_ATTRIBUTE_INVALID)
|
|
|
{
|
|
|
bool isEnableSC = nFileAttr & SCC_FILE_ATTRIBUTE_MANAGED;
|
|
|
bool isInPak = nFileAttr & SCC_FILE_ATTRIBUTE_INPAK;
|