Merging latest origin

This commit is contained in:
karlberg
2021-05-07 16:28:11 -07:00
141 changed files with 2843 additions and 1178 deletions
@@ -124,131 +124,29 @@ namespace AssetProcessor
NativeLegacyRCCompiler::NativeLegacyRCCompiler()
: m_resourceCompilerInitialized(false)
, m_systemRoot()
, m_rcExecutableFullPath()
, m_requestedQuit(false)
{
}
bool NativeLegacyRCCompiler::Initialize(const QString& systemRoot, const QString& rcExecutableFullPath)
bool NativeLegacyRCCompiler::Initialize()
{
// QFile::exists(normalizedPath)
if (!QDir(systemRoot).exists())
{
AZ_TracePrintf(AssetProcessor::DebugChannel, QString("Cannot locate system root dir %1").arg(systemRoot).toUtf8().data());
return false;
}
if (!AZ::IO::SystemFile::Exists(rcExecutableFullPath.toUtf8().data()))
{
AZ_TracePrintf(AssetProcessor::DebugChannel, QString("Invalid executable path '%1'").arg(rcExecutableFullPath).toUtf8().data());
return false;
}
this->m_systemRoot.setPath(systemRoot);
this->m_rcExecutableFullPath = rcExecutableFullPath;
this->m_resourceCompilerInitialized = true;
return true;
}
bool NativeLegacyRCCompiler::Execute(const QString& inputFile, const QString& watchFolder, const QString& platformIdentifier,
const QString& params, const QString& dest, const AssetBuilderSDK::JobCancelListener* jobCancelListener, Result& result) const
bool NativeLegacyRCCompiler::Execute(
[[maybe_unused]] const QString& inputFile,
[[maybe_unused]] const QString& watchFolder,
[[maybe_unused]] const QString& platformIdentifier,
[[maybe_unused]] const QString& params,
[[maybe_unused]] const QString& dest,
[[maybe_unused]] const AssetBuilderSDK::JobCancelListener* jobCancelListener,
[[maybe_unused]] Result& result) const
{
if (!this->m_resourceCompilerInitialized)
{
result.m_exitCode = JobExitCode_RCCouldNotBeLaunched;
result.m_crashed = false;
AZ_Warning("RC Builder", false, "RC Compiler has not been initialized before use.");
return false;
}
// running RC.EXE is deprecated.
AZ_Error("RC Builder", false, "running RC.EXE is deprecated");
// build the command line:
QString commandString = NativeLegacyRCCompiler::BuildCommand(inputFile, watchFolder, platformIdentifier, params, dest);
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
// while it might be tempting to set the executable in processLaunchInfo.m_processExecutableString, it turns out that RC.EXE
// won't work if you do that because it assumes the first command line param is the exe name, which is not the case if you do it that way...
QString formatter("\"%1\" %2");
processLaunchInfo.m_commandlineParameters = QString(formatter).arg(m_rcExecutableFullPath).arg(commandString).toUtf8().data();
processLaunchInfo.m_showWindow = false;
processLaunchInfo.m_workingDirectory = m_systemRoot.absolutePath().toUtf8().data();
processLaunchInfo.m_processPriority = AzFramework::ProcessPriority::PROCESSPRIORITY_IDLE;
AZ_TracePrintf("RC Builder", "Executing RC.EXE: '%s' ...\n", processLaunchInfo.m_commandlineParameters.c_str());
AZ_TracePrintf("Rc Builder", "Executing RC.EXE with working directory: '%s' ...\n", processLaunchInfo.m_workingDirectory.c_str());
AzFramework::ProcessWatcher* watcher = AzFramework::ProcessWatcher::LaunchProcess(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT);
if (!watcher)
{
result.m_exitCode = JobExitCode_RCCouldNotBeLaunched;
result.m_crashed = false;
AZ_Error("RC Builder", false, "RC failed to execute\n");
return false;
}
QElapsedTimer ticker;
ticker.start();
// it created the process, wait for it to exit:
bool finishedOK = false;
{
CommunicatorTracePrinter tracer(watcher->GetCommunicator(), "RC Builder"); // allow this to go out of scope...
while ((!m_requestedQuit) && (!finishedOK))
{
AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(NativeLegacyRCCompiler::s_maxSleepTime));
tracer.Pump();
if (ticker.elapsed() > s_jobMaximumWaitTime || (jobCancelListener && jobCancelListener->IsCancelled()))
{
break;
}
AZ::u32 exitCode = 0;
if (!watcher->IsProcessRunning(&exitCode))
{
finishedOK = true; // we either cant wait for it, or it finished.
result.m_exitCode = exitCode;
result.m_crashed = (exitCode == 100) || (exitCode == 101); // these indicate fatal errors.
break;
}
}
tracer.Pump(); // empty whats left if possible.
}
if (!finishedOK)
{
if (watcher->IsProcessRunning())
{
watcher->TerminateProcess(0xFFFFFFFF);
}
if (!this->m_requestedQuit)
{
if (jobCancelListener == nullptr || !jobCancelListener->IsCancelled())
{
AZ_Error("RC Builder", false, "RC failed to complete within the maximum allowed time and was terminated. please see %s/rc_log.log for details", result.m_outputDir.toUtf8().data());
}
else
{
AZ_TracePrintf("RC Builder", "RC was terminated. There was a request to cancel the job.\n");
result.m_exitCode = JobExitCode_JobCancelled;
}
}
else
{
AZ_Warning("RC Builder", false, "RC terminated because the application is shutting down.\n");
result.m_exitCode = JobExitCode_JobCancelled;
}
result.m_crashed = false;
}
AZ_TracePrintf("RC Builder", "RC.EXE execution has ended\n");
delete watcher;
return finishedOK;
return false;
}
QString NativeLegacyRCCompiler::BuildCommand(const QString& inputFile, const QString& watchFolder, const QString& platformIdentifier, const QString& params, const QString& dest)
@@ -438,22 +336,7 @@ namespace AssetProcessor
bool InternalRecognizerBasedBuilder::Initialize(const RecognizerConfiguration& recognizerConfig)
{
InitializeAssetRecognizers(recognizerConfig.GetAssetRecognizerContainer());
// Get the engine root since rc.exe will exist there and not in any external project folder
QString systemRoot;
QString rcFullPath;
// Validate that the engine root contains the necessary rc.exe
if (!FindRC(rcFullPath))
{
return false;
}
if (!m_rcCompiler->Initialize(systemRoot, rcFullPath))
{
AssetBuilderSDK::BuilderLog(m_internalRecognizerBuilderUuid, "Unable to find rc.exe from the engine root (%1).", rcFullPath.toUtf8().data());
return false;
}
return true;
return m_rcCompiler->Initialize();
}
@@ -31,7 +31,7 @@ namespace AssetProcessor
};
virtual ~RCCompiler() = default;
virtual bool Initialize(const QString& systemRoot, const QString& rcExecutableFullPath) = 0;
virtual bool Initialize() = 0;
virtual bool Execute(const QString& inputFile, const QString& watchFolder, const QString& platformIdentifier, const QString& params,
const QString& dest, const AssetBuilderSDK::JobCancelListener* jobCancelListener, Result& result) const = 0;
virtual void RequestQuit() = 0;
@@ -44,7 +44,7 @@ namespace AssetProcessor
public:
NativeLegacyRCCompiler();
bool Initialize(const QString& systemRoot, const QString& rcExecutableFullPath) override;
bool Initialize() override;
bool Execute(const QString& inputFile, const QString& watchFolder, const QString& platformIdentifier, const QString& params, const QString& dest,
const AssetBuilderSDK::JobCancelListener* jobCancelListener, Result& result) const override;
static QString BuildCommand(const QString& inputFile, const QString& watchFolder, const QString& platformIdentifier, const QString& params, const QString& dest);
@@ -53,8 +53,6 @@ namespace AssetProcessor
static const int s_maxSleepTime;
static const unsigned int s_jobMaximumWaitTime;
bool m_resourceCompilerInitialized;
QDir m_systemRoot;
QString m_rcExecutableFullPath;
volatile bool m_requestedQuit;
};
@@ -43,19 +43,6 @@ TEST_F(RCBuilderTest, Shutdown_NormalShutdown_Requested)
}
TEST_F(RCBuilderTest, Initialize_StandardInitialization_Fail)
{
MockRCCompiler* mockRC = new MockRCCompiler();
TestInternalRecognizerBasedBuilder test(mockRC);
MockRecognizerConfiguration configuration;
mockRC->SetResultInitialize(false);
bool initialization_result = test.Initialize(configuration);
ASSERT_FALSE(initialization_result);
}
TEST_F(RCBuilderTest, Initialize_StandardInitializationWithDuplicateAndInvalidRecognizers_Valid)
{
MockRCCompiler* mockRC = new MockRCCompiler();
@@ -34,7 +34,7 @@ public:
{
}
bool Initialize([[maybe_unused]] const QString& systemRoot, [[maybe_unused]] const QString& rcExecutableFullPath) override
bool Initialize() override
{
m_initialize++;
return m_initializeResult;
@@ -47,7 +47,7 @@ namespace AssetProcessor
{
}
bool Initialize([[maybe_unused]] const QString& systemRoot, [[maybe_unused]] const QString& rcExecutableFullPath) override
bool Initialize() override
{
m_initialize++;
return m_initializeResult;
@@ -1,47 +0,0 @@
/*
* 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 <GemCatalog.h>
#include <Source/ui_GemCatalog.h>
namespace O3DE::ProjectManager
{
GemCatalog::GemCatalog(ProjectManagerWindow* window)
: ScreenWidget(window)
, m_ui(new Ui::GemCatalogClass())
{
m_ui->setupUi(this);
ConnectSlotsAndSignals();
}
GemCatalog::~GemCatalog()
{
}
void GemCatalog::ConnectSlotsAndSignals()
{
QObject::connect(m_ui->backButton, &QPushButton::pressed, this, &GemCatalog::HandleBackButton);
QObject::connect(m_ui->confirmButton, &QPushButton::pressed, this, &GemCatalog::HandleConfirmButton);
}
void GemCatalog::HandleBackButton()
{
m_projectManagerWindow->ChangeToScreen(ProjectManagerScreen::NewProjectSettings);
}
void GemCatalog::HandleConfirmButton()
{
m_projectManagerWindow->ChangeToScreen(ProjectManagerScreen::ProjectsHome);
}
} // namespace O3DE::ProjectManager
@@ -1,231 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GemCatalogClass</class>
<widget class="QWidget" name="GemCatalogClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>806</width>
<height>566</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Gem Catalog</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<property name="text">
<string>Cart</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_2">
<property name="text">
<string>Hamburger Menu</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton">
<property name="text">
<string>RadioButton</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_2">
<property name="text">
<string>RadioButton</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_3">
<property name="text">
<string>RadioButton</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_3">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Atom</string>
</property>
</item>
<item>
<property name="text">
<string>Audio</string>
</property>
</item>
<item>
<property name="text">
<string>Camera</string>
</property>
</item>
<item>
<property name="text">
<string>PhysX</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="backButton">
<property name="text">
<string>Back</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="confirmButton">
<property name="text">
<string>Create Project</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,103 @@
/*
* 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 <GemCatalog/GemCatalog.h>
#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
namespace O3DE::ProjectManager
{
GemCatalog::GemCatalog(ProjectManagerWindow* window)
: ScreenWidget(window)
{
ConnectSlotsAndSignals();
m_gemModel = new GemModel(this);
QVBoxLayout* vLayout = new QVBoxLayout();
setLayout(vLayout);
QHBoxLayout* hLayout = new QHBoxLayout();
vLayout->addLayout(hLayout);
QWidget* filterPlaceholderWidget = new QWidget();
filterPlaceholderWidget->setFixedWidth(250);
hLayout->addWidget(filterPlaceholderWidget);
m_gemListView = new GemListView(m_gemModel, this);
hLayout->addWidget(m_gemListView);
QWidget* inspectorPlaceholderWidget = new QWidget();
inspectorPlaceholderWidget->setFixedWidth(250);
hLayout->addWidget(inspectorPlaceholderWidget);
// Temporary back and next buttons until they are centralized and shared.
QDialogButtonBox* backNextButtons = new QDialogButtonBox();
vLayout->addWidget(backNextButtons);
QPushButton* tempBackButton = backNextButtons->addButton("Back", QDialogButtonBox::RejectRole);
QPushButton* tempNextButton = backNextButtons->addButton("Next", QDialogButtonBox::AcceptRole);
connect(tempBackButton, &QPushButton::pressed, this, &GemCatalog::HandleBackButton);
connect(tempNextButton, &QPushButton::pressed, this, &GemCatalog::HandleConfirmButton);
// Start: Temporary gem test data
{
m_gemModel->AddGem(GemInfo("EMotion FX",
"O3DE Foundation",
"EMFX is a real-time character animation system. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
(GemInfo::Android | GemInfo::iOS | GemInfo::Windows | GemInfo::Linux),
true));
m_gemModel->AddGem(O3DE::ProjectManager::GemInfo("Atom",
"O3DE Foundation",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
GemInfo::Android | GemInfo::Windows | GemInfo::Linux,
true));
m_gemModel->AddGem(O3DE::ProjectManager::GemInfo("PhysX",
"O3DE Foundation",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
GemInfo::Android | GemInfo::Linux,
false));
m_gemModel->AddGem(O3DE::ProjectManager::GemInfo("Certificate Manager",
"O3DE Foundation",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
GemInfo::Windows,
false));
m_gemModel->AddGem(O3DE::ProjectManager::GemInfo("Cloud Gem Framework",
"O3DE Foundation",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
GemInfo::iOS | GemInfo::Linux,
false));
m_gemModel->AddGem(O3DE::ProjectManager::GemInfo("Achievements",
"O3DE Foundation",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
GemInfo::Android | GemInfo::Windows | GemInfo::Linux,
false));
}
// End: Temporary gem test data
}
void GemCatalog::HandleBackButton()
{
m_projectManagerWindow->ChangeToScreen(ProjectManagerScreen::NewProjectSettings);
}
void GemCatalog::HandleConfirmButton()
{
m_projectManagerWindow->ChangeToScreen(ProjectManagerScreen::ProjectsHome);
}
} // namespace O3DE::ProjectManager
@@ -13,32 +13,25 @@
#if !defined(Q_MOC_RUN)
#include <ScreenWidget.h>
#include <GemCatalog/GemListView.h>
#include <GemCatalog/GemModel.h>
#endif
namespace Ui
{
class GemCatalogClass;
}
namespace O3DE::ProjectManager
{
class GemCatalog
: public ScreenWidget
{
public:
explicit GemCatalog(ProjectManagerWindow* window);
~GemCatalog();
protected:
void ConnectSlotsAndSignals() override;
~GemCatalog() = default;
protected slots:
void HandleBackButton();
void HandleConfirmButton();
private:
QScopedPointer<Ui::GemCatalogClass> m_ui;
GemListView* m_gemListView = nullptr;
GemModel* m_gemModel = nullptr;
};
} // namespace O3DE::ProjectManager
@@ -0,0 +1,135 @@
/*
* 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 "GemItemDelegate.h"
#include "GemModel.h"
#include <QEvent>
#include <QPainter>
#include <QMouseEvent>
namespace O3DE::ProjectManager
{
GemItemDelegate::GemItemDelegate(GemModel* gemModel, QObject* parent)
: QStyledItemDelegate(parent)
, m_gemModel(gemModel)
{
}
void GemItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& modelIndex) const
{
if (!modelIndex.isValid())
{
return;
}
QStyleOptionViewItem options(option);
initStyleOption(&options, modelIndex);
painter->setRenderHint(QPainter::Antialiasing);
QRect fullRect, itemRect, contentRect;
CalcRects(options, modelIndex, fullRect, itemRect, contentRect);
QFont standardFont(options.font);
standardFont.setPixelSize(s_fontSize);
painter->save();
painter->setClipping(true);
painter->setClipRect(fullRect);
painter->setFont(options.font);
// Draw background
painter->fillRect(fullRect, m_backgroundColor);
// Draw item background
const QColor itemBackgroundColor = options.state & QStyle::State_MouseOver ? m_itemBackgroundColor.lighter(120) : m_itemBackgroundColor;
painter->fillRect(itemRect, itemBackgroundColor);
// Draw border
if (options.state & QStyle::State_Selected)
{
painter->save();
QPen borderPen(m_borderColor);
borderPen.setWidth(s_borderWidth);
painter->setPen(borderPen);
painter->drawRect(itemRect);
painter->restore();
}
// Gem name
const QString gemName = m_gemModel->GetName(modelIndex);
QFont gemNameFont(options.font);
gemNameFont.setPixelSize(s_gemNameFontSize);
gemNameFont.setBold(true);
QRect gemNameRect = GetTextRect(gemNameFont, gemName, s_gemNameFontSize);
gemNameRect.moveTo(contentRect.left(), contentRect.top());
painter->setFont(gemNameFont);
painter->setPen(m_textColor);
painter->drawText(gemNameRect, Qt::TextSingleLine, gemName);
// Gem creator
const QString gemCreator = m_gemModel->GetCreator(modelIndex);
QRect gemCreatorRect = GetTextRect(standardFont, gemCreator, s_fontSize);
gemCreatorRect.moveTo(contentRect.left(), contentRect.top() + gemNameRect.height());
painter->setFont(standardFont);
painter->setPen(m_linkColor);
painter->drawText(gemCreatorRect, Qt::TextSingleLine, gemCreator);
// Gem summary
const QSize summarySize = QSize(contentRect.width() - s_summaryStartX - s_itemMargins.right() * 4, contentRect.height());
const QRect summaryRect = QRect(/*topLeft=*/QPoint(contentRect.left() + s_summaryStartX, contentRect.top()), summarySize);
painter->setFont(standardFont);
painter->setPen(m_textColor);
const QString summary = m_gemModel->GetSummary(modelIndex);
painter->drawText(summaryRect, Qt::AlignLeft | Qt::TextWordWrap, summary);
painter->restore();
}
QSize GemItemDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& modelIndex) const
{
QStyleOptionViewItem options(option);
initStyleOption(&options, modelIndex);
int marginsHorizontal = s_itemMargins.left() + s_itemMargins.right() + s_contentMargins.left() + s_contentMargins.right();
return QSize(marginsHorizontal + s_summaryStartX, s_height);
}
bool GemItemDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& modelIndex)
{
if (!modelIndex.isValid())
{
return false;
}
return QStyledItemDelegate::editorEvent(event, model, option, modelIndex);
}
void GemItemDelegate::CalcRects(const QStyleOptionViewItem& option, const QModelIndex& modelIndex, QRect& outFullRect, QRect& outItemRect, QRect& outContentRect) const
{
const bool isFirst = modelIndex.row() == 0;
outFullRect = QRect(option.rect);
outItemRect = QRect(outFullRect.adjusted(s_itemMargins.left(), isFirst ? s_itemMargins.top() * 2 : s_itemMargins.top(), -s_itemMargins.right(), -s_itemMargins.bottom()));
outContentRect = QRect(outItemRect.adjusted(s_contentMargins.left(), s_contentMargins.top(), -s_contentMargins.right(), -s_contentMargins.bottom()));
}
QRect GemItemDelegate::GetTextRect(QFont& font, const QString& text, qreal fontSize) const
{
font.setPixelSize(fontSize);
return QFontMetrics(font).boundingRect(text);
}
} // namespace O3DE::ProjectManager
@@ -0,0 +1,62 @@
/*
* 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.
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <QStyledItemDelegate>
#include "GemInfo.h"
#include "GemModel.h"
#endif
QT_FORWARD_DECLARE_CLASS(QEvent)
namespace O3DE::ProjectManager
{
class GemItemDelegate
: public QStyledItemDelegate
{
Q_OBJECT // AUTOMOC
public:
explicit GemItemDelegate(GemModel* gemModel, QObject* parent = nullptr);
~GemItemDelegate() = default;
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& modelIndex) const override;
bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& modelIndex) override;
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& modelIndex) const override;
private:
void CalcRects(const QStyleOptionViewItem& option, const QModelIndex& modelIndex, QRect& outFullRect, QRect& outItemRect, QRect& outContentRect) const;
QRect GetTextRect(QFont& font, const QString& text, qreal fontSize) const;
GemModel* m_gemModel = nullptr;
// Colors
const QColor m_textColor = QColor("#FFFFFF");
const QColor m_linkColor = QColor("#94D2FF");
const QColor m_backgroundColor = QColor("#333333"); // Outside of the actual gem item
const QColor m_itemBackgroundColor = QColor("#404040"); // Background color of the gem item
const QColor m_borderColor = QColor("#1E70EB");
// Item
inline constexpr static int s_height = 140; // Gem item total height
inline constexpr static qreal s_gemNameFontSize = 16.0;
inline constexpr static qreal s_fontSize = 15.0;
inline constexpr static int s_summaryStartX = 200;
// Margin and borders
inline constexpr static QMargins s_itemMargins = QMargins(/*left=*/20, /*top=*/10, /*right=*/20, /*bottom=*/10); // Item border distances
inline constexpr static QMargins s_contentMargins = QMargins(/*left=*/15, /*top=*/12, /*right=*/12, /*bottom=*/12); // Distances of the elements within an item to the item borders
inline constexpr static int s_borderWidth = 4;
};
} // namespace O3DE::ProjectManager
@@ -0,0 +1,34 @@
/*
* 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 "GemListView.h"
#include "GemItemDelegate.h"
#include <QStandardItemModel>
#include <QDateTime>
#include <QPalette>
namespace O3DE::ProjectManager
{
GemListView::GemListView(GemModel* model, QWidget *parent) :
QListView(parent)
{
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
QPalette palette;
palette.setColor(QPalette::Window, QColor("#333333"));
setPalette(palette);
setModel(model);
setSelectionModel(model->GetSelectionModel());
setItemDelegate(new GemItemDelegate(model, this));
}
} // namespace O3DE::ProjectManager
@@ -0,0 +1,31 @@
/*
* 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.
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include "GemInfo.h"
#include "GemModel.h"
#include <QListView>
#endif
namespace O3DE::ProjectManager
{
class GemListView
: public QListView
{
Q_OBJECT // AUTOMOC
public:
explicit GemListView(GemModel* model, QWidget *parent = nullptr);
~GemListView() = default;
};
} // namespace O3DE::ProjectManager
@@ -0,0 +1,72 @@
/*
* 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 "GemModel.h"
namespace O3DE::ProjectManager
{
GemModel::GemModel(QObject* parent)
: QStandardItemModel(parent)
{
m_selectionModel = new QItemSelectionModel(this, parent);
}
QItemSelectionModel* GemModel::GetSelectionModel() const
{
return m_selectionModel;
}
void GemModel::AddGem(const GemInfo& gemInfo)
{
QStandardItem* item = new QStandardItem();
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
item->setData(gemInfo.m_name, RoleName);
item->setData(gemInfo.m_creator, RoleCreator);
item->setData(static_cast<int>(gemInfo.m_platforms), RolePlatforms);
item->setData(gemInfo.m_summary, RoleSummary);
item->setData(gemInfo.m_isAdded, RoleIsAdded);
appendRow(item);
}
void GemModel::Clear()
{
clear();
}
QString GemModel::GetName(const QModelIndex& modelIndex) const
{
return modelIndex.data(RoleName).toString();
}
QString GemModel::GetCreator(const QModelIndex& modelIndex) const
{
return modelIndex.data(RoleCreator).toString();
}
int GemModel::GetPlatforms(const QModelIndex& modelIndex) const
{
return static_cast<GemInfo::Platforms>(modelIndex.data(RolePlatforms).toInt());
}
QString GemModel::GetSummary(const QModelIndex& modelIndex) const
{
return modelIndex.data(RoleSummary).toString();
}
bool GemModel::IsAdded(const QModelIndex& modelIndex) const
{
return modelIndex.data(RoleIsAdded).toBool();
}
} // namespace O3DE::ProjectManager
@@ -0,0 +1,53 @@
/*
* 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.
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include "GemInfo.h"
#include <QStandardItemModel>
#include <QItemSelectionModel>
#endif
namespace O3DE::ProjectManager
{
class GemModel
: public QStandardItemModel
{
Q_OBJECT // AUTOMOC
public:
explicit GemModel(QObject* parent = nullptr);
QItemSelectionModel* GetSelectionModel() const;
void AddGem(const GemInfo& gemInfo);
void Clear();
QString GetName(const QModelIndex& modelIndex) const;
QString GetCreator(const QModelIndex& modelIndex) const;
int GetPlatforms(const QModelIndex& modelIndex) const;
QString GetSummary(const QModelIndex& modelIndex) const;
bool IsAdded(const QModelIndex& modelIndex) const;
private:
enum UserRole
{
RoleName = Qt::UserRole,
RoleCreator,
RolePlatforms,
RoleSummary,
RoleIsAdded
};
QItemSelectionModel* m_selectionModel = nullptr;
};
} // namespace O3DE::ProjectManager
@@ -13,7 +13,7 @@
#include <FirstTimeUse.h>
#include <NewProjectSettings.h>
#include <GemCatalog.h>
#include <GemCatalog/GemCatalog.h>
#include <ProjectsHome.h>
#include <ProjectSettings.h>
#include <EngineSettings.h>
@@ -30,7 +30,7 @@ namespace O3DE::ProjectManager
}
protected:
virtual void ConnectSlotsAndSignals() = 0;
virtual void ConnectSlotsAndSignals() {}
ProjectManagerWindow* m_projectManagerWindow;
};
@@ -25,9 +25,6 @@ set(FILES
Source/NewProjectSettings.h
Source/NewProjectSettings.cpp
Source/NewProjectSettings.ui
Source/GemCatalog.h
Source/GemCatalog.cpp
Source/GemCatalog.ui
Source/ProjectsHome.h
Source/ProjectsHome.cpp
Source/ProjectsHome.ui
@@ -37,6 +34,14 @@ set(FILES
Source/EngineSettings.h
Source/EngineSettings.cpp
Source/EngineSettings.ui
Source/GemCatalog/GemCatalog.h
Source/GemCatalog/GemCatalog.cpp
Source/GemCatalog/GemInfo.h
Source/GemCatalog/GemInfo.cpp
Source/GemCatalog/GemItemDelegate.h
Source/GemCatalog/GemItemDelegate.cpp
Source/GemCatalog/GemListView.h
Source/GemCatalog/GemListView.cpp
Source/GemCatalog/GemModel.h
Source/GemCatalog/GemModel.cpp
)
@@ -151,7 +151,7 @@ namespace AZ
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<AssImpAnimationImporter, SceneCore::LoadingComponent>()->Version(2); // [LYN-2281] Skinned mesh loading fixes
serializeContext->Class<AssImpAnimationImporter, SceneCore::LoadingComponent>()->Version(3); // [LYN-3349] Rolling back rotation change
}
}