merge main

This commit is contained in:
sphrose
2021-05-04 16:41:24 +01:00
9671 changed files with 142654 additions and 716493 deletions
+1 -1
View File
@@ -2,4 +2,4 @@
SDKs
#ignore these files
*.user
*.user
+1 -1
View File
@@ -12,4 +12,4 @@
# Plugins should be processed before because we are going to generate the list of plugins
# that the editor should load
add_subdirectory(Plugins)
add_subdirectory(Editor)
add_subdirectory(Editor)
-6
View File
@@ -20,7 +20,6 @@
#include "2DViewport.h"
#include "CryEditDoc.h"
#include "DisplaySettings.h"
#include "EditTool.h"
#include "GameEngine.h"
#include "Settings.h"
#include "ViewManager.h"
@@ -1117,11 +1116,6 @@ void Q2DViewport::DrawObjects(DisplayContext& dc)
GetIEditor()->GetObjectManager()->Display(dc);
}
// Display editing tool.
if (GetEditTool())
{
GetEditTool()->Display(dc);
}
dc.PopMatrix();
}
+1 -1
View File
@@ -56,7 +56,7 @@ CAboutDialog::CAboutDialog(QString versionText, QString richTextCopyrightNotice,
m_backgroundImage = QPixmap::fromImage(backgroundImage.scaled(m_enforcedWidth, m_enforcedHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
// Draw the Open 3D Engine logo from svg
m_ui->m_logo->load(QStringLiteral(":/StartupLogoDialog/lumberyard_logo.svg"));
m_ui->m_logo->load(QStringLiteral(":/StartupLogoDialog/o3de_logo.svg"));
// Prevent re-sizing
setFixedSize(m_enforcedWidth, m_enforcedHeight);
+34 -29
View File
@@ -60,35 +60,35 @@
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_42">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QSvgWidget" name="m_logo" native="true">
<property name="minimumSize">
<size>
<width>250</width>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>250</width>
<height>60</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_42">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QSvgWidget" name="m_logo" native="true">
<property name="minimumSize">
<size>
<width>161</width>
<height>49</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>161</width>
<height>49</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="m_transparentVersion">
<property name="text">
@@ -251,6 +251,11 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QSvgWidget</class>
<extends>QWidget</extends>
<header>qsvgwidget.h</header>
</customwidget>
<customwidget>
<class>ClickableLabel</class>
<extends>QLabel</extends>
@@ -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);
}
-142
View File
@@ -1,142 +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 "AlignTool.h"
// Editor
#include "Objects/BaseObject.h"
#include "Objects/SelectionGroup.h"
//////////////////////////////////////////////////////////////////////////
bool CAlignPickCallback::m_bActive = false;
//////////////////////////////////////////////////////////////////////////
//! Called when object picked.
void CAlignPickCallback::OnPick(CBaseObject* picked)
{
Matrix34 pickedTM(picked->GetWorldTM());
AABB pickedAABB;
picked->GetBoundBox(pickedAABB);
pickedAABB.Move(-pickedTM.GetTranslation());
Vec3 pickedPivot = pickedAABB.GetCenter();
AABB pickedLocalAABB;
picked->GetLocalBounds(pickedLocalAABB);
const Quat& pickedRot = picked->GetRotation();
const Vec3& pickedScale = picked->GetScale();
const Vec3& pickedPos = picked->GetPos();
bool bKeepScale = CheckVirtualKey(Qt::Key_Shift);
bool bKeepRotation = CheckVirtualKey(Qt::Key_Alt);
bool bAlignToBoundBox = CheckVirtualKey(Qt::Key_Control);
bool bApplyTransform = !bKeepScale && !bKeepRotation && !bAlignToBoundBox;
{
bool bUndo = !CUndo::IsRecording();
if (bUndo)
{
GetIEditor()->BeginUndo();
}
CSelectionGroup* selGroup = GetIEditor()->GetSelection();
selGroup->FilterParents();
for (int i = 0; i < selGroup->GetFilteredCount(); i++)
{
CBaseObject* pMovedObj = selGroup->GetFilteredObject(i);
if (bKeepScale || bKeepRotation || bApplyTransform)
{
if (bKeepScale && bKeepRotation) // Keep scale and rotation of a moved object
{
pMovedObj->SetWorldTM(Matrix34::Create(pMovedObj->GetScale(), pMovedObj->GetRotation(), pickedPos), eObjectUpdateFlags_UserInput);
}
else if (bKeepScale) // Keep only scale of a moved object
{
pMovedObj->SetWorldTM(Matrix34::Create(pMovedObj->GetScale(), pickedRot, pickedPos), eObjectUpdateFlags_UserInput);
}
else if (bKeepRotation) // Keep only rotation of a moved object
{
pMovedObj->SetWorldTM(Matrix34::Create(pickedScale, pMovedObj->GetRotation(), pickedPos), eObjectUpdateFlags_UserInput);
}
else // Scale, Rotation and Position of a picked object are applied to a moved object.
{
pMovedObj->SetWorldTM(pickedTM, eObjectUpdateFlags_UserInput);
}
}
else if (bAlignToBoundBox) // align to the bounding box.
{
if (pickedLocalAABB.GetVolume() == 0.0f)
{
continue;
}
AABB movedLocalAABB;
pMovedObj->GetLocalBounds(movedLocalAABB);
if (fabs(movedLocalAABB.max.x - movedLocalAABB.min.x) < VEC_EPSILON &&
fabs(movedLocalAABB.max.y - movedLocalAABB.min.y) < VEC_EPSILON &&
fabs(movedLocalAABB.max.z - movedLocalAABB.min.z) < VEC_EPSILON)
{
continue;
}
const Vec3& movedScale(pMovedObj->GetScale());
Matrix34 movedScaleTM = Matrix34::CreateScale(movedScale);
AABB movedLocalScaledAABB;
movedLocalScaledAABB.min = movedScaleTM.TransformVector(movedLocalAABB.min);
movedLocalScaledAABB.max = movedScaleTM.TransformVector(movedLocalAABB.max);
float fMovedWidth = movedLocalScaledAABB.max.x - movedLocalScaledAABB.min.x;
float fMovedHeight = movedLocalScaledAABB.max.z - movedLocalScaledAABB.min.z;
float fMovedLength = movedLocalScaledAABB.max.y - movedLocalScaledAABB.min.y;
Matrix34 pickedScaleTM = Matrix34::CreateScale(picked->GetScale());
AABB pickedLocalScaledAABB;
pickedLocalScaledAABB.min = pickedScaleTM.TransformVector(pickedLocalAABB.min);
pickedLocalScaledAABB.max = pickedScaleTM.TransformVector(pickedLocalAABB.max);
float fScaledPickedtWidth = pickedLocalScaledAABB.max.x - pickedLocalScaledAABB.min.x;
float fScaledPickedHeight = pickedLocalScaledAABB.max.z - pickedLocalScaledAABB.min.z;
float fScaledPickedLength = pickedLocalScaledAABB.max.y - pickedLocalScaledAABB.min.y;
Vec3 scale((fScaledPickedtWidth / fMovedWidth) * movedScale.x, (fScaledPickedLength / fMovedLength) * movedScale.y, (fScaledPickedHeight / fMovedHeight) * movedScale.z);
Matrix34 scaleRotTM = Matrix34::Create(scale, pickedRot, Vec3(0, 0, 0));
Vec3 movedPivot = scaleRotTM.TransformVector(movedLocalAABB.GetCenter());
pMovedObj->SetWorldTM(Matrix34::Create(scale, pickedRot, Vec3(pickedPos + (pickedPivot - movedPivot))), eObjectUpdateFlags_UserInput);
}
}
m_bActive = false;
if (bUndo)
{
GetIEditor()->AcceptUndo("Align To Object");
}
}
delete this;
}
//! Called when pick mode cancelled.
void CAlignPickCallback::OnCancelPick()
{
m_bActive = false;
delete this;
}
//! Return true if specified object is pickable.
bool CAlignPickCallback::OnPickFilter([[maybe_unused]] CBaseObject* filterObject)
{
return true;
};
-40
View File
@@ -1,40 +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_ALIGNTOOL_H
#define CRYINCLUDE_EDITOR_ALIGNTOOL_H
#pragma once
//////////////////////////////////////////////////////////////////////////
class CAlignPickCallback
: public IPickObjectCallback
{
public:
CAlignPickCallback() { m_bActive = true; };
//! Called when object picked.
virtual void OnPick(CBaseObject* picked);
//! Called when pick mode cancelled.
virtual void OnCancelPick();
//! Return true if specified object is pickable.
virtual bool OnPickFilter(CBaseObject* filterObject);
static bool IsActive() { return m_bActive; }
virtual bool IsNeedSpecificBehaviorForSpaceAcce() { return true; }
private:
static bool m_bActive;
};
#endif // CRYINCLUDE_EDITOR_ALIGNTOOL_H
@@ -35,4 +35,4 @@ namespace EditorAnimationBones
}
#endif // CRYINCLUDE_EDITOR_ANIMATION_ANIMATIONBIPEDBONENAMES_H
#endif // CRYINCLUDE_EDITOR_ANIMATION_ANIMATIONBIPEDBONENAMES_H
@@ -36,4 +36,4 @@ namespace AssetDatabase
AzToolsFramework::AssetDatabase::AssetDatabaseConnection* m_assetDatabaseConnection = nullptr;
};
}//namespace AssetDatabase
}//namespace AssetDatabase
@@ -20,6 +20,7 @@
// AzCore
#include <AzCore/Asset/AssetManager.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
#include <AzCore/Utils/Utils.h>
// AzToolsFramework
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
@@ -104,13 +105,9 @@ void AssetEditorWindow::SaveAssetAs(const AZStd::string_view assetPath)
return;
}
const char* engineRoot;
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(engineRoot, &AzToolsFramework::ToolsApplicationRequests::GetEngineRootPath);
auto absoluteAssetPath = AZ::IO::FixedMaxPath(AZ::Utils::GetEnginePath()) / assetPath;
AZStd::string absoluteAssetPath;
AzFramework::StringFunc::Path::Join(engineRoot, assetPath.data(), absoluteAssetPath);
if (!m_ui->m_assetEditorWidget->SaveAssetToPath(absoluteAssetPath))
if (!m_ui->m_assetEditorWidget->SaveAssetToPath(absoluteAssetPath.Native()))
{
AZ_Warning("Asset Editor", false, "File was not saved correctly via SaveAssetAs.");
}
@@ -31,4 +31,4 @@ public:
};
using CommandManagerRequestBus = AZ::EBus<CommandManagerRequests>;
using CommandManagerRequestBus = AZ::EBus<CommandManagerRequests>;
+1 -1
View File
@@ -136,4 +136,4 @@ void CControlMRU::OnCalcDynamicSize(DWORD dwMode)
m_dwHideFlags = 0;
SetEnabled(FALSE);
}
}
}
@@ -365,10 +365,6 @@ bool CPreviewModelCtrl::Render()
}
_smart_ptr<IMaterial> pMaterial;
if (m_pCurrentMaterial)
{
pMaterial = m_pCurrentMaterial->GetMatInfo();
}
if (m_bPrecacheMaterial)
{
@@ -430,11 +426,6 @@ bool CPreviewModelCtrl::Render()
m_pRenderer->EF_ADDDlight(&m_lights[i], passInfo);
}
if (m_pCurrentMaterial)
{
m_pCurrentMaterial->DisableHighlightForFrame();
}
if (m_bShowObject)
{
RenderObject(pMaterial, passInfo);
@@ -778,32 +769,6 @@ void CPreviewModelCtrl::SetRotation(bool bEnable)
m_bRotate = bEnable;
}
void CPreviewModelCtrl::SetMaterial(CMaterial* pMaterial)
{
if (pMaterial)
{
if ((pMaterial->GetFlags() & MTL_FLAG_NOPREVIEW))
{
m_pCurrentMaterial = 0;
if (isVisible())
{
update();
}
return;
}
}
m_pCurrentMaterial = pMaterial;
if (isVisible())
{
update();
}
}
CMaterial* CPreviewModelCtrl::GetMaterial()
{
return m_pCurrentMaterial;
}
void CPreviewModelCtrl::OnEditorNotifyEvent(EEditorNotifyEvent event)
{
switch (event)
@@ -22,8 +22,6 @@
#include <IStatObj.h>
#include <Editor/Material/Material.h>
#endif
struct IRenderNode;
@@ -71,9 +69,6 @@ public:
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);
@@ -192,7 +187,6 @@ protected:
float m_tileY;
float m_tileSizeX;
float m_tileSizeY;
_smart_ptr<CMaterial> m_pCurrentMaterial;
CameraChangeCallback m_cameraChangeCallback;
void* m_pCameraChangeUserData;
@@ -1,588 +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 "QRollupCtrl.h"
// Qt
#include <QMenu>
#include <QStylePainter>
#include <QVBoxLayout>
#include <QSettings>
#include <QToolButton>
#include <QStyleOptionToolButton>
//////////////////////////////////////////////////////////////////////////
class QRollupCtrlButton
: public QToolButton
{
public:
QRollupCtrlButton(QWidget* parent);
inline void setSelected(bool b) { selected = b; update(); }
inline bool isSelected() const { return selected; }
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
protected:
void paintEvent(QPaintEvent*) override;
private:
bool selected;
};
QRollupCtrlButton::QRollupCtrlButton(QWidget* parent)
: QToolButton(parent)
, selected(true)
{
setBackgroundRole(QPalette::Window);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
setFocusPolicy(Qt::NoFocus);
setStyleSheet("* {margin: 2px 5px 2px 5px; border: 1px solid #CBA457;}");
}
QSize QRollupCtrlButton::sizeHint() const
{
QSize iconSize(8, 8);
if (!icon().isNull())
{
int icone = style()->pixelMetric(QStyle::PM_SmallIconSize);
iconSize += QSize(icone + 2, icone);
}
QSize textSize = fontMetrics().size(Qt::TextShowMnemonic, text()) + QSize(0, 8);
QSize total(iconSize.width() + textSize.width(), qMax(iconSize.height(), textSize.height()));
return total.expandedTo(QApplication::globalStrut());
}
QSize QRollupCtrlButton::minimumSizeHint() const
{
if (icon().isNull())
{
return QSize();
}
int icone = style()->pixelMetric(QStyle::PM_SmallIconSize);
return QSize(icone + 8, icone + 8);
}
void QRollupCtrlButton::paintEvent(QPaintEvent*)
{
QStylePainter p(this);
// draw the background manually, not to clash with UI 2.0 style shets
// the numbers here are taken from the stylesheet in the constructor
p.fillRect(QRect(5, 1, width() - 10, height() - 3), QColor(52, 52, 52));
{
QStyleOptionToolButton opt;
initStyleOption(&opt);
if (isSelected())
{
if (opt.state & QStyle::State_MouseOver)
{
opt.state |= QStyle::State_Sunken;
}
opt.state |= QStyle::State_MouseOver;
}
p.drawComplexControl(QStyle::CC_ToolButton, opt);
}
{
p.setPen(QPen(QColor(132, 128, 125)));
int top = height() / 2 - 2;
p.drawLine(2, top, 4, top);
p.drawLine(width() - 5, top, width() - 3, top);
int bottom = !isSelected() ? top + 4 : height();
p.drawLine(2, bottom, 2, top);
p.drawLine(width() - 3, bottom, width() - 3, top);
if (!isSelected())
{
p.drawLine(2, bottom, 4, bottom);
p.drawLine(width() - 5, bottom, width() - 3, bottom);
}
}
}
//////////////////////////////////////////////////////////////////////////
QRollupCtrl::Page* QRollupCtrl::page(QWidget* widget) const
{
if (!widget)
{
return 0;
}
for (PageList::ConstIterator i = m_pageList.constBegin(); i != m_pageList.constEnd(); ++i)
{
if ((*i).widget == widget)
{
return (Page*)&(*i);
}
}
return 0;
}
QRollupCtrl::Page* QRollupCtrl::page(int index)
{
if (index >= 0 && index < m_pageList.size())
{
return &m_pageList[index];
}
return 0;
}
const QRollupCtrl::Page* QRollupCtrl::page(int index) const
{
if (index >= 0 && index < m_pageList.size())
{
return &m_pageList.at(index);
}
return 0;
}
inline void QRollupCtrl::Page::setText(const QString& text) { button->setText(text); }
inline void QRollupCtrl::Page::setIcon(const QIcon& is) { button->setIcon(is); }
inline void QRollupCtrl::Page::setToolTip(const QString& tip) { button->setToolTip(tip); }
inline QString QRollupCtrl::Page::text() const { return button->text(); }
inline QIcon QRollupCtrl::Page::icon() const { return button->icon(); }
inline QString QRollupCtrl::Page::toolTip() const { return button->toolTip(); }
//////////////////////////////////////////////////////////////////////////
QRollupCtrl::QRollupCtrl(QWidget* parent)
: QScrollArea(parent)
, m_layout(0)
{
m_body = new QWidget(this);
m_body->setBackgroundRole(QPalette::Button);
setWidgetResizable(true);
setAlignment(Qt::AlignLeft | Qt::AlignTop);
setWidget(m_body);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
relayout();
}
QRollupCtrl::~QRollupCtrl()
{
foreach(const QRollupCtrl::Page & c, m_pageList)
disconnect(c.widget, &QObject::destroyed, this, &QRollupCtrl::_q_widgetDestroyed);
}
void QRollupCtrl::readSettings(const QString& qSettingsGroup)
{
QSettings settings;
settings.beginGroup(qSettingsGroup);
int i = 0;
foreach(const QRollupCtrl::Page & c, m_pageList) {
QString qObjectName = c.widget->objectName();
bool bHidden = settings.value(qObjectName, true).toBool();
setIndexVisible(i++, !bHidden);
}
settings.endGroup();
}
void QRollupCtrl::writeSettings(const QString& qSettingsGroup)
{
QSettings settings;
settings.beginGroup(qSettingsGroup);
for (int i = 0; i < count(); i++)
{
QString qObjectName;
bool bHidden = isPageHidden(i, qObjectName);
settings.setValue(qObjectName, bHidden);
}
}
void QRollupCtrl::updateTabs()
{
for (auto i = m_pageList.constBegin(); i != m_pageList.constEnd(); ++i)
{
QRollupCtrlButton* tB = (*i).button;
QWidget* tW = (*i).sv;
tB->setSelected(tW->isVisible());
tB->update();
}
}
int QRollupCtrl::insertItem(int index, QWidget* widget, const QIcon& icon, const QString& text)
{
if (!widget)
{
return -1;
}
auto it = std::find_if(m_pageList.cbegin(), m_pageList.cend(), [widget](const Page& page) { return page.widget == widget; });
if (it != m_pageList.cend())
{
return -1;
}
connect(widget, &QObject::destroyed, this, &QRollupCtrl::_q_widgetDestroyed);
QRollupCtrl::Page c;
c.widget = widget;
c.button = new QRollupCtrlButton(m_body);
c.button->setContextMenuPolicy(Qt::CustomContextMenu);
connect(c.button, &QRollupCtrlButton::clicked, this, &QRollupCtrl::_q_buttonClicked);
connect(c.button, &QRollupCtrlButton::customContextMenuRequested, this, &QRollupCtrl::_q_custumButtonMenu);
c.sv = new QFrame(m_body);
c.sv->setObjectName("rollupPaneFrame");
// c.sv->setFixedHeight(qMax(widget->sizeHint().height(), widget->size().height()));
QVBoxLayout* layout = new QVBoxLayout;
layout->setMargin(3);
layout->addWidget(widget);
c.sv->setLayout(layout);
c.sv->setStyleSheet("QFrame#rollupPaneFrame {margin: 0px 2px 2px 2px; border: 1px solid #84807D; border-top:0px;}");
c.sv->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
c.sv->show();
c.setText(text);
c.setIcon(icon);
const int numPages = m_pageList.count();
if (index < 0 || index >= numPages)
{
m_pageList.append(c);
index = numPages - 1;
m_layout->insertWidget(m_layout->count() - 1, c.button);
m_layout->insertWidget(m_layout->count() - 1, c.sv);
}
else
{
m_pageList.insert(index, c);
relayout();
}
c.button->show();
updateTabs();
itemInserted(index);
return index;
}
void QRollupCtrl::_q_buttonClicked()
{
QObject* tb = sender();
QWidget* item = 0;
for (auto i = m_pageList.constBegin(); i != m_pageList.constEnd(); ++i)
{
if ((*i).button == tb)
{
item = (*i).widget;
break;
}
}
if (item)
{
setIndexVisible(indexOf(item), !item->isVisible());
}
}
int QRollupCtrl::count() const
{
return m_pageList.count();
}
bool QRollupCtrl::isPageHidden(int index, QString& qObjectName) const
{
if (index < 0 || index >= m_pageList.size())
{
return true;
}
const QRollupCtrl::Page& c = m_pageList.at(index);
qObjectName = c.widget->objectName();
return c.sv->isHidden();
}
void QRollupCtrl::setIndexVisible(int index, bool visible)
{
QRollupCtrl::Page* c = page(index);
if (!c)
{
return;
}
if (c->sv->isHidden() && visible)
{
c->sv->show();
}
else if (c->sv->isVisible() && !visible)
{
c->sv->hide();
}
updateTabs();
}
void QRollupCtrl::setWidgetVisible(QWidget* widget, bool visible)
{
setIndexVisible(indexOf(widget), visible);
}
void QRollupCtrl::relayout()
{
delete m_layout;
m_layout = new QVBoxLayout(m_body);
m_layout->setMargin(3);
m_layout->setSpacing(0);
for (QRollupCtrl::PageList::ConstIterator i = m_pageList.constBegin(); i != m_pageList.constEnd(); ++i)
{
m_layout->addWidget((*i).button);
m_layout->addWidget((*i).sv);
}
m_layout->addStretch();
updateTabs();
}
void QRollupCtrl::_q_widgetDestroyed(QObject* object)
{
// no verification - vtbl corrupted already
QWidget* p = (QWidget*)object;
QRollupCtrl::Page* c = page(p);
if (!p || !c)
{
return;
}
m_layout->removeWidget(c->sv);
m_layout->removeWidget(c->button);
c->sv->deleteLater(); // page might still be a child of sv
delete c->button;
m_pageList.removeOne(*c);
}
void QRollupCtrl::_q_custumButtonMenu([[maybe_unused]] const QPoint& pos)
{
QMenu menu;
menu.addAction("Expand All")->setData(-1);
menu.addAction("Collapse All")->setData(-2);
menu.addSeparator();
for (int i = 0; i < m_pageList.size(); ++i)
{
QRollupCtrl::Page* c = page(i);
QAction* action = menu.addAction(c->button->text());
action->setCheckable(true);
action->setChecked(c->sv->isVisible());
action->setData(i);
}
QAction* action = menu.exec(QCursor::pos());
if (!action)
{
return;
}
int res = action->data().toInt();
switch (res)
{
case -1: // fall through
case -2:
expandAllPages(res == -1);
break;
default:
{
QRollupCtrl::Page* c = page(res);
if (c)
{
setIndexVisible(res, !c->sv->isVisible());
}
}
break;
}
}
void QRollupCtrl::expandAllPages(bool v)
{
for (int i = 0; i < m_pageList.size(); i++)
{
setIndexVisible(i, v);
}
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
void QRollupCtrl::clear()
{
while (!m_pageList.isEmpty())
{
removeItem(0);
}
}
void QRollupCtrl::removeItem(QWidget* widget)
{
auto it = std::find_if(m_pageList.cbegin(), m_pageList.cend(), [widget](const Page& page) { return page.widget == widget; });
if (it != m_pageList.cend())
{
removeItem(it - m_pageList.cbegin());
}
}
void QRollupCtrl::removeItem(int index)
{
if (QWidget* w = widget(index))
{
disconnect(w, &QObject::destroyed, this, &QRollupCtrl::_q_widgetDestroyed);
w->setParent(this);
// destroy internal data
_q_widgetDestroyed(w);
itemRemoved(index);
}
}
QWidget* QRollupCtrl::widget(int index) const
{
if (index < 0 || index >= (int) m_pageList.size())
{
return 0;
}
return m_pageList.at(index).widget;
}
int QRollupCtrl::indexOf(QWidget* widget) const
{
QRollupCtrl::Page* c = page(widget);
return c ? m_pageList.indexOf(*c) : -1;
}
void QRollupCtrl::setItemEnabled(int index, bool enabled)
{
QRollupCtrl::Page* c = page(index);
if (!c)
{
return;
}
c->button->setEnabled(enabled);
if (!enabled)
{
int curIndexUp = index;
int curIndexDown = curIndexUp;
const int count = m_pageList.count();
while (curIndexUp > 0 || curIndexDown < count - 1)
{
if (curIndexDown < count - 1)
{
if (page(++curIndexDown)->button->isEnabled())
{
index = curIndexDown;
break;
}
}
if (curIndexUp > 0)
{
if (page(--curIndexUp)->button->isEnabled())
{
index = curIndexUp;
break;
}
}
}
}
}
void QRollupCtrl::setItemText(int index, const QString& text)
{
QRollupCtrl::Page* c = page(index);
if (c)
{
c->setText(text);
}
}
void QRollupCtrl::setItemIcon(int index, const QIcon& icon)
{
QRollupCtrl::Page* c = page(index);
if (c)
{
c->setIcon(icon);
}
}
void QRollupCtrl::setItemToolTip(int index, const QString& toolTip)
{
QRollupCtrl::Page* c = page(index);
if (c)
{
c->setToolTip(toolTip);
}
}
bool QRollupCtrl::isItemEnabled(int index) const
{
const QRollupCtrl::Page* c = page(index);
return c && c->button->isEnabled();
}
QString QRollupCtrl::itemText(int index) const
{
const QRollupCtrl::Page* c = page(index);
return (c ? c->text() : QString());
}
QIcon QRollupCtrl::itemIcon(int index) const
{
const QRollupCtrl::Page* c = page(index);
return (c ? c->icon() : QIcon());
}
QString QRollupCtrl::itemToolTip(int index) const
{
const QRollupCtrl::Page* c = page(index);
return (c ? c->toolTip() : QString());
}
void QRollupCtrl::changeEvent(QEvent* ev)
{
if (ev->type() == QEvent::StyleChange)
{
updateTabs();
}
QFrame::changeEvent(ev);
}
void QRollupCtrl::showEvent(QShowEvent* ev)
{
if (isVisible())
{
updateTabs();
}
IEditor* pEditor = GetIEditor();
pEditor->SetEditMode(EEditMode::eEditModeSelect);
QFrame::showEvent(ev);
}
void QRollupCtrl::itemInserted(int index)
{
Q_UNUSED(index)
}
void QRollupCtrl::itemRemoved(int index)
{
Q_UNUSED(index)
}
#include <Controls/moc_QRollupCtrl.cpp>
-126
View File
@@ -1,126 +0,0 @@
#ifndef CRYINCLUDE_EDITOR_CONTROLS_QROLLUPCTRL_H
#define CRYINCLUDE_EDITOR_CONTROLS_QROLLUPCTRL_H
/*
* 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.
*
*/
#if !defined(Q_MOC_RUN)
#include <QFrame>
#include <QScrollArea>
#include <QIcon>
#endif
class QVBoxLayout;
class QRollupCtrlButton;
class QRollupCtrl
: public QScrollArea
{
Q_OBJECT
Q_PROPERTY(int count READ count)
public:
explicit QRollupCtrl(QWidget* parent = 0);
~QRollupCtrl();
int addItem(QWidget* widget, const QString& text);
int addItem(QWidget* widget, const QIcon& icon, const QString& text);
int insertItem(int index, QWidget* widget, const QString& text);
int insertItem(int index, QWidget* widget, const QIcon& icon, const QString& text);
void clear();
void removeItem(QWidget* widget);
void removeItem(int index);
void setItemEnabled(int index, bool enabled);
bool isItemEnabled(int index) const;
void setItemText(int index, const QString& text);
QString itemText(int index) const;
void setItemIcon(int index, const QIcon& icon);
QIcon itemIcon(int index) const;
void setItemToolTip(int index, const QString& toolTip);
QString itemToolTip(int index) const;
QWidget* widget(int index) const;
int indexOf(QWidget* widget) const;
int count() const;
void readSettings (const QString& qSettingsGroup);
void writeSettings(const QString& qSettingsGroup);
public slots:
void setIndexVisible(int index, bool visible);
void setWidgetVisible(QWidget* widget, bool visible);
void expandAllPages(bool v);
protected:
virtual void itemInserted(int index);
virtual void itemRemoved(int index);
void changeEvent(QEvent*) override;
void showEvent(QShowEvent*) override;
private:
Q_DISABLE_COPY(QRollupCtrl)
struct Page
{
QRollupCtrlButton* button;
QFrame* sv;
QWidget* widget;
void setText(const QString& text);
void setIcon(const QIcon& is);
void setToolTip(const QString& tip);
QString text() const;
QIcon icon() const;
QString toolTip() const;
inline bool operator==(const Page& other) const
{
return widget == other.widget;
}
};
typedef QList<Page> PageList;
Page* page(QWidget* widget) const;
const Page* page(int index) const;
Page* page(int index);
void updateTabs();
void relayout();
bool isPageHidden(int index, QString& qObjectName) const;
QWidget* m_body;
PageList m_pageList;
QVBoxLayout* m_layout;
private slots:
void _q_buttonClicked();
void _q_widgetDestroyed(QObject*);
void _q_custumButtonMenu(const QPoint&);
};
//////////////////////////////////////////////////////////////////////////
inline int QRollupCtrl::addItem(QWidget* item, const QString& text)
{ return insertItem(-1, item, QIcon(), text); }
inline int QRollupCtrl::addItem(QWidget* item, const QIcon& iconSet, const QString& text)
{ return insertItem(-1, item, iconSet, text); }
inline int QRollupCtrl::insertItem(int index, QWidget* item, const QString& text)
{ return insertItem(index, item, QIcon(), text); }
#endif
@@ -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();
}
-171
View File
@@ -1,171 +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"
// Editor
#include "CryEditDoc.h"
#include "EditTool.h"
#include "ToolButton.h"
QEditorToolButton::QEditorToolButton(QWidget* parent /* = nullptr */)
: QPushButton(parent)
, m_styleSheet(styleSheet())
, m_toolClass(nullptr)
, m_toolCreated(nullptr)
, m_needDocument(true)
{
setSizePolicy({ QSizePolicy::Expanding, QSizePolicy::Fixed });
connect(this, &QAbstractButton::clicked, this, &QEditorToolButton::OnClicked);
GetIEditor()->RegisterNotifyListener(this);
}
QEditorToolButton::~QEditorToolButton()
{
GetIEditor()->UnregisterNotifyListener(this);
}
void QEditorToolButton::SetToolName(const QString& editToolName, const QString& userDataKey, void* userData)
{
IClassDesc* klass = GetIEditor()->GetClassFactory()->FindClass(editToolName.toUtf8().data());
if (!klass)
{
Warning(QStringLiteral("Editor Tool %1 not registered.").arg(editToolName).toUtf8().data());
return;
}
if (klass->SystemClassID() != ESYSTEM_CLASS_EDITTOOL)
{
Warning(QStringLiteral("Class name %1 is not a valid Edit Tool class.").arg(editToolName).toUtf8().data());
return;
}
QScopedPointer<QObject> o(klass->CreateQObject());
if (!qobject_cast<CEditTool*>(o.data()))
{
Warning(QStringLiteral("Class name %1 is not a valid Edit Tool class.").arg(editToolName).toUtf8().data());
return;
}
SetToolClass(o->metaObject(), userDataKey, userData);
}
//////////////////////////////////////////////////////////////////////////
void QEditorToolButton::SetToolClass(const QMetaObject* toolClass, const QString& userDataKey, void* userData)
{
m_toolClass = toolClass;
m_userData = userData;
if (!userDataKey.isEmpty())
{
m_userDataKey = userDataKey;
}
}
void QEditorToolButton::OnEditorNotifyEvent(EEditorNotifyEvent event)
{
switch (event)
{
case eNotify_OnBeginNewScene:
case eNotify_OnBeginLoad:
case eNotify_OnBeginSceneOpen:
{
if (m_needDocument)
{
setEnabled(false);
}
break;
}
case eNotify_OnEndNewScene:
case eNotify_OnEndLoad:
case eNotify_OnEndSceneOpen:
{
if (m_needDocument)
{
setEnabled(true);
}
break;
}
case eNotify_OnEditToolChange:
{
CEditTool* tool = GetIEditor()->GetEditTool();
if (!tool || tool != m_toolCreated || tool->metaObject() != m_toolClass)
{
m_toolCreated = nullptr;
SetSelected(false);
}
}
default:
break;
}
}
void QEditorToolButton::OnClicked()
{
if (!m_toolClass)
{
return;
}
if (m_needDocument && !GetIEditor()->GetDocument()->IsDocumentReady())
{
return;
}
CEditTool* tool = GetIEditor()->GetEditTool();
if (tool && tool->IsMoveToObjectModeAfterEnd() && tool->metaObject() == m_toolClass && tool == m_toolCreated)
{
GetIEditor()->SetEditTool(nullptr);
SetSelected(false);
}
else
{
CEditTool* newTool = qobject_cast<CEditTool*>(m_toolClass->newInstance());
if (!newTool)
{
return;
}
m_toolCreated = newTool;
SetSelected(true);
if (m_userData)
{
newTool->SetUserData(m_userDataKey.toUtf8().data(), (void*)m_userData);
}
update();
// Must be last function, can delete this.
GetIEditor()->SetEditTool(newTool);
}
}
void QEditorToolButton::SetSelected(bool selected)
{
if (selected)
{
setStyleSheet(QStringLiteral("QPushButton { background-color: palette(highlight); color: palette(highlighted-text); }"));
}
else
{
setStyleSheet(m_styleSheet);
}
}
#include <Controls/moc_ToolButton.cpp>
-60
View File
@@ -1,60 +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_TOOLBUTTON_H
#define CRYINCLUDE_EDITOR_CONTROLS_TOOLBUTTON_H
#pragma once
// ToolButton.h : header file
//
#if !defined(Q_MOC_RUN)
#include <AzCore/PlatformDef.h>
#include <QPushButton>
#endif
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
class SANDBOX_API QEditorToolButton
: public QPushButton
, public IEditorNotifyListener
{
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
Q_OBJECT
// Construction
public:
QEditorToolButton(QWidget* parent = nullptr);
virtual ~QEditorToolButton();
void SetToolClass(const QMetaObject* toolClass, const QString& userDataKey = 0, void* userData = nullptr);
void SetToolName(const QString& editToolName, const QString& userDataKey = 0, void* userData = nullptr);
// Set if this tool button relies on a loaded level / ready document. By default every tool button only works if a level is loaded.
// However some tools are also used without a loaded level (e.g. UI Emulator)
void SetNeedDocument(bool needDocument) { m_needDocument = needDocument; }
void SetSelected(bool selected);
void OnEditorNotifyEvent(EEditorNotifyEvent event) override;
protected:
void OnClicked();
const QString m_styleSheet;
//! Tool associated with this button.
const QMetaObject* m_toolClass;
CEditTool* m_toolCreated;
QString m_userDataKey;
void* m_userData;
bool m_needDocument;
};
#endif // CRYINCLUDE_EDITOR_CONTROLS_TOOLBUTTON_H
@@ -458,8 +458,6 @@ QMenu* LevelEditorMenuHandler::CreateFileMenu()
void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMenu)
{
const bool newViewportInteractionModelEnabled = GetIEditor()->IsNewViewportInteractionModelEnabled();
// Undo
editMenu.AddAction(ID_UNDO);
@@ -496,40 +494,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,73 +551,15 @@ 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 alignMenu = modifyMenu.AddMenu(tr("Align"));
alignMenu.AddAction(ID_OBJECTMODIFY_ALIGNTOGRID);
alignMenu.AddAction(ID_OBJECTMODIFY_ALIGN);
alignMenu.AddAction(ID_MODIFY_ALIGNOBJTOSURF);
auto constrainMenu = modifyMenu.AddMenu(tr("Constrain"));
constrainMenu.AddAction(ID_SELECT_AXIS_X);
constrainMenu.AddAction(ID_SELECT_AXIS_Y);
constrainMenu.AddAction(ID_SELECT_AXIS_Z);
constrainMenu.AddAction(ID_SELECT_AXIS_XY);
constrainMenu.AddAction(ID_SELECT_AXIS_TERRAIN);
}
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"));
if (!newViewportInteractionModelEnabled)
{
transformModeMenu.AddAction(ID_EDITMODE_SELECT);
}
transformModeMenu.AddAction(ID_EDITMODE_MOVE);
transformModeMenu.AddAction(ID_EDITMODE_ROTATE);
transformModeMenu.AddAction(ID_EDITMODE_SCALE);
if (!newViewportInteractionModelEnabled)
{
transformModeMenu.AddAction(ID_EDITMODE_SELECTAREA);
}
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
@@ -747,12 +668,6 @@ QMenu* LevelEditorMenuHandler::CreateGameMenu()
gameMenu.AddSeparator();
if (!GetIEditor()->IsNewViewportInteractionModelEnabled())
{
gameMenu.AddAction(ID_TERRAIN_VEGETATION);
gameMenu.AddSeparator();
}
CreateDebuggingSubMenu(gameMenu);
return gameMenu;
@@ -815,12 +730,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();
@@ -1256,22 +1165,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
-65
View File
@@ -28,7 +28,6 @@
class CCryDocManager;
class CQuickAccessBar;
class CMatEditMainDlg;
class CCryEditDoc;
class CEditCommandLineInfo;
class CMainFrame;
@@ -117,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; }
@@ -211,66 +209,25 @@ 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 OnEditToolLink();
void OnUpdateEditToolLink(QAction* action);
void OnEditToolUnlink();
void OnUpdateEditToolUnlink(QAction* action);
void OnEditmodeSelect();
void OnEditEscape();
void OnObjectSetArea();
void OnObjectSetHeight();
void OnObjectVertexSnapping();
void OnUpdateEditmodeVertexSnapping(QAction* action);
void OnUpdateEditmodeSelect(QAction* action);
void OnUpdateEditmodeMove(QAction* action);
void OnUpdateEditmodeRotate(QAction* action);
void OnUpdateEditmodeScale(QAction* action);
void OnObjectmodifyFreeze();
void OnObjectmodifyUnfreeze();
void OnEditmodeSelectarea();
void OnUpdateEditmodeSelectarea(QAction* action);
void OnSelectAxisX();
void OnSelectAxisY();
void OnSelectAxisZ();
void OnSelectAxisXy();
void OnUpdateSelectAxisX(QAction* action);
void OnUpdateSelectAxisXy(QAction* action);
void OnUpdateSelectAxisY(QAction* action);
void OnUpdateSelectAxisZ(QAction* action);
void OnUndo();
void OnEditClone();
void OnSelectionSave();
void OnOpenAssetImporter();
void OnSelectionLoad();
void OnUpdateSelected(QAction* action);
void OnAlignObject();
void OnAlignToVoxel();
void OnAlignToGrid();
void OnUpdateAlignObject(QAction* action);
void OnUpdateAlignToVoxel(QAction* action);
void OnLockSelection();
void OnEditLevelData();
void OnFileEditLogFile();
void OnFileResaveSlices();
void OnFileEditEditorini();
void OnSelectAxisTerrain();
void OnSelectAxisSnapToAll();
void OnUpdateSelectAxisTerrain(QAction* action);
void OnUpdateSelectAxisSnapToAll(QAction* action);
void OnPreferences();
void OnReloadTextures();
void OnReloadGeometry();
@@ -367,7 +324,6 @@ private:
//! Autotest mode: Special mode meant for automated testing, things like blocking dialogs or error report windows won't appear
bool m_bAutotestMode = false;
CMatEditMainDlg* m_pMatEditDlg = nullptr;
CConsoleDialog* m_pConsoleDialog = nullptr;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
@@ -417,13 +373,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);
@@ -462,29 +411,18 @@ private:
void OnToolsScriptHelp();
void OnViewCycle2dviewport();
void OnDisplayGotoPosition();
void OnDisplaySetVector();
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();
@@ -493,13 +431,10 @@ private:
void OnUpdateSwitchToSelectedCamera(QAction* action);
void OnSwitchcameraNext();
void OnOpenProceduralMaterialEditor();
void OnOpenMaterialEditor();
void OnOpenAssetBrowserView();
void OnOpenTrackView();
void OnOpenAudioControlsEditor();
void OnOpenUICanvasEditor();
void OnGotoViewportSearch();
void OnMaterialPicktool();
void OnTimeOfDay();
void OnChangeGameSpec(UINT nID);
void SetGameSpecCheck(ESystemConfigSpec spec, ESystemConfigPlatform platform, int &nCheck, bool &enable);
+24 -35
View File
@@ -28,6 +28,11 @@
#include <AzFramework/Archive/IArchive.h>
#include <AzFramework/API/ApplicationAPI.h>
#include <AzFramework/API/AtomActiveInterface.h>
#include <AzFramework/Viewport/CameraInput.h>
// Atom
#include <Atom/RPI.Public/ViewportContext.h>
#include <Atom/RPI.Public/ViewportContextBus.h>
// AzToolsFramework
#include <AzToolsFramework/Slice/SliceUtilities.h>
@@ -51,8 +56,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"
@@ -83,7 +86,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,
@@ -279,9 +282,6 @@ void CCryEditDoc::DeleteContents()
// [LY-90904] move this to the EditorVegetationManager component
InstanceStatObjEventBus::Broadcast(&InstanceStatObjEventBus::Events::ReleaseData);
GetIEditor()->SetEditTool(0); // Turn off any active edit tools.
GetIEditor()->SetEditMode(eEditModeSelect);
//////////////////////////////////////////////////////////////////////////
// Clear all undo info.
//////////////////////////////////////////////////////////////////////////
@@ -361,10 +361,6 @@ void CCryEditDoc::Save(TDocMultiArchive& arrXmlAr)
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]));
@@ -519,22 +515,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
//////////////////////////////////////////////////////////////////////////
@@ -672,13 +652,21 @@ void CCryEditDoc::SerializeViewSettings(CXmlArchive& xmlAr)
CViewport* pVP = GetIEditor()->GetViewManager()->GetView(i);
Matrix34 tm = Matrix34::CreateRotationXYZ(va);
tm.SetTranslation(vp);
if (pVP)
{
Matrix34 tm = Matrix34::CreateRotationXYZ(va);
tm.SetTranslation(vp);
pVP->SetViewTM(tm);
}
if (auto viewportContext = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get()->GetDefaultViewportContext())
{
AzFramework::ModernViewportCameraControllerRequestBus::Event(
viewportContext->GetId(), &AzFramework::ModernViewportCameraControllerRequestBus::Events::SetTargetCameraTransform,
LYTransformToAZTransform(tm));
}
// Load grid.
auto gridName = QString("Grid%1").arg(useOldViewFormat ? "" : QString::number(i));
XmlNodeRef gridNode = xmlAr.root->newChild(gridName.toUtf8().constData());
@@ -1167,7 +1155,7 @@ bool CCryEditDoc::OnSaveDocument(const QString& lpszPathName)
{
DoSaveDocument(lpszPathName, context);
saveSuccess = AfterSaveDocument(lpszPathName, context);
}
}
}
return saveSuccess;
@@ -1439,7 +1427,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();
@@ -1461,7 +1449,7 @@ bool CCryEditDoc::SaveLevel(const QString& filename)
}
}
AZStd::vector<AZ::Entity*> editorEntities;
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(
&AzToolsFramework::EditorEntityContextRequestBus::Events::GetLooseEditorEntities,
@@ -1818,7 +1806,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();
@@ -2394,7 +2382,8 @@ void CCryEditDoc::InitEmptyLevel(int /*resolution*/, int /*unitSize*/, bool /*bU
GetIEditor()->GetGameEngine()->SetLevelCreated(false);
// Default time of day.
XmlNodeRef root = GetISystem()->LoadXmlFromFile("@engroot@/Editor/default_time_of_day.xml");
auto defaultTimeOfDayPath = AZ::IO::FixedMaxPath(AZ::Utils::GetEnginePath()) / "Assets" / "Editor" / "default_time_of_day.xml";
XmlNodeRef root = GetISystem()->LoadXmlFromFile(defaultTimeOfDayPath.c_str());
if (root)
{
ITimeOfDay* pTimeOfDay = gEnv->p3DEngine ? gEnv->p3DEngine->GetTimeOfDay() : nullptr;
@@ -2457,7 +2446,7 @@ void CCryEditDoc::CreateDefaultLevelAssets(int resolution, int unitSize)
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(
@@ -2616,7 +2605,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
-1
View File
@@ -216,7 +216,6 @@ protected:
void OnSliceInstantiationFailed(const AZ::Data::AssetId& sliceAssetId, const AzFramework::SliceInstantiationTicket& /*ticket*/) override;
//////////////////////////////////////////////////////////////////////////
QString m_strMasterCDFolder;
bool m_bLoadFailed;
QColor m_waterColor;
XmlNodeRef m_fogTemplate;
+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);
@@ -60,4 +60,4 @@ private:
QStringList BuildModels(QWidget* parent);
};
#endif //CRYINCLUDE_EDITOR_CUSTOMIZE_KEYBOARD_DIALOG_H
#endif //CRYINCLUDE_EDITOR_CUSTOMIZE_KEYBOARD_DIALOG_H
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,123 +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 "ButtonsPanel.h"
// Qt
#include <QGridLayout>
// Editor
#include "Controls/ToolButton.h"
/////////////////////////////////////////////////////////////////////////////
// CButtonsPanel dialog
CButtonsPanel::CButtonsPanel(QWidget* parent)
: QWidget(parent)
{
}
CButtonsPanel::~CButtonsPanel()
{
}
//////////////////////////////////////////////////////////////////////////
void CButtonsPanel::AddButton(const SButtonInfo& button)
{
SButton b;
b.info = button;
m_buttons.push_back(b);
}
//////////////////////////////////////////////////////////////////////////
void CButtonsPanel::AddButton(const QString& name, const QString& toolClass)
{
SButtonInfo bi;
bi.name = name;
bi.toolClassName = toolClass;
AddButton(bi);
}
//////////////////////////////////////////////////////////////////////////
void CButtonsPanel::AddButton(const QString& name, const QMetaObject* pToolClass)
{
SButtonInfo bi;
bi.name = name;
bi.pToolClass = pToolClass;
AddButton(bi);
}
//////////////////////////////////////////////////////////////////////////
void CButtonsPanel::ClearButtons()
{
auto buttons = layout()->findChildren<QEditorToolButton*>();
foreach(auto button, buttons)
{
layout()->removeWidget(button);
delete button;
}
m_buttons.clear();
}
void CButtonsPanel::UncheckAll()
{
for (auto& button : m_buttons)
{
button.pButton->SetSelected(false);
}
}
void CButtonsPanel::OnInitDialog()
{
auto layout = new QGridLayout(this);
setLayout(layout);
layout->setMargin(4);
layout->setHorizontalSpacing(4);
layout->setVerticalSpacing(1);
// Create Buttons.
int index = 0;
for (auto& button : m_buttons)
{
button.pButton = new QEditorToolButton(this);
button.pButton->setObjectName(button.info.name);
button.pButton->setText(button.info.name);
button.pButton->SetNeedDocument(button.info.bNeedDocument);
button.pButton->setToolTip(button.info.toolTip);
if (button.info.pToolClass)
{
button.pButton->SetToolClass(button.info.pToolClass, button.info.toolUserDataKey, (void*)button.info.toolUserData.c_str());
}
else if (!button.info.toolClassName.isEmpty())
{
button.pButton->SetToolName(button.info.toolClassName, button.info.toolUserDataKey, (void*)button.info.toolUserData.c_str());
}
layout->addWidget(button.pButton, index / 2, index % 2);
connect(button.pButton, &QEditorToolButton::clicked, this, [&]() { OnButtonPressed(button.info); });
++index;
}
}
void CButtonsPanel::EnableButton(const QString& buttonName, bool enable)
{
for (auto& button : m_buttons)
{
if (button.pButton->objectName() == buttonName)
{
button.pButton->setEnabled(enable);
}
}
}
#include <Dialogs/moc_ButtonsPanel.cpp>
@@ -1,76 +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_BUTTONSPANEL_H
#define CRYINCLUDE_EDITOR_DIALOGS_BUTTONSPANEL_H
#pragma once
#if !defined(Q_MOC_RUN)
#include <QWidget>
#endif
class QEditorToolButton;
/////////////////////////////////////////////////////////////////////////////
// Panel with custom auto arranged buttons
class CButtonsPanel
: public QWidget
{
Q_OBJECT
public:
struct SButtonInfo
{
QString name;
QString toolClassName;
QString toolUserDataKey;
std::string toolUserData;
QString toolTip;
bool bNeedDocument;
const QMetaObject* pToolClass;
SButtonInfo()
: pToolClass(nullptr)
, bNeedDocument(true) {};
};
CButtonsPanel(QWidget* parent);
virtual ~CButtonsPanel();
virtual void AddButton(const SButtonInfo& button);
virtual void AddButton(const QString& name, const QString& toolClass);
virtual void AddButton(const QString& name, const QMetaObject* pToolClass);
virtual void EnableButton(const QString& buttonName, bool disable);
virtual void ClearButtons();
virtual void OnButtonPressed([[maybe_unused]] const SButtonInfo& button) {};
virtual void UncheckAll();
protected:
void ReleaseGuiButtons();
virtual void OnInitDialog();
//////////////////////////////////////////////////////////////////////////
struct SButton
{
SButtonInfo info;
QEditorToolButton* pButton;
SButton()
: pButton(nullptr) {};
};
std::vector<SButton> m_buttons;
};
#endif // CRYINCLUDE_EDITOR_DIALOGS_BUTTONSPANEL_H
@@ -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>
-25
View File
@@ -22,7 +22,6 @@
// Editor
#include "Settings.h"
#include "Material/MaterialManager.h"
@@ -112,30 +111,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);
}
}
//////////////////////////////////////////////////////////////////////////
File diff suppressed because it is too large Load Diff
-134
View File
@@ -1,134 +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 : Object edit mode describe viewport input behavior when operating on objects.
#ifndef CRYINCLUDE_EDITOR_EDITMODE_OBJECTMODE_H
#define CRYINCLUDE_EDITOR_EDITMODE_OBJECTMODE_H
#pragma once
// {87109FED-BDB5-4874-936D-338400079F58}
DEFINE_GUID(OBJECT_MODE_GUID, 0x87109fed, 0xbdb5, 0x4874, 0x93, 0x6d, 0x33, 0x84, 0x0, 0x7, 0x9f, 0x58);
#include "EditTool.h"
class CBaseObject;
class CDeepSelection;
/*!
* CObjectMode is an abstract base class for All Editing Tools supported by Editor.
* Edit tools handle specific editing modes in viewports.
*/
class SANDBOX_API CObjectMode
: public CEditTool
{
Q_OBJECT
public:
Q_INVOKABLE CObjectMode(QObject* parent = nullptr);
virtual ~CObjectMode();
static const GUID& GetClassID() { return OBJECT_MODE_GUID; }
// Registration function.
static void RegisterTool(CRegistrationContext& rc);
//////////////////////////////////////////////////////////////////////////
// CEditTool implementation.
//////////////////////////////////////////////////////////////////////////
virtual void BeginEditParams([[maybe_unused]] IEditor* ie, [[maybe_unused]] int flags) {};
virtual void EndEditParams();
virtual void Display(struct DisplayContext& dc);
virtual void DisplaySelectionPreview(struct DisplayContext& dc);
virtual void DrawSelectionPreview(struct DisplayContext& dc, CBaseObject* drawObject);
void DisplayExtraLightInfo(struct DisplayContext& dc);
virtual bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags);
virtual bool OnKeyDown(CViewport* view, uint32 nChar, uint32 nRepCnt, uint32 nFlags);
virtual bool OnKeyUp(CViewport* view, uint32 nChar, uint32 nRepCnt, uint32 nFlags);
virtual bool OnSetCursor([[maybe_unused]] CViewport* vp) { return false; };
virtual void OnManipulatorDrag(CViewport* view, ITransformManipulator* pManipulator, QPoint& p0, QPoint& p1, const Vec3& value) override;
bool IsUpdateUIPanel() override { return true; }
protected:
enum ECommandMode
{
NothingMode = 0,
ScrollZoomMode,
SelectMode,
MoveMode,
RotateMode,
ScaleMode,
ScrollMode,
ZoomMode,
};
virtual bool OnLButtonDown(CViewport* view, int nFlags, const QPoint& point);
virtual bool OnLButtonDblClk(CViewport* view, int nFlags, const QPoint& point);
virtual bool OnLButtonUp(CViewport* view, int nFlags, const QPoint& point);
virtual bool OnRButtonDown(CViewport* view, int nFlags, const QPoint& point);
virtual bool OnRButtonUp(CViewport* view, int nFlags, const QPoint& point);
virtual bool OnMButtonDown(CViewport* view, int nFlags, const QPoint& point);
virtual bool OnMouseMove(CViewport* view, int nFlags, const QPoint& point);
virtual bool OnMouseLeave(CViewport* view);
void SetCommandMode(ECommandMode mode) { m_commandMode = mode; }
ECommandMode GetCommandMode() const { return m_commandMode; }
//! Ctrl-Click in move mode to move selected objects to given pos.
void MoveSelectionToPos(CViewport* view, Vec3& pos, bool align, const QPoint& point);
void SetObjectCursor(CViewport* view, CBaseObject* hitObj, bool bChangeNow = false);
virtual void DeleteThis() { delete this; };
void UpdateStatusText();
void AwakeObjectAtPoint(CViewport* view, const QPoint& point);
void HideMoveByFaceNormGizmo();
void HandleMoveByFaceNormal(HitContext& hitInfo);
void UpdateMoveByFaceNormGizmo(CBaseObject* pHitObject);
protected:
bool m_openContext;
private:
void CheckDeepSelection(HitContext& hitContext, CViewport* view);
Vec3& GetScale(const CViewport* view, const QPoint& point, Vec3& OutScale);
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
QPoint m_cMouseDownPos;
bool m_bDragThresholdExceeded;
ECommandMode m_commandMode;
GUID m_MouseOverObject;
typedef std::vector<GUID> TGuidContainer;
TGuidContainer m_PreviewGUIDs;
_smart_ptr<CDeepSelection> m_pDeepSelection;
bool m_bMoveByFaceNormManipShown;
CBaseObject* m_pHitObject;
bool m_bTransformChanged;
QPoint m_prevMousePos = QPoint(0, 0);
Vec3 m_lastValidMoveVector = Vec3(0, 0, 0);
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
#endif // CRYINCLUDE_EDITOR_EDITMODE_OBJECTMODE_H
@@ -1,430 +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"
#if defined(AZ_PLATFORM_WINDOWS)
#include <InitGuid.h>
#endif
#include "VertexSnappingModeTool.h"
// Editor
#include "Settings.h"
#include "Viewport.h"
#include "SurfaceInfoPicker.h"
#include "Material/Material.h"
#include "Util/KDTree.h"
// {3e008046-9269-41d7-82e2-07ffd7254c10}
DEFINE_GUID(VERTEXSNAPPING_MODE_GUID, 0x3e008046, 0x9269, 0x41d7, 0x82, 0xe2, 0x07, 0xff, 0xd7, 0x25, 0x4c, 0x10);
bool FindNearestVertex(CBaseObject* pObject, CKDTree* pTree, const Vec3& vWorldRaySrc, const Vec3& vWorldRayDir, Vec3& outPos, Vec3& vOutHitPosOnCube)
{
Matrix34 worldInvTM = pObject->GetWorldTM().GetInverted();
Vec3 vRaySrc = worldInvTM.TransformPoint(vWorldRaySrc);
Vec3 vRayDir = worldInvTM.TransformVector(vWorldRayDir);
Vec3 vLocalCameraPos = worldInvTM.TransformPoint(gEnv->pRenderer->GetCamera().GetPosition());
Vec3 vPos;
Vec3 vHitPosOnCube;
if (pTree)
{
if (pTree->FindNearestVertex(vRaySrc, vRayDir, gSettings.vertexSnappingSettings.vertexCubeSize, vLocalCameraPos, vPos, vHitPosOnCube))
{
outPos = pObject->GetWorldTM().TransformPoint(vPos);
vOutHitPosOnCube = pObject->GetWorldTM().TransformPoint(vHitPosOnCube);
return true;
}
}
else
{
// for objects without verts, the pivot is the nearest vertex
// return true if the ray hits the bounding box
outPos = pObject->GetWorldPos();
AABB bbox;
pObject->GetBoundBox(bbox);
if (bbox.IsContainPoint(vWorldRaySrc))
{
// if ray starts inside bounding box, reject cases where pivot is behind the ray
float hitDistAlongRay = vWorldRayDir.Dot(outPos - vWorldRaySrc);
if (hitDistAlongRay >= 0.f)
{
vHitPosOnCube = vWorldRaySrc + (vWorldRayDir * hitDistAlongRay);
return true;
}
}
else if (Intersect::Ray_AABB(vWorldRaySrc, vWorldRayDir, bbox, vOutHitPosOnCube))
{
return true;
}
}
return false;
}
CVertexSnappingModeTool::CVertexSnappingModeTool()
{
m_modeStatus = eVSS_SelectFirstVertex;
m_bHit = false;
}
CVertexSnappingModeTool::~CVertexSnappingModeTool()
{
std::map<CBaseObjectPtr, CKDTree*>::iterator ii = m_ObjectKdTreeMap.begin();
for (; ii != m_ObjectKdTreeMap.end(); ++ii)
{
delete ii->second;
}
}
const GUID& CVertexSnappingModeTool::GetClassID()
{
return VERTEXSNAPPING_MODE_GUID;
}
void CVertexSnappingModeTool::RegisterTool(CRegistrationContext& rc)
{
rc.pClassFactory->RegisterClass(new CQtViewClass<CVertexSnappingModeTool>("EditTool.VertexSnappingMode", "Select", ESYSTEM_CLASS_EDITTOOL));
}
bool CVertexSnappingModeTool::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags)
{
CBaseObjectPtr pExcludedObject = NULL;
if (m_modeStatus == eVSS_MoveSelectVertexToAnotherVertex)
{
pExcludedObject = m_SelectionInfo.m_pObject;
}
m_bHit = HitTest(view, point, pExcludedObject, m_vHitVertex, m_pHitObject, m_Objects);
if (event == eMouseLDown && m_bHit && m_pHitObject && m_modeStatus == eVSS_SelectFirstVertex)
{
m_modeStatus = eVSS_MoveSelectVertexToAnotherVertex;
m_SelectionInfo.m_pObject = m_pHitObject;
m_SelectionInfo.m_vPos = m_vHitVertex;
GetIEditor()->BeginUndo();
m_pHitObject->StoreUndo("Vertex Snapping", true);
view->SetCapture();
}
if (m_modeStatus == eVSS_MoveSelectVertexToAnotherVertex)
{
if (event == eMouseLUp)
{
m_modeStatus = eVSS_SelectFirstVertex;
GetIEditor()->AcceptUndo("Vertex Snapping");
view->ReleaseMouse();
}
else if ((flags & MK_LBUTTON) && event == eMouseMove)
{
Vec3 vOffset = m_SelectionInfo.m_pObject->GetWorldPos() - m_SelectionInfo.m_vPos;
m_SelectionInfo.m_pObject->SetWorldPos(m_vHitVertex + vOffset);
m_SelectionInfo.m_vPos = m_SelectionInfo.m_pObject->GetWorldPos() - vOffset;
}
}
return true;
}
bool CVertexSnappingModeTool::HitTest(CViewport* view, const QPoint& point, CBaseObject* pExcludedObj, Vec3& outHitPos, CBaseObjectPtr& pOutHitObject, std::vector<CBaseObjectPtr>& outObjects)
{
if (gSettings.vertexSnappingSettings.bRenderPenetratedBoundBox)
{
m_DebugBoxes.clear();
}
pOutHitObject = NULL;
outObjects.clear();
//
// Collect valid objects that mouse is over
//
CSurfaceInfoPicker picker;
CSurfaceInfoPicker::CExcludedObjects excludedObjects;
if (pExcludedObj)
{
excludedObjects.Add(pExcludedObj);
}
int nPickFlag = CSurfaceInfoPicker::ePOG_Entity;
std::vector<CBaseObjectPtr> penetratedObjects;
if (!picker.PickByAABB(point, nPickFlag, view, &excludedObjects, &penetratedObjects))
{
return false;
}
for (int i = 0, iCount(penetratedObjects.size()); i < iCount; ++i)
{
CMaterial* pMaterial = penetratedObjects[i]->GetMaterial();
if (pMaterial)
{
QString matName = pMaterial->GetName();
if (!QString::compare(matName, "Objects/sky/forest_sky_dome", Qt::CaseInsensitive))
{
continue;
}
}
outObjects.push_back(penetratedObjects[i]);
}
//
// Find the best vertex.
//
Vec3 vWorldRaySrc, vWorldRayDir;
view->ViewToWorldRay(point, vWorldRaySrc, vWorldRayDir);
std::vector<CBaseObjectPtr>::iterator ii = outObjects.begin();
float fNearestDist = 3e10f;
Vec3 vNearestPos;
CBaseObjectPtr pNearestObject = NULL;
for (ii = outObjects.begin(); ii != outObjects.end(); ++ii)
{
if (gSettings.vertexSnappingSettings.bRenderPenetratedBoundBox)
{
// add to debug boxes: the penetrated nodes of each object's kd-tree
if (auto pTree = GetKDTree(*ii))
{
Matrix34 invWorldTM = (*ii)->GetWorldTM().GetInverted();
int nIndex = m_DebugBoxes.size();
Vec3 vLocalRaySrc = invWorldTM.TransformPoint(vWorldRaySrc);
Vec3 vLocalRayDir = invWorldTM.TransformVector(vWorldRayDir);
pTree->GetPenetratedBoxes(vLocalRaySrc, vLocalRayDir, m_DebugBoxes);
for (int i = nIndex; i < m_DebugBoxes.size(); ++i)
{
m_DebugBoxes[i].SetTransformedAABB((*ii)->GetWorldTM(), m_DebugBoxes[i]);
}
}
}
// find the nearest vertex on this object
Vec3 vPos, vHitPosOnCube;
if (FindNearestVertex(*ii, GetKDTree(*ii), vWorldRaySrc, vWorldRayDir, vPos, vHitPosOnCube))
{
// is this the best so far?
float fDistance = vHitPosOnCube.GetDistance(vWorldRaySrc);
if (fDistance < fNearestDist)
{
fNearestDist = fDistance;
vNearestPos = vPos;
pNearestObject = *ii;
}
}
}
if (fNearestDist < 3e10f)
{
outHitPos = vNearestPos;
pOutHitObject = pNearestObject;
}
// if the mouse is over the object's pivot, use that instead of a vertex
if (pOutHitObject)
{
Vec3 vPivotPos = pOutHitObject->GetWorldPos();
Vec3 vPivotBox = GetCubeSize(view, pOutHitObject->GetWorldPos());
AABB pivotAABB(vPivotPos - vPivotBox, vPivotPos + vPivotBox);
Vec3 vPosOnPivotCube;
if (Intersect::Ray_AABB(vWorldRaySrc, vWorldRayDir, pivotAABB, vPosOnPivotCube))
{
outHitPos = vPivotPos;
return true;
}
}
return pOutHitObject && pOutHitObject == pNearestObject;
}
Vec3 CVertexSnappingModeTool::GetCubeSize(IDisplayViewport* pView, const Vec3& pos) const
{
if (!pView)
{
return Vec3(0, 0, 0);
}
float fScreenFactor = pView->GetScreenScaleFactor(pos);
return gSettings.vertexSnappingSettings.vertexCubeSize * Vec3(fScreenFactor, fScreenFactor, fScreenFactor);
}
void CVertexSnappingModeTool::Display(struct DisplayContext& dc)
{
const ColorB SnappedColor(0xFF00FF00);
const ColorB PivotColor(0xFF2020FF);
const ColorB VertexColor(0xFFFFAAAA);
// draw all objects under mouse
dc.SetColor(VertexColor);
for (int i = 0, iCount(m_Objects.size()); i < iCount; ++i)
{
AABB worldAABB;
m_Objects[i]->GetBoundBox(worldAABB);
if (!dc.view->IsBoundsVisible(worldAABB))
{
continue;
}
if (auto pStatObj = m_Objects[i]->GetIStatObj())
{
DrawVertexCubes(dc, m_Objects[i]->GetWorldTM(), pStatObj);
}
else
{
dc.DrawWireBox(worldAABB.min, worldAABB.max);
}
}
// draw object being moved
if (m_modeStatus == eVSS_MoveSelectVertexToAnotherVertex && m_SelectionInfo.m_pObject)
{
dc.SetColor(QColor(0xaa, 0xaa, 0xaa));
if (auto pStatObj = m_SelectionInfo.m_pObject->GetIStatObj())
{
DrawVertexCubes(dc, m_SelectionInfo.m_pObject->GetWorldTM(), pStatObj);
}
else
{
AABB bounds;
m_SelectionInfo.m_pObject->GetBoundBox(bounds);
dc.DrawWireBox(bounds.min, bounds.max);
}
}
// draw pivot of hit object
if (m_pHitObject && (!m_bHit || m_bHit && !m_pHitObject->GetWorldPos().IsEquivalent(m_vHitVertex, 0.001f)))
{
dc.SetColor(PivotColor);
dc.DepthTestOff();
Vec3 vBoxSize = GetCubeSize(dc.view, m_pHitObject->GetWorldPos()) * 1.2f;
AABB vertexBox(m_pHitObject->GetWorldPos() - vBoxSize, m_pHitObject->GetWorldPos() + vBoxSize);
dc.DrawBall((vertexBox.min + vertexBox.max) * 0.5f, (vertexBox.max.x - vertexBox.min.x) * 0.5f);
dc.DepthTestOn();
}
// draw the vertex (or pivot) that's being hit
if (m_bHit)
{
dc.DepthTestOff();
dc.SetColor(SnappedColor);
Vec3 vBoxSize = GetCubeSize(dc.view, m_vHitVertex);
if (m_vHitVertex.IsEquivalent(m_pHitObject->GetWorldPos(), 0.001f))
{
dc.DrawBall(m_vHitVertex, vBoxSize.x * 1.2f);
}
else
{
dc.DrawSolidBox(m_vHitVertex - vBoxSize, m_vHitVertex + vBoxSize);
}
dc.DepthTestOn();
}
// draw wireframe of hit object
if (m_pHitObject && m_pHitObject->GetIStatObj())
{
SGeometryDebugDrawInfo dd;
dd.tm = m_pHitObject->GetWorldTM();
dd.color = ColorB(250, 0, 250, 30);
dd.lineColor = ColorB(255, 255, 0, 160);
dd.bExtrude = true;
m_pHitObject->GetIStatObj()->DebugDraw(dd);
}
// draw debug boxes
if (gSettings.vertexSnappingSettings.bRenderPenetratedBoundBox)
{
ColorB boxColor(40, 40, 40);
for (int i = 0, iCount(m_DebugBoxes.size()); i < iCount; ++i)
{
dc.SetColor(boxColor);
boxColor += ColorB(25, 25, 25);
dc.DrawWireBox(m_DebugBoxes[i].min, m_DebugBoxes[i].max);
}
}
}
void CVertexSnappingModeTool::DrawVertexCubes(DisplayContext& dc, const Matrix34& tm, IStatObj* pStatObj)
{
if (!pStatObj)
{
return;
}
IIndexedMesh* pIndexedMesh = pStatObj->GetIndexedMesh();
if (pIndexedMesh)
{
IIndexedMesh::SMeshDescription md;
pIndexedMesh->GetMeshDescription(md);
for (int k = 0; k < md.m_nVertCount; ++k)
{
Vec3 vPos(0, 0, 0);
if (md.m_pVerts)
{
vPos = md.m_pVerts[k];
}
else if (md.m_pVertsF16)
{
vPos = md.m_pVertsF16[k].ToVec3();
}
else
{
continue;
}
vPos = tm.TransformPoint(vPos);
Vec3 vBoxSize = GetCubeSize(dc.view, vPos);
if (!m_bHit || !m_vHitVertex.IsEquivalent(vPos, 0.001f))
{
dc.DrawSolidBox(vPos - vBoxSize, vPos + vBoxSize);
}
}
}
for (int i = 0, iSubStatObjNum(pStatObj->GetSubObjectCount()); i < iSubStatObjNum; ++i)
{
IStatObj::SSubObject* pSubObj = pStatObj->GetSubObject(i);
if (pSubObj)
{
DrawVertexCubes(dc, tm * pSubObj->localTM, pSubObj->pStatObj);
}
}
}
CKDTree* CVertexSnappingModeTool::GetKDTree(CBaseObject* pObject)
{
auto existingTree = m_ObjectKdTreeMap.find(pObject);
if (existingTree != m_ObjectKdTreeMap.end())
{
return existingTree->second;
}
// Don't build a kd-tree for objects without verts
CKDTree* pTree = nullptr;
if (auto pStatObj = pObject->GetIStatObj())
{
pTree = new CKDTree();
pTree->Build(pObject->GetIStatObj());
}
m_ObjectKdTreeMap[pObject] = pTree;
return pTree;
}
#include <EditMode/moc_VertexSnappingModeTool.cpp>
@@ -1,91 +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_EDITMODE_VERTEXSNAPPINGMODETOOL_H
#define CRYINCLUDE_EDITOR_EDITMODE_VERTEXSNAPPINGMODETOOL_H
#pragma once
#include "EditTool.h"
#include "Objects/BaseObject.h"
class CKDTree;
struct IDisplayViewport;
class CVertexSnappingModeTool
: public CEditTool
{
Q_OBJECT
public:
Q_INVOKABLE CVertexSnappingModeTool();
~CVertexSnappingModeTool();
static const GUID& GetClassID();
static void RegisterTool(CRegistrationContext& rc);
void Display(DisplayContext& dc);
bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags);
protected:
void DrawVertexCubes(DisplayContext& dc, const Matrix34& tm, IStatObj* pStatObj);
void DeleteThis(){ delete this; }
Vec3 GetCubeSize(IDisplayViewport* pView, const Vec3& pos) const;
private:
using CEditTool::HitTest;
bool HitTest(CViewport* view, const QPoint& point, CBaseObject* pExcludedObj, Vec3& outHitPos, CBaseObjectPtr& pOutHitObject, std::vector<CBaseObjectPtr>& outObjects);
CKDTree* GetKDTree(CBaseObject* pObject);
enum EVertexSnappingStatus
{
eVSS_SelectFirstVertex,
eVSS_MoveSelectVertexToAnotherVertex
};
EVertexSnappingStatus m_modeStatus;
struct SSelectionInfo
{
SSelectionInfo()
{
m_pObject = NULL;
m_vPos = Vec3(0, 0, 0);
}
CBaseObjectPtr m_pObject;
Vec3 m_vPos;
};
/// Info on object being moved (when in eVSS_MoveSelectVertexToAnotherVertex mode).
SSelectionInfo m_SelectionInfo;
/// Objects that mouse is over
std::vector<CBaseObjectPtr> m_Objects;
/// Position of vertex that mouse is hitting.
/// Invalid when m_bHit is false.
Vec3 m_vHitVertex;
/// Whether the mouse hit test succeeded
bool m_bHit;
/// Object that mouse is hitting
CBaseObjectPtr m_pHitObject;
/// Boxes to render for debug drawing
std::vector<AABB> m_DebugBoxes;
/// For each object, a tree containing its vertices.
std::map<CBaseObjectPtr, CKDTree*> m_ObjectKdTreeMap;
};
#endif // CRYINCLUDE_EDITOR_EDITMODE_VERTEXSNAPPINGMODETOOL_H
-89
View File
@@ -1,89 +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 "EditTool.h"
// Editor
#include "Include/IObjectManager.h"
#include "Objects/SelectionGroup.h"
//////////////////////////////////////////////////////////////////////////
// Class description.
//////////////////////////////////////////////////////////////////////////
class CEditTool_ClassDesc
: public CRefCountClassDesc
{
virtual ESystemClassID SystemClassID() { return ESYSTEM_CLASS_EDITTOOL; }
virtual REFGUID ClassID()
{
// {0A43AB8E-B1AE-44aa-93B1-229F73D58CA4}
static const GUID guid = {
0xa43ab8e, 0xb1ae, 0x44aa, { 0x93, 0xb1, 0x22, 0x9f, 0x73, 0xd5, 0x8c, 0xa4 }
};
return guid;
}
virtual QString ClassName() { return "EditTool.Default"; };
virtual QString Category() { return "EditTool"; };
};
CEditTool_ClassDesc g_stdClassDesc;
//////////////////////////////////////////////////////////////////////////
CEditTool::CEditTool(QObject* parent)
: QObject(parent)
{
m_pClassDesc = &g_stdClassDesc;
m_nRefCount = 0;
};
//////////////////////////////////////////////////////////////////////////
void CEditTool::SetParentTool(CEditTool* pTool)
{
m_pParentTool = pTool;
}
//////////////////////////////////////////////////////////////////////////
CEditTool* CEditTool::GetParentTool()
{
return m_pParentTool;
}
//////////////////////////////////////////////////////////////////////////
void CEditTool::Abort()
{
if (m_pParentTool)
{
GetIEditor()->SetEditTool(m_pParentTool);
}
else
{
GetIEditor()->SetEditTool(0);
}
}
//////////////////////////////////////////////////////////////////////////
void CEditTool::GetAffectedObjects(DynArray<CBaseObject*>& outAffectedObjects)
{
CSelectionGroup* pSelection = GetIEditor()->GetObjectManager()->GetSelection();
if (pSelection == NULL)
{
return;
}
for (int i = 0, iCount(pSelection->GetCount()); i < iCount; ++i)
{
outAffectedObjects.push_back(pSelection->GetObject(i));
}
}
#include <moc_EditTool.cpp>
-175
View File
@@ -1,175 +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_EDITTOOL_H
#define CRYINCLUDE_EDITOR_EDITTOOL_H
#pragma once
#if !defined(Q_MOC_RUN)
#include "QtViewPaneManager.h"
#endif
class CViewport;
struct IClassDesc;
struct ITransformManipulator;
struct HitContext;
enum EEditToolType
{
EDIT_TOOL_TYPE_PRIMARY,
EDIT_TOOL_TYPE_SECONDARY,
};
/*!
* CEditTool is an abstract base class for All Editing Tools supported by Editor.
* Edit tools handle specific editing modes in viewports.
*/
class SANDBOX_API CEditTool
: public QObject
{
Q_OBJECT
public:
explicit CEditTool(QObject* parent = nullptr);
//////////////////////////////////////////////////////////////////////////
// For reference counting.
//////////////////////////////////////////////////////////////////////////
void AddRef() { m_nRefCount++; };
void Release()
{
AZ_Assert(m_nRefCount > 0, "Negative ref count");
if (--m_nRefCount == 0)
{
DeleteThis();
}
};
//! Returns class description for this tool.
IClassDesc* GetClassDesc() const { return m_pClassDesc; }
virtual void SetParentTool(CEditTool* pTool);
virtual CEditTool* GetParentTool();
virtual EEditToolType GetType() { return EDIT_TOOL_TYPE_PRIMARY; }
virtual EOperationMode GetMode() { return eOperationModeNone; }
// Abort tool.
virtual void Abort();
// Accept tool.
virtual void Accept([[maybe_unused]] bool resetPosition = false) {}
//! Status text displayed when this tool is active.
void SetStatusText(const QString& text) { m_statusText = text; };
QString GetStatusText() { return m_statusText; };
// Description:
// Activates tool.
// Arguments:
// pPreviousTool - Previously active edit tool.
// Return:
// True if the tool can be activated,
virtual bool Activate([[maybe_unused]] CEditTool* pPreviousTool) { return true; };
//! Used to pass user defined data to edit tool from ToolButton.
virtual void SetUserData([[maybe_unused]] const char* key, [[maybe_unused]] void* userData) {};
//! Called when user starts using this tool.
//! Flags is comnination of ObjectEditFlags flags.
virtual void BeginEditParams([[maybe_unused]] IEditor* ie, [[maybe_unused]] int flags) {};
//! Called when user ends using this tool.
virtual void EndEditParams() {};
// Called each frame to display tool for given viewport.
virtual void Display(struct DisplayContext& dc) = 0;
//! Mouse callback sent from viewport.
//! Returns true if event processed by callback, and all other processing for this event should abort.
//! Return false if event was not processed by callback, and other processing for this event should occur.
//! @param view Viewport that sent this callback.
//! @param event Indicate what kind of event occured in viewport.
//! @param point 2D coordinate in viewport where event occured.
//! @param flags Additional flags (MK_LBUTTON,etc..) or from (MouseEventFlags) specified by viewport when calling callback.
virtual bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags) = 0;
//! Called when key in viewport is pressed while using this tool.
//! Returns true if event processed by callback, and all other processing for this event should abort.
//! Returns false if event was not processed by callback, and other processing for this event should occur.
//! @param view Viewport where key was pressed.
//! @param nChar Specifies the virtual key code of the given key. For a list of standard virtual key codes, see Winuser.h
//! @param nRepCnt Specifies the repeat count, that is, the number of times the keystroke is repeated as a result of the user holding down the key.
//! @param nFlags Specifies the scan code, key-transition code, previous key state, and context code, (see WM_KEYDOWN)
virtual bool OnKeyDown([[maybe_unused]] CViewport* view, [[maybe_unused]] uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) { return false; };
//! Called when key in viewport is released while using this tool.
//! Returns true if event processed by callback, and all other processing for this event should abort.
//! Returns false if event was not processed by callback, and other processing for this event should occur.
//! @param view Viewport where key was pressed.
//! @param nChar Specifies the virtual key code of the given key. For a list of standard virtual key codes, see Winuser.h
//! @param nRepCnt Specifies the repeat count, that is, the number of times the keystroke is repeated as a result of the user holding down the key.
//! @param nFlags Specifies the scan code, key-transition code, previous key state, and context code, (see WM_KEYDOWN)
virtual bool OnKeyUp([[maybe_unused]] CViewport* view, [[maybe_unused]] uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) { return false; };
//! Called when mouse is moved and give oportunity to tool to set it own cursor.
//! @return true if cursor changed. or false otherwise.
virtual bool OnSetCursor([[maybe_unused]] CViewport* vp) { return false; };
// Return objects affected by this edit tool. The returned objects usually will be the selected objects.
virtual void GetAffectedObjects(DynArray<CBaseObject*>& outAffectedObjects);
// Called in response to the dragging of the manipulator in the view.
// Allow edit tool to handle manipulator dragging the way it wants.
virtual void OnManipulatorDrag([[maybe_unused]] CViewport* view, [[maybe_unused]] ITransformManipulator* pManipulator, [[maybe_unused]] QPoint& p0, [[maybe_unused]] QPoint& p1, [[maybe_unused]] const Vec3& value) {}
virtual void OnManipulatorDrag(CViewport* view, ITransformManipulator* pManipulator, const Vec3& value)
{
// Overload with less boiler-plate
QPoint p0, p1;
OnManipulatorDrag(view, pManipulator, p0, p1, value);
}
// Called in response to mouse event of the manipulator in the view
virtual void OnManipulatorMouseEvent([[maybe_unused]] CViewport* view, [[maybe_unused]] ITransformManipulator* pManipulator, [[maybe_unused]] EMouseEvent event, [[maybe_unused]] QPoint& point, [[maybe_unused]] int flags, [[maybe_unused]] bool bHitGizmo = false) {}
virtual bool IsNeedMoveTool() { return false; }
virtual bool IsNeedSpecificBehaviorForSpaceAcce() { return false; }
virtual bool IsNeedToSkipPivotBoxForObjects() { return false; }
virtual bool IsDisplayGrid() { return true; }
virtual bool IsUpdateUIPanel() { return false; }
virtual bool IsMoveToObjectModeAfterEnd() { return true; }
virtual bool IsCircleTypeRotateGizmo() { return false; }
// Draws object specific helpers for this tool
virtual void DrawObjectHelpers([[maybe_unused]] CBaseObject* pObject, [[maybe_unused]] DisplayContext& dc) {}
// Hit test against edit tool
virtual bool HitTest([[maybe_unused]] CBaseObject* pObject, [[maybe_unused]] HitContext& hc) { return false; }
protected:
virtual ~CEditTool() {};
//////////////////////////////////////////////////////////////////////////
// Delete edit tool.
//////////////////////////////////////////////////////////////////////////
virtual void DeleteThis() = 0;
protected:
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
_smart_ptr<CEditTool> m_pParentTool; // Pointer to parent edit tool.
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
QString m_statusText;
IClassDesc* m_pClassDesc;
int m_nRefCount;
};
#endif // CRYINCLUDE_EDITOR_EDITTOOL_H
+1 -1
View File
@@ -1 +1 @@
IDI_ICON1 ICON DISCARDABLE "res\\o3de_editor.ico"
IDI_ICON1 ICON DISCARDABLE "res\\o3de_editor.ico"
+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))
{
@@ -73,4 +73,4 @@ private:
QPixmap m_unSelectedPixmap;
EditorPreferencesTreeWidgetItem* m_currentPageItem;
QString m_filter;
};
};
@@ -63,11 +63,6 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
->Field("DeepSelectionRange", &DeepSelection::m_deepSelectionRange)
->Field("StickDuplicate", &DeepSelection::m_stickDuplicate);
serialize.Class<VertexSnapping>()
->Version(1)
->Field("VertexCubeSize", &VertexSnapping::m_vertexCubeSize)
->Field("RenderPenetratedBoundBox", &VertexSnapping::m_bRenderPenetratedBoundBox);
serialize.Class<SliceSettings>()
->Version(1)
->Field("DynamicByDefault", &SliceSettings::m_slicesDynamicByDefault);
@@ -78,7 +73,6 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
->Field("Messaging", &CEditorPreferencesPage_General::m_messaging)
->Field("Undo", &CEditorPreferencesPage_General::m_undo)
->Field("Deep Selection", &CEditorPreferencesPage_General::m_deepSelection)
->Field("Vertex Snapping", &CEditorPreferencesPage_General::m_vertexSnapping)
->Field("Slice Settings", &CEditorPreferencesPage_General::m_sliceSettings);
@@ -119,12 +113,6 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Max, 1000.0f);
editContext->Class<VertexSnapping>("Vertex Snapping", "")
->DataElement(AZ::Edit::UIHandlers::SpinBox, &VertexSnapping::m_vertexCubeSize, "Vertex Cube Size", "Vertex Cube Size")
->Attribute(AZ::Edit::Attributes::Min, 0.0001f)
->Attribute(AZ::Edit::Attributes::Max, 1.0f)
->DataElement(AZ::Edit::UIHandlers::CheckBox, &VertexSnapping::m_bRenderPenetratedBoundBox, "Render Penetrated BoundBoxes", "Render Penetrated BoundBoxes");
editContext->Class<SliceSettings>("Slices", "")
->DataElement(AZ::Edit::UIHandlers::CheckBox, &SliceSettings::m_slicesDynamicByDefault, "New Slices Dynamic By Default", "When creating slices, they will be set to dynamic by default");
@@ -135,7 +123,6 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_messaging, "Messaging", "Messaging")
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_undo, "Undo", "Undo Preferences")
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_deepSelection, "Selection", "Selection")
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_vertexSnapping, "Vertex Snapping", "Vertex Snapping")
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_sliceSettings, "Slices", "Slice Settings");
}
}
@@ -189,10 +176,6 @@ void CEditorPreferencesPage_General::OnApply()
gSettings.deepSelectionSettings.fRange = m_deepSelection.m_deepSelectionRange;
gSettings.deepSelectionSettings.bStickDuplicate = m_deepSelection.m_stickDuplicate;
//vertex snapping
gSettings.vertexSnappingSettings.vertexCubeSize = m_vertexSnapping.m_vertexCubeSize;
gSettings.vertexSnappingSettings.bRenderPenetratedBoundBox = m_vertexSnapping.m_bRenderPenetratedBoundBox;
//slices
gSettings.sliceSettings.dynamicByDefault = m_sliceSettings.m_slicesDynamicByDefault;
@@ -236,10 +219,6 @@ void CEditorPreferencesPage_General::InitializeSettings()
m_deepSelection.m_deepSelectionRange = gSettings.deepSelectionSettings.fRange;
m_deepSelection.m_stickDuplicate = gSettings.deepSelectionSettings.bStickDuplicate;
//vertex snapping
m_vertexSnapping.m_vertexCubeSize = gSettings.vertexSnappingSettings.vertexCubeSize;
m_vertexSnapping.m_bRenderPenetratedBoundBox = gSettings.vertexSnappingSettings.bRenderPenetratedBoundBox;
//slices
m_sliceSettings.m_slicesDynamicByDefault = gSettings.sliceSettings.dynamicByDefault;
}
@@ -88,14 +88,6 @@ private:
bool m_stickDuplicate;
};
struct VertexSnapping
{
AZ_TYPE_INFO(VertexSnapping, "{20F16350-990C-4096-86E3-40D56DDDD702}")
float m_vertexCubeSize;
bool m_bRenderPenetratedBoundBox;
};
struct SliceSettings
{
AZ_TYPE_INFO(SliceSettings, "{8505CCC1-874C-4389-B51A-B9E5FF70CFDA}")
@@ -107,7 +99,6 @@ private:
Messaging m_messaging;
Undo m_undo;
DeepSelection m_deepSelection;
VertexSnapping m_vertexSnapping;
SliceSettings m_sliceSettings;
QIcon m_icon;
};
@@ -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>());
+55 -47
View File
@@ -65,7 +65,6 @@
#include "Util/fastlib.h"
#include "CryEditDoc.h"
#include "GameEngine.h"
#include "EditTool.h"
#include "ViewManager.h"
#include "Objects/DisplayContext.h"
#include "DisplaySettings.h"
@@ -231,10 +230,6 @@ EditorViewportWidget::~EditorViewportWidget()
//////////////////////////////////////////////////////////////////////////
int EditorViewportWidget::OnCreate()
{
m_renderer = GetIEditor()->GetRenderer();
m_engine = GetIEditor()->Get3DEngine();
assert(m_engine);
CreateRenderContext();
return 0;
@@ -276,9 +271,6 @@ void EditorViewportWidget::paintEvent([[maybe_unused]] QPaintEvent* event)
if ((ge && ge->IsLevelLoaded()) || (GetType() != ET_ViewportCamera))
{
setRenderOverlayVisible(true);
m_isOnPaint = true;
Update();
m_isOnPaint = false;
}
else
{
@@ -431,7 +423,7 @@ void EditorViewportWidget::Update()
return;
}
if (!m_engine || m_rcClient.isEmpty() || GetIEditor()->IsInMatEditMode())
if (m_rcClient.isEmpty() || GetIEditor()->IsInMatEditMode())
{
return;
}
@@ -682,6 +674,11 @@ void EditorViewportWidget::OnEditorNotifyEvent(EEditorNotifyEvent event)
}
SetCurrentCursor(STD_CURSOR_GAME);
}
if (m_renderViewport)
{
m_renderViewport->GetControllerList()->SetEnabled(false);
}
}
break;
@@ -700,6 +697,11 @@ void EditorViewportWidget::OnEditorNotifyEvent(EEditorNotifyEvent event)
RestoreViewportAfterGameMode();
}
if (m_renderViewport)
{
m_renderViewport->GetControllerList()->SetEnabled(true);
}
break;
case eNotify_OnCloseScene:
@@ -730,6 +732,8 @@ void EditorViewportWidget::OnEditorNotifyEvent(EEditorNotifyEvent event)
// meters above the terrain (default terrain height is 32)
viewTM.SetTranslation(Vec3(sx * 0.5f, sy * 0.5f, 34.0f));
SetViewTM(viewTM);
UpdateScene();
}
break;
@@ -785,8 +789,10 @@ void EditorViewportWidget::OnRender()
// This is necessary so that automated editor tests using the null renderer to test systems like dynamic vegetation
// are still able to manipulate the current logical camera position, even if nothing is rendered.
GetIEditor()->GetSystem()->SetViewCamera(m_Camera);
GetIEditor()->GetRenderer()->SetCamera(gEnv->pSystem->GetViewCamera());
m_engine->RenderWorld(0, SRenderingPassInfo::CreateGeneralPassRenderingInfo(m_Camera), __FUNCTION__);
if (GetIEditor()->GetRenderer())
{
GetIEditor()->GetRenderer()->SetCamera(gEnv->pSystem->GetViewCamera());
}
return;
}
@@ -809,6 +815,10 @@ void EditorViewportWidget::OnBeginPrepareRender()
return;
}
m_isOnPaint = true;
Update();
m_isOnPaint = false;
float fNearZ = GetIEditor()->GetConsoleVar("cl_DefaultNearPlane");
float fFarZ = m_Camera.GetFarPlane();
@@ -874,12 +884,16 @@ void EditorViewportWidget::OnBeginPrepareRender()
fov = 2 * atanf((h * tan(fov / 2)) / maxTargetHeight);
}
}
m_Camera.SetFrustum(w, h, fov, fNearZ, gEnv->p3DEngine->GetMaxViewDistance());
m_Camera.SetFrustum(w, h, fov, fNearZ);
}
GetIEditor()->GetSystem()->SetViewCamera(m_Camera);
if (GetIEditor()->IsInGameMode())
{
return;
}
PreWidgetRendering();
RenderAll();
@@ -905,11 +919,6 @@ void EditorViewportWidget::OnBeginPrepareRender()
m_debugDisplay->DepthTestOn();
PostWidgetRendering();
if (!m_renderer->IsStereoEnabled())
{
GetIEditor()->GetSystem()->RenderStatistics();
}
}
//////////////////////////////////////////////////////////////////////////
@@ -1206,13 +1215,18 @@ void EditorViewportWidget::SetViewportId(int id)
CViewport::SetViewportId(id);
// Now that we have an ID, we can initialize our viewport.
m_renderViewport = new AtomToolsFramework::RenderViewportWidget(id, this);
m_defaultViewportContextName = m_renderViewport->GetViewportContext()->GetName();
m_renderViewport = new AtomToolsFramework::RenderViewportWidget(this, false);
if (!m_renderViewport->InitializeViewportContext(id))
{
AZ_Warning("EditorViewportWidget", false, "Failed to initialize RenderViewportWidget's ViewportContext");
return;
}
auto viewportContext = m_renderViewport->GetViewportContext();
m_defaultViewportContextName = viewportContext->GetName();
QBoxLayout* layout = new QBoxLayout(QBoxLayout::Direction::TopToBottom, this);
layout->setContentsMargins(QMargins());
layout->addWidget(m_renderViewport);
auto viewportContext = m_renderViewport->GetViewportContext();
viewportContext->ConnectViewMatrixChangedHandler(m_cameraViewMatrixChangeHandler);
viewportContext->ConnectProjectionMatrixChangedHandler(m_cameraProjectionMatrixChangeHandler);
@@ -1488,10 +1502,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)
{
@@ -1612,16 +1626,11 @@ 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())
{
if (m_keyDown.isEmpty())
{
grabKeyboard();
}
m_keyDown.insert(event->key());
}
@@ -1798,11 +1807,6 @@ void EditorViewportWidget::SetViewTM(const Matrix34& viewTM, bool bMoveOnly)
//////////////////////////////////////////////////////////////////////////
void EditorViewportWidget::RenderSelectedRegion()
{
if (!m_engine)
{
return;
}
AABB box;
GetIEditor()->GetSelectedRegion(box);
if (box.IsEmpty())
@@ -2412,7 +2416,10 @@ void EditorViewportWidget::SetDefaultCamera()
return;
}
ResetToViewSourceType(ViewSourceType::None);
gEnv->p3DEngine->GetPostEffectBaseGroup()->SetParam("Dof_Active", 0.0f);
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->GetPostEffectBaseGroup()->SetParam("Dof_Active", 0.0f);
}
GetViewManager()->SetCameraObjectId(m_cameraObjectId);
SetName(m_defaultViewName);
SetViewTM(m_defaultViewTM);
@@ -2595,8 +2602,7 @@ bool EditorViewportWidget::GetActiveCameraPosition(AZ::Vector3& cameraPos)
{
if (GetIEditor()->IsInGameMode())
{
const Vec3 camPos = m_engine->GetRenderingCamera().GetPosition();
cameraPos = LYVec3ToAZVec3(camPos);
cameraPos = m_renderViewport->GetViewportContext()->GetCameraTransform().GetTranslation();
}
else
{
@@ -2808,14 +2814,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());
}
}
}
+2 -8
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>
@@ -234,11 +234,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 +395,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;
-13
View File
@@ -19,10 +19,6 @@
#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
@@ -36,15 +32,6 @@ CEnvironmentPanel::CEnvironmentPanel(QWidget* pParent /*=nullptr*/)
{
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);
-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())
{
+17 -92
View File
@@ -23,7 +23,6 @@
// Editor
#include "Geometry/EdGeometry.h"
#include "Material/Material.h"
#include "ViewManager.h"
#include "OBJExporter.h"
#include "OCMExporter.h"
@@ -65,7 +64,7 @@ namespace
const float kTangentDelta = 0.01f;
const float kAspectRatio = 1.777778f;
const int kReserveCount = 7; // x,y,z,rot_x,rot_y,rot_z,fov
const QString kMasterCameraName = "MasterCamera";
const QString kPrimaryCameraName = "PrimaryCamera";
} // namespace
@@ -79,47 +78,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)
@@ -169,10 +127,10 @@ CExportManager::CExportManager()
, m_numberOfExportFrames(0)
, m_pivotEntityObject(0)
, m_bBakedKeysSequenceExport(true)
, m_animTimeExportMasterSequenceCurrentTime(0.0f)
, m_animTimeExportPrimarySequenceCurrentTime(0.0f)
, m_animKeyTimeExport(true)
, m_soundKeyTimeExport(true)
, m_bExportOnlyMasterCamera(false)
, m_bExportOnlyPrimaryCamera(false)
{
RegisterExporter(new COBJExporter());
RegisterExporter(new COCMExporter());
@@ -416,18 +374,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 +393,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 +426,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);
}
}
@@ -773,14 +698,14 @@ bool CExportManager::ShowFBXExportDialog()
return false;
}
SetFBXExportSettings(fpsDialog.GetExportCoordsLocalToTheSelectedObject(), fpsDialog.GetExportOnlyMasterCamera(), fpsDialog.GetFPS());
SetFBXExportSettings(fpsDialog.GetExportCoordsLocalToTheSelectedObject(), fpsDialog.GetExportOnlyPrimaryCamera(), fpsDialog.GetFPS());
return true;
}
bool CExportManager::ProcessObjectsForExport()
{
Export::CObject* pObj = new Export::CObject(kMasterCameraName.toUtf8().data());
Export::CObject* pObj = new Export::CObject(kPrimaryCameraName.toUtf8().data());
pObj->entityType = Export::eCamera;
m_data.m_objects.push_back(pObj);
@@ -808,13 +733,13 @@ bool CExportManager::ProcessObjectsForExport()
Export::CObject* pObj2 = m_data.m_objects[objectID];
CBaseObject* pObject = 0;
if (QString::compare(pObj2->name, kMasterCameraName) == 0)
if (QString::compare(pObj2->name, kPrimaryCameraName) == 0)
{
pObject = GetIEditor()->GetObjectManager()->FindObject(GetIEditor()->GetViewManager()->GetCameraObjectId());
}
else
{
if (m_bExportOnlyMasterCamera && pObj2->entityType != Export::eCameraTarget)
if (m_bExportOnlyPrimaryCamera && pObj2->entityType != Export::eCameraTarget)
{
continue;
}
@@ -952,7 +877,7 @@ void CExportManager::FillAnimTimeNode(XmlNodeRef writeNode, CTrackViewAnimNode*
if (numAllTracks > 0)
{
XmlNodeRef objNode = writeNode->createNode(CleanXMLText(pObjectNode->GetName()).toUtf8().data());
writeNode->setAttr("time", m_animTimeExportMasterSequenceCurrentTime);
writeNode->setAttr("time", m_animTimeExportPrimarySequenceCurrentTime);
for (unsigned int trackID = 0; trackID < numAllTracks; ++trackID)
{
@@ -1020,7 +945,7 @@ void CExportManager::FillAnimTimeNode(XmlNodeRef writeNode, CTrackViewAnimNode*
XmlNodeRef keyNode = subNode->createNode(keyContentName.toUtf8().data());
float keyGlobalTime = m_animTimeExportMasterSequenceCurrentTime + keyTime;
float keyGlobalTime = m_animTimeExportPrimarySequenceCurrentTime + keyTime;
keyNode->setAttr("keyTime", keyGlobalTime);
if (keyStartTime > 0)
@@ -1123,13 +1048,13 @@ bool CExportManager::AddObjectsFromSequence(CTrackViewSequence* pSequence, XmlNo
const QString sequenceName = pSubSequence->GetName();
XmlNodeRef subSeqNode2 = seqNode->createNode(sequenceName.toUtf8().data());
if (sequenceName == m_animTimeExportMasterSequenceName)
if (sequenceName == m_animTimeExportPrimarySequenceName)
{
m_animTimeExportMasterSequenceCurrentTime = sequenceKey.time;
m_animTimeExportPrimarySequenceCurrentTime = sequenceKey.time;
}
else
{
m_animTimeExportMasterSequenceCurrentTime += sequenceKey.time;
m_animTimeExportPrimarySequenceCurrentTime += sequenceKey.time;
}
AddObjectsFromSequence(pSubSequence, subSeqNode2);
@@ -1336,7 +1261,7 @@ bool CExportManager::Export(const char* defaultName, const char* defaultExt, con
{
m_numberOfExportFrames = pSequence->GetTimeRange().end * m_FBXBakedExportFPS;
if (!m_bExportOnlyMasterCamera)
if (!m_bExportOnlyPrimaryCamera)
{
AddObjectsFromSequence(pSequence);
}
@@ -1365,10 +1290,10 @@ bool CExportManager::Export(const char* defaultName, const char* defaultExt, con
return returnRes;
}
void CExportManager::SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyMasterCamera, const float fps)
void CExportManager::SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyPrimaryCamera, const float fps)
{
m_bExportLocalCoords = bLocalCoordsToSelectedObject;
m_bExportOnlyMasterCamera = bExportOnlyMasterCamera;
m_bExportOnlyPrimaryCamera = bExportOnlyPrimaryCamera;
m_FBXBakedExportFPS = fps;
}
@@ -1439,10 +1364,10 @@ void CExportManager::SaveNodeKeysTimeToXML()
if (dlg.exec())
{
m_animTimeNode = XmlHelpers::CreateXmlNode(pSequence->GetName());
m_animTimeExportMasterSequenceName = pSequence->GetName();
m_animTimeExportPrimarySequenceName = pSequence->GetName();
m_data.Clear();
m_animTimeExportMasterSequenceCurrentTime = 0.0;
m_animTimeExportPrimarySequenceCurrentTime = 0.0;
AddObjectsFromSequence(pSequence, m_animTimeNode);
+4 -6
View File
@@ -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;
@@ -171,7 +169,7 @@ private:
bool AddObjectsFromSequence(CTrackViewSequence* pSequence, XmlNodeRef seqNode = 0);
bool IsDuplicateObjectBeingAdded(const QString& newObject);
void SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyMasterCamera, const float fps);
void SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyPrimaryCamera, const float fps);
bool ProcessObjectsForExport();
bool ShowFBXExportDialog();
@@ -193,13 +191,13 @@ private:
float m_FBXBakedExportFPS;
bool m_bExportLocalCoords;
bool m_bExportOnlyMasterCamera;
bool m_bExportOnlyPrimaryCamera;
int m_numberOfExportFrames;
CEntityObject* m_pivotEntityObject;
bool m_bBakedKeysSequenceExport;
QString m_animTimeExportMasterSequenceName;
float m_animTimeExportMasterSequenceCurrentTime;
QString m_animTimeExportPrimarySequenceName;
float m_animTimeExportPrimarySequenceCurrentTime;
XmlNodeRef m_animTimeNode;
bool m_animKeyTimeExport;
+3 -3
View File
@@ -55,9 +55,9 @@ bool CFBXExporterDialog::GetExportCoordsLocalToTheSelectedObject() const
return m_ui->m_exportLocalCoordsCheckbox->isChecked();
}
bool CFBXExporterDialog::GetExportOnlyMasterCamera() const
bool CFBXExporterDialog::GetExportOnlyPrimaryCamera() const
{
return m_ui->m_exportOnlyMasterCameraCheckBox->isChecked();
return m_ui->m_exportOnlyPrimaryCameraCheckBox->isChecked();
}
void CFBXExporterDialog::SetExportLocalCoordsCheckBoxEnable(bool checked)
@@ -100,7 +100,7 @@ int CFBXExporterDialog::exec()
if (m_bDisplayOnlyFPSSetting)
{
m_ui->m_exportLocalCoordsCheckbox->setEnabled(false);
m_ui->m_exportOnlyMasterCameraCheckBox->setEnabled(false);
m_ui->m_exportOnlyPrimaryCameraCheckBox->setEnabled(false);
}
m_ui->m_fpsCombo->addItem("24");
+2 -2
View File
@@ -36,7 +36,7 @@ public:
float GetFPS() const;
bool GetExportCoordsLocalToTheSelectedObject() const;
bool GetExportOnlyMasterCamera() const;
bool GetExportOnlyPrimaryCamera() const;
void SetExportLocalCoordsCheckBoxEnable(bool checked);
int exec() override;
@@ -44,7 +44,7 @@ public:
protected:
void OnFPSChange();
void SetExportLocalToTheSelectedObjectCheckBox();
void SetExportOnlyMasterCameraCheckBox();
void SetExportOnlyPrimaryCameraCheckBox();
void accept() override;
+2 -2
View File
@@ -49,9 +49,9 @@
</layout>
</item>
<item>
<widget class="QCheckBox" name="m_exportOnlyMasterCameraCheckBox">
<widget class="QCheckBox" name="m_exportOnlyPrimaryCameraCheckBox">
<property name="text">
<string>Export Only Master Camera</string>
<string>Export Only Primary Camera</string>
</property>
</widget>
</item>
+34 -148
View File
@@ -27,17 +27,11 @@
#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>
@@ -125,9 +119,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
{
QDir::setCurrent(pEditor->GetPrimaryCDFolder());
// Close all Editor tools
pEditor->SetEditTool(0);
QString sLevelPath = Path::AddSlash(pGameEngine->GetLevelPath());
if (subdirectory && subdirectory[0] && strcmp(subdirectory, ".") != 0)
{
@@ -142,7 +133,10 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
// Make sure we unload any unused CGFs before exporting so that they don't end up in
// the level data.
pEditor->Get3DEngine()->FreeUnusedCGFResources();
if (pEditor->Get3DEngine())
{
pEditor->Get3DEngine()->FreeUnusedCGFResources();
}
CCryEditDoc* pDocument = pEditor->GetDocument();
@@ -192,14 +186,6 @@ 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
////////////////////////////////////////////////////////////////////////
@@ -219,7 +205,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
ExportLevelInfo(sLevelPath);
ExportLevelLensFlares(sLevelPath);
ExportLevelResourceList(sLevelPath);
ExportLevelUsedResourceList(sLevelPath);
ExportLevelShaderCache(sLevelPath);
@@ -285,7 +270,7 @@ void CGameExporter::ExportVisAreas(const char* pszGamePath, EEndian eExportEndia
SHotUpdateInfo exportInfo;
I3DEngine* p3DEngine = pEditor->Get3DEngine();
if (eExportEndian == GetPlatformEndian()) // skip second export, this data is common for PC and consoles
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;
@@ -349,11 +334,6 @@ void CGameExporter::ExportLevelData(const QString& path, bool bExportMission)
ExportMapInfo(root);
//////////////////////////////////////////////////////////////////////////
// Export materials.
ExportMaterials(root, path);
//////////////////////////////////////////////////////////////////////////
CCryEditDoc* pDocument = pEditor->GetDocument();
CMission* pCurrentMission = 0;
@@ -370,25 +350,28 @@ void CGameExporter::ExportLevelData(const QString& path, bool bExportMission)
QString missionFileName;
QString currentMissionFileName;
I3DEngine* p3DEngine = pEditor->Get3DEngine();
for (int i = 0; i < pDocument->GetMissionCount(); i++)
if (p3DEngine)
{
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)
for (int i = 0; i < pDocument->GetMissionCount(); i++)
{
currentMissionFileName = missionFileName;
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;
}
}
}
@@ -416,7 +399,10 @@ void CGameExporter::ExportLevelData(const QString& path, bool bExportMission)
XmlNodeRef missionNode = rootAction->createNode("Mission");
pCurrentMission->Export(missionNode, objectsNode);
missionNode->setAttr("CGFCount", p3DEngine->GetLoadedObjectCount());
if (p3DEngine)
{
missionNode->setAttr("CGFCount", p3DEngine->GetLoadedObjectCount());
}
//if (!CFileUtil::OverwriteFile( path+currentMissionFileName ))
// return;
@@ -486,6 +472,11 @@ void CGameExporter::ExportLevelInfo(const QString& path)
//////////////////////////////////////////////////////////////////////////
void CGameExporter::ExportMapInfo(XmlNodeRef& node)
{
if (!GetIEditor()->Get3DEngine())
{
return;
}
XmlNodeRef info = node->newChild("LevelInfo");
IEditor* pEditor = GetIEditor();
@@ -508,111 +499,6 @@ void CGameExporter::ExportMapInfo(XmlNodeRef& node)
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);
}
//////////////////////////////////////////////////////////////////////////
-2
View File
@@ -95,11 +95,9 @@ private:
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
-64
View File
@@ -40,18 +40,14 @@ struct QMetaObject;
class CBaseObject;
class CCryEditDoc;
class CSelectionGroup;
class CEditTool;
class CAnimationContext;
class CTrackViewSequenceManager;
class CGameEngine;
struct IIconManager;
class CToolBoxManager;
class CClassFactory;
class CMaterialManager;
class CMusicManager;
class CMaterail;
struct IEditorParticleManager;
class CLensFlareManager;
class CEAXPresetManager;
class CErrorReport;
class CBaseLibraryItem;
@@ -319,17 +315,6 @@ enum EOperationMode
eModellingMode // Geometry modeling mode
};
enum EEditMode
{
eEditModeSelect,
eEditModeSelectArea,
eEditModeMove,
eEditModeRotate,
eEditModeScale,
eEditModeTool,
eEditModeRotateCircle,
};
//! Mouse events that viewport can send
enum EMouseEvent
{
@@ -391,21 +376,6 @@ enum EModifiedModule
eModifiedAll = -1
};
//! Callback class passed to PickObject.
struct IPickObjectCallback
{
virtual ~IPickObjectCallback() = default;
//! Called when object picked.
virtual void OnPick(CBaseObject* picked) = 0;
//! Called when pick mode cancelled.
virtual void OnCancelPick() = 0;
//! Return true if specified object is pickable.
virtual bool OnPickFilter([[maybe_unused]] CBaseObject* filterObject) { return true; };
//! If need a specific behavior when holding space, return true or if not, return false.
virtual bool IsNeedSpecificBehaviorForSpaceAcce() { return false; }
};
//! Class provided by editor for various registration functions.
struct CRegistrationContext
{
@@ -570,24 +540,8 @@ struct IEditor
//! Get access to object manager.
virtual struct IObjectManager* GetObjectManager() = 0;
virtual CSettingsManager* GetSettingsManager() = 0;
//! Set pick object mode.
//! When object picked callback will be called, with OnPick
//! If pick operation is canceled Cancel will be called
//! @param targetClass specifies objects of which class are supposed to be picked
//! @param bMultipick if true pick tool will pick multiple object
virtual void PickObject(
IPickObjectCallback* callback,
const QMetaObject* targetClass = 0,
const char* statusText = 0,
bool bMultipick = false) = 0;
//! Cancel current pick operation
virtual void CancelPick() = 0;
//! Return true if editor now in object picking mode
virtual bool IsPicking() = 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.
@@ -596,8 +550,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;
@@ -649,17 +601,6 @@ struct IEditor
virtual void SetOperationMode(EOperationMode mode) = 0;
virtual EOperationMode GetOperationMode() = 0;
//! editMode - EEditMode
virtual void SetEditMode(int editMode) = 0;
virtual int GetEditMode() = 0;
//! Assign current edit tool, destroy previously used edit too.
virtual void SetEditTool(CEditTool* tool, bool bStopCurrentTool = true) = 0;
//! Assign current edit tool by class name.
virtual void SetEditTool(const QString& sEditToolName, bool bStopCurrentTool = true) = 0;
//! Reinitializes the current edit tool if one is selected.
virtual void ReinitializeEditTool() = 0;
//! Returns current edit tool.
virtual CEditTool* GetEditTool() = 0;
//! Shows/Hides transformation manipulator.
//! if bShow is true also returns a valid ITransformManipulator pointer.
virtual ITransformManipulator* ShowTransformManipulator(bool bShow) = 0;
@@ -684,9 +625,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;
@@ -814,8 +752,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
+4 -348
View File
@@ -53,32 +53,24 @@ AZ_POP_DISABLE_WARNING
#include "KeyboardCustomizationSettings.h"
#include "Export/ExportManager.h"
#include "LevelIndependentFileMan.h"
#include "Material/MaterialManager.h"
#include "Material/MaterialPickTool.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"
#include "PickObjectTool.h"
#include "Settings.h"
#include "Include/IObjectManager.h"
#include "Include/ISourceControl.h"
#include "Objects/SelectionGroup.h"
#include "Objects/ObjectManager.h"
#include "RotateTool.h"
#include "NullEditTool.h"
#include "BackgroundTaskManager.h"
#include "BackgroundScheduleManager.h"
#include "EditorFileMonitor.h"
#include "EditMode/VertexSnappingModeTool.h"
#include "Mission.h"
#include "MainStatusBar.h"
@@ -150,8 +142,7 @@ namespace
const char* CEditorImpl::m_crashLogFileName = "SessionStatus/editor_statuses.json";
CEditorImpl::CEditorImpl()
: m_currEditMode(eEditModeSelect)
, m_operationMode(eOperationModeNone)
: m_operationMode(eOperationModeNone)
, m_pSystem(nullptr)
, m_pFileUtil(nullptr)
, m_pClassFactory(nullptr)
@@ -170,15 +161,12 @@ CEditorImpl::CEditorImpl()
, m_pShaderEnum(nullptr)
, m_pIconManager(nullptr)
, m_bSelectionLocked(true)
, m_pPickTool(nullptr)
, m_pAxisGizmo(nullptr)
, m_pGameEngine(nullptr)
, 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)
@@ -232,29 +220,15 @@ 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);
m_selectedRegion.max = Vec3(0, 0, 0);
ZeroStruct(m_lastAxis);
m_lastAxis[eEditModeSelect] = AXIS_TERRAIN;
m_lastAxis[eEditModeSelectArea] = AXIS_TERRAIN;
m_lastAxis[eEditModeMove] = AXIS_TERRAIN;
m_lastAxis[eEditModeRotate] = AXIS_Z;
m_lastAxis[eEditModeScale] = AXIS_XY;
ZeroStruct(m_lastCoordSys);
m_lastCoordSys[eEditModeSelect] = COORDS_LOCAL;
m_lastCoordSys[eEditModeSelectArea] = COORDS_LOCAL;
m_lastCoordSys[eEditModeMove] = COORDS_WORLD;
m_lastCoordSys[eEditModeRotate] = COORDS_WORLD;
m_lastCoordSys[eEditModeScale] = COORDS_WORLD;
DetectVersion();
RegisterTools();
@@ -264,8 +238,6 @@ CEditorImpl::CEditorImpl()
m_pAssetBrowserRequestHandler = nullptr;
m_assetEditorRequestsHandler = nullptr;
AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusConnect();
AZ::IO::SystemFile::CreateDir("SessionStatus");
QFile::setPermissions(m_crashLogFileName, QFileDevice::ReadOther | QFileDevice::WriteOther);
}
@@ -289,8 +261,6 @@ void CEditorImpl::Initialize()
// Activate QT immediately so that its available as soon as CEditorImpl is (and thus GetIEditor())
InitializeEditorCommon(GetIEditor());
LoadSettings();
}
//The only purpose of that function is to be called at the very begining of the shutdown sequence so that we can instrument and track
@@ -305,8 +275,6 @@ void CEditorImpl::OnEarlyExitShutdownSequence()
void CEditorImpl::Uninitialize()
{
SaveSettings();
if (m_pSystem)
{
UninitializeEditorCommonISystem(m_pSystem);
@@ -367,13 +335,10 @@ void CEditorImpl::LoadPlugins()
CEditorImpl::~CEditorImpl()
{
AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusDisconnect();
gSettings.Save();
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)
@@ -443,7 +408,6 @@ void CEditorImpl::SetGameEngine(CGameEngine* ge)
m_pObjectManager->LoadClassTemplates("Editor");
m_pObjectManager->RegisterCVars();
m_pMaterialManager->Set3DEngine();
m_pAnimationContext->Init();
}
@@ -453,12 +417,6 @@ void CEditorImpl::RegisterTools()
rc.pCommandManager = m_pCommandManager;
rc.pClassFactory = m_pClassFactory;
CObjectMode::RegisterTool(rc);
CMaterialPickTool::RegisterTool(rc);
CVertexSnappingModeTool::RegisterTool(rc);
CRotateTool::RegisterTool(rc);
NullEditTool::RegisterTool(rc);
}
void CEditorImpl::ExecuteCommand(const char* sCommand, ...)
@@ -663,53 +621,6 @@ IMainStatusBar* CEditorImpl::GetMainStatusBar()
return MainWindow::instance()->StatusBar();
}
int CEditorImpl::GetEditMode()
{
return m_currEditMode;
}
void CEditorImpl::SetEditMode(int editMode)
{
bool isEditorInGameMode = false;
EBUS_EVENT_RESULT(isEditorInGameMode, AzToolsFramework::EditorEntityContextRequestBus, IsEditorRunningGame);
if (isEditorInGameMode)
{
if (editMode != eEditModeSelect)
{
if (SelectionContainsComponentEntities())
{
return;
}
}
}
if ((EEditMode)editMode == eEditModeRotate)
{
if (GetEditTool() && GetEditTool()->IsCircleTypeRotateGizmo())
{
editMode = eEditModeRotateCircle;
}
}
EEditMode newEditMode = (EEditMode)editMode;
if (m_currEditMode == newEditMode)
{
return;
}
m_currEditMode = newEditMode;
AABB box(Vec3(0, 0, 0), Vec3(0, 0, 0));
SetSelectedRegion(box);
if (GetEditTool() && !GetEditTool()->IsNeedMoveTool())
{
SetEditTool(0, true);
}
Notify(eNotify_OnEditModeChange);
}
void CEditorImpl::SetOperationMode(EOperationMode mode)
{
m_operationMode = mode;
@@ -721,144 +632,6 @@ EOperationMode CEditorImpl::GetOperationMode()
return m_operationMode;
}
bool CEditorImpl::HasCorrectEditTool() const
{
if (!m_pEditTool)
{
return false;
}
switch (m_currEditMode)
{
case eEditModeRotate:
return qobject_cast<CRotateTool*>(m_pEditTool) != nullptr;
default:
return qobject_cast<CObjectMode*>(m_pEditTool) != nullptr && qobject_cast<CRotateTool*>(m_pEditTool) == nullptr;
}
}
CEditTool* CEditorImpl::CreateCorrectEditTool()
{
if (m_currEditMode == eEditModeRotate)
{
CBaseObject* selectedObj = nullptr;
CSelectionGroup* pSelection = GetIEditor()->GetObjectManager()->GetSelection();
if (pSelection && pSelection->GetCount() > 0)
{
selectedObj = pSelection->GetObject(0);
}
return (new CRotateTool(selectedObj));
}
return (new CObjectMode);
}
void CEditorImpl::SetEditTool(CEditTool* tool, bool bStopCurrentTool)
{
CViewport* pViewport = GetIEditor()->GetActiveView();
if (pViewport)
{
pViewport->SetCurrentCursor(STD_CURSOR_DEFAULT);
}
if (!tool)
{
if (HasCorrectEditTool())
{
return;
}
else
{
tool = CreateCorrectEditTool();
}
}
if (!tool->Activate(m_pEditTool))
{
return;
}
if (bStopCurrentTool)
{
if (m_pEditTool && m_pEditTool != tool)
{
m_pEditTool->EndEditParams();
SetStatusText("Ready");
}
}
m_pEditTool = tool;
if (m_pEditTool)
{
m_pEditTool->BeginEditParams(this, 0);
}
// Make sure pick is aborted.
if (tool != m_pPickTool)
{
m_pPickTool = nullptr;
}
Notify(eNotify_OnEditToolChange);
}
void CEditorImpl::ReinitializeEditTool()
{
if (m_pEditTool)
{
m_pEditTool->EndEditParams();
m_pEditTool->BeginEditParams(this, 0);
}
}
void CEditorImpl::SetEditTool(const QString& sEditToolName, [[maybe_unused]] bool bStopCurrentTool)
{
CEditTool* pTool = GetEditTool();
if (pTool && pTool->GetClassDesc())
{
// Check if already selected.
if (QString::compare(pTool->GetClassDesc()->ClassName(), sEditToolName, Qt::CaseInsensitive) == 0)
{
return;
}
}
IClassDesc* pClass = GetIEditor()->GetClassFactory()->FindClass(sEditToolName.toUtf8().data());
if (!pClass)
{
Warning("Editor Tool %s not registered.", sEditToolName.toUtf8().data());
return;
}
if (pClass->SystemClassID() != ESYSTEM_CLASS_EDITTOOL)
{
Warning("Class name %s is not a valid Edit Tool class.", sEditToolName.toUtf8().data());
return;
}
QScopedPointer<QObject> o(pClass->CreateQObject());
if (CEditTool* pEditTool = qobject_cast<CEditTool*>(o.data()))
{
GetIEditor()->SetEditTool(pEditTool);
o.take();
return;
}
else
{
Warning("Class name %s is not a valid Edit Tool class.", sEditToolName.toUtf8().data());
return;
}
}
CEditTool* CEditorImpl::GetEditTool()
{
if (m_isNewViewportInteractionModelEnabled)
{
return nullptr;
}
return m_pEditTool;
}
ITransformManipulator* CEditorImpl::ShowTransformManipulator(bool bShow)
{
if (bShow)
@@ -892,7 +665,6 @@ ITransformManipulator* CEditorImpl::GetTransformManipulator()
void CEditorImpl::SetAxisConstraints(AxisConstrains axisFlags)
{
m_selectedAxis = axisFlags;
m_lastAxis[m_currEditMode] = m_selectedAxis;
m_pViewManager->SetAxisConstrain(axisFlags);
SetTerrainAxisIgnoreObjects(false);
@@ -918,7 +690,6 @@ bool CEditorImpl::IsTerrainAxisIgnoreObjects()
void CEditorImpl::SetReferenceCoordSys(RefCoordSys refCoords)
{
m_refCoordsSys = refCoords;
m_lastCoordSys[m_currEditMode] = m_refCoordsSys;
// Update all views.
UpdateViews(eUpdateObjects, NULL);
@@ -1069,34 +840,6 @@ bool CEditorImpl::IsSelectionLocked()
return m_bSelectionLocked;
}
void CEditorImpl::PickObject(IPickObjectCallback* callback, const QMetaObject* targetClass, const char* statusText, bool bMultipick)
{
m_pPickTool = new CPickObjectTool(callback, targetClass);
static_cast<CPickObjectTool*>(m_pPickTool.get())->SetMultiplePicks(bMultipick);
if (statusText)
{
m_pPickTool.get()->SetStatusText(statusText);
}
SetEditTool(m_pPickTool);
}
void CEditorImpl::CancelPick()
{
SetEditTool(0);
m_pPickTool = 0;
}
bool CEditorImpl::IsPicking()
{
if (GetEditTool() == m_pPickTool && m_pPickTool != 0)
{
return true;
}
return false;
}
CViewManager* CEditorImpl::GetViewManager()
{
return m_pViewManager;
@@ -1252,39 +995,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);
@@ -2047,13 +1762,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()
@@ -2071,65 +1786,6 @@ void CEditorImpl::DestroyQMimeData(QMimeData* data) const
delete data;
}
bool CEditorImpl::IsNewViewportInteractionModelEnabled() const
{
return m_isNewViewportInteractionModelEnabled;
}
void CEditorImpl::OnStartPlayInEditor()
{
if (SelectionContainsComponentEntities())
{
SetEditMode(eEditModeSelect);
}
}
namespace
{
const std::vector<std::pair<EEditMode, QString>> s_editModeNames = {
{ eEditModeSelect, QStringLiteral("Select") },
{ eEditModeSelectArea, QStringLiteral("SelectArea") },
{ eEditModeMove, QStringLiteral("Move") },
{ eEditModeRotate, QStringLiteral("Rotate") },
{ eEditModeScale, QStringLiteral("Scale") }
};
}
void CEditorImpl::LoadSettings()
{
QSettings settings(QStringLiteral("Amazon"), QStringLiteral("O3DE"));
settings.beginGroup(QStringLiteral("Editor"));
settings.beginGroup(QStringLiteral("CoordSys"));
for (const auto& editMode : s_editModeNames)
{
if (settings.contains(editMode.second))
{
m_lastCoordSys[editMode.first] = static_cast<RefCoordSys>(settings.value(editMode.second).toInt());
}
}
settings.endGroup(); // CoordSys
settings.endGroup(); // Editor
}
void CEditorImpl::SaveSettings() const
{
QSettings settings(QStringLiteral("Amazon"), QStringLiteral("O3DE"));
settings.beginGroup(QStringLiteral("Editor"));
settings.beginGroup(QStringLiteral("CoordSys"));
for (const auto& editMode : s_editModeNames)
{
settings.setValue(editMode.second, static_cast<int>(m_lastCoordSys[editMode.first]));
}
settings.endGroup(); // CoordSys
settings.endGroup(); // Editor
}
IEditorPanelUtils* CEditorImpl::GetEditorPanelUtils()
{
return m_panelEditorUtils;
+1 -42
View File
@@ -23,7 +23,6 @@
#include <memory> // for shared_ptr
#include <QMap>
#include <QApplication>
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
#include <AzToolsFramework/Thumbnails/ThumbnailerBus.h>
#include <AzCore/std/string/string.h>
@@ -43,7 +42,6 @@ class CUndoManager;
class CGameEngine;
class CExportManager;
class CErrorsDlg;
class CLensFlareManager;
class CIconManager;
class CBackgroundTaskManager;
class CTrackViewSequenceManager;
@@ -86,13 +84,12 @@ namespace AssetDatabase
class CEditorImpl
: public IEditor
, protected AzToolsFramework::EditorEntityContextNotificationBus::Handler
{
Q_DECLARE_TR_FUNCTIONS(CEditorImpl)
public:
CEditorImpl();
~CEditorImpl();
virtual ~CEditorImpl();
void Initialize();
void OnBeginShutdownSequence();
@@ -181,14 +178,9 @@ public:
void SelectObject(CBaseObject* obj);
void LockSelection(bool bLock);
bool IsSelectionLocked();
void PickObject(IPickObjectCallback* callback, const QMetaObject* targetClass = 0, const char* statusText = 0, bool bMultipick = false);
void CancelPick();
bool IsPicking();
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;
@@ -229,20 +221,6 @@ public:
void SetDataModified();
void SetOperationMode(EOperationMode mode);
EOperationMode GetOperationMode();
void SetEditMode(int editMode);
int GetEditMode();
//! A correct tool is one that corresponds to the previously set edit mode.
bool HasCorrectEditTool() const;
//! Returns the edit tool required for the edit mode specified.
CEditTool* CreateCorrectEditTool();
void SetEditTool(CEditTool* tool, bool bStopCurrentTool = true) override;
void SetEditTool(const QString& sEditToolName, bool bStopCurrentTool = true) override;
void ReinitializeEditTool() override;
//! Returns current edit tool.
CEditTool* GetEditTool() override;
ITransformManipulator* ShowTransformManipulator(bool bShow);
ITransformManipulator* GetTransformManipulator();
@@ -256,7 +234,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;
@@ -359,27 +336,17 @@ public:
QMimeData* CreateQMimeData() const override;
void DestroyQMimeData(QMimeData* data) const override;
bool IsNewViewportInteractionModelEnabled() const override;
protected:
//////////////////////////////////////////////////////////////////////////
// EditorEntityContextNotificationBus implementation
void OnStartPlayInEditor() override;
//////////////////////////////////////////////////////////////////////////
AZStd::string LoadProjectIdFromProjectData();
void DetectVersion();
void RegisterTools();
void SetPrimaryCDFolder();
void LoadSettings();
void SaveSettings() const;
//! List of all notify listeners.
std::list<IEditorNotifyListener*> m_listeners;
EEditMode m_currEditMode;
EOperationMode m_operationMode;
ISystem* m_pSystem;
IFileUtil* m_pFileUtil;
@@ -393,8 +360,6 @@ protected:
AABB m_selectedRegion;
AxisConstrains m_selectedAxis;
RefCoordSys m_refCoordsSys;
AxisConstrains m_lastAxis[16];
RefCoordSys m_lastCoordSys[16];
bool m_bAxisVectorLock;
bool m_bUpdates;
bool m_bTerrainAxisIgnoreObjects;
@@ -403,22 +368,18 @@ protected:
CXmlTemplateRegistry m_templateRegistry;
CDisplaySettings* m_pDisplaySettings;
CShaderEnum* m_pShaderEnum;
_smart_ptr<CEditTool> m_pEditTool;
CIconManager* m_pIconManager;
std::unique_ptr<SGizmoParameters> m_pGizmoParameters;
QString m_primaryCDFolder;
QString m_userFolder;
bool m_bSelectionLocked;
_smart_ptr<CEditTool> m_pPickTool;
class CAxisGizmo* m_pAxisGizmo;
CGameEngine* m_pGameEngine;
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;
@@ -474,7 +435,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;
};
+11 -11
View File
@@ -27,27 +27,27 @@
#include "Util/ImageUtil.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",
};
};
@@ -25,4 +25,4 @@ struct IEditorMaterial
virtual void DisableHighlightForFrame() = 0;
};
#endif
#endif
@@ -21,7 +21,6 @@
#include <IValidator.h>
// forward declarations.
class CMaterial;
class CParticleItem;
class CBaseObject;
class CBaseLibraryItem;
@@ -24,7 +24,6 @@ class CUsedResources;
class CSelectionGroup;
class CObjectClassDesc;
class CObjectArchive;
class CObjectPhysicsManager;
class CViewport;
struct HitContext;
enum class ImageRotationDegrees;
@@ -188,8 +187,6 @@ public:
virtual void SetSelection(const QString& name) = 0;
//! Removes one of named selections.
virtual void RemoveSelection(const QString& name) = 0;
//! Checks for changes to the current selection and makes adjustments accordingly
virtual void CheckAndFixSelection() = 0;
//! Delete all objects in current selection group.
virtual void DeleteSelection() = 0;
@@ -249,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:
//
+18 -521
View File
@@ -22,15 +22,15 @@
#include "Include/ITransformManipulator.h"
#include "ActionManager.h"
#include "Settings.h"
#include "Objects/SelectionGroup.h"
#include "Include/IObjectManager.h"
#include "MathConversion.h"
#include "EditTool.h"
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
#include <ui_InfoBar.h>
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
#include <QLineEdit>
#include <AzQtComponents/Components/Style.h>
#include "CryPhysicsDeprecation.h"
@@ -53,12 +53,7 @@ CInfoBar::CInfoBar(QWidget* parent)
{
ui->setupUi(this);
m_enabledVector = false;
m_bVectorLock = false;
m_prevEditMode = 0;
m_bSelectionLocked = false;
m_bSelectionChanged = false;
m_editTool = 0;
m_bDragMode = false;
m_prevMoveSpeed = 0;
m_currValue = Vec3(-111, +222, -333); //this wasn't initialized. I don't know what a good value is
@@ -72,25 +67,14 @@ CInfoBar::CInfoBar(QWidget* parent)
OnInitDialog();
connect(ui->m_vectorLock, &QToolButton::clicked, this, &CInfoBar::OnVectorLock);
connect(ui->m_lockSelection, &QToolButton::clicked, this, &CInfoBar::OnLockSelection);
auto comboBoxTextChanged = static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::currentTextChanged);
connect(ui->m_moveSpeed, comboBoxTextChanged, this, &CInfoBar::OnUpdateMoveSpeedText);
connect(ui->m_moveSpeed->lineEdit(), &QLineEdit::returnPressed, this, &CInfoBar::OnSpeedComboBoxEnter);
connect(ui->m_posCtrl, &AzQtComponents::VectorInput::valueChanged, this, &CInfoBar::OnVectorChanged);
// Hide some buttons from the expander menu
AzQtComponents::Style::addClass(ui->m_posCtrl, "expanderMenu_hide");
AzQtComponents::Style::addClass(ui->m_physDoStepBtn, "expanderMenu_hide");
AzQtComponents::Style::addClass(ui->m_physSingleStepBtn, "expanderMenu_hide");
// posCtrl is a VectorInput initialized via UI; as such, we can't construct it to have only 3 elements.
// We can just hide the W element as it is unused.
ui->m_posCtrl->getElements()[3]->setVisible(false);
connect(ui->m_setVector, &QToolButton::clicked, this, &CInfoBar::OnBnClickedSetVector);
connect(ui->m_physicsBtn, &QToolButton::clicked, this, &CInfoBar::OnBnClickedPhysics);
connect(ui->m_physSingleStepBtn, &QToolButton::clicked, this, &CInfoBar::OnBnClickedSingleStepPhys);
connect(ui->m_physDoStepBtn, &QToolButton::clicked, this, &CInfoBar::OnBnClickedDoStepPhys);
@@ -101,12 +85,6 @@ CInfoBar::CInfoBar(QWidget* parent)
connect(this, &CInfoBar::ActionTriggered, MainWindow::instance()->GetActionManager(), &ActionManager::ActionTriggered);
connect(ui->m_lockSelection, &QAbstractButton::toggled, ui->m_lockSelection, [this](bool checked) {
ui->m_lockSelection->setToolTip(checked ? tr("Unlock Object Selection") : tr("Lock Object Selection"));
});
connect(ui->m_vectorLock, &QAbstractButton::toggled, ui->m_vectorLock, [this](bool checked) {
ui->m_vectorLock->setToolTip(checked ? tr("Unlock Axis Vectors") : tr("Lock Axis Vectors"));
});
connect(ui->m_physicsBtn, &QAbstractButton::toggled, ui->m_physicsBtn, [this](bool checked) {
ui->m_physicsBtn->setToolTip(checked ? tr("Stop Simulation (Ctrl+P)") : tr("Simulate (Ctrl+P)"));
});
@@ -123,27 +101,6 @@ CInfoBar::CInfoBar(QWidget* parent)
ui->m_vrBtn->setToolTip(checked ? tr("Disable VR Preview") : tr("Enable VR Preview"));
});
// hide old ui elements that are not valid with the new viewport interaction model
if (GetIEditor()->IsNewViewportInteractionModelEnabled())
{
ui->m_lockSelection->setVisible(false);
AzQtComponents::Style::addClass(ui->m_lockSelection, "expanderMenu_hide");
ui->m_posCtrl->setVisible(false);
AzQtComponents::Style::addClass(ui->m_posCtrl, "expanderMenu_hide");
ui->m_setVector->setVisible(false);
AzQtComponents::Style::addClass(ui->m_setVector, "expanderMenu_hide");
ui->m_vectorLock->setVisible(false);
AzQtComponents::Style::addClass(ui->m_vectorLock, "expanderMenu_hide");
// As we're hiding some of the icons, we have an extra spacer to deal with.
// We cannot set the visibility of separators, so we'll have to take it out.
int separatorIndex = layout()->indexOf(ui->verticalSpacer_2);
QLayoutItem* separator = layout()->takeAt(separatorIndex);
// takeAt() removes the item from the layout; delete to avoid memory leaks.
delete separator;
}
ui->m_moveSpeed->setValidator(new QDoubleValidator(m_minSpeed, m_maxSpeed, m_numDecimals, ui->m_moveSpeed));
// Save off the move speed here since setting up the combo box can cause it to update values in the background.
@@ -209,172 +166,6 @@ void CInfoBar::OnEditorNotifyEvent(EEditorNotifyEvent event)
{
m_bSelectionChanged = true;
}
else if (event == eNotify_OnEditModeChange)
{
int emode = GetIEditor()->GetEditMode();
switch (emode)
{
case eEditModeMove:
ui->m_setVector->setToolTip(tr("Set Position of Selected Objects"));
break;
case eEditModeRotate:
ui->m_setVector->setToolTip(tr("Set Rotation of Selected Objects"));
break;
case eEditModeScale:
ui->m_setVector->setToolTip(tr("Set Scale of Selected Objects"));
break;
default:
ui->m_setVector->setToolTip(tr("Set Position/Rotation/Scale of Selected Objects (None Selected)"));
break;
}
}
}
//////////////////////////////////////////////////////////////////////////
void CInfoBar::OnVectorChanged()
{
SetVector(GetVector());
OnVectorUpdate(false);
}
void CInfoBar::OnVectorUpdate(bool followTerrain)
{
int emode = GetIEditor()->GetEditMode();
if (emode != eEditModeMove && emode != eEditModeRotate && emode != eEditModeScale)
{
return;
}
Vec3 v = GetVector();
ITransformManipulator* pManipulator = GetIEditor()->GetTransformManipulator();
if (pManipulator)
{
CEditTool* pEditTool = GetIEditor()->GetEditTool();
if (pEditTool)
{
Vec3 diff = v - m_lastValue;
if (emode == eEditModeMove)
{
//GetIEditor()->RestoreUndo();
pEditTool->OnManipulatorDrag(GetIEditor()->GetActiveView(), pManipulator, diff);
}
if (emode == eEditModeRotate)
{
diff = DEG2RAD(diff);
//GetIEditor()->RestoreUndo();
pEditTool->OnManipulatorDrag(GetIEditor()->GetActiveView(), pManipulator, diff);
}
if (emode == eEditModeScale)
{
//GetIEditor()->RestoreUndo();
pEditTool->OnManipulatorDrag(GetIEditor()->GetActiveView(), pManipulator, diff);
}
}
return;
}
CSelectionGroup* selection = GetIEditor()->GetObjectManager()->GetSelection();
if (selection->IsEmpty())
{
return;
}
GetIEditor()->RestoreUndo();
int referenceCoordSys = GetIEditor()->GetReferenceCoordSys();
CBaseObject* obj = GetIEditor()->GetSelectedObject();
Matrix34 tm;
AffineParts ap;
if (obj)
{
tm = obj->GetWorldTM();
ap.SpectralDecompose(tm);
}
if (emode == eEditModeMove)
{
if (obj)
{
if (referenceCoordSys == COORDS_WORLD)
{
tm.SetTranslation(v);
obj->SetWorldTM(tm);
}
else
{
obj->SetPos(v);
}
}
else
{
GetIEditor()->GetSelection()->MoveTo(v, followTerrain ? CSelectionGroup::eMS_FollowTerrain : CSelectionGroup::eMS_None, referenceCoordSys);
}
}
if (emode == eEditModeRotate)
{
if (obj)
{
AZ::Vector3 av = LYVec3ToAZVec3(v);
AZ::Transform tr = AZ::ConvertEulerDegreesToTransform(av);
Matrix34 lyTransform = AZTransformToLYTransform(tr);
AffineParts newap;
newap.SpectralDecompose(lyTransform);
if (referenceCoordSys == COORDS_WORLD)
{
tm = Matrix34::Create(ap.scale, newap.rot, ap.pos);
obj->SetWorldTM(tm);
}
else
{
obj->SetRotation(newap.rot);
}
}
else
{
CBaseObject *refObj;
CSelectionGroup* pGroup = GetIEditor()->GetSelection();
if (pGroup && pGroup->GetCount() > 0)
{
refObj = pGroup->GetObject(0);
AffineParts ap2;
ap2.SpectralDecompose(refObj->GetWorldTM());
Vec3 oldEulerRotation = AZVec3ToLYVec3(AZ::ConvertQuaternionToEulerDegrees(LYQuaternionToAZQuaternion(ap2.rot)));
Vec3 diff = v - oldEulerRotation;
GetIEditor()->GetSelection()->Rotate((Ang3)diff, referenceCoordSys);
}
}
}
if (emode == eEditModeScale)
{
if (v.x == 0 || v.y == 0 || v.z == 0)
{
return;
}
if (obj)
{
if (referenceCoordSys == COORDS_WORLD)
{
tm = Matrix34::Create(v, ap.rot, ap.pos);
obj->SetWorldTM(tm);
}
else
{
obj->SetScale(v);
}
}
else
{
GetIEditor()->GetSelection()->SetScale(v, referenceCoordSys);
}
}
}
void CInfoBar::IdleUpdate()
@@ -399,61 +190,31 @@ void CInfoBar::IdleUpdate()
Vec3 marker = GetIEditor()->GetMarkerPosition();
/*
// Get active viewport.
int hx = marker.x / 2;
int hy = marker.y / 2;
if (m_heightMapX != hx || m_heightMapY != hy)
int selectedEntitiesCount = 0;
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
selectedEntitiesCount, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntitiesCount);
if (selectedEntitiesCount != m_numSelected)
{
m_heightMapX = hx;
m_heightMapY = hy;
m_numSelected = selectedEntitiesCount;
updateUI = true;
}
*/
RefCoordSys coordSys = GetIEditor()->GetReferenceCoordSys();
bool bWorldSpace = GetIEditor()->GetReferenceCoordSys() == COORDS_WORLD;
CSelectionGroup* selection = GetIEditor()->GetSelection();
if (selection->GetCount() != m_numSelected)
{
m_numSelected = selection->GetCount();
updateUI = true;
}
if (GetIEditor()->GetEditTool() != m_editTool)
{
updateUI = true;
m_editTool = GetIEditor()->GetEditTool();
}
QString str;
if (m_editTool)
{
str = m_editTool->GetStatusText();
if (str != m_sLastText)
{
updateUI = true;
}
}
if (updateUI)
{
if (!m_editTool)
if (m_numSelected == 0)
{
if (m_numSelected == 0)
{
str = tr("None Selected");
}
else if (m_numSelected == 1)
{
str = tr("1 Object Selected");
}
else
{
str = tr("%1 Objects Selected").arg(m_numSelected);
}
str = tr("None Selected");
}
else if (m_numSelected == 1)
{
str = tr("1 Object Selected");
}
else
{
str = tr("%1 Objects Selected").arg(m_numSelected);
}
ui->m_statusText->setText(str);
m_sLastText = str;
}
@@ -488,198 +249,11 @@ void CInfoBar::IdleUpdate()
}
}
bool bSelLocked = GetIEditor()->IsSelectionLocked();
if (bSelLocked != m_bSelectionLocked)
{
m_bSelectionLocked = bSelLocked;
ui->m_lockSelection->setChecked(m_bSelectionLocked);
}
if (GetIEditor()->GetSelection()->IsEmpty())
{
if (ui->m_lockSelection->isEnabled())
{
ui->m_lockSelection->setEnabled(false);
}
}
else
{
if (!ui->m_lockSelection->isEnabled())
{
ui->m_lockSelection->setEnabled(true);
}
}
//////////////////////////////////////////////////////////////////////////
// Update vector.
//////////////////////////////////////////////////////////////////////////
Vec3 v(0, 0, 0);
bool enable = false;
float min = 0, max = 10000;
int emode = GetIEditor()->GetEditMode();
ITransformManipulator* pManipulator = GetIEditor()->GetTransformManipulator();
if (pManipulator)
{
AffineParts ap;
ap.SpectralDecompose(pManipulator->GetTransformation(coordSys));
if (emode == eEditModeMove)
{
v = ap.pos;
enable = true;
min = -64000;
max = 64000;
}
if (emode == eEditModeRotate)
{
v = Vec3(RAD2DEG(Ang3::GetAnglesXYZ(Matrix33(ap.rot))));
enable = true;
min = -10000;
max = 10000;
}
if (emode == eEditModeScale)
{
v = ap.scale;
enable = true;
min = -10000;
max = 10000;
}
}
else
{
if (selection->IsEmpty())
{
// Show marker position.
EnableVector(false);
SetVector(marker);
SetVectorRange(-100000, 100000);
return;
}
CBaseObject* obj = GetIEditor()->GetSelectedObject();
if (!obj)
{
CSelectionGroup* pGroup = GetIEditor()->GetSelection();
if (pGroup && pGroup->GetCount() > 0)
{
obj = pGroup->GetObject(0);
}
}
if (obj)
{
v = obj->GetWorldPos();
}
if (emode == eEditModeMove)
{
if (obj)
{
if (bWorldSpace)
{
v = obj->GetWorldTM().GetTranslation();
}
else
{
v = obj->GetPos();
}
}
enable = true;
min = -64000;
max = 64000;
}
if (emode == eEditModeRotate)
{
if (obj)
{
Quat objRot;
if (bWorldSpace)
{
AffineParts ap;
ap.SpectralDecompose(obj->GetWorldTM());
objRot = ap.rot;
}
else
{
objRot = obj->GetRotation();
}
// Always convert objRot to v in order to ensure that the inspector and info bar are always in sync
v = AZVec3ToLYVec3(AZ::ConvertQuaternionToEulerDegrees(LYQuaternionToAZQuaternion(objRot)));
}
enable = true;
min = -10000;
max = 10000;
}
if (emode == eEditModeScale)
{
if (obj)
{
if (bWorldSpace)
{
AffineParts ap;
ap.SpectralDecompose(obj->GetWorldTM());
v = ap.scale;
}
else
{
v = obj->GetScale();
}
}
enable = true;
min = -10000;
max = 10000;
}
}
bool updateDisplayVector = (m_currValue != v);
// If Edit mode changed.
if (m_prevEditMode != emode)
{
// Scale mode enables vector lock.
SetVectorLock(emode == eEditModeScale);
// Change undo strings.
QString undoString("Modify Object(s)");
int mode = GetIEditor()->GetEditMode();
switch (mode)
{
case eEditModeMove:
undoString = QStringLiteral("Move Object(s)");
break;
case eEditModeRotate:
undoString = QStringLiteral("Rotate Object(s)");
break;
case eEditModeScale:
undoString = QStringLiteral("Scale Object(s)");
break;
}
// edit mode changed, we must update the number values
updateDisplayVector = true;
}
SetVectorRange(min, max);
EnableVector(enable);
// if our selection changed, or if our display values are out of date
if (m_bSelectionChanged)
{
updateDisplayVector = true;
m_bSelectionChanged = false;
}
if (updateDisplayVector)
{
SetVector(v);
}
m_prevEditMode = emode;
}
inline double Round(double fVal, double fStep)
@@ -691,71 +265,6 @@ inline double Round(double fVal, double fStep)
return fVal;
}
void CInfoBar::SetVector(const Vec3& v)
{
if (!m_bDragMode)
{
m_lastValue = m_currValue;
}
if (m_currValue != v)
{
ui->m_posCtrl->setValuebyIndex(v.x, 0);
ui->m_posCtrl->setValuebyIndex(v.y, 1);
ui->m_posCtrl->setValuebyIndex(v.z, 2);
m_currValue = v;
}
}
Vec3 CInfoBar::GetVector()
{
Vec3 v;
v.x = ui->m_posCtrl->getElements()[0]->getValue();
v.y = ui->m_posCtrl->getElements()[1]->getValue();
v.z = ui->m_posCtrl->getElements()[2]->getValue();
m_currValue = v;
return v;
}
void CInfoBar::EnableVector(bool enable)
{
if (m_enabledVector != enable)
{
m_enabledVector = enable;
ui->m_posCtrl->setEnabled(enable);
ui->m_vectorLock->setEnabled(enable);
ui->m_setVector->setEnabled(enable);
}
}
void CInfoBar::SetVectorLock(bool bVectorLock)
{
m_bVectorLock = bVectorLock;
ui->m_vectorLock->setChecked(bVectorLock);
GetIEditor()->SetAxisVectorLock(bVectorLock);
}
void CInfoBar::SetVectorRange(float min, float max)
{
// Worth noting that this gets called every IdleUpdate, so it is necessary to make sure
// setting the min/max doesn't result in the Qt event queue being pumped
ui->m_posCtrl->setMinimum(min);
ui->m_posCtrl->setMaximum(max);
}
void CInfoBar::OnVectorLock()
{
SetVectorLock(!m_bVectorLock);
}
void CInfoBar::OnLockSelection()
{
bool newLockSelectionValue = !m_bSelectionLocked;
m_bSelectionLocked = newLockSelectionValue;
ui->m_lockSelection->setChecked(newLockSelectionValue);
GetIEditor()->LockSelection(newLockSelectionValue);
}
void CInfoBar::OnUpdateMoveSpeedText(const QString& text)
{
gSettings.cameraMoveSpeed = aznumeric_cast<float>(Round(text.toDouble(), m_speedStep));
@@ -771,12 +280,6 @@ void CInfoBar::OnInitDialog()
QFontMetrics metrics({});
int width = metrics.boundingRect("-9999.99").width() * m_fieldWidthMultiplier;
ui->m_posCtrl->setEnabled(false);
ui->m_posCtrl->getElements()[0]->setFixedWidth(width);
ui->m_posCtrl->getElements()[1]->setFixedWidth(width);
ui->m_posCtrl->getElements()[2]->setFixedWidth(width);
ui->m_setVector->setEnabled(false);
ui->m_moveSpeed->setFixedWidth(width);
ui->m_physicsBtn->setEnabled(false);
@@ -850,12 +353,6 @@ void CInfoBar::OnBnClickedGotoPosition()
emit ActionTriggered(ID_DISPLAY_GOTOPOSITION);
}
//////////////////////////////////////////////////////////////////////////
void CInfoBar::OnBnClickedSetVector()
{
emit ActionTriggered(ID_DISPLAY_SETVECTOR);
}
//////////////////////////////////////////////////////////////////////////
void CInfoBar::OnBnClickedMuteAudio()
{
-21
View File
@@ -59,24 +59,9 @@ protected:
virtual void OnOK() {};
virtual void OnCancel() {};
void OnVectorUpdate(bool followTerrain);
// this gets called by stepper or text edit changes
void OnVectorChanged();
void SetVector(const Vec3& v);
void SetVectorRange(float min, float max);
Vec3 GetVector();
void EnableVector(bool enable);
void SetVectorLock(bool bVectorLock);
void OnBnClickedSyncplayer();
void OnBnClickedGotoPosition();
void OnVectorLock();
void OnLockSelection();
void OnBnClickedSetVector();
void OnSpeedComboBoxEnter();
void OnUpdateMoveSpeedText(const QString&);
void OnBnClickedTerrainCollision();
@@ -98,13 +83,10 @@ protected:
void EnteredComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
void LeftComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
bool m_enabledVector;
float m_width, m_height;
//int m_heightMapX,m_heightMapY;
double m_fieldWidthMultiplier = 1.8;
int m_prevEditMode;
int m_numSelected;
float m_prevMoveSpeed;
@@ -117,14 +99,11 @@ protected:
// Speed presets
float m_speedPresetValues[3] = { 0.1f, 1.0f, 10.0f };
bool m_bVectorLock;
bool m_bSelectionLocked;
bool m_bSelectionChanged;
bool m_bDragMode;
QString m_sLastText;
CEditTool* m_editTool;
Vec3 m_lastValue;
Vec3 m_currValue;
float m_oldMainVolume;
-105
View File
@@ -57,42 +57,6 @@
</property>
</widget>
</item>
<item>
<widget class="AzQtComponents::VectorInput" name="m_posCtrl" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Position</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="m_setVector">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>XYZ</string>
</property>
<property name="icon">
<iconset resource="InfoBar.qrc">
<normaloff>:/InfoBar/XYZ-default.svg</normaloff>:/InfoBar/XYZ-default.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>18</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="m_gotoPos">
<property name="sizePolicy">
@@ -135,68 +99,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="m_lockSelection">
<property name="toolTip">
<string>Lock Object Selection</string>
</property>
<property name="text">
<string>Lock Selection</string>
</property>
<property name="icon">
<iconset resource="InfoBar.qrc">
<normaloff>:/InfoBar/LockSelection-default.svg</normaloff>:/InfoBar/LockSelection-default.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="m_vectorLock">
<property name="toolTip">
<string>Lock Scale Axis Vectors</string>
</property>
<property name="text">
<string>Lock Scale</string>
</property>
<property name="icon">
<iconset resource="InfoBar.qrc">
<normaloff>:/InfoBar/LockScale-default.svg</normaloff>:/InfoBar/LockScale-default.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>18</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
@@ -424,13 +326,6 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>AzQtComponents::VectorInput</class>
<extends>QWidget</extends>
<header location="global">AzQtComponents/Components/Widgets/VectorInput.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="InfoBar.qrc"/>
</resources>
+4 -1
View File
@@ -418,8 +418,11 @@ void CLayoutWnd::CreateLayout(EViewLayout layout, bool bBindViewports, EViewport
QRect rcView = rect();
rcView.setBottom(rcView.bottom() - m_infoBar->height());
// Ensure we delete our old view immediately so it can relinquish its backing ViewportContext
if (m_maximizedView)
m_maximizedView->deleteLater();
{
delete m_maximizedView;
}
m_maximizedView = new CLayoutViewPane(this);
m_maximizedView->SetId(0);
@@ -408,6 +408,13 @@ bool LegacyViewportCameraControllerInstance::HandleInputChannelEvent(const AzFra
}
}
UpdateCursorCapture(shouldCaptureCursor);
return shouldConsumeEvent;
}
void LegacyViewportCameraControllerInstance::UpdateCursorCapture(bool shouldCaptureCursor)
{
if (m_capturingCursor != shouldCaptureCursor)
{
if (shouldCaptureCursor)
@@ -427,8 +434,14 @@ bool LegacyViewportCameraControllerInstance::HandleInputChannelEvent(const AzFra
m_capturingCursor = shouldCaptureCursor;
}
}
return shouldConsumeEvent;
void LegacyViewportCameraControllerInstance::ResetInputChannels()
{
m_modifiers = 0;
m_pressedKeys.clear();
UpdateCursorCapture(false);
m_inRotateMode = m_inMoveMode = m_inOrbitMode = m_inZoomMode = false;
}
void LegacyViewportCameraControllerInstance::UpdateViewport(const AzFramework::ViewportControllerUpdateEvent& event)
@@ -35,6 +35,7 @@ namespace SandboxEditor
explicit LegacyViewportCameraControllerInstance(AzFramework::ViewportId viewport);
bool HandleInputChannelEvent(const AzFramework::ViewportControllerInputEvent& event) override;
void ResetInputChannels() override;
void UpdateViewport(const AzFramework::ViewportControllerUpdateEvent& event) override;
private:
@@ -53,6 +54,7 @@ namespace SandboxEditor
bool HandleMouseMove(const AzFramework::ScreenPoint& currentMousePos, const AzFramework::ScreenPoint& previousMousePos);
bool HandleMouseWheel(float zDelta);
bool IsKeyDown(Qt::Key key) const;
void UpdateCursorCapture(bool shouldCaptureCursor);
bool m_inRotateMode = false;
bool m_inMoveMode = false;
@@ -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

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