Merge branch 'main' into LYN-1767-AB

This commit is contained in:
igarri
2021-05-10 10:41:54 +01:00
5881 changed files with 99964 additions and 678754 deletions
-108
View File
@@ -650,114 +650,6 @@ void Q2DViewport::OnDestroy()
//////////////////////////////////////////////////////////////////////////
void Q2DViewport::Render()
{
if (GetIEditor()->IsInGameMode())
{
return;
}
if (!m_renderer)
{
return;
}
if (!isVisible())
{
return;
}
if (!GetIEditor()->GetDocument()->IsDocumentReady())
{
return;
}
if (m_renderer->IsStereoEnabled())
{
return;
}
FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR);
QRect rc = rect();
if (rc.isEmpty())
{
return;
}
CalculateViewTM();
// Render
WIN_HWND priorContext = m_renderer->GetCurrentContextHWND();
m_renderer->SetCurrentContext(renderOverlayHWND());
m_renderer->BeginFrame();
m_renderer->ChangeViewport(0, 0, rc.right(), rc.bottom(), true);
CScopedWireFrameMode scopedWireFrame(m_renderer, R_SOLID_MODE);
auto colorf = Rgb2ColorF(m_colorBackground);
m_renderer->ClearTargetsLater(FRT_CLEAR, colorf);
//////////////////////////////////////////////////////////////////////////
// 2D Mode.
//////////////////////////////////////////////////////////////////////////
if (rc.right() != 0 && rc.bottom() != 0)
{
TransformationMatrices backupSceneMatrices;
m_renderer->Set2DMode(rc.right(), rc.bottom(), backupSceneMatrices);
//////////////////////////////////////////////////////////////////////////
// Draw viewport elements here.
//////////////////////////////////////////////////////////////////////////
// Calc world bounding box for objects rendering.
m_displayBounds = GetWorldBounds(QPoint(0, 0), QPoint(rc.width(), rc.height()));
// Draw all objects.
DisplayContext& dc = m_displayContext;
dc.settings = GetIEditor()->GetDisplaySettings();
dc.view = this;
dc.renderer = m_renderer;
dc.engine = GetIEditor()->Get3DEngine();
dc.flags = DISPLAY_2D;
dc.box = m_displayBounds;
dc.camera = &GetIEditor()->GetSystem()->GetViewCamera();
if (!dc.settings->IsDisplayLabels() || !dc.settings->IsDisplayHelpers())
{
dc.flags |= DISPLAY_HIDENAMES;
}
if (dc.settings->IsDisplayLinks() && dc.settings->IsDisplayHelpers())
{
dc.flags |= DISPLAY_LINKS;
}
if (m_bDegradateQuality)
{
dc.flags |= DISPLAY_DEGRADATED;
}
SRenderingPassInfo passInfo = SRenderingPassInfo::CreateGeneralPassRenderingInfo(GetIEditor()->GetSystem()->GetViewCamera());
m_renderer->BeginSpawningGeneratingRendItemJobs(passInfo.ThreadID());
m_renderer->BeginSpawningShadowGeneratingRendItemJobs(passInfo.ThreadID());
m_renderer->EF_StartEf(passInfo);
dc.SetState(e_Mode3D | e_AlphaBlended | e_FillModeSolid | e_CullModeBack | e_DepthWriteOff | e_DepthTestOn);
Draw(dc);
m_renderer->EF_EndEf3D(SHDF_STREAM_SYNC, -1, -1, passInfo);
m_renderer->EF_RenderTextMessages();
// Return back from 2D mode.
m_renderer->Unset2DMode(backupSceneMatrices);
m_renderer->RenderDebug(false);
ProcessRenderLisneters(m_displayContext);
m_renderer->EndFrame();
}
GetIEditor()->GetRenderer()->SetCurrentContext(priorContext);
}
//////////////////////////////////////////////////////////////////////////
@@ -19,6 +19,8 @@
#include <QPushButton>
// AzCore
#include <AzCore/Utils/Utils.h>
#include <Pak/CryPakUtils.h>
// Editor
@@ -70,12 +72,13 @@ void CAlembicCompileDialog::OnInitDialog()
SDirectoryEnumeratorHelper dirHelper;
dirHelper.ScanDirectoryRecursive(gEnv->pCryPak, "@engroot@/", "Editor/Presets/GeomCache", filePattern, presetFiles);
auto engineAssetSourceRoot = AZ::IO::FixedMaxPath(AZ::Utils::GetEnginePath()) / "Assets";
dirHelper.ScanDirectoryRecursive(gEnv->pCryPak, engineAssetSourceRoot.c_str(), "Editor/Presets/GeomCache", filePattern, presetFiles);
for (auto iter = presetFiles.begin(); iter != presetFiles.end(); ++iter)
{
const auto& file = *iter;
const AZStd::string filePath = "@engroot@/" + file;
const AZ::IO::FixedMaxPath filePath = engineAssetSourceRoot / file;
m_presets.push_back(LoadConfig(Path::GetFileName(file.c_str()), XmlHelpers::LoadXmlFromFile(filePath.c_str())));
m_ui->m_presetComboBox->addItem(m_presets.back().m_name);
}
@@ -50,8 +50,6 @@
#include "Include/IObjectManager.h"
#include "CryEditDoc.h"
#include "QtViewPaneManager.h"
#include "AzAssetBrowser/Preview/LegacyPreviewerFactory.h"
namespace AzAssetBrowserRequestHandlerPrivate
{
@@ -230,18 +228,15 @@ namespace AzAssetBrowserRequestHandlerPrivate
}
AzAssetBrowserRequestHandler::AzAssetBrowserRequestHandler()
: m_previewerFactory(aznew LegacyPreviewerFactory)
{
using namespace AzToolsFramework::AssetBrowser;
AssetBrowserInteractionNotificationBus::Handler::BusConnect();
AzQtComponents::DragAndDropEventsBus::Handler::BusConnect(AzQtComponents::DragAndDropContexts::EditorViewport);
AzToolsFramework::AssetBrowser::PreviewerRequestBus::Handler::BusConnect();
}
AzAssetBrowserRequestHandler::~AzAssetBrowserRequestHandler()
{
AzToolsFramework::AssetBrowser::PreviewerRequestBus::Handler::BusDisconnect();
AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler::BusDisconnect();
AzQtComponents::DragAndDropEventsBus::Handler::BusDisconnect();
}
@@ -527,15 +522,6 @@ void AzAssetBrowserRequestHandler::Drop(QDropEvent* event, AzQtComponents::DragA
}
}
const AzToolsFramework::AssetBrowser::PreviewerFactory* AzAssetBrowserRequestHandler::GetPreviewerFactory(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const
{
if (m_previewerFactory->IsEntrySupported(entry))
{
return m_previewerFactory.get();
}
return nullptr;
}
void AzAssetBrowserRequestHandler::AddSourceFileOpeners(const char* fullSourceFileName, const AZ::Uuid& sourceUUID, AzToolsFramework::AssetBrowser::SourceFileOpenerList& openers)
{
using namespace AzToolsFramework;
@@ -37,12 +37,9 @@ namespace AzToolsFramework
}
}
class LegacyPreviewerFactory;
class AzAssetBrowserRequestHandler
: protected AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler
, protected AzQtComponents::DragAndDropEventsBus::Handler
, protected AzToolsFramework::AssetBrowser::PreviewerRequestBus::Handler
{
public:
AzAssetBrowserRequestHandler();
@@ -66,16 +63,8 @@ protected:
void DragLeave(QDragLeaveEvent* event) override;
void Drop(QDropEvent* event, AzQtComponents::DragAndDropContextBase& context) override;
//////////////////////////////////////////////////////////////////////////
// PreviewerRequestBus::Handler
//////////////////////////////////////////////////////////////////////////
const AzToolsFramework::AssetBrowser::PreviewerFactory* GetPreviewerFactory(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const override;
bool CanAcceptDragAndDropEvent(
QDropEvent* event, AzQtComponents::DragAndDropContextBase& context,
AZStd::optional<AZStd::vector<const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry*>*> outSources = AZStd::nullopt,
AZStd::optional<AZStd::vector<const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry*>*> outProducts = AZStd::nullopt) const;
private:
AZStd::unique_ptr<const LegacyPreviewerFactory> m_previewerFactory;
};
@@ -1,409 +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 "EditorDefs.h"
#include "LegacyPreviewer.h"
// AzToolsFramework
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserEntry.h>
#include <AzToolsFramework/AssetBrowser/EBusFindAssetTypeByName.h>
// Editor
#include "Util/Image.h"
#include "Util/ImageUtil.h"
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
#include <AzAssetBrowser/Preview/ui_LegacyPreviewer.h>
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
static const int s_CharWidth = 6;
const QString LegacyPreviewer::Name{ QStringLiteral("LegacyPreviewer") };
LegacyPreviewer::LegacyPreviewer(QWidget* parent)
: Previewer(parent)
, m_ui(new Ui::LegacyPreviewerClass())
, m_textureType(TextureType::RGB)
{
m_ui->setupUi(this);
m_ui->m_comboBoxRGB->addItems(QStringList() << "RGB" << "RGBA" << "Alpha");
m_ui->m_previewCtrl->SetAspectRatio(4.0f / 3.0f);
connect(m_ui->m_comboBoxRGB, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), this,
[=](int index)
{
m_textureType = static_cast<TextureType>(index);
UpdateTextureType();
});
Clear();
}
LegacyPreviewer::~LegacyPreviewer()
{
}
void LegacyPreviewer::Clear() const
{
m_ui->m_previewCtrl->ReleaseObject();
m_ui->m_modelPreviewWidget->hide();
m_ui->m_texturePreviewWidget->hide();
m_ui->m_fileInfoCtrl->hide();
}
void LegacyPreviewer::Display(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry)
{
using namespace AzToolsFramework::AssetBrowser;
if (!entry)
{
Clear();
return;
}
switch (entry->GetEntryType())
{
case AssetBrowserEntry::AssetEntryType::Source:
{
const SourceAssetBrowserEntry* sourceEntry = azrtti_cast<const SourceAssetBrowserEntry*>(entry);
DisplaySource(sourceEntry);
break;
}
case AssetBrowserEntry::AssetEntryType::Product:
DisplayProduct(static_cast<const ProductAssetBrowserEntry*>(entry));
break;
default:
Clear();
}
}
const QString& LegacyPreviewer::GetName() const
{
return Name;
}
void LegacyPreviewer::resizeEvent(QResizeEvent* /*event*/)
{
m_ui->m_fileInfoCtrl->setText(WordWrap(m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth));
}
bool LegacyPreviewer::DisplayProduct(const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry* product)
{
m_ui->m_fileInfoCtrl->show();
m_fileinfo = QString::fromUtf8(product->GetName().c_str());
m_fileinfo += GetFileSize(product->GetRelativePath().c_str());
EBusFindAssetTypeByName meshAssetTypeResult("Static Mesh");
AZ::AssetTypeInfoBus::BroadcastResult(meshAssetTypeResult, &AZ::AssetTypeInfo::GetAssetType);
QString filename(product->GetRelativePath().c_str());
// Find item.
if (product->GetAssetType() == meshAssetTypeResult.GetAssetType())
{
m_ui->m_modelPreviewWidget->show();
m_ui->m_texturePreviewWidget->hide();
m_ui->m_previewCtrl->LoadFile(filename);
int nVertexCount = m_ui->m_previewCtrl->GetVertexCount();
int nFaceCount = m_ui->m_previewCtrl->GetFaceCount();
int nMaxLod = m_ui->m_previewCtrl->GetMaxLod();
int nMtls = m_ui->m_previewCtrl->GetMtlCount();
if (nFaceCount > 0)
{
m_fileinfo += tr("\r\n%1 Faces\r\n%2 Verts\r\n%3 MaxLod\r\n%4 Materials").arg(nFaceCount).arg(nVertexCount).arg(nMaxLod).arg(nMtls);
}
m_ui->m_fileInfoCtrl->setText(WordWrap(m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth));
updateGeometry();
return true;
}
EBusFindAssetTypeByName textureAssetTypeResult("Texture");
AZ::AssetTypeInfoBus::BroadcastResult(textureAssetTypeResult, &AZ::AssetTypeInfo::GetAssetType);
if (product->GetAssetType() == textureAssetTypeResult.GetAssetType())
{
// Get full product file path
const char* assetCachePath = AZ::IO::FileIOBase::GetInstance()->GetAlias("@assets@");
AZStd::string productFullPath;
AzFramework::StringFunc::Path::Join(assetCachePath, product->GetRelativePath().c_str(), productFullPath);
if (AZ::IO::FileIOBase::GetInstance()->Exists(productFullPath.c_str()))
{
// Try to display it in modern dds image loader, if no one exists, use the legacy image loader
bool foundPixmap = DisplayTextureProductModern(productFullPath.c_str());
return foundPixmap ? foundPixmap : DisplayTextureLegacy(productFullPath.c_str());
}
else
{
// If we cannot find the product file, means it's not treated as an asset, display its source
return DisplayTextureLegacy(product->GetFullPath().c_str());
}
}
Clear();
return false;
}
void LegacyPreviewer::DisplaySource(const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* source)
{
using namespace AzToolsFramework::AssetBrowser;
EBusFindAssetTypeByName textureAssetType("Texture");
AZ::AssetTypeInfoBus::BroadcastResult(textureAssetType, &AZ::AssetTypeInfo::GetAssetType);
if (source->GetPrimaryAssetType() == textureAssetType.GetAssetType())
{
m_ui->m_fileInfoCtrl->show();
m_fileinfo = QString::fromUtf8(source->GetName().c_str());
m_fileinfo += GetFileSize(source->GetFullPath().c_str());
const char* fullSourcePath = source->GetFullPath().c_str();
// If it's a source dds file, try to display it using modern way
if (AzFramework::StringFunc::Path::IsExtension(fullSourcePath, "dds", false))
{
if (DisplayTextureProductModern(fullSourcePath))
{
return;
}
}
DisplayTextureLegacy(source->GetFullPath().c_str());
}
else
{
AZStd::vector<const ProductAssetBrowserEntry*> products;
source->GetChildrenRecursively<ProductAssetBrowserEntry>(products);
if (products.empty())
{
Clear();
}
else
{
for (auto* product : products)
{
if (DisplayProduct(product))
{
break;
}
}
}
}
}
QString LegacyPreviewer::GetFileSize(const char* path)
{
QString fileSizeStr;
AZ::u64 fileSizeResult = 0;
if (AZ::IO::FileIOBase::GetInstance()->Size(path, fileSizeResult))
{
static double kb = 1024.0f;
static double mb = kb * 1024.0;
static double gb = mb * 1024.0;
static QString byteStr = "B";
static QString kbStr = "KB";
static QString mbStr = "MB";
static QString gbStr = "GB";
#if AZ_TRAIT_OS_PLATFORM_APPLE
kb = 1000.0;
mb = kb * 1000.0;
gb = mb * 1000.0;
kbStr = "kB";
mbStr = "mB";
gbStr = "gB";
#endif // AZ_TRAIT_OS_PLATFORM_APPLE
if (fileSizeResult < kb)
{
fileSizeStr += tr("\r\nFile Size: %1%2").arg(QString::number(fileSizeResult), byteStr);
}
else if (fileSizeResult < mb)
{
double size = fileSizeResult / kb;
fileSizeStr += tr("\r\nFile Size: %1%2").arg(QString::number(size, 'f', 2), kbStr);
}
else if (fileSizeResult < gb)
{
double size = fileSizeResult / mb;
fileSizeStr += tr("\r\nFile Size: %1%2").arg(QString::number(size, 'f', 2), mbStr);
}
else
{
double size = fileSizeResult / gb;
fileSizeStr += tr("\r\nFile Size: %1%2").arg(QString::number(size, 'f', 2), gbStr);
}
}
return fileSizeStr;
}
bool LegacyPreviewer::DisplayTextureLegacy(const char* fullImagePath)
{
m_ui->m_modelPreviewWidget->hide();
m_ui->m_texturePreviewWidget->show();
bool foundPixmap = false;
if (!AZ::IO::FileIOBase::GetInstance()->IsDirectory(fullImagePath))
{
QString strLoadFilename = QString(fullImagePath);
if (CImageUtil::LoadImage(strLoadFilename, m_previewImageSource))
{
m_fileinfo += QStringLiteral("\r\n%1x%2\r\n%3")
.arg(m_previewImageSource.GetWidth())
.arg(m_previewImageSource.GetHeight())
.arg(m_previewImageSource.GetFormatDescription());
m_fileinfoAlphaTexture = m_fileinfo;
UpdateTextureType();
foundPixmap = true;
}
}
if (!foundPixmap)
{
m_ui->m_previewImageCtrl->setPixmap(QPixmap());
m_ui->m_fileInfoCtrl->setText(WordWrap(m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth));
}
updateGeometry();
return foundPixmap;
}
bool LegacyPreviewer::DisplayTextureProductModern(const char* fullProductImagePath)
{
m_ui->m_modelPreviewWidget->hide();
m_ui->m_texturePreviewWidget->show();
bool foundPixmap = false;
QImage previewImage;
AZStd::string productInfo;
AZStd::string productAlphaInfo;
AzToolsFramework::AssetBrowser::AssetBrowserTexturePreviewRequestsBus::BroadcastResult(foundPixmap, &AzToolsFramework::AssetBrowser::AssetBrowserTexturePreviewRequests::GetProductTexturePreview, fullProductImagePath, previewImage, productInfo, productAlphaInfo);
if (foundPixmap)
{
QPixmap pix = QPixmap::fromImage(previewImage);
m_ui->m_previewImageCtrl->setPixmap(pix);
m_ui->m_previewImageCtrl->updateGeometry();
CImageUtil::QImageToImage(previewImage, m_previewImageSource);
m_fileinfo += QStringLiteral("\r\n%1x%2\r\n%3")
.arg(m_previewImageSource.GetWidth())
.arg(m_previewImageSource.GetHeight())
.arg(m_previewImageSource.GetFormatDescription());
m_fileinfoAlphaTexture = m_fileinfo;
m_fileinfo += QString(productInfo.c_str());
if (productAlphaInfo.empty())
{
// If there is no separate info for alpha, use the image info
m_fileinfoAlphaTexture += QString(productInfo.c_str());
}
else
{
m_fileinfoAlphaTexture += QString(productAlphaInfo.c_str());
}
UpdateTextureType();
}
else
{
m_ui->m_previewImageCtrl->setPixmap(QPixmap());
m_ui->m_fileInfoCtrl->setText(WordWrap(m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth));
}
updateGeometry();
return foundPixmap;
}
void LegacyPreviewer::UpdateTextureType()
{
m_previewImageUpdated.Copy(m_previewImageSource);
switch (m_textureType)
{
case TextureType::RGB:
{
m_previewImageUpdated.SwapRedAndBlue();
m_previewImageUpdated.FillAlpha();
break;
}
case TextureType::RGBA:
{
m_previewImageUpdated.SwapRedAndBlue();
break;
}
case TextureType::Alpha:
{
for (int h = 0; h < m_previewImageUpdated.GetHeight(); h++)
{
for (int w = 0; w < m_previewImageUpdated.GetWidth(); w++)
{
int a = m_previewImageUpdated.ValueAt(w, h) >> 24;
m_previewImageUpdated.ValueAt(w, h) = RGB(a, a, a) | 0xFF000000;
}
}
break;
}
}
// note that Qt will not deep copy the data, so WE MUST KEEP THE IMAGE DATA AROUND!
QPixmap qtPixmap = QPixmap::fromImage(
QImage(reinterpret_cast<uchar*>(m_previewImageUpdated.GetData()), m_previewImageUpdated.GetWidth(), m_previewImageUpdated.GetHeight(), QImage::Format_ARGB32));
m_ui->m_previewImageCtrl->setPixmap(qtPixmap);
m_ui->m_fileInfoCtrl->setText(WordWrap(m_textureType == TextureType::Alpha? m_fileinfoAlphaTexture: m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth));
m_ui->m_previewImageCtrl->updateGeometry();
}
bool LegacyPreviewer::FileInfoCompare(const FileInfo& f1, const FileInfo& f2)
{
if ((f1.attrib & _A_SUBDIR) && !(f2.attrib & _A_SUBDIR))
{
return true;
}
if (!(f1.attrib & _A_SUBDIR) && (f2.attrib & _A_SUBDIR))
{
return false;
}
return QString::compare(f1.filename, f2.filename, Qt::CaseInsensitive) < 0;
}
QString LegacyPreviewer::WordWrap(const QString& string, int maxLength)
{
QString result;
int length = 0;
for (auto c : string)
{
if (c == '\n')
{
length = 0;
}
else if (length > maxLength)
{
result.append('\n');
length = 0;
}
else
{
length++;
}
result.append(c);
}
return result;
}
#include <AzAssetBrowser/Preview/moc_LegacyPreviewer.cpp>
@@ -1,100 +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.
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <Editor/Util/Image.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzToolsFramework/AssetBrowser/Previewer/Previewer.h>
#include <QWidget>
#include <QScopedPointer>
#endif
namespace Ui
{
class LegacyPreviewerClass;
}
namespace AzToolsFramework
{
namespace AssetBrowser
{
class ProductAssetBrowserEntry;
class SourceAssetBrowserEntry;
class AssetBrowserEntry;
}
}
class QResizeEvent;
class LegacyPreviewer
: public AzToolsFramework::AssetBrowser::Previewer
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(LegacyPreviewer, AZ::SystemAllocator, 0);
explicit LegacyPreviewer(QWidget* parent = nullptr);
~LegacyPreviewer();
//////////////////////////////////////////////////////////////////////////
// AzToolsFramework::AssetBrowser::Previewer
//////////////////////////////////////////////////////////////////////////
void Clear() const override;
void Display(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) override;
const QString& GetName() const override;
static const QString Name;
protected:
void resizeEvent(QResizeEvent * event) override;
private:
struct FileInfo
{
QString filename;
unsigned attrib;
time_t time_create; /* -1 for FAT file systems */
time_t time_access; /* -1 for FAT file systems */
time_t time_write;
_fsize_t size;
};
enum class TextureType
{
RGB,
RGBA,
Alpha
};
QScopedPointer<Ui::LegacyPreviewerClass> m_ui;
CImageEx m_previewImageSource;
CImageEx m_previewImageUpdated;
TextureType m_textureType;
QString m_fileinfo;
QString m_fileinfoAlphaTexture;
bool DisplayProduct(const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry* product);
void DisplaySource(const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* source);
QString GetFileSize(const char* path);
bool DisplayTextureLegacy(const char* fullImagePath);
bool DisplayTextureProductModern(const char* fullProductImagePath);
void UpdateTextureType();
static bool FileInfoCompare(const FileInfo& f1, const FileInfo& f2);
//! QLabel word wrap does not break long words such as filenames, so manual word wrap needed
static QString WordWrap(const QString& string, int maxLength);
};
@@ -1,176 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LegacyPreviewerClass</class>
<widget class="QWidget" name="LegacyPreviewerClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>148</width>
<height>282</height>
</rect>
</property>
<property name="windowTitle">
<string>Preview</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="m_texturePreviewWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="m_horizontalLayout">
<item>
<spacer name="m_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="QComboBox" name="m_comboBoxRGB">
<property name="currentText">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="AzToolsFramework::AspectRatioAwarePixmapWidget" name="m_previewImageCtrl" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="m_modelPreviewWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="CPreviewModelCtrl" name="m_previewCtrl" native="true"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="m_fileInfoCtrl">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="m_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>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>CPreviewModelCtrl</class>
<extends>QWidget</extends>
<header>Controls/PreviewModelCtrl.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>AzToolsFramework::AspectRatioAwarePixmapWidget</class>
<extends>QWidget</extends>
<header>AzToolsFramework/UI/UICore/AspectRatioAwarePixmapWidget.hxx</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
@@ -1,71 +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 "EditorDefs.h"
#include "LegacyPreviewerFactory.h"
// AzToolsFramework
#include <AzToolsFramework/AssetBrowser/AssetBrowserEntry.h> // for AssetBrowserEntry::AssetEntryType
#include <AzToolsFramework/AssetBrowser/EBusFindAssetTypeByName.h> // for EBusFindAssetTypeByName
// Editor
#include "LegacyPreviewer.h"
AzToolsFramework::AssetBrowser::Previewer* LegacyPreviewerFactory::CreatePreviewer(QWidget* parent) const
{
return new LegacyPreviewer(parent);
}
bool LegacyPreviewerFactory::IsEntrySupported(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const
{
using namespace AzToolsFramework::AssetBrowser;
EBusFindAssetTypeByName meshAssetTypeResult("Static Mesh");
AZ::AssetTypeInfoBus::BroadcastResult(meshAssetTypeResult, &AZ::AssetTypeInfo::GetAssetType);
EBusFindAssetTypeByName textureAssetTypeResult("Texture");
AZ::AssetTypeInfoBus::BroadcastResult(textureAssetTypeResult, &AZ::AssetTypeInfo::GetAssetType);
switch (entry->GetEntryType())
{
case AssetBrowserEntry::AssetEntryType::Source:
{
const auto* source = azrtti_cast < const SourceAssetBrowserEntry * > (entry);
if (source->GetPrimaryAssetType() == textureAssetTypeResult.GetAssetType())
{
return true;
}
AZStd::vector < const ProductAssetBrowserEntry * > products;
source->GetChildrenRecursively < ProductAssetBrowserEntry > (products);
for (auto* product : products)
{
if (product->GetAssetType() == textureAssetTypeResult.GetAssetType() ||
product->GetAssetType() == meshAssetTypeResult.GetAssetType())
{
return true;
}
}
break;
}
case AssetBrowserEntry::AssetEntryType::Product:
const auto* product = azrtti_cast < const ProductAssetBrowserEntry * > (entry);
return product->GetAssetType() == textureAssetTypeResult.GetAssetType() ||
product->GetAssetType() == meshAssetTypeResult.GetAssetType();
}
return false;
}
const QString& LegacyPreviewerFactory::GetName() const
{
return LegacyPreviewer::Name;
}
@@ -1,34 +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.
*
*/
#pragma once
#include <AzCore/Memory/SystemAllocator.h>
#include <AzToolsFramework/AssetBrowser/Previewer/PreviewerFactory.h>
class QString;
class LegacyPreviewerFactory final
: public AzToolsFramework::AssetBrowser::PreviewerFactory
{
public:
AZ_CLASS_ALLOCATOR(LegacyPreviewerFactory, AZ::SystemAllocator, 0);
LegacyPreviewerFactory() = default;
~LegacyPreviewerFactory() = default;
//////////////////////////////////////////////////////////////////////////
// AzToolsFramework::AssetBrowser::PreviewerFactory
//////////////////////////////////////////////////////////////////////////
AzToolsFramework::AssetBrowser::Previewer* CreatePreviewer(QWidget* parent = nullptr) const override;
bool IsEntrySupported(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const override;
const QString& GetName() const override;
};
@@ -826,9 +826,6 @@ void CBaseLibraryManager::OnEditorNotifyEvent(EEditorNotifyEvent event)
SetSelectedItem(0);
ClearAll();
break;
case eNotify_OnMissionChange:
SetSelectedItem(0);
break;
case eNotify_OnCloseScene:
SetSelectedItem(0);
ClearAll();
File diff suppressed because it is too large Load Diff
@@ -1,204 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_CONTROLS_PREVIEWMODELCTRL_H
#define CRYINCLUDE_EDITOR_CONTROLS_PREVIEWMODELCTRL_H
#pragma once
#if !defined(Q_MOC_RUN)
#include <QString>
#include <QPoint>
#include <QWidget>
#include <IStatObj.h>
#include <Editor/Material/Material.h>
#endif
struct IRenderNode;
class CImageEx;
class CPreviewModelCtrl
: public QWidget
, public IEditorNotifyListener
{
Q_OBJECT
public:
explicit CPreviewModelCtrl(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
QSize minimumSizeHint() const override;
public:
void LoadFile(const QString& modelFile, bool changeCamera = true);
Vec3 GetSize() const { return m_size; };
QString GetLoadedFile() const { return m_loadedFile; }
void SetEntity(IRenderNode* entity);
void SetObject(IStatObj* pObject);
IStatObj* GetObject() { return m_pObj; }
void SetCameraLookAt(float fRadiusScale, const Vec3& dir = Vec3(0, 1, 0));
void SetCameraRadius(float fRadius);
CCamera& GetCamera();
void SetGrid(bool bEnable) { m_bGrid = bEnable; }
void SetAxis(bool bEnable, bool forParticleEditor = false) { m_bAxis = bEnable; m_bAxisParticleEditor = forParticleEditor; }
void SetRotation(bool bEnable);
void SetClearColor(const ColorF& color);
void SetBackgroundTexture(const QString& textureFilename);
void UseBackLight(bool bEnable);
bool UseBackLight() const { return m_bUseBacklight; }
void SetShowNormals(bool bShow) { m_bShowNormals = bShow; }
void SetShowPhysics(bool bShow) { m_bShowPhysics = bShow; }
void SetShowRenderInfo(bool bShow) { m_bShowRenderInfo = bShow; }
void EnableUpdate(bool bEnable);
bool IsUpdateEnabled() const { return m_bUpdate; }
void Update(bool bForceUpdate = false);
void ProcessKeys();
// this turns on and off aspect-ratio-maintaining. Use it when the widget is free to resize itself.
void SetAspectRatio(float newAspectRatio);
int heightForWidth(int w) const override;
bool hasHeightForWidth() const override;
void SetMaterial(CMaterial* pMaterial);
CMaterial* GetMaterial();
void GetImageOffscreen(CImageEx& image, const QSize& customSize = QSize(0, 0));
void GetCameraTM(Matrix34& cameraTM);
void SetCameraTM(const Matrix34& cameraTM);
// Place camera so that whole object fits on screen.
void FitToScreen();
// Get information about the preview model.
int GetFaceCount();
int GetVertexCount();
int GetMaxLod();
int GetMtlCount();
void SetShowObject(bool bShowObject) {m_bShowObject = bShowObject; }
bool GetShowObject() {return m_bShowObject; }
void SetAmbient(ColorF amb) { m_ambientColor = amb; }
void SetAmbientMultiplier(f32 multiplier) { m_ambientMultiplier = multiplier; }
typedef void (* CameraChangeCallback)(void* m_userData, CPreviewModelCtrl* m_currentCamera);
void SetCameraChangeCallback(CameraChangeCallback callback, void* userData) { m_cameraChangeCallback = callback, m_pCameraChangeUserData = userData; }
void EnableMaterialPrecaching(bool bPrecacheMaterial) { m_bPrecacheMaterial = bPrecacheMaterial; }
void EnableWireframeRendering(bool bDrawWireframe) { m_bDrawWireFrame = bDrawWireframe; }
public:
~CPreviewModelCtrl();
bool CreateContext();
void ReleaseObject();
void DeleteRenderContex();
protected:
void OnCreate();
void OnDestroy();
void OnLButtonDown(QPoint point);
void OnLButtonUp(QPoint point);
void OnMButtonDown(QPoint point);
void OnMButtonUp(QPoint point);
void OnRButtonUp(QPoint point);
void OnRButtonDown(QPoint point);
QPaintEngine* paintEngine() const override;
void showEvent(QShowEvent* event) override;
void paintEvent(QPaintEvent* event) override;
void timerEvent(QTimerEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
void wheelEvent(QWheelEvent* event) override;
virtual void OnEditorNotifyEvent(EEditorNotifyEvent event);
protected:
virtual bool Render();
virtual void SetCamera(CCamera& cam);
virtual void RenderObject(_smart_ptr<IMaterial> pMaterial, SRenderingPassInfo& passInfo);
HWND m_hWnd;
CCamera m_camera;
float m_fov;
struct SPreviousContext;
std::vector<SPreviousContext> m_previousContexts;
void SetOrbitAngles(const Ang3& ang);
void DrawGrid();
void DrawBackground();
_smart_ptr<IMaterial> GetCurrentMaterial();
_smart_ptr<IStatObj> m_pObj;
IRenderer* m_pRenderer;
bool m_bContextCreated;
Vec3 m_size;
Vec3 m_pos;
int m_nTimer;
bool m_useAspectRatio = false;
float m_aspectRatio = 1.0f;
QString m_loadedFile;
std::vector<CDLight> m_lights;
AABB m_aabb;
Vec3 m_cameraTarget;
float m_cameraRadius;
Vec3 m_cameraAngles;
bool m_bInRotateMode;
bool m_bInMoveMode;
bool m_bInPanMode;
QPoint m_mousePosition;
QPoint m_previousMousePosition;
IRenderNode* m_pEntity;
bool m_bHaveAnythingToRender;
bool m_bGrid;
bool m_bAxis;
bool m_bAxisParticleEditor;
bool m_bUpdate;
bool m_bRotate;
float m_rotateAngle;
ColorF m_clearColor;
ColorF m_ambientColor;
f32 m_ambientMultiplier;
bool m_bUseBacklight;
bool m_bShowObject;
bool m_bPrecacheMaterial;
bool m_bDrawWireFrame;
bool m_bShowNormals;
bool m_bShowPhysics;
bool m_bShowRenderInfo;
int m_backgroundTextureId;
float m_tileX;
float m_tileY;
float m_tileSizeX;
float m_tileSizeY;
_smart_ptr<CMaterial> m_pCurrentMaterial;
CameraChangeCallback m_cameraChangeCallback;
void* m_pCameraChangeUserData;
protected:
void StorePreviousContext();
void SetCurrentContext();
void RestorePreviousContext();
};
#endif // CRYINCLUDE_EDITOR_CONTROLS_PREVIEWMODELCTRL_H
@@ -29,14 +29,12 @@ void RegisterReflectedVarHandlers()
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew AnimationPropertyWidgetHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew FileResourceSelectorWidgetHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew ShaderPropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew MaterialPropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew ReverbPresetPropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew SequencePropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew SequenceIdPropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew LocalStringPropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew LightAnimationPropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew UserPopupWidgetHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew LensFlareHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew ColorCurveHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew FloatCurveHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew MotionPropertyWidgetHandler());
@@ -27,7 +27,6 @@
// Editor
#include "ShadersDialog.h"
#include "Material/MaterialManager.h"
#include "SelectLightAnimationDialog.h"
#include "SelectSequenceDialog.h"
#include "SelectEAXPresetDlg.h"
@@ -88,28 +87,6 @@ void ShaderPropertyEditor::onEditClicked()
}
}
void MaterialPropertyEditor::onEditClicked()
{
QString name = GetValue();
IDataBaseItem *pItem = GetIEditor()->GetMaterialManager()->FindItemByName(name);
GetIEditor()->OpenMaterialLibrary(pItem);
}
void MaterialPropertyEditor::onButton2Clicked()
{
// Open material browser dialog.
IDataBaseItem *pItem = GetIEditor()->GetMaterialManager()->GetSelectedItem();
if (pItem)
{
QString value = pItem->GetName();
value.replace('\\', '/');
if (value.length() >= MAX_PATH)
value = value.left(MAX_PATH);
SetValue(value);
}
else
SetValue(QString());
}
void ReverbPresetPropertyEditor::onEditClicked()
{
@@ -109,16 +109,6 @@ public:
void onEditClicked() override;
};
class MaterialPropertyEditor
: public GenericPopupPropertyEditor
{
public:
MaterialPropertyEditor(QWidget* pParent = nullptr)
: GenericPopupPropertyEditor(pParent, true){}
void onEditClicked() override;
void onButton2Clicked() override;
};
class ReverbPresetPropertyEditor
: public GenericPopupPropertyEditor
{
@@ -179,7 +169,6 @@ public:
#define CONST_AZ_CRC(name, value) AZ::u32(value)
using ShaderPropertyHandler = GenericPopupWidgetHandler<ShaderPropertyEditor, CONST_AZ_CRC("ePropertyShader", 0xc40932f1)>;
using MaterialPropertyHandler = GenericPopupWidgetHandler<MaterialPropertyEditor, CONST_AZ_CRC("ePropertyMaterial", 0xf324dffa)>;
using ReverbPresetPropertyHandler = GenericPopupWidgetHandler<ReverbPresetPropertyEditor, CONST_AZ_CRC("ePropertyReverbPreset", 0x51469f38)>;
using MissionObjPropertyHandler = GenericPopupWidgetHandler<MissionObjPropertyEditor, CONST_AZ_CRC("ePropertyMissionObj", 0x4a2d0dc8)>;
using SequencePropertyHandler = GenericPopupWidgetHandler<SequencePropertyEditor, CONST_AZ_CRC("ePropertySequence", 0xdd1c7d44)>;
@@ -25,7 +25,6 @@
// Editor
#include "GenericSelectItemDialog.h"
#include "QtViewPaneManager.h"
#include "LensFlareEditor/LensFlareEditor.h"
UserPropertyEditor::UserPropertyEditor(QWidget *pParent /*= nullptr*/)
@@ -147,79 +146,6 @@ bool UserPopupWidgetHandler::ReadValuesIntoGUI(size_t index, UserPropertyEditor*
#include <Controls/ReflectedPropertyControl/moc_PropertyMiscCtrl.cpp>
LensFlarePropertyWidget::LensFlarePropertyWidget(QWidget *pParent /*= nullptr*/)
:QWidget(pParent)
{
m_valueEdit = new QLineEdit;
QToolButton *mainButton = new QToolButton;
mainButton->setText("D");
connect(mainButton, &QToolButton::clicked, this, &LensFlarePropertyWidget::OnEditClicked);
connect(m_valueEdit, &QLineEdit::editingFinished, m_valueEdit, [this] () {emit ValueChanged(m_valueEdit->text());});
QHBoxLayout *mainLayout = new QHBoxLayout(this);
mainLayout->addWidget(m_valueEdit, 1);
mainLayout->addWidget(mainButton);
mainLayout->setContentsMargins(1, 1, 1, 1);
}
void LensFlarePropertyWidget::SetValue(const QString &value)
{
m_valueEdit->setText(value);
}
QString LensFlarePropertyWidget::GetValue() const
{
return m_valueEdit->text();
}
void LensFlarePropertyWidget::OnEditClicked()
{
const QtViewPane *lensFlarePane = GetIEditor()->OpenView(CLensFlareEditor::s_pLensFlareEditorClassName);
if (!lensFlarePane)
return;
CLensFlareEditor *editor = FindViewPane<CLensFlareEditor>(QtUtil::ToQString(CLensFlareEditor::s_pLensFlareEditorClassName));
if (editor)
QTimer::singleShot(0, editor, SLOT(OnUpdateTreeCtrl()));
}
QWidget* LensFlareHandler::CreateGUI(QWidget *pParent)
{
LensFlarePropertyWidget* newCtrl = aznew LensFlarePropertyWidget(pParent);
connect(newCtrl, &LensFlarePropertyWidget::ValueChanged, newCtrl, [newCtrl]()
{
EBUS_EVENT(AzToolsFramework::PropertyEditorGUIMessages::Bus, RequestWrite, newCtrl);
});
return newCtrl;
}
void LensFlareHandler::ConsumeAttribute(LensFlarePropertyWidget* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName)
{
Q_UNUSED(GUI); Q_UNUSED(attrib); Q_UNUSED(attrValue); Q_UNUSED(debugName);
}
void LensFlareHandler::WriteGUIValuesIntoProperty(size_t index, LensFlarePropertyWidget* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node)
{
Q_UNUSED(index);
Q_UNUSED(node);
CReflectedVarGenericProperty val = instance;
val.m_value = GUI->GetValue().toUtf8().data();
instance = static_cast<property_t>(val);
}
bool LensFlareHandler::ReadValuesIntoGUI(size_t index, LensFlarePropertyWidget* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node)
{
Q_UNUSED(index);
Q_UNUSED(node);
CReflectedVarGenericProperty val = instance;
GUI->SetValue(val.m_value.c_str());
return false;
}
QWidget* FloatCurveHandler::CreateGUI(QWidget *pParent)
{
CSplineCtrl *cSpline = new CSplineCtrl(pParent);
@@ -70,39 +70,6 @@ public:
};
class LensFlarePropertyWidget : public QWidget
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(LensFlarePropertyWidget, AZ::SystemAllocator, 0);
LensFlarePropertyWidget(QWidget *pParent = nullptr);
void SetValue(const QString &value);
QString GetValue() const;
void OnEditClicked();
signals:
void ValueChanged(const QString &value);
private:
QLineEdit *m_valueEdit;
};
class LensFlareHandler : public QObject, public AzToolsFramework::PropertyHandler < CReflectedVarGenericProperty, LensFlarePropertyWidget>
{
public:
AZ_CLASS_ALLOCATOR(LensFlareHandler, AZ::SystemAllocator, 0);
bool IsDefaultHandler() const override { return false; }
QWidget* CreateGUI(QWidget *pParent) override;
AZ::u32 GetHandlerName(void) const override { return AZ_CRC("ePropertyFlare", 0x5ce803df); }
void ConsumeAttribute(LensFlarePropertyWidget* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
void WriteGUIValuesIntoProperty(size_t index, LensFlarePropertyWidget* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
bool ReadValuesIntoGUI(size_t index, LensFlarePropertyWidget* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
};
class FloatCurveHandler : public QObject, public AzToolsFramework::PropertyHandler < CReflectedVarSpline, CSplineCtrl>
{
public:
@@ -1,187 +1,64 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates, or
* a third party where indicated.
*
* 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.
*
*/
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates, or
* a third party where indicated.
*
* 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 "EditorDefs.h"
#include "PropertyMotionCtrl.h"
// Qt
#include <QHBoxLayout>
#include <QLabel>
#include <QToolButton>
// AzToolsFramework
#include <AzToolsFramework/AssetBrowser/AssetSelectionModel.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/AssetBrowser/AssetSelectionModel.h>
MotionPropertyCtrl::MotionPropertyCtrl(QWidget *pParent)
: QWidget(pParent)
QWidget* MotionPropertyWidgetHandler::CreateGUI(QWidget* pParent)
{
m_motionLabel = new QLabel;
m_pBrowseButton = new QToolButton;
m_pBrowseButton->setIcon(QIcon(":/reflectedPropertyCtrl/img/file_browse.png"));
m_pApplyButton = new QToolButton;
m_pApplyButton->setIcon(QIcon(":/reflectedPropertyCtrl/img/apply.png"));
m_pApplyButton->setFocusPolicy(Qt::StrongFocus);
m_pBrowseButton->setFocusPolicy(Qt::StrongFocus);
QHBoxLayout *pLayout = new QHBoxLayout(this);
pLayout->setContentsMargins(0, 0, 0, 0);
pLayout->addWidget(m_motionLabel, 1);
pLayout->addWidget(m_pBrowseButton);
pLayout->addWidget(m_pApplyButton);
connect(m_pBrowseButton, &QAbstractButton::clicked, this, &MotionPropertyCtrl::OnBrowseClicked);
connect(m_pApplyButton, &QAbstractButton::clicked, this, &MotionPropertyCtrl::OnApplyClicked);
};
MotionPropertyCtrl::~MotionPropertyCtrl()
{
}
void MotionPropertyCtrl::SetValue(const CReflectedVarMotion &motion)
{
m_motion = motion;
SetLabelText(motion.m_motion);
}
CReflectedVarMotion MotionPropertyCtrl::value() const
{
return m_motion;
}
void MotionPropertyCtrl::OnBrowseClicked()
{
static AZ::Data::AssetType emotionFXMotionAssetType("{00494B8E-7578-4BA2-8B28-272E90680787}"); // from MotionAsset.h in EMotionFX Gem
// Request the AssetBrowser Dialog and set a type filter
AssetSelectionModel selection = AssetSelectionModel::AssetTypeSelection(emotionFXMotionAssetType);
selection.SetSelectedAssetId(m_motion.m_assetId);
AzToolsFramework::EditorRequests::Bus::Broadcast(&AzToolsFramework::EditorRequests::BrowseForAssets, selection);
if (selection.IsValid())
{
auto product = azrtti_cast<const ProductAssetBrowserEntry*>(selection.GetResult());
if (product != nullptr)
{
m_motion.m_motion = product->GetRelativePath();
m_motion.m_assetId = product->GetAssetId();
SetLabelText(m_motion.m_motion);
emit ValueChanged(m_motion);
}
}
}
// TODO: Might be able to delete this function
void MotionPropertyCtrl::OnApplyClicked()
{
#if 0
CUIEnumerations &roGeneralProxy = CUIEnumerations::GetUIEnumerationsInstance();
QStringList cSelectedMotions;
size_t nTotalMotions(0);
size_t nCurrentMotion(0);
QString combinedString = GetIEditor()->GetResourceSelectorHost()->GetGlobalSelection("motion");
SplitString(combinedString, cSelectedMotions, ',');
nTotalMotions = cSelectedMotions.size();
for (nCurrentMotion = 0; nCurrentMotion < nTotalMotions; ++nCurrentMotion)
{
QString& rstrCurrentAnimAction = cSelectedMotions[nCurrentMotion];
if (!rstrCurrentAnimAction.isEmpty())
{
m_motion.m_motion = rstrCurrentAnimAction.toLatin1().data();
SetLabelText(m_motion.m_motion);
emit ValueChanged(m_motion);
}
}
#endif
}
QWidget* MotionPropertyCtrl::GetFirstInTabOrder()
{
return m_pBrowseButton;
}
QWidget* MotionPropertyCtrl::GetLastInTabOrder()
{
return m_pApplyButton;
}
void MotionPropertyCtrl::UpdateTabOrder()
{
setTabOrder(m_pBrowseButton, m_pApplyButton);
}
void MotionPropertyCtrl::SetLabelText(const AZStd::string& motion)
{
if (!motion.empty())
{
AZStd::string filename;
if (AzFramework::StringFunc::Path::GetFileName(motion.c_str(), filename))
{
m_motionLabel->setText(filename.c_str());
}
else
{
m_motionLabel->setText(motion.c_str());
}
}
else
{
m_motionLabel->setText("");
}
}
QWidget* MotionPropertyWidgetHandler::CreateGUI(QWidget *pParent)
{
MotionPropertyCtrl* newCtrl = aznew MotionPropertyCtrl(pParent);
connect(newCtrl, &MotionPropertyCtrl::ValueChanged, newCtrl, [newCtrl]()
{
EBUS_EVENT(AzToolsFramework::PropertyEditorGUIMessages::Bus, RequestWrite, newCtrl);
});
AzToolsFramework::PropertyAssetCtrl* newCtrl = aznew AzToolsFramework::PropertyAssetCtrl(pParent);
connect(
newCtrl, &AzToolsFramework::PropertyAssetCtrl::OnAssetIDChanged, this, [newCtrl]([[maybe_unused]] AZ::Data::AssetId newAssetId) {
EBUS_EVENT(AzToolsFramework::PropertyEditorGUIMessages::Bus, RequestWrite, newCtrl);
AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(
&AzToolsFramework::PropertyEditorGUIMessages::Bus::Handler::OnEditingFinished, newCtrl);
});
return newCtrl;
}
void MotionPropertyWidgetHandler::ConsumeAttribute(MotionPropertyCtrl* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName)
void MotionPropertyWidgetHandler::ConsumeAttribute(
[[maybe_unused]] AzToolsFramework::PropertyAssetCtrl* GUI, [[maybe_unused]] AZ::u32 attrib,
[[maybe_unused]] AzToolsFramework::PropertyAttributeReader* attrValue, [[maybe_unused]] const char* debugName)
{
Q_UNUSED(GUI);
Q_UNUSED(attrib);
Q_UNUSED(attrValue);
Q_UNUSED(debugName);
}
void MotionPropertyWidgetHandler::WriteGUIValuesIntoProperty(size_t index, MotionPropertyCtrl* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node)
void MotionPropertyWidgetHandler::WriteGUIValuesIntoProperty(
[[maybe_unused]] size_t index, [[maybe_unused]] AzToolsFramework::PropertyAssetCtrl* GUI, property_t& instance,
[[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
{
Q_UNUSED(index);
Q_UNUSED(node);
CReflectedVarMotion val = GUI->value();
CReflectedVarMotion val;
val.m_motion = GUI->GetCurrentAssetHint();
val.m_assetId = GUI->GetSelectedAssetID();
instance = static_cast<property_t>(val);
}
bool MotionPropertyWidgetHandler::ReadValuesIntoGUI(size_t index, MotionPropertyCtrl* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node)
bool MotionPropertyWidgetHandler::ReadValuesIntoGUI(
[[maybe_unused]] size_t index, [[maybe_unused]] AzToolsFramework::PropertyAssetCtrl* GUI, const property_t& instance,
[[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
{
Q_UNUSED(index);
Q_UNUSED(node);
CReflectedVarMotion val = instance;
GUI->SetValue(val);
static const AZ::Data::AssetType emotionFXMotionAssetType(
"{00494B8E-7578-4BA2-8B28-272E90680787}"); // from MotionAsset.h in EMotionFX Gem
GUI->blockSignals(true);
GUI->SetSelectedAssetID(instance.m_assetId);
GUI->SetCurrentAssetType(emotionFXMotionAssetType);
GUI->blockSignals(false);
return false;
}
#include <Controls/ReflectedPropertyControl/moc_PropertyMotionCtrl.cpp>
@@ -1,92 +1,67 @@
/*
* 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.
*
*/
* 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.
*
*/
#ifndef CRYINCLUDE_EDITOR_UTILS_PROPERTYMOTIONCTRL_H
#define CRYINCLUDE_EDITOR_UTILS_PROPERTYMOTIONCTRL_H
#pragma once
#if !defined(Q_MOC_RUN)
#include <AzCore/base.h>
#include <AzCore/Memory/SystemAllocator.h>
#include "ReflectedVar.h"
#include <QWidget>
#include <QPointer>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/base.h>
#include <AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.hxx>
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
#include <QPointer>
#include <QWidget>
#endif
class QToolButton;
class QLabel;
class QHBoxLayout;
namespace AzToolsFramework
{
class PropertyAssetCtrl;
}
class MotionPropertyCtrl
: public QWidget
class MotionPropertyWidgetHandler : QObject,
public AzToolsFramework::PropertyHandler<CReflectedVarMotion, AzToolsFramework::PropertyAssetCtrl>
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(MotionPropertyCtrl, AZ::SystemAllocator, 0);
MotionPropertyCtrl(QWidget* pParent = nullptr);
virtual ~MotionPropertyCtrl();
CReflectedVarMotion value() const;
QWidget* GetFirstInTabOrder();
QWidget* GetLastInTabOrder();
void UpdateTabOrder();
signals:
void ValueChanged(CReflectedVarMotion value);
public slots:
void SetValue(const CReflectedVarMotion& motion);
protected slots:
void OnBrowseClicked();
void OnApplyClicked();
private:
void SetLabelText(const AZStd::string& motion);
QToolButton* m_pBrowseButton;
QToolButton* m_pApplyButton;
QLabel* m_motionLabel;
CReflectedVarMotion m_motion;
};
class MotionPropertyWidgetHandler
: QObject
, public AzToolsFramework::PropertyHandler < CReflectedVarMotion, MotionPropertyCtrl >
{
public:
AZ_CLASS_ALLOCATOR(MotionPropertyWidgetHandler, AZ::SystemAllocator, 0);
virtual AZ::u32 GetHandlerName(void) const override { return AZ_CRC("Motion", 0xf5fea1e8); }
virtual bool IsDefaultHandler() const override { return true; }
virtual QWidget* GetFirstInTabOrder(MotionPropertyCtrl* widget) override { return widget->GetFirstInTabOrder(); }
virtual QWidget* GetLastInTabOrder(MotionPropertyCtrl* widget) override { return widget->GetLastInTabOrder(); }
virtual void UpdateWidgetInternalTabbing(MotionPropertyCtrl* widget) override { widget->UpdateTabOrder(); }
virtual AZ::u32 GetHandlerName(void) const override
{
return AZ_CRC("Motion", 0xf5fea1e8);
}
virtual bool IsDefaultHandler() const override
{
return true;
}
virtual QWidget* GetFirstInTabOrder(AzToolsFramework::PropertyAssetCtrl* widget) override
{
return widget->GetFirstInTabOrder();
}
virtual QWidget* GetLastInTabOrder(AzToolsFramework::PropertyAssetCtrl* widget) override
{
return widget->GetLastInTabOrder();
}
virtual void UpdateWidgetInternalTabbing(AzToolsFramework::PropertyAssetCtrl* widget) override
{
widget->UpdateTabOrder();
}
virtual QWidget* CreateGUI(QWidget* pParent) override;
virtual void ConsumeAttribute(MotionPropertyCtrl* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
virtual void WriteGUIValuesIntoProperty(size_t index, MotionPropertyCtrl* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
virtual bool ReadValuesIntoGUI(size_t index, MotionPropertyCtrl* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
virtual void ConsumeAttribute(
AzToolsFramework::PropertyAssetCtrl* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue,
const char* debugName) override;
virtual void WriteGUIValuesIntoProperty(
size_t index, AzToolsFramework::PropertyAssetCtrl* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
virtual bool ReadValuesIntoGUI(
size_t index, AzToolsFramework::PropertyAssetCtrl* GUI, const property_t& instance,
AzToolsFramework::InstanceDataNode* node) override;
};
#endif // CRYINCLUDE_EDITOR_UTILS_PROPERTYMOTIONCTRL_H
@@ -111,14 +111,12 @@ private:
{
case ePropertyTexture:
case ePropertyModel:
case ePropertyMaterial:
newPath.replace("\\\\", "/");
}
switch (m_propertyType)
{
case ePropertyTexture:
case ePropertyModel:
case ePropertyMaterial:
case ePropertyFile:
if (newPath.size() > MAX_PATH)
{
@@ -361,16 +361,6 @@ void ReflectedPropertyControl::CreateItems(XmlNodeRef node, CVarBlockPtr& outBlo
textureVar->Set(textureName);
}
}
else if (!azstricmp(type, "material"))
{
CSmartVariable<QString> materialVar;
AddVariable(group, materialVar, child->getTag(), humanReadableName.toUtf8().data(), strDescription.toUtf8().data(), func, pUserData, IVariable::DT_MATERIAL);
const char* materialName;
if (child->getAttr("value", &materialName))
{
materialVar->Set(materialName);
}
}
else if (!azstricmp(type, "color"))
{
CSmartVariable<Vec3> colorVar;
@@ -269,7 +269,6 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
m_reflectedVarAdapter = new ReflectedVarUserAdapter;
break;
case ePropertyShader:
case ePropertyMaterial:
case ePropertyEquip:
case ePropertyReverbPreset:
case ePropertyGameToken:
@@ -279,7 +278,6 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
case ePropertyLocalString:
case ePropertyLightAnimation:
case ePropertyParticleName:
case ePropertyFlare:
m_reflectedVarAdapter = new ReflectedVarGenericPropertyAdapter(desc.m_type);
break;
case ePropertyTexture:
@@ -577,7 +575,6 @@ void ReflectedPropertyItem::SetValue(const QString& sValue, bool bRecordUndo, bo
case ePropertyTexture:
case ePropertyModel:
case ePropertyMaterial:
value.replace('\\', '/');
break;
}
@@ -587,7 +584,6 @@ void ReflectedPropertyItem::SetValue(const QString& sValue, bool bRecordUndo, bo
{
case ePropertyTexture:
case ePropertyModel:
case ePropertyMaterial:
case ePropertyFile:
if (value.length() >= MAX_PATH)
{
@@ -286,8 +286,6 @@ AZ::u32 CReflectedVarGenericProperty::handler()
{
case ePropertyShader:
return AZ_CRC("ePropertyShader", 0xc40932f1);
case ePropertyMaterial:
return AZ_CRC("ePropertyMaterial", 0xf324dffa);
case ePropertyEquip:
return AZ_CRC("ePropertyEquip", 0x66ffd290);
case ePropertyReverbPreset:
@@ -308,8 +306,6 @@ AZ::u32 CReflectedVarGenericProperty::handler()
return AZ_CRC("ePropertyLightAnimation", 0x277097da);
case ePropertyParticleName:
return AZ_CRC("ePropertyParticleName", 0xf44c7133);
case ePropertyFlare:
return AZ_CRC("ePropertyFlare", 0x5ce803df);
default:
AZ_Assert(false, "No property handlers defined for the property type");
return AZ_CRC("Default", 0xe35e00df);
@@ -455,8 +455,6 @@ void ReflectedVarGenericPropertyAdapter::SyncReflectedVarToIVar(IVariable *pVari
{
QString value;
pVariable->Get(value);
if (m_reflectedVar->m_propertyType == ePropertyMaterial)
value.replace('\\', '/');
m_reflectedVar->m_value = value.toUtf8().data();
}
@@ -1,26 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : implementation file
#include "EditorDefs.h"
#include "TimeOfDaySlider.h"
QString TimeOfDaySlider::hoverValueText(int sliderValue) const
{
return QString::fromLatin1("%1:%2").arg(static_cast<int>(sliderValue / 60)).arg(sliderValue % 60, 2, 10, QLatin1Char('0'));
}
#include <Controls/moc_TimeOfDaySlider.cpp>
@@ -1,34 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_TIMEOFDAYSLIDER_H
#define CRYINCLUDE_EDITOR_TIMEOFDAYSLIDER_H
#pragma once
#if !defined(Q_MOC_RUN)
#include <AzQtComponents/Components/Widgets/Slider.h>
#endif
class TimeOfDaySlider
: public AzQtComponents::SliderInt
{
Q_OBJECT
public:
using AzQtComponents::SliderInt::SliderInt;
protected:
QString hoverValueText(int sliderValue) const override;
};
#endif // CRYINCLUDE_EDITOR_TIMEOFDAYSLIDER_H
@@ -23,7 +23,6 @@
#include "Objects/SelectionGroup.h"
#include "ViewManager.h"
#include <AzFramework/API/AtomActiveInterface.h>
#include <AzCore/Interface/Interface.h>
// Qt
@@ -458,8 +457,6 @@ QMenu* LevelEditorMenuHandler::CreateFileMenu()
void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMenu)
{
const bool newViewportInteractionModelEnabled = GetIEditor()->IsNewViewportInteractionModelEnabled();
// Undo
editMenu.AddAction(ID_UNDO);
@@ -496,40 +493,21 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe
// Select All
editMenu.AddAction(ID_EDIT_SELECTALL);
// Deselect All
if (!newViewportInteractionModelEnabled)
{
editMenu.AddAction(ID_EDIT_SELECTNONE);
}
// Invert Selection
editMenu.AddAction(ID_EDIT_INVERTSELECTION);
editMenu.AddSeparator();
// New Viewport Interaction Model actions/shortcuts
if (newViewportInteractionModelEnabled)
{
editMenu.AddAction(ID_EDIT_PIVOT);
editMenu.AddAction(ID_EDIT_RESET);
editMenu.AddAction(ID_EDIT_RESET_MANIPULATOR);
editMenu.AddAction(ID_EDIT_RESET_LOCAL);
editMenu.AddAction(ID_EDIT_RESET_WORLD);
}
editMenu.AddAction(ID_EDIT_PIVOT);
editMenu.AddAction(ID_EDIT_RESET);
editMenu.AddAction(ID_EDIT_RESET_MANIPULATOR);
editMenu.AddAction(ID_EDIT_RESET_LOCAL);
editMenu.AddAction(ID_EDIT_RESET_WORLD);
// Hide Selection
editMenu.AddAction(ID_EDIT_HIDE);
if (!newViewportInteractionModelEnabled)
{
// Show Selection
auto showSelectionMenu = editMenu.Get()->addAction(tr("Show Selection"));
connect(showSelectionMenu, &QAction::triggered, this, [this]() { ToggleSelection(false); });
// Show Last Hidden
editMenu.AddAction(ID_EDIT_SHOW_LAST_HIDDEN);
}
// Unhide All
editMenu.AddAction(ID_EDIT_UNHIDEALL);
@@ -572,31 +550,10 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe
// Modify Menu
auto modifyMenu = editMenu.AddMenu(tr("&Modify"));
if (!newViewportInteractionModelEnabled)
{
modifyMenu.AddAction(ID_MODIFY_LINK);
modifyMenu.AddAction(ID_MODIFY_UNLINK);
modifyMenu.AddSeparator();
}
auto snapMenu = modifyMenu.AddMenu(tr("Snap"));
if (!newViewportInteractionModelEnabled)
{
snapMenu.AddAction(ID_SNAP_TO_GRID);
}
snapMenu.AddAction(ID_SNAPANGLE);
if (!newViewportInteractionModelEnabled)
{
auto fastRotateMenu = modifyMenu.AddMenu(tr("Fast Rotate"));
fastRotateMenu.AddAction(ID_ROTATESELECTION_XAXIS);
fastRotateMenu.AddAction(ID_ROTATESELECTION_YAXIS);
fastRotateMenu.AddAction(ID_ROTATESELECTION_ZAXIS);
fastRotateMenu.AddAction(ID_ROTATESELECTION_ROTATEANGLE);
}
auto transformModeMenu = modifyMenu.AddMenu(tr("Transform Mode"));
transformModeMenu.AddAction(ID_EDITMODE_MOVE);
transformModeMenu.AddAction(ID_EDITMODE_ROTATE);
@@ -604,21 +561,6 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe
editMenu.AddSeparator();
// Lock Selection
editMenu.AddAction(ID_EDIT_FREEZE);
// NEWMENUS: NEEDS IMPLEMENTATION
//// Unlock Selection
//auto unlockSelectionMenu = editMenu.Get()->addAction(tr("Unlock Selection"));
//// Unlock Last Locked
//auto unlockLastLockedMenu = editMenu.Get()->addAction(tr("Unlock Last Locked"));
// Unlock All
editMenu.AddAction(ID_EDIT_UNFREEZEALL);
editMenu.AddSeparator();
// Editor Settings
auto editorSettingsMenu = editMenu.AddMenu(tr("Editor Settings"));
@@ -725,12 +667,6 @@ QMenu* LevelEditorMenuHandler::CreateGameMenu()
gameMenu.AddSeparator();
if (!GetIEditor()->IsNewViewportInteractionModelEnabled())
{
gameMenu.AddAction(ID_TERRAIN_VEGETATION);
gameMenu.AddSeparator();
}
CreateDebuggingSubMenu(gameMenu);
return gameMenu;
@@ -793,12 +729,6 @@ QMenu* LevelEditorMenuHandler::CreateViewMenu()
viewportViewsMenuWrapper.AddAction(ID_WIREFRAME);
viewportViewsMenuWrapper.AddSeparator();
if (!GetIEditor()->IsNewViewportInteractionModelEnabled())
{
// Ruler
viewportViewsMenuWrapper.AddAction(ID_RULER);
}
viewportViewsMenuWrapper.AddAction(ID_VIEW_GRIDSETTINGS);
viewportViewsMenuWrapper.AddSeparator();
@@ -1234,22 +1164,6 @@ void LevelEditorMenuHandler::ClearAll()
UpdateMRUFiles();
}
void LevelEditorMenuHandler::ToggleSelection(bool hide)
{
CCryEditApp::instance()->OnToggleSelection(hide);
}
// Used for showing last hidden objects
void LevelEditorMenuHandler::ShowLastHidden()
{
CSelectionGroup* sel = GetIEditor()->GetSelection();
if (!sel->IsEmpty())
{
CUndo undo("Show Last Hidden");
GetIEditor()->GetObjectManager()->ShowLastHiddenObject();
}
}
// Used for disabling "Open Recent" menu option
void LevelEditorMenuHandler::OnUpdateOpenRecent()
{
@@ -78,8 +78,6 @@ private:
void UpdateMRUFiles();
void ClearAll();
void ToggleSelection(bool hide);
void ShowLastHidden();
void OnUpdateOpenRecent();
void OnUpdateMacrosMenu();
File diff suppressed because it is too large Load Diff
-37
View File
@@ -116,7 +116,6 @@ public:
static CCryEditApp* instance();
bool GetRootEnginePath(QDir& rootEnginePath) const;
void OnToggleSelection(bool hide);
bool CreateLevel(bool& wasCreateLevelOperationCancelled);
void LoadFile(QString fileName);
void ForceNextIdleProcessing() { m_bForceProcessIdle = true; }
@@ -210,44 +209,30 @@ public:
void OnExportSelectedObjects();
void OnEditHold();
void OnEditFetch();
void OnGeneratorsStaticobjects();
void OnFileExportToGameNoSurfaceTexture();
void OnViewSwitchToGame();
void OnViewDeploy();
void OnEditSelectAll();
void OnEditSelectNone();
void OnEditDelete();
void DeleteSelectedEntities(bool includeDescendants);
void OnMoveObject();
void OnRenameObj();
void OnSetHeight();
void OnEditmodeMove();
void OnEditmodeRotate();
void OnEditmodeScale();
void OnObjectSetArea();
void OnObjectSetHeight();
void OnUpdateEditmodeMove(QAction* action);
void OnUpdateEditmodeRotate(QAction* action);
void OnUpdateEditmodeScale(QAction* action);
void OnObjectmodifyFreeze();
void OnObjectmodifyUnfreeze();
void OnUndo();
void OnSelectionSave();
void OnOpenAssetImporter();
void OnSelectionLoad();
void OnUpdateSelected(QAction* action);
void OnLockSelection();
void OnEditLevelData();
void OnFileEditLogFile();
void OnFileResaveSlices();
void OnFileEditEditorini();
void OnPreferences();
void OnReloadTextures();
void OnReloadGeometry();
void OnRedo();
void OnUpdateRedo(QAction* action);
void OnUpdateUndo(QAction* action);
void OnGenerateCgfThumbnails();
void OnSwitchPhysics();
void OnSwitchPhysicsUpdate(QAction* action);
void OnSyncPlayer();
@@ -386,13 +371,6 @@ private:
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
friend struct PythonTestOutputHandler;
void OnEditHide();
void OnUpdateEditHide(QAction* action);
void OnEditShowLastHidden();
void OnEditUnhideall();
void OnEditFreeze();
void OnUpdateEditFreeze(QAction* action);
void OnEditUnfreezeall();
void OnSnap();
void OnWireframe();
void OnUpdateWireframe(QAction* action);
@@ -433,26 +411,14 @@ private:
void OnDisplayGotoPosition();
void OnSnapangle();
void OnUpdateSnapangle(QAction* action);
void OnRuler();
void OnUpdateRuler(QAction* action);
void OnRotateselectionXaxis();
void OnRotateselectionYaxis();
void OnRotateselectionZaxis();
void OnRotateselectionRotateangle();
void OnEditRenameobject();
void OnChangemovespeedIncrease();
void OnChangemovespeedDecrease();
void OnChangemovespeedChangestep();
void OnMaterialAssigncurrent();
void OnMaterialResettodefault();
void OnMaterialGetmaterial();
void OnFileSavelevelresources();
void OnClearRegistryData();
void OnValidatelevel();
void OnValidateObjectPositions();
void OnToolsPreferences();
void OnGraphicsSettings();
void OnEditInvertselection();
void OnSwitchToDefaultCamera();
void OnUpdateSwitchToDefaultCamera(QAction* action);
void OnSwitchToSequenceCamera();
@@ -461,13 +427,10 @@ private:
void OnUpdateSwitchToSelectedCamera(QAction* action);
void OnSwitchcameraNext();
void OnOpenProceduralMaterialEditor();
void OnOpenMaterialEditor();
void OnOpenAssetBrowserView();
void OnOpenTrackView();
void OnOpenAudioControlsEditor();
void OnOpenUICanvasEditor();
void OnGotoViewportSearch();
void OnTimeOfDay();
void OnChangeGameSpec(UINT nID);
void SetGameSpecCheck(ESystemConfigSpec spec, ESystemConfigPlatform platform, int &nCheck, bool &enable);
void OnUpdateGameSpec(QAction* action);
+13 -336
View File
@@ -27,7 +27,6 @@
// AzFramework
#include <AzFramework/Archive/IArchive.h>
#include <AzFramework/API/ApplicationAPI.h>
#include <AzFramework/API/AtomActiveInterface.h>
// AzToolsFramework
#include <AzToolsFramework/Slice/SliceUtilities.h>
@@ -43,7 +42,6 @@
#include "Settings.h"
#include "PluginManager.h"
#include "Mission.h"
#include "ViewManager.h"
#include "DisplaySettings.h"
#include "GameEngine.h"
@@ -51,8 +49,6 @@
#include "CryEdit.h"
#include "ActionManager.h"
#include "Include/IObjectManager.h"
#include "Material/MaterialManager.h"
#include "LensFlareEditor/LensFlareManager.h"
#include "ErrorReportDialog.h"
#include "SurfaceTypeValidator.h"
#include "ShaderCache.h"
@@ -60,11 +56,13 @@
#include "CheckOutDialog.h"
#include "GameExporter.h"
#include "MainWindow.h"
#include "ITimeOfDay.h"
#include "LevelFileDialog.h"
#include "StatObjBus.h"
// LmbrCentral
#include <ModernViewportCameraController.h>
#include <Atom/RPI.Public/ViewportContext.h>
#include <Atom/RPI.Public/ViewportContextBus.h>
#include <LmbrCentral/Rendering/EditorLightComponentBus.h> // for LmbrCentral::EditorLightComponentRequestBus
@@ -83,7 +81,7 @@ static const char* kHoldFolder = "$tmp_hold"; // conform to the ignored file typ
static const char* kSaveBackupFolder = "_savebackup";
static const char* kResizeTempFolder = "$tmp_resize"; // conform to the ignored file types $tmp[0-9]*_ regex
static const char* kBackupOrTempFolders[] =
static const char* kBackupOrTempFolders[] =
{
kAutoBackupFolder,
kHoldFolder,
@@ -123,7 +121,6 @@ CCryEditDoc::CCryEditDoc()
// The right way would require us to save to the level folder the export status of the
// level.
, m_boLevelExported(true)
, m_mission(NULL)
, m_modified(false)
, m_envProbeHeight(200.0f)
, m_envProbeSliceRelativePath("EngineAssets/Slices/DefaultLevelSetup.slice")
@@ -158,7 +155,6 @@ CCryEditDoc::CCryEditDoc()
CCryEditDoc::~CCryEditDoc()
{
GetIEditor()->SetDocument(nullptr);
ClearMissions();
delete m_pLevelShaderCache;
@@ -255,17 +251,6 @@ bool CCryEditDoc::Save()
return OnSaveDocument(GetActivePathName());
}
void CCryEditDoc::ChangeMission()
{
GetIEditor()->Notify(eNotify_OnMissionChange);
// Notify listeners.
for (std::list<IDocListener*>::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it)
{
(*it)->OnMissionChange();
}
}
void CCryEditDoc::DeleteContents()
{
m_hasErrors = false;
@@ -295,10 +280,6 @@ void CCryEditDoc::DeleteContents()
// Delete all objects from Object Manager.
GetIEditor()->GetObjectManager()->DeleteAllObjects();
ClearMissions();
GetIEditor()->GetGameEngine()->ResetResources();
// Load scripts data
SetModifiedFlag(FALSE);
SetModifiedModules(eModifiedNothing);
@@ -341,7 +322,6 @@ void CCryEditDoc::Save(TDocMultiArchive& arrXmlAr)
if (!isPrefabEnabled)
{
CAutoDocNotReady autoDocNotReady;
QString currentMissionName;
if (arrXmlAr[DMAS_GENERAL] != NULL)
{
@@ -356,12 +336,6 @@ void CCryEditDoc::Save(TDocMultiArchive& arrXmlAr)
// Fog settings ///////////////////////////////////////////////////////
SerializeFogSettings((*arrXmlAr[DMAS_GENERAL]));
// Serialize Missions //////////////////////////////////////////////////
SerializeMissions(arrXmlAr, currentMissionName, false);
//! Serialize material manager.
GetIEditor()->GetMaterialManager()->Serialize((*arrXmlAr[DMAS_GENERAL]).root, (*arrXmlAr[DMAS_GENERAL]).bLoading);
//! Serialize LensFlare manager.
GetIEditor()->GetLensFlareManager()->Serialize((*arrXmlAr[DMAS_GENERAL]).root, (*arrXmlAr[DMAS_GENERAL]).bLoading);
SerializeShaderCache((*arrXmlAr[DMAS_GENERAL_NAMED_DATA]));
SerializeNameSelection((*arrXmlAr[DMAS_GENERAL]));
@@ -408,7 +382,6 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
HEAP_CHECK
CLogFile::FormatLine("Loading from %s...", szFilename.toUtf8().data());
QString currentMissionName;
QString szLevelPath = Path::GetPath(szFilename);
{
@@ -486,27 +459,9 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
}
HEAP_CHECK
if (!isPrefabEnabled)
{
// multiple missions are no longer supported, only load the current mission (last used)
SerializeMissions(arrXmlAr, currentMissionName, false);
}
HEAP_CHECK
if (GetIEditor()->Get3DEngine())
{
if (!isPrefabEnabled)
{
GetIEditor()->Get3DEngine()->LoadCompiledOctreeForEditor();
}
}
{
CAutoLogTime logtime("Game Engine level load");
GetIEditor()->GetGameEngine()->LoadLevel(currentMissionName, true, true);
GetIEditor()->GetGameEngine()->LoadLevel(true, true);
}
if (!isPrefabEnabled)
@@ -516,22 +471,6 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
//////////////////////////////////////////////////////////////////////////
(*arrXmlAr[DMAS_GENERAL]).root->getAttr("WaterColor", m_waterColor);
//////////////////////////////////////////////////////////////////////////
// Load materials.
//////////////////////////////////////////////////////////////////////////
{
CAutoLogTime logtime("Load MaterialManager");
GetIEditor()->GetMaterialManager()->Serialize((*arrXmlAr[DMAS_GENERAL]).root, (*arrXmlAr[DMAS_GENERAL]).bLoading);
}
//////////////////////////////////////////////////////////////////////////
// Load LensFlares.
//////////////////////////////////////////////////////////////////////////
{
CAutoLogTime logtime("Load Flares");
GetIEditor()->GetLensFlareManager()->Serialize((*arrXmlAr[DMAS_GENERAL]).root, (*arrXmlAr[DMAS_GENERAL]).bLoading);
}
//////////////////////////////////////////////////////////////////////////
// Load View Settings
//////////////////////////////////////////////////////////////////////////
@@ -543,27 +482,6 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
SerializeFogSettings((*arrXmlAr[DMAS_GENERAL]));
}
{
QByteArray str;
str = tr("Activating Mission %1").arg(currentMissionName).toUtf8();
CAutoLogTime logtime(str.data());
// Select current mission.
m_mission = FindMission(currentMissionName);
if (m_mission)
{
SyncCurrentMissionContent(true);
}
else
{
GetCurrentMission();
}
}
ForceSkyUpdate();
if (!isPrefabEnabled)
{
// Serialize Shader Cache.
@@ -669,6 +587,7 @@ void CCryEditDoc::SerializeViewSettings(CXmlArchive& xmlAr)
CViewport* pVP = GetIEditor()->GetViewManager()->GetView(i);
if (pVP)
{
Matrix34 tm = Matrix34::CreateRotationXYZ(va);
@@ -749,94 +668,6 @@ void CCryEditDoc::SerializeFogSettings(CXmlArchive& xmlAr)
}
}
void CCryEditDoc::SerializeMissions(TDocMultiArchive& arrXmlAr, QString& currentMissionName, bool bPartsInXml)
{
bool bLoading = IsLoadingXmlArArray(arrXmlAr);
if (bLoading)
{
// Loading
CLogFile::WriteLine("Loading missions...");
// Clear old layers
ClearMissions();
// Load shared objects and layers.
XmlNodeRef objectsNode = arrXmlAr[DMAS_GENERAL]->root->findChild("Objects");
XmlNodeRef objectLayersNode = arrXmlAr[DMAS_GENERAL]->root->findChild("ObjectLayers");
// Load the layer count
XmlNodeRef node = arrXmlAr[DMAS_GENERAL]->root->findChild("Missions");
if (!node)
{
return;
}
QString current;
node->getAttr("Current", current);
currentMissionName = current;
// Read all node
for (int i = 0; i < node->getChildCount(); i++)
{
CXmlArchive ar(*arrXmlAr[DMAS_GENERAL]);
ar.root = node->getChild(i);
CMission* mission = new CMission(this);
mission->Serialize(ar);
if (bPartsInXml)
{
mission->SerializeTimeOfDay(*arrXmlAr[DMAS_TIME_OF_DAY]);
mission->SerializeEnvironment(*arrXmlAr[DMAS_ENVIRONMENT]);
}
else
{
mission->LoadParts();
}
// Timur[9/11/2002] For backward compatibility with shared objects
if (objectsNode)
{
mission->AddObjectsNode(objectsNode);
}
if (objectLayersNode)
{
mission->SetLayersNode(objectLayersNode);
}
AddMission(mission);
}
}
else
{
// Storing
CLogFile::WriteLine("Storing missions...");
// Save contents of current mission.
SyncCurrentMissionContent(false);
XmlNodeRef node = arrXmlAr[DMAS_GENERAL]->root->newChild("Missions");
//! Store current mission name.
currentMissionName = GetCurrentMission()->GetName();
node->setAttr("Current", currentMissionName.toUtf8().data());
// Write all surface types.
for (int i = 0; i < m_missions.size(); i++)
{
CXmlArchive ar(*arrXmlAr[DMAS_GENERAL]);
ar.root = node->newChild("Mission");
m_missions[i]->Serialize(ar, false);
if (bPartsInXml)
{
m_missions[i]->SerializeTimeOfDay(*arrXmlAr[DMAS_TIME_OF_DAY]);
m_missions[i]->SerializeEnvironment(*arrXmlAr[DMAS_ENVIRONMENT]);
}
else
{
m_missions[i]->SaveParts();
}
}
CLogFile::WriteString("Done");
}
}
void CCryEditDoc::SerializeShaderCache(CXmlArchive& xmlAr)
{
if (xmlAr.bLoading)
@@ -1164,7 +995,7 @@ bool CCryEditDoc::OnSaveDocument(const QString& lpszPathName)
{
DoSaveDocument(lpszPathName, context);
saveSuccess = AfterSaveDocument(lpszPathName, context);
}
}
}
return saveSuccess;
@@ -1436,7 +1267,7 @@ bool CCryEditDoc::SaveLevel(const QString& filename)
// Save AZ entities to the editor level.
bool contentsAllSaved = false; // abort level save if anything within it fails
auto tempFilenameStrData = tempSaveFile.toStdString();
auto filenameStrData = fullPathName.toStdString();
@@ -1458,7 +1289,7 @@ bool CCryEditDoc::SaveLevel(const QString& filename)
}
}
AZStd::vector<AZ::Entity*> editorEntities;
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(
&AzToolsFramework::EditorEntityContextRequestBus::Events::GetLooseEditorEntities,
@@ -1815,7 +1646,7 @@ bool CCryEditDoc::LoadLevel(TDocMultiArchive& arrXmlAr, const QString& absoluteC
AzFramework::ApplicationRequests::Bus::BroadcastResult(isPrefabEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
auto pIPak = GetIEditor()->GetSystem()->GetIPak();
QString folderPath = QFileInfo(absoluteCryFilePath).absolutePath();
OnStartLevelResourceList();
@@ -2108,58 +1939,6 @@ void CCryEditDoc::SaveAutoBackup(bool bForce)
isInProgress = false;
}
CMission* CCryEditDoc::GetCurrentMission(bool bSkipLoadingAIWhenSyncingContent /* = false */)
{
if (m_mission)
{
return m_mission;
}
if (!m_missions.empty())
{
// Choose first available mission.
SetCurrentMission(m_missions[0]);
return m_mission;
}
// Create initial mission.
m_mission = new CMission(this);
m_mission->SetName("Mission0");
AddMission(m_mission);
m_mission->SyncContent(true, false, bSkipLoadingAIWhenSyncingContent);
return m_mission;
}
void CCryEditDoc::SetCurrentMission(CMission* mission)
{
if (mission != m_mission)
{
QWaitCursor wait;
if (m_mission)
{
m_mission->SyncContent(false, false);
}
m_mission = mission;
m_mission->SyncContent(true, false);
GetIEditor()->GetGameEngine()->LoadMission(m_mission->GetName());
}
}
void CCryEditDoc::ClearMissions()
{
for (int i = 0; i < m_missions.size(); i++)
{
delete m_missions[i];
}
m_missions.clear();
m_mission = 0;
}
bool CCryEditDoc::IsLevelExported() const
{
return m_boLevelExported;
@@ -2170,37 +1949,6 @@ void CCryEditDoc::SetLevelExported(bool boExported)
m_boLevelExported = boExported;
}
CMission* CCryEditDoc::FindMission(const QString& name) const
{
for (int i = 0; i < m_missions.size(); i++)
{
if (QString::compare(name, m_missions[i]->GetName(), Qt::CaseInsensitive) == 0)
{
return m_missions[i];
}
}
return 0;
}
void CCryEditDoc::AddMission(CMission* mission)
{
assert(std::find(m_missions.begin(), m_missions.end(), mission) == m_missions.end());
m_missions.push_back(mission);
GetIEditor()->Notify(eNotify_OnInvalidateControls);
}
void CCryEditDoc::RemoveMission(CMission* mission)
{
// if deleting current mission.
if (mission == m_mission)
{
m_mission = 0;
}
m_missions.erase(std::find(m_missions.begin(), m_missions.end(), mission));
GetIEditor()->Notify(eNotify_OnInvalidateControls);
}
void CCryEditDoc::RegisterListener(IDocListener* listener)
{
if (listener == nullptr)
@@ -2306,19 +2054,6 @@ void CCryEditDoc::OnStartLevelResourceList()
gEnv->pCryPak->GetResourceList(AZ::IO::IArchive::RFOM_Level)->Clear();
}
void CCryEditDoc::ForceSkyUpdate()
{
ITimeOfDay* pTimeOfDay = gEnv->p3DEngine ? gEnv->p3DEngine->GetTimeOfDay() : nullptr;
CMission* pCurMission = GetIEditor()->GetDocument()->GetCurrentMission();
if (pTimeOfDay && pCurMission)
{
pTimeOfDay->SetTime(pCurMission->GetTime(), gSettings.bForceSkyUpdate);
pCurMission->SetTime(pCurMission->GetTime());
GetIEditor()->Notify(eNotify_OnTimeOfDayChange);
}
}
BOOL CCryEditDoc::DoFileSave()
{
if (GetEditMode() == CCryEditDoc::DocumentEditingMode::LevelEdit)
@@ -2380,26 +2115,11 @@ void CCryEditDoc::InitEmptyLevel(int /*resolution*/, int /*unitSize*/, bool /*bU
//////////////////////////////////////////////////////////////////////////
if (!GetIEditor()->IsInPreviewMode())
{
// Make new mission.
GetIEditor()->ReloadTemplates();
m_environmentTemplate = GetIEditor()->FindTemplate("Environment");
GetCurrentMission(true); // true = skip loading the AI in case the content needs to get synchronized (otherwise it would attempt to load AI stuff from the previously loaded level (!) which might give confusing warnings)
GetIEditor()->GetGameEngine()->SetMissionName(GetCurrentMission()->GetName());
GetIEditor()->GetGameEngine()->SetLevelCreated(true);
GetIEditor()->GetGameEngine()->ReloadEnvironment();
GetIEditor()->GetGameEngine()->SetLevelCreated(false);
// Default time of day.
XmlNodeRef root = GetISystem()->LoadXmlFromFile("@engroot@/Editor/default_time_of_day.xml");
if (root)
{
ITimeOfDay* pTimeOfDay = gEnv->p3DEngine ? gEnv->p3DEngine->GetTimeOfDay() : nullptr;
if (pTimeOfDay)
{
pTimeOfDay->Serialize(root, true);
}
}
}
{
@@ -2425,44 +2145,9 @@ void CCryEditDoc::InitEmptyLevel(int /*resolution*/, int /*unitSize*/, bool /*bU
GetIEditor()->SetStatusText("Ready");
}
void CCryEditDoc::CreateDefaultLevelAssets(int resolution, int unitSize)
void CCryEditDoc::CreateDefaultLevelAssets([[maybe_unused]] int resolution, [[maybe_unused]] int unitSize)
{
if (AZ::Interface<AzFramework::AtomActiveInterface>::Get())
{
AzToolsFramework::EditorLevelNotificationBus::Broadcast(&AzToolsFramework::EditorLevelNotificationBus::Events::OnNewLevelCreated);
}
else
{
bool isPrefabSystemEnabled = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
if (!isPrefabSystemEnabled)
{
AZ::Data::AssetCatalogRequestBus::BroadcastResult(
m_envProbeSliceAssetId, &AZ::Data::AssetCatalogRequests::GetAssetIdByPath, m_envProbeSliceRelativePath,
azrtti_typeid<AZ::SliceAsset>(), false);
if (m_envProbeSliceAssetId.IsValid())
{
AZ::Data::Asset<AZ::Data::AssetData> asset = AZ::Data::AssetManager::Instance().FindOrCreateAsset<AZ::SliceAsset>(
m_envProbeSliceAssetId, AZ::Data::AssetLoadBehavior::Default);
if (asset)
{
m_terrainSize = resolution * unitSize;
const float halfTerrainSize = m_terrainSize / 2.0f;
AZ::Transform worldTransform = AZ::Transform::CreateIdentity();
worldTransform = AZ::Transform::CreateTranslation(AZ::Vector3(halfTerrainSize, halfTerrainSize, m_envProbeHeight / 2));
AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusConnect();
GetIEditor()->SuspendUndo();
AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Broadcast(
&AzToolsFramework::SliceEditorEntityOwnershipServiceRequests::InstantiateEditorSlice, asset, worldTransform);
}
}
}
}
AzToolsFramework::EditorLevelNotificationBus::Broadcast(&AzToolsFramework::EditorLevelNotificationBus::Events::OnNewLevelCreated);
}
void CCryEditDoc::OnEnvironmentPropertyChanged(IVariable* pVar)
@@ -2522,8 +2207,6 @@ void CCryEditDoc::OnEnvironmentPropertyChanged(IVariable* pVar)
pVar->Get(value);
childNode->setAttr("value", value.toUtf8().data());
}
GetIEditor()->GetGameEngine()->ReloadEnvironment();
}
QString CCryEditDoc::GetCryIndexPath(const LPCTSTR levelFilePath)
@@ -2576,12 +2259,6 @@ void CCryEditDoc::ReleaseXmlArchiveArray(TDocMultiArchive& arrXmlAr)
SAFE_DELETE(arrXmlAr[0]);
}
void CCryEditDoc::SyncCurrentMissionContent(bool bRetrieve)
{
GetCurrentMission()->SyncContent(bRetrieve, false);
}
//////////////////////////////////////////////////////////////////////////
// AzToolsFramework::EditorEntityContextNotificationBus interface implementation
void CCryEditDoc::OnSliceInstantiated(const AZ::Data::AssetId& sliceAssetId, AZ::SliceComponent::SliceInstanceAddress& sliceAddress, const AzFramework::SliceInstantiationTicket& /*ticket*/)
@@ -2613,7 +2290,7 @@ void CCryEditDoc::OnSliceInstantiated(const AZ::Data::AssetId& sliceAssetId, AZ:
sliceAddress.SetReference(nullptr);
SetModifiedFlag(true);
SetModifiedModules(eModifiedEntities);
AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusDisconnect();
//save after level default slice fully instantiated
-24
View File
@@ -22,7 +22,6 @@
#include <TimeValue.h>
#endif
class CMission;
class CLevelShaderCache;
class CClouds;
struct LightingSettings;
@@ -124,18 +123,6 @@ public: // Create from serialization only
const char* GetTemporaryLevelName() const;
void DeleteTemporaryLevel();
void ChangeMission();
//! Return currently active Mission.
CMission* GetCurrentMission(bool bSkipLoadingAIWhenSyncingContent = false);
//! Get number of missions on Map.
int GetMissionCount() const { return m_missions.size(); }
//! Get Mission by index.
CMission* GetMission(int index) const { return m_missions[index]; }
//! Find Mission by name.
CMission* FindMission(const QString& name) const;
//! Makes specified mission current.
void SetCurrentMission(CMission* mission);
CLevelShaderCache* GetShaderCache() { return m_pLevelShaderCache; }
CClouds* GetClouds() { return m_pClouds; }
void SetWaterColor(const QColor& col) { m_waterColor = col; }
@@ -167,7 +154,6 @@ protected:
virtual void Load(TDocMultiArchive& arrXmlAr, const QString& szFilename);
virtual void StartStreamingLoad(){}
virtual void SyncCurrentMissionContent(bool bRetrieve);
void Save(CXmlArchive& xmlAr);
void Load(CXmlArchive& xmlAr, const QString& szFilename);
@@ -179,14 +165,8 @@ protected:
bool LoadEntitiesFromSlice(const QString& sliceFile);
void SerializeFogSettings(CXmlArchive& xmlAr);
virtual void SerializeViewSettings(CXmlArchive& xmlAr);
void SerializeMissions(TDocMultiArchive& arrXmlAr, QString& currentMission, bool bPartsInXml);
void SerializeShaderCache(CXmlArchive& xmlAr);
void SerializeNameSelection(CXmlArchive& xmlAr);
void ForceSkyUpdate();
//! Add new mission to map.
void AddMission(CMission* mission);
//! Remove existing mission from map.
void RemoveMission(CMission* mission);
void LogLoadTime(int time);
struct TSaveDocContext
@@ -200,10 +180,8 @@ protected:
virtual bool OnSaveDocument(const QString& lpszPathName);
virtual void OnFileSaveAs();
void LoadTemplates();
//! called immediately after saving the level.
void AfterSave();
void ClearMissions();
void RegisterConsoleVariables();
void OnStartLevelResourceList();
static void OnValidateSurfaceTypesChanged(ICVar*);
@@ -220,9 +198,7 @@ protected:
QColor m_waterColor;
XmlNodeRef m_fogTemplate;
XmlNodeRef m_environmentTemplate;
CMission* m_mission;
CClouds* m_pClouds;
std::vector<CMission*> m_missions;
std::list<IDocListener*> m_listeners;
bool m_bDocumentReady;
CLevelShaderCache* m_pLevelShaderCache;
+5 -5
View File
@@ -27,6 +27,7 @@ AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
#define MIN_RES 64
#define MAX_RES 8192
CCustomResolutionDlg::CCustomResolutionDlg(int w, int h, QWidget* pParent /*=NULL*/)
: QDialog(pParent)
@@ -46,18 +47,17 @@ CCustomResolutionDlg::~CCustomResolutionDlg()
void CCustomResolutionDlg::OnInitDialog()
{
int maxRes = GetIEditor()->GetRenderer()->GetMaxSquareRasterDimension();
m_ui->m_width->setRange(MIN_RES, maxRes);
m_ui->m_width->setRange(MIN_RES, MAX_RES);
m_ui->m_width->setValue(m_wDefault);
m_ui->m_height->setRange(MIN_RES, maxRes);
m_ui->m_height->setRange(MIN_RES, MAX_RES);
m_ui->m_height->setValue(m_hDefault);
QString maxDimensionString;
QTextStream(&maxDimensionString)
<< "Maximum Dimension: " << maxRes << Qt::endl
<< "Maximum Dimension: " << MAX_RES << Qt::endl
<< Qt::endl
<< "Note: Dimensions over 4K may be" << Qt::endl
<< "Note: Dimensions over 8K may be" << Qt::endl
<< "unstable depending on hardware.";
m_ui->m_maxDimension->setText(maxDimensionString);
File diff suppressed because it is too large Load Diff
-250
View File
@@ -1,250 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#pragma once
////////////////////////////////////////////////////////////////////////////
// Crytek Engine Source File.
// Copyright (C), Crytek Studios, 2011.
// -------------------------------------------------------------------------
// File name: DatabaseFrameWnd.h
// Created: 10/Dec/2012 by Jaesik.
////////////////////////////////////////////////////////////////////////////
#ifndef CRYINCLUDE_EDITOR_DATABASEFRAMEWND_H
#define CRYINCLUDE_EDITOR_DATABASEFRAMEWND_H
#if !defined(Q_MOC_RUN)
#include <AzToolsFramework/AssetBrowser/AssetSelectionModel.h>
#include <AzQtComponents/Components/DockMainWindow.h>
#include "Undo/IUndoManagerListener.h"
#include "BaseLibrary.h"
#include <QMainWindow>
#include <QAbstractItemModel>
#include <QAbstractListModel>
#include <QScopedPointer>
#endif
class QComboBox;
class QTreeView;
class QMimeData;
class CBaseLibraryItem;
class CBaseLibraryManager;
class LibraryListModel;
class LibraryItemTreeModel;
namespace Ui {
class DatabaseFrameWnd;
}
class CDatabaseFrameWnd
: public AzQtComponents::DockMainWindow
, public IEditorNotifyListener
, public IUndoManagerListener
{
Q_OBJECT
public:
CDatabaseFrameWnd(CBaseLibraryManager* pItemManager, QWidget* pParent = nullptr);
virtual ~CDatabaseFrameWnd();
enum SortRecursionType
{
SORT_RECURSION_NONE = 1,
SORT_RECURSION_ITEM = 2,
SORT_RECURSION_FULL = 9999
};
virtual void ReloadLibs();
virtual void ReloadItems();
virtual void SelectLibrary(const QString& library, bool bForceSelect = false);
virtual void SelectLibrary(CBaseLibrary* pItem, bool bForceSelect = false);
virtual void SelectItem(CBaseLibraryItem* item, bool bForceReload = false);
virtual CBaseLibrary* FindLibrary(const QString& libraryName);
virtual CBaseLibrary* NewLibrary(const QString& libraryName);
virtual void DeleteLibrary(CBaseLibrary* pLibrary);
virtual void DeleteItem(CBaseLibraryItem* pItem);
virtual void ReleasePreviewControl(){}
virtual bool SetItemName(CBaseLibraryItem* item, const QString& groupName, const QString& itemName);
void DoesItemExist(const QString& itemName, bool& bOutExist) const;
void DoesGroupExist(const QString& groupName, bool& bOutExist) const;
virtual void OnEditorNotifyEvent(EEditorNotifyEvent event) override;
void SignalNumUndoRedo(const unsigned int& numUndo, const unsigned int& numRedo) override;
QString GetSelectedLibraryName() const;
virtual const char* GetClassName() = 0;
protected:
int GetComboBoxIndex(CBaseLibrary* pLibrary);
virtual void OnInitDialog() = 0;
void showEvent(QShowEvent* event) override;
void OnUndo();
void OnRedo();
virtual void OnAddLibrary();
virtual void OnRemoveLibrary();
virtual void OnAddItem();
virtual void OnRemoveItem();
virtual void OnRenameItem();
virtual void OnChangedLibrary();
virtual void OnExportLibrary();
virtual void OnSave();
virtual void OnReloadLib();
virtual void OnLoadLibrary();
void OnSelChangedItemTree(const QModelIndex& index);
bool eventFilter(QObject* watched, QEvent* event);
virtual void OnCopy() = 0;
virtual void OnPaste() = 0;
virtual void OnCut();
virtual void OnClone();
void InitTreeCtrl();
virtual AssetSelectionModel GetAssetSelectionModel() const = 0;
void LoadLibrary();
QString MakeValidName(const QString& candidateName, AZStd::function<void(const QString&, bool&)> cb) const;
virtual QTreeView* GetTreeCtrl() = 0;
virtual const QTreeView* GetTreeCtrl() const = 0;
private:
LibraryListModel* m_pLibraryListModel;
QComboBox* m_pLibraryListComboBox;
bool m_bLibsLoaded;
protected:
LibraryItemTreeModel* m_pLibraryItemTreeModel;
//! Selected library.
_smart_ptr<CBaseLibrary> m_pLibrary;
//! Last selected Item. (kept here for compatibility reasons)
// See comments on m_cpoSelectedLibraryItems for more details.
_smart_ptr<CBaseLibraryItem> m_pCurrentItem;
// A set containing all the currently selected items
// (it's disabled for MOST, but not ALL cases).
// This should be the new standard way of storing selections as
// opposed to the former mean, it allows us to store multiple selections.
// The migration to this new style should be done according to the needs
// for multiple selection.
std::set<CBaseLibraryItem*> m_cpoSelectedLibraryItems;
//! Pointer to item manager.
CBaseLibraryManager* m_pItemManager;
SortRecursionType m_sortRecursionType;
QString m_selectedGroup;
QScopedPointer<Ui::DatabaseFrameWnd> ui;
bool m_initialized;
};
class LibraryListModel
: public QAbstractListModel
{
Q_OBJECT
public:
LibraryListModel(CBaseLibraryManager* itemManager, QObject* pParent = nullptr);
int rowCount(const QModelIndex& parent = {}) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
void Reload();
void clear();
private:
void LibraryModified(bool bModified);
CBaseLibraryManager* m_pItemManager;
};
class LibraryItemTreeModel
: public QAbstractItemModel
{
Q_OBJECT
using Group = std::pair<QString, std::vector<CBaseLibraryItem*> >;
public:
LibraryItemTreeModel(CDatabaseFrameWnd* pParent);
QModelIndex parent(const QModelIndex& index) const override;
QModelIndex index(int row, int column, const QModelIndex& parent = {}) const override;
QModelIndex index(CBaseLibraryItem* pItem) const;
int rowCount(const QModelIndex& parent) const override;
int columnCount(const QModelIndex& parent) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
bool removeRows(int row, int count, const QModelIndex& parent = {}) override;
QStringList mimeTypes() const override;
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) override;
QMimeData* mimeData(const QModelIndexList& indexes) const override;
Qt::DropActions supportedDragActions() const override;
Qt::DropActions supportedDropActions() const override;
void Clear();
void Reload(CBaseLibrary* library);
void Add(CBaseLibraryItem* item);
bool Remove(CBaseLibraryItem* item);
void Rename(CBaseLibraryItem* item, const QString& groupName, const QString& shortName);
std::vector<CBaseLibraryItem*> ChildItems(const QModelIndex& index) const;
QString GetFullName(const QModelIndex& index) const;
QModelIndex FindLibraryItemByFullName(const QString& fullName) const;
bool DoesGroupExist(const QString& groupName) const;
signals:
void itemRenamed(CBaseLibraryItem* item, const QString& prevFullName);
protected:
void RenameItem(CBaseLibraryItem* item, const QString& fullName);
QString MakeValidName(const Group& group, const QString& baseName) const;
bool MoveItem(CBaseLibraryItem* item, const QModelIndex& parent);
CDatabaseFrameWnd* m_dialog;
std::map<QString, std::shared_ptr<Group> > m_groups;
};
Q_DECLARE_METATYPE(CBaseLibrary*)
#endif // CRYINCLUDE_EDITOR_DATABASEFRAMEWND_H
-35
View File
@@ -1,35 +0,0 @@
<RCC>
<qresource prefix="/DatabaseFrameWnd">
<file alias="db_library_bar_00.png">res/db_library_bar_00.png</file>
<file alias="db_library_bar_01.png">res/db_library_bar_01.png</file>
<file alias="db_library_bar_02.png">res/db_library_bar_02.png</file>
<file alias="db_library_bar_03.png">res/db_library_bar_03.png</file>
<file alias="db_library_bar_04.png">res/db_library_bar_04.png</file>
<file alias="db_library_bar_05.png">res/db_library_bar_05.png</file>
<file alias="db_standart_00.png">res/db_standart_00.png</file>
<file alias="db_standart_01.png">res/db_standart_01.png</file>
<file alias="db_standart_02.png">res/db_standart_02.png</file>
<file alias="db_standart_03.png">res/db_standart_03.png</file>
<file alias="db_library_item_bar_00.png">res/db_library_item_bar_00.png</file>
<file alias="db_library_item_bar_01.png">res/db_library_item_bar_01.png</file>
<file alias="db_library_item_bar_02.png">res/db_library_item_bar_02.png</file>
<file alias="db_library_item_bar_03.png">res/db_library_item_bar_03.png</file>
<file alias="db_library_item_bar_04.png">res/db_library_item_bar_04.png</file>
<file alias="db_library_item_bar_05.png">res/db_library_item_bar_05.png</file>
<file alias="db_library_open.svg">res/db_library_open.svg</file>
<file alias="db_library_save.svg">res/db_library_save.svg</file>
<file alias="db_library_add.svg">res/db_library_add.svg</file>
<file alias="db_library_delete.svg">res/db_library_delete.svg</file>
<file alias="db_library_refresh.svg">res/db_library_refresh.svg</file>
<file alias="db_library_undo.svg">res/db_library_undo.svg</file>
<file alias="db_library_redo.svg">res/db_library_redo.svg</file>
<file alias="db_library_copy.svg">res/db_library_copy.svg</file>
<file alias="db_library_paste.svg">res/db_library_paste.svg</file>
<file alias="db_library_additem.svg">res/db_library_additem.svg</file>
<file alias="db_library_cloneitem.svg">res/db_library_cloneitem.svg</file>
<file alias="db_library_removeitem.svg">res/db_library_removeitem.svg</file>
<file alias="db_library_assignitem.svg">res/db_library_assignitem.svg</file>
<file alias="db_library_getproperties.svg">res/db_library_getproperties.svg</file>
<file alias="db_library_reload.svg">res/db_library_reload.svg</file>
</qresource>
</RCC>
-279
View File
@@ -1,279 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DatabaseFrameWnd</class>
<widget class="QMainWindow" name="DatabaseFrameWnd">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>633</width>
<height>42</height>
</rect>
</property>
<widget class="QToolBar" name="m_toolBar">
<property name="windowTitle">
<string>Lens Flare Toolbar</string>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="floatable">
<bool>false</bool>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionDBLoadLib"/>
<addaction name="actionDBSave"/>
<addaction name="actionDBAddLib"/>
<addaction name="actionDBDelLib"/>
<addaction name="actionDBReloadLib"/>
</widget>
<widget class="QToolBar" name="m_toolBar2">
<property name="windowTitle">
<string>StandartToolBar</string>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="floatable">
<bool>false</bool>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionUndo"/>
<addaction name="actionRedo"/>
<addaction name="separator"/>
<addaction name="actionDBCopy"/>
<addaction name="actionDBPaste"/>
</widget>
<widget class="QToolBar" name="m_toolBar3">
<property name="windowTitle">
<string>ItemToolBar</string>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="floatable">
<bool>false</bool>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionDBAdd"/>
<addaction name="actionDBClone"/>
<addaction name="actionDBRemove"/>
<addaction name="separator"/>
<addaction name="actionDBAssignToSelection"/>
<addaction name="actionDBGetFromSelection"/>
<addaction name="actionDBReload"/>
</widget>
<action name="actionDBLoadLib">
<property name="icon">
<iconset>
<normaloff>:/DatabaseFrameWnd/db_library_open.svg</normaloff>:/DatabaseFrameWnd/db_library_open.svg</iconset>
</property>
<property name="text">
<string>Load Library</string>
</property>
<property name="toolTip">
<string>Load Library</string>
</property>
</action>
<action name="actionDBSave">
<property name="icon">
<iconset>
<normaloff>:/DatabaseFrameWnd/db_library_save.svg</normaloff>:/DatabaseFrameWnd/db_library_save.svg</iconset>
</property>
<property name="text">
<string>Save Modified Libraries</string>
</property>
<property name="toolTip">
<string>Save Modified Libraries</string>
</property>
</action>
<action name="actionDBAddLib">
<property name="icon">
<iconset>
<normaloff>:/DatabaseFrameWnd/db_library_add.svg</normaloff>:/DatabaseFrameWnd/db_library_add.svg</iconset>
</property>
<property name="text">
<string>Add Library</string>
</property>
<property name="toolTip">
<string>Add Library</string>
</property>
</action>
<action name="actionDBDelLib">
<property name="icon">
<iconset>
<normaloff>:/DatabaseFrameWnd/db_library_delete.svg</normaloff>:/DatabaseFrameWnd/db_library_delete.svg</iconset>
</property>
<property name="text">
<string>Remove Library</string>
</property>
<property name="toolTip">
<string>Remove Library</string>
</property>
</action>
<action name="actionDBReloadLib">
<property name="icon">
<iconset>
<normaloff>:/DatabaseFrameWnd/db_library_refresh.svg</normaloff>:/DatabaseFrameWnd/db_library_refresh.svg</iconset>
</property>
<property name="text">
<string>Reload Library</string>
</property>
<property name="toolTip">
<string>Reload Library</string>
</property>
</action>
<action name="actionUndo">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:/DatabaseFrameWnd/db_library_undo.svg</normaloff>:/DatabaseFrameWnd/db_library_undo.svg</iconset>
</property>
<property name="text">
<string>Undo last operation</string>
</property>
<property name="toolTip">
<string>Undo</string>
</property>
</action>
<action name="actionRedo">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:/DatabaseFrameWnd/db_library_redo.svg</normaloff>:/DatabaseFrameWnd/db_library_redo.svg</iconset>
</property>
<property name="text">
<string>Redo last undo operation</string>
</property>
<property name="toolTip">
<string>Redo</string>
</property>
</action>
<action name="actionDBCopy">
<property name="icon">
<iconset>
<normaloff>:/DatabaseFrameWnd/db_library_copy.svg</normaloff>:/DatabaseFrameWnd/db_library_copy.svg</iconset>
</property>
<property name="text">
<string>Copy Item</string>
</property>
<property name="toolTip">
<string>Copy Item</string>
</property>
</action>
<action name="actionDBPaste">
<property name="icon">
<iconset>
<normaloff>:/DatabaseFrameWnd/db_library_paste.svg</normaloff>:/DatabaseFrameWnd/db_library_paste.svg</iconset>
</property>
<property name="text">
<string>Paste Item</string>
</property>
<property name="toolTip">
<string>Paste Item</string>
</property>
</action>
<action name="actionDBAdd">
<property name="icon">
<iconset>
<normaloff>:/DatabaseFrameWnd/db_library_additem.svg</normaloff>:/DatabaseFrameWnd/db_library_additem.svg</iconset>
</property>
<property name="text">
<string>Add New Item</string>
</property>
<property name="toolTip">
<string>Add New Item</string>
</property>
</action>
<action name="actionDBClone">
<property name="icon">
<iconset>
<normaloff>:/DatabaseFrameWnd/db_library_cloneitem.svg</normaloff>:/DatabaseFrameWnd/db_library_cloneitem.svg</iconset>
</property>
<property name="text">
<string>Clone Library Item</string>
</property>
<property name="toolTip">
<string>Clone Library Item</string>
</property>
</action>
<action name="actionDBRemove">
<property name="icon">
<iconset>
<normaloff>:/DatabaseFrameWnd/db_library_removeitem.svg</normaloff>:/DatabaseFrameWnd/db_library_removeitem.svg</iconset>
</property>
<property name="text">
<string>Remove Item</string>
</property>
<property name="toolTip">
<string>Remove Item</string>
</property>
</action>
<action name="actionDBAssignToSelection">
<property name="icon">
<iconset>
<normaloff>:/DatabaseFrameWnd/db_library_assignitem.svg</normaloff>:/DatabaseFrameWnd/db_library_assignitem.svg</iconset>
</property>
<property name="text">
<string>Assign Item to Selected Objects</string>
</property>
<property name="toolTip">
<string>Assign Item to Selected Objects</string>
</property>
</action>
<action name="actionDBGetFromSelection">
<property name="icon">
<iconset>
<normaloff>:/DatabaseFrameWnd/db_library_getproperties.svg</normaloff>:/DatabaseFrameWnd/db_library_getproperties.svg</iconset>
</property>
<property name="text">
<string>Get Properties From Selection</string>
</property>
<property name="toolTip">
<string>Get Properties From Selection</string>
</property>
</action>
<action name="actionDBReload">
<property name="icon">
<iconset>
<normaloff>:/DatabaseFrameWnd/db_library_reload.svg</normaloff>:/DatabaseFrameWnd/db_library_reload.svg</iconset>
</property>
<property name="text">
<string>Reload Item</string>
</property>
<property name="toolTip">
<string>Reload Item</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>
@@ -1,51 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "EditorDefs.h"
#include "DuplicatedObjectsHandlerDlg.h"
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
#include <Dialogs/ui_DuplicatedObjectsHandlerDlg.h>
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
CDuplicatedObjectsHandlerDlg::CDuplicatedObjectsHandlerDlg(const QString& msg, QWidget* pParent)
: QDialog(pParent)
, m_ui(new Ui::DuplicatedObjectsHandlerDlg)
{
m_ui->setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
m_ui->textBrowser->setPlainText(msg);
connect(m_ui->buttonOverride, &QPushButton::clicked, this, &CDuplicatedObjectsHandlerDlg::OnBnClickedOverrideBtn);
connect(m_ui->buttonCreateCopies, &QPushButton::clicked, this, &CDuplicatedObjectsHandlerDlg::OnBnClickedCreateCopiesBtn);
}
CDuplicatedObjectsHandlerDlg::~CDuplicatedObjectsHandlerDlg()
{
}
void CDuplicatedObjectsHandlerDlg::OnBnClickedOverrideBtn()
{
m_result = eResult_Override;
accept();
}
void CDuplicatedObjectsHandlerDlg::OnBnClickedCreateCopiesBtn()
{
m_result = eResult_CreateCopies;
accept();
}
#include <Dialogs/moc_DuplicatedObjectsHandlerDlg.cpp>
@@ -1,57 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_DIALOGS_DUPLICATEDOBJECTSHANDLERDLG_H
#define CRYINCLUDE_EDITOR_DIALOGS_DUPLICATEDOBJECTSHANDLERDLG_H
#pragma once
#if !defined(Q_MOC_RUN)
#include <QDialog>
#endif
namespace Ui
{
class DuplicatedObjectsHandlerDlg;
}
class CDuplicatedObjectsHandlerDlg
: public QDialog
{
Q_OBJECT
public:
CDuplicatedObjectsHandlerDlg(const QString& msg, QWidget* pParent = nullptr);
virtual ~CDuplicatedObjectsHandlerDlg();
enum EResult
{
eResult_None,
eResult_Override,
eResult_CreateCopies
};
EResult GetResult() const
{
return m_result;
}
protected:
EResult m_result;
void OnBnClickedOverrideBtn();
void OnBnClickedCreateCopiesBtn();
QScopedPointer<Ui::DuplicatedObjectsHandlerDlg> m_ui;
};
#endif // CRYINCLUDE_EDITOR_DIALOGS_DUPLICATEDOBJECTSHANDLERDLG_H
@@ -1,83 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DuplicatedObjectsHandlerDlg</class>
<widget class="QDialog" name="DuplicatedObjectsHandlerDlg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>474</width>
<height>204</height>
</rect>
</property>
<property name="windowTitle">
<string>Duplicated Objects Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTextBrowser" name="textBrowser">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<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="QPushButton" name="pushButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonOverride">
<property name="text">
<string>Override</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCreateCopies">
<property name="text">
<string>Create Copies</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>DuplicatedObjectsHandlerDlg</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>258</x>
<y>183</y>
</hint>
<hint type="destinationlabel">
<x>190</x>
<y>184</y>
</hint>
</hints>
</connection>
</connections>
</ui>
@@ -71,24 +71,8 @@ CPythonScriptsDialog::CPythonScriptsDialog(QWidget* parent)
AzQtComponents::LineEdit::applySearchStyle(ui->searchField);
QStringList scriptFolders;
const auto editorEnvStr = gSettings.strEditorEnv.toLocal8Bit();
AZStd::string editorScriptsPath = AZStd::string::format("@engroot@/%s", editorEnvStr.constData());
XmlNodeRef envNode = XmlHelpers::LoadXmlFromFile(editorScriptsPath.c_str());
if (envNode)
{
QString scriptPath;
int childrenCount = envNode->getChildCount();
for (int idx = 0; idx < childrenCount; ++idx)
{
XmlNodeRef child = envNode->getChild(idx);
if (child->haveAttr("scriptPath"))
{
scriptPath = child->getAttr("scriptPath");
scriptFolders.push_back(scriptPath);
}
}
}
auto engineScriptPath = AZ::IO::FixedMaxPath(AZ::Utils::GetEnginePath()) / "Assets" / "Editor" / "Scripts";
scriptFolders.push_back(engineScriptPath.c_str());
AZ::IO::FixedMaxPathString projectPath = AZ::Utils::GetProjectPath();
ScanFolderForScripts(QString("%1/Editor/Scripts").arg(projectPath.c_str()), scriptFolders);
@@ -1,218 +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 "EditorDefs.h"
#include "NewEntityDialog.h"
// Qt
#include <QPushButton>
#include <QToolTip>
#include <QMessageBox>
// Editor
#include "Dialogs/QT/ui_NewEntityDialog.h"
NewEntityDialog::NewEntityDialog(QWidget* parent)
: QDialog(parent)
, ui(new Ui::NewEntityDialog)
{
entityNameValidator = new EntityNameValidator(this);
ui->setupUi(this);
ui->entityName->setFocus();
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
connect(ui->entityName, SIGNAL(textChanged(QString)), this, SLOT(ValidateInput()));
connect(ui->categoryName, SIGNAL(textChanged(QString)), this, SLOT(ValidateInput()));
SetCategoryCompleterPath((Path::GetEditingGameDataFolder() + "/Scripts/Entities").c_str());
SetNameValidatorPath((Path::GetEditingGameDataFolder() + "/Entities").c_str());
}
NewEntityDialog::~NewEntityDialog()
{
SAFE_DELETE(entityNameValidator);
SAFE_DELETE(folderNameCompleter);
delete ui;
}
void NewEntityDialog::SetCategoryCompleterPath(CryStringT<char> path)
{
SAFE_DELETE(folderNameCompleter);
QDirIterator directoryIt(QString::fromLocal8Bit(path.c_str(), path.length()), QDir::NoDotAndDotDot | QDir::AllDirs, QDirIterator::Subdirectories);
baseDir = directoryIt.path() + "/";
QStringList dirs;
while (directoryIt.hasNext())
{
QString dir = directoryIt.next().remove(baseDir);
dirs.append(dir);
}
folderNameCompleter = new QCompleter(dirs);
folderNameCompleter->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
folderNameCompleter->setCaseSensitivity(Qt::CaseInsensitive);
ui->categoryName->setCompleter(folderNameCompleter);
}
void NewEntityDialog::SetNameValidatorPath(CryStringT<char> path)
{
QDir dir(QString::fromLocal8Bit(path.c_str(), path.length()));
nameBaseDir = dir.path() + "/";
}
void NewEntityDialog::ValidateInput()
{
int cursorPos = ui->entityName->cursorPosition();
QString text = ui->entityName->text();
bool validText = entityNameValidator->validate(text, cursorPos);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(validText);
}
void NewEntityDialog::accept()
{
if (ui->categoryName->text().isEmpty()
&& QMessageBox::question(this, "Are you sure?", "Create entity without category?", QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
{
return;
}
const char* devRoot = gEnv->pFileIO->GetAlias("@engroot@");
QString devRootPath(devRoot);
QFile entTemplateFile(devRootPath + "/Editor/NewEntityTemplate.ent_template");
QFile luaTemplateFile(devRootPath + "/Editor/NewEntityTemplate.lua_template");
QFile entDestFile(nameBaseDir + ui->entityName->text() + ".ent");
QFile luaDestFile(baseDir + ui->categoryName->text() + "/" + ui->entityName->text() + ".lua");
if (!entTemplateFile.exists() || !luaTemplateFile.exists())
{
QMessageBox::critical(this, tr("Missing Template Files"), tr("In order to create default entities the NewEntityTemplate.lua and NewEntityTemplate.ent template files must exist in the Templates folder!"));
return;
}
//generate the .ent file
QDir pathMaker(nameBaseDir);
pathMaker.mkpath(pathMaker.path());
QString entFileString;
if (!entTemplateFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
AZ_Warning("Editor", false, "Enable to open template file for ent : %s", entTemplateFile.fileName().toUtf8().constData());
return;
}
else
{
entFileString = entTemplateFile.readAll();
entTemplateFile.close();
}
entFileString.replace(QString("[CATEGORY_NAME]"), ui->categoryName->text());
entFileString.replace(QString("[ENTITY_NAME]"), ui->entityName->text());
if (!entDestFile.open(QIODevice::WriteOnly | QIODevice::Text))
{
AZ_Warning("Editor", false, "Enable to open destination file for ent : %s", entDestFile.fileName().toUtf8().constData());
return;
}
else
{
entDestFile.write(entFileString.toUtf8());
entDestFile.close();
}
//generate the .lua file
pathMaker.setPath(baseDir);
pathMaker.mkpath(ui->categoryName->text() + "/");
QString luaFileString;
if (!luaTemplateFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
AZ_Warning("Editor", false, "Enable to open template file for lua : %s", luaTemplateFile.fileName().toUtf8().constData());
return;
}
else
{
luaFileString = luaTemplateFile.readAll();
luaTemplateFile.close();
}
luaFileString.replace(QString("[ENTITY_NAME]"), ui->entityName->text());
if (!luaDestFile.open(QIODevice::WriteOnly | QIODevice::Text))
{
AZ_Warning("Editor", false, "Enable to open destination file for lua : %s", luaDestFile.fileName().toUtf8().constData());
return;
}
else
{
luaDestFile.write(luaFileString.toUtf8());
luaDestFile.close();
}
if (ui->openLuaCB->isChecked())
{
CFileUtil::EditTextFile(luaDestFile.fileName().toLocal8Bit().data());
}
QDialog::accept();
}
QValidator::State NewEntityDialog::EntityNameValidator::validate(QString& input, [[maybe_unused]] int& pos) const
{
if (!m_Parent)
{
return Invalid;
}
if (input.isEmpty())
{
return Invalid;
}
if (input.contains("/"))
{
return Invalid;
}
QString fileBaseName = m_Parent->ui->entityName->text();
// Characters
const char* notAllowedChars = ",^@=+{}[]~!?:&*\"|#%<>$\"'();`' ";
for (const char* c = notAllowedChars; *c; c++)
{
if (fileBaseName.contains(QLatin1Char(*c)))
{
const QChar qc = QLatin1Char(*c);
if (qc.isSpace())
{
QToolTip::showText(m_Parent->ui->entityName->mapToGlobal(QPoint()), tr("Name may not contain white space."), m_Parent->ui->entityName, m_Parent->ui->entityName->rect(), 2000);
}
else
{
QToolTip::showText(m_Parent->ui->entityName->mapToGlobal(QPoint()), tr("Invalid character \"%1\".").arg(qc), m_Parent->ui->entityName, m_Parent->ui->entityName->rect(), 2000);
}
return Invalid;
}
}
QString filename(m_Parent->nameBaseDir + m_Parent->ui->entityName->text() + ".ent");
QFile newFile(filename);
if (newFile.exists())
{
QToolTip::showText(m_Parent->ui->entityName->mapToGlobal(QPoint()), tr("Filename already exists!"), m_Parent->ui->entityName, m_Parent->ui->entityName->rect(), 2000);
return Invalid;
}
return Acceptable;
}
#include <Dialogs/QT/moc_NewEntityDialog.cpp>
@@ -1,69 +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.
*
*/
#ifndef NEWENTITYDIALOG_H
#define NEWENTITYDIALOG_H
#if !defined(Q_MOC_RUN)
#include <QDialog>
#include <QCompleter>
#include <QDirIterator>
#include <QStringListModel>
#include <QValidator>
#include <QEvent>
#include <QLineEdit>
#endif
namespace Ui {
class NewEntityDialog;
}
class NewEntityDialog
: public QDialog
{
Q_OBJECT
public:
explicit NewEntityDialog(QWidget* parent = 0);
~NewEntityDialog();
private:
Ui::NewEntityDialog* ui;
QString baseDir = "";
QString nameBaseDir = "";
QCompleter* folderNameCompleter = NULL;
void SetCategoryCompleterPath(CryStringT<char> path);
void SetNameValidatorPath(CryStringT<char> path);
virtual void accept();
class EntityNameValidator
: public QValidator
{
public:
explicit EntityNameValidator(NewEntityDialog* parent = 0)
: QValidator(parent)
, m_Parent(parent)
{
}
virtual State validate(QString& input, int& pos) const;
NewEntityDialog* m_Parent;
};
EntityNameValidator* entityNameValidator;
public slots:
void ValidateInput();
};
#endif // NEWENTITYDIALOG_H
@@ -1,161 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NewEntityDialog</class>
<widget class="QDialog" name="NewEntityDialog">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>111</height>
</rect>
</property>
<property name="contextMenuPolicy">
<enum>Qt::PreventContextMenu</enum>
</property>
<property name="windowTitle">
<string>New Entity</string>
</property>
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
<property name="modal">
<bool>false</bool>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>30</x>
<y>70</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QLineEdit" name="entityName">
<property name="geometry">
<rect>
<x>110</x>
<y>10</y>
<width>281</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>71</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Entity Name:</string>
</property>
<property name="buddy">
<cstring>entityName</cstring>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>91</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Entity Category:</string>
</property>
<property name="buddy">
<cstring>categoryName</cstring>
</property>
</widget>
<widget class="QLineEdit" name="categoryName">
<property name="geometry">
<rect>
<x>110</x>
<y>40</y>
<width>281</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QCheckBox" name="openLuaCB">
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<width>141</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Open Lua After Creating</string>
</property>
</widget>
</widget>
<tabstops>
<tabstop>entityName</tabstop>
<tabstop>categoryName</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>NewEntityDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>NewEntityDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
-30
View File
@@ -22,7 +22,6 @@
// Editor
#include "Settings.h"
#include "Material/MaterialManager.h"
@@ -87,11 +86,6 @@ void CDisplaySettings::PostInitApply()
void CDisplaySettings::SetRenderFlags(int flags)
{
m_renderFlags = flags;
if (!GetIEditor()->Get3DEngine())
{
return;
}
}
//////////////////////////////////////////////////////////////////////////
@@ -112,30 +106,6 @@ void CDisplaySettings::SetDebugFlags(int flags)
//SetCVarInt( "sys_enable_budgetmonitoring",(m_debugFlags&DBG_BUDGET_MONITORING) ? 4:0 );
//SetCVarInt( "Profile",(m_debugFlags&DBG_FRAMEPROFILE) ? 1:0 );
if (CMaterialManager* pMaterialManager = GetIEditor()->GetMaterialManager())
{
int mask = pMaterialManager->GetHighlightMask();
if (m_debugFlags & DBG_HIGHLIGHT_BREAKABLE)
{
mask |= eHighlight_Breakable;
}
else
{
mask &= ~eHighlight_Breakable;
}
if (m_debugFlags & DBG_HIGHLIGHT_MISSING_SURFACE_TYPE)
{
mask |= eHighlight_NoSurfaceType;
}
else
{
mask &= ~eHighlight_NoSurfaceType;
}
pMaterialManager->SetHighlightMask(mask);
}
}
//////////////////////////////////////////////////////////////////////////
-1
View File
@@ -132,7 +132,6 @@
#include <IRenderer.h>
#include <CryFile.h>
#include <ISystem.h>
#include <I3DEngine.h>
#include <IIndexedMesh.h>
#include <ITimer.h>
#include <IXml.h>
+4 -1
View File
@@ -16,6 +16,8 @@
#include "EditorPanelUtils.h"
#include <AzCore/Utils/Utils.h>
// Qt
#include <QInputDialog>
#include <QFileDialog>
@@ -147,7 +149,8 @@ public:
virtual void HotKey_Export() override
{
QString filepath = QFileDialog::getSaveFileName(nullptr, "Select shortcut configuration to load", "Editor/Plugins/ParticleEditorPlugin/settings", "HotKey Config Files (*.hkxml)");
auto settingDir = AZ::IO::FixedMaxPath(AZ::Utils::GetEnginePath()) / "Editor" / "Plugins" / "ParticleEditorPlugin" / "settings";
QString filepath = QFileDialog::getSaveFileName(nullptr, "Select shortcut configuration to load", settingDir.c_str(), "HotKey Config Files (*.hkxml)");
QFile file(filepath);
if (!file.open(QIODevice::WriteOnly))
{
@@ -21,14 +21,12 @@
#include <AzToolsFramework/UI/UICore/WidgetHelpers.h>
#include <AzToolsFramework/Thumbnails/ThumbnailerComponent.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserComponent.h>
#include <AzToolsFramework/MaterialBrowser/MaterialBrowserComponent.h>
// Editor
#include "MainWindow.h"
#include "CryEdit.h"
#include "DisplaySettingsPythonFuncs.h"
#include "GameEngine.h"
#include "Material/MaterialPythonFuncs.h"
#include "PythonEditorFuncs.h"
#include "TrackView/TrackViewPythonFuncs.h"
#include "Include/IObjectManager.h"
@@ -65,7 +63,6 @@ namespace EditorInternal
RegisterComponentDescriptor(AzToolsFramework::DisplaySettingsPythonFuncsHandler::CreateDescriptor());
RegisterComponentDescriptor(AzToolsFramework::MainWindowEditorFuncsHandler::CreateDescriptor());
RegisterComponentDescriptor(AzToolsFramework::ObjectManagerFuncsHandler::CreateDescriptor());
RegisterComponentDescriptor(AzToolsFramework::MaterialPythonFuncsHandler::CreateDescriptor());
RegisterComponentDescriptor(AzToolsFramework::PythonEditorComponent::CreateDescriptor());
RegisterComponentDescriptor(AzToolsFramework::PythonEditorFuncsHandler::CreateDescriptor());
RegisterComponentDescriptor(AzToolsFramework::DisplaySettingsComponent::CreateDescriptor());
@@ -81,7 +78,6 @@ namespace EditorInternal
components.emplace_back(azrtti_typeid<AzToolsFramework::Thumbnailer::ThumbnailerComponent>());
components.emplace_back(azrtti_typeid<AzToolsFramework::AssetBrowser::AssetBrowserComponent>());
components.emplace_back(azrtti_typeid<AzToolsFramework::MaterialBrowser::MaterialBrowserComponent>());
// Add new Bus-based Python Bindings
components.emplace_back(azrtti_typeid<AzToolsFramework::DisplaySettingsComponent>());
+122 -103
View File
@@ -40,7 +40,6 @@
# include <AzFramework/Input/Buses/Notifications/RawInputNotificationBus_Platform.h>
#endif // defined(AZ_PLATFORM_WINDOWS)
#include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h> // for AzFramework::InputDeviceMouse
#include <AzFramework/API/AtomActiveInterface.h>
#include <AzFramework/Viewport/ViewportControllerList.h>
// AzQtComponents
@@ -55,7 +54,6 @@
#include <AtomToolsFramework/Viewport/RenderViewportWidget.h>
// CryCommon
#include <CryCommon/I3DEngine.h>
#include <CryCommon/HMDBus.h>
// AzFramework
@@ -98,12 +96,25 @@
#include <QtGui/private/qhighdpiscaling_p.h>
#include <IEntityRenderState.h>
#include <IPhysics.h>
#include <IStatObj.h>
AZ_CVAR(
bool, ed_visibility_logTiming, false, nullptr, AZ::ConsoleFunctorFlags::Null,
"Output the timing of the new IVisibilitySystem query");
EditorViewportWidget* EditorViewportWidget::m_pPrimaryViewport = nullptr;
namespace AzFramework
{
extern InputChannelId CameraFreeLookButton;
extern InputChannelId CameraFreePanButton;
extern InputChannelId CameraOrbitLookButton;
extern InputChannelId CameraOrbitDollyButton;
extern InputChannelId CameraOrbitPanButton;
}
#if AZ_TRAIT_OS_PLATFORM_APPLE
void StopFixedCursorMode();
void StartFixedCursorMode(QObject *viewport);
@@ -159,6 +170,7 @@ EditorViewportWidget::EditorViewportWidget(const QString& name, QWidget* parent)
, m_camFOV(gSettings.viewports.fDefaultFov)
, m_defaultViewName(name)
, m_renderViewport(nullptr) //m_renderViewport is initialized later, in SetViewportId
, m_editorViewportSettings(this)
{
// need this to be set in order to allow for language switching on Windows
setAttribute(Qt::WA_InputMethodEnabled);
@@ -230,9 +242,6 @@ EditorViewportWidget::~EditorViewportWidget()
//////////////////////////////////////////////////////////////////////////
int EditorViewportWidget::OnCreate()
{
m_renderer = GetIEditor()->GetRenderer();
m_engine = GetIEditor()->Get3DEngine();
CreateRenderContext();
return 0;
@@ -254,11 +263,6 @@ void EditorViewportWidget::resizeEvent(QResizeEvent* event)
gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_RESIZE, width(), height());
if (gEnv->pRenderer)
{
gEnv->pRenderer->EF_DisableTemporalEffects();
}
// We queue the window resize event because the render overlay may be hidden.
// If the render overlay is not visible, the native window that is backing it will
// also be hidden, and it will not resize until it becomes visible.
@@ -324,8 +328,8 @@ AzToolsFramework::ViewportInteraction::MousePick EditorViewportWidget::BuildMous
using namespace AzToolsFramework::ViewportInteraction;
MousePick mousePick;
mousePick.m_screenCoordinates = AzFramework::ScreenPoint(point.x(), point.y());
const auto& ray = m_renderViewport->ViewportScreenToWorldRay(point);
mousePick.m_screenCoordinates = ScreenPointFromQPoint(point);
const auto& ray = m_renderViewport->ViewportScreenToWorldRay(mousePick.m_screenCoordinates);
if (ray.has_value())
{
mousePick.m_rayOrigin = ray.value().origin;
@@ -426,7 +430,7 @@ void EditorViewportWidget::Update()
return;
}
if (!m_engine || m_rcClient.isEmpty() || GetIEditor()->IsInMatEditMode())
if (m_rcClient.isEmpty() || GetIEditor()->IsInMatEditMode())
{
return;
}
@@ -524,9 +528,6 @@ void EditorViewportWidget::Update()
// Render
{
// TODO: Move out this logic to a controller and refactor to work with Atom
// m_renderer->SetClearColor(Vec3(0.4f, 0.4f, 0.4f));
// 3D engine stats
GetIEditor()->GetSystem()->RenderBegin();
OnRender();
@@ -551,8 +552,6 @@ void EditorViewportWidget::Update()
}
}
GetIEditor()->GetSystem()->RenderEnd(m_bRenderStats);
gEnv->pSystem->SetViewCamera(CurCamera);
}
@@ -796,10 +795,6 @@ void EditorViewportWidget::OnRender()
{
GetIEditor()->GetRenderer()->SetCamera(gEnv->pSystem->GetViewCamera());
}
if (m_engine)
{
m_engine->RenderWorld(0, SRenderingPassInfo::CreateGeneralPassRenderingInfo(m_Camera), __FUNCTION__);
}
return;
}
@@ -1113,40 +1108,14 @@ AzFramework::CameraState EditorViewportWidget::GetCameraState()
return m_renderViewport->GetCameraState();
}
bool EditorViewportWidget::GridSnappingEnabled()
{
return GetViewManager()->GetGrid()->IsEnabled();
}
float EditorViewportWidget::GridSize()
{
const CGrid* grid = GetViewManager()->GetGrid();
return grid->scale * grid->size;
}
bool EditorViewportWidget::ShowGrid()
{
return gSettings.viewports.bShowGridGuide;
}
bool EditorViewportWidget::AngleSnappingEnabled()
{
return GetViewManager()->GetGrid()->IsAngleSnapEnabled();
}
float EditorViewportWidget::AngleStep()
{
return GetViewManager()->GetGrid()->GetAngleSnap();
}
AZ::Vector3 EditorViewportWidget::PickTerrain(const QPoint& point)
AZ::Vector3 EditorViewportWidget::PickTerrain(const AzFramework::ScreenPoint& point)
{
FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR);
return LYVec3ToAZVec3(ViewToWorld(point, nullptr, true));
return LYVec3ToAZVec3(ViewToWorld(AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(point), nullptr, true));
}
AZ::EntityId EditorViewportWidget::PickEntity(const QPoint& point)
AZ::EntityId EditorViewportWidget::PickEntity(const AzFramework::ScreenPoint& point)
{
FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR);
@@ -1155,7 +1124,7 @@ AZ::EntityId EditorViewportWidget::PickEntity(const QPoint& point)
AZ::EntityId entityId;
HitContext hitInfo;
hitInfo.view = this;
if (HitTest(point, hitInfo))
if (HitTest(AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(point), hitInfo))
{
if (hitInfo.object && (hitInfo.object->GetType() == OBJTYPE_AZENTITY))
{
@@ -1181,7 +1150,7 @@ void EditorViewportWidget::FindVisibleEntities(AZStd::vector<AZ::EntityId>& visi
visibleEntitiesOut.assign(m_entityVisibilityQuery.Begin(), m_entityVisibilityQuery.End());
}
QPoint EditorViewportWidget::ViewportWorldToScreen(const AZ::Vector3& worldPosition)
AzFramework::ScreenPoint EditorViewportWidget::ViewportWorldToScreen(const AZ::Vector3& worldPosition)
{
return m_renderViewport->ViewportWorldToScreen(worldPosition);
}
@@ -1241,13 +1210,48 @@ void EditorViewportWidget::SetViewportId(int id)
if (ed_useNewCameraSystem)
{
m_renderViewport->GetControllerList()->Add(AZStd::make_shared<SandboxEditor::ModernViewportCameraController>());
AzFramework::ReloadCameraKeyBindings();
auto controller = AZStd::make_shared<SandboxEditor::ModernViewportCameraController>();
controller->SetCameraListBuilderCallback([](AzFramework::Cameras& cameras)
{
auto firstPersonRotateCamera = AZStd::make_shared<AzFramework::RotateCameraInput>(AzFramework::CameraFreeLookButton);
auto firstPersonPanCamera =
AZStd::make_shared<AzFramework::PanCameraInput>(AzFramework::CameraFreePanButton, AzFramework::LookPan);
auto firstPersonTranslateCamera = AZStd::make_shared<AzFramework::TranslateCameraInput>(AzFramework::LookTranslation);
auto firstPersonWheelCamera = AZStd::make_shared<AzFramework::ScrollTranslationCameraInput>();
auto orbitCamera = AZStd::make_shared<AzFramework::OrbitCameraInput>();
auto orbitRotateCamera = AZStd::make_shared<AzFramework::RotateCameraInput>(AzFramework::CameraOrbitLookButton);
auto orbitTranslateCamera = AZStd::make_shared<AzFramework::TranslateCameraInput>(AzFramework::OrbitTranslation);
auto orbitDollyWheelCamera = AZStd::make_shared<AzFramework::OrbitDollyScrollCameraInput>();
auto orbitDollyMoveCamera =
AZStd::make_shared<AzFramework::OrbitDollyCursorMoveCameraInput>(AzFramework::CameraOrbitDollyButton);
auto orbitPanCamera =
AZStd::make_shared<AzFramework::PanCameraInput>(AzFramework::CameraOrbitPanButton, AzFramework::OrbitPan);
orbitCamera->m_orbitCameras.AddCamera(orbitRotateCamera);
orbitCamera->m_orbitCameras.AddCamera(orbitTranslateCamera);
orbitCamera->m_orbitCameras.AddCamera(orbitDollyWheelCamera);
orbitCamera->m_orbitCameras.AddCamera(orbitDollyMoveCamera);
orbitCamera->m_orbitCameras.AddCamera(orbitPanCamera);
cameras.AddCamera(firstPersonRotateCamera);
cameras.AddCamera(firstPersonPanCamera);
cameras.AddCamera(firstPersonTranslateCamera);
cameras.AddCamera(firstPersonWheelCamera);
cameras.AddCamera(orbitCamera);
});
m_renderViewport->GetControllerList()->Add(controller);
}
else
{
m_renderViewport->GetControllerList()->Add(AZStd::make_shared<SandboxEditor::LegacyViewportCameraController>());
}
m_renderViewport->SetViewportSettings(&m_editorViewportSettings);
UpdateScene();
if (m_pPrimaryViewport == this)
@@ -1312,26 +1316,8 @@ namespace AZ::ViewportHelpers
//////////////////////////////////////////////////////////////////////////
void EditorViewportWidget::OnTitleMenu(QMenu* menu)
{
const int nWireframe = gEnv->pConsole->GetCVar("r_wireframe")->GetIVal();
QAction* action = menu->addAction(tr("Wireframe"));
connect(action, &QAction::triggered, action, []()
{
ICVar* piVar(gEnv->pConsole->GetCVar("r_wireframe"));
int nRenderMode = piVar->GetIVal();
if (nRenderMode != R_WIREFRAME_MODE)
{
piVar->Set(R_WIREFRAME_MODE);
}
else
{
piVar->Set(R_SOLID_MODE);
}
});
action->setCheckable(true);
action->setChecked(nWireframe == R_WIREFRAME_MODE);
const bool bDisplayLabels = GetIEditor()->GetDisplaySettings()->IsDisplayLabels();
action = menu->addAction(tr("Labels"));
QAction* action = menu->addAction(tr("Labels"));
connect(action, &QAction::triggered, this, [bDisplayLabels] {GetIEditor()->GetDisplaySettings()->DisplayLabels(!bDisplayLabels);
});
action->setCheckable(true);
@@ -1509,10 +1495,10 @@ bool EditorViewportWidget::AddCameraMenuItems(QMenu* menu)
}
action = customCameraMenu->addAction(tr("Look through entity"));
AzToolsFramework::EntityIdList selectedEntityList;
AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult(selectedEntityList, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
action->setCheckable(selectedEntityList.size() > 0 || m_viewSourceType == ViewSourceType::AZ_Entity);
action->setEnabled(selectedEntityList.size() > 0 || m_viewSourceType == ViewSourceType::AZ_Entity);
bool areAnyEntitiesSelected = false;
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(areAnyEntitiesSelected, &AzToolsFramework::ToolsApplicationRequests::AreAnyEntitiesSelected);
action->setCheckable(areAnyEntitiesSelected || m_viewSourceType == ViewSourceType::AZ_Entity);
action->setEnabled(areAnyEntitiesSelected || m_viewSourceType == ViewSourceType::AZ_Entity);
action->setChecked(m_viewSourceType == ViewSourceType::AZ_Entity);
connect(action, &QAction::triggered, this, [this](bool isChecked)
{
@@ -1563,7 +1549,6 @@ void EditorViewportWidget::ToggleCameraObject()
{
if (m_viewSourceType == ViewSourceType::SequenceCamera)
{
gEnv->p3DEngine->GetPostEffectBaseGroup()->SetParam("Dof_Active", 0.0f);
ResetToViewSourceType(ViewSourceType::LegacyCamera);
}
else
@@ -1633,8 +1618,8 @@ void EditorViewportWidget::keyPressEvent(QKeyEvent* event)
QCoreApplication::sendEvent(GetIEditor()->GetEditorMainWindow(), event);
}
// NOTE: we keep track of keypresses and releases explicitly because the OS/Qt will insert a slight delay between sending
// keyevents when the key is held down. This is standard, but makes responding to key events for game style input silly
// NOTE: we keep track of key presses and releases explicitly because the OS/Qt will insert a slight delay between sending
// key events when the key is held down. This is standard, but makes responding to key events for game style input silly
// because we want the movement to be butter smooth.
if (!event->isAutoRepeat())
{
@@ -1814,11 +1799,6 @@ void EditorViewportWidget::SetViewTM(const Matrix34& viewTM, bool bMoveOnly)
//////////////////////////////////////////////////////////////////////////
void EditorViewportWidget::RenderSelectedRegion()
{
if (!m_engine)
{
return;
}
AABB box;
GetIEditor()->GetSelectedRegion(box);
if (box.IsEmpty())
@@ -2013,7 +1993,7 @@ Vec3 EditorViewportWidget::WorldToView3D(const Vec3& wp, [[maybe_unused]] int nF
//////////////////////////////////////////////////////////////////////////
QPoint EditorViewportWidget::WorldToView(const Vec3& wp) const
{
return m_renderViewport->ViewportWorldToScreen(LYVec3ToAZVec3(wp));
return AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(m_renderViewport->ViewportWorldToScreen(LYVec3ToAZVec3(wp)));
}
//////////////////////////////////////////////////////////////////////////
QPoint EditorViewportWidget::WorldToViewParticleEditor(const Vec3& wp, int width, int height) const
@@ -2035,7 +2015,8 @@ QPoint EditorViewportWidget::WorldToViewParticleEditor(const Vec3& wp, int width
}
//////////////////////////////////////////////////////////////////////////
Vec3 EditorViewportWidget::ViewToWorld(const QPoint& vp, bool* collideWithTerrain, bool onlyTerrain, bool bSkipVegetation, bool bTestRenderMesh, bool* collideWithObject) const
Vec3 EditorViewportWidget::ViewToWorld(
const QPoint& vp, bool* collideWithTerrain, bool onlyTerrain, bool bSkipVegetation, bool bTestRenderMesh, bool* collideWithObject) const
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Editor);
@@ -2046,7 +2027,7 @@ Vec3 EditorViewportWidget::ViewToWorld(const QPoint& vp, bool* collideWithTerrai
AZ_UNUSED(bSkipVegetation)
AZ_UNUSED(collideWithObject)
auto ray = m_renderViewport->ViewportScreenToWorldRay(vp);
auto ray = m_renderViewport->ViewportScreenToWorldRay(AzToolsFramework::ViewportInteraction::ScreenPointFromQPoint(vp));
if (!ray.has_value())
{
return Vec3(0, 0, 0);
@@ -2147,23 +2128,29 @@ bool EditorViewportWidget::AdjustObjectPosition(const ray_hit& hit, Vec3& outNor
//////////////////////////////////////////////////////////////////////////
bool EditorViewportWidget::RayRenderMeshIntersection(IRenderMesh* pRenderMesh, const Vec3& vInPos, const Vec3& vInDir, Vec3& vOutPos, Vec3& vOutNormal) const
{
SRayHitInfo hitInfo;
AZ_UNUSED(pRenderMesh);
AZ_UNUSED(vInPos);
AZ_UNUSED(vInDir);
AZ_UNUSED(vOutPos);
AZ_UNUSED(vOutNormal);
return false;
/*SRayHitInfo hitInfo;
hitInfo.bUseCache = false;
hitInfo.bInFirstHit = false;
hitInfo.inRay.origin = vInPos;
hitInfo.inRay.direction = vInDir.GetNormalized();
hitInfo.inReferencePoint = vInPos;
hitInfo.fMaxHitDistance = 0;
bool bRes = GetIEditor()->Get3DEngine()->RenderMeshRayIntersection(pRenderMesh, hitInfo, nullptr);
bool bRes = ???->RenderMeshRayIntersection(pRenderMesh, hitInfo, nullptr);
vOutPos = hitInfo.vHitPos;
vOutNormal = hitInfo.vHitNormal;
return bRes;
return bRes;*/
}
void EditorViewportWidget::UnProjectFromScreen(float sx, float sy, float sz, float* px, float* py, float* pz) const
{
AZ::Vector3 wp;
wp = m_renderViewport->ViewportScreenToWorld({(int)sx, m_rcClient.bottom() - ((int)sy)}, sz).value_or(wp);
wp = m_renderViewport->ViewportScreenToWorld(AzFramework::ScreenPoint{(int)sx, m_rcClient.bottom() - ((int)sy)}, sz).value_or(wp);
*px = wp.GetX();
*py = wp.GetY();
*pz = wp.GetZ();
@@ -2171,9 +2158,9 @@ void EditorViewportWidget::UnProjectFromScreen(float sx, float sy, float sz, flo
void EditorViewportWidget::ProjectToScreen(float ptx, float pty, float ptz, float* sx, float* sy, float* sz) const
{
QPoint screenPosition = m_renderViewport->ViewportWorldToScreen(AZ::Vector3{ptx, pty, ptz});
*sx = screenPosition.x();
*sy = screenPosition.y();
AzFramework::ScreenPoint screenPosition = m_renderViewport->ViewportWorldToScreen(AZ::Vector3{ptx, pty, ptz});
*sx = screenPosition.m_x;
*sy = screenPosition.m_y;
*sz = 0.f;
}
@@ -2428,7 +2415,6 @@ void EditorViewportWidget::SetDefaultCamera()
return;
}
ResetToViewSourceType(ViewSourceType::None);
gEnv->p3DEngine->GetPostEffectBaseGroup()->SetParam("Dof_Active", 0.0f);
GetViewManager()->SetCameraObjectId(m_cameraObjectId);
SetName(m_defaultViewName);
SetViewTM(m_defaultViewTM);
@@ -2823,14 +2809,16 @@ void EditorViewportWidget::RestoreViewportAfterGameMode()
void EditorViewportWidget::UpdateScene()
{
AZStd::vector<AzFramework::Scene*> scenes;
AzFramework::SceneSystemRequestBus::BroadcastResult(scenes, &AzFramework::SceneSystemRequests::GetAllScenes);
if (scenes.size() > 0)
auto sceneSystem = AzFramework::SceneSystemInterface::Get();
if (sceneSystem)
{
AZ::RPI::SceneNotificationBus::Handler::BusDisconnect();
auto scene = scenes[0];
m_renderViewport->SetScene(scene);
AZ::RPI::SceneNotificationBus::Handler::BusConnect(m_renderViewport->GetViewportContext()->GetRenderScene()->GetId());
AZStd::shared_ptr<AzFramework::Scene> mainScene = sceneSystem->GetScene(AzFramework::Scene::MainSceneName);
if (mainScene)
{
AZ::RPI::SceneNotificationBus::Handler::BusDisconnect();
m_renderViewport->SetScene(mainScene);
AZ::RPI::SceneNotificationBus::Handler::BusConnect(m_renderViewport->GetViewportContext()->GetRenderScene()->GetId());
}
}
}
@@ -2883,4 +2871,35 @@ void EditorViewportWidget::SetAsActiveViewport()
}
}
EditorViewportSettings::EditorViewportSettings(const EditorViewportWidget* editorViewportWidget)
: m_editorViewportWidget(editorViewportWidget)
{
}
bool EditorViewportSettings::GridSnappingEnabled() const
{
return m_editorViewportWidget->GetViewManager()->GetGrid()->IsEnabled();
}
float EditorViewportSettings::GridSize() const
{
const CGrid* grid = m_editorViewportWidget->GetViewManager()->GetGrid();
return grid->scale * grid->size;
}
bool EditorViewportSettings::ShowGrid() const
{
return gSettings.viewports.bShowGridGuide;
}
bool EditorViewportSettings::AngleSnappingEnabled() const
{
return m_editorViewportWidget->GetViewManager()->GetGrid()->IsAngleSnapEnabled();
}
float EditorViewportSettings::AngleStep() const
{
return m_editorViewportWidget->GetViewManager()->GetGrid()->GetAngleSnap();
}
#include <moc_EditorViewportWidget.cpp>
+25 -23
View File
@@ -28,7 +28,7 @@
#include <AzCore/Component/EntityId.h>
#include <AzCore/std/optional.h>
#include <AzFramework/Input/Buses/Requests/InputSystemCursorRequestBus.h>
#include <AzFramework/Scene/SceneSystemBus.h>
#include <AzFramework/Scene/SceneSystemInterface.h>
#include <AzFramework/Asset/AssetCatalogBus.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/API/EditorCameraBus.h>
@@ -65,6 +65,23 @@ namespace AzToolsFramework
class ManipulatorManager;
}
class EditorViewportWidget;
//! Viewport settings for the EditorViewportWidget
struct EditorViewportSettings : public AzToolsFramework::ViewportInteraction::ViewportSettings
{
explicit EditorViewportSettings(const EditorViewportWidget* editorViewportWidget);
bool GridSnappingEnabled() const override;
float GridSize() const override;
bool ShowGrid() const override;
bool AngleSnappingEnabled() const override;
float AngleStep() const override;
private:
const EditorViewportWidget* m_editorViewportWidget = nullptr;
};
// EditorViewportWidget window
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
@@ -189,22 +206,16 @@ public:
virtual void OnStartPlayInEditor();
virtual void OnStopPlayInEditor();
// AzToolsFramework::ViewportInteractionRequestBus
AzFramework::CameraState GetCameraState();
bool GridSnappingEnabled();
float GridSize();
bool ShowGrid();
bool AngleSnappingEnabled();
float AngleStep();
QPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition);
AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition);
// AzToolsFramework::ViewportFreezeRequestBus
bool IsViewportInputFrozen() override;
void FreezeViewportInput(bool freeze) override;
// AzToolsFramework::MainEditorViewportInteractionRequestBus
AZ::EntityId PickEntity(const QPoint& point) override;
AZ::Vector3 PickTerrain(const QPoint& point) override;
AZ::EntityId PickEntity(const AzFramework::ScreenPoint& point) override;
AZ::Vector3 PickTerrain(const AzFramework::ScreenPoint& point) override;
float TerrainHeight(const AZ::Vector2& position) override;
void FindVisibleEntities(AZStd::vector<AZ::EntityId>& visibleEntitiesOut) override;
bool ShowingWorldSpace() override;
@@ -234,11 +245,8 @@ public:
QPoint ViewportToWidget(const QPoint& point) const;
QSize WidgetToViewport(const QSize& size) const;
/// Take raw input and create a final mouse interaction.
/// @attention Do not map **point** from widget to viewport explicitly,
/// this is handled internally by BuildMouseInteraction - just pass directly.
AzToolsFramework::ViewportInteraction::MouseInteraction BuildMouseInteraction(
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPoint& point);
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPoint& point) override;
void SetPlayerPos()
{
@@ -398,9 +406,6 @@ protected:
};
void ResetToViewSourceType(const ViewSourceType& viewSourType);
//! Assigned renderer.
IRenderer* m_renderer = nullptr;
I3DEngine* m_engine = nullptr;
bool m_bRenderContextCreated = false;
bool m_bInRotateMode = false;
bool m_bInMoveMode = false;
@@ -487,10 +492,6 @@ protected:
OBB m_GroundOBB;
Vec3 m_GroundOBBPos;
//-------------------------------------------
// Render options.
bool m_bRenderStats = true;
// Index of camera objects.
mutable GUID m_cameraObjectId;
mutable AZ::EntityId m_viewEntityId;
@@ -563,8 +564,7 @@ private:
void PushDisableRendering();
void PopDisableRendering();
bool IsRenderingDisabled() const;
AzToolsFramework::ViewportInteraction::MousePick BuildMousePickInternal(
const QPoint& point) const;
AzToolsFramework::ViewportInteraction::MousePick BuildMousePickInternal(const QPoint& point) const;
void RestoreViewportAfterGameMode();
void UpdateCameraFromViewportContext();
@@ -607,5 +607,7 @@ private:
AZ::Name m_defaultViewportContextName;
EditorViewportSettings m_editorViewportSettings;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
-66
View File
@@ -1,66 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "EditorDefs.h"
#include "EnvironmentPanel.h"
// Editor
#include "GameEngine.h"
#include "CryEditDoc.h"
// Cry3DEngine
#include <Cry3DEngine/Environment/OceanEnvironmentBus.h>
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
#include <ui_EnvironmentPanel.h>
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
/////////////////////////////////////////////////////////////////////////////
// CEnvironmentPanel dialog
CEnvironmentPanel::CEnvironmentPanel(QWidget* pParent /*=nullptr*/)
: QWidget(pParent)
, ui(new Ui::CEnvironmentPanel)
{
XmlNodeRef node = GetIEditor()->GetDocument()->GetEnvironmentTemplate();
// is the feature toggle enabled?
bool bHasOceanFeature = false;
AZ::OceanFeatureToggleBus::BroadcastResult(bHasOceanFeature, &AZ::OceanFeatureToggleBus::Events::OceanComponentEnabled);
if (bHasOceanFeature)
{
node->findChild("Ocean")->setAttr("hidden", true);
node->findChild("OceanAnimation")->setAttr("hidden", true);
}
m_onSetCallback = AZStd::bind(&CCryEditDoc::OnEnvironmentPropertyChanged, GetIEditor()->GetDocument(), AZStd::placeholders::_1);
ui->setupUi(this);
ui->m_wndProps->Setup();
ui->m_wndProps->CreateItems(node, m_varBlock, &m_onSetCallback, true);
ui->m_wndProps->RebuildCtrl(false);
ui->m_wndProps->ExpandAll();
connect(ui->APPLYBTN, &QPushButton::clicked, this, &CEnvironmentPanel::OnBnClickedApply);
}
CEnvironmentPanel::~CEnvironmentPanel()
{
}
//////////////////////////////////////////////////////////////////////////
void CEnvironmentPanel::OnBnClickedApply()
{
GetIEditor()->GetGameEngine()->ReloadEnvironment();
}
-53
View File
@@ -1,53 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_ENVIRONMENTPANEL_H
#define CRYINCLUDE_EDITOR_ENVIRONMENTPANEL_H
#pragma once
// EnvironmentPanel.h : header file
//
#include "Util/Variable.h"
#include <QWidget>
#include <QScopedPointer>
/////////////////////////////////////////////////////////////////////////////
// CEnvironmentPanel dialog
namespace Ui {
class CEnvironmentPanel;
}
class CEnvironmentPanel
: public QWidget
{
// Construction
public:
CEnvironmentPanel(QWidget* pParent = nullptr); // standard constructor
~CEnvironmentPanel();
// Implementation
protected:
CVarBlockPtr m_varBlock;
public:
void OnBnClickedApply();
private:
QScopedPointer<Ui::CEnvironmentPanel> ui;
IVariable::OnSetCallback m_onSetCallback;
};
#endif // CRYINCLUDE_EDITOR_ENVIRONMENTPANEL_H
-56
View File
@@ -1,56 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CEnvironmentPanel</class>
<widget class="QWidget" name="CEnvironmentPanel">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>264</width>
<height>259</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="ReflectedPropertyControl" name="m_wndProps" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>200</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="APPLYBTN">
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>162</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ReflectedPropertyControl</class>
<extends>QWidget</extends>
<header>Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
-1
View File
@@ -19,7 +19,6 @@
#pragma once
// forward declarations.
class CMaterial;
class CParticleItem;
#include "BaseLibraryItem.h"
-10
View File
@@ -519,11 +519,6 @@ void CErrorReportDialog::OnReportItemDblClick(const QModelIndex& index)
}
bDone = true;
}
if (pError && pError->pItem != NULL)
{
GetIEditor()->OpenMaterialLibrary(pError->pItem);
bDone = true;
}
if (!bDone && pError && GetIEditor()->GetActiveView())
{
@@ -581,11 +576,6 @@ void CErrorReportDialog::OnReportHyperlink(const QModelIndex& index)
GetIEditor()->SelectObject(pError->pObject);
bDone = true;
}
if (pError && pError->pItem != NULL)
{
GetIEditor()->OpenMaterialLibrary(pError->pItem);
bDone = true;
}
if (!bDone && pError && GetIEditor()->GetActiveView())
{
+5 -164
View File
@@ -22,8 +22,6 @@
#include <Maestro/Types/AnimParamType.h>
// Editor
#include "Geometry/EdGeometry.h"
#include "Material/Material.h"
#include "ViewManager.h"
#include "OBJExporter.h"
#include "OCMExporter.h"
@@ -42,6 +40,9 @@
#include "Resource.h"
#include "Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.h"
#include <IEntityRenderState.h>
#include <IStatObj.h>
namespace
{
void SetTexture(Export::TPath& outName, IRenderShaderResources* pRes, int nSlot)
@@ -79,47 +80,6 @@ Export::CMesh::CMesh()
}
void Export::CMesh::SetMaterial(CMaterial* pMtl, CBaseObject* pBaseObj)
{
if (!pMtl)
{
cry_strcpy(material.name, pBaseObj->GetName().toUtf8().data());
return;
}
cry_strcpy(material.name, pMtl->GetFullName().toUtf8().data());
_smart_ptr<IMaterial> matInfo = pMtl->GetMatInfo();
IRenderShaderResources* pRes = matInfo->GetShaderItem().m_pShaderResources;
if (!pRes)
{
return;
}
ColorF difColor = pRes->GetColorValue(EFTT_DIFFUSE);
material.diffuse.r = difColor.r;
material.diffuse.g = difColor.g;
material.diffuse.b = difColor.b;
material.diffuse.a = difColor.a;
ColorF specColor = pRes->GetColorValue(EFTT_SPECULAR);
material.specular.r = specColor.r;
material.specular.g = specColor.g;
material.specular.b = specColor.b;
material.specular.a = specColor.a;
material.opacity = pRes->GetStrengthValue(EFTT_OPACITY);
material.smoothness = pRes->GetStrengthValue(EFTT_SMOOTHNESS);
SetTexture(material.mapDiffuse, pRes, EFTT_DIFFUSE);
SetTexture(material.mapSpecular, pRes, EFTT_SPECULAR);
SetTexture(material.mapOpacity, pRes, EFTT_OPACITY);
SetTexture(material.mapNormals, pRes, EFTT_NORMALS);
SetTexture(material.mapDecal, pRes, EFTT_DECAL_OVERLAY);
SetTexture(material.mapDisplacement, pRes, EFTT_HEIGHT);
}
//////////////////////////////////////////////////////////
// CObject
Export::CObject::CObject(const char* pName)
@@ -416,18 +376,6 @@ void CExportManager::AddMesh(Export::CObject* pObj, const IIndexedMesh* pIndMesh
pObj->m_texCoords.push_back(tc);
}
CMaterial* pMtl = 0;
if (m_pBaseObj)
{
pMtl = m_pBaseObj->GetRenderMaterial();
}
if (pMtl)
{
pObj->SetMaterialName(pMtl->GetFullName().toUtf8().data());
}
if (pIndMesh->GetSubSetCount() && !(pIndMesh->GetSubSetCount() == 1 && pIndMesh->GetSubSet(0).nNumIndices == 0))
{
for (int i = 0; i < pIndMesh->GetSubSetCount(); ++i)
@@ -447,23 +395,6 @@ void CExportManager::AddMesh(Export::CObject* pObj, const IIndexedMesh* pIndMesh
pMesh->m_faces.push_back(face);
}
if (pMtl)
{
if (pMtl->IsMultiSubMaterial())
{
CMaterial* pSubMtl = 0;
if (sms.nMatID < pMtl->GetSubMaterialCount())
{
pSubMtl = pMtl->GetSubMaterial(sms.nMatID);
}
pMesh->SetMaterial(pSubMtl, m_pBaseObj);
}
else
{
pMesh->SetMaterial(pMtl, m_pBaseObj);
}
}
pObj->m_meshes.push_back(pMesh);
}
}
@@ -497,10 +428,6 @@ void CExportManager::AddMesh(Export::CObject* pObj, const IIndexedMesh* pIndMesh
}
}
if (m_pBaseObj && pMtl)
{
pMesh->SetMaterial(pMtl, m_pBaseObj);
}
pObj->m_meshes.push_back(pMesh);
}
}
@@ -569,53 +496,6 @@ bool CExportManager::AddStatObj(Export::CObject* pObj, IStatObj* pStatObj, Matri
bool CExportManager::AddMeshes(Export::CObject* pObj)
{
CEdGeometry* pEdGeom = m_pBaseObj->GetGeometry();
IIndexedMesh* pIndMesh = 0;
if (pEdGeom)
{
size_t idx = 0;
size_t nextIdx = 0;
do
{
pIndMesh = 0;
if (m_isOccluder)
{
if (pEdGeom->GetIStatObj() && pEdGeom->GetIStatObj()->GetLodObject(2))
{
pIndMesh = pEdGeom->GetIStatObj()->GetLodObject(2)->GetIndexedMesh(true);
}
if (!pIndMesh && pEdGeom->GetIStatObj() && pEdGeom->GetIStatObj()->GetLodObject(1))
{
pIndMesh = pEdGeom->GetIStatObj()->GetLodObject(1)->GetIndexedMesh(true);
}
}
if (!pIndMesh)
{
pIndMesh = pEdGeom->GetIndexedMesh(idx);
nextIdx++;
}
if (!pIndMesh)
{
break;
}
Matrix34 tm;
pEdGeom->GetTM(&tm, idx);
Matrix34A objTM = tm;
AddMesh(pObj, pIndMesh, &objTM);
idx = nextIdx;
}
while (pIndMesh && idx);
if (idx > 0)
{
return true;
}
}
if (m_pBaseObj->GetType() == OBJTYPE_AZENTITY)
{
CEntityObject* pEntityObject = (CEntityObject*)m_pBaseObj;
@@ -623,11 +503,7 @@ bool CExportManager::AddMeshes(Export::CObject* pObj)
if (pEngineNode)
{
if (m_isPrecaching)
{
GetIEditor()->Get3DEngine()->PrecacheRenderNode(pEngineNode, 0);
}
else
if (!m_isPrecaching)
{
for (int i = 0; i < pEngineNode->GetSlotCount(); ++i)
{
@@ -1166,35 +1042,6 @@ bool CExportManager::AddSelectedEntityObjects()
return true;
}
bool CExportManager::AddSelectedObjects()
{
CSelectionGroup* pSelection = GetIEditor()->GetSelection();
int numObjects = pSelection->GetCount();
if (numObjects > m_data.m_objects.size())
{
m_data.m_objects.reserve(numObjects + 1); // +1 for terrain
}
// First run pipeline to precache geometry
m_isPrecaching = true;
for (int i = 0; i < numObjects; i++)
{
AddObject(pSelection->GetObject(i));
}
GetIEditor()->Get3DEngine()->ProposeContentPrecache();
// Repeat pipeline to collect geometry
m_isPrecaching = false;
for (int i = 0; i < numObjects; i++)
{
AddObject(pSelection->GetObject(i));
}
return true;
}
bool CExportManager::AddSelectedRegionObjects()
{
AABB box;
@@ -1219,8 +1066,6 @@ bool CExportManager::AddSelectedRegionObjects()
AddObject(objects[i]);
}
GetIEditor()->Get3DEngine()->ProposeContentPrecache();
// Repeat pipeline to collect geometry
m_isPrecaching = false;
for (size_t i = 0; i < numObjects; ++i)
@@ -1260,7 +1105,7 @@ bool CExportManager::ExportToFile(const char* filename, bool bClearDataAfterExpo
}
bool CExportManager::Export(const char* defaultName, const char* defaultExt, const char* defaultPath, bool isSelectedObjects, bool isSelectedRegionObjects, bool isOccluder, bool bAnimationExport)
bool CExportManager::Export(const char* defaultName, const char* defaultExt, const char* defaultPath, [[maybe_unused]] bool isSelectedObjects, bool isSelectedRegionObjects, bool isOccluder, bool bAnimationExport)
{
m_bAnimationExport = bAnimationExport;
@@ -1304,10 +1149,6 @@ bool CExportManager::Export(const char* defaultName, const char* defaultExt, con
if (m_bAnimationExport || CFileUtil::SelectSaveFile(filters, defaultExt, defaultPath, newFilename))
{
WaitCursor wait;
if (isSelectedObjects)
{
AddSelectedObjects();
}
if (isSelectedRegionObjects)
{
AddSelectedRegionObjects();
@@ -43,8 +43,6 @@ namespace Export
virtual int GetFaceCount() const { return m_faces.size(); }
virtual const Face* GetFaceBuffer() const { return m_faces.size() ? &m_faces[0] : 0; }
void SetMaterial(CMaterial* pMtl, CBaseObject* pBaseObj);
private:
std::vector<Face> m_faces;
@@ -130,10 +128,6 @@ public:
bool Export(const char* defaultName, const char* defaultExt = "", const char* defaultPath = "", bool isSelectedObjects = true,
bool isSelectedRegionObjects = false, bool isOccluder = false, bool bAnimationExport = false);
//! Add to Export Data geometry from selected objects
//! return true if succeed, otherwise false
bool AddSelectedObjects();
bool AddSelectedEntityObjects();
//! Add to Export Data geometry from objects inside selected region volume
+1 -193
View File
@@ -34,15 +34,11 @@
// Editor
#include "IEditorImpl.h"
#include "CryEditDoc.h"
#include "Geometry/EdMesh.h"
#include "Mission.h"
#include "Settings.h"
// CryCommon
#include <CryCommon/I3DEngine.h>
#include <CryCommon/INavigationSystem.h>
#include <CryCommon/IDeferredCollisionEvent.h>
#include <CryCommon/ITimeOfDay.h>
#include <CryCommon/LyShine/ILyShine.h>
#include <CryCommon/MainThreadRenderRequestBus.h>
@@ -283,7 +279,6 @@ AZ_POP_DISABLE_WARNING
AZ::Interface<IEditorCameraController>::Unregister(this);
GetIEditor()->UnregisterNotifyListener(this);
m_pISystem->GetIMovieSystem()->SetCallback(NULL);
CEdMesh::ReleaseAll();
if (m_gameDll)
{
@@ -493,13 +488,6 @@ AZ::Outcome<void, AZStd::string> CGameEngine::Init(
SetEditorCoreEnvironment(gEnv);
if (gEnv
&& gEnv->p3DEngine
&& gEnv->p3DEngine->GetTimeOfDay())
{
gEnv->p3DEngine->GetTimeOfDay()->BeginEditMode();
}
if (gEnv && gEnv->pMovieSystem)
{
gEnv->pMovieSystem->EnablePhysicsEvents(m_bSimulationMode);
@@ -549,26 +537,14 @@ void CGameEngine::SetLevelPath(const QString& path)
{
m_levelExtension = defaultExtension;
}
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->SetLevelPath(m_levelPath.toUtf8().data());
}
}
void CGameEngine::SetMissionName(const QString& mission)
{
m_missionName = mission;
}
bool CGameEngine::LoadLevel(
const QString& mission,
[[maybe_unused]] bool bDeleteAIGraph,
bool bReleaseResources)
{
LOADING_TIME_PROFILE_SECTION(GetIEditor()->GetSystem());
m_bLevelLoaded = false;
m_missionName = mission;
CLogFile::FormatLine("Loading map '%s' into engine...", m_levelPath.toUtf8().data());
// Switch the current directory back to the Primary CD folder first.
// The engine might have trouble to find some files when the current
@@ -607,30 +583,17 @@ bool CGameEngine::LoadLevel(
}
// Load level in 3d engine.
if (gEnv->p3DEngine && !gEnv->p3DEngine->InitLevelForEditor(m_levelPath.toUtf8().data(), m_missionName.toUtf8().data()))
{
CLogFile::WriteLine("ERROR: Can't load level !");
QMessageBox::critical(QApplication::activeWindow(), QString(), QObject::tr("ERROR: Can't load level !"));
return false;
}
// Audio: notify audio of level loading start?
GetIEditor()->GetObjectManager()->SendEvent(EVENT_REFRESH);
m_bLevelLoaded = true;
if (!bReleaseResources)
{
ReloadEnvironment();
}
return true;
}
bool CGameEngine::ReloadLevel()
{
if (!LoadLevel(GetMissionName(), false, false))
if (!LoadLevel(false, false))
{
return false;
}
@@ -638,61 +601,8 @@ bool CGameEngine::ReloadLevel()
return true;
}
bool CGameEngine::LoadMission(const QString& mission)
{
if (!IsLevelLoaded())
{
return false;
}
if (mission != m_missionName)
{
m_missionName = mission;
gEnv->p3DEngine->LoadMissionDataFromXMLNode(m_missionName.toUtf8().data());
}
return true;
}
bool CGameEngine::ReloadEnvironment()
{
if (!gEnv->p3DEngine)
{
return false;
}
if (!IsLevelLoaded() && !m_bJustCreated)
{
return false;
}
if (!GetIEditor()->GetDocument())
{
return false;
}
XmlNodeRef env = XmlHelpers::CreateXmlNode("Environment");
CXmlTemplate::SetValues(GetIEditor()->GetDocument()->GetEnvironmentTemplate(), env);
// Notify mission that environment may be changed.
GetIEditor()->GetDocument()->GetCurrentMission()->OnEnvironmentChange();
QString xmlStr = QString::fromLatin1(env->getXML());
// Reload level data in engine.
gEnv->p3DEngine->LoadEnvironmentSettingsFromXML(env);
return true;
}
void CGameEngine::SwitchToInGame()
{
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->DisablePostEffects();
gEnv->p3DEngine->ResetPostEffects();
}
auto streamer = AZ::Interface<AZ::IO::IStreamer>::Get();
if (streamer)
{
@@ -707,11 +617,6 @@ void CGameEngine::SwitchToInGame()
m_pISystem->SetThreadState(ESubsys_Physics, false);
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->ResetParticlesAndDecals();
}
m_pISystem->GetIMovieSystem()->EnablePhysicsEvents(true);
m_bInGameMode = true;
@@ -721,10 +626,6 @@ void CGameEngine::SwitchToInGame()
pRuler->SetActive(false);
}
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->GetTimeOfDay()->EndEditMode();
}
gEnv->pSystem->GetViewCamera().SetMatrix(m_playerViewTM);
// Disable accelerators.
@@ -760,24 +661,9 @@ void CGameEngine::SwitchToInEditor()
m_pISystem->SetThreadState(ESubsys_Physics, false);
if (gEnv->p3DEngine)
{
// Reset 3d engine effects
gEnv->p3DEngine->DisablePostEffects();
gEnv->p3DEngine->ResetPostEffects();
gEnv->p3DEngine->ResetParticlesAndDecals();
}
CViewport* pGameViewport = GetIEditor()->GetViewManager()->GetGameViewport();
m_pISystem->GetIMovieSystem()->EnablePhysicsEvents(m_bSimulationMode);
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->GetTimeOfDay()->BeginEditMode();
// this has to be done before the RemoveSink() call, or else some entities may not be removed
gEnv->p3DEngine->GetDeferredPhysicsEventManager()->ClearDeferredEvents();
}
// Enable accelerators.
GetIEditor()->EnableAcceleratos(true);
@@ -865,7 +751,6 @@ void CGameEngine::SetGameMode(bool bInGame)
// Ignore updates while changing in and out of game mode
m_bIgnoreUpdates = true;
LockResources();
// Switching modes will destroy the current AzFramework::EntityConext which may contain
// data the queued events hold on to, so execute all queued events before switching.
@@ -891,7 +776,6 @@ void CGameEngine::SetGameMode(bool bInGame)
GetISystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_EDITOR_GAME_MODE_CHANGED, bInGame, 0);
UnlockResources();
m_bIgnoreUpdates = false;
GetISystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_GAME_MODE_SWITCH_END, bInGame, 0);
@@ -906,11 +790,6 @@ void CGameEngine::SetSimulationMode(bool enabled, bool bOnlyPhysics)
m_pISystem->GetIMovieSystem()->EnablePhysicsEvents(enabled);
if (!bOnlyPhysics)
{
LockResources();
}
if (enabled)
{
CRuler* pRuler = GetIEditor()->GetRuler();
@@ -935,35 +814,12 @@ void CGameEngine::SetSimulationMode(bool enabled, bool bOnlyPhysics)
if (m_bSimulationMode)
{
if (!bOnlyPhysics)
{
if (m_pISystem->GetI3DEngine())
{
m_pISystem->GetI3DEngine()->ResetPostEffects();
}
GetIEditor()->SetConsoleVar("ai_ignoreplayer", 1);
//GetIEditor()->SetConsoleVar( "ai_soundperception",0 );
}
// [Anton] the order of the next 3 calls changed, since, EVENT_INGAME loads physics state (if any),
// and Reset should be called before it
GetIEditor()->GetObjectManager()->SendEvent(EVENT_INGAME);
}
else
{
if (!bOnlyPhysics)
{
GetIEditor()->SetConsoleVar("ai_ignoreplayer", 0);
//GetIEditor()->SetConsoleVar( "ai_soundperception",1 );
if (m_pISystem->GetI3DEngine())
{
m_pISystem->GetI3DEngine()->ResetPostEffects();
}
}
GetIEditor()->GetObjectManager()->SendEvent(EVENT_OUTOFGAME);
}
@@ -983,23 +839,9 @@ void CGameEngine::SetSimulationMode(bool enabled, bool bOnlyPhysics)
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(&AzToolsFramework::EditorEntityContextRequestBus::Events::StartPlayInEditor);
}
if (!bOnlyPhysics)
{
UnlockResources();
}
AzFramework::InputChannelRequestBus::Broadcast(&AzFramework::InputChannelRequests::ResetState);
}
void CGameEngine::ResetResources()
{
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->UnloadLevel();
}
}
void CGameEngine::SetPlayerViewMatrix(const Matrix34& tm, [[maybe_unused]] bool bEyePos)
{
m_playerViewTM = tm;
@@ -1107,24 +949,6 @@ void CGameEngine::OnEditorNotifyEvent(EEditorNotifyEvent event)
{
switch (event)
{
case eNotify_OnBeginNewScene:
case eNotify_OnBeginSceneOpen:
{
ResetResources();
}
break;
case eNotify_OnEndSceneOpen:
case eNotify_OnEndTerrainRebuild:
{
}
case eNotify_OnEndNewScene: // intentional fall-through?
{
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->PostLoadLevel();
}
}
break;
case eNotify_OnSplashScreenDestroyed:
{
if (m_pSystemUserCallback != NULL)
@@ -1136,22 +960,6 @@ void CGameEngine::OnEditorNotifyEvent(EEditorNotifyEvent event)
}
}
void CGameEngine::LockResources()
{
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->LockCGFResources();
}
}
void CGameEngine::UnlockResources()
{
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->UnlockCGFResources();
}
}
void CGameEngine::OnTerrainModified(const Vec2& modPosition, float modAreaRadius, bool fullTerrain)
{
INavigationSystem* pNavigationSystem = nullptr; // INavigationSystem will be converted to an AZInterface (LY-111343)
-13
View File
@@ -89,15 +89,10 @@ public:
//! Load new terrain level into 3d engine.
//! Also load AI triangulation for this level.
bool LoadLevel(
const QString& mission,
bool bDeleteAIGraph,
bool bReleaseResources);
//!* Reload level if it was already loaded.
bool ReloadLevel();
//! Load new mission.
bool LoadMission(const QString& mission);
//! Reload environment settings in currently loaded level.
bool ReloadEnvironment();
//! Request to switch In/Out of game mode on next update.
//! The switch will happen when no sub systems are currently being updated.
//! @param inGame When true editor switch to game mode.
@@ -111,14 +106,10 @@ public:
bool IsLevelLoaded() const { return m_bLevelLoaded; };
//! Assign new level path name.
void SetLevelPath(const QString& path);
//! Assign new current mission name.
void SetMissionName(const QString& mission);
//! Return name of currently loaded level.
const QString& GetLevelName() const { return m_levelName; };
//! Return extension of currently loaded level.
const QString& GetLevelExtension() const { return m_levelExtension; };
//! Return name of currently active mission.
const QString& GetMissionName() const { return m_missionName; };
//! Get fully specified level path.
const QString& GetLevelPath() const { return m_levelPath; };
//! Query if engine is in game mode.
@@ -142,9 +133,6 @@ public:
//! Called every frame.
void Update();
virtual void OnEditorNotifyEvent(EEditorNotifyEvent event);
void LockResources();
void UnlockResources();
void ResetResources();
void OnTerrainModified(const Vec2& modPosition, float modAreaRadius, bool fullTerrain);
void OnAreaModified(const AABB& modifiedArea);
@@ -179,7 +167,6 @@ private:
CLogFile m_logFile;
QString m_levelName;
QString m_levelExtension;
QString m_missionName;
QString m_levelPath;
QString m_MOD;
bool m_bLevelLoaded;
+1 -299
View File
@@ -24,20 +24,13 @@
#include "GameExporter.h"
#include "GameEngine.h"
#include "CryEditDoc.h"
#include "Mission.h"
#include "ShaderCache.h"
#include "UsedResources.h"
#include "Material/MaterialManager.h"
#include "Material/MaterialLibrary.h"
#include "WaitProgress.h"
#include "Util/CryMemFile.h"
#include "Objects/ObjectManager.h"
#include "Objects/ObjectPhysicsManager.h"
#include "Objects/EntityObject.h"
#include "LensFlareEditor/LensFlareManager.h"
#include "LensFlareEditor/LensFlareLibrary.h"
#include "LensFlareEditor/LensFlareItem.h"
#include <AzFramework/Terrain/TerrainDataRequestBus.h>
@@ -137,13 +130,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
m_levelPath = Path::RemoveBackslash(sLevelPath);
QString rootLevelPath = Path::AddSlash(pGameEngine->GetLevelPath());
// Make sure we unload any unused CGFs before exporting so that they don't end up in
// the level data.
if (pEditor->Get3DEngine())
{
pEditor->Get3DEngine()->FreeUnusedCGFResources();
}
CCryEditDoc* pDocument = pEditor->GetDocument();
if (flags & eExp_Fast)
@@ -192,21 +178,11 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
}
}
////////////////////////////////////////////////////////////////////////
// Inform all objects that an export is about to begin
////////////////////////////////////////////////////////////////////////
if (exportSuccessful)
{
GetIEditor()->GetObjectManager()->GetPhysicsManager()->PrepareForExport();
}
////////////////////////////////////////////////////////////////////////
// Export all data to the game
////////////////////////////////////////////////////////////////////////
if (exportSuccessful)
{
ExportVisAreas(sLevelPath.toUtf8().data(), eExportEndian);
////////////////////////////////////////////////////////////////////////
// Exporting map setttings
////////////////////////////////////////////////////////////////////////
@@ -219,7 +195,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
ExportLevelInfo(sLevelPath);
ExportLevelLensFlares(sLevelPath);
ExportLevelResourceList(sLevelPath);
ExportLevelUsedResourceList(sLevelPath);
ExportLevelShaderCache(sLevelPath);
@@ -269,47 +244,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
return exportSuccessful;
}
//////////////////////////////////////////////////////////////////////////
void CGameExporter::ExportVisAreas(const char* pszGamePath, EEndian eExportEndian)
{
char szFileOutputPath[_MAX_PATH];
// export visareas
IEditor* pEditor = GetIEditor();
// remove old files
sprintf_s(szFileOutputPath, "%s%s", pszGamePath, COMPILED_VISAREA_MAP_FILE_NAME);
m_levelPak.m_pakFile.RemoveFile(szFileOutputPath);
SHotUpdateInfo exportInfo;
I3DEngine* p3DEngine = pEditor->Get3DEngine();
if (p3DEngine && (eExportEndian == GetPlatformEndian())) // skip second export, this data is common for PC and consoles
{
std::vector<struct IStatObj*>* pTempBrushTable = NULL;
std::vector<_smart_ptr<IMaterial>>* pTempMatsTable = NULL;
std::vector<struct IStatInstGroup*>* pTempVegGroupTable = NULL;
// export visareas
CLogFile::WriteLine("Exporting indoors...");
pEditor->SetStatusText("Exporting indoors...");
if (IVisAreaManager* pVisAreaManager = p3DEngine->GetIVisAreaManager())
{
if (int nSize = pVisAreaManager->GetCompiledDataSize())
{ // get visareas data from 3dengine and save it into file
uint8* pData = new uint8[nSize];
pVisAreaManager->GetCompiledData(pData, nSize, &pTempBrushTable, &pTempMatsTable, &pTempVegGroupTable, eExportEndian);
sprintf_s(szFileOutputPath, "%s%s", pszGamePath, COMPILED_VISAREA_MAP_FILE_NAME);
CCryMemFile visareasCompiledFile;
visareasCompiledFile.Write(pData, nSize);
m_levelPak.m_pakFile.UpdateFile(szFileOutputPath, visareasCompiledFile);
delete[] pData;
}
}
}
}
//////////////////////////////////////////////////////////////////////////
void CGameExporter::ExportOcclusionMesh(const char* pszGamePath)
{
@@ -334,7 +268,7 @@ void CGameExporter::ExportOcclusionMesh(const char* pszGamePath)
}
//////////////////////////////////////////////////////////////////////////
void CGameExporter::ExportLevelData(const QString& path, bool bExportMission)
void CGameExporter::ExportLevelData(const QString& path, bool /*bExportMission*/)
{
IEditor* pEditor = GetIEditor();
pEditor->SetStatusText(QObject::tr("Exporting LevelData.xml..."));
@@ -347,54 +281,6 @@ void CGameExporter::ExportLevelData(const QString& path, bool bExportMission)
XmlNodeRef rootAction = XmlHelpers::CreateXmlNode("LevelDataAction");
rootAction->setAttr("SandboxVersion", versionString);
ExportMapInfo(root);
//////////////////////////////////////////////////////////////////////////
// Export materials.
ExportMaterials(root, path);
//////////////////////////////////////////////////////////////////////////
CCryEditDoc* pDocument = pEditor->GetDocument();
CMission* pCurrentMission = 0;
if (bExportMission)
{
pCurrentMission = pDocument->GetCurrentMission();
// Save contents of current mission.
}
//////////////////////////////////////////////////////////////////////////
// Export missions tag.
//////////////////////////////////////////////////////////////////////////
XmlNodeRef missionsNode = rootAction->newChild("Missions");
QString missionFileName;
QString currentMissionFileName;
I3DEngine* p3DEngine = pEditor->Get3DEngine();
if (p3DEngine)
{
for (int i = 0; i < pDocument->GetMissionCount(); i++)
{
CMission* pMission = pDocument->GetMission(i);
QString name = pMission->GetName();
name.replace(' ', '_');
missionFileName = QStringLiteral("Mission_%1.xml").arg(name);
XmlNodeRef missionDescNode = missionsNode->newChild("Mission");
missionDescNode->setAttr("Name", pMission->GetName().toUtf8().data());
missionDescNode->setAttr("File", missionFileName.toUtf8().data());
missionDescNode->setAttr("CGFCount", p3DEngine->GetLoadedObjectCount());
int nProgressBarRange = m_numExportedMaterials / 10 + p3DEngine->GetLoadedObjectCount();
missionDescNode->setAttr("ProgressBarRange", nProgressBarRange);
if (pMission == pCurrentMission)
{
currentMissionFileName = missionFileName;
}
}
}
//////////////////////////////////////////////////////////////////////////
// Save Level Data XML
//////////////////////////////////////////////////////////////////////////
@@ -409,41 +295,6 @@ void CGameExporter::ExportLevelData(const QString& path, bool bExportMission)
CCryMemFile fileAction;
fileAction.Write(xmlDataAction.c_str(), xmlDataAction.length());
m_levelPak.m_pakFile.UpdateFile(levelDataActionFile.toUtf8().data(), fileAction);
if (bExportMission)
{
XmlNodeRef objectsNode = NULL;
//////////////////////////////////////////////////////////////////////////
// Export current mission file.
//////////////////////////////////////////////////////////////////////////
XmlNodeRef missionNode = rootAction->createNode("Mission");
pCurrentMission->Export(missionNode, objectsNode);
if (p3DEngine)
{
missionNode->setAttr("CGFCount", p3DEngine->GetLoadedObjectCount());
}
//if (!CFileUtil::OverwriteFile( path+currentMissionFileName ))
// return;
AZStd::vector<char> entitySaveBuffer;
AZ::IO::ByteContainerStream<AZStd::vector<char> > entitySaveStream(&entitySaveBuffer);
bool savedEntities = false;
EBUS_EVENT_RESULT(savedEntities, AzToolsFramework::EditorEntityContextRequestBus, SaveToStreamForGame, entitySaveStream, AZ::DataStream::ST_BINARY);
if (savedEntities)
{
QString entitiesFile;
entitiesFile = QStringLiteral("%1%2.entities_xml").arg(path, pCurrentMission ? pCurrentMission->GetName() : "");
m_levelPak.m_pakFile.UpdateFile(entitiesFile.toUtf8().data(), entitySaveBuffer.begin(), entitySaveBuffer.size());
}
_smart_ptr<IXmlStringData> pXmlStrData = missionNode->getXMLData(5000000);
CCryMemFile fileMission;
fileMission.Write(pXmlStrData->GetString(), pXmlStrData->GetStringLength());
m_levelPak.m_pakFile.UpdateFile((path + currentMissionFileName).toUtf8().data(), fileMission);
}
}
//////////////////////////////////////////////////////////////////////////
@@ -466,18 +317,6 @@ void CGameExporter::ExportLevelInfo(const QString& path)
const int compiledHeightmapSize = static_cast<int>(terrainAabb.GetXExtent() / terrainGridResolution.GetX());
root->setAttr("HeightmapSize", compiledHeightmapSize);
// Save all missions in this level.
XmlNodeRef missionsNode = root->newChild("Missions");
int numMissions = pEditor->GetDocument()->GetMissionCount();
for (int i = 0; i < numMissions; i++)
{
CMission* pMission = pEditor->GetDocument()->GetMission(i);
XmlNodeRef missionNode = missionsNode->newChild("Mission");
missionNode->setAttr("Name", pMission->GetName().toUtf8().data());
missionNode->setAttr("Description", pMission->GetDescription().toUtf8().data());
}
//////////////////////////////////////////////////////////////////////////
// Save LevelInfo file.
//////////////////////////////////////////////////////////////////////////
@@ -489,143 +328,6 @@ void CGameExporter::ExportLevelInfo(const QString& path)
m_levelPak.m_pakFile.UpdateFile(filename.toUtf8().data(), file);
}
//////////////////////////////////////////////////////////////////////////
void CGameExporter::ExportMapInfo(XmlNodeRef& node)
{
if (!GetIEditor()->Get3DEngine())
{
return;
}
XmlNodeRef info = node->newChild("LevelInfo");
IEditor* pEditor = GetIEditor();
info->setAttr("Name", QFileInfo(pEditor->GetDocument()->GetTitle()).completeBaseName());
auto terrain = AzFramework::Terrain::TerrainDataRequestBus::FindFirstHandler();
const AZ::Aabb terrainAabb = terrain ? terrain->GetTerrainAabb() : AZ::Aabb::CreateFromPoint(AZ::Vector3::CreateZero());
const AZ::Vector2 terrainGridResolution = terrain ? terrain->GetTerrainGridResolution() : AZ::Vector2::CreateOne();
const int terrainSizeInMeters = static_cast<int>(terrainAabb.GetXExtent());
const int terrainUnitSizeInMeters = static_cast<int>(terrainGridResolution.GetX());
info->setAttr("HeightmapSize", terrainSizeInMeters / terrainUnitSizeInMeters);
info->setAttr("HeightmapUnitSize", terrainUnitSizeInMeters);
//! Default Max Height value.
constexpr int HEIGHTMAP_MAX_HEIGHT = 150; //This is the default max height in CHeightmap
info->setAttr("HeightmapMaxHeight", HEIGHTMAP_MAX_HEIGHT);
info->setAttr("WaterLevel", pEditor->Get3DEngine()->GetWaterLevel());
// Serialize surface types.
CXmlArchive xmlAr;
xmlAr.bLoading = false;
xmlAr.root = node;
GetIEditor()->GetObjectManager()->GetPhysicsManager()->SerializeCollisionClasses(xmlAr);
}
//////////////////////////////////////////////////////////////////////////
void CGameExporter::ExportMaterials(XmlNodeRef& levelDataNode, const QString& path)
{
//////////////////////////////////////////////////////////////////////////
// Export materials manager.
CMaterialManager* pManager = GetIEditor()->GetMaterialManager();
pManager->Export(levelDataNode);
QString filename = Path::Make(path, MATERIAL_LEVEL_LIBRARY_FILE);
bool bHaveItems = true;
int numMtls = 0;
XmlNodeRef nodeMaterials = XmlHelpers::CreateXmlNode("MaterialsLibrary");
// Export Materials local level library.
for (int i = 0; i < pManager->GetLibraryCount(); i++)
{
XmlNodeRef nodeLib = nodeMaterials->newChild("Library");
CMaterialLibrary* pLib = (CMaterialLibrary*)pManager->GetLibrary(i);
if (pLib->GetItemCount() > 0)
{
bHaveItems = false;
// Export this library.
numMtls += pManager->ExportLib(pLib, nodeLib);
}
}
if (!bHaveItems)
{
XmlString xmlData = nodeMaterials->getXML();
CCryMemFile file;
file.Write(xmlData.c_str(), xmlData.length());
m_levelPak.m_pakFile.UpdateFile(filename.toUtf8().data(), file);
}
else
{
m_levelPak.m_pakFile.RemoveFile(filename.toUtf8().data());
}
m_numExportedMaterials = numMtls;
}
//////////////////////////////////////////////////////////////////////////
void CGameExporter::ExportLevelLensFlares(const QString& path)
{
GetIEditor()->SetStatusText(QObject::tr("Exporting Lens Flares..."));
std::vector<CBaseObject*> objects;
GetIEditor()->GetObjectManager()->FindObjectsOfType(&CEntityObject::staticMetaObject, objects);
std::set<QString> flareNameSet;
for (int i = 0, iObjectSize(objects.size()); i < iObjectSize; ++i)
{
CEntityObject* pEntity = (CEntityObject*)objects[i];
if (!pEntity->IsLight())
{
continue;
}
QString flareName = pEntity->GetEntityPropertyString(CEntityObject::s_LensFlarePropertyName);
if (flareName.isEmpty() || flareName == "@root")
{
continue;
}
flareNameSet.insert(flareName);
}
XmlNodeRef pRootNode = GetIEditor()->GetSystem()->CreateXmlNode("LensFlareList");
pRootNode->setAttr("Version", FLARE_EXPORT_FILE_VERSION);
CLensFlareManager* pLensManager = GetIEditor()->GetLensFlareManager();
if (CLensFlareLibrary* pLevelLib = (CLensFlareLibrary*)pLensManager->GetLevelLibrary())
{
for (int i = 0; i < pLevelLib->GetItemCount(); i++)
{
CLensFlareItem* pItem = (CLensFlareItem*)pLevelLib->GetItem(i);
if (flareNameSet.find(pItem->GetFullName()) == flareNameSet.end())
{
continue;
}
CBaseLibraryItem::SerializeContext ctx(pItem->CreateXmlData(), false);
pRootNode->addChild(ctx.node);
pItem->Serialize(ctx);
flareNameSet.erase(pItem->GetFullName());
}
}
std::set<QString>::iterator iFlareNameSet = flareNameSet.begin();
for (; iFlareNameSet != flareNameSet.end(); ++iFlareNameSet)
{
QString flareName = *iFlareNameSet;
XmlNodeRef pFlareNode = GetIEditor()->GetSystem()->CreateXmlNode("LensFlare");
pFlareNode->setAttr("name", flareName.toUtf8().data());
pRootNode->addChild(pFlareNode);
}
CCryMemFile lensFlareNames;
lensFlareNames.Write(pRootNode->getXMLData()->GetString(), pRootNode->getXMLData()->GetStringLength());
QString exportPathName = path + FLARE_EXPORT_FILE;
m_levelPak.m_pakFile.UpdateFile(exportPathName.toUtf8().data(), lensFlareNames);
}
//////////////////////////////////////////////////////////////////////////
void CGameExporter::ExportLevelResourceList(const QString& path)
{
-4
View File
@@ -91,15 +91,11 @@ private:
void ExportLevelData(const QString& path, bool bExportMission = true);
void ExportLevelInfo(const QString& path);
void ExportVisAreas(const char* pszGamePath, EEndian eExportEndian);
void ExportOcclusionMesh(const char* pszGamePath);
void ExportMapInfo(XmlNodeRef& node);
void ExportLevelLensFlares(const QString& path);
void ExportLevelResourceList(const QString& path);
void ExportLevelUsedResourceList(const QString& path);
void ExportLevelShaderCache(const QString& path);
void ExportMaterials(XmlNodeRef& levelDataNode, const QString& path);
void ExportGameData(const QString& path);
void ExportFileList(const QString& path, const QString& levelName);
+1 -12
View File
@@ -21,7 +21,6 @@
// Editor
#include "UsedResources.h"
#include "GameEngine.h"
#include "Material/MaterialManager.h"
#include "Include/IObjectManager.h"
#include "WaitProgress.h"
@@ -51,7 +50,7 @@ void CGameResourcesExporter::ChooseDirectory()
void CGameResourcesExporter::GatherAllLoadedResources()
{
m_files.clear();
m_files.reserve(100000); // count from GetResourceList, GetFilesFromObjects, GetFilesFromMaterials ... is unknown
m_files.reserve(100000); // count from GetResourceList, GetFilesFromObjects ... is unknown
auto pResList = gEnv->pCryPak->GetResourceList(AZ::IO::IArchive::RFOM_Level);
{
@@ -62,7 +61,6 @@ void CGameResourcesExporter::GatherAllLoadedResources()
}
GetFilesFromObjects();
GetFilesFromMaterials();
}
//////////////////////////////////////////////////////////////////////////
@@ -158,12 +156,3 @@ void CGameResourcesExporter::GetFilesFromObjects()
Append(m_files, rs.files);
}
//////////////////////////////////////////////////////////////////////////
void CGameResourcesExporter::GetFilesFromMaterials()
{
CUsedResources rs;
GetIEditor()->GetMaterialManager()->GatherUsedResources(rs);
Append(m_files, rs.files);
}
@@ -44,7 +44,6 @@ private:
void GetFilesFromObjects();
void GetFilesFromVarBlock(CVarBlock* pVB);
void GetFilesFromVariable(IVariable* pVar);
void GetFilesFromMaterials();
};
#endif // CRYINCLUDE_EDITOR_GAMERESOURCESEXPORTER_H
@@ -1,16 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "EditorDefs.h"
#include "EdGeometry.h"
-84
View File
@@ -1,84 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_GEOMETRY_EDGEOMETRY_H
#define CRYINCLUDE_EDITOR_GEOMETRY_EDGEOMETRY_H
#pragma once
struct IIndexedMesh;
struct DisplayContext;
struct HitContext;
struct SSubObjSelectionModifyContext;
class CObjectArchive;
// Basic supported geometry types.
enum EEdGeometryType
{
GEOM_TYPE_MESH = 0, // Mesh geometry.
GEOM_TYPE_BRUSH, // Solid brush geometry.
GEOM_TYPE_PATCH, // Bezier patch surface geometry.
GEOM_TYPE_NURB, // Nurbs surface geometry.
};
//////////////////////////////////////////////////////////////////////////
// Description:
// CEdGeometry is a base class for all supported editable geometries.
//////////////////////////////////////////////////////////////////////////
class CRYEDIT_API CEdGeometry
: public CRefCountBase
{
public:
CEdGeometry() {};
// Query the type of the geometry mesh.
virtual EEdGeometryType GetType() const = 0;
// Serialize geometry.
virtual void Serialize(CObjectArchive& ar) = 0;
// Return geometry axis aligned bounding box.
virtual void GetBounds(AABB& box) = 0;
// Clones Geometry, returns exact copy of the original geometry.
virtual CEdGeometry* Clone() = 0;
// Access to the indexed mesh.
// Return false if geometry can not be represented by an indexed mesh.
virtual IIndexedMesh* GetIndexedMesh(size_t idx = 0) = 0;
virtual IStatObj* GetIStatObj() const = 0;
virtual void GetTM(Matrix34* pTM, size_t idx = 0) = 0;
//////////////////////////////////////////////////////////////////////////
// Advanced geometry interface for SubObject selection and modification.
//////////////////////////////////////////////////////////////////////////
virtual void SetModified(bool bModified = true) = 0;
virtual bool IsModified() const = 0;
virtual bool StartSubObjSelection(const Matrix34& nodeWorldTM, int elemType, int nFlags) = 0;
virtual void EndSubObjSelection() = 0;
// Display geometry for sub object selection.
virtual void Display(DisplayContext& dc) = 0;
// Sub geometry hit testing and selection.
virtual bool HitTest(HitContext& hit) = 0;
//////////////////////////////////////////////////////////////////////////
virtual void ModifySelection(SSubObjSelectionModifyContext& modCtx, bool isUndo = true) = 0;
// Called when selection modification is accepted.
virtual void AcceptModifySelection() = 0;
protected:
~CEdGeometry() {};
};
#endif // CRYINCLUDE_EDITOR_GEOMETRY_EDGEOMETRY_H
File diff suppressed because it is too large Load Diff
-194
View File
@@ -1,194 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : Editor structure that wraps access to IStatObj
#ifndef CRYINCLUDE_EDITOR_GEOMETRY_EDMESH_H
#define CRYINCLUDE_EDITOR_GEOMETRY_EDMESH_H
#pragma once
#include "EdGeometry.h"
#include "Objects/SubObjSelection.h"
#include "TriMesh.h"
// Flags that can be set on CEdMesh.
enum CEdMeshFlags
{
};
//////////////////////////////////////////////////////////////////////////
// Description:
// CEdMesh is a Geometry kind representing simple mesh.
// Holds IStatObj interface from the 3D Engine.
//////////////////////////////////////////////////////////////////////////
class CRYEDIT_API CEdMesh
: public CEdGeometry
{
public:
//////////////////////////////////////////////////////////////////////////
// CEdGeometry implementation.
//////////////////////////////////////////////////////////////////////////
virtual EEdGeometryType GetType() const { return GEOM_TYPE_MESH; };
virtual void Serialize(CObjectArchive& ar);
virtual void GetBounds(AABB& box);
virtual CEdGeometry* Clone();
virtual IIndexedMesh* GetIndexedMesh(size_t idx = 0);
virtual void GetTM(Matrix34* pTM, size_t idx = 0);
virtual void SetModified(bool bModified = true);
virtual bool IsModified() const { return m_bModified; };
virtual bool StartSubObjSelection(const Matrix34& nodeWorldTM, int elemType, int nFlags);
virtual void EndSubObjSelection();
virtual void Display(DisplayContext& dc);
virtual bool HitTest(HitContext& hit);
bool GetSelectionReferenceFrame(Matrix34& refFrame);
virtual void ModifySelection(SSubObjSelectionModifyContext& modCtx, bool isUndo = true);
virtual void AcceptModifySelection();
//////////////////////////////////////////////////////////////////////////
~CEdMesh();
// Return filename of mesh.
const QString& GetFilename() const { return m_filename; };
void SetFilename(const QString& filename);
//! Reload geometry of mesh.
void ReloadGeometry();
void AddUser();
void RemoveUser();
int GetUserCount() const { return m_nUserCount; };
//////////////////////////////////////////////////////////////////////////
void SetFlags(int nFlags) { m_nFlags = nFlags; };
int GetFlags() { return m_nFlags; }
//////////////////////////////////////////////////////////////////////////
//! Access stored IStatObj.
IStatObj* GetIStatObj() const { return m_pStatObj; }
//! Returns true if filename and geomname refer to the same object as this one.
bool IsSameObject(const char* filename);
//! RenderMesh.
void Render(SRendParams& rp, const SRenderingPassInfo& passInfo);
//! Make new CEdMesh, if same IStatObj loaded, and CEdMesh for this IStatObj is allocated.
//! This instance of CEdMesh will be returned.
static CEdMesh* LoadMesh(const char* filename);
// Creates a new mesh not from a file.
// Create a new StatObj and IndexedMesh.
static CEdMesh* CreateMesh(const char* name);
//! Reload all geometries.
static void ReloadAllGeometries();
static void ReleaseAll();
//! Check if default object was loaded.
bool IsDefaultObject();
//////////////////////////////////////////////////////////////////////////
// Copy EdMesh data to the specified mesh.
void CopyToMesh(CTriMesh& toMesh, int nCopyFlags);
// Copy EdMesh data from the specified mesh.
void CopyFromMesh(CTriMesh& fromMesh, int nCopyFlags, bool bUndo);
// Retrieve mesh class.
CTriMesh* GetMesh();
//////////////////////////////////////////////////////////////////////////
void InvalidateMesh();
void SetWorldTM(const Matrix34& worldTM);
// Save mesh into the file.
// Optionally can provide pointer to the pak file where to save files into.
void SaveToCGF(const char* sFilename, CPakFile* pPakFile = NULL, _smart_ptr<IMaterial> pMaterial = NULL);
// Draw debug representation of this mesh.
void DebugDraw(const SGeometryDebugDrawInfo& info, float fExtrdueScale = 0.01f);
private:
//////////////////////////////////////////////////////////////////////////
CEdMesh(IStatObj* pGeom);
CEdMesh();
void UpdateSubObjCache();
void UpdateIndexedMeshFromCache(bool bFast);
void OnSelectionChange();
//////////////////////////////////////////////////////////////////////////
struct SSubObjHitTestEnvironment
{
Vec3 vWSCameraPos;
Vec3 vWSCameraVector;
Vec3 vOSCameraVector;
bool bHitTestNearest;
bool bHitTestSelected;
bool bSelectOnHit;
bool bAdd;
bool bRemove;
bool bSelectValue;
bool bHighlightOnly;
bool bIgnoreBackfacing;
};
struct SSubObjHitTestResult
{
CTriMesh::EStream stream; // To What stream of the TriMesh this result apply.
MeshElementsArray elems; // List of hit elements.
float minDistance; // Minimal distance to the hit.
SSubObjHitTestResult() { minDistance = FLT_MAX; }
};
bool HitTestVertex(HitContext& hit, SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result);
bool HitTestEdge(HitContext& hit, SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result);
bool HitTestFace(HitContext& hit, SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result);
// Return`s true if selection changed.
bool SelectSubObjElements(SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result);
bool IsHitTestResultSelected(SSubObjHitTestResult& result);
//////////////////////////////////////////////////////////////////////////
//! CGF filename.
QString m_filename;
IStatObj* m_pStatObj;
int m_nUserCount;
int m_nFlags;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
typedef std::map<QString, CEdMesh*, stl::less_stricmp<QString> > MeshMap;
static MeshMap m_meshMap;
// This cache is created when sub object selection is needed.
struct SubObjCache
{
// Cache of data in geometry.
// World space mesh.
CTriMesh* pTriMesh;
Matrix34 worldTM;
Matrix34 invWorldTM;
CBitArray m_tempBitArray;
bool bNoDisplay;
SubObjCache()
: pTriMesh(0)
, bNoDisplay(false) {};
};
SubObjCache* m_pSubObjCache;
bool m_bModified;
std::vector<IIndexedMesh*> m_tempIndexedMeshes;
std::vector<Matrix34> m_tempMatrices;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
#endif // CRYINCLUDE_EDITOR_GEOMETRY_EDMESH_H
-21
View File
@@ -136,31 +136,10 @@ Matrix34 CGrid::GetMatrix() const
Ang3 angles = Ang3(rotationAngles.x * gf_PI / 180.0, rotationAngles.y * gf_PI / 180.0, rotationAngles.z * gf_PI / 180.0);
tm = Matrix33::CreateRotationXYZ(angles);
if (gSettings.snap.bGridGetFromSelected)
{
CSelectionGroup* sel = GetIEditor()->GetSelection();
if (sel->GetCount() > 0)
{
CBaseObject* obj = sel->GetObject(0);
tm = obj->GetWorldTM();
tm.OrthonormalizeFast();
tm.SetTranslation(Vec3(0, 0, 0));
}
}
}
else if (GetIEditor()->GetReferenceCoordSys() == COORDS_LOCAL)
{
tm.SetIdentity();
CSelectionGroup* sel = GetIEditor()->GetSelection();
if (sel->GetCount() > 0)
{
CBaseObject* obj = sel->GetObject(0);
tm = obj->GetWorldTM();
tm.OrthonormalizeFast();
tm.SetTranslation(Vec3(0, 0, 0));
}
}
else
{
@@ -39,8 +39,6 @@ CGridSettingsDialog::CGridSettingsDialog(QWidget* pParent /*=NULL*/)
connect(ui->m_userDefined, &QCheckBox::clicked, this, &CGridSettingsDialog::OnBnUserDefined);
connect(ui->m_getFromObject, &QCheckBox::clicked, this, &CGridSettingsDialog::OnBnGetFromObject);
connect(ui->m_getAnglesFromObject, &QPushButton::clicked, this, &CGridSettingsDialog::OnBnGetAngles);
connect(ui->m_getTranslationFromObject, &QPushButton::clicked, this, &CGridSettingsDialog::OnBnGetTranslation);
auto doubleSpinBoxValueChanged = static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged);
@@ -115,39 +113,6 @@ void CGridSettingsDialog::OnBnGetFromObject()
EnableGridPropertyControls(ui->m_userDefined->isChecked(), ui->m_getFromObject->isChecked());
}
void CGridSettingsDialog::OnBnGetAngles()
{
CSelectionGroup* sel = GetIEditor()->GetSelection();
if (sel->GetCount() > 0)
{
CBaseObject* obj = sel->GetObject(0);
Matrix34 tm = obj->GetWorldTM();
AffineParts ap;
ap.SpectralDecompose(tm);
Vec3 rotation = Vec3(RAD2DEG(Ang3::GetAnglesXYZ(Matrix33(ap.rot))));
ui->m_angleX->setValue(rotation.x);
ui->m_angleY->setValue(rotation.y);
ui->m_angleZ->setValue(rotation.z);
}
}
void CGridSettingsDialog::OnBnGetTranslation()
{
CSelectionGroup* sel = GetIEditor()->GetSelection();
if (sel->GetCount() > 0)
{
CBaseObject* obj = sel->GetObject(0);
Matrix34 tm = obj->GetWorldTM();
Vec3 translation = tm.GetTranslation();
ui->m_translationX->setValue(translation.x);
ui->m_translationY->setValue(translation.y);
ui->m_translationZ->setValue(translation.z);
}
}
void CGridSettingsDialog::EnableGridPropertyControls(const bool isUserDefined, const bool isGetFromObject)
{
ui->m_getFromObject->setEnabled(isUserDefined == true);
-2
View File
@@ -51,8 +51,6 @@ private slots:
void accept() override;
void OnBnUserDefined();
void OnBnGetFromObject();
void OnBnGetAngles();
void OnBnGetTranslation();
void OnValueUpdate();
private:
-21
View File
@@ -46,11 +46,8 @@ class CGameEngine;
struct IIconManager;
class CToolBoxManager;
class CClassFactory;
class CMaterialManager;
class CMusicManager;
class CMaterail;
struct IEditorParticleManager;
class CLensFlareManager;
class CEAXPresetManager;
class CErrorReport;
class CBaseLibraryItem;
@@ -88,7 +85,6 @@ namespace WinWidget
}
struct ISystem;
struct I3DEngine;
struct IRenderer;
struct AABB;
struct IEventLoopHook;
@@ -140,7 +136,6 @@ enum EEditorNotifyEvent
eNotify_OnEndLayerExport, // Sent after a layer have been exported.
eNotify_OnCloseScene, // Send when the document is about to close.
eNotify_OnSceneClosed, // Send when the document is closed.
eNotify_OnMissionChange, // Send when the current mission changes.
eNotify_OnBeginLoad, // Sent when the document is start to load.
eNotify_OnEndLoad, // Sent when the document loading is finished
@@ -183,8 +178,6 @@ enum EEditorNotifyEvent
eNotify_OnDisplayRenderUpdate, // Sent when editor finish terrain texture generation.
eNotify_OnTimeOfDayChange, // Time of day parameters where modified.
eNotify_OnDataBaseUpdate, // DataBase Library was modified.
eNotify_OnLayerImportBegin, //layer import was started
@@ -244,8 +237,6 @@ struct IDocListener
virtual void OnLoadDocument() = 0;
//! Called when document is being closed.
virtual void OnCloseDocument() = 0;
//! Called when mission changes.
virtual void OnMissionChange() = 0;
};
//! Derive from this class if you want to register for getting global editor notifications.
@@ -434,7 +425,6 @@ struct IEditor
virtual void DeleteThis() = 0;
//! Access to Editor ISystem interface.
virtual ISystem* GetSystem() = 0;
virtual I3DEngine* Get3DEngine() = 0;
virtual IRenderer* GetRenderer() = 0;
//! Access to class factory.
virtual IEditorClassFactory* GetClassFactory() = 0;
@@ -545,8 +535,6 @@ struct IEditor
virtual CSettingsManager* GetSettingsManager() = 0;
//! Get DB manager that own items of specified type.
virtual IDataBaseManager* GetDBItemManager(EDataBaseItemType itemType) = 0;
//! Get Manager of Materials.
virtual CMaterialManager* GetMaterialManager() = 0;
virtual IBaseLibraryManager* GetMaterialManagerLibrary() = 0; // Vladimir@conffx
virtual IEditorMaterialManager* GetIEditorMaterialManager() = 0; // Vladimir@Conffx
//! Returns IconManager.
@@ -555,8 +543,6 @@ struct IEditor
virtual IEditorPanelUtils* GetEditorPanelUtils() = 0;
//! Get Music Manager.
virtual CMusicManager* GetMusicManager() = 0;
//! Get Lens Flare Manager.
virtual CLensFlareManager* GetLensFlareManager() = 0;
virtual float GetTerrainElevation(float x, float y) = 0;
virtual Editor::EditorQtApplication* GetEditorQtApplication() = 0;
virtual const QColor& GetColorByName(const QString& name) = 0;
@@ -632,9 +618,6 @@ struct IEditor
virtual RefCoordSys GetReferenceCoordSys() = 0;
virtual XmlNodeRef FindTemplate(const QString& templateName) = 0;
virtual void AddTemplate(const QString& templateName, XmlNodeRef& tmpl) = 0;
//! Open material library and select specified item.
//! If parameter is NULL current selection in material library does not change.
virtual void OpenMaterialLibrary(IDataBaseItem* pItem = NULL) = 0;
virtual const QtViewPane* OpenView(QString sViewClassName, bool reuseOpen = true) = 0;
virtual QWidget* FindView(QString viewClassName) = 0;
@@ -749,8 +732,6 @@ struct IEditor
typedef AZStd::function<void(QMenu*, const CBaseObject*)> TContextMenuExtensionFunc;
virtual void RegisterObjectContextMenuExtension(TContextMenuExtensionFunc func) = 0;
virtual void SetCurrentMissionTime(float time) = 0;
virtual SSystemGlobalEnvironment* GetEnv() = 0;
virtual IImageUtil* GetImageUtil() = 0; // Vladimir@conffx
virtual SEditorSettings* GetEditorSettings() = 0;
@@ -762,8 +743,6 @@ struct IEditor
// reloads the plugins
virtual void LoadPlugins() = 0;
virtual bool IsNewViewportInteractionModelEnabled() const = 0;
};
//! Callback used by editor when initializing for info in UI dialogs
+3 -84
View File
@@ -53,14 +53,12 @@ AZ_POP_DISABLE_WARNING
#include "KeyboardCustomizationSettings.h"
#include "Export/ExportManager.h"
#include "LevelIndependentFileMan.h"
#include "Material/MaterialManager.h"
#include "TrackView/TrackViewSequenceManager.h"
#include "AnimationContext.h"
#include "GameEngine.h"
#include "ToolBox.h"
#include "MainWindow.h"
#include "Alembic/AlembicCompiler.h"
#include "LensFlareEditor/LensFlareManager.h"
#include "UIEnumsDatabase.h"
#include "Util/Ruler.h"
#include "RenderHelpers/AxisHelper.h"
@@ -73,7 +71,6 @@ AZ_POP_DISABLE_WARNING
#include "BackgroundTaskManager.h"
#include "BackgroundScheduleManager.h"
#include "EditorFileMonitor.h"
#include "Mission.h"
#include "MainStatusBar.h"
#include "SettingsBlock.h"
@@ -118,29 +115,6 @@ static CCryEditDoc * theDocument;
#undef GetCommandLine
namespace
{
bool SelectionContainsComponentEntities()
{
bool result = false;
CSelectionGroup* pSelection = GetIEditor()->GetObjectManager()->GetSelection();
if (pSelection)
{
CBaseObject* selectedObj = nullptr;
for (int selectionCounter = 0; selectionCounter < pSelection->GetCount(); ++selectionCounter)
{
selectedObj = pSelection->GetObject(selectionCounter);
if (selectedObj->GetType() == OBJTYPE_AZENTITY)
{
result = true;
break;
}
}
}
return result;
}
}
const char* CEditorImpl::m_crashLogFileName = "SessionStatus/editor_statuses.json";
CEditorImpl::CEditorImpl()
@@ -168,9 +142,7 @@ CEditorImpl::CEditorImpl()
, m_pAnimationContext(nullptr)
, m_pSequenceManager(nullptr)
, m_pToolBoxManager(nullptr)
, m_pMaterialManager(nullptr)
, m_pMusicManager(nullptr)
, m_pLensFlareManager(nullptr)
, m_pErrorReport(nullptr)
, m_pLasLoadedLevelErrorReport(nullptr)
, m_pErrorsDlg(nullptr)
@@ -224,13 +196,11 @@ CEditorImpl::CEditorImpl()
m_pIconManager = new CIconManager;
m_pUndoManager = new CUndoManager;
m_pToolBoxManager = new CToolBoxManager;
m_pMaterialManager = new CMaterialManager(regCtx);
m_pAlembicCompiler = new CAlembicCompiler();
m_pSequenceManager = new CTrackViewSequenceManager;
m_pAnimationContext = new CAnimationContext;
m_pImageUtil = new CImageUtil_impl();
m_pLensFlareManager = new CLensFlareManager;
m_pResourceSelectorHost.reset(CreateResourceSelectorHost());
m_pRuler = new CRuler;
m_selectedRegion.min = Vec3(0, 0, 0);
@@ -345,7 +315,6 @@ CEditorImpl::~CEditorImpl()
m_bExiting = true; // Can't save level after this point (while Crash)
SAFE_RELEASE(m_pSourceControl);
SAFE_DELETE(m_pMaterialManager)
SAFE_DELETE(m_pAlembicCompiler)
SAFE_DELETE(m_pIconManager)
SAFE_DELETE(m_pViewManager)
@@ -415,7 +384,6 @@ void CEditorImpl::SetGameEngine(CGameEngine* ge)
m_pObjectManager->LoadClassTemplates("Editor");
m_pObjectManager->RegisterCVars();
m_pMaterialManager->Set3DEngine();
m_pAnimationContext->Init();
}
@@ -472,15 +440,6 @@ ISystem* CEditorImpl::GetSystem()
return m_pSystem;
}
I3DEngine* CEditorImpl::Get3DEngine()
{
if (gEnv)
{
return gEnv->p3DEngine;
}
return nullptr;
}
IRenderer* CEditorImpl::GetRenderer()
{
if (gEnv)
@@ -1003,39 +962,11 @@ void CEditorImpl::CloseView(const GUID& classId)
}
}
IDataBaseManager* CEditorImpl::GetDBItemManager(EDataBaseItemType itemType)
IDataBaseManager* CEditorImpl::GetDBItemManager([[maybe_unused]] EDataBaseItemType itemType)
{
switch (itemType)
{
case EDB_TYPE_MATERIAL:
return m_pMaterialManager;
}
return 0;
}
void CEditorImpl::OpenMaterialLibrary(IDataBaseItem* item)
{
EDataBaseItemType type = item ? item->GetType() : EDB_TYPE_MATERIAL;
AZ_Assert(type == EDB_TYPE_MATERIAL, "Call to OpenMaterialLibrary with non-material data base item");
if (type == EDB_TYPE_MATERIAL)
{
QtViewPaneManager::instance()->OpenPane(LyViewPane::MaterialEditor);
// This is a workaround for a timing issue where the material editor
// gets in a bad state while it is being polished for the first time
// while loading a material at the same time, so delay the setting
// of the material until the next event queue check
QTimer::singleShot(0, [this, item] {
IDataBaseManager* pManager = GetDBItemManager(EDB_TYPE_MATERIAL);
if (pManager)
{
pManager->SetSelectedItem(item);
}
});
}
}
bool CEditorImpl::SelectColor(QColor& color, QWidget* parent)
{
const AZ::Color c = AzQtComponents::fromQColor(color);
@@ -1775,13 +1706,6 @@ void CEditorImpl::RegisterObjectContextMenuExtension(TContextMenuExtensionFunc f
m_objectContextMenuExtensions.push_back(func);
}
void CEditorImpl::SetCurrentMissionTime(float time)
{
if (CMission* pMission = GetIEditor()->GetDocument()->GetCurrentMission())
{
pMission->SetTime(time);
}
}
// Vladimir@Conffx
SSystemGlobalEnvironment* CEditorImpl::GetEnv()
{
@@ -1798,13 +1722,13 @@ SEditorSettings* CEditorImpl::GetEditorSettings()
// Vladimir@Conffx
IBaseLibraryManager* CEditorImpl::GetMaterialManagerLibrary()
{
return m_pMaterialManager;
return nullptr;
}
// Vladimir@Conffx
IEditorMaterialManager* CEditorImpl::GetIEditorMaterialManager()
{
return m_pMaterialManager;
return nullptr;
}
IImageUtil* CEditorImpl::GetImageUtil()
@@ -1822,11 +1746,6 @@ void CEditorImpl::DestroyQMimeData(QMimeData* data) const
delete data;
}
bool CEditorImpl::IsNewViewportInteractionModelEnabled() const
{
return m_isNewViewportInteractionModelEnabled;
}
IEditorPanelUtils* CEditorImpl::GetEditorPanelUtils()
{
return m_panelEditorUtils;
-12
View File
@@ -42,7 +42,6 @@ class CUndoManager;
class CGameEngine;
class CExportManager;
class CErrorsDlg;
class CLensFlareManager;
class CIconManager;
class CBackgroundTaskManager;
class CTrackViewSequenceManager;
@@ -117,7 +116,6 @@ public:
bool IsInitialized() const{ return m_bInitialized; }
bool SaveDocument();
ISystem* GetSystem();
I3DEngine* Get3DEngine();
IRenderer* GetRenderer();
void WriteToConsole(const char* string) { CLogFile::WriteLine(string); };
void WriteToConsole(const QString& string) { CLogFile::WriteLine(string); };
@@ -181,9 +179,7 @@ public:
bool IsSelectionLocked();
IDataBaseManager* GetDBItemManager(EDataBaseItemType itemType);
CMaterialManager* GetMaterialManager() { return m_pMaterialManager; }
CMusicManager* GetMusicManager() { return m_pMusicManager; };
CLensFlareManager* GetLensFlareManager() { return m_pLensFlareManager; };
IBackgroundTaskManager* GetBackgroundTaskManager() override;
IBackgroundScheduleManager* GetBackgroundScheduleManager() override;
@@ -237,7 +233,6 @@ public:
RefCoordSys GetReferenceCoordSys();
XmlNodeRef FindTemplate(const QString& templateName);
void AddTemplate(const QString& templateName, XmlNodeRef& tmpl);
void OpenMaterialLibrary(IDataBaseItem* pItem = NULL);
const QtViewPane* OpenView(QString sViewClassName, bool reuseOpened = true) override;
@@ -325,7 +320,6 @@ public:
void OnObjectContextMenuOpened(QMenu* pMenu, const CBaseObject* pObject);
virtual void RegisterObjectContextMenuExtension(TContextMenuExtensionFunc func) override;
virtual void SetCurrentMissionTime(float time);
virtual SSystemGlobalEnvironment* GetEnv() override;
virtual IBaseLibraryManager* GetMaterialManagerLibrary() override; // Vladimir@Conffx
virtual IEditorMaterialManager* GetIEditorMaterialManager() override; // Vladimir@Conffx
@@ -340,8 +334,6 @@ public:
QMimeData* CreateQMimeData() const override;
void DestroyQMimeData(QMimeData* data) const override;
bool IsNewViewportInteractionModelEnabled() const override;
protected:
AZStd::string LoadProjectIdFromProjectData();
@@ -384,10 +376,8 @@ protected:
CAnimationContext* m_pAnimationContext;
CTrackViewSequenceManager* m_pSequenceManager;
CToolBoxManager* m_pToolBoxManager;
CMaterialManager* m_pMaterialManager;
CAlembicCompiler* m_pAlembicCompiler;
CMusicManager* m_pMusicManager;
CLensFlareManager* m_pLensFlareManager;
CErrorReport* m_pErrorReport;
//! Contains the error reports for the last loaded level.
CErrorReport* m_pLasLoadedLevelErrorReport;
@@ -443,7 +433,5 @@ protected:
CryMutex m_pluginMutex; // protect any pointers that come from plugins, such as the source control cached pointer.
static const char* m_crashLogFileName;
bool m_isNewViewportInteractionModelEnabled = true;
};
+15 -110
View File
@@ -15,7 +15,6 @@
#include "IconManager.h"
#include <AzFramework/API/AtomActiveInterface.h>
#include <AzCore/Interface/Interface.h>
// AzToolsFramework
@@ -26,28 +25,29 @@
#include "Util/Image.h"
#include "Util/ImageUtil.h"
#include <IStatObj.h>
#define HELPER_MATERIAL "Editor/Objects/Helper"
#define HELPER_MATERIAL "Objects/Helper"
namespace
{
// Object names in this array must correspond to EObject enumeration.
const char* g_ObjectNames[eStatObject_COUNT] =
{
"Editor/Objects/Arrow.cgf",
"Editor/Objects/Axis.cgf",
"Editor/Objects/Sphere.cgf",
"Editor/Objects/Anchor.cgf",
"Editor/Objects/entrypoint.cgf",
"Editor/Objects/hidepoint.cgf",
"Editor/Objects/hidepoint_sec.cgf",
"Editor/Objects/reinforcement_point.cgf",
"Objects/Arrow.cgf",
"Objects/Axis.cgf",
"Objects/Sphere.cgf",
"Objects/Anchor.cgf",
"Objects/entrypoint.cgf",
"Objects/hidepoint.cgf",
"Objects/hidepoint_sec.cgf",
"Objects/reinforcement_point.cgf",
};
const char* g_IconNames[eIcon_COUNT] =
{
"Editor/Icons/ScaleWarning.png",
"Editor/Icons/RotationWarning.png",
"Icons/ScaleWarning.png",
"Icons/RotationWarning.png",
};
};
@@ -77,12 +77,11 @@ void CIconManager::Done()
//////////////////////////////////////////////////////////////////////////
void CIconManager::Reset()
{
I3DEngine* pEngine = GetIEditor()->Get3DEngine();
// Do not unload objects. but clears them.
int i;
for (i = 0; i < sizeof(m_objects) / sizeof(m_objects[0]); i++)
{
if (m_objects[i] && pEngine)
if (m_objects[i])
{
m_objects[i]->Release();
}
@@ -115,71 +114,6 @@ int CIconManager::GetIconTexture(const char* iconName)
return 0;
}
if (AZ::Interface<AzFramework::AtomActiveInterface>::Get())
{
ITexture* texture = GetIEditor()->GetRenderer() ? GetIEditor()->GetRenderer()->EF_LoadTexture(iconName) : nullptr;
if (texture)
{
id = texture->GetTextureID();
m_textures[iconName] = id;
}
}
else
{
QString ext = Path::GetExt(iconName);
QString actualName = iconName;
char iconPath[AZ_MAX_PATH_LEN] = { 0 };
gEnv->pFileIO->ResolvePath(actualName.toUtf8().data(), iconPath, AZ_MAX_PATH_LEN);
// if we can't find it at the resolved path, try the devroot if necessary:
if (!gEnv->pFileIO->Exists(iconPath))
{
if (iconName[0] != '@') // it has no specified alias
{
if (QString::compare(ext, "dds", Qt::CaseInsensitive) != 0) // if its a DDS, it comes out of processed files in @assets@, and assets is assumed by default (legacy renderer)
{
// check for a source file
AZStd::string iconFullPath;
bool pathFound = false;
using AssetSysReqBus = AzToolsFramework::AssetSystemRequestBus;
AssetSysReqBus::BroadcastResult(pathFound, &AssetSysReqBus::Events::GetFullSourcePathFromRelativeProductPath, iconName, iconFullPath);
if (pathFound)
{
azstrncpy(iconPath, AZ_MAX_PATH_LEN, iconFullPath.c_str(), iconFullPath.length() + 1);
}
}
}
}
CImageEx image;
// Load icon.
if (CImageUtil::LoadImage(iconPath, image))
{
IRenderer* pRenderer(GetIEditor()->GetRenderer());
if (pRenderer->GetRenderType() != eRT_DX11)
{
image.SwapRedAndBlue();
}
if (QString::compare(ext, "bmp", Qt::CaseInsensitive) == 0 || QString::compare(ext, "jpg", Qt::CaseInsensitive) == 0)
{
int sz = image.GetWidth() * image.GetHeight();
uint8* buf = (uint8*)image.GetData();
for (int i = 0; i < sz; i++)
{
uint32 alpha = max(max(buf[i * 4], buf[i * 4 + 1]), buf[i * 4 + 2]);
alpha *= 2;
buf[i * 4 + 3] = (alpha > 255) ? 255 : alpha;
}
}
id = pRenderer->DownLoadToVideoMemory((unsigned char*)image.GetData(), image.GetWidth(), image.GetHeight(), eTF_R8G8B8A8, eTF_R8G8B8A8, 0, 0, 0);
m_textures[iconName] = id;
}
}
return id;
}
@@ -196,39 +130,10 @@ int CIconManager::GetIconTexture(EIcon icon)
return m_icons[icon];
}
//////////////////////////////////////////////////////////////////////////
_smart_ptr<IMaterial> CIconManager::GetHelperMaterial()
IStatObj* CIconManager::GetObject(EStatObject)
{
if (!m_pHelperMtl)
{
m_pHelperMtl = GetIEditor()->Get3DEngine()->GetMaterialManager()->LoadMaterial(HELPER_MATERIAL);
}
return m_pHelperMtl;
};
//////////////////////////////////////////////////////////////////////////
IStatObj* CIconManager::GetObject(EStatObject object)
{
assert(object >= 0 && object < eStatObject_COUNT);
if (m_objects[object])
{
return m_objects[object];
}
// Try to load this object.
m_objects[object] = GetIEditor()->Get3DEngine()->LoadStatObjUnsafeManualRef(g_ObjectNames[object], NULL, NULL, false);
if (!m_objects[object])
{
CLogFile::FormatLine("Error: Load Failed: %s", g_ObjectNames[object]);
}
m_objects[object]->AddRef();
if (GetHelperMaterial())
{
m_objects[object]->SetMaterial(GetHelperMaterial());
}
return m_objects[object];
return nullptr;
}
//////////////////////////////////////////////////////////////////////////
-4
View File
@@ -51,7 +51,6 @@ public:
virtual IStatObj* GetObject(EStatObject object);
virtual int GetIconTexture(const char* iconName);
virtual _smart_ptr<IMaterial> GetHelperMaterial();
//////////////////////////////////////////////////////////////////////////
// Icon bitmaps.
@@ -64,14 +63,11 @@ public:
virtual void OnNewDocument() { Reset(); };
virtual void OnLoadDocument() { Reset(); };
virtual void OnCloseDocument() { Reset(); };
virtual void OnMissionChange() { Reset(); };
//////////////////////////////////////////////////////////////////////////
private:
StdMap<QString, int> m_textures;
_smart_ptr<IMaterial> m_pHelperMtl;
IStatObj* m_objects[eStatObject_COUNT];
int m_icons[eIcon_COUNT];
@@ -21,7 +21,6 @@
#include <IValidator.h>
// forward declarations.
class CMaterial;
class CParticleItem;
class CBaseObject;
class CBaseLibraryItem;
@@ -61,7 +61,6 @@ struct IIconManager
virtual IStatObj* GetObject(EStatObject object) = 0;
virtual int GetIconTexture(EIcon icon) = 0;
virtual int GetIconTexture(const char* iconName) = 0;
virtual _smart_ptr<IMaterial> GetHelperMaterial() = 0;
virtual QImage* GetIconBitmap(const char* filename, bool& haveAlpha, uint32 effects = 0) = 0;
// Register an Icon for the specific command
virtual void RegisterCommandIcon([[maybe_unused]] const char* filename, [[maybe_unused]] int nCommandId) {}
@@ -24,7 +24,6 @@ class CUsedResources;
class CSelectionGroup;
class CObjectClassDesc;
class CObjectArchive;
class CObjectPhysicsManager;
class CViewport;
struct HitContext;
enum class ImageRotationDegrees;
@@ -247,10 +246,6 @@ public:
virtual IGizmoManager* GetGizmoManager() = 0;
//////////////////////////////////////////////////////////////////////////
//! Get acess to object physics manager
virtual CObjectPhysicsManager* GetPhysicsManager() = 0;
//////////////////////////////////////////////////////////////////////////
//! Invalidate visibily settings of objects.
virtual void InvalidateVisibleList() = 0;
@@ -26,7 +26,7 @@
// ...
// return previousValue;
// }
// REGISTER_RESOURCE_SELECTOR("Sound", SoundFileSelector, "Editor/icons/sound_16x16.png")
// REGISTER_RESOURCE_SELECTOR("Sound", SoundFileSelector, "Icons/sound_16x16.png")
//
// To expose it to serialization:
//
-1
View File
@@ -24,7 +24,6 @@
#include <QTextDocumentFragment>
#include <AzCore/Interface/Interface.h>
#include <AzFramework/API/AtomActiveInterface.h>
#include <AzQtComponents/Components/Style.h> // for AzQtComponents::Style
// Editor
@@ -28,8 +28,8 @@
namespace SandboxEditor
{
LegacyViewportCameraControllerInstance::LegacyViewportCameraControllerInstance(AzFramework::ViewportId viewportId)
: AzFramework::MultiViewportControllerInstanceInterface(viewportId)
LegacyViewportCameraControllerInstance::LegacyViewportCameraControllerInstance(AzFramework::ViewportId viewportId, LegacyViewportCameraController* controller)
: AzFramework::MultiViewportControllerInstanceInterface<LegacyViewportCameraController>(viewportId, controller)
{
}
@@ -28,11 +28,14 @@ namespace AzFramework
namespace SandboxEditor
{
class LegacyViewportCameraControllerInstance;
using LegacyViewportCameraController = AzFramework::MultiViewportController<LegacyViewportCameraControllerInstance>;
class LegacyViewportCameraControllerInstance final
: public AzFramework::MultiViewportControllerInstanceInterface
: public AzFramework::MultiViewportControllerInstanceInterface<LegacyViewportCameraController>
{
public:
explicit LegacyViewportCameraControllerInstance(AzFramework::ViewportId viewport);
LegacyViewportCameraControllerInstance(AzFramework::ViewportId viewport, LegacyViewportCameraController* controller);
bool HandleInputChannelEvent(const AzFramework::ViewportControllerInputEvent& event) override;
void ResetInputChannels() override;
@@ -69,5 +72,4 @@ namespace SandboxEditor
bool m_capturingCursor = false;
};
using LegacyViewportCameraController = AzFramework::MultiViewportController<LegacyViewportCameraControllerInstance>;
} //namespace SandboxEditor
@@ -1,33 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_ILENSFLARELISTENER_H
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_ILENSFLARELISTENER_H
#pragma once
class CLensFlareItem;
class CLensFlareElement;
class ILensFlareChangeItemListener
{
public:
virtual void OnLensFlareChangeItem(CLensFlareItem* pLensFlareItem) = 0;
virtual void OnLensFlareDeleteItem(CLensFlareItem* pLensFlareItem) = 0;
};
class ILensFlareChangeElementListener
{
public:
virtual void OnLensFlareChangeElement(CLensFlareElement* pLensFlareElement) = 0;
};
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_ILENSFLARELISTENER_H
@@ -1,326 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "EditorDefs.h"
#include "LensFlareAtomicList.h"
// Qt
#include <QScrollBar>
#include <QMimeData>
// Editor
#include "LensFlareUtil.h"
#include "Util/Image.h"
#include "Util/ImageUtil.h"
struct QLensFlareAtomicListModel::Item
{
QString text;
QSize size;
QPixmap pixmap;
EFlareType flareType;
};
CLensFlareAtomicList::CLensFlareAtomicList(QWidget* parent)
: CImageListCtrl(parent)
, m_model(new QLensFlareAtomicListModel(this))
{
setDragEnabled(true);
setDragDropMode(DragOnly);
setModel(m_model.data());
}
CLensFlareAtomicList::~CLensFlareAtomicList()
{
}
QModelIndex QLensFlareAtomicListModel::InsertItem(const FlareInfo& flareInfo)
{
Item* pPreviewItem = new Item;
if (flareInfo.imagename)
{
CImageEx* pImage = new CImageEx();
if (CImageUtil::LoadImage(flareInfo.imagename, *pImage))
{
pImage->SwapRedAndBlue();
pPreviewItem->size = QSize(pImage->GetWidth(), pImage->GetHeight());
QImage img(reinterpret_cast<const uchar*>(pImage->GetData()), pImage->GetWidth(), pImage->GetHeight(), QImage::Format_RGB32);
pPreviewItem->pixmap = QPixmap::fromImage(img.copy());
}
delete pImage;
}
if (pPreviewItem->pixmap.isNull())
{
pPreviewItem->pixmap = QPixmap(":/water.png");
pPreviewItem->size = QSize(64, 64);
}
pPreviewItem->text = flareInfo.name;
pPreviewItem->flareType = flareInfo.type;
const int row = m_items.count();
beginInsertRows(QModelIndex(), row, row);
m_items.append(pPreviewItem);
endInsertRows();
return index(row, 0);
}
void QLensFlareAtomicListModel::Populate()
{
Clear();
const FlareInfoArray::Props array = FlareInfoArray::Get();
for (size_t i = 0; i < array.size; ++i)
{
const FlareInfo& flareInfo(array.p[i]);
if (LensFlareUtil::IsElement(flareInfo.type))
{
InsertItem(flareInfo);
}
}
}
void CLensFlareAtomicList::FillAtomicItems()
{
if (m_model)
{
m_model->Populate();
}
}
void CLensFlareAtomicList::updateGeometries()
{
ClearItemGeometries();
if (!model())
{
return;
}
const int rowCount = model()->rowCount();
const int nPageHorz = viewport()->width();
const int nPageVert = viewport()->height();
if (nPageHorz == 0 || nPageVert == 0 || rowCount <= 0)
{
return;
}
const QSize& borderSize = BorderSize();
int x = borderSize.width();
int y = borderSize.height();
QSize itemSize = ItemSize();
const int nTextHeight = fontMetrics().height();
const int xMax = nPageHorz - borderSize.width();
int itemHeightMax = 0;
for (int row = 0; row < rowCount; ++row)
{
QModelIndex index = m_model->index(row, 0);
itemSize = index.data(Qt::SizeHintRole).toSize();
if ((x + itemSize.width()) > xMax)
{
y += itemHeightMax + borderSize.height() + nTextHeight;
x = borderSize.width();
itemHeightMax = 0;
}
if (itemSize.height() > itemHeightMax)
{
itemHeightMax = itemSize.height();
}
SetItemGeometry(index, QRect(QPoint(x, y), itemSize));
x += itemSize.width() + borderSize.width();
}
verticalScrollBar()->setPageStep(viewport()->height());
verticalScrollBar()->setRange(0, (y + itemHeightMax - viewport()->height()));
}
QLensFlareAtomicListModel::QLensFlareAtomicListModel(QObject* parent)
: QAbstractListModel(parent)
{
}
QLensFlareAtomicListModel::~QLensFlareAtomicListModel()
{
}
void QLensFlareAtomicListModel::Clear()
{
qDeleteAll(m_items);
m_items.clear();
}
int QLensFlareAtomicListModel::rowCount(const QModelIndex& parent) const
{
if (parent.isValid())
{
return 0;
}
return m_items.count();
}
QVariant QLensFlareAtomicListModel::data(const QModelIndex& index, int role) const
{
Item* item;
if (!index.isValid())
{
return QVariant();
}
else
{
item = ItemFromIndex(index);
if (!item)
{
return QVariant();
}
}
switch (role)
{
case Qt::DisplayRole:
case Qt::EditRole:
return item->text;
case Qt::SizeHintRole:
return item->size;
case Qt::DecorationRole:
return item->pixmap;
case Qt::UserRole:
return item->flareType;
}
return QVariant();
}
bool QLensFlareAtomicListModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
Item* item;
if (index.isValid())
{
return false;
}
else
{
item = ItemFromIndex(index);
if (!item)
{
return false;
}
}
switch (role)
{
case Qt::EditRole:
item->text = value.toString();
break;
case Qt::DecorationRole:
item->pixmap = value.value<QPixmap>();
break;
case Qt::SizeHintRole:
item->size = value.toSize();
break;
default:
return false;
}
emit dataChanged(index, index, QVector<int>() << role);
return false;
}
Qt::ItemFlags QLensFlareAtomicListModel::flags(const QModelIndex& index) const
{
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsDragEnabled;
}
EFlareType QLensFlareAtomicListModel::FlareTypeFromIndex(QModelIndex index) const
{
Item* item;
if (!index.isValid())
{
return eFT_Max;
}
else
{
item = ItemFromIndex(index);
if (!item)
{
return eFT_Max;
}
}
return item->flareType;
}
QLensFlareAtomicListModel::Item* QLensFlareAtomicListModel::ItemFromIndex(QModelIndex index) const
{
if (!index.isValid())
{
return nullptr;
}
return m_items.at(index.row());
}
QStringList QLensFlareAtomicListModel::mimeTypes() const
{
return {
QStringLiteral("application/x-o3de-flaretypes")
};
}
QMimeData* QLensFlareAtomicListModel::mimeData(const QModelIndexList& indexes) const
{
QMimeData* data = new QMimeData();
QByteArray encoded;
QDataStream stream(&encoded, QIODevice::WriteOnly);
for (const QModelIndex& index : indexes)
{
stream << static_cast<int>(FlareTypeFromIndex(index));
}
data->setData(QStringLiteral("application/x-o3de-flaretypes"), encoded);
return data;
}
bool QLensFlareAtomicListModel::dropMimeData([[maybe_unused]] const QMimeData* data, [[maybe_unused]] Qt::DropAction action, [[maybe_unused]] int row, [[maybe_unused]] int column, [[maybe_unused]] const QModelIndex& parent)
{
return false;
}
Qt::DropActions QLensFlareAtomicListModel::supportedDragActions() const
{
return Qt::CopyAction;
}
#include <LensFlareEditor/moc_LensFlareAtomicList.cpp>
@@ -1,78 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREATOMICLIST_H
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREATOMICLIST_H
#pragma once
#if !defined(Q_MOC_RUN)
#include "Controls/ImageListCtrl.h"
#endif
#if !defined(Q_MOC_RUN)
#include <QAbstractItemModel>
#include <QScopedPointer>
#endif
class CLensFlareEditor;
class QLensFlareAtomicListModel;
class CLensFlareAtomicList
: public CImageListCtrl
{
Q_OBJECT
public:
CLensFlareAtomicList(QWidget* parent = nullptr);
virtual ~CLensFlareAtomicList();
void FillAtomicItems();
protected:
void updateGeometries() override;
private:
QScopedPointer<QLensFlareAtomicListModel> m_model;
};
class QLensFlareAtomicListModel
: public QAbstractListModel
{
struct Item;
Q_OBJECT
public:
QLensFlareAtomicListModel(QObject* parent = nullptr);
~QLensFlareAtomicListModel();
void Clear();
void Populate();
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
QStringList mimeTypes() const override;
QMimeData* mimeData(const QModelIndexList& indexes) const override;
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) override;
Qt::DropActions supportedDragActions() const override;
EFlareType FlareTypeFromIndex(QModelIndex index) const;
protected:
QModelIndex InsertItem(const FlareInfo& flareInfo);
Item* ItemFromIndex(QModelIndex index) const;
private:
QVector<Item*> m_items;
};
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREATOMICLIST_H
File diff suppressed because it is too large Load Diff
@@ -1,233 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREEDITOR_H
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREEDITOR_H
#pragma once
#if !defined(Q_MOC_RUN)
#include "DatabaseFrameWnd.h"
#include "LensFlareUtil.h"
#include "ILensFlareListener.h"
#include "LensFlareItemTree.h"
#include "UserMessageDefines.h"
#endif
#include <AzQtComponents/Components/DockMainWindow.h>
namespace AzQtComponents
{
class FancyDocking;
}
class CLensFlareView;
class CLensFlareElementTree;
class CLensFlareAtomicList;
class CLensFlareElementPropertyView;
class CLensFlareItem;
class CLensFlareLibrary;
class ReflectedPropertyControl;
class CLensFlareLightEntityTree;
class CLensFlareReferenceTree;
class CLensFlareEditor
: public CDatabaseFrameWnd
, public ILensFlareChangeElementListener
{
Q_OBJECT
public:
static const GUID& GetClassID();
static void RegisterViewClass();
CLensFlareEditor(QWidget* pParent = nullptr);
~CLensFlareEditor();
QMenu* createPopupMenu() override;
// CDatabaseFrameWnd overrides...
virtual void SelectItem(CBaseLibraryItem* item, bool bForceReload = false) override;
CLensFlareItem* GetSelectedLensFlareItem() const;
bool GetSelectedLensFlareName(QString& outName) const;
void UpdateLensFlareItem(CLensFlareItem* pLensFlareItem);
void ResetElementTreeControl();
CLensFlareLibrary* GetCurrentLibrary() const
{
if (m_pLibrary == NULL)
{
return NULL;
}
return (CLensFlareLibrary*)&(*m_pLibrary);
}
bool IsExistTreeItem(const QString& name, bool bExclusiveSelectedItem = false);
void RenameLensFlareItem(CLensFlareItem* pLensFlareItem, const QString& newGroupName, const QString& newShortName);
IOpticsElementBasePtr FindOptics(const QString& itemPath, const QString& opticsPath);
CLensFlareElementTree* GetLensFlareElementTree()
{
return m_pLensFlareElementTree;
}
CLensFlareView* GetLensFlareView() const
{
return m_pLensFlareView;
}
CLensFlareItemTree* GetLensFlareItemTree()
{
return m_LensFlareItemTree;
}
void RemovePropertyItems();
ReflectedPropertyControl* GetPropertyCtrl()
{
return m_pWndProps;
}
void UpdateLensOpticsNames(const QString& oldFullName, const QString& newFullName);
void SelectItemInLensFlareElementTreeByName(const QString& name);
void ReloadItems();
void RegisterLensFlareItemChangeListener(ILensFlareChangeItemListener* pListener);
void UnregisterLensFlareItemChangeListener(ILensFlareChangeItemListener* pListener);
bool SelectItemByName(const QString& itemName);
static CLensFlareEditor* GetLensFlareEditor()
{
return s_pLensFlareEditor;
}
bool GetFullSelectedFlareItemName(QString& outFullName) const
{
QModelIndexList selected = GetTreeCtrl()->selectionModel()->selectedIndexes();
if (selected.isEmpty())
{
return false;
}
return GetFullLensFlareItemName(selected.first(), outFullName);
}
void SelectLensFlareItem(const QString& fullItemName);
const char* GetClassName()
{
return s_pLensFlareEditorClassName;
}
void Paste(XmlNodeRef node);
void Paste(const QModelIndex& index, XmlNodeRef node);
XmlNodeRef CreateXML(const char* type) const;
static const char* s_pLensFlareEditorClassName;
QTreeView* GetTreeCtrl() override
{
return m_LensFlareItemTree;
}
const QTreeView* GetTreeCtrl() const override
{
return m_LensFlareItemTree;
}
void AddNewItemByAtomicOptics(const QModelIndex& hSelectedItem, EFlareType flareType);
public slots:
void OnUpdateTreeCtrl();
protected:
static CLensFlareEditor* s_pLensFlareEditor;
void OnInitDialog() override;
void OnCopy();
void OnPaste();
void OnCut();
void UpdateClipboard(const char* type) const;
bool GetClipboardDataList(std::vector<LensFlareUtil::SClipboardData>& outList, QString& outGroupName) const;
void OnLensFlareChangeElement(CLensFlareElement* pLensFlareElement);
void OnAddLibrary();
void OnAssignFlareToLightEntities();
void OnSelectAssignedObjects();
void OnGetFlareFromSelection();
void OnRenameItem();
void OnAddItem();
void OnRemoveItem();
void OnCopyNameToClipboard();
void OnNotifyTreeRClick();
void OnTvnItemSelChanged(const QItemSelection& selected, const QItemSelection& deselected);
void OnReloadLib();
void ReleaseWindowsToBePutIntoPanels();
void SelectLensFlareItem(const QModelIndex& hItem);
void SelectLensFlareItem(const QModelIndex& hItem, const QModelIndex& hPrevItem);
void StartEditItem(const QModelIndex& hItem);
bool GetFullLensFlareItemName(const QModelIndex& hItem, QString& outFullName) const;
AssetSelectionModel GetAssetSelectionModel() const override;
CLensFlareItem* AddNewLensFlareItem(const QString& groupName, const QString& shortName);
QModelIndex GetTreeLensFlareItem(CLensFlareItem* pItem) const;
void OnItemTreeDataRenamed(CBaseLibraryItem* pItem, const QString& prevFullName);
enum ESelectedItemStatus
{
eSIS_Unselected,
eSIS_Group,
eSIS_Flare
};
ESelectedItemStatus GetSelectedItemStatus() const;
void addDockWidget(Qt::DockWidgetArea area, QWidget* widget, const QString& title, bool closable = true);
void OnUpdateProperties(IVariable* var);
private:
CLensFlareView* m_pLensFlareView;
CLensFlareAtomicList* m_pLensFlareAtomicList;
CLensFlareElementTree* m_pLensFlareElementTree;
ReflectedPropertyControl* m_pWndProps;
CLensFlareLightEntityTree* m_pLensFlareLightEntityTree;
CLensFlareReferenceTree* m_pLensFlareReferenceTree;
CLensFlareItemTree* m_LensFlareItemTree;
std::vector<ILensFlareChangeItemListener*> m_LensFlareChangeItemListenerList;
AzQtComponents::FancyDocking* m_advancedDockManager = nullptr;
};
class LensFlareItemTreeModel
: public LibraryItemTreeModel
{
Q_OBJECT
public:
LensFlareItemTreeModel(CDatabaseFrameWnd* pParent);
Qt::ItemFlags flags(const QModelIndex& index) const override;
QStringList mimeTypes() const override;
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) override;
Qt::DropActions supportedDragActions() const override;
Qt::DropActions supportedDropActions() const override;
};
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREEDITOR_H
@@ -1,381 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "EditorDefs.h"
#include "LensFlareElement.h"
// Editor
#include "LensFlareElementTree.h"
#include "LensFlareUtil.h"
#include "LensFlareItem.h"
#include "LensFlareEditor.h"
#include "LensFlareView.h"
#include "LensFlareLibrary.h"
CLensFlareElement::CLensFlareElement()
: m_vars(NULL)
, m_pOpticsElement(NULL)
, m_pParent(NULL)
{
}
CLensFlareElement::~CLensFlareElement()
{
}
void CLensFlareElement::OnInternalVariableChange(IVariable* pVar)
{
IOpticsElementBasePtr pOptics = GetOpticsElement();
if (pOptics == NULL)
{
return;
}
IFuncVariable* pFuncVar = LensFlareUtil::GetFuncVariable(pOptics, pVar->GetUserData().toInt());
if (pFuncVar == NULL)
{
return;
}
switch (pVar->GetType())
{
case IVariable::INT:
{
int var(0);
pVar->Get(var);
if (pFuncVar->paramType == e_COLOR)
{
ColorF color(pFuncVar->GetColorF());
color.a = (float)var / 255.0f;
pFuncVar->InvokeSetter((void*)&color);
}
else if (pFuncVar->paramType == e_INT)
{
if (LensFlareUtil::HaveParameterLowBoundary(pFuncVar->name.c_str()))
{
LensFlareUtil::BoundaryProcess(var);
}
pFuncVar->InvokeSetter((void*)&var);
if (pFuncVar->GetInt() != var)
{
pVar->Set(pFuncVar->GetInt());
}
}
}
break;
case IVariable::BOOL:
{
if (pFuncVar->paramType == e_BOOL)
{
bool var;
pVar->Get(var);
pFuncVar->InvokeSetter((void*)&var);
}
}
break;
case IVariable::FLOAT:
{
if (pFuncVar->paramType == e_FLOAT)
{
float var;
pVar->Get(var);
pFuncVar->InvokeSetter((void*)&var);
}
}
break;
case IVariable::VECTOR2:
{
if (pFuncVar->paramType == e_VEC2)
{
Vec2 var;
pVar->Get(var);
pFuncVar->InvokeSetter((void*)&var);
}
}
break;
case IVariable::VECTOR:
{
Vec3 var;
pVar->Get(var);
if (pFuncVar->paramType == e_COLOR)
{
ColorF color(pFuncVar->GetColorF());
color.r = var.x;
color.g = var.y;
color.b = var.z;
pFuncVar->InvokeSetter((void*)&color);
}
else if (pFuncVar->paramType == e_VEC3)
{
pFuncVar->InvokeSetter((void*)&var);
}
}
break;
case IVariable::VECTOR4:
{
if (pFuncVar->paramType == e_VEC4)
{
Vec4 var;
pVar->Get(var);
pFuncVar->InvokeSetter((void*)&var);
}
}
break;
case IVariable::STRING:
{
QString var;
pVar->Get(var);
if (pFuncVar->paramType == e_TEXTURE2D || pFuncVar->paramType == e_TEXTURE3D || pFuncVar->paramType == e_TEXTURE_CUBE)
{
var = var.trimmed();
ITexture* pTexture = NULL;
if (!var.isEmpty())
{
pTexture = GetIEditor()->GetRenderer()->EF_LoadTexture(var.toUtf8().data());
}
pFuncVar->InvokeSetter((void*)pTexture);
if (pTexture)
{
pTexture->Release();
}
}
}
break;
}
UpdateLights();
}
bool CLensFlareElement::IsEnable()
{
IOpticsElementBasePtr pOptics = GetOpticsElement();
if (pOptics == NULL)
{
return false;
}
return pOptics->IsEnabled();
}
void CLensFlareElement::SetEnable(bool bEnable)
{
IOpticsElementBasePtr pOptics = GetOpticsElement();
if (pOptics == NULL)
{
return;
}
pOptics->SetEnabled(bEnable);
UpdateLights();
}
EFlareType CLensFlareElement::GetOpticsType()
{
IOpticsElementBasePtr pOptics = GetOpticsElement();
if (pOptics == NULL)
{
return eFT__Base__;
}
return pOptics->GetType();
}
bool CLensFlareElement::GetShortName(QString& outName) const
{
QString fullName;
if (!GetName(fullName))
{
return false;
}
int nPos = fullName.lastIndexOf('.');
if (nPos == -1)
{
outName = fullName;
return true;
}
outName = fullName.right(fullName.length() - nPos - 1);
return true;
}
void CLensFlareElement::UpdateLights()
{
IOpticsElementBasePtr pOptics = GetOpticsElement();
if (pOptics == NULL)
{
return;
}
if (GetLensFlareTree())
{
if (GetLensFlareTree()->GetLensFlareItem())
{
GetLensFlareTree()->GetLensFlareItem()->UpdateLights(pOptics);
}
}
}
void CLensFlareElement::UpdateProperty(IOpticsElementBasePtr pOptics)
{
std::vector<IVariable::OnSetCallback*> funcs;
if (CLensFlareElementTree* lensFlareTree = GetLensFlareTree(); lensFlareTree)
{
auto callbackItr = m_callbackCache.find(lensFlareTree);
if (callbackItr == m_callbackCache.end())
{
IVariable::OnSetCallback callback =
AZStd::bind(&CLensFlareElementTree::OnInternalVariableChange, lensFlareTree, AZStd::placeholders::_1);
auto result = m_callbackCache.insert(AZStd::make_pair(lensFlareTree, callback));
callbackItr = result.first;
}
funcs.push_back(&(callbackItr->second));
}
if (CLensFlareView* lensFlareView = GetLensFlareView(); lensFlareView)
{
auto callbackItr = m_callbackCache.find(lensFlareView);
if (callbackItr == m_callbackCache.end())
{
IVariable::OnSetCallback callback =
AZStd::bind(&CLensFlareView::OnInternalVariableChange, lensFlareView, AZStd::placeholders::_1);
auto result = m_callbackCache.insert(AZStd::make_pair(lensFlareView, callback));
callbackItr = result.first;
}
funcs.push_back(&(callbackItr->second));
}
if (CLensFlareLibrary* lensFlareLibrary = GetLensFlareLibrary(); lensFlareLibrary)
{
auto callbackItr = m_callbackCache.find(lensFlareLibrary);
if (callbackItr == m_callbackCache.end())
{
IVariable::OnSetCallback callback =
AZStd::bind(&CLensFlareLibrary::OnInternalVariableChange, lensFlareLibrary, AZStd::placeholders::_1);
auto result = m_callbackCache.insert(AZStd::make_pair(lensFlareLibrary, callback));
callbackItr = result.first;
}
funcs.push_back(&(callbackItr->second));
}
LensFlareUtil::SetVariablesTemplateFromOptics(pOptics, m_vars, funcs);
}
CLensFlareElementTree* CLensFlareElement::GetLensFlareTree() const
{
CLensFlareEditor* pEditor = CLensFlareEditor::GetLensFlareEditor();
if (pEditor == NULL)
{
return NULL;
}
return pEditor->GetLensFlareElementTree();
}
CLensFlareView* CLensFlareElement::GetLensFlareView() const
{
CLensFlareEditor* pEditor = CLensFlareEditor::GetLensFlareEditor();
if (pEditor == NULL)
{
return NULL;
}
return pEditor->GetLensFlareView();
}
CLensFlareLibrary* CLensFlareElement::GetLensFlareLibrary() const
{
CLensFlareEditor* pEditor = CLensFlareEditor::GetLensFlareEditor();
if (pEditor == NULL)
{
return NULL;
}
return pEditor->GetCurrentLibrary();
}
CLensFlareElement* CLensFlareElement::GetParent() const
{
return m_pParent;
}
void CLensFlareElement::SetParent(CLensFlareElement* pParent)
{
m_pParent = pParent;
}
int CLensFlareElement::GetChildCount() const
{
return m_children.size();
}
CLensFlareElement* CLensFlareElement::GetChildAt(int nPos) const
{
if (nPos < 0 || nPos >= m_children.size())
{
return nullptr;
}
return m_children[nPos];
}
void CLensFlareElement::AddChild(CLensFlareElement* pElement)
{
pElement->SetParent(this);
m_children.push_back(pElement);
}
void CLensFlareElement::InsertChild(int nPos, CLensFlareElement* pElement)
{
pElement->SetParent(this);
m_children.insert(std::begin(m_children) + nPos, pElement);
}
void CLensFlareElement::RemoveChild(int nPos)
{
m_children.erase(std::begin(m_children) + nPos);
}
void CLensFlareElement::SwapChildren(int nPos1, int nPos2)
{
std::swap(m_children[nPos1], m_children[nPos2]);
}
void CLensFlareElement::RemoveAllChildren()
{
m_children.clear();
}
int CLensFlareElement::GetChildIndex(const CLensFlareElement* pElement) const
{
auto it = std::find_if(
std::begin(m_children),
std::end(m_children),
[=](const LensFlareElementPtr& pChild)
{
return pChild.get() == pElement;
});
if (it != std::end(m_children))
{
return std::distance(std::begin(m_children), it);
}
else
{
return -1;
}
}
int CLensFlareElement::GetRow() const
{
return m_pParent ? m_pParent->GetChildIndex(this) : 0;
}
@@ -1,106 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREELEMENT_H
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREELEMENT_H
#pragma once
#include "IFlares.h"
#include "Util/Variable.h"
class CLensFlareElementTree;
class CLensFlareView;
class CLensFlareLibrary;
class CLensFlareElement
: public CRefCountBase
{
public:
typedef _smart_ptr<CLensFlareElement> LensFlareElementPtr;
typedef std::vector<LensFlareElementPtr> LensFlareElementList;
CLensFlareElement();
virtual ~CLensFlareElement();
CVarBlock* GetProperties() const
{
return m_vars;
}
void OnInternalVariableChange(IVariable* pVar);
bool IsEnable();
void SetEnable(bool bEnable);
EFlareType GetOpticsType();
bool GetName(QString& outName) const
{
IOpticsElementBasePtr pOptics = GetOpticsElement();
if (pOptics == NULL)
{
return false;
}
outName = pOptics->GetName();
return true;
}
bool GetShortName(QString& outName) const;
IOpticsElementBasePtr GetOpticsElement() const
{
return m_pOpticsElement;
}
void SetOpticsElement(IOpticsElementBasePtr pOptics)
{
m_pOpticsElement = pOptics;
UpdateProperty(m_pOpticsElement);
}
CLensFlareElement* GetParent() const;
void SetParent(CLensFlareElement* pParent);
int GetChildCount() const;
CLensFlareElement* GetChildAt(int nPos) const;
void AddChild(CLensFlareElement* pElement);
void InsertChild(int nPos, CLensFlareElement* pElement);
void RemoveChild(int nPos);
void RemoveAllChildren();
void SwapChildren(int nPos1, int nPos2);
int GetChildIndex(const CLensFlareElement* pChild) const;
int GetRow() const;
private:
void UpdateLights();
void UpdateProperty(IOpticsElementBasePtr pOptics);
CLensFlareElementTree* GetLensFlareTree() const;
CLensFlareView* GetLensFlareView() const;
CLensFlareLibrary* GetLensFlareLibrary() const;
private:
IOpticsElementBasePtr m_pOpticsElement;
CVarBlockPtr m_vars;
CLensFlareElement* m_pParent;
LensFlareElementList m_children;
AZStd::map<void*, IVariable::OnSetCallback> m_callbackCache;
};
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREELEMENT_H
File diff suppressed because it is too large Load Diff
@@ -1,197 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREELEMENTTREE_H
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREELEMENTTREE_H
#pragma once
#if !defined(Q_MOC_RUN)
#include "LensFlareElement.h"
#include "LensFlareUtil.h"
#include "ILensFlareListener.h"
#include <QAbstractItemModel>
#include <QTreeView>
#endif
class CLensFlareItem;
class LensFlareElementTreeModel;
class QMouseEvent;
class CLensFlareElementTree
: public QTreeView
{
Q_OBJECT
public:
CLensFlareElementTree(QWidget* pParent = nullptr);
void RegisterListener(ILensFlareChangeElementListener* pListener)
{
if (pListener)
{
m_LensFlaresElementListeners.push_back(pListener);
}
}
void UnregisterListener(ILensFlareChangeElementListener* pListener)
{
if (pListener == NULL)
{
return;
}
std::vector<ILensFlareChangeElementListener*>::iterator ii = m_LensFlaresElementListeners.begin();
for (; ii != m_LensFlaresElementListeners.end(); )
{
if (*ii == pListener)
{
ii = m_LensFlaresElementListeners.erase(ii);
}
else
{
++ii;
}
}
}
CLensFlareElement::LensFlareElementPtr FindLensFlareElement(IOpticsElementBasePtr pElement) const;
void OnInternalVariableChange(IVariable* pVar);
CLensFlareElement* GetCurrentLensFlareElement() const;
void UpdateProperty();
void UpdateClipboard(const char* type, bool bPasteAtSameLevel);
void SelectTreeItemByName(const QString& name);
CLensFlareItem* GetLensFlareItem() const;
void InvalidateLensFlareItem();
protected:
void CallChangeListeners();
void OnDataChanged(const QModelIndex& index);
void OnRowsInserted(const QModelIndex& index, int first, int last);
void OnRowsRemoved(const QModelIndex& index, int first, int last);
void OnNotifyTreeRClick();
void OnTvnSelchangedTree(const QItemSelection& selected, const QItemSelection& deselected);
XmlNodeRef CreateXML(const char* type) const;
bool GetClipboardList(const char* type, std::vector<LensFlareUtil::SClipboardData>& outList) const;
//! Only the basic operations like following methods must have routine for undoing.
void ElementChanged(CLensFlareElement* pPrevLensFlareElement);
/////////////////////////////////////////////////////////////////////////////////////////
void OnAddGroup();
void OnCopy();
void OnCut();
void OnPaste();
void OnClone();
void OnRenameItem();
void OnRemoveItem();
void OnRemoveAll();
void OnItemUp();
void OnItemDown();
void mousePressEvent(QMouseEvent* event);
void keyPressEvent(QKeyEvent* event);
void Cut(bool bPasteAtSameLevel);
private:
void SelectItem(const QModelIndex& index);
std::vector<ILensFlareChangeElementListener*> m_LensFlaresElementListeners;
QScopedPointer<LensFlareElementTreeModel> m_model;
};
class LensFlareElementTreeModel
: public QAbstractItemModel
, public ILensFlareChangeItemListener
{
Q_OBJECT
public:
LensFlareElementTreeModel(QObject* pParent = nullptr);
~LensFlareElementTreeModel();
int rowCount(const QModelIndex& parent = {}) const override;
int columnCount(const QModelIndex& parent = {}) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
QVariant data(const QModelIndex& index, int role) const override;
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
QModelIndex index(int row, int column, const QModelIndex& parent = {}) const override;
QModelIndex parent(const QModelIndex& index) const override;
bool removeRows(int row, int count, const QModelIndex& parent = {}) override;
QStringList mimeTypes() const override;
QMimeData* mimeData(const QModelIndexList& indexes) const override;
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) override;
Qt::DropActions supportedDragActions() const override;
Qt::DropActions supportedDropActions() const override;
CLensFlareElement* GetLensFlareElement(const QModelIndex& index) const;
QModelIndex GetTreeItemByName(const QString& name) const;
void Paste(const QModelIndex& index, XmlNodeRef xmlNode);
void Cut(const QModelIndex& index, bool bPasteAtSameLevel);
CLensFlareItem* GetLensFlareItem() const
{
return m_pLensFlareItem;
}
void InvalidateLensFlareItem();
void RemoveAllElements();
bool AddElement(const QModelIndex& index, int row, EFlareType flareType);
bool MoveElement(CLensFlareElement* pElement, int row, const QModelIndex& parentIndex);
private:
QModelIndex GetRootItem() const;
IOpticsElementBasePtr GetOpticsElementByTreeItem(const QModelIndex& index) const;
void OnLensFlareChangeItem(CLensFlareItem* pLensFlareItem);
void OnLensFlareDeleteItem(CLensFlareItem* pLensFlareItem);
void UpdateLensFlareItem(CLensFlareItem* pLensFlareItem);
CLensFlareElement* UpdateLensFlareElementsRecusively(IOpticsElementBasePtr pOptics);
CLensFlareElement* CreateElement(IOpticsElementBasePtr pOptics);
void Reload();
void MakeValidElementName(const QString& seedName, QString& outValidName) const;
bool IsExistElement(const QString& name) const;
CLensFlareElement::LensFlareElementPtr InsertAtomicElement(int nIndex, EFlareType flareType, CLensFlareElement* pParentElement);
CLensFlareElement::LensFlareElementPtr AddElement(IOpticsElementBasePtr pOptics, CLensFlareElement* pParentElement);
CLensFlareElement* FindLensFlareElement(IOpticsElementBasePtr pOptics) const;
QModelIndex GetTreeItemByOpticsElement(const IOpticsElementBasePtr pOptics) const;
void EnableElement(CLensFlareElement* pLensFlareElement, bool bEnable);
void RenameElement(CLensFlareElement* pLensFlareElement, const QString& newName);
void StoreUndo(const QString& undoDescription = "");
CLensFlareElement::LensFlareElementPtr m_pRootElement;
CLensFlareItem* m_pLensFlareItem;
};
Q_DECLARE_METATYPE(CLensFlareElement*)
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREELEMENTTREE_H
@@ -1,203 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "EditorDefs.h"
#include "LensFlareItem.h"
// Editor
#include "LensFlareUtil.h"
#include "LensFlareEditor.h"
#include "LensFlareUndo.h"
#include "Objects/EntityObject.h"
CLensFlareItem::CLensFlareItem()
{
m_pOptics = NULL;
CreateOptics();
}
CLensFlareItem::~CLensFlareItem()
{
}
void CLensFlareItem::Serialize(SerializeContext& ctx)
{
if (ctx.bLoading)
{
CreateOptics();
LensFlareUtil::FillOpticsFromXML(m_pOptics, ctx.node);
for (int i = 0, iChildCount(ctx.node->getChildCount()); i < iChildCount; ++i)
{
AddChildOptics(m_pOptics, ctx.node->getChild(i));
}
CBaseLibraryItem::Serialize(ctx);
}
else
{
CBaseLibraryItem::Serialize(ctx);
}
}
void CLensFlareItem::AddChildOptics(IOpticsElementBasePtr pParentOptics, const XmlNodeRef& pNode)
{
if (pNode == NULL)
{
return;
}
if (pNode->getTag() && strcmp(pNode->getTag(), "FlareItem"))
{
return;
}
IOpticsElementBasePtr pOptics = LensFlareUtil::CreateOptics(pNode);
if (pOptics == NULL)
{
return;
}
pParentOptics->AddElement(pOptics);
for (int i = 0, iChildCount(pNode->getChildCount()); i < iChildCount; ++i)
{
AddChildOptics(pOptics, pNode->getChild(i));
}
}
void CLensFlareItem::CreateOptics()
{
m_pOptics = gEnv->pOpticsManager->Create(eFT_Root);
}
XmlNodeRef CLensFlareItem::CreateXmlData() const
{
XmlNodeRef pRootNode = NULL;
if (LensFlareUtil::CreateXmlData(m_pOptics, pRootNode))
{
pRootNode->setAttr("Name", m_pOptics->GetName().c_str());
return pRootNode;
}
return NULL;
}
void CLensFlareItem::SetName(const QString& name)
{
QString newNameWithGroup;
QString newFullName;
LensFlareUtil::GetExpandedItemNames(this, LensFlareUtil::GetGroupNameFromName(name), LensFlareUtil::GetShortName(name), newNameWithGroup, newFullName);
if (CUndo::IsRecording())
{
CUndo::Record(new CUndoRenameLensFlareItem(GetFullName(), newFullName));
}
CBaseLibraryItem::SetName(name);
if (m_pOptics)
{
m_pOptics->SetName(GetShortName().toUtf8().data());
}
}
void CLensFlareItem::UpdateLights(IOpticsElementBasePtr pSrcOptics)
{
QString srcFullOpticsName = GetFullName();
bool bUpdateChildren = false;
if (pSrcOptics == NULL)
{
if (m_pOptics == NULL)
{
return;
}
pSrcOptics = m_pOptics;
bUpdateChildren = true;
}
std::vector<CEntityObject*> lightEntities;
LensFlareUtil::GetLightEntityObjects(lightEntities);
for (int i = 0, iLightSize(lightEntities.size()); i < iLightSize; ++i)
{
CEntityObject* pLightEntity = lightEntities[i];
if (pLightEntity == NULL)
{
continue;
}
IOpticsElementBasePtr pTargetOptics = pLightEntity->GetOpticsElement();
if (pTargetOptics == NULL)
{
continue;
}
QString targetFullOpticsName(pTargetOptics->GetName().c_str());
if (srcFullOpticsName != targetFullOpticsName)
{
continue;
}
QString srcOpticsName(pSrcOptics->GetName().c_str());
IOpticsElementBasePtr pFoundOptics = NULL;
if (LensFlareUtil::GetShortName(targetFullOpticsName) == srcOpticsName)
{
pFoundOptics = pTargetOptics;
}
else
{
pFoundOptics = LensFlareUtil::FindOptics(pTargetOptics, srcOpticsName);
}
if (pFoundOptics == NULL)
{
continue;
}
if (pFoundOptics->GetType() != pSrcOptics->GetType())
{
continue;
}
LensFlareUtil::CopyOptics(pSrcOptics, pFoundOptics, bUpdateChildren);
}
}
void CLensFlareItem::ReplaceOptics(IOpticsElementBasePtr pNewData)
{
if (pNewData == NULL)
{
return;
}
if (pNewData->GetType() != eFT_Root)
{
return;
}
CreateOptics();
LensFlareUtil::CopyOptics(pNewData, m_pOptics);
m_pOptics->SetName(GetFullName().toUtf8().data());
UpdateLights();
CLensFlareEditor* pLensFlareEditor = CLensFlareEditor::GetLensFlareEditor();
if (pLensFlareEditor == NULL)
{
return;
}
if (this != pLensFlareEditor->GetSelectedLensFlareItem())
{
return;
}
pLensFlareEditor->UpdateLensFlareItem(this);
pLensFlareEditor->RemovePropertyItems();
}
@@ -1,59 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREITEM_H
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREITEM_H
#pragma once
class IOpticsElementBase;
class CEntityObject;
#include "BaseLibraryItem.h"
#include "Include/IDataBaseItem.h"
class CLensFlareItem
: public CBaseLibraryItem
{
public:
CLensFlareItem();
~CLensFlareItem();
EDataBaseItemType GetType() const
{
return EDB_TYPE_FLARE;
}
void SetName(const QString& name);
void Serialize(SerializeContext& ctx);
void CreateOptics();
IOpticsElementBasePtr GetOptics() const
{
return m_pOptics;
}
void ReplaceOptics(IOpticsElementBasePtr pNewData);
XmlNodeRef CreateXmlData() const;
void UpdateLights(IOpticsElementBasePtr pSrcOptics = NULL);
private:
void GetLightEntityObjects(std::vector<CEntityObject*>& outEntityLights) const;
static void AddChildOptics(IOpticsElementBasePtr pParentOptics, const XmlNodeRef& pNode);
IOpticsElementBasePtr m_pOptics;
};
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREITEM_H
@@ -1,87 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "EditorDefs.h"
#include "LensFlareItemTree.h"
// Editor
#include "LensFlareItem.h"
#include "ViewManager.h"
#include "Objects/EntityObject.h"
CLensFlareItemTree::CLensFlareItemTree(QWidget* pParent)
: QTreeView(pParent)
{
setHeaderHidden(true);
setSelectionMode(QAbstractItemView::SingleSelection);
setContextMenuPolicy(Qt::CustomContextMenu);
setDragEnabled(true);
setAcceptDrops(true);
setDropIndicatorShown(true);
setDragDropMode(DragDrop);
}
CLensFlareItemTree::~CLensFlareItemTree()
{
}
void CLensFlareItemTree::startDrag(Qt::DropActions supportedDropActions)
{
QTreeView::startDrag(supportedDropActions);
}
void CLensFlareItemTree::mousePressEvent(QMouseEvent* event)
{
if (event->button() == Qt::LeftButton)
{
CUndo undo(tr("Changed lens flare item").toUtf8());
QTreeView::mousePressEvent(event);
}
else
{
QTreeView::mousePressEvent(event);
}
}
void CLensFlareItemTree::AssignLensFlareToLightEntity(CViewport* pViewport) const
{
QModelIndexList selected = selectionModel()->selectedIndexes();
if (selected.isEmpty())
{
return;
}
CLensFlareItem* pLensFlareItem = static_cast<CLensFlareItem*>(selected.first().data(Qt::UserRole).value<CBaseLibraryItem*>());
QPoint viewportPos = QCursor::pos();
pViewport->ScreenToClient(viewportPos);
HitContext hit;
if (!pViewport->HitTest(viewportPos, hit))
{
return;
}
if (hit.object && qobject_cast<CEntityObject*>(hit.object))
{
CEntityObject* pEntity = (CEntityObject*)hit.object;
if (pEntity->IsLight())
{
CUndo undo(tr("Assign a lens flare item to a light entity").toUtf8());
pEntity->ApplyOptics(pLensFlareItem->GetFullName(), pLensFlareItem->GetOptics());
}
}
}
#include <LensFlareEditor/moc_LensFlareItemTree.cpp>
@@ -1,45 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREITEMTREE_H
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREITEMTREE_H
#pragma once
#if !defined(Q_MOC_RUN)
#include "LensFlareElement.h"
#include "ILensFlareListener.h"
#include <QTreeView>
#endif
class QMouseEvent;
class CLensFlareItem;
class CLensFlareItemTree
: public QTreeView
{
Q_OBJECT
public:
CLensFlareItemTree(QWidget* pParent = nullptr);
~CLensFlareItemTree();
protected:
void startDrag(Qt::DropActions supportedDropActions) override;
void mousePressEvent(QMouseEvent* event) override;
private:
void AssignLensFlareToLightEntity(CViewport* pViewport) const;
};
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREITEMTREE_H
@@ -1,100 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "EditorDefs.h"
#include "LensFlareLibrary.h"
// Editor
#include "LensFlareItem.h"
bool CLensFlareLibrary::Save()
{
return SaveLibrary("LensFlareLibrary");
}
bool CLensFlareLibrary::Load(const QString& filename)
{
if (filename.isEmpty())
{
return false;
}
SetFilename(filename);
XmlNodeRef root = XmlHelpers::LoadXmlFromFile(filename.toUtf8().data());
if (!root)
{
return false;
}
Serialize(root, true);
return true;
}
void CLensFlareLibrary::Serialize(XmlNodeRef& root, bool bLoading)
{
if (bLoading)
{
RemoveAllItems();
QString name = GetName();
root->getAttr("Name", name);
SetName(name);
for (int i = 0; i < root->getChildCount(); i++)
{
XmlNodeRef itemNode = root->getChild(i);
CLensFlareItem* pLensFlareItem = new CLensFlareItem;
AddItem(pLensFlareItem);
CBaseLibraryItem::SerializeContext ctx(itemNode, bLoading);
pLensFlareItem->Serialize(ctx);
}
SetModified(false);
m_bNewLibrary = false;
}
else
{
root->setAttr("Name", GetName().toUtf8().data());
for (int i = 0; i < GetItemCount(); i++)
{
CLensFlareItem* pItem = (CLensFlareItem*)GetItem(i);
if(pItem)
{
CBaseLibraryItem::SerializeContext ctx(pItem->CreateXmlData(), bLoading);
root->addChild(ctx.node);
pItem->Serialize(ctx);
}
}
}
}
IOpticsElementBasePtr CLensFlareLibrary::GetOpticsOfItem(const char* szflareName)
{
IOpticsElementBasePtr pOptics = NULL;
for (int i = 0; i < GetItemCount(); i++)
{
CLensFlareItem* pItem = (CLensFlareItem*)GetItem(i);
if (pItem->GetFullName() == szflareName)
{
pOptics = pItem->GetOptics();
break;
}
}
return pOptics;
}
void CLensFlareLibrary::OnInternalVariableChange([[maybe_unused]] IVariable* pVar)
{
SetModified(true);
}
@@ -1,35 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLARELIBRARY_H
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLARELIBRARY_H
#pragma once
#include "BaseLibrary.h"
struct IVariable;
class CRYEDIT_API CLensFlareLibrary
: public CBaseLibrary
{
public:
CLensFlareLibrary(IBaseLibraryManager* pManager)
: CBaseLibrary(pManager) {};
virtual bool Save();
virtual bool Load(const QString& filename);
virtual void Serialize(XmlNodeRef& node, bool bLoading);
IOpticsElementBasePtr GetOpticsOfItem(const char* szflareName);
void OnInternalVariableChange(IVariable* pVar);
};
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLARELIBRARY_H
@@ -1,225 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "EditorDefs.h"
#include "LensFlareLightEntityTree.h"
// Editor
#include "Viewport.h"
#include "Include/IObjectManager.h"
#include "Objects/SelectionGroup.h"
#include "LensFlareItem.h"
#include "LensFlareEditor.h"
CLensFlareLightEntityTree::CLensFlareLightEntityTree(QWidget* pParent)
: QTreeView(pParent)
, m_model(new LensFlareLightEntityModel)
{
setHeaderHidden(true);
setModel(m_model.data());
connect(this, &QTreeView::doubleClicked, this, &CLensFlareLightEntityTree::OnTvnItemDoubleClicked);
}
CLensFlareLightEntityTree::~CLensFlareLightEntityTree()
{
}
void CLensFlareLightEntityTree::OnLensFlareChangeItem(CLensFlareItem* pLensFlareItem)
{
m_model->OnLensFlareChangeItem(pLensFlareItem);
}
void CLensFlareLightEntityTree::OnLensFlareDeleteItem(CLensFlareItem* pLensFlareItem)
{
m_model->OnLensFlareDeleteItem(pLensFlareItem);
}
void CLensFlareLightEntityTree::OnTvnItemDoubleClicked(const QModelIndex& index)
{
CEntityObject* pObject = index.data(Qt::UserRole).value<CEntityObject*>();
if (!qobject_cast<CEntityObject*>(pObject))
{
return;
}
CSelectionGroup* pSelection = GetIEditor()->GetObjectManager()->GetSelection();
if (pSelection)
{
int iSelectionCount(pSelection->GetCount());
if (iSelectionCount == 1)
{
if (pSelection->GetObject(0) == pObject)
{
CViewport* vp = GetIEditor()->GetActiveView();
if (vp)
{
vp->CenterOnSelection();
}
return;
}
}
}
GetIEditor()->GetObjectManager()->ClearSelection();
GetIEditor()->GetObjectManager()->SelectObject(pObject);
}
LensFlareLightEntityModel::LensFlareLightEntityModel(QObject* pParent)
: QAbstractListModel(pParent)
{
CLensFlareEditor::GetLensFlareEditor()->RegisterLensFlareItemChangeListener(this);
GetIEditor()->GetObjectManager()->AddObjectEventListener(this);
}
LensFlareLightEntityModel::~LensFlareLightEntityModel()
{
CLensFlareEditor::GetLensFlareEditor()->UnregisterLensFlareItemChangeListener(this);
GetIEditor()->GetObjectManager()->RemoveObjectEventListener(this);
}
void LensFlareLightEntityModel::OnLensFlareChangeItem(CLensFlareItem* pLensFlareItem)
{
beginResetModel();
m_pLensFlareItem = pLensFlareItem;
m_lightEntities.clear();
if (m_pLensFlareItem)
{
std::vector<CEntityObject*> lightEntities;
LensFlareUtil::GetLightEntityObjects(lightEntities);
for (int i = 0, iEntitySize(lightEntities.size()); i < iEntitySize; ++i)
{
AddLightEntity(lightEntities[i]);
}
}
endResetModel();
}
void LensFlareLightEntityModel::OnLensFlareDeleteItem([[maybe_unused]] CLensFlareItem* pLensFlareItem)
{
beginResetModel();
m_lightEntities.clear();
m_pLensFlareItem = NULL;
endResetModel();
}
void LensFlareLightEntityModel::OnObjectEvent(CBaseObject* pObject, int nEvent)
{
if (!qobject_cast<CEntityObject*>(pObject))
{
return;
}
switch (nEvent)
{
case CBaseObject::ON_RENAME:
case CBaseObject::ON_DELETE:
{
auto it = std::find(std::begin(m_lightEntities), std::end(m_lightEntities), pObject);
if (it == std::end(m_lightEntities))
{
return;
}
int row = std::distance(std::begin(m_lightEntities), it);
if (nEvent == CBaseObject::ON_RENAME)
{
emit dataChanged(index(row, 0), index(row, 0));
}
else
{
beginRemoveRows({}, row, row);
m_lightEntities.erase(it);
endRemoveRows();
}
}
break;
case CBaseObject::ON_ADD:
if (AddLightEntity((CEntityObject*)pObject))
{
int row = m_lightEntities.size() - 1;
beginInsertRows({}, row, row);
endInsertRows();
}
break;
}
}
bool LensFlareLightEntityModel::AddLightEntity(CEntityObject* pEntity)
{
if (pEntity == NULL || m_pLensFlareItem == NULL)
{
return false;
}
QString lensFlareName = pEntity->GetEntityPropertyString(CEntityObject::s_LensFlarePropertyName);
if (lensFlareName.isEmpty())
{
return false;
}
QString fullName = m_pLensFlareItem->GetFullName();
if (fullName.isEmpty())
{
return false;
}
if (QString::compare(lensFlareName, fullName, Qt::CaseInsensitive))
{
return false;
}
m_lightEntities.push_back(pEntity);
return true;
}
int LensFlareLightEntityModel::rowCount(const QModelIndex&) const
{
return m_lightEntities.size();
}
QVariant LensFlareLightEntityModel::data(const QModelIndex& index, int role) const
{
const int row = index.row();
if (row < 0 || row >= m_lightEntities.size())
{
return {};
}
auto pEntity = m_lightEntities[row];
switch (role)
{
case Qt::DisplayRole:
return pEntity->GetName();
case Qt::UserRole:
return QVariant::fromValue<CEntityObject*>(pEntity);
}
return {};
}
#include <LensFlareEditor/moc_LensFlareLightEntityTree.cpp>
@@ -1,75 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLARELIGHTENTITYTREE_H
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLARELIGHTENTITYTREE_H
#pragma once
#if !defined(Q_MOC_RUN)
#include "ILensFlareListener.h"
#include <QScopedPointer>
#include <QTreeWidget>
#include "IObjectManager.h" // for IObjectManager::EventListener
#include "Objects/EntityObject.h"
#endif
class LensFlareLightEntityModel;
class CLensFlareLightEntityTree
: public QTreeView
{
Q_OBJECT
public:
CLensFlareLightEntityTree(QWidget* pParent = nullptr);
~CLensFlareLightEntityTree();
void OnLensFlareDeleteItem(CLensFlareItem* pLensFlareItem);
void OnLensFlareChangeItem(CLensFlareItem* pLensFlareItem);
protected:
void OnTvnItemDoubleClicked(const QModelIndex& index);
QScopedPointer<LensFlareLightEntityModel> m_model;
};
class LensFlareLightEntityModel
: public QAbstractListModel
, public ILensFlareChangeItemListener
, public IObjectManager::EventListener
{
Q_OBJECT
public:
LensFlareLightEntityModel(QObject* pParent = nullptr);
~LensFlareLightEntityModel();
int rowCount(const QModelIndex& parent = {}) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
void OnLensFlareDeleteItem(CLensFlareItem* pLensFlareItem);
void OnLensFlareChangeItem(CLensFlareItem* pLensFlareItem);
protected:
void OnObjectEvent(CBaseObject* pObject, int nEvent) override;
bool AddLightEntity(CEntityObject* pEntity);
std::vector<CEntityObject*> m_lightEntities;
_smart_ptr<CLensFlareItem> m_pLensFlareItem;
};
Q_DECLARE_METATYPE(CEntityObject*)
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLARELIGHTENTITYTREE_H
@@ -1,234 +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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "EditorDefs.h"
#include "LensFlareManager.h"
// AzCore
#include <AzCore/XML/rapidxml.h>
#include <AzCore/std/string/wildcard.h>
// Editor
#include "LensFlareEditor.h"
#include "LensFlareItem.h"
#include "LensFlareLibrary.h"
#include "LensFlareUtil.h"
//////////////////////////////////////////////////////////////////////////
// CLensFlareManager implementation.
//////////////////////////////////////////////////////////////////////////
CLensFlareManager::CLensFlareManager()
: CBaseLibraryManager()
{
m_bUniqNameMap = true;
m_pLevelLibrary = (CBaseLibrary*)AddLibrary("Level", true);
AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler::BusConnect();
}
//////////////////////////////////////////////////////////////////////////
CLensFlareManager::~CLensFlareManager()
{
AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler::BusDisconnect();
}
//////////////////////////////////////////////////////////////////////////
void CLensFlareManager::ClearAll()
{
CBaseLibraryManager::ClearAll();
m_pLevelLibrary = (CBaseLibrary*)AddLibrary("Level", true);
}
//////////////////////////////////////////////////////////////////////////
CBaseLibraryItem* CLensFlareManager::MakeNewItem()
{
return new CLensFlareItem;
}
//////////////////////////////////////////////////////////////////////////
CBaseLibrary* CLensFlareManager::MakeNewLibrary()
{
return new CLensFlareLibrary(this);
}
//////////////////////////////////////////////////////////////////////////
QString CLensFlareManager::GetRootNodeName()
{
return "FlareLibs";
}
//////////////////////////////////////////////////////////////////////////
QString CLensFlareManager::GetLibsPath()
{
if (m_libsPath.isEmpty())
{
m_libsPath += FLARE_LIBS_PATH;
}
return m_libsPath;
}
//////////////////////////////////////////////////////////////////////////
bool CLensFlareManager::LoadFlareItemByName(const QString& fullItemName, IOpticsElementBasePtr pDestOptics)
{
if (pDestOptics == NULL)
{
return false;
}
CLensFlareItem* pLensFlareItem = (CLensFlareItem*)LoadItemByName(fullItemName);
if (pLensFlareItem == NULL)
{
return false;
}
LensFlareUtil::CopyOptics(pLensFlareItem->GetOptics(), pDestOptics, true);
return true;
}
//////////////////////////////////////////////////////////////////////////
void CLensFlareManager::Modified()
{
CLensFlareEditor* pEditor = CLensFlareEditor::GetLensFlareEditor();
if (pEditor == NULL)
{
return;
}
if (pEditor->GetCurrentLibrary())
{
pEditor->GetCurrentLibrary()->SetModified(true);
}
}
//////////////////////////////////////////////////////////////////////////
IDataBaseLibrary* CLensFlareManager::LoadLibrary(const QString& filename, [[maybe_unused]] bool bReload)
{
CLensFlareEditor* pEditor = CLensFlareEditor::GetLensFlareEditor();
QString fileNameWithGameFolder(filename);
fileNameWithGameFolder.replace('\\', '/');
int nGamePathLength = static_cast<int>(Path::GetEditingGameDataFolder().size());
QString gamePathName;
if (nGamePathLength < filename.length())
{
gamePathName = filename.left(nGamePathLength);
}
if (gamePathName != Path::GetEditingGameDataFolder().c_str())
{
fileNameWithGameFolder.insert(0, "/");
fileNameWithGameFolder.insert(0, Path::GetEditingGameDataFolder().c_str());
}
int nLibraryIndex(-1);
bool bSameAsCurrentLibrary(false);
for (int i = 0; i < m_libs.size(); i++)
{
if (QString::compare(fileNameWithGameFolder, m_libs[i]->GetFilename(), Qt::CaseInsensitive) == 0)
{
IDataBaseLibrary* pExistingLib = m_libs[i];
for (int j = 0; j < pExistingLib->GetItemCount(); j++)
{
UnregisterItem((CBaseLibraryItem*)pExistingLib->GetItem(j));
}
pExistingLib->RemoveAllItems();
nLibraryIndex = i;
if (pEditor)
{
bSameAsCurrentLibrary = pEditor->GetCurrentLibrary() == pExistingLib;
}
break;
}
}
TSmartPtr<CBaseLibrary> pLib = MakeNewLibrary();
if (!pLib->Load(filename))
{
Error(QObject::tr("Failed to Load Item Library: %1").arg(filename).toUtf8().data());
return NULL;
}
if (nLibraryIndex != -1)
{
m_libs[nLibraryIndex] = pLib;
if (bSameAsCurrentLibrary && pEditor)
{
pEditor->ResetElementTreeControl();
pEditor->SelectLibrary(pLib, true);
}
}
else
{
m_libs.push_back(pLib);
}
pLib->SetFilename(filename);
return pLib;
}
bool CLensFlareManager::IsLensFlareLibraryXML(const char* fileSourceFilePath)
{
if ((!fileSourceFilePath) || (!AZStd::wildcard_match("*.xml", fileSourceFilePath)))
{
return false;
}
using namespace AZ::IO;
bool isLensFlareLibrary = false;
// we are forced to read the asset to discover its type since "xml" was the chosen extension.
SystemFile::SizeType fileSize = SystemFile::Length(fileSourceFilePath);
if (fileSize > 0)
{
AZStd::vector<char> buffer(fileSize + 1);
buffer[fileSize] = 0;
if (!AZ::IO::SystemFile::Read(fileSourceFilePath, buffer.data(), fileSize))
{
return false;
}
AZ::rapidxml::xml_document<char>* xmlDoc = azcreate(AZ::rapidxml::xml_document<char>, (), AZ::SystemAllocator, "LensFlareLibrary Temp XML Reader");
if (xmlDoc->parse<AZ::rapidxml::parse_no_data_nodes>(buffer.data()))
{
AZ::rapidxml::xml_node<char>* xmlRootNode = xmlDoc->first_node();
if (xmlRootNode)
{
if (azstricmp(xmlRootNode->name(), "LensFlareLibrary") == 0)
{
isLensFlareLibrary = true;
}
}
}
azdestroy(xmlDoc, AZ::SystemAllocator, AZ::rapidxml::xml_document<char>);
}
return isLensFlareLibrary;
}
AzToolsFramework::AssetBrowser::SourceFileDetails CLensFlareManager::GetSourceFileDetails(const char* fullSourceFileName)
{
if (IsLensFlareLibraryXML(fullSourceFileName))
{
return AzToolsFramework::AssetBrowser::SourceFileDetails("Editor/Icons/AssetBrowser/LensFlare_16.png");
}
return AzToolsFramework::AssetBrowser::SourceFileDetails();
}

Some files were not shown because too many files have changed in this diff Show More