Merge branch 'development' into Atom/santorac/RemixableMaterialTypes3

There were lots of material system conflicts that had to be resolved. I expect the build is broken at this commit, and I'll fix it in followup commits.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
This commit is contained in:
santorac
2022-01-25 14:47:24 -08:00
9789 changed files with 757680 additions and 902265 deletions
+3 -28
View File
@@ -234,7 +234,7 @@ void Q2DViewport::UpdateContent(int flags)
}
//////////////////////////////////////////////////////////////////////////
void Q2DViewport::OnRButtonDown(Qt::KeyboardModifiers modifiers, const QPoint& point)
void Q2DViewport::OnRButtonDown([[maybe_unused]] Qt::KeyboardModifiers modifiers, const QPoint& point)
{
if (GetIEditor()->IsInGameMode())
{
@@ -246,9 +246,6 @@ void Q2DViewport::OnRButtonDown(Qt::KeyboardModifiers modifiers, const QPoint& p
setFocus();
}
// Check Edit Tool.
MouseCallback(eMouseRDown, point, modifiers);
SetCurrentCursor(STD_CURSOR_MOVE, QString());
// Save the mouse down position
@@ -273,17 +270,8 @@ void Q2DViewport::OnRButtonUp([[maybe_unused]] Qt::KeyboardModifiers modifiers,
}
//////////////////////////////////////////////////////////////////////////
void Q2DViewport::OnMButtonDown(Qt::KeyboardModifiers modifiers, const QPoint& point)
void Q2DViewport::OnMButtonDown([[maybe_unused]] Qt::KeyboardModifiers modifiers, const QPoint& point)
{
////////////////////////////////////////////////////////////////////////
// User pressed the middle mouse button
////////////////////////////////////////////////////////////////////////
// Check Edit Tool.
if (MouseCallback(eMouseMDown, point, modifiers))
{
return;
}
// Save the mouse down position
m_RMouseDownPos = point;
@@ -300,14 +288,8 @@ void Q2DViewport::OnMButtonDown(Qt::KeyboardModifiers modifiers, const QPoint& p
}
//////////////////////////////////////////////////////////////////////////
void Q2DViewport::OnMButtonUp(Qt::KeyboardModifiers modifiers, const QPoint& point)
void Q2DViewport::OnMButtonUp([[maybe_unused]] Qt::KeyboardModifiers modifiers, [[maybe_unused]] const QPoint& point)
{
// Check Edit Tool.
if (MouseCallback(eMouseMUp, point, modifiers))
{
return;
}
SetViewMode(NothingMode);
ReleaseMouse();
@@ -547,13 +529,6 @@ QPoint Q2DViewport::WorldToView(const Vec3& wp) const
QPoint p = QPoint(static_cast<int>(sp.x), static_cast<int>(sp.y));
return p;
}
//////////////////////////////////////////////////////////////////////////
QPoint Q2DViewport::WorldToViewParticleEditor(const Vec3& wp, [[maybe_unused]] int width, [[maybe_unused]] int height) const //Eric@conffx implement for the children class of IDisplayViewport
{
Vec3 sp = m_screenTM.TransformPoint(wp);
QPoint p = QPoint(static_cast<int>(sp.x), static_cast<int>(sp.y));
return p;
}
//////////////////////////////////////////////////////////////////////////
Vec3 Q2DViewport::ViewToWorld(const QPoint& vp, [[maybe_unused]] bool* collideWithTerrain, [[maybe_unused]] bool onlyTerrain, [[maybe_unused]] bool bSkipVegetation, [[maybe_unused]] bool bTestRenderMesh, [[maybe_unused]] bool* collideWithObject) const
-3
View File
@@ -50,8 +50,6 @@ public:
//! Map world space position to viewport position.
QPoint WorldToView(const Vec3& wp) const override;
QPoint WorldToViewParticleEditor(const Vec3& wp, int width, int height) const override; //Eric@conffx
//! Map viewport position to world space position.
Vec3 ViewToWorld(const QPoint& vp, bool* collideWithTerrain = nullptr, bool onlyTerrain = false, bool bSkipVegetation = false, bool bTestRenderMesh = false, bool* collideWithObject = nullptr) const override;
//! Map viewport position to world space ray from camera.
@@ -64,7 +62,6 @@ public:
// ovverided from CViewport.
float GetScreenScaleFactor(const Vec3& worldPoint) const override;
float GetScreenScaleFactor([[maybe_unused]] const CCamera& camera, [[maybe_unused]] const Vec3& object_position) override { return 1; } //Eric@conffx
// Overrided from CViewport.
void OnDragSelectRectangle(const QRect &rect, bool bNormalizeRect = false) override;
+7 -14
View File
@@ -6,10 +6,7 @@
*
*/
#include "EditorDefs.h"
#include "AboutDialog.h"
// Qt
@@ -33,8 +30,6 @@ CAboutDialog::CAboutDialog(QString versionText, QString richTextCopyrightNotice,
m_ui->setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
connect(m_ui->m_transparentAgreement, &QLabel::linkActivated, this, &CAboutDialog::OnCustomerAgreement);
m_ui->m_transparentTrademarks->setText(versionText);
m_ui->m_transparentAllRightReserved->setObjectName("copyrightNotice");
@@ -47,14 +42,17 @@ CAboutDialog::CAboutDialog(QString versionText, QString richTextCopyrightNotice,
CAboutDialog > QLabel#link { text-decoration: underline; color: #94D2FF; }");
// Prepare background image
m_backgroundImage = AzQtComponents::ScalePixmapForScreenDpi(
QPixmap(QStringLiteral(":/StartupLogoDialog/splashscreen_background_developer_preview.jpg")),
screen(),
QSize(m_enforcedWidth, m_enforcedHeight),
QPixmap image = AzQtComponents::ScalePixmapForScreenDpi(
QPixmap(QStringLiteral(":/StartupLogoDialog/splashscreen_background_2021_11.jpg")),
screen(), QSize(m_imageWidth, m_imageHeight),
Qt::IgnoreAspectRatio,
Qt::SmoothTransformation
);
// Crop image to cut out transparent border
QRect cropRect((m_imageWidth - m_enforcedWidth) / 2, (m_imageHeight - m_enforcedHeight) / 2, m_enforcedWidth, m_enforcedHeight);
m_backgroundImage = AzQtComponents::CropPixmapForScreenDpi(image, screen(), cropRect);
// Draw the Open 3D Engine logo from svg
m_ui->m_logo->load(QStringLiteral(":/StartupLogoDialog/o3de_logo.svg"));
@@ -84,9 +82,4 @@ void CAboutDialog::mouseReleaseEvent(QMouseEvent* event)
QDialog::mouseReleaseEvent(event);
}
void CAboutDialog::OnCustomerAgreement()
{
QDesktopServices::openUrl(QUrl(QStringLiteral("https://www.o3debinaries.org/license")));
}
#include <moc_AboutDialog.cpp>
+4 -4
View File
@@ -30,15 +30,15 @@ public:
private:
void OnCustomerAgreement();
void mouseReleaseEvent(QMouseEvent* event) override;
void paintEvent(QPaintEvent* event) override;
QScopedPointer<Ui::CAboutDialog> m_ui;
QPixmap m_backgroundImage;
int m_enforcedWidth = 600;
int m_enforcedHeight = 400;
const int m_imageWidth = 668;
const int m_imageHeight = 368;
const int m_enforcedWidth = 600;
const int m_enforcedHeight = 300;
};
+12 -14
View File
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>600</width>
<height>360</height>
<height>300</height>
</rect>
</property>
<property name="sizePolicy">
@@ -19,13 +19,13 @@
<property name="minimumSize">
<size>
<width>600</width>
<height>360</height>
<height>300</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>360</height>
<width>608</width>
<height>300</height>
</size>
</property>
<property name="windowTitle">
@@ -69,7 +69,7 @@
<number>11</number>
</property>
<property name="topMargin">
<number>12</number>
<number>10</number>
</property>
<property name="bottomMargin">
<number>12</number>
@@ -125,7 +125,7 @@
</size>
</property>
<property name="text">
<string>Developer Preview</string>
<string>development</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
@@ -181,14 +181,17 @@
</spacer>
</item>
<item>
<widget class="ClickableLabel" name="m_transparentAgreement">
<widget class="QLabel" name="m_transparentAgreement">
<property name="text">
<string>Terms of Use</string>
<string>&lt;a href=&quot;https://www.o3debinaries.org/license&quot;&gt;Terms of Use&lt;/a&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="showDecoration" stdset="0">
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
@@ -274,11 +277,6 @@
<extends>QWidget</extends>
<header>qsvgwidget.h</header>
</customwidget>
<customwidget>
<class>ClickableLabel</class>
<extends>QLabel</extends>
<header>QtUI/ClickableLabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
-9
View File
@@ -152,15 +152,6 @@ ActionManager::ActionWrapper& ActionManager::ActionWrapper::SetMenu(DynamicMenu*
return *this;
}
ActionManager::ActionWrapper& ActionManager::ActionWrapper::SetApplyHoverEffect()
{
// Our standard toolbar icons, when hovered on, get a white color effect.
// But for this to work we need .pngs that look good with this effect, so this only works with the standard toolbars
// and looks very ugly for other toolbars, including toolbars loaded from XML (which just show a white rectangle)
m_action->setProperty("IconHasHoverEffect", true);
return *this;
}
ActionManager::ActionWrapper& ActionManager::ActionWrapper::SetReserved()
{
m_action->setProperty("Reserved", true);
-1
View File
@@ -151,7 +151,6 @@ public:
}
ActionWrapper& SetMenu(DynamicMenu* menu);
ActionWrapper& SetApplyHoverEffect();
operator QAction*() const {
return m_action;
@@ -1,33 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "AnimationBipedBoneNames.h"
namespace EditorAnimationBones
{
namespace Biped
{
const char* Pelvis = "Bip01 Pelvis";
const char* Head = "Bip01 Head";
const char* Weapon = "weapon_bone";
const char* LeftEye = "eye_bone_left";
const char* RightEye = "eye_bone_right";
const char* Spine[5] = { "Bip01 Spine", "Bip01 Spine1", "Bip01 Spine2", "Bip01 Spine3", "Bip01 Spine4" };
const char* Neck[2] = { "Bip01 Neck", "Bip01 Neck1" };
const char* LeftHeel = "Bip01 L Heel";
const char* LeftToe[2] = { "Bip01 L Toe0", "Bip01 L Toe1" };
const char* RightHeel = "Bip01 R Heel";
const char* RightToe[2] = { "Bip01 R Toe0", "Bip01 R Toe1" };
}
}
@@ -1,34 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_ANIMATION_ANIMATIONBIPEDBONENAMES_H
#define CRYINCLUDE_EDITOR_ANIMATION_ANIMATIONBIPEDBONENAMES_H
#pragma once
namespace EditorAnimationBones
{
namespace Biped
{
extern const char* Pelvis;
extern const char* Head;
extern const char* Weapon;
extern const char* Spine[5];
extern const char* Neck[2];
extern const char* LeftEye;
extern const char* RightEye;
extern const char* LeftHeel;
extern const char* RightHeel;
extern const char* LeftToe[2];
extern const char* RightToe[2];
}
}
#endif // CRYINCLUDE_EDITOR_ANIMATION_ANIMATIONBIPEDBONENAMES_H
+14 -9
View File
@@ -21,6 +21,8 @@
#include "Include/IObjectManager.h"
#include "Objects/EntityObject.h"
#include <AzCore/Time/ITime.h>
//////////////////////////////////////////////////////////////////////////
// Movie Callback.
//////////////////////////////////////////////////////////////////////////
@@ -499,25 +501,24 @@ void CAnimationContext::Update()
return;
}
ITimer* pTimer = GetIEditor()->GetSystem()->GetITimer();
const AZ::TimeUs frameDeltaTimeUs = AZ::GetSimulationTickDeltaTimeUs();
const float frameDeltaTime = AZ::TimeUsToSeconds(frameDeltaTimeUs);
if (!m_bAutoRecording)
{
AnimateActiveSequence();
float dt = pTimer->GetFrameTime();
m_currTime += dt * m_fTimeScale;
m_currTime += frameDeltaTime * m_fTimeScale;
if (!m_recording)
{
GetIEditor()->GetMovieSystem()->PreUpdate(dt);
GetIEditor()->GetMovieSystem()->PostUpdate(dt);
GetIEditor()->GetMovieSystem()->PreUpdate(frameDeltaTime);
GetIEditor()->GetMovieSystem()->PostUpdate(frameDeltaTime);
}
}
else
{
float dt = pTimer->GetFrameTime();
m_fRecordingCurrTime += dt * m_fTimeScale;
m_fRecordingCurrTime += frameDeltaTime * m_fTimeScale;
if (fabs(m_fRecordingCurrTime - m_currTime) > m_fRecordingTimeStep)
{
m_currTime += m_fRecordingTimeStep;
@@ -644,7 +645,9 @@ void CAnimationContext::OnPostRender()
{
SAnimContext ac;
ac.dt = 0;
ac.fps = GetIEditor()->GetSystem()->GetITimer()->GetFrameRate();
const AZ::TimeUs frameDeltaTimeUs = AZ::GetSimulationTickDeltaTimeUs();
const float frameDeltaTime = AZ::TimeUsToSeconds(frameDeltaTimeUs);
ac.fps = 1.0f / frameDeltaTime;
ac.time = m_currTime;
ac.singleFrame = true;
ac.forcePlay = true;
@@ -797,7 +800,9 @@ void CAnimationContext::AnimateActiveSequence()
SAnimContext ac;
ac.dt = 0;
ac.fps = GetIEditor()->GetSystem()->GetITimer()->GetFrameRate();
const AZ::TimeUs frameDeltaTimeUs = AZ::GetSimulationTickDeltaTimeUs();
const float frameDeltaTime = AZ::TimeUsToSeconds(frameDeltaTimeUs);
ac.fps = 1.0f / frameDeltaTime;
ac.time = m_currTime;
ac.singleFrame = true;
ac.forcePlay = true;
@@ -7,7 +7,6 @@
*/
#pragma once
#include <AzCore/Serialization/SerializeContext.h>
#include <AzToolsFramework/AssetEditor/AssetEditorBus.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
@@ -9,7 +9,6 @@
#if !defined(Q_MOC_RUN)
#include <AzCore/Asset/AssetCommon.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/UserSettings/UserSettings.h>
#include <AzToolsFramework/AssetEditor/AssetEditorBus.h>
#include <QWidget>
@@ -140,7 +140,7 @@ bool AssetImporterManager::OnBrowseFiles()
bool encounteredCrate = false;
QStringList invalidFiles;
for (QString path : fileDialog.selectedFiles())
for (const QString& path : fileDialog.selectedFiles())
{
QString fileName = GetFileName(path);
QFileInfo info(path);
@@ -191,6 +191,7 @@ void AssetImporterManager::OnBrowseDestinationFilePath(QLineEdit* destinationLin
fileDialog.setViewMode(QFileDialog::List);
fileDialog.setWindowModality(Qt::WindowModality::ApplicationModal);
fileDialog.setWindowTitle(tr("Select import destination"));
fileDialog.setFileMode(QFileDialog::Directory);
QSettings settings;
QString currentDestination = settings.value(AssetImporterManagerPrivate::g_selectDestinationFilesPath).toString();
@@ -199,41 +199,6 @@ namespace AzAssetBrowserRequestHandlerPrivate
}
}
}
// Helper utility - determines if the thing being dragged is a FBX from the scene import pipeline
// This is important to differentiate.
// when someone drags a MTL file directly into the viewport, even from a FBX, we want to spawn it as a decal
// but when someone drags a FBX that contains MTL files, we want only to spawn the meshes.
// so we have to specifically differentiate here between the mimeData type that contains the source as the root
// (dragging the fbx file itself)
// and one which contains the actual product at its root.
bool IsDragOfFBX(const QMimeData* mimeData)
{
AZStd::vector<AssetBrowserEntry*> entries;
if (!AssetBrowserEntry::FromMimeData(mimeData, entries))
{
// if mimedata does not even contain entries, no point in proceeding.
return false;
}
for (auto entry : entries)
{
if (entry->GetEntryType() != AssetBrowserEntry::AssetEntryType::Source)
{
continue;
}
// this is a source file. Is it the filetype we're looking for?
if (SourceAssetBrowserEntry* source = azrtti_cast<SourceAssetBrowserEntry*>(entry))
{
if (AzFramework::StringFunc::Equal(source->GetExtension().c_str(), ".fbx", false))
{
return true;
}
}
}
return false;
}
}
AzAssetBrowserRequestHandler::AzAssetBrowserRequestHandler()
@@ -17,6 +17,7 @@
#include <AzToolsFramework/AssetBrowser/AssetBrowserEntry.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserModel.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h>
// AzQtComponents
#include <AzQtComponents/Utilities/QtWindowUtilities.h>
@@ -31,6 +32,15 @@ AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
AZ_CVAR_EXTERNED(bool, ed_useNewAssetBrowserTableView);
namespace AzToolsFramework
{
namespace AssetBrowser
{
static constexpr const char* CollapseAllIcon = "Assets/Editor/Icons/AssetBrowser/Collapse_All.svg";
static constexpr const char* MenuIcon = ":/Menu/menu.svg";
} // namespace AssetBrowser
} // namespace AzToolsFramework
class ListenerForShowAssetEditorEvent
: public QObject
, private AzToolsFramework::EditorEvents::Bus::Handler
@@ -83,10 +93,24 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent)
m_ui->m_assetBrowserTableViewWidget->setVisible(false);
m_ui->m_toggleDisplayViewBtn->setVisible(false);
m_ui->m_searchWidget->SetFilterInputInterval(AZStd::chrono::milliseconds(250));
m_assetBrowserModel->SetFilterModel(m_filterModel.data());
m_ui->m_collapseAllButton->setAutoRaise(true); // hover highlight
m_ui->m_collapseAllButton->setIcon(QIcon(AzAssetBrowser::CollapseAllIcon));
connect(
m_ui->m_collapseAllButton, &QToolButton::clicked, this,
[this]()
{
m_ui->m_assetBrowserTreeViewWidget->collapseAll();
});
if (ed_useNewAssetBrowserTableView)
{
m_ui->m_toggleDisplayViewBtn->setVisible(true);
m_ui->m_toggleDisplayViewBtn->setIcon(QIcon(":/Menu/menu.svg"));
m_ui->m_toggleDisplayViewBtn->setAutoRaise(true);
m_ui->m_toggleDisplayViewBtn->setIcon(QIcon(AzAssetBrowser::MenuIcon));
m_tableModel->setFilterRole(Qt::DisplayRole);
m_tableModel->setSourceModel(m_filterModel.data());
@@ -96,10 +120,6 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent)
connect(
m_filterModel.data(), &AzAssetBrowser::AssetBrowserFilterModel::filterChanged, this,
&AzAssetBrowserWindow::SetTableViewVisibleAfterFilter);
connect(
m_filterModel.data(), &AzAssetBrowser::AssetBrowserFilterModel::filterChanged, this,
&AzAssetBrowserWindow::UpdateTableModelAfterFilter);
connect(
m_ui->m_assetBrowserTableViewWidget, &AzAssetBrowser::AssetBrowserTableView::selectionChangedSignal, this,
&AzAssetBrowserWindow::SelectionChangedSlot);
@@ -251,24 +271,6 @@ void AzAssetBrowserWindow::SetExpandedAssetBrowserMode()
m_assetBrowserDisplayState = AzAssetBrowser::AssetBrowserDisplayState::ExpandedMode;
disconnect(
m_filterModel.data(), &AzAssetBrowser::AssetBrowserFilterModel::filterChanged, this,
&AzAssetBrowserWindow::UpdateTableModelAfterFilter);
disconnect(
m_filterModel.data(), &AzAssetBrowser::AssetBrowserFilterModel::filterChanged, this,
&AzAssetBrowserWindow::SetTableViewVisibleAfterFilter);
disconnect(
m_ui->m_assetBrowserTableViewWidget, &AzAssetBrowser::AssetBrowserTableView::selectionChangedSignal, this,
&AzAssetBrowserWindow::SelectionChangedSlot);
disconnect(m_ui->m_assetBrowserTableViewWidget, &QAbstractItemView::doubleClicked, this, &AzAssetBrowserWindow::DoubleClickedItem);
disconnect(
m_ui->m_assetBrowserTableViewWidget, &AzAssetBrowser::AssetBrowserTableView::ClearStringFilter, m_ui->m_searchWidget,
&AzAssetBrowser::SearchWidget::ClearStringFilter);
disconnect(
m_ui->m_assetBrowserTableViewWidget, &AzAssetBrowser::AssetBrowserTableView::ClearTypeFilter, m_ui->m_searchWidget,
&AzAssetBrowser::SearchWidget::ClearTypeFilter);
if (m_ui->m_assetBrowserTableViewWidget->isVisible())
{
m_ui->m_assetBrowserTableViewWidget->setVisible(false);
@@ -281,37 +283,9 @@ void AzAssetBrowserWindow::SetDefaultAssetBrowserMode()
namespace AzAssetBrowser = AzToolsFramework::AssetBrowser;
m_assetBrowserDisplayState = AzAssetBrowser::AssetBrowserDisplayState::DefaultMode;
connect(
m_filterModel.data(), &AzAssetBrowser::AssetBrowserFilterModel::filterChanged, this,
&AzAssetBrowserWindow::SetTableViewVisibleAfterFilter);
connect(
m_filterModel.data(), &AzAssetBrowser::AssetBrowserFilterModel::filterChanged, this,
&AzAssetBrowserWindow::UpdateTableModelAfterFilter);
connect(
m_ui->m_assetBrowserTableViewWidget, &AzAssetBrowser::AssetBrowserTableView::selectionChangedSignal, this,
&AzAssetBrowserWindow::SelectionChangedSlot);
connect(m_ui->m_assetBrowserTableViewWidget, &QAbstractItemView::doubleClicked, this, &AzAssetBrowserWindow::DoubleClickedItem);
connect(
m_ui->m_assetBrowserTableViewWidget, &AzAssetBrowser::AssetBrowserTableView::ClearStringFilter, m_ui->m_searchWidget,
&AzAssetBrowser::SearchWidget::ClearStringFilter);
connect(
m_ui->m_assetBrowserTableViewWidget, &AzAssetBrowser::AssetBrowserTableView::ClearTypeFilter, m_ui->m_searchWidget,
&AzAssetBrowser::SearchWidget::ClearTypeFilter);
//If the filter is not empty we want to switch views and Update the model
UpdateTableModelAfterFilter();
SetTableViewVisibleAfterFilter();
}
void AzAssetBrowserWindow::UpdateTableModelAfterFilter()
{
if (!m_ui->m_searchWidget->GetFilterString().isEmpty())
{
m_tableModel->UpdateTableModelMaps();
}
}
void AzAssetBrowserWindow::SetTableViewVisibleAfterFilter()
{
@@ -389,8 +363,8 @@ void AzAssetBrowserWindow::SelectionChangedSlot(const QItemSelection& /*selected
UpdatePreview();
}
// while its tempting to use Activated here, we dont actually want it to count as activation
// just becuase on some OS clicking once is activation.
// while its tempting to use Activated here, we don't actually want it to count as activation
// just because on some OS clicking once is activation.
void AzAssetBrowserWindow::DoubleClickedItem([[maybe_unused]] const QModelIndex& element)
{
namespace AzAssetBrowser = AzToolsFramework::AssetBrowser;
@@ -68,7 +68,6 @@ protected slots:
void CreateSwitchViewMenu();
void SetExpandedAssetBrowserMode();
void SetDefaultAssetBrowserMode();
void UpdateTableModelAfterFilter();
void SetTableViewVisibleAfterFilter();
private:
@@ -72,6 +72,22 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="m_collapseAllButton">
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="toolTip">
<string extracomment="Collapse All"/>
</property>
<property name="toolTipDuration">
<number>3</number>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
@@ -143,15 +159,6 @@
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
<item>
-292
View File
@@ -1,292 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "BaseLibrary.h"
#include "BaseLibraryItem.h"
#include "Include/IBaseLibraryManager.h"
#include <Util/PathUtil.h>
#include <IFileUtil.h>
#include "Undo/IUndoObject.h"
//////////////////////////////////////////////////////////////////////////
// Undo functionality for libraries.
//////////////////////////////////////////////////////////////////////////
class CUndoBaseLibrary
: public IUndoObject
{
public:
CUndoBaseLibrary(CBaseLibrary* pLib, const QString& description, const QString& selectedItem = QString())
: m_pLib(pLib)
, m_description(description)
, m_redo(nullptr)
, m_selectedItem(selectedItem)
{
assert(m_pLib);
m_undo = GetIEditor()->GetSystem()->CreateXmlNode("Undo");
m_pLib->Serialize(m_undo, false);
}
QString GetEditorObjectName() override
{
return m_selectedItem;
}
protected:
int GetSize() override { return sizeof(CUndoBaseLibrary); }
QString GetDescription() override { return m_description; };
void Undo(bool bUndo) override
{
if (bUndo)
{
m_redo = GetIEditor()->GetSystem()->CreateXmlNode("Redo");
m_pLib->Serialize(m_redo, false);
}
m_pLib->Serialize(m_undo, true);
m_pLib->SetModified();
GetIEditor()->Notify(eNotify_OnDataBaseUpdate);
}
void Redo() override
{
m_pLib->Serialize(m_redo, true);
m_pLib->SetModified();
GetIEditor()->Notify(eNotify_OnDataBaseUpdate);
}
private:
QString m_description;
QString m_selectedItem;
_smart_ptr<CBaseLibrary> m_pLib;
XmlNodeRef m_undo;
XmlNodeRef m_redo;
};
//////////////////////////////////////////////////////////////////////////
// CBaseLibrary implementation.
//////////////////////////////////////////////////////////////////////////
CBaseLibrary::CBaseLibrary(IBaseLibraryManager* pManager)
: m_pManager(pManager)
, m_bModified(false)
, m_bLevelLib(false)
, m_bNewLibrary(true)
{
}
//////////////////////////////////////////////////////////////////////////
CBaseLibrary::~CBaseLibrary()
{
m_items.clear();
}
//////////////////////////////////////////////////////////////////////////
IBaseLibraryManager* CBaseLibrary::GetManager()
{
return m_pManager;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibrary::RemoveAllItems()
{
AddRef();
for (int i = 0; i < m_items.size(); i++)
{
// Unregister item in case it was registered. It is ok if it wasn't. This is still safe to call.
m_pManager->UnregisterItem(m_items[i]);
// Clear library item.
m_items[i]->m_library = nullptr;
}
m_items.clear();
Release();
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibrary::SetName(const QString& name)
{
//the fullname of the items in the library will be changed due to library's name change
//so we need unregistered them and register them after their name changed.
for (int i = 0; i < m_items.size(); i++)
{
m_pManager->UnregisterItem(m_items[i]);
}
m_name = name;
for (int i = 0; i < m_items.size(); i++)
{
m_pManager->RegisterItem(m_items[i]);
}
SetModified();
}
//////////////////////////////////////////////////////////////////////////
const QString& CBaseLibrary::GetName() const
{
return m_name;
}
//////////////////////////////////////////////////////////////////////////
bool CBaseLibrary::Save()
{
return true;
}
//////////////////////////////////////////////////////////////////////////
bool CBaseLibrary::Load(const QString& filename)
{
m_filename = filename;
SetModified(false);
m_bNewLibrary = false;
return true;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibrary::SetModified(bool bModified)
{
if (bModified != m_bModified)
{
m_bModified = bModified;
emit Modified(bModified);
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibrary::AddItem(IDataBaseItem* item, bool bRegister)
{
CBaseLibraryItem* pLibItem = (CBaseLibraryItem*)item;
// Check if item is already assigned to this library.
if (pLibItem->m_library != this)
{
pLibItem->m_library = this;
m_items.push_back(pLibItem);
SetModified();
if (bRegister)
{
m_pManager->RegisterItem(pLibItem);
}
}
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibrary::GetItem(int index)
{
assert(index >= 0 && index < m_items.size());
return m_items[index];
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibrary::RemoveItem(IDataBaseItem* item)
{
for (int i = 0; i < m_items.size(); i++)
{
if (m_items[i] == item)
{
// Unregister item in case it was registered. It is ok if it wasn't. This is still safe to call.
m_pManager->UnregisterItem(m_items[i]);
m_items.erase(m_items.begin() + i);
SetModified();
break;
}
}
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibrary::FindItem(const QString& name)
{
for (int i = 0; i < m_items.size(); i++)
{
if (QString::compare(m_items[i]->GetName(), name, Qt::CaseInsensitive) == 0)
{
return m_items[i];
}
}
return nullptr;
}
bool CBaseLibrary::AddLibraryToSourceControl(const QString& fullPathName) const
{
IEditor* pEditor = GetIEditor();
IFileUtil* pFileUtil = pEditor ? pEditor->GetFileUtil() : nullptr;
if (pFileUtil)
{
return pFileUtil->CheckoutFile(fullPathName.toUtf8().data(), nullptr);
}
return false;
}
bool CBaseLibrary::SaveLibrary(const char* name, bool saveEmptyLibrary)
{
assert(name != nullptr);
if (name == nullptr)
{
CryFatalError("The library you are attempting to save has no name specified.");
return false;
}
QString fileName(GetFilename());
if (fileName.isEmpty() && !saveEmptyLibrary)
{
return false;
}
fileName = Path::GamePathToFullPath(fileName);
XmlNodeRef root = GetIEditor()->GetSystem()->CreateXmlNode(name);
Serialize(root, false);
bool bRes = XmlHelpers::SaveXmlNode(GetIEditor()->GetFileUtil(), root, fileName.toUtf8().data());
if (m_bNewLibrary)
{
AddLibraryToSourceControl(fileName);
m_bNewLibrary = false;
}
if (!bRes)
{
QByteArray filenameUtf8 = fileName.toUtf8();
AZStd::string strMessage = AZStd::string::format("The file %s is read-only and the save of the library couldn't be performed. Try to remove the \"read-only\" flag or check-out the file and then try again.", filenameUtf8.data());
CryMessageBox(strMessage.c_str(), "Saving Error", MB_OK | MB_ICONWARNING);
}
return bRes;
}
//CONFETTI BEGIN
void CBaseLibrary::ChangeItemOrder(CBaseLibraryItem* item, unsigned int newLocation)
{
std::vector<_smart_ptr<CBaseLibraryItem> > temp;
for (unsigned int i = 0; i < m_items.size(); i++)
{
if (i == newLocation)
{
temp.push_back(_smart_ptr<CBaseLibraryItem>(item));
}
if (m_items[i] != item)
{
temp.push_back(m_items[i]);
}
}
// If newLocation is greater than the original size, append the item to end of the list
if (newLocation >= m_items.size())
{
temp.push_back(_smart_ptr<CBaseLibraryItem>(item));
}
m_items = temp;
}
//CONFETTI END
#include <moc_BaseLibrary.cpp>
-129
View File
@@ -1,129 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_BASELIBRARY_H
#define CRYINCLUDE_EDITOR_BASELIBRARY_H
#pragma once
#if !defined(Q_MOC_RUN)
#include "Include/IDataBaseLibrary.h"
#include "Include/IBaseLibraryManager.h"
#include "Include/EditorCoreAPI.h"
#include "Util/TRefCountBase.h"
#include <QObject>
#endif
// Ensure we don't try to dllimport when moc includes us
#if defined(Q_MOC_BUILD) && !defined(EDITOR_CORE)
#define EDITOR_CORE
#endif
/** This a base class for all Libraries used by Editor.
*/
class EDITOR_CORE_API CBaseLibrary
: public QObject
, public TRefCountBase<IDataBaseLibrary>
{
Q_OBJECT
public:
explicit CBaseLibrary(IBaseLibraryManager* pManager);
~CBaseLibrary();
//! Set library name.
virtual void SetName(const QString& name);
//! Get library name.
const QString& GetName() const override;
//! Set new filename for this library.
virtual bool SetFilename(const QString& filename, [[maybe_unused]] bool checkForUnique = true) { m_filename = filename.toLower(); return true; };
const QString& GetFilename() const override { return m_filename; };
bool Save() override = 0;
bool Load(const QString& filename) override = 0;
void Serialize(XmlNodeRef& node, bool bLoading) override = 0;
//! Mark library as modified.
void SetModified(bool bModified = true) override;
//! Check if library was modified.
bool IsModified() const override { return m_bModified; };
//////////////////////////////////////////////////////////////////////////
// Working with items.
//////////////////////////////////////////////////////////////////////////
//! Add a new prototype to library.
void AddItem(IDataBaseItem* item, bool bRegister = true) override;
//! Get number of known prototypes.
int GetItemCount() const override { return static_cast<int>(m_items.size()); }
//! Get prototype by index.
IDataBaseItem* GetItem(int index) override;
//! Delete item by pointer of item.
void RemoveItem(IDataBaseItem* item) override;
//! Delete all items from library.
void RemoveAllItems() override;
//! Find library item by name.
//! Using linear search.
IDataBaseItem* FindItem(const QString& name) override;
//! Check if this library is local level library.
bool IsLevelLibrary() const override { return m_bLevelLib; };
//! Set library to be level library.
void SetLevelLibrary(bool bEnable) override { m_bLevelLib = bEnable; };
//////////////////////////////////////////////////////////////////////////
//! Return manager for this library.
IBaseLibraryManager* GetManager() override;
// Saves the library with the main tag defined by the parameter name
bool SaveLibrary(const char* name, bool saveEmptyLibrary = false);
//CONFETTI BEGIN
// Used to change the library item order
void ChangeItemOrder(CBaseLibraryItem* item, unsigned int newLocation) override;
//CONFETTI END
signals:
void Modified(bool bModified);
private:
// Add the library to the source control
bool AddLibraryToSourceControl(const QString& fullPathName) const;
protected:
//! Name of the library.
QString m_name;
//! Filename of the library.
QString m_filename;
//! Flag set when library was modified.
bool m_bModified;
// Flag set when the library is just created and it's not yet saved for the first time.
bool m_bNewLibrary;
//! Level library is saved within the level .ly file and is local for this level.
bool m_bLevelLib;
//////////////////////////////////////////////////////////////////////////
// Manager.
IBaseLibraryManager* m_pManager;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
// Array of all our library items.
std::vector<_smart_ptr<CBaseLibraryItem> > m_items;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
#endif // CRYINCLUDE_EDITOR_BASELIBRARY_H
-273
View File
@@ -1,273 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "BaseLibraryItem.h"
#include "BaseLibrary.h"
#include "BaseLibraryManager.h"
#include "Undo/IUndoObject.h"
#include <AzCore/Math/Uuid.h>
//undo object for multi-changes inside library item. such as set all variables to default values.
//For example: change particle emitter shape will lead to multiple variable changes
class CUndoBaseLibraryItem
: public IUndoObject
{
public:
CUndoBaseLibraryItem(IBaseLibraryManager *libMgr, CBaseLibraryItem* libItem, bool ignoreChild)
: m_libMgr(libMgr)
{
assert(libItem);
assert(libMgr);
m_itemPath = libItem->GetFullName();
m_description = "Lib item changed: " + m_itemPath;
//serialize the lib item to undo
m_undoCtx.node = GetIEditor()->GetSystem()->CreateXmlNode("Undo");
m_undoCtx.bIgnoreChilds = ignoreChild;
m_undoCtx.bLoading = false; //saving
m_undoCtx.bUniqName = false; //don't generate new name
m_undoCtx.bCopyPaste = true; //so it won't override guid
m_undoCtx.bUndo = true;
libItem->Serialize(m_undoCtx);
//evaluate size
XmlString xmlStr = m_undoCtx.node->getXML();
m_size = sizeof(CUndoBaseLibraryItem);
m_size += static_cast<int>(xmlStr.GetAllocatedMemory());
m_size += m_itemPath.length();
m_size += m_description.length();
}
QString GetEditorObjectName() override
{
return m_itemPath;
}
protected:
int GetSize() override
{
return m_size;
}
QString GetDescription() override
{
return m_description;
}
void Undo(bool bUndo) override
{
//find the libItem
IDataBaseItem *libItem = m_libMgr->FindItemByName(m_itemPath);
if (libItem == nullptr)
{
//the undo stack is not reliable any more..
assert(false);
return;
}
//save for redo
if (bUndo)
{
m_redoCtx.node = GetIEditor()->GetSystem()->CreateXmlNode("Redo");
m_redoCtx.bIgnoreChilds = m_undoCtx.bIgnoreChilds;
m_redoCtx.bLoading = false; //saving
m_redoCtx.bUniqName = false;
m_redoCtx.bCopyPaste = true;
m_redoCtx.bUndo = true;
libItem->Serialize(m_redoCtx);
XmlString xmlStr = m_redoCtx.node->getXML();
m_size += static_cast<int>(xmlStr.GetAllocatedMemory());
}
//load previous saved data
m_undoCtx.bLoading = true;
libItem->Serialize(m_undoCtx);
}
void Redo() override
{
//find the libItem
IDataBaseItem *libItem = m_libMgr->FindItemByName(m_itemPath);
if (libItem == nullptr || m_redoCtx.node == nullptr)
{
//the undo stack is not reliable any more..
assert(false);
return;
}
m_redoCtx.bLoading = true;
libItem->Serialize(m_redoCtx);
}
private:
QString m_description;
QString m_itemPath;
IDataBaseItem::SerializeContext m_undoCtx; //saved before operation
IDataBaseItem::SerializeContext m_redoCtx; //saved after operation so used for redo
IBaseLibraryManager* m_libMgr;
int m_size;
};
//////////////////////////////////////////////////////////////////////////
// CBaseLibraryItem implementation.
//////////////////////////////////////////////////////////////////////////
CBaseLibraryItem::CBaseLibraryItem()
{
m_library = nullptr;
GenerateId();
m_bModified = false;
}
CBaseLibraryItem::~CBaseLibraryItem()
{
}
//////////////////////////////////////////////////////////////////////////
QString CBaseLibraryItem::GetFullName() const
{
QString name;
if (m_library)
{
name = m_library->GetName() + ".";
}
name += m_name;
return name;
}
//////////////////////////////////////////////////////////////////////////
QString CBaseLibraryItem::GetGroupName()
{
QString str = GetName();
int p = str.lastIndexOf('.');
if (p >= 0)
{
return str.mid(0, p);
}
return "";
}
//////////////////////////////////////////////////////////////////////////
QString CBaseLibraryItem::GetShortName()
{
QString str = GetName();
int p = str.lastIndexOf('.');
if (p >= 0)
{
return str.mid(p + 1);
}
p = str.lastIndexOf('/');
if (p >= 0)
{
return str.mid(p + 1);
}
return str;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryItem::SetName(const QString& name)
{
assert(m_library);
if (name == m_name)
{
return;
}
QString oldName = GetFullName();
m_name = name;
((CBaseLibraryManager*)m_library->GetManager())->OnRenameItem(this, oldName);
}
//////////////////////////////////////////////////////////////////////////
const QString& CBaseLibraryItem::GetName() const
{
return m_name;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryItem::GenerateId()
{
GUID guid = AZ::Uuid::CreateRandom();
SetGUID(guid);
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryItem::SetGUID(REFGUID guid)
{
if (m_library)
{
((CBaseLibraryManager*)m_library->GetManager())->RegisterItem(this, guid);
}
m_guid = guid;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryItem::Serialize(SerializeContext& ctx)
{
assert(m_library);
XmlNodeRef node = ctx.node;
if (ctx.bLoading)
{
QString name = m_name;
// Loading
node->getAttr("Name", name);
if (!ctx.bUniqName)
{
SetName(name);
}
else
{
SetName(GetLibrary()->GetManager()->MakeUniqueItemName(name));
}
if (!ctx.bCopyPaste)
{
GUID guid;
if (node->getAttr("Id", guid))
{
SetGUID(guid);
}
}
}
else
{
// Saving.
node->setAttr("Name", m_name.toUtf8().data());
node->setAttr("Id", m_guid);
node->setAttr("Library", GetLibrary()->GetName().toUtf8().data());
}
m_bModified = false;
}
//////////////////////////////////////////////////////////////////////////
IDataBaseLibrary* CBaseLibraryItem::GetLibrary() const
{
return m_library;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryItem::SetLibrary(CBaseLibrary* pLibrary)
{
m_library = pLibrary;
}
//! Mark library as modified.
void CBaseLibraryItem::SetModified(bool bModified)
{
m_bModified = bModified;
if (m_bModified && m_library != nullptr)
{
m_library->SetModified(bModified);
}
}
-114
View File
@@ -1,114 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_BASELIBRARYITEM_H
#define CRYINCLUDE_EDITOR_BASELIBRARYITEM_H
#pragma once
#include "Include/IDataBaseItem.h"
#include "BaseLibrary.h"
#include <QMetaType>
class CBaseLibrary;
//////////////////////////////////////////////////////////////////////////
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
/** Base class for all items contained in BaseLibraray.
*/
class EDITOR_CORE_API CBaseLibraryItem
: public TRefCountBase<IDataBaseItem>
{
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
public:
CBaseLibraryItem();
~CBaseLibraryItem();
//! Set item name.
//! Its virtual, in case you want to override it in derrived item.
virtual void SetName(const QString& name);
//! Get item name.
const QString& GetName() const;
//! Get full item name, including name of library.
//! Name formed by adding dot after name of library
//! eg. library Pickup and item PickupRL form full item name: "Pickups.PickupRL".
QString GetFullName() const;
//! Get only nameof group from prototype.
QString GetGroupName();
//! Get short name of prototype without group.
QString GetShortName();
//! Return Library this item are contained in.
//! Item can only be at one library.
IDataBaseLibrary* GetLibrary() const;
void SetLibrary(CBaseLibrary* pLibrary);
//////////////////////////////////////////////////////////////////////////
//! Serialize library item to archive.
virtual void Serialize(SerializeContext& ctx);
//////////////////////////////////////////////////////////////////////////
//! Generate new unique id for this item.
void GenerateId();
//! Returns GUID of this material.
const GUID& GetGUID() const { return m_guid; }
//! Mark library as modified.
void SetModified(bool bModified = true);
//! Check if library was modified.
bool IsModified() const { return m_bModified; };
//! Returns true if the item is registered, otherwise false
bool IsRegistered() const { return m_bRegistered; };
//! Validate item for errors.
virtual void Validate() {};
//! Get number of sub childs.
virtual int GetChildCount() const { return 0; }
//! Get sub child by index.
virtual CBaseLibraryItem* GetChild([[maybe_unused]] int index) const { return nullptr; }
//////////////////////////////////////////////////////////////////////////
//! Gathers resources by this item.
virtual void GatherUsedResources([[maybe_unused]] CUsedResources& resources) {};
//! Get if stored item is enabled
virtual bool GetIsEnabled() { return true; };
int IsParticleItem = -1;
protected:
void SetGUID(REFGUID guid);
friend class CBaseLibrary;
friend class CBaseLibraryManager;
// Name of this prototype.
QString m_name;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
//! Reference to prototype library who contains this prototype.
_smart_ptr<CBaseLibrary> m_library;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
//! Every base library item have unique id.
GUID m_guid;
// True when item modified by editor.
bool m_bModified;
// True when item registered in manager.
bool m_bRegistered = false;
};
Q_DECLARE_METATYPE(CBaseLibraryItem*);
TYPEDEF_AUTOPTR(CBaseLibraryItem);
#endif // CRYINCLUDE_EDITOR_BASELIBRARYITEM_H
-938
View File
@@ -1,938 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "BaseLibraryManager.h"
// Editor
#include "BaseLibraryItem.h"
#include "ErrorReport.h"
#include "Undo/IUndoObject.h"
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Undo functionality for Managers, including add library, remove library, and rename library -- Vera, Confetti
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class CUndoBaseLibraryManager
: public IUndoObject
{
public:
CUndoBaseLibraryManager(CBaseLibraryManager* pMngr, const QString& description, const QString& modifiedManager = nullptr)
: m_pMngr(pMngr)
, m_description(description)
, m_editorObject(modifiedManager)
{
assert(m_pMngr);
SerializeTo(m_undos);
}
QString GetEditorObjectName() override
{
return m_editorObject;
}
protected:
int GetSize() override { return sizeof(CUndoBaseLibraryManager); }
QString GetDescription() override { return m_description; };
void Undo(bool bUndo) override
{
if (bUndo)
{
SerializeTo(m_redos);
}
m_pMngr->ClearAll();
UnserializeFrom(m_undos);
GetIEditor()->Notify(eNotify_OnDataBaseUpdate);
}
void Redo() override
{
m_pMngr->ClearAll();
UnserializeFrom(m_redos);
GetIEditor()->Notify(eNotify_OnDataBaseUpdate);
}
private:
struct LibUndoNode
: public _i_reference_target_t
{
LibUndoNode()
{
node = nullptr;
fileName = "";
}
XmlNodeRef node;
QString fileName;
};
static const char* const LIBRARY_TAG;
static const char* const LEVEL_LIBRARY_TAG;
void SerializeTo(std::vector<_smart_ptr<LibUndoNode> >& undos) // Save Library Undo
{
undos.clear();
for (int i = 0; i < m_pMngr->GetLibraryCount(); i++)
{
IDataBaseLibrary* library = m_pMngr->GetLibrary(i);
const char* tag = library->IsLevelLibrary() ? LEVEL_LIBRARY_TAG : LIBRARY_TAG;
XmlNodeRef node = GetIEditor()->GetSystem()->CreateXmlNode(tag);
QString file = library->GetFilename().isEmpty() ? library->GetFilename() : library->GetName();
library->Serialize(node, false);
if (node && !file.isEmpty())
{
_smart_ptr<LibUndoNode> undo = new LibUndoNode();
undo->fileName = file;
undo->node = node;
undos.push_back(undo);
}
}
}
void UnserializeFrom(std::vector<_smart_ptr<LibUndoNode> >& undos) // Load Library Undo
{
for (int i = 0; i < undos.size(); i++)
{
_smart_ptr<LibUndoNode> undo = undos[i];
if (undo->node && !undo->fileName.isEmpty())
{
//AddLibrary adds a .xml to the end of the library path, this will remove the extra for compatibility
undo->fileName.replace(m_pMngr->GetLibsPath().toLower(), "");
undo->fileName.replace(".xml", "");
const bool isLevelLibrary = (strcmp(undo->node->getTag(), LEVEL_LIBRARY_TAG) == 0);
IDataBaseLibrary* library = m_pMngr->AddLibrary(undo->fileName, isLevelLibrary);
library->Serialize(undo->node, true);
}
}
}
QString m_description;
QString m_editorObject;
CBaseLibraryManager* m_pMngr;
std::vector<_smart_ptr<LibUndoNode> > m_undos;
std::vector<_smart_ptr<LibUndoNode> > m_redos;
};
const char* const CUndoBaseLibraryManager::LIBRARY_TAG = "UndoLibrary";
const char* const CUndoBaseLibraryManager::LEVEL_LIBRARY_TAG = "UndoLevelLibrary";
//////////////////////////////////////////////////////////////////////////
// CBaseLibraryManager implementation.
//////////////////////////////////////////////////////////////////////////
CBaseLibraryManager::CBaseLibraryManager()
{
m_bUniqNameMap = false;
m_bUniqGuidMap = true;
GetIEditor()->RegisterNotifyListener(this);
}
//////////////////////////////////////////////////////////////////////////
CBaseLibraryManager::~CBaseLibraryManager()
{
ClearAll();
GetIEditor()->UnregisterNotifyListener(this);
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::ClearAll()
{
// Delete all items from all libraries.
for (int i = 0; i < m_libs.size(); i++)
{
m_libs[i]->RemoveAllItems();
}
// if we will not copy maps locally then destructors of the elements of
// the map will operate on the already invalid map object
// see:
// CBaseLibraryManager::UnregisterItem()
// CBaseLibraryManager::DeleteItem()
// CMaterial::~CMaterial()
ItemsGUIDMap itemsGuidMap;
ItemsNameMap itemsNameMap;
{
AZStd::lock_guard<AZStd::mutex> lock(m_itemsNameMapMutex);
std::swap(itemsGuidMap, m_itemsGuidMap);
std::swap(itemsNameMap, m_itemsNameMap);
m_libs.clear();
}
}
//////////////////////////////////////////////////////////////////////////
IDataBaseLibrary* CBaseLibraryManager::FindLibrary(const QString& library)
{
const int index = FindLibraryIndex(library);
return index == -1 ? nullptr : m_libs[index];
}
//////////////////////////////////////////////////////////////////////////
int CBaseLibraryManager::FindLibraryIndex(const QString& library)
{
QString lib = library;
lib.replace('\\', '/');
for (int i = 0; i < m_libs.size(); i++)
{
QString _lib = m_libs[i]->GetFilename();
_lib.replace('\\', '/');
if (QString::compare(lib, m_libs[i]->GetName(), Qt::CaseInsensitive) == 0 || QString::compare(lib, _lib, Qt::CaseInsensitive) == 0)
{
return i;
}
}
return -1;
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibraryManager::FindItem(REFGUID guid) const
{
CBaseLibraryItem* pMtl = stl::find_in_map(m_itemsGuidMap, guid, nullptr);
return pMtl;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::SplitFullItemName(const QString& fullItemName, QString& libraryName, QString& itemName)
{
int p;
p = fullItemName.indexOf('.');
if (p < 0 || !QString::compare(fullItemName.mid(p + 1), "mtl", Qt::CaseInsensitive))
{
libraryName = "";
itemName = fullItemName;
return;
}
libraryName = fullItemName.mid(0, p);
itemName = fullItemName.mid(p + 1);
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibraryManager::FindItemByName(const QString& fullItemName)
{
AZStd::lock_guard<AZStd::mutex> lock(m_itemsNameMapMutex);
return stl::find_in_map(m_itemsNameMap, fullItemName, nullptr);
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibraryManager::LoadItemByName(const QString& fullItemName)
{
QString libraryName, itemName;
SplitFullItemName(fullItemName, libraryName, itemName);
if (!FindLibrary(libraryName))
{
LoadLibrary(MakeFilename(libraryName));
}
return FindItemByName(fullItemName);
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibraryManager::FindItemByName(const char* fullItemName)
{
return FindItemByName(QString(fullItemName));
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibraryManager::LoadItemByName(const char* fullItemName)
{
return LoadItemByName(QString(fullItemName));
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibraryManager::CreateItem(IDataBaseLibrary* pLibrary)
{
assert(pLibrary);
// Add item to this library.
TSmartPtr<CBaseLibraryItem> pItem = MakeNewItem();
pLibrary->AddItem(pItem);
return pItem;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::DeleteItem(IDataBaseItem* pItem)
{
assert(pItem);
UnregisterItem((CBaseLibraryItem*)pItem);
if (pItem->GetLibrary())
{
pItem->GetLibrary()->RemoveItem(pItem);
}
}
//////////////////////////////////////////////////////////////////////////
IDataBaseLibrary* CBaseLibraryManager::LoadLibrary(const QString& inFilename, [[maybe_unused]] bool bReload)
{
if (auto lib = FindLibrary(inFilename))
{
return lib;
}
TSmartPtr<CBaseLibrary> pLib = MakeNewLibrary();
if (!pLib->Load(MakeFilename(inFilename)))
{
Error(QObject::tr("Failed to Load Item Library: %1").arg(inFilename).toUtf8().data());
return nullptr;
}
m_libs.push_back(pLib);
return pLib;
}
//////////////////////////////////////////////////////////////////////////
int CBaseLibraryManager::GetModifiedLibraryCount() const
{
int count = 0;
for (int i = 0; i < m_libs.size(); i++)
{
if (m_libs[i]->IsModified())
{
count++;
}
}
return count;
}
//////////////////////////////////////////////////////////////////////////
IDataBaseLibrary* CBaseLibraryManager::AddLibrary(const QString& library, bool bIsLevelLibrary, bool bIsLoading)
{
// Make a filename from name of library.
QString filename = library;
if (filename.indexOf(".xml") == -1) // if its already a filename, we don't do anything
{
filename.replace(' ', '_');
if (!bIsLevelLibrary)
{
filename = MakeFilename(library);
}
else
{
// if its the level library it gets saved in the level and should not be concatenated with any other file name
filename = filename + ".xml";
}
}
IDataBaseLibrary* pBaseLib = FindLibrary(library); //library name
if (!pBaseLib)
{
pBaseLib = FindLibrary(filename); //library file name
}
if (pBaseLib)
{
return pBaseLib;
}
CBaseLibrary* lib = MakeNewLibrary();
lib->SetName(library);
lib->SetLevelLibrary(bIsLevelLibrary);
lib->SetFilename(filename, !bIsLoading);
// set modified to true, so even empty particle libraries get saved
lib->SetModified(true);
m_libs.push_back(lib);
return lib;
}
//////////////////////////////////////////////////////////////////////////
QString CBaseLibraryManager::MakeFilename(const QString& library)
{
QString filename = library;
filename.replace(' ', '_');
filename.replace(".xml", "");
// make it contain the canonical libs path:
Path::ConvertBackSlashToSlash(filename);
QString LibsPath(GetLibsPath());
Path::ConvertBackSlashToSlash(LibsPath);
if (filename.left(LibsPath.length()).compare(LibsPath, Qt::CaseInsensitive) == 0)
{
filename = filename.mid(LibsPath.length());
}
return LibsPath + filename + ".xml";
}
//////////////////////////////////////////////////////////////////////////
bool CBaseLibraryManager::IsUniqueFilename(const QString& library)
{
QString resultPath = MakeFilename(library);
CCryFile xmlFile;
// If we can find a file for the path
return !xmlFile.Open(resultPath.toUtf8().data(), "rb");
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::DeleteLibrary(const QString& library, bool forceDeleteLevel)
{
for (int i = 0; i < m_libs.size(); i++)
{
if (QString::compare(library, m_libs[i]->GetName(), Qt::CaseInsensitive) == 0)
{
CBaseLibrary* pLibrary = m_libs[i];
// Check if not level library, they cannot be deleted.
if (!pLibrary->IsLevelLibrary() || forceDeleteLevel)
{
for (int j = 0; j < pLibrary->GetItemCount(); j++)
{
UnregisterItem((CBaseLibraryItem*)pLibrary->GetItem(j));
}
pLibrary->RemoveAllItems();
if (pLibrary->IsLevelLibrary())
{
m_pLevelLibrary = nullptr;
}
m_libs.erase(m_libs.begin() + i);
}
break;
}
}
}
//////////////////////////////////////////////////////////////////////////
IDataBaseLibrary* CBaseLibraryManager::GetLibrary(int index) const
{
assert(index >= 0 && index < m_libs.size());
return m_libs[index];
};
//////////////////////////////////////////////////////////////////////////
IDataBaseLibrary* CBaseLibraryManager::GetLevelLibrary() const
{
IDataBaseLibrary* pLevelLib = nullptr;
for (int i = 0; i < GetLibraryCount(); i++)
{
if (GetLibrary(i)->IsLevelLibrary())
{
pLevelLib = GetLibrary(i);
break;
}
}
return pLevelLib;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::SaveAllLibs()
{
for (int i = 0; i < GetLibraryCount(); i++)
{
// Check if library is modified.
IDataBaseLibrary* pLibrary = GetLibrary(i);
//Level library is saved when the level is saved
if (pLibrary->IsLevelLibrary())
{
continue;
}
if (pLibrary->IsModified())
{
if (pLibrary->Save())
{
pLibrary->SetModified(false);
}
}
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::Serialize(XmlNodeRef& node, bool bLoading)
{
static const char* const LEVEL_LIBRARY_TAG = "LevelLibrary";
QString rootNodeName = GetRootNodeName();
if (bLoading)
{
XmlNodeRef libs = node->findChild(rootNodeName.toUtf8().data());
if (libs)
{
for (int i = 0; i < libs->getChildCount(); i++)
{
// Load only library name.
XmlNodeRef libNode = libs->getChild(i);
if (strcmp(libNode->getTag(), LEVEL_LIBRARY_TAG) == 0)
{
if (!m_pLevelLibrary)
{
QString libName;
libNode->getAttr("Name", libName);
m_pLevelLibrary = static_cast<CBaseLibrary*>(AddLibrary(libName, true));
}
m_pLevelLibrary->Serialize(libNode, bLoading);
}
else
{
QString libName;
if (libNode->getAttr("Name", libName))
{
// Load this library.
if (!FindLibrary(libName))
{
LoadLibrary(MakeFilename(libName));
}
}
}
}
}
}
else
{
// Save all libraries.
XmlNodeRef libs = node->newChild(rootNodeName.toUtf8().data());
for (int i = 0; i < GetLibraryCount(); i++)
{
IDataBaseLibrary* pLib = GetLibrary(i);
if (pLib->IsLevelLibrary())
{
// Level libraries are saved in in level.
XmlNodeRef libNode = libs->newChild(LEVEL_LIBRARY_TAG);
pLib->Serialize(libNode, bLoading);
}
else
{
// Save only library name.
XmlNodeRef libNode = libs->newChild("Library");
libNode->setAttr("Name", pLib->GetName().toUtf8().data());
}
}
SaveAllLibs();
}
}
//////////////////////////////////////////////////////////////////////////
QString CBaseLibraryManager::MakeUniqueItemName(const QString& srcName, const QString& libName)
{
// unlikely we'll ever encounter more than 16
std::vector<AZStd::string> possibleDuplicates;
possibleDuplicates.reserve(16);
// search for strings in the database that might have a similar name (ignore case)
IDataBaseItemEnumerator* pEnum = GetItemEnumerator();
for (IDataBaseItem* pItem = pEnum->GetFirst(); pItem != nullptr; pItem = pEnum->GetNext())
{
//Check if the item is in the target library first.
IDataBaseLibrary* itemLibrary = pItem->GetLibrary();
QString itemLibraryName;
if (itemLibrary)
{
itemLibraryName = itemLibrary->GetName();
}
// Item is not in the library so there cannot be a naming conflict.
if (!libName.isEmpty() && !itemLibraryName.isEmpty() && itemLibraryName != libName)
{
continue;
}
const QString& name = pItem->GetName();
if (name.startsWith(srcName, Qt::CaseInsensitive))
{
possibleDuplicates.push_back(AZStd::string(name.toUtf8().data()));
}
}
pEnum->Release();
if (possibleDuplicates.empty())
{
return srcName;
}
std::sort(possibleDuplicates.begin(), possibleDuplicates.end(), [](const AZStd::string& strOne, const AZStd::string& strTwo)
{
// I can assume size sorting since if the length is different, either one of the two strings doesn't
// closely match the string we are trying to duplicate, or it's a bigger number (X1 vs X10)
if (strOne.size() != strTwo.size())
{
return strOne.size() < strTwo.size();
}
else
{
return azstricmp(strOne.c_str(), strTwo.c_str()) < 0;
}
}
);
int num = 0;
QString returnValue = srcName;
while (num < possibleDuplicates.size() && QString::compare(possibleDuplicates[num].c_str(), returnValue, Qt::CaseInsensitive) == 0)
{
returnValue = QStringLiteral("%1%2%3").arg(srcName).arg("_").arg(num);
++num;
}
return returnValue;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::Validate()
{
IDataBaseItemEnumerator* pEnum = GetItemEnumerator();
for (IDataBaseItem* pItem = pEnum->GetFirst(); pItem != nullptr; pItem = pEnum->GetNext())
{
pItem->Validate();
}
pEnum->Release();
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::RegisterItem(CBaseLibraryItem* pItem, REFGUID newGuid)
{
assert(pItem);
bool bNotify = false;
if (m_bUniqGuidMap)
{
bool bNewItem = true;
REFGUID oldGuid = pItem->GetGUID();
if (!GuidUtil::IsEmpty(oldGuid))
{
bNewItem = false;
m_itemsGuidMap.erase(oldGuid);
}
if (GuidUtil::IsEmpty(newGuid))
{
return;
}
CBaseLibraryItem* pOldItem = stl::find_in_map(m_itemsGuidMap, newGuid, nullptr);
if (!pOldItem)
{
pItem->m_guid = newGuid;
m_itemsGuidMap[newGuid] = pItem;
pItem->m_bRegistered = true;
bNotify = true;
}
else
{
if (pOldItem != pItem)
{
ReportDuplicateItem(pItem, pOldItem);
}
}
}
if (m_bUniqNameMap)
{
QString fullName = pItem->GetFullName();
if (!pItem->GetName().isEmpty())
{
CBaseLibraryItem* pOldItem = static_cast<CBaseLibraryItem*>(FindItemByName(fullName));
if (!pOldItem)
{
AZStd::lock_guard<AZStd::mutex> lock(m_itemsNameMapMutex);
m_itemsNameMap[fullName] = pItem;
pItem->m_bRegistered = true;
bNotify = true;
}
else
{
if (pOldItem != pItem)
{
ReportDuplicateItem(pItem, pOldItem);
}
}
}
}
// Notify listeners.
if (bNotify)
{
NotifyItemEvent(pItem, EDB_ITEM_EVENT_ADD);
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::RegisterItem(CBaseLibraryItem* pItem)
{
assert(pItem);
bool bNotify = false;
if (m_bUniqGuidMap)
{
if (GuidUtil::IsEmpty(pItem->GetGUID()))
{
return;
}
CBaseLibraryItem* pOldItem = stl::find_in_map(m_itemsGuidMap, pItem->GetGUID(), nullptr);
if (!pOldItem)
{
m_itemsGuidMap[pItem->GetGUID()] = pItem;
pItem->m_bRegistered = true;
bNotify = true;
}
else
{
if (pOldItem != pItem)
{
ReportDuplicateItem(pItem, pOldItem);
}
}
}
if (m_bUniqNameMap)
{
QString fullName = pItem->GetFullName();
if (!fullName.isEmpty())
{
CBaseLibraryItem* pOldItem = static_cast<CBaseLibraryItem*>(FindItemByName(fullName));
if (!pOldItem)
{
AZStd::lock_guard<AZStd::mutex> lock(m_itemsNameMapMutex);
m_itemsNameMap[fullName] = pItem;
pItem->m_bRegistered = true;
bNotify = true;
}
else
{
if (pOldItem != pItem)
{
ReportDuplicateItem(pItem, pOldItem);
}
}
}
}
// Notify listeners.
if (bNotify)
{
NotifyItemEvent(pItem, EDB_ITEM_EVENT_ADD);
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::SetRegisteredFlag(CBaseLibraryItem* pItem, bool bFlag)
{
pItem->m_bRegistered = bFlag;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::ReportDuplicateItem(CBaseLibraryItem* pItem, CBaseLibraryItem* pOldItem)
{
QString sLibName;
if (pOldItem->GetLibrary())
{
sLibName = pOldItem->GetLibrary()->GetName();
}
CErrorRecord err;
err.pItem = pItem;
err.error = QStringLiteral("Item %1 with duplicate GUID to loaded item %2 ignored").arg(pItem->GetFullName(), pOldItem->GetFullName());
GetIEditor()->GetErrorReport()->ReportError(err);
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::UnregisterItem(CBaseLibraryItem* pItem)
{
// Notify listeners.
NotifyItemEvent(pItem, EDB_ITEM_EVENT_DELETE);
if (!pItem)
{
return;
}
if (m_bUniqGuidMap)
{
m_itemsGuidMap.erase(pItem->GetGUID());
}
if (m_bUniqNameMap && !pItem->GetFullName().isEmpty())
{
AZStd::lock_guard<AZStd::mutex> lock(m_itemsNameMapMutex);
auto findIter = m_itemsNameMap.find(pItem->GetFullName());
if (findIter != m_itemsNameMap.end())
{
_smart_ptr<CBaseLibraryItem> item = findIter->second;
m_itemsNameMap.erase(findIter);
}
}
pItem->m_bRegistered = false;
}
//////////////////////////////////////////////////////////////////////////
QString CBaseLibraryManager::MakeFullItemName(IDataBaseLibrary* pLibrary, const QString& group, const QString& itemName)
{
assert(pLibrary);
QString name = pLibrary->GetName() + ".";
if (!group.isEmpty())
{
name += group + ".";
}
name += itemName;
return name;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::GatherUsedResources(CUsedResources& resources)
{
IDataBaseItemEnumerator* pEnum = GetItemEnumerator();
for (IDataBaseItem* pItem = pEnum->GetFirst(); pItem != nullptr; pItem = pEnum->GetNext())
{
pItem->GatherUsedResources(resources);
}
pEnum->Release();
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItemEnumerator* CBaseLibraryManager::GetItemEnumerator()
{
if (m_bUniqNameMap)
{
return new CDataBaseItemEnumerator<ItemsNameMap>(&m_itemsNameMap);
}
else
{
return new CDataBaseItemEnumerator<ItemsGUIDMap>(&m_itemsGuidMap);
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::OnEditorNotifyEvent(EEditorNotifyEvent event)
{
switch (event)
{
case eNotify_OnBeginNewScene:
SetSelectedItem(nullptr);
ClearAll();
break;
case eNotify_OnBeginSceneOpen:
SetSelectedItem(nullptr);
ClearAll();
break;
case eNotify_OnCloseScene:
SetSelectedItem(nullptr);
ClearAll();
break;
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::OnRenameItem(CBaseLibraryItem* pItem, const QString& oldName)
{
m_itemsNameMapMutex.lock();
if (!oldName.isEmpty())
{
m_itemsNameMap.erase(oldName);
}
if (!pItem->GetFullName().isEmpty())
{
m_itemsNameMap[pItem->GetFullName()] = pItem;
}
m_itemsNameMapMutex.unlock();
OnItemChanged(pItem);
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::AddListener(IDataBaseManagerListener* pListener)
{
stl::push_back_unique(m_listeners, pListener);
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::RemoveListener(IDataBaseManagerListener* pListener)
{
stl::find_and_erase(m_listeners, pListener);
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::NotifyItemEvent(IDataBaseItem* pItem, EDataBaseItemEvent event)
{
// Notify listeners.
if (!m_listeners.empty())
{
for (int i = 0; i < m_listeners.size(); i++)
{
m_listeners[i]->OnDataBaseItemEvent(pItem, event);
}
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::OnItemChanged(IDataBaseItem* pItem)
{
NotifyItemEvent(pItem, EDB_ITEM_EVENT_CHANGED);
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::OnUpdateProperties(IDataBaseItem* pItem, bool bRefresh)
{
NotifyItemEvent(pItem, bRefresh ? EDB_ITEM_EVENT_UPDATE_PROPERTIES
: EDB_ITEM_EVENT_UPDATE_PROPERTIES_NO_EDITOR_REFRESH);
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::SetSelectedItem(IDataBaseItem* pItem)
{
if (m_pSelectedItem == pItem)
{
return;
}
m_pSelectedItem = (CBaseLibraryItem*)pItem;
NotifyItemEvent(m_pSelectedItem, EDB_ITEM_EVENT_SELECTED);
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibraryManager::GetSelectedItem() const
{
return m_pSelectedItem;
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibraryManager::GetSelectedParentItem() const
{
return m_pSelectedParent;
}
void CBaseLibraryManager::ChangeLibraryOrder(IDataBaseLibrary* lib, unsigned int newLocation)
{
if (!lib || newLocation >= m_libs.size() || lib == m_libs[newLocation])
{
return;
}
for (int i = 0; i < m_libs.size(); i++)
{
if (lib == m_libs[i])
{
_smart_ptr<CBaseLibrary> curLib = m_libs[i];
m_libs.erase(m_libs.begin() + i);
m_libs.insert(m_libs.begin() + newLocation, curLib);
return;
}
}
}
bool CBaseLibraryManager::SetLibraryName(CBaseLibrary* lib, const QString& name)
{
// SetFilename will validate if the name is duplicate with exist libraries.
if (lib->SetFilename(MakeFilename(name)))
{
lib->SetName(name);
return true;
}
return false;
}
-226
View File
@@ -1,226 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_BASELIBRARYMANAGER_H
#define CRYINCLUDE_EDITOR_BASELIBRARYMANAGER_H
#pragma once
#include "Include/IBaseLibraryManager.h"
#include "Include/IDataBaseItem.h"
#include "Include/IDataBaseLibrary.h"
#include "Include/IDataBaseManager.h"
#include "Util/TRefCountBase.h"
#include "Util/GuidUtil.h"
#include "BaseLibrary.h"
#include "Util/smartptr.h"
#include <EditorDefs.h>
#include <QtUtil.h>
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
/** Manages all Libraries and Items.
*/
class SANDBOX_API CBaseLibraryManager
: public IBaseLibraryManager
{
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
public:
CBaseLibraryManager();
~CBaseLibraryManager();
//! Clear all libraries.
void ClearAll() override;
//////////////////////////////////////////////////////////////////////////
// IDocListener implementation.
//////////////////////////////////////////////////////////////////////////
void OnEditorNotifyEvent(EEditorNotifyEvent event) override;
//////////////////////////////////////////////////////////////////////////
// Library items.
//////////////////////////////////////////////////////////////////////////
//! Make a new item in specified library.
IDataBaseItem* CreateItem(IDataBaseLibrary* pLibrary) override;
//! Delete item from library and manager.
void DeleteItem(IDataBaseItem* pItem) override;
//! Find Item by its GUID.
IDataBaseItem* FindItem(REFGUID guid) const override;
IDataBaseItem* FindItemByName(const QString& fullItemName) override;
IDataBaseItem* LoadItemByName(const QString& fullItemName) override;
virtual IDataBaseItem* FindItemByName(const char* fullItemName);
virtual IDataBaseItem* LoadItemByName(const char* fullItemName);
IDataBaseItemEnumerator* GetItemEnumerator() override;
//////////////////////////////////////////////////////////////////////////
// Set item currently selected.
void SetSelectedItem(IDataBaseItem* pItem) override;
// Get currently selected item.
IDataBaseItem* GetSelectedItem() const override;
IDataBaseItem* GetSelectedParentItem() const override;
//////////////////////////////////////////////////////////////////////////
// Libraries.
//////////////////////////////////////////////////////////////////////////
//! Add Item library.
IDataBaseLibrary* AddLibrary(const QString& library, bool bIsLevelLibrary = false, bool bIsLoading = true) override;
void DeleteLibrary(const QString& library, bool forceDeleteLevel = false) override;
//! Get number of libraries.
int GetLibraryCount() const override { return static_cast<int>(m_libs.size()); };
//! Get number of modified libraries.
int GetModifiedLibraryCount() const override;
//! Get Item library by index.
IDataBaseLibrary* GetLibrary(int index) const override;
//! Get Level Item library.
IDataBaseLibrary* GetLevelLibrary() const override;
//! Find Items Library by name.
IDataBaseLibrary* FindLibrary(const QString& library) override;
//! Find Items Library's index by name.
int FindLibraryIndex(const QString& library) override;
//! Load Items library.
IDataBaseLibrary* LoadLibrary(const QString& filename, bool bReload = false) override;
//! Save all modified libraries.
void SaveAllLibs() override;
//! Serialize property manager.
void Serialize(XmlNodeRef& node, bool bLoading) override;
//! Export items to game.
void Export([[maybe_unused]] XmlNodeRef& node) override {};
//! Returns unique name base on input name.
QString MakeUniqueItemName(const QString& name, const QString& libName = "") override;
QString MakeFullItemName(IDataBaseLibrary* pLibrary, const QString& group, const QString& itemName) override;
//! Root node where this library will be saved.
QString GetRootNodeName() override = 0;
//! Path to libraries in this manager.
QString GetLibsPath() override = 0;
//////////////////////////////////////////////////////////////////////////
//! Validate library items for errors.
void Validate() override;
//////////////////////////////////////////////////////////////////////////
void GatherUsedResources(CUsedResources& resources) override;
void AddListener(IDataBaseManagerListener* pListener) override;
void RemoveListener(IDataBaseManagerListener* pListener) override;
//////////////////////////////////////////////////////////////////////////
void RegisterItem(CBaseLibraryItem* pItem, REFGUID newGuid) override;
void RegisterItem(CBaseLibraryItem* pItem) override;
void UnregisterItem(CBaseLibraryItem* pItem) override;
// Only Used internally.
void OnRenameItem(CBaseLibraryItem* pItem, const QString& oldName) override;
// Called by items to indicated that they have been modified.
// Sends item changed event to listeners.
void OnItemChanged(IDataBaseItem* pItem) override;
void OnUpdateProperties(IDataBaseItem* pItem, bool bRefresh) override;
QString MakeFilename(const QString& library);
bool IsUniqueFilename(const QString& library) override;
//CONFETTI BEGIN
// Used to change the library item order
void ChangeLibraryOrder(IDataBaseLibrary* lib, unsigned int newLocation) override;
bool SetLibraryName(CBaseLibrary* lib, const QString& name) override;
protected:
void SplitFullItemName(const QString& fullItemName, QString& libraryName, QString& itemName);
void NotifyItemEvent(IDataBaseItem* pItem, EDataBaseItemEvent event);
void SetRegisteredFlag(CBaseLibraryItem* pItem, bool bFlag);
//////////////////////////////////////////////////////////////////////////
// Must be overriden.
//! Makes a new Item.
virtual CBaseLibraryItem* MakeNewItem() = 0;
virtual CBaseLibrary* MakeNewLibrary() = 0;
//////////////////////////////////////////////////////////////////////////
virtual void ReportDuplicateItem(CBaseLibraryItem* pItem, CBaseLibraryItem* pOldItem);
protected:
bool m_bUniqGuidMap;
bool m_bUniqNameMap;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
//! Array of all loaded entity items libraries.
std::vector<_smart_ptr<CBaseLibrary> > m_libs;
// There is always one current level library.
TSmartPtr<CBaseLibrary> m_pLevelLibrary;
// GUID to item map.
typedef std::map<GUID, _smart_ptr<CBaseLibraryItem>, guid_less_predicate> ItemsGUIDMap;
ItemsGUIDMap m_itemsGuidMap;
// Case insensitive name to items map.
typedef std::map<QString, _smart_ptr<CBaseLibraryItem>, stl::less_stricmp<QString>> ItemsNameMap;
ItemsNameMap m_itemsNameMap;
AZStd::mutex m_itemsNameMapMutex;
std::vector<IDataBaseManagerListener*> m_listeners;
// Currently selected item.
_smart_ptr<CBaseLibraryItem> m_pSelectedItem;
_smart_ptr<CBaseLibraryItem> m_pSelectedParent;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
//////////////////////////////////////////////////////////////////////////
template <class TMap>
class CDataBaseItemEnumerator
: public IDataBaseItemEnumerator
{
TMap* m_pMap;
typename TMap::iterator m_iterator;
public:
CDataBaseItemEnumerator(TMap* pMap)
{
assert(pMap);
m_pMap = pMap;
m_iterator = m_pMap->begin();
}
void Release() override { delete this; };
IDataBaseItem* GetFirst() override
{
m_iterator = m_pMap->begin();
if (m_iterator == m_pMap->end())
{
return 0;
}
return m_iterator->second;
}
IDataBaseItem* GetNext() override
{
if (m_iterator != m_pMap->end())
{
m_iterator++;
}
if (m_iterator == m_pMap->end())
{
return 0;
}
return m_iterator->second;
}
};
#endif // CRYINCLUDE_EDITOR_BASELIBRARYMANAGER_H
+4 -38
View File
@@ -33,7 +33,6 @@ ly_add_target(
BUILD_DEPENDENCIES
PRIVATE
Legacy::CryCommon
3rdParty::zlib
PUBLIC
3rdParty::Qt::Core
3rdParty::Qt::Gui
@@ -64,7 +63,7 @@ ly_add_target(
set(pal_cmake_files "")
foreach(enabled_platform ${LY_PAL_TOOLS_ENABLED})
string(TOLOWER ${enabled_platform} enabled_platform_lowercase)
ly_get_list_relative_pal_filename(pal_cmake_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${enabled_platform})
o3de_pal_dir(pal_cmake_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${enabled_platform} ${O3DE_ENGINE_RESTRICTED_PATH} ${LY_ROOT_FOLDER})
list(APPEND pal_cmake_files ${pal_cmake_dir}/editor_lib_${enabled_platform_lowercase}_files.cmake)
endforeach()
@@ -103,16 +102,13 @@ ly_add_target(
3rdParty::Qt::Gui
3rdParty::Qt::Widgets
3rdParty::Qt::Concurrent
3rdParty::tiff
3rdParty::TIFF
3rdParty::squish-ccr
3rdParty::zlib
3rdParty::AWSNativeSDK::STS
Legacy::CryCommon
Legacy::EditorCommon
AZ::AzCore
AZ::AzToolsFramework
Gem::LmbrCentral.Static
AZ::AWSNativeSDKInit
AZ::AtomCore
Gem::Atom_RPI.Edit
Gem::Atom_RPI.Public
@@ -121,7 +117,6 @@ ly_add_target(
Gem::AtomViewportDisplayInfo
${additional_dependencies}
PUBLIC
3rdParty::AWSNativeSDK::Core
3rdParty::Qt::Network
Legacy::EditorCore
RUNTIME_DEPENDENCIES
@@ -133,7 +128,7 @@ ly_add_source_properties(
PROPERTY COMPILE_DEFINITIONS
VALUES
O3DE_COPYRIGHT_YEAR=${LY_VERSION_COPYRIGHT_YEAR}
LY_BUILD=${LY_VERSION_BUILD_NUMBER}
LY_VERSION_BUILD_NUMBER=${LY_VERSION_BUILD_NUMBER}
${LY_PAL_TOOLS_DEFINES}
)
ly_add_source_properties(
@@ -251,38 +246,9 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
RUNTIME_DEPENDENCIES
Gem::LmbrCentral
)
ly_add_googletest(
NAME Legacy::EditorLib.Tests
)
ly_add_target(
NAME EditorLib.Camera.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
NAMESPACE Legacy
FILES_CMAKE
Lib/Tests/Camera/editor_lib_camera_test_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
.
BUILD_DEPENDENCIES
PRIVATE
AZ::AzCore
AZ::AzTest
AZ::AzToolsFramework
AZ::AzTestShared
Legacy::EditorLib
Gem::Camera.Editor
Gem::AtomToolsFramework.Static
RUNTIME_DEPENDENCIES
Legacy::EditorLib
)
ly_add_source_properties(
SOURCES Lib/Tests/Camera/test_EditorCamera.cpp
PROPERTY COMPILE_DEFINITIONS
VALUES CAMERA_EDITOR_MODULE="$<TARGET_FILE_BASE_NAME:Camera.Editor>"
)
ly_add_googletest(
NAME Legacy::EditorLib.Camera.Tests
)
endif()
+3
View File
@@ -16,9 +16,12 @@
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/utils.h>
struct ICVar;
class CVarMenu
: public QMenu
{
Q_OBJECT
public:
// CVar that can be toggled on and off
struct CVarToggle
-3
View File
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:58ef978b31b31df9aaf715a0e9b006fde414a17a3ff15a3bf680eaad7418867a
size 364
-3
View File
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:98a681ec3d89ee57c5d1057fe984dcf8ad45721f47ae4df57fa358fbee85e616
size 385
-3
View File
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:24a2b2c9242a841c20e7815dab0d80a575844055328aea413d28b7283b65a92e
size 386
-3
View File
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ce23a276fec849b8f832fab96d3b738793335c27d37ae3813158387f3415b508
size 377
-3
View File
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c03befab41765200f4f28dbf1e0b2a702d2244bfa79b0d463f5d58d0a26095fc
size 386
-3
View File
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:418c3f0f27854b3795841359014d87686a7bf94daf2568d9cfd3ffac22675f69
size 386
-3
View File
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d3a831f34ac53c9b1f20037290e8a2b62a3cfb8a4f86467591f44fd2a0e3c15b
size 379
-3
View File
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4267102ca7a889c34eff905480a68878d4d56e15bc723a5b0575cd472e259f5d
size 389
-3
View File
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a0df013dd102b87348fba18b4da5443591309e9c40166d27ae928636924154ea
size 388
-3
View File
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e713076ab5abbbb2cf28da431a339e9905acc790e35295f025aa2e79e1c04141
size 376
-3
View File
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9e5af9d62ceafc3b8a1dfc36772350cd623fcc86c68711b299e143ff133f79b6
size 387
-3
View File
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:17c5fb3d7b87ea87a98934954c721573c641bc44005a34f1e16589d7f39b71e8
size 409
-3
View File
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6f5c78d9f764b62fb7dcf400c91c1edea9d7f88a426ba513fbf70825c6bcd2ac
size 383
-3
View File
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:376b549602afffca407525b77c1a9821bf6a0e279792ae2e52fe0a4f7c3c5bd4
size 364
-3
View File
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e7dc48f8d324b7563b168f27ebde1e00ee2bd11ba462f114a05b297913e285c5
size 374
-3
View File
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:66b73afbd6dba1caaedfaae161b277b460b5198f7fc00bec414530116c567276
size 375
-3
View File
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ae6e6714acf495246f4e59f6e5640f3a4417ea50100d37a116950d2b859aed0c
size 417
+87 -95
View File
@@ -19,10 +19,9 @@ namespace Config
CConfigGroup::~CConfigGroup()
{
for (TConfigVariables::const_iterator it = m_vars.begin();
it != m_vars.end(); ++it)
for (IConfigVar* var : m_vars)
{
delete (*it);
delete var;
}
}
@@ -31,17 +30,15 @@ namespace Config
m_vars.push_back(var);
}
uint32 CConfigGroup::GetVarCount()
AZ::u32 CConfigGroup::GetVarCount()
{
return static_cast<uint32>(m_vars.size());
return aznumeric_cast<AZ::u32>(m_vars.size());
}
IConfigVar* CConfigGroup::GetVar(const char* szName)
{
for (TConfigVariables::const_iterator it = m_vars.begin();
it != m_vars.end(); ++it)
for (IConfigVar* var : m_vars)
{
IConfigVar* var = (*it);
if (0 == _stricmp(szName, var->GetName().c_str()))
{
return var;
@@ -53,20 +50,19 @@ namespace Config
const IConfigVar* CConfigGroup::GetVar(const char* szName) const
{
for (TConfigVariables::const_iterator it = m_vars.begin();
it != m_vars.end(); ++it)
for (const IConfigVar* var : m_vars)
{
IConfigVar* var = (*it);
if (0 == _stricmp(szName, var->GetName().c_str()))
{
return var;
}
}
return nullptr;
}
IConfigVar* CConfigGroup::GetVar(uint index)
IConfigVar* CConfigGroup::GetVar(AZ::u32 index)
{
if (index < m_vars.size())
{
@@ -76,7 +72,7 @@ namespace Config
return nullptr;
}
const IConfigVar* CConfigGroup::GetVar(uint index) const
const IConfigVar* CConfigGroup::GetVar(AZ::u32 index) const
{
if (index < m_vars.size())
{
@@ -89,114 +85,110 @@ namespace Config
void CConfigGroup::SaveToXML(XmlNodeRef node)
{
// save only values that don't have default values
for (TConfigVariables::const_iterator it = m_vars.begin();
it != m_vars.end(); ++it)
for (const IConfigVar* var : m_vars)
{
IConfigVar* var = (*it);
if (!var->IsFlagSet(IConfigVar::eFlag_DoNotSave))
if (var->IsFlagSet(IConfigVar::eFlag_DoNotSave) || var->IsDefault())
{
if (!var->IsDefault())
{
const char* szName = var->GetName().c_str();
continue;
}
switch (var->GetType())
{
case IConfigVar::eType_BOOL:
{
bool currentValue = false;
var->Get(&currentValue);
node->setAttr(szName, currentValue);
break;
}
const char* szName = var->GetName().c_str();
case IConfigVar::eType_INT:
{
int currentValue = 0;
var->Get(&currentValue);
node->setAttr(szName, currentValue);
break;
}
switch (var->GetType())
{
case IConfigVar::eType_BOOL:
{
bool currentValue = false;
var->Get(&currentValue);
node->setAttr(szName, currentValue);
break;
}
case IConfigVar::eType_FLOAT:
{
float currentValue = 0;
var->Get(&currentValue);
node->setAttr(szName, currentValue);
break;
}
case IConfigVar::eType_INT:
{
int currentValue = 0;
var->Get(&currentValue);
node->setAttr(szName, currentValue);
break;
}
case IConfigVar::eType_STRING:
{
AZStd::string currentValue;
var->Get(&currentValue);
node->setAttr(szName, currentValue.c_str());
break;
}
}
}
case IConfigVar::eType_FLOAT:
{
float currentValue = 0;
var->Get(&currentValue);
node->setAttr(szName, currentValue);
break;
}
case IConfigVar::eType_STRING:
{
AZStd::string currentValue;
var->Get(&currentValue);
node->setAttr(szName, currentValue.c_str());
break;
}
}
}
}
void CConfigGroup::LoadFromXML(XmlNodeRef node)
{
// save only values that don't have default values
for (TConfigVariables::const_iterator it = m_vars.begin();
it != m_vars.end(); ++it)
// load values that are save-able
for (IConfigVar* var : m_vars)
{
IConfigVar* var = (*it);
if (!var->IsFlagSet(IConfigVar::eFlag_DoNotSave))
if (var->IsFlagSet(IConfigVar::eFlag_DoNotSave))
{
const char* szName = var->GetName().c_str();
continue;
}
const char* szName = var->GetName().c_str();
switch (var->GetType())
switch (var->GetType())
{
case IConfigVar::eType_BOOL:
{
bool currentValue = false;
var->GetDefault(&currentValue);
if (node->getAttr(szName, currentValue))
{
case IConfigVar::eType_BOOL:
{
bool currentValue = false;
var->GetDefault(&currentValue);
if (node->getAttr(szName, currentValue))
{
var->Set(&currentValue);
}
break;
var->Set(&currentValue);
}
break;
}
case IConfigVar::eType_INT:
case IConfigVar::eType_INT:
{
int currentValue = 0;
var->GetDefault(&currentValue);
if (node->getAttr(szName, currentValue))
{
int currentValue = 0;
var->GetDefault(&currentValue);
if (node->getAttr(szName, currentValue))
{
var->Set(&currentValue);
}
break;
var->Set(&currentValue);
}
break;
}
case IConfigVar::eType_FLOAT:
case IConfigVar::eType_FLOAT:
{
float currentValue = 0;
var->GetDefault(&currentValue);
if (node->getAttr(szName, currentValue))
{
float currentValue = 0;
var->GetDefault(&currentValue);
if (node->getAttr(szName, currentValue))
{
var->Set(&currentValue);
}
break;
var->Set(&currentValue);
}
break;
}
case IConfigVar::eType_STRING:
case IConfigVar::eType_STRING:
{
AZStd::string currentValue;
var->GetDefault(&currentValue);
QString readValue(currentValue.c_str());
if (node->getAttr(szName, readValue))
{
AZStd::string currentValue;
var->GetDefault(&currentValue);
QString readValue(currentValue.c_str());
if (node->getAttr(szName, readValue))
{
currentValue = readValue.toUtf8().data();
var->Set(&currentValue);
}
break;
}
currentValue = readValue.toUtf8().data();
var->Set(&currentValue);
}
break;
}
}
}
}
+21 -69
View File
@@ -8,8 +8,12 @@
#pragma once
#ifndef CRYINCLUDE_EDITOR_CONFIGGROUP_H
#define CRYINCLUDE_EDITOR_CONFIGGROUP_H
#include <AzCore/base.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/string/string.h>
struct ICVar;
class XmlNodeRef;
namespace Config
{
@@ -32,7 +36,7 @@ namespace Config
eFlag_DoNotSave = 1 << 2,
};
IConfigVar(const char* szName, const char* szDescription, EType varType, uint8 flags)
IConfigVar(const char* szName, const char* szDescription, EType varType, AZ::u8 flags)
: m_name(szName)
, m_description(szDescription)
, m_type(varType)
@@ -42,22 +46,22 @@ namespace Config
virtual ~IConfigVar() = default;
ILINE EType GetType() const
AZ_FORCE_INLINE EType GetType() const
{
return m_type;
}
ILINE const AZStd::string& GetName() const
AZ_FORCE_INLINE const AZStd::string& GetName() const
{
return m_name;
}
ILINE const AZStd::string& GetDescription() const
AZ_FORCE_INLINE const AZStd::string& GetDescription() const
{
return m_description;
}
ILINE bool IsFlagSet(EFlags flag) const
AZ_FORCE_INLINE bool IsFlagSet(EFlags flag) const
{
return 0 != (m_flags & flag);
}
@@ -68,73 +72,28 @@ namespace Config
virtual void GetDefault(void* outPtr) const = 0;
virtual void Reset() = 0;
static EType TranslateType(const bool&) { return eType_BOOL; }
static EType TranslateType(const int&) { return eType_INT; }
static EType TranslateType(const float&) { return eType_FLOAT; }
static EType TranslateType(const AZStd::string&) { return eType_STRING; }
static constexpr EType TranslateType(const bool&) { return eType_BOOL; }
static constexpr EType TranslateType(const int&) { return eType_INT; }
static constexpr EType TranslateType(const float&) { return eType_FLOAT; }
static constexpr EType TranslateType(const AZStd::string&) { return eType_STRING; }
protected:
EType m_type;
uint8 m_flags;
AZ::u8 m_flags;
AZStd::string m_name;
AZStd::string m_description;
void* m_ptr;
ICVar* m_pCVar;
};
// Typed wrapper for config variable
template<class T>
class TConfigVar
: public IConfigVar
{
private:
T m_default;
public:
TConfigVar(const char* szName, const char* szDescription, uint8 flags, T& ptr, const T& defaultValue)
: IConfigVar(szName, szDescription, IConfigVar::TranslateType(ptr), flags)
, m_default(defaultValue)
{
m_ptr = &ptr;
// reset to default value on initializations
ptr = defaultValue;
}
virtual void Get(void* outPtr) const
{
*reinterpret_cast<T*>(outPtr) = *reinterpret_cast<const T*>(m_ptr);
}
virtual void Set(const void* ptr)
{
*reinterpret_cast<T*>(m_ptr) = *reinterpret_cast<const T*>(ptr);
}
virtual void Reset()
{
*reinterpret_cast<T*>(m_ptr) = m_default;
}
virtual void GetDefault(void* outPtr) const
{
*reinterpret_cast<T*>(outPtr) = m_default;
}
virtual bool IsDefault() const
{
return *reinterpret_cast<const T*>(m_ptr) == m_default;
}
};
// Group of configuration variables with optional mapping to CVars
class CConfigGroup
{
private:
typedef std::vector<IConfigVar*> TConfigVariables;
using TConfigVariables = AZStd::vector<IConfigVar*> ;
TConfigVariables m_vars;
typedef std::vector<ICVar*> TConsoleVariables;
using TConsoleVariables = AZStd::vector<ICVar*>;
TConsoleVariables m_consoleVars;
public:
@@ -142,20 +101,13 @@ namespace Config
virtual ~CConfigGroup();
void AddVar(IConfigVar* var);
uint32 GetVarCount();
AZ::u32 GetVarCount();
IConfigVar* GetVar(const char* szName);
IConfigVar* GetVar(uint index);
IConfigVar* GetVar(AZ::u32 index);
const IConfigVar* GetVar(const char* szName) const;
const IConfigVar* GetVar(uint index) const;
const IConfigVar* GetVar(AZ::u32 index) const;
void SaveToXML(XmlNodeRef node);
void LoadFromXML(XmlNodeRef node);
template<class T>
void AddVar(const char* szName, const char* szDescription, T& var, const T& defaultValue, uint8 flags = 0)
{
AddVar(new TConfigVar<T>(szName, szDescription, flags, var, defaultValue));
}
};
};
#endif // CRYINCLUDE_EDITOR_CONFIGGROUP_H
-923
View File
@@ -1,923 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "ColorGradientCtrl.h"
// Qt
#include <QPainter>
#include <QToolTip>
// AzQtComponents
#include <AzQtComponents/Components/Widgets/ColorPicker.h>
#define MIN_TIME_EPSILON 0.01f
//////////////////////////////////////////////////////////////////////////
CColorGradientCtrl::CColorGradientCtrl(QWidget* parent)
: QWidget(parent)
{
m_nActiveKey = -1;
m_nHitKeyIndex = -1;
m_nKeyDrawRadius = 3;
m_bTracking = false;
m_pSpline = nullptr;
m_fMinTime = -1;
m_fMaxTime = 1;
m_fMinValue = -1;
m_fMaxValue = 1;
m_fTooltipScaleX = 1;
m_fTooltipScaleY = 1;
m_bNoTimeMarker = true;
m_bLockFirstLastKey = false;
m_bNoZoom = true;
ClearSelection();
m_bSelectedKeys.reserve(0);
m_fTimeMarker = -10;
m_grid.zoom.x = 100;
setMouseTracking(true);
}
CColorGradientCtrl::~CColorGradientCtrl()
{
}
/////////////////////////////////////////////////////////////////////////////
// QColorGradientCtrl message handlers
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::resizeEvent(QResizeEvent* event)
{
QWidget::resizeEvent(event);
QRect rc(QPoint(0, 0), event->size());
m_rcGradient = rc;
m_rcGradient.setHeight(m_rcGradient.height() - 11);
//m_rcGradient.DeflateRect(4,4);
m_grid.rect = m_rcGradient;
if (m_bNoZoom)
{
m_grid.zoom.x = static_cast<f32>(m_grid.rect.width());
}
m_rcKeys = rc;
m_rcKeys.setTop(m_rcKeys.bottom() - 10);
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::SetZoom(float fZoom)
{
m_grid.zoom.x = fZoom;
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::SetOrigin(float fOffset)
{
m_grid.origin.x = fOffset;
}
//////////////////////////////////////////////////////////////////////////
QPoint CColorGradientCtrl::KeyToPoint(int nKey)
{
if (nKey >= 0)
{
return TimeToPoint(m_pSpline->GetKeyTime(nKey));
}
return QPoint(0, 0);
}
//////////////////////////////////////////////////////////////////////////
QPoint CColorGradientCtrl::TimeToPoint(float time)
{
return QPoint(m_grid.WorldToClient(Vec2(time, 0)).x(), m_rcGradient.height() / 2);
}
//////////////////////////////////////////////////////////////////////////
AZ::Color CColorGradientCtrl::TimeToColor(float time)
{
ISplineInterpolator::ValueType val;
m_pSpline->Interpolate(time, val);
const AZ::Color col = ValueToColor(val);
return col;
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::PointToTimeValue(QPoint point, float& time, ISplineInterpolator::ValueType& val)
{
time = XOfsToTime(point.x());
ColorToValue(TimeToColor(time), val);
}
//////////////////////////////////////////////////////////////////////////
float CColorGradientCtrl::XOfsToTime(int x)
{
return m_grid.ClientToWorld(QPoint(x, 0)).x;
}
//////////////////////////////////////////////////////////////////////////
QPoint CColorGradientCtrl::XOfsToPoint(int x)
{
return TimeToPoint(XOfsToTime(x));
}
//////////////////////////////////////////////////////////////////////////
AZ::Color CColorGradientCtrl::XOfsToColor(int x)
{
return TimeToColor(XOfsToTime(x));
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::paintEvent(QPaintEvent* e)
{
QPainter painter(this);
QRect rcClient = rect();
if (m_pSpline)
{
m_bSelectedKeys.resize(m_pSpline->GetKeyCount());
}
{
if (!isEnabled())
{
painter.setBrush(palette().button());
painter.drawRect(rcClient);
return;
}
//////////////////////////////////////////////////////////////////////////
// Fill keys backgound.
//////////////////////////////////////////////////////////////////////////
QRect rcKeys = m_rcKeys.intersected(e->rect());
painter.setBrush(palette().button());
painter.drawRect(rcKeys);
//////////////////////////////////////////////////////////////////////////
//Draw Keys and Curve
if (m_pSpline)
{
DrawGradient(e, &painter);
DrawKeys(e, &painter);
}
}
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::DrawGradient(QPaintEvent* e, QPainter* painter)
{
//Draw Curve
// create and select a thick, white pen
painter->setPen(QPen(QColor(128, 255, 128), 1, Qt::SolidLine));
const QRect rcClip = e->rect().intersected(m_rcGradient);
const int right = rcClip.left() + rcClip.width();
for (int x = rcClip.left(); x < right; x++)
{
const AZ::Color col = XOfsToColor(x);
QPen pen(QColor(col.GetR8(), col.GetG8(), col.GetR8(), col.GetA8()), 1, Qt::SolidLine);
painter->setPen(pen);
painter->drawLine(x, m_rcGradient.top(), x, m_rcGradient.top() + m_rcGradient.height());
}
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::DrawKeys(QPaintEvent* e, QPainter* painter)
{
if (!m_pSpline)
{
return;
}
// create and select a white pen
painter->setPen(QPen(QColor(0, 0, 0), 1, Qt::SolidLine));
QRect rcClip = e->rect();
m_bSelectedKeys.resize(m_pSpline->GetKeyCount());
for (int i = 0; i < m_pSpline->GetKeyCount(); i++)
{
float time = m_pSpline->GetKeyTime(i);
QPoint pt = TimeToPoint(time);
if (pt.x() < rcClip.left() - 8 || pt.x() > rcClip.left() + rcClip.width() + 8)
{
continue;
}
const AZ::Color clr = TimeToColor(time);
QBrush brush(QColor(clr.GetR8(), clr.GetG8(), clr.GetB8(), clr.GetA8()));
painter->setBrush(brush);
// Find the midpoints of the top, right, left, and bottom
// of the client area. They will be the vertices of our polygon.
QPoint pts[3];
pts[0].rx() = pt.x();
pts[0].ry() = m_rcKeys.top() + 1;
pts[1].rx() = pt.x() - 5;
pts[1].ry() = m_rcKeys.top() + 8;
pts[2].rx() = pt.x() + 5;
pts[2].ry() = m_rcKeys.top() + 8;
painter->drawPolygon(pts, 3);
if (m_bSelectedKeys[i])
{
QPen pen(QColor(200, 0, 0), 1, Qt::SolidLine);
QPen oldPen = painter->pen();
painter->setPen(pen);
painter->drawPolygon(pts, 3);
painter->setPen(oldPen);
}
}
if (!m_bNoTimeMarker)
{
QPen timePen(QColor(255, 0, 255), 1, Qt::SolidLine);
painter->setPen(timePen);
QPoint pt = TimeToPoint(m_fTimeMarker);
painter->drawLine(pt.x(), m_rcGradient.top() + 1, pt.x(), m_rcGradient.bottom() - 1);
}
}
void CColorGradientCtrl::UpdateTooltip(QPoint pos)
{
if (m_nHitKeyIndex >= 0)
{
float time = m_pSpline->GetKeyTime(m_nHitKeyIndex);
ISplineInterpolator::ValueType val;
m_pSpline->GetKeyValue(m_nHitKeyIndex, val);
AZ::Color col = TimeToColor(time);
int cont_s = (m_pSpline->GetKeyFlags(m_nHitKeyIndex) >> SPLINE_KEY_TANGENT_IN_SHIFT) & SPLINE_KEY_TANGENT_LINEAR ? 1 : 2;
int cont_d = (m_pSpline->GetKeyFlags(m_nHitKeyIndex) >> SPLINE_KEY_TANGENT_OUT_SHIFT) & SPLINE_KEY_TANGENT_LINEAR ? 1 : 2;
QString tipText(tr("%1 : %2,%3,%4 [%5,%6]").arg(time * m_fTooltipScaleX, 0, 'f', 2).arg(col.GetR8()).arg(col.GetG8()).arg(col.GetB8()).arg(cont_s).arg(cont_d));
const QPoint globalPos = mapToGlobal(pos);
QToolTip::showText(mapToGlobal(pos), tipText, this, QRect(globalPos, QSize(1, 1)));
}
}
/////////////////////////////////////////////////////////////////////////////
//Mouse Message Handlers
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::mousePressEvent(QMouseEvent* event)
{
if (event->button() == Qt::LeftButton)
{
OnLButtonDown(event);
}
else if (event->button() == Qt::RightButton)
{
OnRButtonDown(event);
}
}
void CColorGradientCtrl::OnLButtonDown([[maybe_unused]] QMouseEvent* event)
{
if (m_bTracking)
{
return;
}
if (!m_pSpline)
{
return;
}
setFocus();
switch (m_hitCode)
{
case HIT_KEY:
StartTracking();
SetActiveKey(m_nHitKeyIndex);
break;
/*
case HIT_SPLINE:
{
// Cycle the spline slope of the nearest key.
int flags = m_pSpline->GetKeyFlags(m_nHitKeyIndex);
if (m_nHitKeyDist < 0)
// Toggle left side.
flags ^= SPLINE_KEY_TANGENT_LINEAR << SPLINE_KEY_TANGENT_IN_SHIFT;
if (m_nHitKeyDist > 0)
// Toggle right side.
flags ^= SPLINE_KEY_TANGENT_LINEAR << SPLINE_KEY_TANGENT_OUT_SHIFT;
m_pSpline->SetKeyFlags(m_nHitKeyIndex, flags);
m_pSpline->Update();
SetActiveKey(-1);
SendNotifyEvent( CLRGRDN_CHANGE );
if (m_updateCallback)
m_updateCallback(this);
break;
}
*/
case HIT_NOTHING:
SetActiveKey(-1);
break;
}
update();
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::OnRButtonDown([[maybe_unused]] QMouseEvent* event)
{
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::mouseDoubleClickEvent(QMouseEvent* event)
{
if (!m_pSpline)
{
return;
}
if (event->button() != Qt::LeftButton)
{
return;
}
switch (m_hitCode)
{
case HIT_SPLINE:
{
int iIndex = InsertKey(event->pos());
SetActiveKey(iIndex);
EditKey(iIndex);
update();
}
break;
case HIT_KEY:
{
EditKey(m_nHitKeyIndex);
}
break;
}
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::mouseMoveEvent(QMouseEvent* event)
{
if (!m_pSpline)
{
return;
}
if (!m_bTracking)
{
switch (HitTest(event->pos()))
{
case HIT_SPLINE:
{
setCursor(CMFCUtils::LoadCursor(IDC_ARRWHITE));
} break;
case HIT_KEY:
{
setCursor(CMFCUtils::LoadCursor(IDC_ARRBLCK));
} break;
default:
break;
}
}
if (m_bTracking)
{
TrackKey(event->pos());
}
if (m_bTracking || m_nHitKeyIndex >= 0)
{
UpdateTooltip(event->pos());
}
else
{
QToolTip::hideText();
}
}
void CColorGradientCtrl::mouseReleaseEvent(QMouseEvent* event)
{
if (event->button() == Qt::LeftButton)
{
OnLButtonUp(event);
}
else if (event->button() == Qt::RightButton)
{
OnRButtonUp(event);
}
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::OnLButtonUp(QMouseEvent* event)
{
if (!m_pSpline)
{
return;
}
if (m_bTracking)
{
StopTracking(event->pos());
}
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::OnRButtonUp([[maybe_unused]] QMouseEvent* event)
{
if (!m_pSpline)
{
return;
}
}
/////////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::SetActiveKey(int nIndex)
{
ClearSelection();
//Activate New Key
if (nIndex >= 0)
{
m_bSelectedKeys[nIndex] = true;
}
m_nActiveKey = nIndex;
update();
SendNotifyEvent(CLRGRDN_ACTIVE_KEY_CHANGE);
}
/////////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::SetSpline(ISplineInterpolator* pSpline, bool bRedraw)
{
if (pSpline != m_pSpline)
{
//if (pSpline && pSpline->GetNumDimensions() != 3)
//return;
m_pSpline = pSpline;
m_nActiveKey = -1;
}
ClearSelection();
if (bRedraw)
{
update();
}
}
//////////////////////////////////////////////////////////////////////////
ISplineInterpolator* CColorGradientCtrl::GetSpline()
{
return m_pSpline;
}
/////////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::keyPressEvent(QKeyEvent* event)
{
bool bProcessed = false;
if (m_nActiveKey != -1 && m_pSpline)
{
switch (event->key())
{
case Qt::Key_Delete:
{
RemoveKey(m_nActiveKey);
bProcessed = true;
} break;
case Qt::Key_Up:
{
CUndo undo("Move Spline Key");
QPoint point = KeyToPoint(m_nActiveKey);
point.rx() -= 1;
SendNotifyEvent(CLRGRDN_BEFORE_CHANGE);
TrackKey(point);
bProcessed = true;
} break;
case Qt::Key_Down:
{
CUndo undo("Move Spline Key");
QPoint point = KeyToPoint(m_nActiveKey);
point.rx() += 1;
SendNotifyEvent(CLRGRDN_BEFORE_CHANGE);
TrackKey(point);
bProcessed = true;
} break;
case Qt::Key_Left:
{
CUndo undo("Move Spline Key");
QPoint point = KeyToPoint(m_nActiveKey);
point.rx() -= 1;
SendNotifyEvent(CLRGRDN_BEFORE_CHANGE);
TrackKey(point);
bProcessed = true;
} break;
case Qt::Key_Right:
{
CUndo undo("Move Spline Key");
QPoint point = KeyToPoint(m_nActiveKey);
point.rx() += 1;
SendNotifyEvent(CLRGRDN_BEFORE_CHANGE);
TrackKey(point);
bProcessed = true;
} break;
default:
break; //do nothing
}
update();
}
event->setAccepted(bProcessed);
}
//////////////////////////////////////////////////////////////////////////////
CColorGradientCtrl::EHitCode CColorGradientCtrl::HitTest(QPoint point)
{
if (!m_pSpline)
{
return HIT_NOTHING;
}
ISplineInterpolator::ValueType val;
float time;
PointToTimeValue(point, time, val);
QRect rc = rect();
m_nHitKeyIndex = -1;
if (rc.contains(point))
{
m_nHitKeyDist = 0xFFFF;
m_hitCode = HIT_SPLINE;
for (int i = 0; i < m_pSpline->GetKeyCount(); i++)
{
QPoint splinePt = TimeToPoint(m_pSpline->GetKeyTime(i));
if (abs(point.x() - splinePt.x()) < abs(m_nHitKeyDist))
{
m_nHitKeyIndex = i;
m_nHitKeyDist = point.x() - splinePt.x();
}
}
if (abs(m_nHitKeyDist) < 4)
{
m_hitCode = HIT_KEY;
}
}
else
{
m_hitCode = HIT_NOTHING;
}
return m_hitCode;
}
///////////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::StartTracking()
{
m_bTracking = true;
GetIEditor()->BeginUndo();
SendNotifyEvent(CLRGRDN_BEFORE_CHANGE);
setCursor(CMFCUtils::LoadCursor(IDC_ARRBLCKCROSS));
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::TrackKey(QPoint point)
{
if (point.x() < m_rcGradient.left() || point.y() > m_rcGradient.right())
{
return;
}
int nKey = m_nHitKeyIndex;
if (nKey >= 0)
{
ISplineInterpolator::ValueType val;
float time;
PointToTimeValue(point, time, val);
// Clamp to min/max time.
if (time < m_fMinTime || time > m_fMaxTime)
{
return;
}
int i;
for (i = 0; i < m_pSpline->GetKeyCount(); i++)
{
// Switch to next key.
if ((m_pSpline->GetKeyTime(i) < time && i > nKey) ||
(m_pSpline->GetKeyTime(i) > time && i < nKey))
{
m_pSpline->SetKeyTime(nKey, time);
m_pSpline->Update();
SetActiveKey(i);
m_nHitKeyIndex = i;
return;
}
}
if (!m_bLockFirstLastKey || (nKey != 0 && nKey != m_pSpline->GetKeyCount() - 1))
{
m_pSpline->SetKeyTime(nKey, time);
m_pSpline->Update();
}
SendNotifyEvent(CLRGRDN_CHANGE);
if (m_updateCallback)
{
m_updateCallback(this);
}
update();
}
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::StopTracking(QPoint point)
{
if (!m_bTracking)
{
return;
}
GetIEditor()->AcceptUndo("Spline Move");
if (m_nHitKeyIndex >= 0)
{
QRect rc = rect();
rc = rc.marginsAdded(QMargins(100, 100, 100, 100));
if (!rc.contains(point))
{
RemoveKey(m_nHitKeyIndex);
}
}
m_bTracking = false;
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::EditKey(int nKey)
{
if (!m_pSpline)
{
return;
}
if (nKey < 0 || nKey >= m_pSpline->GetKeyCount())
{
return;
}
SetActiveKey(nKey);
ISplineInterpolator::ValueType val;
m_pSpline->GetKeyValue(nKey, val);
SendNotifyEvent(CLRGRDN_BEFORE_CHANGE);
AzQtComponents::ColorPicker dlg(AzQtComponents::ColorPicker::Configuration::RGB);
dlg.setCurrentColor(ValueToColor(val));
dlg.setSelectedColor(ValueToColor(val));
connect(&dlg, &AzQtComponents::ColorPicker::currentColorChanged, this, &CColorGradientCtrl::OnKeyColorChanged);
if (dlg.exec() == QDialog::Accepted)
{
CUndo undo("Modify Gradient Color");
OnKeyColorChanged(dlg.selectedColor());
}
else
{
OnKeyColorChanged(ValueToColor(val));
}
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::OnKeyColorChanged(const AZ::Color& color)
{
int nKey = m_nActiveKey;
if (!m_pSpline)
{
return;
}
if (nKey < 0 || nKey >= m_pSpline->GetKeyCount())
{
return;
}
ISplineInterpolator::ValueType val;
ColorToValue(color, val);
m_pSpline->SetKeyValue(nKey, val);
update();
if (m_bLockFirstLastKey)
{
if (nKey == 0)
{
m_pSpline->SetKeyValue(m_pSpline->GetKeyCount() - 1, val);
}
else if (nKey == m_pSpline->GetKeyCount() - 1)
{
m_pSpline->SetKeyValue(0, val);
}
}
m_pSpline->Update();
SendNotifyEvent(CLRGRDN_CHANGE);
if (m_updateCallback)
{
m_updateCallback(this);
}
GetIEditor()->UpdateViews(eRedrawViewports);
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::RemoveKey(int nKey)
{
if (!m_pSpline)
{
return;
}
if (m_bLockFirstLastKey)
{
if (nKey == 0 || nKey == m_pSpline->GetKeyCount() - 1)
{
return;
}
}
CUndo undo("Remove Spline Key");
SendNotifyEvent(CLRGRDN_BEFORE_CHANGE);
m_nActiveKey = -1;
m_nHitKeyIndex = -1;
if (m_pSpline)
{
m_pSpline->RemoveKey(nKey);
m_pSpline->Update();
}
SendNotifyEvent(CLRGRDN_CHANGE);
if (m_updateCallback)
{
m_updateCallback(this);
}
update();
}
//////////////////////////////////////////////////////////////////////////
int CColorGradientCtrl::InsertKey(QPoint point)
{
CUndo undo("Spline Insert Key");
ISplineInterpolator::ValueType val;
float time;
PointToTimeValue(point, time, val);
if (time < m_fMinTime || time > m_fMaxTime)
{
return -1;
}
int i;
for (i = 0; i < m_pSpline->GetKeyCount(); i++)
{
// Skip if any key already have time that is very close.
if (fabs(m_pSpline->GetKeyTime(i) - time) < MIN_TIME_EPSILON)
{
return i;
}
}
SendNotifyEvent(CLRGRDN_BEFORE_CHANGE);
m_pSpline->InsertKey(time, val);
m_pSpline->Interpolate(time, val);
ClearSelection();
update();
SendNotifyEvent(CLRGRDN_CHANGE);
if (m_updateCallback)
{
m_updateCallback(this);
}
for (i = 0; i < m_pSpline->GetKeyCount(); i++)
{
// Find key with added time.
if (m_pSpline->GetKeyTime(i) == time)
{
return i;
}
}
return -1;
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::ClearSelection()
{
m_nActiveKey = -1;
if (m_pSpline)
{
m_bSelectedKeys.resize(m_pSpline->GetKeyCount());
}
for (int i = 0; i < (int)m_bSelectedKeys.size(); i++)
{
m_bSelectedKeys[i] = false;
}
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::SetTimeMarker(float fTime)
{
if (!m_pSpline)
{
return;
}
{
QPoint pt = TimeToPoint(m_fTimeMarker);
QRect rc = QRect(pt.x(), m_rcGradient.top(), 0, m_rcGradient.bottom() - m_rcGradient.top()).normalized();
rc += QMargins(1, 0, 1, 0);
update(rc);
}
{
QPoint pt = TimeToPoint(fTime);
QRect rc = QRect(pt.x(), m_rcGradient.top(), 0, m_rcGradient.bottom() - m_rcGradient.top()).normalized();
rc += QMargins(1, 0, 1, 0);
update(rc);
}
m_fTimeMarker = fTime;
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::SendNotifyEvent(int nEvent)
{
switch (nEvent)
{
case CLRGRDN_BEFORE_CHANGE:
emit beforeChange();
break;
case CLRGRDN_CHANGE:
emit change();
break;
case CLRGRDN_ACTIVE_KEY_CHANGE:
emit activeKeyChange();
break;
}
}
//////////////////////////////////////////////////////////////////////////
AZ::Color CColorGradientCtrl::ValueToColor(ISplineInterpolator::ValueType val)
{
const AZ::Color color(val[0], val[1], val[2], 1.0);
return color.LinearToGamma();
}
//////////////////////////////////////////////////////////////////////////
void CColorGradientCtrl::ColorToValue(const AZ::Color& col, ISplineInterpolator::ValueType& val)
{
const AZ::Color colLin = col.GammaToLinear();
val[0] = colLin.GetR();
val[1] = colLin.GetG();
val[2] = colLin.GetB();
val[3] = 0;
}
void CColorGradientCtrl::SetNoTimeMarker(bool noTimeMarker)
{
m_bNoTimeMarker = noTimeMarker;
update();
}
#include <Controls/moc_ColorGradientCtrl.cpp>
-167
View File
@@ -1,167 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_CONTROLS_COLORGRADIENTCTRL_H
#define CRYINCLUDE_EDITOR_CONTROLS_COLORGRADIENTCTRL_H
#pragma once
#if !defined(Q_MOC_RUN)
#include <QWidget>
#include <ISplines.h>
#include "Controls/WndGridHelper.h"
#endif
namespace AZ
{
class Color;
}
// Notify event sent when spline is being modified.
#define CLRGRDN_CHANGE (0x0001)
// Notify event sent just before when spline is modified.
#define CLRGRDN_BEFORE_CHANGE (0x0002)
// Notify event sent when the active key changes
#define CLRGRDN_ACTIVE_KEY_CHANGE (0x0003)
//////////////////////////////////////////////////////////////////////////
// Spline control.
//////////////////////////////////////////////////////////////////////////
class CColorGradientCtrl
: public QWidget
{
Q_OBJECT
public:
CColorGradientCtrl(QWidget* parent = nullptr);
virtual ~CColorGradientCtrl();
//Key functions
int GetActiveKey() { return m_nActiveKey; };
void SetActiveKey(int nIndex);
int InsertKey(QPoint point);
// Turns on/off zooming and scroll support.
void SetNoZoom([[maybe_unused]] bool bNoZoom) { m_bNoZoom = false; };
void SetTimeRange(float tmin, float tmax) { m_fMinTime = tmin; m_fMaxTime = tmax; }
void SetValueRange(float tmin, float tmax) { m_fMinValue = tmin; m_fMaxValue = tmax; }
void SetTooltipValueScale(float x, float y) { m_fTooltipScaleX = x; m_fTooltipScaleY = y; };
// Lock value of first and last key to be the same.
void LockFirstAndLastKeys(bool bLock) { m_bLockFirstLastKey = bLock; }
void SetSpline(ISplineInterpolator* pSpline, bool bRedraw = false);
ISplineInterpolator* GetSpline();
void SetTimeMarker(float fTime);
// Zoom in pixels per time unit.
void SetZoom(float fZoom);
void SetOrigin(float fOffset);
typedef AZStd::function<void(CColorGradientCtrl*)> UpdateCallback;
void SetUpdateCallback(const UpdateCallback& cb) { m_updateCallback = cb; };
void SetNoTimeMarker(bool noTimeMarker);
signals:
void change();
void beforeChange();
void activeKeyChange();
protected:
enum EHitCode
{
HIT_NOTHING,
HIT_KEY,
HIT_SPLINE,
};
void paintEvent(QPaintEvent* e) override;
void resizeEvent(QResizeEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
void OnLButtonDown(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event) override;
void OnLButtonUp(QMouseEvent* event);
void OnRButtonUp(QMouseEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event) override;
void OnRButtonDown(QMouseEvent* event);
void keyPressEvent(QKeyEvent* event) override;
// Drawing functions
void DrawGradient(QPaintEvent* e, QPainter* painter);
void DrawKeys(QPaintEvent* e, QPainter* painter);
void UpdateTooltip(QPoint pos);
EHitCode HitTest(QPoint point);
//Tracking support helper functions
void StartTracking();
void TrackKey(QPoint point);
void StopTracking(QPoint point);
void RemoveKey(int nKey);
void EditKey(int nKey);
QPoint KeyToPoint(int nKey);
QPoint TimeToPoint(float time);
void PointToTimeValue(QPoint point, float& time, ISplineInterpolator::ValueType& val);
float XOfsToTime(int x);
QPoint XOfsToPoint(int x);
AZ::Color XOfsToColor(int x);
AZ::Color TimeToColor(float time);
void ClearSelection();
void SendNotifyEvent(int nEvent);
AZ::Color ValueToColor(ISplineInterpolator::ValueType val);
void ColorToValue(const AZ::Color& col, ISplineInterpolator::ValueType& val);
private:
void OnKeyColorChanged(const AZ::Color& color);
private:
ISplineInterpolator* m_pSpline;
bool m_bNoZoom;
QRect m_rcClipRect;
QRect m_rcGradient;
QRect m_rcKeys;
QPoint m_hitPoint;
EHitCode m_hitCode;
int m_nHitKeyIndex;
int m_nHitKeyDist;
QPoint m_curvePoint;
float m_fTimeMarker;
int m_nActiveKey;
int m_nKeyDrawRadius;
bool m_bTracking;
float m_fMinTime, m_fMaxTime;
float m_fMinValue, m_fMaxValue;
float m_fTooltipScaleX, m_fTooltipScaleY;
bool m_bLockFirstLastKey;
bool m_bNoTimeMarker;
std::vector<int> m_bSelectedKeys;
UpdateCallback m_updateCallback;
CWndGridHelper m_grid;
};
#endif // CRYINCLUDE_EDITOR_CONTROLS_COLORGRADIENTCTRL_H
-111
View File
@@ -1,111 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_CONTROLS_CONSOLESCBMFC_H
#define CRYINCLUDE_EDITOR_CONTROLS_CONSOLESCBMFC_H
#pragma once
#if !defined(Q_MOC_RUN)
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QTextEdit>
#include <QtWidgets/QPushButton>
#include "ConsoleSCB.h"
#endif
class QMenu;
class ConsoleWidget;
class QFocusEvent;
namespace Ui {
class ConsoleMFC;
}
namespace MFC
{
struct ConsoleLine
{
QString text;
bool newLine;
};
typedef std::deque<ConsoleLine> Lines;
class ConsoleLineEdit
: public QLineEdit
{
Q_OBJECT
public:
explicit ConsoleLineEdit(QWidget* parent = nullptr);
protected:
void mousePressEvent(QMouseEvent* ev) override;
void mouseDoubleClickEvent(QMouseEvent* ev) override;
void keyPressEvent(QKeyEvent* ev) override;
bool event(QEvent* ev) override;
signals:
void variableEditorRequested();
void setWindowTitle(const QString&);
private:
void DisplayHistory(bool bForward);
QStringList m_history;
unsigned int m_historyIndex;
bool m_bReusedHistory;
};
class ConsoleTextEdit
: public QTextEdit
{
Q_OBJECT
public:
explicit ConsoleTextEdit(QWidget* parent = nullptr);
};
class CConsoleSCB
: public QWidget
{
Q_OBJECT
public:
explicit CConsoleSCB(QWidget* parent = nullptr);
~CConsoleSCB();
static void RegisterViewClass();
void SetInputFocus();
void AddToConsole(const QString& text, bool bNewLine);
void FlushText();
void showPopupAndSetTitle();
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
static CConsoleSCB* GetCreatedInstance();
static void AddToPendingLines(const QString& text, bool bNewLine); // call this function instead of AddToConsole() until an instance of CConsoleSCB exists to prevent messages from getting lost
public Q_SLOTS:
void OnStyleSettingsChanged();
private Q_SLOTS:
void showVariableEditor();
private:
QScopedPointer<Ui::ConsoleMFC> ui;
int m_richEditTextLength;
Lines m_lines;
static Lines s_pendingLines;
QList<QColor> m_colorTable;
SEditorSettings::ConsoleColorTheme m_backgroundTheme;
};
} // namespace MFC
#endif // CRYINCLUDE_EDITOR_CONTROLS_CONSOLESCB_H
-132
View File
@@ -1,132 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ConsoleMFC</class>
<widget class="QWidget" name="Console">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>120</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Console</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QTextEdit" name="textEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="container2" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="button">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>30</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="MFC::ConsoleLineEdit" name="lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>MFC::ConsoleLineEdit</class>
<extends>QLineEdit</extends>
<header>ConsoleSCBMFC.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="ConsoleSCB.qrc"/>
</resources>
<connections/>
</ui>
+6 -7
View File
@@ -278,17 +278,16 @@ void CFolderTreeCtrl::LoadTreeRec(const QString& currentFolder)
void CFolderTreeCtrl::AddItem(const QString& path)
{
QString folder;
QString fileNameWithoutExtension;
QString ext;
Path::Split(path, folder, fileNameWithoutExtension, ext);
AZ::IO::FixedMaxPath folder{ AZ::IO::PathView(path.toUtf8().constData()) };
AZ::IO::FixedMaxPath fileNameWithoutExtension = folder.Stem();
folder = folder.ParentPath();
auto regex = QRegExp(m_fileNameSpec, Qt::CaseInsensitive, QRegExp::Wildcard);
if (regex.exactMatch(path))
{
CTreeItem* folderTreeItem = CreateFolderItems(folder);
folderTreeItem->AddChild(fileNameWithoutExtension, path, eTreeImage_File);
CTreeItem* folderTreeItem = CreateFolderItems(QString::fromUtf8(folder.c_str(), static_cast<int>(folder.Native().size())));
folderTreeItem->AddChild(QString::fromUtf8(fileNameWithoutExtension.c_str(),
static_cast<int>(fileNameWithoutExtension.Native().size())), path, eTreeImage_File);
}
}
@@ -1,48 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "HotTrackingTreeCtrl.h"
// Qt
#include <QMouseEvent>
CHotTrackingTreeCtrl::CHotTrackingTreeCtrl(QWidget* parent)
: QTreeWidget(parent)
{
setMouseTracking(true);
m_hHoverItem = nullptr;
}
void CHotTrackingTreeCtrl::mouseMoveEvent(QMouseEvent* event)
{
QTreeWidgetItem* hItem = itemAt(event->pos());
if (m_hHoverItem != nullptr)
{
QFont font = m_hHoverItem->font(0);
font.setBold(false);
m_hHoverItem->setFont(0, font);
m_hHoverItem = nullptr;
}
if (hItem != nullptr)
{
QFont font = hItem->font(0);
font.setBold(true);
hItem->setFont(0, font);
m_hHoverItem = hItem;
}
QTreeWidget::mouseMoveEvent(event);
}
#include <Controls/moc_HotTrackingTreeCtrl.cpp>
@@ -1,33 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_CONTROLS_HOTTRACKINGTREECTRL_H
#define CRYINCLUDE_EDITOR_CONTROLS_HOTTRACKINGTREECTRL_H
#pragma once
#if !defined(Q_MOC_RUN)
#include <QTreeWidget>
#endif
class CHotTrackingTreeCtrl
: public QTreeWidget
{
Q_OBJECT
public:
CHotTrackingTreeCtrl(QWidget* parent = 0);
virtual ~CHotTrackingTreeCtrl(){};
protected:
void mouseMoveEvent(QMouseEvent* event) override;
private:
QTreeWidgetItem* m_hHoverItem;
};
#endif // CRYINCLUDE_EDITOR_CONTROLS_HOTTRACKINGTREECTRL_H
-567
View File
@@ -1,567 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "ImageListCtrl.h"
// Qt
#include <QPainter>
#include <QScrollBar>
//////////////////////////////////////////////////////////////////////////
CImageListCtrl::CImageListCtrl(QWidget* parent)
: QAbstractItemView(parent)
, m_itemSize(60, 60)
, m_borderSize(4, 4)
, m_style(DefaultStyle)
{
setItemDelegate(new QImageListDelegate(this));
setAutoFillBackground(false);
QPalette p = palette();
p.setColor(QPalette::Highlight, QColor(255, 55, 50));
setPalette(p);
horizontalScrollBar()->setRange(0, 0);
verticalScrollBar()->setRange(0, 0);
}
//////////////////////////////////////////////////////////////////////////
CImageListCtrl::~CImageListCtrl()
{
}
//////////////////////////////////////////////////////////////////////////
CImageListCtrl::ListStyle CImageListCtrl::Style() const
{
return m_style;
}
//////////////////////////////////////////////////////////////////////////
void CImageListCtrl::SetStyle(ListStyle style)
{
m_style = style;
scheduleDelayedItemsLayout();
}
//////////////////////////////////////////////////////////////////////////
const QSize& CImageListCtrl::ItemSize() const
{
return m_itemSize;
}
//////////////////////////////////////////////////////////////////////////
void CImageListCtrl::SetItemSize(QSize size)
{
Q_ASSERT(size.isValid());
m_itemSize = size;
scheduleDelayedItemsLayout();
}
//////////////////////////////////////////////////////////////////////////
const QSize& CImageListCtrl::BorderSize() const
{
return m_borderSize;
}
//////////////////////////////////////////////////////////////////////////
void CImageListCtrl::SetBorderSize(QSize size)
{
Q_ASSERT(size.isValid());
m_borderSize = size;
scheduleDelayedItemsLayout();
}
//////////////////////////////////////////////////////////////////////////
QModelIndexList CImageListCtrl::ItemsInRect(const QRect& rect) const
{
QModelIndexList list;
if (!model())
{
return list;
}
QHash<int, QRect>::const_iterator i;
QHash<int, QRect>::const_iterator c = m_geometry.cend();
for (i = m_geometry.cbegin(); i != c; ++i)
{
if (i.value().intersects(rect))
{
list << model()->index(i.key(), 0, rootIndex());
}
}
return list;
}
//////////////////////////////////////////////////////////////////////////
void CImageListCtrl::paintEvent(QPaintEvent* event)
{
QAbstractItemView::paintEvent(event);
if (!model())
{
return;
}
const int rowCount = model()->rowCount();
if (m_geometry.isEmpty() && rowCount)
{
updateGeometries();
}
QPainter painter(viewport());
painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
painter.setBackground(palette().window());
painter.setFont(font());
QStyleOptionViewItem option;
option.palette = palette();
option.font = font();
option.fontMetrics = fontMetrics();
option.decorationAlignment = Qt::AlignCenter;
const QRect visibleRect(QPoint(horizontalOffset(), verticalOffset()), viewport()->contentsRect().size());
painter.translate(-horizontalOffset(), -verticalOffset());
for (int r = 0; r < rowCount; ++r)
{
const QModelIndex& index = model()->index(r, 0, rootIndex());
option.rect = m_geometry.value(r);
if (!option.rect.intersects(visibleRect))
{
continue;
}
option.state = QStyle::State_None;
if (selectionModel()->isSelected(index))
{
option.state |= QStyle::State_Selected;
}
if (currentIndex() == index)
{
option.state |= QStyle::State_HasFocus;
}
QAbstractItemDelegate* idt = itemDelegate(index);
idt->paint(&painter, option, index);
}
}
//////////////////////////////////////////////////////////////////////////
void CImageListCtrl::rowsInserted(const QModelIndex& parent, int start, int end)
{
QAbstractItemView::rowsInserted(parent, start, end);
if (isVisible())
{
scheduleDelayedItemsLayout();
}
}
//////////////////////////////////////////////////////////////////////////
void CImageListCtrl::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;
}
int x = m_borderSize.width();
int y = m_borderSize.height();
const int nItemWidth = m_itemSize.width() + m_borderSize.width();
if (m_style == HorizontalStyle)
{
for (int row = 0; row < rowCount; ++row)
{
m_geometry.insert(row, QRect(QPoint(x, y), m_itemSize));
x += nItemWidth;
}
horizontalScrollBar()->setPageStep(viewport()->width());
horizontalScrollBar()->setRange(0, x - viewport()->width());
}
else
{
const int nTextHeight = fontMetrics().height();
const int nItemHeight = m_itemSize.height() + m_borderSize.height() + nTextHeight;
int nNumOfHorzItems = nPageHorz / nItemWidth;
if (nNumOfHorzItems <= 0)
{
nNumOfHorzItems = 1;
}
for (int row = 0; row < rowCount; ++row)
{
m_geometry.insert(row, QRect(QPoint(x, y), m_itemSize));
if ((row + 1) % nNumOfHorzItems == 0)
{
y += nItemHeight;
x = m_borderSize.width();
}
else
{
x += nItemWidth;
}
}
verticalScrollBar()->setPageStep(viewport()->height());
verticalScrollBar()->setRange(0, (y + nItemHeight) - viewport()->height());
}
}
//////////////////////////////////////////////////////////////////////////
QModelIndex CImageListCtrl::indexAt(const QPoint& point) const
{
if (!model())
{
return QModelIndex();
}
const QPoint p = point +
QPoint(horizontalOffset(), verticalOffset());
QHash<int, QRect>::const_iterator i;
QHash<int, QRect>::const_iterator c = m_geometry.cend();
for (i = m_geometry.cbegin(); i != c; ++i)
{
if (i.value().contains(p))
{
return model()->index(i.key(), 0, rootIndex());
}
}
return QModelIndex();
}
//////////////////////////////////////////////////////////////////////////
void CImageListCtrl::scrollTo(const QModelIndex& index, ScrollHint hint)
{
if (!index.isValid())
{
return;
}
QRect rect = m_geometry.value(index.row());
switch (hint)
{
case EnsureVisible:
if (horizontalOffset() > rect.right())
{
horizontalScrollBar()->setValue(rect.left());
}
else if ((horizontalOffset() + viewport()->width()) < rect.left())
{
horizontalScrollBar()->setValue(rect.right() - viewport()->width());
}
if (verticalOffset() > rect.bottom())
{
verticalScrollBar()->setValue(rect.top());
}
else if ((verticalOffset() + viewport()->height()) < rect.top())
{
verticalScrollBar()->setValue(rect.bottom() - viewport()->height());
}
break;
case PositionAtTop:
horizontalScrollBar()->setValue(rect.left());
verticalScrollBar()->setValue(rect.top());
break;
case PositionAtBottom:
horizontalScrollBar()->setValue(rect.right() - viewport()->width());
verticalScrollBar()->setValue(rect.bottom() - viewport()->height());
break;
case PositionAtCenter:
horizontalScrollBar()->setValue(rect.center().x() - (viewport()->width() / 2));
verticalScrollBar()->setValue(rect.center().y() - (viewport()->height() / 2));
break;
}
}
//////////////////////////////////////////////////////////////////////////
QRect CImageListCtrl::visualRect(const QModelIndex& index) const
{
if (!index.isValid())
{
return QRect();
}
if (!m_geometry.contains(index.row()))
{
return QRect();
}
return m_geometry.value(index.row())
.translated(-horizontalOffset(), -verticalOffset());
}
//////////////////////////////////////////////////////////////////////////
QRect CImageListCtrl::ItemGeometry(const QModelIndex& index) const
{
Q_ASSERT(index.model() == model());
Q_ASSERT(m_geometry.contains(index.row()));
return m_geometry.value(index.row());
}
void CImageListCtrl::SetItemGeometry(const QModelIndex& index, const QRect& rect)
{
Q_ASSERT(index.model() == model());
m_geometry.insert(index.row(), rect);
update(rect);
}
void CImageListCtrl::ClearItemGeometries()
{
m_geometry.clear();
}
//////////////////////////////////////////////////////////////////////////
int CImageListCtrl::horizontalOffset() const
{
return horizontalScrollBar()->value();
}
//////////////////////////////////////////////////////////////////////////
int CImageListCtrl::verticalOffset() const
{
return verticalScrollBar()->value();
}
//////////////////////////////////////////////////////////////////////////
bool CImageListCtrl::isIndexHidden([[maybe_unused]] const QModelIndex& index) const
{
return false; /* not supported */
}
//////////////////////////////////////////////////////////////////////////
QModelIndex CImageListCtrl::moveCursor(CursorAction cursorAction, [[maybe_unused]] Qt::KeyboardModifiers modifiers)
{
if (!model())
{
return QModelIndex();
}
const int rowCount = model()->rowCount();
if (0 == rowCount)
{
return QModelIndex();
}
switch (cursorAction)
{
case MoveHome:
return model()->index(0, 0, rootIndex());
case MoveEnd:
return model()->index(rowCount - 1, 0, rootIndex());
case MovePrevious:
{
QModelIndex current = currentIndex();
if (current.isValid())
{
return model()->index((current.row() - 1) % rowCount, 0, rootIndex());
}
} break;
case MoveNext:
{
QModelIndex current = currentIndex();
if (current.isValid())
{
return model()->index((current.row() + 1) % rowCount, 0, rootIndex());
}
} break;
case MoveUp:
case MoveDown:
case MoveLeft:
case MoveRight:
case MovePageUp:
case MovePageDown:
/* TODO */
break;
}
return QModelIndex();
}
//////////////////////////////////////////////////////////////////////////
void CImageListCtrl::setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags flags)
{
if (!model())
{
return;
}
const QRect lrect =
rect.translated(horizontalOffset(), verticalOffset());
QHash<int, QRect>::const_iterator i;
QHash<int, QRect>::const_iterator c = m_geometry.cend();
for (i = m_geometry.cbegin(); i != c; ++i)
{
if (i.value().intersects(lrect))
{
selectionModel()->select(model()->index(i.key(), 0, rootIndex()), flags);
}
}
}
//////////////////////////////////////////////////////////////////////////
QRegion CImageListCtrl::visualRegionForSelection(const QItemSelection& selection) const
{
QRegion region;
foreach(const QModelIndex &index, selection.indexes())
{
region += visualRect(index);
}
return region;
}
//////////////////////////////////////////////////////////////////////////
QImageListDelegate::QImageListDelegate(QObject* parent)
: QAbstractItemDelegate(parent)
{
}
//////////////////////////////////////////////////////////////////////////
void QImageListDelegate::paint(QPainter* painter,
const QStyleOptionViewItem& option, const QModelIndex& index) const
{
painter->save();
painter->setFont(option.font);
if (option.rect.isValid())
{
painter->setClipRect(option.rect);
}
QRect innerRect = option.rect.adjusted(1, 1, -1, -1);
QRect textRect(innerRect.left(), innerRect.bottom() - option.fontMetrics.height(),
innerRect.width(), option.fontMetrics.height() + 1);
/* fill item background */
painter->fillRect(option.rect, option.palette.color(QPalette::Base));
/* draw image */
if (index.data(Qt::DecorationRole).isValid())
{
const QPixmap& p = index.data(Qt::DecorationRole).value<QPixmap>();
if (p.isNull() || p.size() == QSize(1, 1))
{
emit InvalidPixmapGenerated(index);
}
else
{
painter->drawPixmap(innerRect, p);
}
}
/* draw text */
const QColor trColor = option.palette.color(QPalette::Shadow);
painter->fillRect(textRect, (option.state & QStyle::State_Selected) ?
trColor.lighter() : trColor);
if (option.state & QStyle::State_Selected)
{
painter->setPen(QPen(option.palette.color(QPalette::HighlightedText)));
QFont f = painter->font();
f.setBold(true);
painter->setFont(f);
}
else
{
painter->setPen(QPen(option.palette.color(QPalette::Text)));
}
painter->drawText(textRect, index.data(Qt::DisplayRole).toString(),
QTextOption(option.decorationAlignment));
painter->setPen(QPen(option.palette.color(QPalette::Shadow)));
painter->drawRect(textRect);
/* draw border */
if (option.state & QStyle::State_Selected)
{
QPen pen(option.palette.color(QPalette::Highlight));
pen.setWidth(2);
painter->setPen(pen);
painter->drawRect(innerRect);
}
else
{
painter->setPen(QPen(option.palette.color(QPalette::Shadow)));
painter->drawRect(option.rect);
}
if (option.state & QStyle::State_HasFocus)
{
QPen pen(Qt::DotLine);
pen.setColor(option.palette.color(QPalette::AlternateBase));
painter->setPen(pen);
painter->drawRect(option.rect);
}
painter->restore();
}
//////////////////////////////////////////////////////////////////////////
QSize QImageListDelegate::sizeHint(const QStyleOptionViewItem& option,
[[maybe_unused]] const QModelIndex& index) const
{
return option.rect.size();
}
//////////////////////////////////////////////////////////////////////////
QVector<int> QImageListDelegate::paintingRoles() const
{
return QVector<int>() << Qt::DecorationRole << Qt::DisplayRole;
}
#include <Controls/moc_ImageListCtrl.cpp>
-97
View File
@@ -1,97 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_CONTROLS_IMAGELISTCTRL_H
#define CRYINCLUDE_EDITOR_CONTROLS_IMAGELISTCTRL_H
#pragma once
#if !defined(Q_MOC_RUN)
#include <QAbstractItemView>
#include <QHash>
#endif
//////////////////////////////////////////////////////////////////////////
// Custom control to display list of images.
//////////////////////////////////////////////////////////////////////////
class CImageListCtrl
: public QAbstractItemView
{
Q_OBJECT
public:
enum ListStyle
{
DefaultStyle,
HorizontalStyle
};
public:
CImageListCtrl(QWidget* parent = nullptr);
~CImageListCtrl();
ListStyle Style() const;
void SetStyle(ListStyle style);
const QSize& ItemSize() const;
void SetItemSize(QSize size);
const QSize& BorderSize() const;
void SetBorderSize(QSize size);
// Get all items inside specified rectangle.
QModelIndexList ItemsInRect(const QRect& rect) const;
QModelIndex indexAt(const QPoint& point) const override;
void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible) override;
QRect visualRect(const QModelIndex& index) const override;
protected:
QRect ItemGeometry(const QModelIndex& index) const;
void SetItemGeometry(const QModelIndex& index, const QRect& rect);
void ClearItemGeometries();
int horizontalOffset() const override;
int verticalOffset() const override;
bool isIndexHidden(const QModelIndex& index) const override;
QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags flags) override;
QRegion visualRegionForSelection(const QItemSelection& selection) const override;
void paintEvent(QPaintEvent* event) override;
void rowsInserted(const QModelIndex& parent, int start, int end) override;
void updateGeometries() override;
private:
QHash<int, QRect> m_geometry;
QSize m_itemSize;
QSize m_borderSize;
ListStyle m_style;
};
class QImageListDelegate
: public QAbstractItemDelegate
{
Q_OBJECT
signals:
void InvalidPixmapGenerated(const QModelIndex& index) const;
public:
QImageListDelegate(QObject* parent = nullptr);
void paint(QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index) const override;
QSize sizeHint(const QStyleOptionViewItem& option,
const QModelIndex& index) const override;
QVector<int> paintingRoles() const override;
};
#endif // CRYINCLUDE_EDITOR_CONTROLS_IMAGELISTCTRL_H
-67
View File
@@ -1,67 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "MultiMonHelper.h"
// Qt
#include <QScreen>
////////////////////////////////////////////////////////////////////////////
void ClipOrCenterRectToMonitor(QRect *prc, const UINT flags)
{
const QScreen* currentScreen = nullptr;
QRect rc;
Q_ASSERT(prc);
const auto screens = qApp->screens();
for (auto screen : screens)
{
if (screen->geometry().contains(prc->center()))
{
currentScreen = screen;
break;
}
}
if (!currentScreen)
{
return;
}
const int w = prc->width();
const int h = prc->height();
if (flags & MONITOR_WORKAREA)
{
rc = currentScreen->availableGeometry();
}
else
{
rc = currentScreen->geometry();
}
// center or clip the passed rect to the monitor rect
if (flags & MONITOR_CENTER)
{
prc->setLeft(rc.left() + (rc.right() - rc.left() - w) / 2);
prc->setTop(rc.top() + (rc.bottom() - rc.top() - h) / 2);
prc->setRight(prc->left() + w);
prc->setBottom(prc->top() + h);
}
else
{
prc->setLeft(qMax(rc.left(), qMin(rc.right() - w, prc->left())));
prc->setTop(qMax(rc.top(), qMin(rc.bottom() - h, prc->top())));
prc->setRight(prc->left() + w);
prc->setBottom(prc->top() + h);
}
}
-44
View File
@@ -1,44 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_CONTROLS_MULTIMONHELPER_H
#define CRYINCLUDE_EDITOR_CONTROLS_MULTIMONHELPER_H
#pragma once
// Taken from: http://msdn.microsoft.com/en-us/library/dd162826(v=vs.85).aspx
#define MONITOR_CENTER 0x0001 // center rect to monitor
#define MONITOR_CLIP 0x0000 // clip rect to monitor
#define MONITOR_WORKAREA 0x0002 // use monitor work area
#define MONITOR_AREA 0x0000 // use monitor entire area
//
// ClipOrCenterRectToMonitor
//
// The most common problem apps have when running on a
// multimonitor system is that they "clip" or "pin" windows
// based on the SM_CXSCREEN and SM_CYSCREEN system metrics.
// Because of app compatibility reasons these system metrics
// return the size of the primary monitor.
//
// This shows how you use the multi-monitor functions
// to do the same thing.
//
// params:
// prc : pointer to QRect to modify
// flags : some combination of the MONITOR_* flags above
//
// example:
//
// ClipOrCenterRectToMonitor(&aRect, MONITOR_CLIP | MONITOR_WORKAREA);
//
// Takes parameter pointer to RECT "aRect" and flags MONITOR_CLIP | MONITOR_WORKAREA
// This will modify aRect without resizing it so that it remains within the on-screen boundaries.
void ClipOrCenterRectToMonitor(QRect *prc, const UINT flags);
#endif // CRYINCLUDE_EDITOR_CONTROLS_MULTIMONHELPER_H
-143
View File
@@ -1,143 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "NumberCtrl.h"
QNumberCtrl::QNumberCtrl(QWidget* parent)
: QDoubleSpinBox(parent)
, m_bMouseDown(false)
, m_bDragged(false)
, m_bUndoEnabled(false)
, m_prevValue(0)
{
connect(this, &QAbstractSpinBox::editingFinished, this, &QNumberCtrl::onEditingFinished);
}
void QNumberCtrl::changeEvent(QEvent* event)
{
if (event->type() == QEvent::EnabledChange)
{
setButtonSymbols(isEnabled() ? UpDownArrows : NoButtons);
}
QDoubleSpinBox::changeEvent(event);
}
void QNumberCtrl::SetRange(double newMin, double newMax)
{
// Avoid setting this value if its close to the current value, because otherwise qt will pump events into the queue to redraw/etc.
if ( (!AZ::IsClose(this->minimum(), newMin, DBL_EPSILON)) || (!AZ::IsClose(this->maximum(), newMax, DBL_EPSILON)) )
{
setRange(newMin, newMax);
}
}
void QNumberCtrl::mousePressEvent(QMouseEvent* event)
{
if (event->button() == Qt::LeftButton)
{
emit mousePressed();
m_bMouseDown = true;
m_bDragged = false;
m_mousePos = event->pos();
if (m_bUndoEnabled && !CUndo::IsRecording())
{
GetIEditor()->BeginUndo();
}
emit dragStarted();
grabMouse();
}
QDoubleSpinBox::mousePressEvent(event);
}
void QNumberCtrl::mouseReleaseEvent(QMouseEvent* event)
{
QDoubleSpinBox::mouseReleaseEvent(event);
if (event->button() == Qt::LeftButton)
{
m_bMouseDown = m_bDragged = false;
emit valueUpdated();
emit valueChanged();
if (m_bUndoEnabled && CUndo::IsRecording())
{
GetIEditor()->AcceptUndo(m_undoText);
}
emit dragFinished();
releaseMouse();
m_prevValue = value();
emit mouseReleased();
}
}
void QNumberCtrl::mouseMoveEvent(QMouseEvent* event)
{
QDoubleSpinBox::mousePressEvent(event);
if (m_bMouseDown)
{
m_bDragged = true;
int dy = event->pos().y() - m_mousePos.y();
setValue(value() - singleStep() * dy);
emit valueUpdated();
m_mousePos = event->pos();
}
}
void QNumberCtrl::EnableUndo(const QString& undoText)
{
m_undoText = undoText;
m_bUndoEnabled = true;
}
void QNumberCtrl::focusInEvent(QFocusEvent* event)
{
m_prevValue = value();
QDoubleSpinBox::focusInEvent(event);
}
void QNumberCtrl::onEditingFinished()
{
bool undo = m_bUndoEnabled && !CUndo::IsRecording() && m_prevValue != value();
if (undo)
{
GetIEditor()->BeginUndo();
}
emit valueUpdated();
emit valueChanged();
if (undo)
{
GetIEditor()->AcceptUndo(m_undoText);
}
m_prevValue = value();
}
#include <Controls/moc_NumberCtrl.cpp>
-64
View File
@@ -1,64 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_CONTROLS_NUMBERCTRL_H
#define CRYINCLUDE_EDITOR_CONTROLS_NUMBERCTRL_H
#pragma once
// NumberCtrl.h : header file
//
#if !defined(Q_MOC_RUN)
#include <QDoubleSpinBox>
#endif
class QNumberCtrl
: public QDoubleSpinBox
{
Q_OBJECT
public:
QNumberCtrl(QWidget* parent = nullptr);
bool IsDragging() const { return m_bDragged; }
//! If called will enable undo with given text when control is modified.
void EnableUndo(const QString& undoText);
void SetRange(double newMin, double maxRange);
Q_SIGNALS:
void dragStarted();
void dragFinished();
void valueUpdated();
void valueChanged();
void mouseReleased();
void mousePressed();
protected:
void changeEvent(QEvent* event) override;
void focusInEvent(QFocusEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
private:
void onEditingFinished();
void onValueChanged(double d);
bool m_bMouseDown;
bool m_bDragged;
QPoint m_mousePos;
bool m_bUndoEnabled;
double m_prevValue;
QString m_undoText;
};
#endif // CRYINCLUDE_EDITOR_CONTROLS_NUMBERCTRL_H
@@ -27,7 +27,6 @@ void RegisterReflectedVarHandlers()
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 ColorCurveHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew FloatCurveHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew MotionPropertyWidgetHandler());
}
@@ -24,7 +24,6 @@
// Editor
#include "SelectLightAnimationDialog.h"
#include "SelectSequenceDialog.h"
#include "SelectEAXPresetDlg.h"
#include "QtViewPaneManager.h"
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
@@ -170,30 +170,3 @@ bool FloatCurveHandler::ReadValuesIntoGUI([[maybe_unused]] size_t index, CSpline
GUI->SetSpline(reinterpret_cast<ISplineInterpolator*>(instance.m_spline));
return false;
}
QWidget* ColorCurveHandler::CreateGUI(QWidget *pParent)
{
CColorGradientCtrl* gradientCtrl = new CColorGradientCtrl(pParent);
//connect(gradientCtrl, &CColorGradientCtrl::change, [gradientCtrl]()
//{
// EBUS_EVENT(AzToolsFramework::PropertyEditorGUIMessages::Bus, RequestWrite, gradientCtrl);
//});
gradientCtrl->SetTimeRange(0, 1);
gradientCtrl->setFixedHeight(36);
return gradientCtrl;
}
void ColorCurveHandler::ConsumeAttribute(CColorGradientCtrl*, AZ::u32, AzToolsFramework::PropertyAttributeReader*, const char*)
{}
void ColorCurveHandler::WriteGUIValuesIntoProperty([[maybe_unused]] size_t index, [[maybe_unused]] CColorGradientCtrl* GUI, [[maybe_unused]] property_t& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
{}
bool ColorCurveHandler::ReadValuesIntoGUI([[maybe_unused]] size_t index, CColorGradientCtrl* GUI, const property_t& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
{
GUI->SetSpline(reinterpret_cast<ISplineInterpolator*>(instance.m_spline));
return false;
}
@@ -6,8 +6,6 @@
*
*/
#ifndef CRYINCLUDE_EDITOR_UTILS_PROPERTYMISCCTRL_H
#define CRYINCLUDE_EDITOR_UTILS_PROPERTYMISCCTRL_H
#pragma once
#if !defined(Q_MOC_RUN)
@@ -16,7 +14,6 @@
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
#include "ReflectedVar.h"
#include "Util/VariablePropertyType.h"
#include "Controls/ColorGradientCtrl.h"
#include "Controls/SplineCtrl.h"
#include <QWidget>
#endif
@@ -54,6 +51,7 @@ private:
class UserPopupWidgetHandler : public QObject, public AzToolsFramework::PropertyHandler < CReflectedVarUser, UserPropertyEditor>
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(UserPopupWidgetHandler, AZ::SystemAllocator, 0);
bool IsDefaultHandler() const override { return false; }
@@ -68,6 +66,7 @@ public:
class FloatCurveHandler : public QObject, public AzToolsFramework::PropertyHandler < CReflectedVarSpline, CSplineCtrl>
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(FloatCurveHandler, AZ::SystemAllocator, 0);
bool IsDefaultHandler() const override { return false; }
@@ -81,18 +80,3 @@ public:
void OnSplineChange(CSplineCtrl*);
};
class ColorCurveHandler : public QObject, public AzToolsFramework::PropertyHandler < CReflectedVarSpline, CColorGradientCtrl>
{
public:
AZ_CLASS_ALLOCATOR(ColorCurveHandler, AZ::SystemAllocator, 0);
bool IsDefaultHandler() const override { return false; }
QWidget* CreateGUI(QWidget *pParent) override;
AZ::u32 GetHandlerName(void) const override { return AZ_CRC("ePropertyColorCurve", 0xa30da4ec); }
void ConsumeAttribute(CColorGradientCtrl* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
void WriteGUIValuesIntoProperty(size_t index, CColorGradientCtrl* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
bool ReadValuesIntoGUI(size_t index, CColorGradientCtrl* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
};
#endif // CRYINCLUDE_EDITOR_UTILS_PROPERTYMISCCTRL_H
@@ -58,17 +58,9 @@ private:
void OnClicked() override
{
QString tempValue("");
QString ext("");
if (m_path.isEmpty() == false)
if (!m_path.isEmpty() && !Path::GetExt(m_path).isEmpty())
{
if (Path::GetExt(m_path) == "")
{
tempValue = "";
}
else
{
tempValue = m_path;
}
tempValue = m_path;
}
AssetSelectionModel selection;
@@ -99,6 +99,7 @@ class FileResourceSelectorWidgetHandler
: QObject
, public AzToolsFramework::PropertyHandler < CReflectedVarResource, FileResourceSelectorWidget >
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(FileResourceSelectorWidgetHandler, AZ::SystemAllocator, 0);
@@ -26,6 +26,9 @@
#include <AzToolsFramework/UI/SearchWidget/SearchCriteriaWidget.hxx>
#include <AzToolsFramework/Editor/EditorSettingsAPIBus.h>
//AzCore
#include <AzCore/Component/ComponentApplicationBus.h>
// Editor
#include "Clipboard.h"
@@ -668,7 +671,7 @@ AzToolsFramework::PropertyRowWidget* ReflectedPropertyControl::FindPropertyRowWi
return nullptr;
}
const AzToolsFramework::ReflectedPropertyEditor::WidgetList& widgets = m_editor->GetWidgets();
for (auto instance : widgets)
for (const auto& instance : widgets)
{
if (instance.second->label() == item->GetPropertyName())
{
@@ -12,7 +12,6 @@
#if !defined(Q_MOC_RUN)
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/std/smart_ptr/unique_ptr.h>
#include "Include/EditorCoreAPI.h"
#include "ReflectedPropertyItem.h"
@@ -10,10 +10,10 @@
#define CRYINCLUDE_EDITOR_UTILS_REFLECTEDVAR_H
#pragma once
#include <AzCore/Serialization/SerializeContext.h>
#include <algorithm>
#include <limits>
#include "Util/VariablePropertyType.h"
#include <AzCore/Asset/AssetCommon.h>
#include <AzCore/Math/Vector2.h>
#include <AzCore/Math/Vector3.h>
#include <AzCore/Math/Vector4.h>
@@ -446,41 +446,54 @@ void ReflectedVarUserAdapter::SetVariable(IVariable *pVariable)
m_reflectedVar.reset(new CReflectedVarUser( pVariable->GetHumanName().toUtf8().data()));
}
void ReflectedVarUserAdapter::SyncReflectedVarToIVar(IVariable *pVariable)
void ReflectedVarUserAdapter::SyncReflectedVarToIVar(IVariable* pVariable)
{
QString value;
pVariable->Get(value);
m_reflectedVar->m_value = value.toUtf8().data();
//extract the list of custom items from the IVariable user data
IVariable::IGetCustomItems* pGetCustomItems = static_cast<IVariable::IGetCustomItems*> (pVariable->GetUserData().value<void *>());
if (pGetCustomItems != nullptr)
{
std::vector<IVariable::IGetCustomItems::SItem> items;
QString dlgTitle;
// call the user supplied callback to fill-in items and get dialog title
bool bShowIt = pGetCustomItems->GetItems(pVariable, items, dlgTitle);
if (bShowIt) // if func didn't veto, show the dialog
{
m_reflectedVar->m_enableEdit = true;
m_reflectedVar->m_useTree = pGetCustomItems->UseTree();
m_reflectedVar->m_treeSeparator = pGetCustomItems->GetTreeSeparator();
m_reflectedVar->m_dialogTitle = dlgTitle.toUtf8().data();
m_reflectedVar->m_itemNames.resize(items.size());
m_reflectedVar->m_itemDescriptions.resize(items.size());
QByteArray ba;
int i = -1;
std::generate(m_reflectedVar->m_itemNames.begin(), m_reflectedVar->m_itemNames.end(), [&items, &i, &ba]() { ++i; ba = items[i].name.toUtf8(); return ba.data(); });
i = -1;
std::generate(m_reflectedVar->m_itemDescriptions.begin(), m_reflectedVar->m_itemDescriptions.end(), [&items, &i, &ba]() { ++i; ba = items[i].desc.toUtf8(); return ba.data(); });
}
}
else
// extract the list of custom items from the IVariable user data
IVariable::IGetCustomItems* pGetCustomItems = static_cast<IVariable::IGetCustomItems*>(pVariable->GetUserData().value<void*>());
if (pGetCustomItems == nullptr)
{
m_reflectedVar->m_enableEdit = false;
return;
}
std::vector<IVariable::IGetCustomItems::SItem> items;
QString dlgTitle;
// call the user supplied callback to fill-in items and get dialog title
bool bShowIt = pGetCustomItems->GetItems(pVariable, items, dlgTitle);
if (!bShowIt) // if func vetoed it, don't show the dialog
{
return;
}
m_reflectedVar->m_enableEdit = true;
m_reflectedVar->m_useTree = pGetCustomItems->UseTree();
m_reflectedVar->m_treeSeparator = pGetCustomItems->GetTreeSeparator();
m_reflectedVar->m_dialogTitle = dlgTitle.toUtf8().data();
m_reflectedVar->m_itemNames.resize(items.size());
m_reflectedVar->m_itemDescriptions.resize(items.size());
QByteArray ba;
int i = -1;
AZStd::generate(
m_reflectedVar->m_itemNames.begin(), m_reflectedVar->m_itemNames.end(),
[&items, &i, &ba]()
{
++i;
ba = items[i].name.toUtf8();
return ba.data();
});
i = -1;
AZStd::generate(
m_reflectedVar->m_itemDescriptions.begin(), m_reflectedVar->m_itemDescriptions.end(),
[&items, &i, &ba]()
{
++i;
ba = items[i].desc.toUtf8();
return ba.data();
});
}
void ReflectedVarUserAdapter::SyncIVarToReflectedVar(IVariable *pVariable)
-1
View File
@@ -82,7 +82,6 @@ protected:
}
int GetSize() override { return sizeof(*this); }
QString GetDescription() override { return "UndoSplineCtrlEx"; };
void Undo(bool bUndo) override
{
-93
View File
@@ -1,93 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "TextEditorCtrl.h"
// CTextEditorCtrl
CTextEditorCtrl::CTextEditorCtrl(QWidget* pParent)
: QTextEdit(pParent)
{
m_bModified = true;
QFont font;
font.setFamily("Courier New");
font.setFixedPitch(true);
font.setPointSize(10);
setFont(font);
setLineWrapMode(NoWrap);
connect(this, &QTextEdit::textChanged, this, &CTextEditorCtrl::OnChange);
}
CTextEditorCtrl::~CTextEditorCtrl()
{
}
// CTextEditorCtrl message handlers
void CTextEditorCtrl::LoadFile(const QString& sFileName)
{
if (m_filename == sFileName)
{
return;
}
m_filename = sFileName;
clear();
CCryFile file(sFileName.toUtf8().data(), "rb");
if (file.Open(sFileName.toUtf8().data(), "rb"))
{
size_t length = file.GetLength();
QByteArray text;
text.resize(static_cast<int>(length));
file.ReadRaw(text.data(), length);
setPlainText(text);
}
m_bModified = false;
}
//////////////////////////////////////////////////////////////////////////
void CTextEditorCtrl::SaveFile(const QString& sFileName)
{
if (sFileName.isEmpty())
{
return;
}
if (!CFileUtil::OverwriteFile(sFileName.toUtf8().data()))
{
return;
}
QFile file(sFileName);
file.open(QFile::WriteOnly);
file.write(toPlainText().toUtf8());
m_bModified = false;
}
//////////////////////////////////////////////////////////////////////////
void CTextEditorCtrl::OnChange()
{
m_bModified = true;
}
#include <Controls/moc_TextEditorCtrl.cpp>
-42
View File
@@ -1,42 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_CONTROLS_TEXTEDITORCTRL_H
#define CRYINCLUDE_EDITOR_CONTROLS_TEXTEDITORCTRL_H
#pragma once
// CTextEditorCtrl
#if !defined(Q_MOC_RUN)
#include <QTextEdit>
#endif
class CTextEditorCtrl
: public QTextEdit
{
Q_OBJECT
public:
CTextEditorCtrl(QWidget* pParent = nullptr);
virtual ~CTextEditorCtrl();
void LoadFile(const QString& sFileName);
void SaveFile(const QString& sFileName);
QString GetFilename() const { return m_filename; }
bool IsModified() const { return m_bModified; }
//! Must be called after OnChange message.
void OnChange();
protected:
QString m_filename;
bool m_bModified;
};
#endif // CRYINCLUDE_EDITOR_CONTROLS_TEXTEDITORCTRL_H
-2
View File
@@ -126,7 +126,6 @@ void TimelineWidget::DrawTicks(QPainter* painter)
const QPen pOldPen = painter->pen();
const QPen ltgray(QColor(110, 110, 110));
const QPen black(palette().color(QPalette::Normal, QPalette::Text));
const QPen redpen(QColor(255, 0, 255));
// Draw time ticks every tick step seconds.
@@ -598,7 +597,6 @@ void TimelineWidget::DrawSecondTicks(QPainter* painter)
{
const QPen ltgray(QColor(110, 110, 110));
const QPen black(palette().color(QPalette::Normal, QPalette::Text));
const QPen redpen(QColor(255, 0, 255));
for (int gx = m_grid.firstGridLine.x(); gx < m_grid.firstGridLine.x() + m_grid.numGridLines.x() + 1; gx++)
{
-322
View File
@@ -1,322 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_CONTROLS_TREECTRLUTILS_H
#define CRYINCLUDE_EDITOR_CONTROLS_TREECTRLUTILS_H
#pragma once
#include <iterator>
namespace TreeCtrlUtils
{
template <typename P>
class TreeItemIterator
: public P
{
public:
typedef P Traits;
//iterator traits, required by STL
typedef ptrdiff_t difference_type;
typedef HTREEITEM value_type;
typedef HTREEITEM* pointer;
typedef HTREEITEM& reference;
typedef std::forward_iterator_tag iterator_category;
TreeItemIterator()
: pCtrl(0)
, hItem(0) {}
explicit TreeItemIterator(const P& traits)
: P(traits)
, pCtrl(0)
, hItem(0) {}
TreeItemIterator(const TreeItemIterator& other)
: P(other)
, pCtrl(other.pCtrl)
, hItem(other.hItem) {}
TreeItemIterator(CTreeCtrl* pCtrl, HTREEITEM hItem)
: pCtrl(pCtrl)
, hItem(hItem) {}
TreeItemIterator(CTreeCtrl* pCtrl, HTREEITEM hItem, const P& traits)
: P(traits)
, pCtrl(pCtrl)
, hItem(hItem) {}
HTREEITEM operator*() {return hItem; }
bool operator==(const TreeItemIterator& other) const {return pCtrl == other.pCtrl && hItem == other.hItem; }
bool operator!=(const TreeItemIterator& other) const {return pCtrl != other.pCtrl || hItem != other.hItem; }
TreeItemIterator& operator++()
{
HTREEITEM hNextItem = 0;
if (RecurseToChildren(hItem))
{
hNextItem = (pCtrl ? pCtrl->GetChildItem(hItem) : 0);
}
while (pCtrl && hItem && !hNextItem)
{
hNextItem = pCtrl->GetNextSiblingItem(hItem);
if (!hNextItem)
{
hItem = pCtrl->GetParentItem(hItem);
}
}
hItem = hNextItem;
return *this;
}
TreeItemIterator operator++(int) {TreeItemIterator old = *this; ++(*this); return old; }
CTreeCtrl* pCtrl;
HTREEITEM hItem;
};
class NonRecursiveTreeItemIteratorTraits
{
public:
bool RecurseToChildren(HTREEITEM hItem) {return false; }
};
typedef TreeItemIterator<NonRecursiveTreeItemIteratorTraits> NonRecursiveTreeItemIterator;
class RecursiveTreeItemIteratorTraits
{
public:
bool RecurseToChildren(HTREEITEM hItem) {return true; }
};
typedef TreeItemIterator<RecursiveTreeItemIteratorTraits> RecursiveTreeItemIterator;
inline RecursiveTreeItemIterator BeginTreeItemsRecursive(CTreeCtrl* pCtrl, HTREEITEM hItem = 0)
{
if (hItem == 0)
{
hItem = (pCtrl ? pCtrl->GetRootItem() : 0);
}
return RecursiveTreeItemIterator(pCtrl, hItem);
}
inline RecursiveTreeItemIterator EndTreeItemsRecursive(CTreeCtrl* pCtrl, HTREEITEM hItem = 0)
{
HTREEITEM hEndItem = 0;
HTREEITEM hParent = hItem;
do
{
if (hParent)
{
hEndItem = pCtrl->GetNextSiblingItem(hParent);
}
hParent = (pCtrl && hParent ? pCtrl->GetParentItem(hParent) : 0);
}
while (hParent && !hEndItem);
return RecursiveTreeItemIterator(pCtrl, hEndItem);
}
inline NonRecursiveTreeItemIterator BeginTreeItemsNonRecursive(CTreeCtrl* pCtrl, HTREEITEM hItem = 0)
{
if (hItem == 0)
{
hItem = (pCtrl ? pCtrl->GetRootItem() : 0);
}
if (hItem)
{
hItem = pCtrl->GetChildItem(hItem);
}
return NonRecursiveTreeItemIterator(pCtrl, hItem);
}
inline NonRecursiveTreeItemIterator EndTreeItemsNonRecursive(CTreeCtrl* pCtrl, HTREEITEM hItem = 0)
{
HTREEITEM hEndItem = 0;
HTREEITEM hParent = 0;
while (hParent && !hEndItem)
{
hParent = (pCtrl && hItem ? pCtrl->GetParentItem(hItem) : 0);
if (hParent)
{
hEndItem = pCtrl->GetNextSiblingItem(hParent);
}
}
return NonRecursiveTreeItemIterator(pCtrl, hEndItem);
}
template <typename T, typename P>
class TreeItemDataIterator
{
public:
typedef T Type;
typedef TreeItemIterator<P> InternalIterator;
//iterator traits, required by STL
typedef ptrdiff_t difference_type;
typedef Type* value_type;
typedef Type** pointer;
typedef Type*& reference;
typedef std::forward_iterator_tag iterator_category;
TreeItemDataIterator() {}
TreeItemDataIterator(const TreeItemDataIterator& other)
: iterator(other.iterator) {AdvanceToValidIterator(); }
explicit TreeItemDataIterator(const InternalIterator& iterator)
: iterator(iterator) {AdvanceToValidIterator(); }
Type* operator*() {return reinterpret_cast<Type*>(iterator.pCtrl->GetItemData(iterator.hItem)); }
bool operator==(const TreeItemDataIterator& other) const {return iterator == other.iterator; }
bool operator!=(const TreeItemDataIterator& other) const {return iterator != other.iterator; }
HTREEITEM GetTreeItem() {return iterator.hItem; }
TreeItemDataIterator& operator++()
{
++iterator;
AdvanceToValidIterator();
return *this;
}
TreeItemDataIterator operator++(int) {TreeItemDataIterator old = *this; ++(*this); return old; }
private:
void AdvanceToValidIterator()
{
while (iterator.pCtrl && iterator.hItem && !iterator.pCtrl->GetItemData(iterator.hItem))
{
++iterator;
}
}
InternalIterator iterator;
};
template <typename T>
class RecursiveItemDataIteratorType
{
public: typedef TreeItemDataIterator<T, RecursiveTreeItemIteratorTraits> type;
};
template <typename T>
inline TreeItemDataIterator<T, RecursiveTreeItemIteratorTraits> BeginTreeItemDataRecursive(CTreeCtrl* pCtrl, HTREEITEM hItem = 0)
{
return TreeItemDataIterator<T, RecursiveTreeItemIteratorTraits>(BeginTreeItemsRecursive(pCtrl, hItem));
}
template <typename T>
inline TreeItemDataIterator<T, RecursiveTreeItemIteratorTraits> EndTreeItemDataRecursive(CTreeCtrl* pCtrl, HTREEITEM hItem = 0)
{
return TreeItemDataIterator<T, RecursiveTreeItemIteratorTraits>(EndTreeItemsRecursive(pCtrl, hItem));
}
template <typename T>
class NonRecursiveItemDataIteratorType
{
typedef TreeItemDataIterator<T, NonRecursiveTreeItemIteratorTraits> type;
};
template <typename T>
inline TreeItemDataIterator<T, NonRecursiveTreeItemIteratorTraits> BeginTreeItemDataNonRecursive(CTreeCtrl* pCtrl, HTREEITEM hItem = 0)
{
return TreeItemDataIterator<T, NonRecursiveTreeItemIteratorTraits>(BeginTreeItemsNonRecursive(pCtrl, hItem));
}
template <typename T>
inline TreeItemDataIterator<T, NonRecursiveTreeItemIteratorTraits> EndTreeItemDataNonRecursive(CTreeCtrl* pCtrl, HTREEITEM hItem = 0)
{
return TreeItemDataIterator<T, NonRecursiveTreeItemIteratorTraits>(EndTreeItemsNonRecursive(pCtrl, hItem));
}
class SelectedTreeItemIterator
{
public:
SelectedTreeItemIterator()
: pCtrl(0)
, hItem(0) {}
SelectedTreeItemIterator(const SelectedTreeItemIterator& other)
: pCtrl(other.pCtrl)
, hItem(other.hItem) {}
SelectedTreeItemIterator(CXTTreeCtrl* pCtrl, HTREEITEM hItem)
: pCtrl(pCtrl)
, hItem(hItem) {}
HTREEITEM operator*() {return hItem; }
bool operator==(const SelectedTreeItemIterator& other) const {return pCtrl == other.pCtrl && hItem == other.hItem; }
bool operator!=(const SelectedTreeItemIterator& other) const {return pCtrl != other.pCtrl || hItem != other.hItem; }
SelectedTreeItemIterator& operator++()
{
hItem = (pCtrl ? pCtrl->GetNextSelectedItem(hItem) : 0);
return *this;
}
SelectedTreeItemIterator operator++(int) {SelectedTreeItemIterator old = *this; ++(*this); return old; }
CXTTreeCtrl* pCtrl;
HTREEITEM hItem;
};
SelectedTreeItemIterator BeginSelectedTreeItems(CXTTreeCtrl* pCtrl)
{
return SelectedTreeItemIterator(pCtrl, (pCtrl ? pCtrl->GetFirstSelectedItem() : 0));
}
SelectedTreeItemIterator EndSelectedTreeItems(CXTTreeCtrl* pCtrl)
{
return SelectedTreeItemIterator(pCtrl, 0);
}
template <typename T>
class SelectedTreeItemDataIterator
{
public:
typedef T Type;
typedef SelectedTreeItemIterator InternalIterator;
SelectedTreeItemDataIterator() {}
SelectedTreeItemDataIterator(const SelectedTreeItemDataIterator& other)
: iterator(other.iterator) {AdvanceToValidIterator(); }
explicit SelectedTreeItemDataIterator(const InternalIterator& iterator)
: iterator(iterator) {AdvanceToValidIterator(); }
Type* operator*() {return reinterpret_cast<Type*>(iterator.pCtrl->GetItemData(iterator.hItem)); }
bool operator==(const SelectedTreeItemDataIterator& other) const {return iterator == other.iterator; }
bool operator!=(const SelectedTreeItemDataIterator& other) const {return iterator != other.iterator; }
HTREEITEM GetTreeItem() {return iterator.hItem; }
SelectedTreeItemDataIterator& operator++()
{
++iterator;
AdvanceToValidIterator();
return *this;
}
SelectedTreeItemDataIterator operator++(int) {SelectedTreeItemDataIterator old = *this; ++(*this); return old; }
private:
void AdvanceToValidIterator()
{
while (iterator.pCtrl && iterator.hItem && !iterator.pCtrl->GetItemData(iterator.hItem))
{
++iterator;
}
}
InternalIterator iterator;
};
template <typename T>
SelectedTreeItemDataIterator<T> BeginSelectedTreeItemData(CXTTreeCtrl* pCtrl)
{
return SelectedTreeItemDataIterator<T>(BeginSelectedTreeItems(pCtrl));
}
template <typename T>
SelectedTreeItemDataIterator<T> EndSelectedTreeItemData(CXTTreeCtrl* pCtrl)
{
return SelectedTreeItemDataIterator<T>(EndSelectedTreeItems(pCtrl));
}
}
#endif // CRYINCLUDE_EDITOR_CONTROLS_TREECTRLUTILS_H
+45 -31
View File
@@ -32,6 +32,7 @@
#include <AzFramework/API/ApplicationAPI.h>
// AzToolsFramework
#include <AzToolsFramework/Viewport/ViewportMessages.h>
#include <AzToolsFramework/ViewportSelection/EditorTransformComponentSelectionRequestBus.h>
// AzQtComponents
@@ -103,6 +104,11 @@ namespace
}
}
// Currently (December 13, 2021), this function is only used by slice editor code.
// When the slice editor is not enabled, there are no references to the
// HideActionWhileEntitiesDeselected function, causing a compiler warning and
// subsequently a build error.
#ifdef ENABLE_SLICE_EDITOR
void HideActionWhileEntitiesDeselected(QAction* action, EEditorNotifyEvent editorNotifyEvent)
{
if (action == nullptr)
@@ -126,6 +132,7 @@ namespace
break;
}
}
#endif
void DisableActionWhileInSimMode(QAction* action, EEditorNotifyEvent editorNotifyEvent)
{
@@ -166,15 +173,14 @@ LevelEditorMenuHandler::LevelEditorMenuHandler(MainWindow* mainWindow, QtViewPan
m_mainWindow->menuBar()->setNativeMenuBar(true);
#endif
ComponentModeFramework::EditorComponentModeNotificationBus::Handler::BusConnect(
AzToolsFramework::GetEntityContextId());
ViewportEditorModeNotificationsBus::Handler::BusConnect(GetEntityContextId());
EditorMenuRequestBus::Handler::BusConnect();
}
LevelEditorMenuHandler::~LevelEditorMenuHandler()
{
EditorMenuRequestBus::Handler::BusDisconnect();
ComponentModeFramework::EditorComponentModeNotificationBus::Handler::BusDisconnect();
ViewportEditorModeNotificationsBus::Handler::BusDisconnect();
}
void LevelEditorMenuHandler::Initialize()
@@ -374,7 +380,6 @@ QMenu* LevelEditorMenuHandler::CreateFileMenu()
{
DisableActionWhileLevelChanges(fileOpenSlice, e);
}));
#endif
// Save Selected Slice
auto saveSelectedSlice = fileMenu.AddAction(ID_FILE_SAVE_SELECTED_SLICE);
@@ -391,7 +396,7 @@ QMenu* LevelEditorMenuHandler::CreateFileMenu()
{
HideActionWhileEntitiesDeselected(saveSliceToRoot, e);
}));
#endif
// Open Recent
m_mostRecentLevelsMenu = fileMenu.AddMenu(tr("Open Recent"));
connect(m_mostRecentLevelsMenu, &QMenu::aboutToShow, this, &LevelEditorMenuHandler::UpdateMRUFiles);
@@ -439,9 +444,10 @@ QMenu* LevelEditorMenuHandler::CreateFileMenu()
// Show Log File
fileMenu.AddAction(ID_FILE_EDITLOGFILE);
#ifdef ENABLE_SLICE_EDITOR
fileMenu.AddSeparator();
fileMenu.AddAction(ID_FILE_RESAVESLICES);
#endif
fileMenu.AddSeparator();
@@ -487,8 +493,6 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe
editMenu.AddAction(AzToolsFramework::EditPivot);
editMenu.AddAction(AzToolsFramework::EditReset);
editMenu.AddAction(AzToolsFramework::EditResetManipulator);
editMenu.AddAction(AzToolsFramework::EditResetLocal);
editMenu.AddAction(AzToolsFramework::EditResetWorld);
// Hide Selection
editMenu.AddAction(AzToolsFramework::HideSelection);
@@ -540,6 +544,7 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe
auto snapMenu = modifyMenu.AddMenu(tr("Snap"));
snapMenu.AddAction(AzToolsFramework::SnapAngle);
snapMenu.AddAction(AzToolsFramework::SnapToGrid);
auto transformModeMenu = modifyMenu.AddMenu(tr("Transform Mode"));
transformModeMenu.AddAction(AzToolsFramework::EditModeMove);
@@ -725,7 +730,8 @@ QMenu* LevelEditorMenuHandler::CreateViewMenu()
// MISSING AVIRECORDER
viewportViewsMenuWrapper.AddSeparator();
viewportViewsMenuWrapper.AddAction(ID_DISPLAY_SHOWHELPERS);
viewportViewsMenuWrapper.AddAction(AzToolsFramework::Helpers);
viewportViewsMenuWrapper.AddAction(AzToolsFramework::Icons);
// Refresh Style
viewMenu.AddAction(ID_SKINS_REFRESH);
@@ -834,7 +840,7 @@ QAction* LevelEditorMenuHandler::CreateViewPaneAction(const QtViewPane* view)
if (view->m_options.showOnToolsToolbar)
{
action->setIcon(QIcon(view->m_options.toolbarIcon));
action->setIcon(QIcon(view->m_options.toolbarIcon.c_str()));
}
m_actionManager->AddAction(view->m_id, action);
@@ -1186,36 +1192,44 @@ void LevelEditorMenuHandler::AddDisableActionInSimModeListener(QAction* action)
}));
}
void LevelEditorMenuHandler::EnteredComponentMode(const AZStd::vector<AZ::Uuid>& /*componentModeTypes*/)
void LevelEditorMenuHandler::OnEditorModeActivated(
[[maybe_unused]] const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode)
{
auto menuWrapper = m_actionManager->FindMenu(s_editMenuId);
if (!menuWrapper.isNull())
if (mode == ViewportEditorMode::Component)
{
// copy of menu actions
auto actions = menuWrapper.Get()->actions();
// remove all non-reserved edit menu options
actions.erase(
std::remove_if(actions.begin(), actions.end(), [](QAction* action)
{
return !action->property("Reserved").toBool();
}),
actions.end());
if (auto menuWrapper = m_actionManager->FindMenu(s_editMenuId);
!menuWrapper.isNull())
{
// copy of menu actions
auto actions = menuWrapper.Get()->actions();
// remove all non-reserved edit menu options
actions.erase(
std::remove_if(actions.begin(), actions.end(), [](QAction* action)
{
return !action->property("Reserved").toBool();
}),
actions.end());
// clear and update the menu with new actions
menuWrapper.Get()->clear();
menuWrapper.Get()->addActions(actions);
// clear and update the menu with new actions
menuWrapper.Get()->clear();
menuWrapper.Get()->addActions(actions);
}
}
}
void LevelEditorMenuHandler::LeftComponentMode(const AZStd::vector<AZ::Uuid>& /*componentModeTypes*/)
void LevelEditorMenuHandler::OnEditorModeDeactivated(
[[maybe_unused]] const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode)
{
RestoreEditMenuToDefault();
if (mode == ViewportEditorMode::Component)
{
RestoreEditMenuToDefault();
}
}
void LevelEditorMenuHandler::AddEditMenuAction(QAction* action)
{
auto menuWrapper = m_actionManager->FindMenu(s_editMenuId);
if (!menuWrapper.isNull())
if (auto menuWrapper = m_actionManager->FindMenu(s_editMenuId);
!menuWrapper.isNull())
{
menuWrapper.Get()->addAction(action);
}
@@ -1239,8 +1253,8 @@ void LevelEditorMenuHandler::AddMenuAction(AZStd::string_view categoryId, QActio
void LevelEditorMenuHandler::RestoreEditMenuToDefault()
{
auto menuWrapper = m_actionManager->FindMenu(s_editMenuId);
if (!menuWrapper.isNull())
if (auto menuWrapper = m_actionManager->FindMenu(s_editMenuId);
!menuWrapper.isNull())
{
menuWrapper.Get()->clear();
PopulateEditMenu(menuWrapper);
+7 -5
View File
@@ -18,7 +18,7 @@
#include <QPointer>
#include "ActionManager.h"
#include "QtViewPaneManager.h"
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
#include <AzToolsFramework/API/ViewportEditorModeTrackerNotificationBus.h>
#endif
class MainWindow;
@@ -28,7 +28,7 @@ struct QtViewPane;
class LevelEditorMenuHandler
: public QObject
, private AzToolsFramework::ComponentModeFramework::EditorComponentModeNotificationBus::Handler
, private AzToolsFramework::ViewportEditorModeNotificationsBus::Handler
, private AzToolsFramework::EditorMenuRequestBus::Handler
{
Q_OBJECT
@@ -88,9 +88,11 @@ private:
void AddDisableActionInSimModeListener(QAction* action);
// EditorComponentModeNotificationBus
void EnteredComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
void LeftComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
// ViewportEditorModeNotificationsBus overrides ...
void OnEditorModeActivated(
const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode) override;
void OnEditorModeDeactivated(
const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode) override;
// EditorMenuRequestBus
void AddEditMenuAction(QAction* action) override;
+4 -130
View File
@@ -16,18 +16,11 @@
#include <QScopedValueRollback>
#include <QToolBar>
#include <QLoggingCategory>
#if defined(AZ_PLATFORM_WINDOWS)
#include <QtGui/qpa/qplatformnativeinterface.h>
#include <QtGui/private/qhighdpiscaling_p.h>
#endif
#include <AzCore/Component/ComponentApplication.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
// AzFramework
#if defined(AZ_PLATFORM_WINDOWS)
# include <AzFramework/Input/Buses/Notifications/RawInputNotificationBus_Platform.h>
#endif // defined(AZ_PLATFORM_WINDOWS)
// AzQtComponents
#include <AzQtComponents/Components/GlobalEventFilter.h>
@@ -39,12 +32,11 @@
#include "Settings.h"
#include "CryEdit.h"
enum
{
// in milliseconds
GameModeIdleFrequency = 0,
EditorModeIdleFrequency = 0,
EditorModeIdleFrequency = 1,
InactiveModeFrequency = 10,
UninitializedFrequency = 9999,
};
@@ -241,7 +233,6 @@ namespace Editor
EditorQtApplication::EditorQtApplication(int& argc, char** argv)
: AzQtApplication(argc, argv)
, m_inWinEventFilter(false)
, m_stylesheet(new AzQtComponents::O3DEStylesheet(this))
, m_idleTimer(new QTimer(this))
{
@@ -368,86 +359,10 @@ namespace Editor
UninstallEditorTranslators();
}
#if defined(AZ_PLATFORM_WINDOWS)
bool EditorQtApplication::nativeEventFilter([[maybe_unused]] const QByteArray& eventType, void* message, long* result)
EditorQtApplication* EditorQtApplication::instance()
{
MSG* msg = (MSG*)message;
if (msg->message == WM_MOVING || msg->message == WM_SIZING)
{
m_isMovingOrResizing = true;
}
else if (msg->message == WM_EXITSIZEMOVE)
{
m_isMovingOrResizing = false;
}
// Prevent the user from being able to move the window in game mode.
// This is done during the hit test phase to bypass the native window move messages. If the window
// decoration wrapper title bar contains the cursor, set the result to HTCLIENT instead of
// HTCAPTION.
if (msg->message == WM_NCHITTEST && GetIEditor()->IsInGameMode())
{
const LRESULT defWinProcResult = DefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam);
if (defWinProcResult == 1)
{
if (QWidget* widget = QWidget::find((WId)msg->hwnd))
{
if (auto wrapper = qobject_cast<const AzQtComponents::WindowDecorationWrapper *>(widget))
{
AzQtComponents::TitleBar* titleBar = wrapper->titleBar();
const short global_x = static_cast<short>(LOWORD(msg->lParam));
const short global_y = static_cast<short>(HIWORD(msg->lParam));
const QPoint globalPos = QHighDpi::fromNativePixels(QPoint(global_x, global_y), widget->window()->windowHandle());
const QPoint local = titleBar->mapFromGlobal(globalPos);
if (titleBar->draggableRect().contains(local) && !titleBar->isTopResizeArea(globalPos))
{
*result = HTCLIENT;
return true;
}
}
}
}
}
// Ensure that the Windows WM_INPUT messages get passed through to the AzFramework input system.
// These events are only broadcast in game mode. In Editor mode, RenderViewportWidget creates synthetic
// keyboard and mouse events via Qt.
if (GetIEditor()->IsInGameMode())
{
if (msg->message == WM_INPUT)
{
UINT rawInputSize;
const UINT rawInputHeaderSize = sizeof(RAWINPUTHEADER);
GetRawInputData((HRAWINPUT)msg->lParam, RID_INPUT, nullptr, &rawInputSize, rawInputHeaderSize);
AZStd::array<BYTE, sizeof(RAWINPUT)> rawInputBytesArray;
LPBYTE rawInputBytes = rawInputBytesArray.data();
[[maybe_unused]] const UINT bytesCopied = GetRawInputData((HRAWINPUT)msg->lParam, RID_INPUT, rawInputBytes, &rawInputSize, rawInputHeaderSize);
CRY_ASSERT(bytesCopied == rawInputSize);
RAWINPUT* rawInput = (RAWINPUT*)rawInputBytes;
CRY_ASSERT(rawInput);
AzFramework::RawInputNotificationBusWindows::Broadcast(&AzFramework::RawInputNotificationsWindows::OnRawInputEvent, *rawInput);
return false;
}
else if (msg->message == WM_DEVICECHANGE)
{
if (msg->wParam == 0x0007) // DBT_DEVNODES_CHANGED
{
AzFramework::RawInputNotificationBusWindows::Broadcast(&AzFramework::RawInputNotificationsWindows::OnRawInputDeviceChangeEvent);
}
return true;
}
}
return false;
return static_cast<EditorQtApplication*>(QApplication::instance());
}
#endif
void EditorQtApplication::OnEditorNotifyEvent(EEditorNotifyEvent event)
{
@@ -505,11 +420,6 @@ namespace Editor
return m_stylesheet->GetColorByName(name);
}
EditorQtApplication* EditorQtApplication::instance()
{
return static_cast<EditorQtApplication*>(QApplication::instance());
}
bool EditorQtApplication::IsActive()
{
return applicationState() == Qt::ApplicationActive;
@@ -613,42 +523,6 @@ namespace Editor
case QEvent::KeyRelease:
m_pressedKeys.remove(reinterpret_cast<QKeyEvent*>(event)->key());
break;
#ifdef AZ_PLATFORM_WINDOWS
case QEvent::Leave:
{
// if we receive a leave event for a toolbar on Windows
// check first whether we really left it. If we didn't: start checking
// for the tool bar under the mouse by timer to check when we really left.
// Synthesize a new leave event then. Workaround for LY-69788
auto toolBarAt = [](const QPoint& pos) -> QToolBar* {
QWidget* widget = qApp->widgetAt(pos);
while (widget != nullptr)
{
if (QToolBar* tb = qobject_cast<QToolBar*>(widget))
{
return tb;
}
widget = widget->parentWidget();
}
return nullptr;
};
if (object == toolBarAt(QCursor::pos()))
{
QTimer* t = new QTimer(object);
t->start(100);
connect(t, &QTimer::timeout, object, [t, object, toolBarAt]() {
if (object != toolBarAt(QCursor::pos()))
{
QEvent event(QEvent::Leave);
qApp->sendEvent(object, &event);
t->deleteLater();
}
});
return true;
}
break;
}
#endif
default:
break;
}
+5 -6
View File
@@ -72,14 +72,12 @@ namespace Editor
////
static EditorQtApplication* instance();
static EditorQtApplication* newInstance(int& argc, char** argv);
static bool IsActive();
bool isMovingOrResizing() const;
// QAbstractNativeEventFilter:
bool nativeEventFilter(const QByteArray& eventType, void* message, long* result) override;
// IEditorNotifyListener:
void OnEditorNotifyEvent(EEditorNotifyEvent event) override;
@@ -100,6 +98,10 @@ namespace Editor
signals:
void skinChanged();
protected:
bool m_isMovingOrResizing = false;
private:
enum TimerResetFlag
{
@@ -116,8 +118,6 @@ namespace Editor
AzQtComponents::O3DEStylesheet* m_stylesheet;
bool m_inWinEventFilter = false;
// Translators
void InstallEditorTranslators();
void UninstallEditorTranslators();
@@ -127,7 +127,6 @@ namespace Editor
QTranslator* m_editorTranslator = nullptr;
QTranslator* m_assetBrowserTranslator = nullptr;
QTimer* const m_idleTimer = nullptr;
bool m_isMovingOrResizing = false;
AZ::UserSettingsProvider m_localUserSettings;
@@ -1,28 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "QtEditorApplication.h"
#ifdef PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
#include <AzFramework/XcbEventHandler.h>
#endif
namespace Editor
{
bool EditorQtApplication::nativeEventFilter([[maybe_unused]] const QByteArray& eventType, void* message, long*)
{
if (GetIEditor()->IsInGameMode())
{
#ifdef PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
AzFramework::XcbEventHandlerBus::Broadcast(&AzFramework::XcbEventHandler::HandleXcbEvent, static_cast<xcb_generic_event_t*>(message));
#endif
return true;
}
return false;
}
}
+2
View File
@@ -33,6 +33,7 @@ public:
protected:
void SetupEnvironment() override
{
AttachEditorCoreAZEnvironment(AZ::Environment::GetInstance());
m_allocatorScope.ActivateAllocators();
m_cryPak = new NiceMock<CryPakMock>();
@@ -49,6 +50,7 @@ protected:
{
delete m_cryPak;
m_allocatorScope.DeactivateAllocators();
DetachEditorCoreAZEnvironment();
}
private:
+22 -15
View File
@@ -5,22 +5,29 @@
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include <AzTest/AzTest.h>
#include "Util/PathUtil.h"
#include <CrySystemBus.h>
TEST(PathUtil, GamePathToFullPath_DoesNotBufferOverflow)
#include <AzCore/UnitTest/TestTypes.h>
#include <Util/PathUtil.h>
namespace UnitTest
{
// There are no test assertions in this test because the purpose is just to verify that the test runs without crashing
QString pngExtension(".png");
class PathUtil
: public ScopedAllocatorSetupFixture
{
};
// Create a string of lenth AZ_MAX_PATH_LEN that ends in .png
QString longStringMaxPath(AZ_MAX_PATH_LEN, 'x');
longStringMaxPath.replace(longStringMaxPath.length() - pngExtension.length(), longStringMaxPath.length(), pngExtension);
Path::GamePathToFullPath(longStringMaxPath);
TEST_F(PathUtil, GamePathToFullPath_DoesNotBufferOverflow)
{
// There are no test assertions in this test because the purpose is just to verify that the test runs without crashing
QString pngExtension(".png");
QString longStringMaxPathPlusOne(AZ_MAX_PATH_LEN + 1, 'x');
longStringMaxPathPlusOne.replace(longStringMaxPathPlusOne.length() - pngExtension.length(), longStringMaxPathPlusOne.length(), pngExtension);
Path::GamePathToFullPath(longStringMaxPathPlusOne);
// Create a string of length AZ_MAX_PATH_LEN that ends in .png
QString longStringMaxPath(AZ_MAX_PATH_LEN, 'x');
longStringMaxPath.replace(longStringMaxPath.length() - pngExtension.length(), longStringMaxPath.length(), pngExtension);
AZ_TEST_START_TRACE_SUPPRESSION;
Path::GamePathToFullPath(longStringMaxPath);
AZ_TEST_STOP_TRACE_SUPPRESSION_NO_COUNT;
QString longStringMaxPathPlusOne(AZ_MAX_PATH_LEN + 1, 'x');
longStringMaxPathPlusOne.replace(longStringMaxPathPlusOne.length() - pngExtension.length(), longStringMaxPathPlusOne.length(), pngExtension);
Path::GamePathToFullPath(longStringMaxPathPlusOne);
}
}
-170
View File
@@ -1,170 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//#ifdef _CRTDBG_MAP_ALLOC
#ifdef CRTDBG_MAP_ALLOC
#pragma pack (push,1)
#define nNoMansLandSize 4
typedef struct MyCrtMemBlockHeader
{
struct MyCrtMemBlockHeader* pBlockHeaderNext;
struct MyCrtMemBlockHeader* pBlockHeaderPrev;
char* szFileName;
int nLine;
size_t nDataSize;
int nBlockUse;
long lRequest;
unsigned char gap[nNoMansLandSize];
/* followed by:
* unsigned char data[nDataSize];
* unsigned char anotherGap[nNoMansLandSize];
*/
} MyCrtMemBlockHeader;
#pragma pack (pop)
#define pbData(pblock) ((unsigned char*)((MyCrtMemBlockHeader*)pblock + 1))
#define pHdr(pbData) (((MyCrtMemBlockHeader*)pbData) - 1)
void crtdebug(const char* s, ...)
{
char str[32768];
va_list arg_ptr;
va_start(arg_ptr, s);
vsprintf(str, s, arg_ptr);
va_end(arg_ptr);
FILE* l = nullptr;
azfopen(&l, "crtdump.txt", "a+t");
if (l)
{
fprintf(l, "%s", str);
fclose(l);
}
}
int crtAllocHook(int nAllocType, void* pvData,
size_t nSize, int nBlockUse, long lRequest,
const unsigned char* szFileName, int nLine)
{
if (nBlockUse == _CRT_BLOCK)
{
return TRUE;
}
static int total_cnt = 0;
static int total_mem = 0;
if (nAllocType == _HOOK_ALLOC)
{
//total_mem += nSize;
//total_cnt++;
//_CrtMemState mem_state;
//_CrtMemCheckpoint( &mem_state );
//total_cnt = mem_state.lCounts[_NORMAL_BLOCK];
//total_mem = mem_state.lTotalCount;
if ((total_cnt & 0xF) == 0)
{
//_CrtCheckMemory();
}
total_cnt++;
total_mem += nSize;
//crtdebug( "<CRT> Alloc %d,size=%d,in: %s %d (total size=%d,num=%d)\n",lRequest,nSize,szFileName,nLine,total_mem,total_cnt );
crtdebug("Size=%d, [Total=%d,N=%d] [%s:%d]\n", nSize, total_mem, total_cnt, szFileName, nLine);
}
else if (nAllocType == _HOOK_FREE)
{
MyCrtMemBlockHeader* pHead;
pHead = pHdr(pvData);
total_cnt--;
total_mem -= pHead->nDataSize;
crtdebug("Size=%d, [Total=%d,N=%d] [%s:%d]\n", pHead->nDataSize, total_mem, total_cnt, pHead->szFileName, pHead->nLine);
//crtdebug( "<CRT> Free size=%d,in: %s %d (total size=%d,num=%d)\n",pHead->nDataSize,pHead->szFileName,pHead->nLine,total_mem,total_cnt );
//total_mem -= nSize;
//total_cnt--;
}
return TRUE;
}
int crtReportHook(int nRptType, char* szMsg, int* retVal)
{
static int gl_num_asserts = 0;
if (gl_num_asserts != 0)
{
return TRUE;
}
gl_num_asserts++;
switch (nRptType)
{
case _CRT_WARN:
crtdebug("<CRT WARNING> %s\n", szMsg);
break;
case _CRT_ERROR:
crtdebug("<CRT ERROR> %s\n", szMsg);
break;
case _CRT_ASSERT:
crtdebug("<CRT ASSERT> %s\n", szMsg);
break;
}
gl_num_asserts--;
return TRUE;
}
void InitCrt()
{
FILE* l = nullptr;
azfopen(&l, "crtdump.txt", "w");
if (l)
{
fclose(l);
}
//_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_DEBUG );
//_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_DEBUG );
//_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_DEBUG );
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_WNDW);
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_WNDW);
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_WNDW);
//_CrtSetDbgFlag( _CRTDBG_CHECK_ALWAYS_DF|_CRTDBG_CHECK_CRT_DF|_CRTDBG_LEAK_CHECK_DF|_CRTDBG_DELAY_FREE_MEM_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) );
//_CrtSetDbgFlag( _CRTDBG_CHECK_CRT_DF|_CRTDBG_LEAK_CHECK_DF/*|_CRTDBG_DELAY_FREE_MEM_DF*/ | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) );
int flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
flags &= ~_CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_CRT_DF;
_CrtSetDbgFlag(flags);
_CrtSetAllocHook (crtAllocHook);
_CrtSetReportHook(crtReportHook);
}
void DoneCrt()
{
//_CrtCheckMemory();
//_CrtDumpMemoryLeaks();
}
// Autoinit CRT.
//struct __autoinit_crt { __autoinit_crt() { InitCrt(); }; ~__autoinit_crt() { DoneCrt(); } } __autoinit_crt_var;
#endif
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
+110 -98
View File
@@ -33,18 +33,12 @@ AZ_POP_DISABLE_WARNING
#include <QScopedValueRollback>
#include <QClipboard>
#include <QMenuBar>
#include <QMessageBox>
#include <QDialogButtonBox>
// Aws Native SDK
#include <aws/sts/STSClient.h>
#include <aws/core/auth/AWSCredentialsProvider.h>
#include <aws/sts/model/GetFederationTokenRequest.h>
#include <aws/core/http/HttpClient.h>
#include <aws/core/http/HttpResponse.h>
#include <aws/core/utils/json/JsonSerializer.h>
// AzCore
#include <AzCore/Casting/numeric_cast.h>
#include <AzCore/Component/ComponentApplicationLifecycle.h>
#include <AzCore/Module/Environment.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/std/smart_ptr/make_shared.h>
@@ -57,6 +51,7 @@ AZ_POP_DISABLE_WARNING
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzFramework/Terrain/TerrainDataRequestBus.h>
#include <AzFramework/ProjectManager/ProjectManager.h>
#include <AzFramework/Spawnable/RootSpawnableInterface.h>
// AzToolsFramework
#include <AzToolsFramework/Component/EditorComponentAPIBus.h>
@@ -78,7 +73,6 @@ AZ_POP_DISABLE_WARNING
#include <AzQtComponents/Utilities/QtPluginPaths.h>
// CryCommon
#include <CryCommon/ITimer.h>
#include <CryCommon/ILevelSystem.h>
// Editor
@@ -122,9 +116,6 @@ AZ_POP_DISABLE_WARNING
#include "ScopedVariableSetter.h"
#include "Util/3DConnexionDriver.h"
#include "DimensionsDialog.h"
#include "Util/AutoDirectoryRestoreFileDialog.h"
#include "Util/EditorAutoLevelLoadTest.h"
#include "AboutDialog.h"
@@ -145,9 +136,7 @@ AZ_POP_DISABLE_WARNING
#include "Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.h"
// AWSNativeSDK
#include <AzToolsFramework/Undo/UndoSystem.h>
#include <AWSNativeSDKInit/AWSNativeSDKInit.h>
#if defined(AZ_PLATFORM_WINDOWS)
@@ -286,21 +275,22 @@ bool CCryDocManager::DoPromptFileName(QString& fileName, [[maybe_unused]] UINT n
return false;
}
CCryEditDoc* CCryDocManager::OpenDocumentFile(const char* lpszFileName, bool bAddToMRU)
CCryEditDoc* CCryDocManager::OpenDocumentFile(const char* filename, bool addToMostRecentFileList, COpenSameLevelOptions openSameLevelOptions)
{
assert(lpszFileName != nullptr);
assert(filename != nullptr);
const bool reopenIfSame = openSameLevelOptions == COpenSameLevelOptions::ReopenLevelIfSame;
// find the highest confidence
auto pos = m_templateList.begin();
CCrySingleDocTemplate::Confidence bestMatch = CCrySingleDocTemplate::noAttempt;
CCrySingleDocTemplate* pBestTemplate = nullptr;
CCryEditDoc* pOpenDocument = nullptr;
if (lpszFileName[0] == '\"')
if (filename[0] == '\"')
{
++lpszFileName;
++filename;
}
QString szPath = QString::fromUtf8(lpszFileName);
QString szPath = QString::fromUtf8(filename);
if (szPath.endsWith('"'))
{
szPath.remove(szPath.length() - 1, 1);
@@ -324,7 +314,7 @@ CCryEditDoc* CCryDocManager::OpenDocumentFile(const char* lpszFileName, bool bAd
}
}
if (pOpenDocument != nullptr)
if (!reopenIfSame && pOpenDocument != nullptr)
{
return pOpenDocument;
}
@@ -335,7 +325,7 @@ CCryEditDoc* CCryDocManager::OpenDocumentFile(const char* lpszFileName, bool bAd
return nullptr;
}
return pBestTemplate->OpenDocumentFile(szPath.toUtf8().data(), bAddToMRU, false);
return pBestTemplate->OpenDocumentFile(szPath.toUtf8().data(), addToMostRecentFileList, false);
}
//////////////////////////////////////////////////////////////////////////////
@@ -368,10 +358,8 @@ void CCryEditApp::RegisterActionHandlers()
ON_COMMAND(ID_EDIT_FETCH, OnEditFetch)
ON_COMMAND(ID_FILE_EXPORTTOGAMENOSURFACETEXTURE, OnFileExportToGameNoSurfaceTexture)
ON_COMMAND(ID_VIEW_SWITCHTOGAME, OnViewSwitchToGame)
MainWindow::instance()->GetActionManager()->RegisterActionHandler(ID_VIEW_SWITCHTOGAME_FULLSCREEN, [this]() {
ed_previewGameInFullscreen_once = true;
OnViewSwitchToGame();
});
ON_COMMAND(ID_VIEW_SWITCHTOGAME_VIEWPORT, OnViewSwitchToGame)
ON_COMMAND(ID_VIEW_SWITCHTOGAME_FULLSCREEN, OnViewSwitchToGameFullScreen)
ON_COMMAND(ID_MOVE_OBJECT, OnMoveObject)
ON_COMMAND(ID_RENAME_OBJ, OnRenameObj)
ON_COMMAND(ID_UNDO, OnUndo)
@@ -379,13 +367,13 @@ void CCryEditApp::RegisterActionHandlers()
ON_COMMAND(ID_IMPORT_ASSET, OnOpenAssetImporter)
ON_COMMAND(ID_EDIT_LEVELDATA, OnEditLevelData)
ON_COMMAND(ID_FILE_EDITLOGFILE, OnFileEditLogFile)
ON_COMMAND(ID_FILE_RESAVESLICES, OnFileResaveSlices)
ON_COMMAND(ID_FILE_EDITEDITORINI, OnFileEditEditorini)
ON_COMMAND(ID_PREFERENCES, OnPreferences)
ON_COMMAND(ID_REDO, OnRedo)
ON_COMMAND(ID_TOOLBAR_WIDGET_REDO, OnRedo)
ON_COMMAND(ID_FILE_OPEN_LEVEL, OnOpenLevel)
#ifdef ENABLE_SLICE_EDITOR
ON_COMMAND(ID_FILE_RESAVESLICES, OnFileResaveSlices)
ON_COMMAND(ID_FILE_NEW_SLICE, OnCreateSlice)
ON_COMMAND(ID_FILE_OPEN_SLICE, OnOpenSlice)
#endif
@@ -444,7 +432,6 @@ void CCryEditApp::RegisterActionHandlers()
ON_COMMAND(ID_OPEN_ASSET_BROWSER, OnOpenAssetBrowserView)
ON_COMMAND(ID_OPEN_AUDIO_CONTROLS_BROWSER, OnOpenAudioControlsEditor)
ON_COMMAND(ID_DISPLAY_SHOWHELPERS, OnShowHelpers)
ON_COMMAND(ID_OPEN_TRACKVIEW, OnOpenTrackView)
ON_COMMAND(ID_OPEN_UICANVASEDITOR, OnOpenUICanvasEditor)
@@ -512,7 +499,7 @@ public:
QString m_appRoot;
QString m_logFile;
QString m_pythonArgs;
QString m_pythontTestCase;
QString m_pythonTestCase;
QString m_execFile;
QString m_execLineCmd;
@@ -545,7 +532,6 @@ public:
{ "BatchMode", m_bConsoleMode },
{ "NullRenderer", m_bNullRenderer },
{ "devmode", m_bDeveloperMode },
{ "VTUNE", dummy },
{ "runpython", m_bRunPythonScript },
{ "runpythontest", m_bRunPythonTestScript },
{ "version", m_bShowVersionInfo },
@@ -561,7 +547,7 @@ public:
const std::vector<std::pair<CommandLineStringOption, QString&> > stringOptions = {
{{"logfile", "File name of the log file to write out to.", "logfile"}, m_logFile},
{{"runpythonargs", "Command-line argument string to pass to the python script if --runpython or --runpythontest was used.", "runpythonargs"}, m_pythonArgs},
{{"pythontestcase", "Test case name of python test script if --runpythontest was used.", "pythontestcase"}, m_pythontTestCase},
{{"pythontestcase", "Test case name of python test script if --runpythontest was used.", "pythontestcase"}, m_pythonTestCase},
{{"exec", "cfg file to run on startup, used for systems like automation", "exec"}, m_execFile},
{{"rhi", "Command-line argument to force which rhi to use", "dummyString"}, dummyString },
{{"rhi-device-validation", "Command-line argument to configure rhi validation", "dummyString"}, dummyString },
@@ -817,7 +803,7 @@ CCryEditDoc* CCrySingleDocTemplate::OpenDocumentFile(const char* lpszPathName, b
return OpenDocumentFile(lpszPathName, true, bMakeVisible);
}
CCryEditDoc* CCrySingleDocTemplate::OpenDocumentFile(const char* lpszPathName, bool bAddToMRU, [[maybe_unused]] bool bMakeVisible)
CCryEditDoc* CCrySingleDocTemplate::OpenDocumentFile(const char* lpszPathName, bool addToMostRecentFileList, [[maybe_unused]] bool bMakeVisible)
{
CCryEditDoc* pCurDoc = GetIEditor()->GetDocument();
@@ -847,7 +833,7 @@ CCryEditDoc* CCrySingleDocTemplate::OpenDocumentFile(const char* lpszPathName, b
{
pCurDoc->OnOpenDocument(lpszPathName);
pCurDoc->SetPathName(lpszPathName);
if (bAddToMRU)
if (addToMostRecentFileList)
{
CCryEditApp::instance()->AddToRecentFileList(lpszPathName);
}
@@ -912,13 +898,9 @@ namespace
QWidget* g_splashScreen = nullptr;
}
QString FormatVersion(const SFileVersion& v)
QString FormatVersion([[maybe_unused]] const SFileVersion& v)
{
#if defined(LY_BUILD)
return QObject::tr("Version %1.%2.%3.%4 - Build %5").arg(v[3]).arg(v[2]).arg(v[1]).arg(v[0]).arg(LY_BUILD);
#else
return QObject::tr("Version %1.%2.%3.%4").arg(v[3]).arg(v[2]).arg(v[1]).arg(v[0]);
#endif
return QObject::tr("Version %1").arg(LY_VERSION_BUILD_NUMBER);
}
QString FormatRichTextCopyrightNotice()
@@ -1357,18 +1339,27 @@ void CCryEditApp::CompileCriticalAssets() const
}
}
assetsInQueueNotifcation.BusDisconnect();
// Signal the "CriticalAssetsCompiled" lifecycle event
// Also reload the "assetcatalog.xml" if it exists
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
{
AZ::ComponentApplicationLifecycle::SignalEvent(*settingsRegistry, "CriticalAssetsCompiled", R"({})");
// Reload the assetcatalog.xml at this point again
// Start Monitoring Asset changes over the network and load the AssetCatalog
auto LoadCatalog = [settingsRegistry](AZ::Data::AssetCatalogRequests* assetCatalogRequests)
{
if (AZ::IO::FixedMaxPath assetCatalogPath;
settingsRegistry->Get(assetCatalogPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_CacheRootFolder))
{
assetCatalogPath /= "assetcatalog.xml";
assetCatalogRequests->LoadCatalog(assetCatalogPath.c_str());
}
};
AZ::Data::AssetCatalogRequestBus::Broadcast(AZStd::move(LoadCatalog));
}
CCryEditApp::OutputStartupMessage(QString("Asset Processor is now ready."));
// VERY early on, as soon as we can, request that the asset system make sure the following assets take priority over others,
// so that by the time we ask for them there is a greater likelihood that they're already good to go.
// these can be loaded later but are still important:
AzFramework::AssetSystemRequestBus::Broadcast(&AzFramework::AssetSystem::AssetSystemRequests::EscalateAssetBySearchTerm, "/texturemsg/");
AzFramework::AssetSystemRequestBus::Broadcast(&AzFramework::AssetSystem::AssetSystemRequests::EscalateAssetBySearchTerm, "engineassets/materials");
AzFramework::AssetSystemRequestBus::Broadcast(&AzFramework::AssetSystem::AssetSystemRequests::EscalateAssetBySearchTerm, "engineassets/geomcaches");
AzFramework::AssetSystemRequestBus::Broadcast(&AzFramework::AssetSystem::AssetSystemRequests::EscalateAssetBySearchTerm, "engineassets/objects");
// some are specifically extra important and will cause issues if missing completely:
AzFramework::AssetSystemRequestBus::Broadcast(&AzFramework::AssetSystem::AssetSystemRequests::CompileAssetSync, "engineassets/objects/default.cgf");
}
bool CCryEditApp::ConnectToAssetProcessor() const
@@ -1534,11 +1525,12 @@ void CCryEditApp::RunInitPythonScript(CEditCommandLineInfo& cmdInfo)
{
// Multiple testcases can be specified them with ';', these should match the files to run
AZStd::vector<AZStd::string_view> testcaseList;
QByteArray pythonTestCase = cmdInfo.m_pythonTestCase.toUtf8();
testcaseList.resize(fileList.size());
{
int i = 0;
AzFramework::StringFunc::TokenizeVisitor(
fileStr.constData(),
pythonTestCase.constData(),
[&i, &testcaseList](AZStd::string_view elem)
{
testcaseList[i++] = (elem);
@@ -1683,6 +1675,11 @@ bool CCryEditApp::InitInstance()
return false;
}
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
{
AZ::ComponentApplicationLifecycle::SignalEvent(*settingsRegistry, "LegacySystemInterfaceCreated", R"({})");
}
// Process some queued events come from system init
// Such as asset catalog loaded notification.
// There are some systems need to load configurations from assets for post initialization but before loading level
@@ -1796,12 +1793,6 @@ bool CCryEditApp::InitInstance()
InitLevel(cmdInfo);
});
#ifdef USE_WIP_FEATURES_MANAGER
// load the WIP features file
CWipFeatureManager::Instance()->EnableManager(!cmdInfo.m_bDeveloperMode);
CWipFeatureManager::Init();
#endif
if (!m_bConsoleMode && !m_bPreviewMode)
{
GetIEditor()->UpdateViews();
@@ -2130,13 +2121,6 @@ int CCryEditApp::ExitInstance(int exitCode)
}
qobject_cast<Editor::EditorQtApplication*>(qApp)->UnloadSettings();
#ifdef USE_WIP_FEATURES_MANAGER
//
// close wip features manager
//
CWipFeatureManager::Shutdown();
#endif
if (IsInRegularEditorMode())
{
if (GetIEditor())
@@ -2574,6 +2558,12 @@ void CCryEditApp::OnViewSwitchToGame()
GetIEditor()->SetInGameMode(inGame);
}
void CCryEditApp::OnViewSwitchToGameFullScreen()
{
ed_previewGameInFullscreen_once = true;
OnViewSwitchToGame();
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnExportSelectedObjects()
{
@@ -2617,17 +2607,11 @@ void CCryEditApp::OnUpdateSelected(QAction* action)
action->setEnabled(!GetIEditor()->GetSelection()->IsEmpty());
}
void CCryEditApp::OnShowHelpers()
{
GetIEditor()->GetDisplaySettings()->DisplayHelpers(!GetIEditor()->GetDisplaySettings()->IsDisplayHelpers());
GetIEditor()->Notify(eNotify_OnDisplayRenderUpdate);
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnEditLevelData()
{
auto dir = QFileInfo(GetIEditor()->GetDocument()->GetLevelPathName()).dir();
CFileUtil::EditTextFile(dir.absoluteFilePath("LevelData.xml").toUtf8().data());
CFileUtil::EditTextFile(dir.absoluteFilePath("leveldata.xml").toUtf8().data());
}
//////////////////////////////////////////////////////////////////////////
@@ -2636,13 +2620,14 @@ void CCryEditApp::OnFileEditLogFile()
CFileUtil::EditTextFile(CLogFile::GetLogFileName(), 0, IFileUtil::FILE_TYPE_SCRIPT);
}
#ifdef ENABLE_SLICE_EDITOR
void CCryEditApp::OnFileResaveSlices()
{
AZStd::vector<AZ::Data::AssetInfo> sliceAssetInfos;
sliceAssetInfos.reserve(5000);
AZ::Data::AssetCatalogRequests::AssetEnumerationCB sliceCountCb = [&sliceAssetInfos]([[maybe_unused]] const AZ::Data::AssetId id, const AZ::Data::AssetInfo& info)
{
// Only add slices and nothing that has been temporarily added to the catalog with a macro in it (ie @devroot@)
// Only add slices and nothing that has been temporarily added to the catalog with a macro in it (ie @engroot@)
if (info.m_assetType == azrtti_typeid<AZ::SliceAsset>() && info.m_relativePath[0] != '@')
{
sliceAssetInfos.push_back(info);
@@ -2766,6 +2751,7 @@ void CCryEditApp::OnFileResaveSlices()
}
}
#endif
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnFileEditEditorini()
@@ -2810,14 +2796,11 @@ void CCryEditApp::OpenProjectManager(const AZStd::string& screen)
{
// provide the current project path for in case we want to update the project
AZ::IO::FixedMaxPathString projectPath = AZ::Utils::GetProjectPath();
#if !AZ_TRAIT_OS_PLATFORM_APPLE && !AZ_TRAIT_OS_USE_WINDOWS_FILE_PATHS
const char* argumentQuoteString = R"(")";
#else
const char* argumentQuoteString = R"(\")";
#endif
const AZStd::string commandLineOptions = AZStd::string::format(R"( --screen %s --project-path %s%s%s)",
screen.c_str(),
argumentQuoteString, projectPath.c_str(), argumentQuoteString);
const AZStd::vector<AZStd::string> commandLineOptions {
"--screen", screen,
"--project-path", AZStd::string::format(R"("%s")", projectPath.c_str()) };
bool launchSuccess = AzFramework::ProjectManager::LaunchProjectManager(commandLineOptions);
if (!launchSuccess)
{
@@ -3019,6 +3002,15 @@ CCryEditApp::ECreateLevelResult CCryEditApp::CreateLevel(const QString& levelNam
bool bIsDocModified = GetIEditor()->GetDocument()->IsModified();
OnSwitchPhysics();
GetIEditor()->GetDocument()->SetModifiedFlag(bIsDocModified);
if (usePrefabSystemForLevels)
{
auto* rootSpawnableInterface = AzFramework::RootSpawnableInterface::Get();
if (rootSpawnableInterface)
{
rootSpawnableInterface->ProcessSpawnableQueue();
}
}
}
const QScopedValueRollback<bool> rollback(m_creatingNewLevel);
@@ -3352,13 +3344,17 @@ void CCryEditApp::OnOpenSlice()
}
//////////////////////////////////////////////////////////////////////////
CCryEditDoc* CCryEditApp::OpenDocumentFile(const char* lpszFileName)
CCryEditDoc* CCryEditApp::OpenDocumentFile(const char* filename, bool addToMostRecentFileList, COpenSameLevelOptions openSameLevelOptions)
{
if (m_openingLevel)
{
return GetIEditor()->GetDocument();
}
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
// If we are loading and we're in simulate mode, then switch it off before we do anything else
if (GetIEditor()->GetGameEngine() && GetIEditor()->GetGameEngine()->GetSimulationMode())
{
@@ -3366,6 +3362,15 @@ CCryEditDoc* CCryEditApp::OpenDocumentFile(const char* lpszFileName)
bool bIsDocModified = GetIEditor()->GetDocument()->IsModified();
OnSwitchPhysics();
GetIEditor()->GetDocument()->SetModifiedFlag(bIsDocModified);
if (usePrefabSystemForLevels)
{
auto* rootSpawnableInterface = AzFramework::RootSpawnableInterface::Get();
if (rootSpawnableInterface)
{
rootSpawnableInterface->ProcessSpawnableQueue();
}
}
}
// We're about to start loading a level, so start recording errors to display at the end.
@@ -3392,9 +3397,9 @@ CCryEditDoc* CCryEditApp::OpenDocumentFile(const char* lpszFileName)
openDocTraceHandler.SetShowWindow(false);
}
// in this case, we set bAddToMRU to always be true because adding files to the MRU list
// in this case, we set addToMostRecentFileList to always be true because adding files to the MRU list
// automatically culls duplicate and normalizes paths anyway
m_pDocManager->OpenDocumentFile(lpszFileName, true);
m_pDocManager->OpenDocumentFile(filename, addToMostRecentFileList, openSameLevelOptions);
if (openDocTraceHandler.HasAnyErrors())
{
@@ -3808,7 +3813,8 @@ void CCryEditApp::OnOpenQuickAccessBar()
}
QRect geo = m_pQuickAccessBar->geometry();
geo.moveCenter(MainWindow::instance()->geometry().center());
auto mainWindow = MainWindow::instance();
geo.moveCenter(mainWindow->mapToGlobal(mainWindow->geometry().center()));
m_pQuickAccessBar->setGeometry(geo);
m_pQuickAccessBar->setVisible(true);
m_pQuickAccessBar->setFocus();
@@ -3954,9 +3960,8 @@ void CCryEditApp::OpenLUAEditor(const char* files)
}
}
const char* engineRoot = nullptr;
AzFramework::ApplicationRequests::Bus::BroadcastResult(engineRoot, &AzFramework::ApplicationRequests::GetEngineRoot);
AZ_Assert(engineRoot != nullptr, "Unable to communicate to AzFramework::ApplicationRequests::Bus");
AZ::IO::FixedMaxPathString engineRoot = AZ::Utils::GetEnginePath();
AZ_Assert(!engineRoot.empty(), "Unable to query Engine Path");
AZStd::string_view exePath;
AZ::ComponentApplicationBus::BroadcastResult(exePath, &AZ::ComponentApplicationRequests::GetExecutableFolder);
@@ -3975,7 +3980,7 @@ void CCryEditApp::OpenLUAEditor(const char* files)
#endif
"%s", argumentQuoteString, aznumeric_cast<int>(exePath.size()), exePath.data(), argumentQuoteString);
AZStd::string processArgs = AZStd::string::format("%s -engine-path \"%s\"", args.c_str(), engineRoot);
AZStd::string processArgs = AZStd::string::format("%s -engine-path \"%s\"", args.c_str(), engineRoot.c_str());
StartProcessDetached(process.c_str(), processArgs.c_str());
}
@@ -4008,7 +4013,7 @@ void CCryEditApp::OnError(AzFramework::AssetSystem::AssetSystemErrors error)
break;
}
CryMessageBox(errorMessage.c_str(), "Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
QMessageBox::critical(nullptr,"Error",errorMessage.c_str());
}
void CCryEditApp::OnOpenProceduralMaterialEditor()
@@ -4121,9 +4126,17 @@ extern "C" int AZ_DLL_EXPORT CryEditMain(int argc, char* argv[])
Editor::EditorQtApplication::InstallQtLogHandler();
AzQtComponents::Utilities::HandleDpiAwareness(AzQtComponents::Utilities::SystemDpiAware);
Editor::EditorQtApplication app(argc, argv);
Editor::EditorQtApplication* app = Editor::EditorQtApplication::newInstance(argc, argv);
if (app.arguments().contains("-autotest_mode"))
QStringList qArgs = app->arguments();
const bool is_automated_test = AZStd::any_of(qArgs.begin(), qArgs.end(),
[](const QString& elem)
{
return elem.endsWith("autotest_mode") || elem.endsWith("runpythontest");
}
);
if (is_automated_test)
{
// Nullroute all stdout to null for automated tests, this way we make sure
// that the test result output is not polluted with unrelated output data.
@@ -4159,12 +4172,7 @@ extern "C" int AZ_DLL_EXPORT CryEditMain(int argc, char* argv[])
return -1;
}
AzToolsFramework::EditorEvents::Bus::Broadcast(&AzToolsFramework::EditorEvents::NotifyQtApplicationAvailable, &app);
#if defined(AZ_PLATFORM_MAC)
// Native menu bars do not work on macOS due to all the tool dialogs
QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
#endif
AzToolsFramework::EditorEvents::Bus::Broadcast(&AzToolsFramework::EditorEvents::NotifyQtApplicationAvailable, app);
int exitCode = 0;
@@ -4173,11 +4181,13 @@ extern "C" int AZ_DLL_EXPORT CryEditMain(int argc, char* argv[])
"\nThis could be because of incorrectly configured components, or missing required gems."
"\nSee other errors for more details.");
AzToolsFramework::EditorEventsBus::Broadcast(&AzToolsFramework::EditorEvents::NotifyEditorInitialized);
if (didCryEditStart)
{
app.EnableOnIdle();
app->EnableOnIdle();
ret = app.exec();
ret = app->exec();
}
else
{
@@ -4188,6 +4198,8 @@ extern "C" int AZ_DLL_EXPORT CryEditMain(int argc, char* argv[])
}
delete app;
gSettings.Disconnect();
return ret;
+13 -5
View File
@@ -14,7 +14,6 @@
#if !defined(Q_MOC_RUN)
#include <AzCore/Outcome/Outcome.h>
#include <AzFramework/Asset/AssetSystemBus.h>
#include "WipFeatureManager.h"
#include "CryEditDoc.h"
#include "ViewPane.h"
@@ -85,6 +84,12 @@ public:
using EditorIdleProcessingBus = AZ::EBus<EditorIdleProcessing>;
enum class COpenSameLevelOptions
{
ReopenLevelIfSame,
NotReopenIfSame
};
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
class SANDBOX_API CCryEditApp
@@ -174,7 +179,9 @@ public:
virtual bool InitInstance();
virtual int ExitInstance(int exitCode = 0);
virtual bool OnIdle(LONG lCount);
virtual CCryEditDoc* OpenDocumentFile(const char* lpszFileName);
virtual CCryEditDoc* OpenDocumentFile(const char* filename,
bool addToMostRecentFileList=true,
COpenSameLevelOptions openSameLevelOptions = COpenSameLevelOptions::NotReopenIfSame);
CCryDocManager* GetDocManager() { return m_pDocManager; }
@@ -204,6 +211,7 @@ public:
void OnEditFetch();
void OnFileExportToGameNoSurfaceTexture();
void OnViewSwitchToGame();
void OnViewSwitchToGameFullScreen();
void OnViewDeploy();
void DeleteSelectedEntities(bool includeDescendants);
void OnMoveObject();
@@ -228,7 +236,6 @@ public:
void OnSyncPlayerUpdate(QAction* action);
void OnResourcesReduceworkingset();
void OnDummyCommand() {};
void OnShowHelpers();
void OnFileSave();
void OnUpdateDocumentReady(QAction* action);
void OnUpdateFileOpen(QAction* action);
@@ -423,6 +430,7 @@ public:
class CCrySingleDocTemplate
: public QObject
{
Q_OBJECT
private:
explicit CCrySingleDocTemplate(const QMetaObject* pDocClass)
: QObject()
@@ -448,7 +456,7 @@ public:
~CCrySingleDocTemplate() {};
// avoid creating another CMainFrame
// close other type docs before opening any things
virtual CCryEditDoc* OpenDocumentFile(const char* lpszPathName, bool bAddToMRU, bool bMakeVisible);
virtual CCryEditDoc* OpenDocumentFile(const char* lpszPathName, bool addToMostRecentFileList, bool bMakeVisible);
virtual CCryEditDoc* OpenDocumentFile(const char* lpszPathName, bool bMakeVisible = TRUE);
virtual Confidence MatchDocType(const char* lpszPathName, CCryEditDoc*& rpDocMatch);
@@ -468,7 +476,7 @@ public:
virtual void OnFileNew();
virtual bool DoPromptFileName(QString& fileName, UINT nIDSTitle,
DWORD lFlags, bool bOpenFileDialog, CDocTemplate* pTemplate);
virtual CCryEditDoc* OpenDocumentFile(const char* lpszFileName, bool bAddToMRU);
virtual CCryEditDoc* OpenDocumentFile(const char* filename, bool addToMostRecentFileList, COpenSameLevelOptions openSameLevelOptions = COpenSameLevelOptions::NotReopenIfSame);
QVector<CCrySingleDocTemplate*> m_templateList;
};
+14 -71
View File
@@ -19,6 +19,7 @@
#include <AzCore/Component/TransformBus.h>
#include <AzCore/Asset/AssetManager.h>
#include <AzCore/Interface/Interface.h>
#include <AzCore/Time/ITime.h>
#include <AzCore/Utils/Utils.h>
#include <MathConversion.h>
@@ -44,13 +45,11 @@
#include "ActionManager.h"
#include "Include/IObjectManager.h"
#include "ErrorReportDialog.h"
#include "SurfaceTypeValidator.h"
#include "Util/AutoLogTime.h"
#include "CheckOutDialog.h"
#include "GameExporter.h"
#include "MainWindow.h"
#include "LevelFileDialog.h"
#include "StatObjBus.h"
#include "Undo/Undo.h"
#include <Atom/RPI.Public/ViewportContext.h>
@@ -60,15 +59,6 @@
#include <LmbrCentral/Audio/AudioSystemComponentBus.h>
#include <LmbrCentral/Rendering/EditorLightComponentBus.h> // for LmbrCentral::EditorLightComponentRequestBus
//#define PROFILE_LOADING_WITH_VTUNE
// profilers api.
//#include "pure.h"
#ifdef PROFILE_LOADING_WITH_VTUNE
#include "C:\Program Files\Intel\Vtune\Analyzer\Include\VTuneApi.h"
#pragma comment(lib,"C:\\Program Files\\Intel\\Vtune\\Analyzer\\Lib\\VTuneApi.lib")
#endif
static const char* kAutoBackupFolder = "_autobackup";
static const char* kHoldFolder = "$tmp_hold"; // conform to the ignored file types $tmp[0-9]*_ regex
static const char* kSaveBackupFolder = "_savebackup";
@@ -108,8 +98,7 @@ namespace Internal
// CCryEditDoc construction/destruction
CCryEditDoc::CCryEditDoc()
: doc_validate_surface_types(nullptr)
, m_modifiedModuleFlags(eModifiedNothing)
: m_modifiedModuleFlags(eModifiedNothing)
{
////////////////////////////////////////////////////////////////////////
// Set member variables to initial values
@@ -129,7 +118,6 @@ CCryEditDoc::CCryEditDoc()
GetIEditor()->SetDocument(this);
CLogFile::WriteLine("Document created");
RegisterConsoleVariables();
MainWindow::instance()->GetActionManager()->RegisterActionHandler(ID_FILE_SAVE_AS, this, &CCryEditDoc::OnFileSaveAs);
bool isPrefabSystemEnabled = false;
@@ -254,9 +242,6 @@ void CCryEditDoc::DeleteContents()
EBUS_EVENT(AzToolsFramework::EditorEntityContextRequestBus, ResetEditorContext);
// [LY-90904] move this to the EditorVegetationManager component
InstanceStatObjEventBus::Broadcast(&InstanceStatObjEventBus::Events::ReleaseData);
//////////////////////////////////////////////////////////////////////////
// Clear all undo info.
//////////////////////////////////////////////////////////////////////////
@@ -316,8 +301,6 @@ void CCryEditDoc::Save(TDocMultiArchive& arrXmlAr)
// Fog settings ///////////////////////////////////////////////////////
SerializeFogSettings((*arrXmlAr[DMAS_GENERAL]));
SerializeNameSelection((*arrXmlAr[DMAS_GENERAL]));
}
}
AfterSave();
@@ -408,9 +391,6 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
int t0 = GetTickCount();
#ifdef PROFILE_LOADING_WITH_VTUNE
VTResume();
#endif
// Load level-specific audio data.
AZStd::string levelFileName{ fileName.toUtf8().constData() };
AZStd::to_lower(levelFileName.begin(), levelFileName.end());
@@ -466,12 +446,6 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
}
}
if (!isPrefabEnabled)
{
// Name Selection groups
SerializeNameSelection((*arrXmlAr[DMAS_GENERAL]));
}
{
CAutoLogTime logtime("Post Load");
@@ -482,12 +456,6 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
}
}
CSurfaceTypeValidator().Validate();
#ifdef PROFILE_LOADING_WITH_VTUNE
VTPause();
#endif
LogLoadTime(GetTickCount() - t0);
// Loaded with success, remove event from log file
GetIEditor()->GetSettingsManager()->UnregisterEvent(loadEvent);
@@ -610,16 +578,6 @@ void CCryEditDoc::SerializeFogSettings(CXmlArchive& xmlAr)
}
}
void CCryEditDoc::SerializeNameSelection(CXmlArchive& xmlAr)
{
IObjectManager* pObjManager = GetIEditor()->GetObjectManager();
if (pObjManager)
{
pObjManager->SerializeNameSelection(xmlAr.root, xmlAr.bLoading);
}
}
void CCryEditDoc::SetModifiedModules(EModifiedModule eModifiedModule, bool boSet)
{
if (!boSet)
@@ -765,7 +723,9 @@ bool CCryEditDoc::OnOpenDocument(const QString& lpszPathName)
bool CCryEditDoc::BeforeOpenDocument(const QString& lpszPathName, TOpenDocContext& context)
{
CTimeValue loading_start_time = gEnv->pTimer->GetAsyncTime();
const AZ::TimeMs timeMs = AZ::GetRealElapsedTimeMs();
const double timeSec = AZ::TimeMsToSecondsDouble(timeMs);
const CTimeValue loading_start_time(timeSec);
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
@@ -806,7 +766,7 @@ bool CCryEditDoc::BeforeOpenDocument(const QString& lpszPathName, TOpenDocContex
bool CCryEditDoc::DoOpenDocument(TOpenDocContext& context)
{
CTimeValue& loading_start_time = context.loading_start_time;
const CTimeValue& loading_start_time = context.loading_start_time;
bool isPrefabEnabled = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(isPrefabEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
@@ -876,7 +836,9 @@ bool CCryEditDoc::DoOpenDocument(TOpenDocContext& context)
StartStreamingLoad();
CTimeValue loading_end_time = gEnv->pTimer->GetAsyncTime();
const AZ::TimeMs timeMs = AZ::GetRealElapsedTimeMs();
const double timeSec = AZ::TimeMsToSecondsDouble(timeMs);
const CTimeValue loading_end_time(timeSec);
CLogFile::FormatLine("-----------------------------------------------------------");
CLogFile::FormatLine("Successfully opened document %s", context.absoluteLevelPath.toUtf8().data());
@@ -1108,7 +1070,7 @@ bool CCryEditDoc::SaveLevel(const QString& filename)
if (QFileInfo(filename).isRelative())
{
// Resolving the path through resolvepath would normalize and lowcase it, and in this case, we don't want that.
fullPathName = Path::ToUnixPath(QDir(QString::fromUtf8(gEnv->pFileIO->GetAlias("@devassets@"))).absoluteFilePath(fullPathName));
fullPathName = Path::ToUnixPath(QDir(QString::fromUtf8(gEnv->pFileIO->GetAlias("@projectroot@"))).absoluteFilePath(fullPathName));
}
if (!CFileUtil::OverwriteFile(fullPathName))
@@ -1139,7 +1101,7 @@ bool CCryEditDoc::SaveLevel(const QString& filename)
const QString oldLevelPattern = QDir(oldLevelFolder).absoluteFilePath("*.*");
const QString oldLevelName = Path::GetFile(GetLevelPathName());
const QString oldLevelXml = Path::ReplaceExtension(oldLevelName, "xml");
AZ::IO::ArchiveFileIterator findHandle = pIPak->FindFirst(oldLevelPattern.toUtf8().data(), AZ::IO::IArchive::eFileSearchType_AllowOnDiskAndInZips);
AZ::IO::ArchiveFileIterator findHandle = pIPak->FindFirst(oldLevelPattern.toUtf8().data(), AZ::IO::FileSearchLocation::Any);
if (findHandle)
{
do
@@ -1273,7 +1235,7 @@ bool CCryEditDoc::SaveLevel(const QString& filename)
if (savedEntities)
{
AZ_PROFILE_SCOPE(AzToolsFramework, "CCryEditDoc::SaveLevel Updated PakFile levelEntities.editor_xml");
pakFile.UpdateFile("LevelEntities.editor_xml", entitySaveBuffer.begin(), static_cast<int>(entitySaveBuffer.size()));
pakFile.UpdateFile("levelentities.editor_xml", entitySaveBuffer.begin(), static_cast<int>(entitySaveBuffer.size()));
// Save XML archive to pak file.
bool bSaved = xmlAr.SaveToPak(Path::GetPath(tempSaveFile), pakFile);
@@ -1501,7 +1463,7 @@ bool CCryEditDoc::LoadEntitiesFromLevel(const QString& levelPakFile)
bool pakOpened = pakSystem->OpenPack(levelPakFile.toUtf8().data());
if (pakOpened)
{
const QString entityFilename = Path::GetPath(levelPakFile) + "LevelEntities.editor_xml";
const QString entityFilename = Path::GetPath(levelPakFile) + "levelentities.editor_xml";
CCryFile entitiesFile;
if (entitiesFile.Open(entityFilename.toUtf8().data(), "rt"))
@@ -1943,25 +1905,6 @@ void CCryEditDoc::SetDocumentReady(bool bReady)
m_bDocumentReady = bReady;
}
void CCryEditDoc::RegisterConsoleVariables()
{
doc_validate_surface_types = gEnv->pConsole->GetCVar("doc_validate_surface_types");
if (!doc_validate_surface_types)
{
doc_validate_surface_types = REGISTER_INT_CB("doc_validate_surface_types", 0, 0,
"Flag indicating whether icons are displayed on the animation graph.\n"
"Default is 1.\n",
OnValidateSurfaceTypesChanged);
}
}
void CCryEditDoc::OnValidateSurfaceTypesChanged(ICVar*)
{
CErrorsRecorder errorsRecorder(GetIEditor());
CSurfaceTypeValidator().Validate();
}
void CCryEditDoc::OnStartLevelResourceList()
{
// after loading another level we clear the RFOM_Level list, the first time the list should be empty
@@ -2159,7 +2102,7 @@ bool CCryEditDoc::LoadXmlArchiveArray(TDocMultiArchive& arrXmlAr, const QString&
xmlAr.bLoading = true;
// bound to the level folder, as if it were the assets folder.
// this mounts (whateverlevelname.ly) as @assets@/Levels/whateverlevelname/ and thus it works...
// this mounts (whateverlevelname.ly) as @products@/Levels/whateverlevelname/ and thus it works...
bool openLevelPakFileSuccess = pIPak->OpenPack(levelPath.toUtf8().data(), absoluteLevelPath.toUtf8().data());
if (!openLevelPakFileSuccess)
{
-7
View File
@@ -24,7 +24,6 @@
#include <IEditor.h>
#endif
class CClouds;
struct LightingSettings;
struct IVariable;
struct ICVar;
@@ -124,7 +123,6 @@ public: // Create from serialization only
const char* GetTemporaryLevelName() const;
void DeleteTemporaryLevel();
CClouds* GetClouds() { return m_pClouds; }
void SetWaterColor(const QColor& col) { m_waterColor = col; }
QColor GetWaterColor() const { return m_waterColor; }
XmlNodeRef& GetFogTemplate() { return m_fogTemplate; }
@@ -163,7 +161,6 @@ protected:
bool LoadEntitiesFromSlice(const QString& sliceFile);
void SerializeFogSettings(CXmlArchive& xmlAr);
virtual void SerializeViewSettings(CXmlArchive& xmlAr);
void SerializeNameSelection(CXmlArchive& xmlAr);
void LogLoadTime(int time) const;
struct TSaveDocContext
@@ -179,9 +176,7 @@ protected:
virtual void OnFileSaveAs();
//! called immediately after saving the level.
void AfterSave();
void RegisterConsoleVariables();
void OnStartLevelResourceList();
static void OnValidateSurfaceTypesChanged(ICVar*);
QString GetCryIndexPath(const char* levelFilePath) const;
@@ -195,10 +190,8 @@ protected:
QColor m_waterColor = QColor(0, 0, 255);
XmlNodeRef m_fogTemplate;
XmlNodeRef m_environmentTemplate;
CClouds* m_pClouds;
std::list<IDocListener*> m_listeners;
bool m_bDocumentReady = false;
ICVar* doc_validate_surface_types = nullptr;
int m_modifiedModuleFlags;
// On construction, it assumes loaded levels have already been exported. Can be a big fat lie, though.
// The right way would require us to save to the level folder the export status of the level.
-213
View File
@@ -1,213 +0,0 @@
⼯䴠捩潲潳瑦嘠獩慵⭃‫敧敮慲整⁤敲潳牵散猠牣灩⹴
椣据畬敤∠敲潳牵散栮
搣晥湩⁥偁呓䑕佉剟䅅佄䱎彙奓䉍䱏
⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯
⼯䜠湥牥瑡摥映潲桴⁥䕔员义䱃䑕⁅′敲潳牵散
椣据畬敤∠楷牮獥栮
椣据畬敤∠敲潳牵散栮
⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯
産摮晥䄠卐啔䥄彏䕒䑁乏奌卟䵙佂卌
⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯
⼯䔠杮楬桳⠠湕瑩摥匠慴整⥳爠獥畯捲獥
椣⁦搡晥湩摥䄨塆剟卅問䍒彅䱄⥌簠⁼敤楦敮⡤䙁彘䅔䝒䕟啎
䅌䝎䅕䕇䰠乁彇久䱇卉ⱈ匠䉕䅌䝎䕟䝎䥌䡓啟
椣摦晥䄠卐啔䥄彏义佖䕋
⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯
⼯吠塅䥔䍎啌䕄
′䕔员义䱃䑕⁅
䕂䥇
††⌢湩汣摵⁥∢楷牮獥栮∢牜湜
††⌢湩汣摵⁥∢敲潳牵散栮∢牜湜
††尢∰
″䕔员义䱃䑕⁅
䕂䥇
††尢屲≮
††尢∰
‱䕔员义䱃䑕⁅
䕂䥇
††爢獥畯捲⹥屨∰
攣摮晩††⼯䄠卐啔䥄彏义佖䕋
⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯
⼯䴠湥
䑉归䕍啎䱟噉䍅䕒呁⁅䕍啎
䕂䥇
††佐啐⁐☢楆敬
††䕂䥇
††††䕍啎呉䵅∠慓敶猠瑥楴杮≳‬†††††††䑉䙟䱉彅䅓䕖䕓呔义升
††††䕍啎呉䵅∠汃獯≥‬†††††††††††䑉䙟䱉彅䱃协彅䥌䕖剃䅅䕔噟䕉
††久
††佐啐⁐☢楖睥
††䕂䥇
††††䕍啎呉䵅∠楌敶牃慥整䰠杯敧≲‬†††††䑉噟䕉彗䥌䕖剃䅅䕔佌䝇剅‬䡃䍅䕋
††††䕍啎呉䵅∠楌敶牃慥整倠潲楦敬䔠楤潴≲‬†䑉噟䕉彗䥌䕖剃䅅䕔剐䙏䱉䕅䥄佔ⱒ䌠䕈䭃䑅
††††䕍啎呉䵅∠楌敶牃慥整䘠汩⁥祓据匠瑥楴杮≳‬䑉噟䕉彗䥌䕖剃䅅䕔䥆䕌奓䍎䕓呔义升‬䡃䍅䕋
††久
⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯
⼯䐠慩潬
䑉彄䥌䕖剃䅅䕔偟䍉䕋⁒䥄䱁䝏塅〠‬ⰰ㌠㘱‬㔲
呓䱙⁅卄卟呅但呎簠䐠当位䅄䙌䅒䕍簠䐠当䥆䕘卄卙簠圠当佐啐⁐⁼南䍟偁䥔乏簠圠当奓䵓久
䅃呐佉⁎匢汥捥⁴慧敭戠極摬搠物捥潴祲
但呎㠠‬䴢⁓桓汥汄≧‬〴ⰰ〠‬砰
䕂䥇
††䕄偆单䉈呕佔⁎†伢≋䤬佄ⱋ〲ⰰ㌲ⰸ〵ㄬ
††啐䡓啂呔乏†††䌢湡散≬䤬䍄乁䕃ⱌ㔲ⰹ㌲ⰸ〵ㄬ
††佃呎佒⁌††††∢䤬䍄䑟剉䍅佔奒呟䕒ⱅ匢獹牔敥楖睥㈳Ⱒ噔当䅈䉓呕佔华簠吠卖䡟十䥌䕎⁓⁼噔当䥌䕎䅓剔住⁔⁼噔当䡓坏䕓䅌坌奁⁓⁼南䉟剏䕄⁒⁼南䡟䍓佒䱌簠圠当䅔卂佔ⱐⰷⰷ〳ⰲ㈲
䑉彄䥌䕖剃䅅䕔䅟䑄呟剁䕇協䐠䅉佌䕇⁘ⰰ〠‬〵ⰰ㐠〰
呓䱙⁅卄卟呅但呎簠䐠当位䅄䙌䅒䕍簠䐠当䥆䕘卄卙簠䐠当䕃呎剅簠圠当佐啐⁐⁼南䍟偁䥔乏簠圠当奓䵓久
䅃呐佉⁎䐢獩潣敶⁲楌敶牃慥整琠牡敧獴
但呎㠠‬䴢⁓桓汥汄≧‬〴ⰰ〠‬砰
䕂䥇
††啐䡓啂呔乏†††刢晥敲桳Ⱒ䑉彃䕒剆卅ⱈⰸⰸ〷ㄬ
††啐䡓啂呔乏†††䄢摤挠獵潴⹭⸮Ⱒ䑉彃啂呔乏䅟䑄偟䕅ⱒ㈸㠬㜬ⰰ㠱
††佃呎佒⁌††††唢敳眠摩牥猠慥捲⁨戨潲摡慣瑳∩䤬䍄䍟䕈䭃䕟䅎䱂䑅∬畂瑴湯Ⱒ卂䅟呕䍏䕈䭃佂⁘⁼南呟䉁呓偏㈬㌳ㄬⰲ〲ⰰ〱
††佃呎佒⁌††††∢䤬䍄䱟卉彔䕐剅ⱓ堢偔敒潰瑲Ⱒ南呟䉁呓偏㠬㌬ⰲ㠴ⰴ㐳ⰲ南䕟彘呓呁䍉䑅䕇
††䕄偆单䉈呕佔⁎†唢敳猠汥捥整≤䤬佄ⱋ㠱ⰰ㜳ⰹ〷ㄬ
††啐䡓啂呔乏†††䌢湡散≬䤬䍄乁䕃ⱌ㔲ⰹ㜳ⰹ〷ㄬ
††啐䡓啂呔乏†††䄢摤戠⁹偉⸮∮䤬䍄䉟呕佔彎䑁彄䅍䕔䥒䱁ㄬ㜵㠬㜬ⰰ㠱
䑉彄䥌䕖剃䅅䕔偟䕅归䥌呓䐠䅉佌䕇⁘ⰰ〠‬㤳ⰵ㈠㌱
呓䱙⁅卄卟呅但呎簠䐠当䥆䕘卄卙簠䐠当䕃呎剅簠圠当䡃䱉⁄⁼南噟卉䉉䕌簠圠当佂䑒剅簠圠当奓䵓久
但呎㠠‬䴢⁓桓汥汄≧‬〴ⰰ〠‬砰
䕂䥇
††呌塅⁔†††††倢敥獲∺䤬䍄卟䅔䥔ⱃ㜱㈬ⰷ㈲㠬
††啐䡓啂呔乏†††䄢摤⸮∮䤬䍄䉟呕佔彎䑁彄䕐剅㔬ⰶ㐲㔬ⰶ㘱
††啐䡓啂呔乏†††䔢楤⹴⸮Ⱒ䑉彃啂呔乏䕟䥄彔䕐剅ㄬ㘱㈬ⰴ㘵ㄬ
††啐䡓啂呔乏†††刢浥癯≥䤬䍄䉟呕佔彎䕄䕌䕔偟䕅ⱒ㜱ⰶ㐲㔬ⰲ㘱
††䕄偆单䉈呕佔⁎†匢慴瑲䄠汬Ⱒ䑉彃啂呔乏卟䅔呒䅟䱌㐬㐬㐬ⰸ㘱
††啐䡓啂呔乏†††刢獥瑥䄠汬Ⱒ䑉彃啂呔乏剟卅呅䅟䱌ㄬ㘷㐬㔬ⰲ㘱
††啐䡓啂呔乏†††䘢牯散匠湹⁣汁≬䤬䍄䉟呕佔彎但䍒彅奓䍎䅟䱌㔬ⰶⰴ㘵ㄬ
††啐䡓啂呔乏†††䌢敬湡䄠汬Ⱒ䑉彃啂呔乏䍟䕌乁䅟䱌㈬㈳㐬㔬ⰲ㘱
††啐䡓啂呔乏†††匢牣敥獮潨⁴汁≬䤬䍄䉟呕佔彎䍓䕒久䡓呏䅟䱌ㄬ㘱㐬㔬ⰶ㘱
††佃呎佒⁌††††∢䤬䍄䱟卉彔䕐剅ⱓ堢偔敒潰瑲Ⱒ南呟䉁呓偏㐬㐬ⰴ㠳ⰶ㘱ⰴ南䕟彘呓呁䍉䑅䕇
††䡃䍅䉋塏††††䰢癩䍥敲瑡≥䤬䍄䉟呕佔彎久䉁䕌䱟噉䍅䕒呁ⱅ㠲ⰸⰴ㈵㌬ⰶ卂偟单䱈䭉⁅⁼卂䵟䱕䥔䥌䕎
††䡃䍅䉋塏††††匢湹屣䍮浡牥≡䤬䍄䉟呕佔彎䅃䕍䅒卟乙ⱃ㐳ⰵⰴ㈵㌬ⰶ卂偟单䱈䭉⁅⁼卂䵟䱕䥔䥌䕎
††啐䡓啂呔乏†††䐢獩潣敶≲䤬䍄䉟呕佔彎䥄䍓噏剅偟䕅卒㈬㈳㈬ⰴ㈵ㄬ
䑉彄䑉彄䥌䕖剃䅅䕔卟呅䥔䝎当䅐䕎⁌䥄䱁䝏塅〠‬ⰰㄠ㘵‬〲
呓䱙⁅卄卟呅但呎簠圠当䡃䱉
但呎㠠‬䴢⁓桓汥汄⁧∲‬〴ⰰ〠‬砰
䕂䥇
††啐䡓啂呔乏†††䄢摤琠牡敧獴⸮∮䤬䍄䉟呕佔彎䥄䍓噏剅偟䕅卒㐬㐬㠬ⰰ㘱
䑉彄䥌䕖剃䅅䕔䕟䥄彔佃乎䍅䥔乏䐠䅉佌䕇⁘ⰰ〠‬㠲ⰸㄠ㌸
呓䱙⁅卄卟呅但呎簠䐠当位䅄䙌䅒䕍簠䐠当䥆䕘卄卙簠圠当佐啐⁐⁼南䍟偁䥔乏簠圠当奓䵓久
䅃呐佉⁎䰢癩䍥敲瑡⁥潨瑳猠瑥楴杮≳
但呎㠠‬䴢⁓桓汥汄≧‬〴ⰰ〠‬砰
䕂䥇
††䕄偆单䉈呕佔⁎†伢≋䤬佄ⱋ㔱ⰸ㔱ⰴ㠵㈬
††啐䡓啂呔乏†††䌢湡散≬䤬䍄乁䕃ⱌ㈲ⰱ㔱ⰴ㠵㈬
††呌塅⁔†††††丢浡㩥Ⱒ䑉彃呓呁䍉ㄬⰶ㘴㈬ⰲ
††䑅呉䕔员††††䑉彃䑅呉呟剁䕇彔䅎䕍㐬ⰴ㐴ㄬ〰ㄬⰴ卅䅟呕䡏䍓佒䱌
††呌塅⁔†††††䤢㩐Ⱒ䑉彃呓呁䍉ㄬ㈵㐬ⰶ〱㠬
††佃呎佒⁌††††∢䤬䍄呟剁䕇彔偉䑁剄卅ⱓ匢獹偉摁牤獥㍳∲圬当䅔卂佔ⱐ㘱ⰸ㐴ㄬ〰ㄬ
††呌塅⁔†††††倢慬晴牯㩭Ⱒ䑉彃呓呁䍉㠬㈬ⰶ〳㠬
††呌塅⁔†††††䈢極摬瀠瑡⁨愨瑵浯瑡捩㨩Ⱒ䑉彃呓呁䍉ㄬⰹ㈱ⰰ㐷㠬
††啐䡓啂呔乏†††吢獥⁴偉Ⱒ䑉彃啂呔乏呟卅彔佃乎䍅䥔乏ㄬ㠶㘬ⰰ〱ⰰ㘱
††佃䉍䉏塏††††䑉彃佃䉍彏䱐呁但䵒㐬ⰴ㐲ㄬ〰㠬ⰸ䉃当剄偏佄乗䥌呓簠圠当卖剃䱏⁌⁼南呟䉁呓偏
††啐䡓啂呔乏†††刢獥癯敬渠浡⁥潴䤠≐䤬䍄䉟呕佔彎䕒剆卅彈偉㐬ⰴ〶ㄬ〰ㄬ
††佃呎佒⁌††††䔢慮汢⁥桴獩瀠敥≲䤬䍄䍟䕈䭃䕟䅎䱂䑅∬畂瑴湯Ⱒ卂䅟呕䍏䕈䭃佂⁘⁼南呟䉁呓偏㠬㠬㘬ⰷ〱
††則問䉐塏††††䈢極摬猠瑥楴杮≳䤬䍄卟䅔䥔ⱃⰷ〸㈬㈷㜬
††呌塅⁔†††††䈢極摬攠數畣慴汢㩥Ⱒ䑉彃呓呁䍉ㄬⰹ㈹㔬ⰶ
††啐䡓啂呔乏†††⸢⸮Ⱒ䑉彃啂呔乏偟䍉彋䅇䕍䑟剉䍅佔奒㈬㤴ㄬ㐰㈬ⰲ㐱
††䑅呉䕔员††††䑉彃䑅呉䉟䥕䑌剟住彔䅐䡔㈬ⰰ〱ⰴ㈲ⰶ㐱䔬当啁佔午剃䱏
††䑅呉䕔员††††䑉彃䑅呉䉟䥕䑌䕟䕘啃䅔䱂ⱅ〲ㄬㄳ㈬㤴ㄬⰴ卅䅟呕䡏䍓佒䱌
䑉彄䥌䕖剃䅅䕔呟十彋䅗呉䐠䅉佌䕇⁘ⰰ〠‬㌲ⰸ㐠
呓䱙⁅卄卟呅但呎簠䐠当位䅄䙌䅒䕍簠䐠当䥆䕘卄卙簠圠当佐啐⁐⁼南䍟偁䥔乏簠圠当奓䵓久
䅃呐佉⁎䐢慩潬≧
但呎㠠‬䴢⁓桓汥汄≧‬〴ⰰ〠‬砰
䕂䥇
††啐䡓啂呔乏†††䌢湡散≬䤬䍄乁䕃ⱌ㐹㈬ⰰ〵ㄬ
††呌塅⁔†††††匢慴楴≣䤬䍄呟十彋剐䝏䕒卓呟塅ⱔⰷⰷ㈲ⰴ
䑉彄䥌䕖剃䅅䕔䅟䑄䉟彙偉䐠䅉佌䕇⁘ⰰ〠‬㌱ⰷ㜠
呓䱙⁅卄卟呅但呎簠䐠当位䅄䙌䅒䕍簠䐠当䥆䕘卄卙簠圠当佐啐⁐⁼南䍟偁䥔乏簠圠当奓䵓久
䅃呐佉⁎䄢摤䰠癩䍥敲瑡⁥祢䤠≐
但呎㠠‬䴢⁓桓汥汄≧‬〴ⰰ〠‬砰
䕂䥇
††䕄偆单䉈呕佔⁎†伢≋䤬佄ⱋⰷ㠴㔬ⰸ〲
††啐䡓啂呔乏†††䌢湡散≬䤬䍄乁䕃ⱌㄷ㐬ⰸ㠵㈬
††呌塅⁔†††††䤢㩐Ⱒㄭ㤬ㄬⰲ〱㠬
††䑅呉䕔员††††䤠䍄呟剁䕇彔偉䑁剄卅ⱓ㔲ㄬⰰ〱ⰰ㔱圬当䅔卂佔
††啐䡓啂呔乏†††吢獥⁴偉Ⱒ䑉彃啂呔乏呟卅彔佃乎䍅䥔乏㈬ⰵ㜲ㄬ〰ㄬ
⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯
⼯䐠卅䝉䥎䙎
椣摦晥䄠卐啔䥄彏义佖䕋
啇䑉䱅义卅䐠卅䝉䥎䙎
䕂䥇
††䑉彄䥌䕖剃䅅䕔䅟䑄呟剁䕇協‬䥄䱁䝏
††䕂䥇
††久
††䑉彄䥌䕖剃䅅䕔䕟䥄彔佃乎䍅䥔乏‬䥄䱁䝏
††䕂䥇
††久
††䑉彄䥌䕖剃䅅䕔呟十彋䅗呉‬䥄䱁䝏
††䕂䥇
††††䕌呆䅍䝒义‬
††††䥒䡇䵔剁䥇ⱎ㈠ㄳ
††††佔䵐剁䥇ⱎ㜠
††††佂呔䵏䅍䝒义‬㐳
††久
††䑉彄䥌䕖剃䅅䕔䅟䑄䉟彙偉‬䥄䱁䝏
††䕂䥇
††久
攣摮晩††⼯䄠卐啔䥄彏义佖䕋
攣摮晩††⼯䔠杮楬桳⠠湕瑩摥匠慴整⥳爠獥畯捲獥
⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯
椣湦敤⁦偁呓䑕佉䥟噎䭏䑅
⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯
⼯䜠湥牥瑡摥映潲桴⁥䕔员义䱃䑕⁅″敲潳牵散
⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯⼯
攣摮晩††⼯渠瑯䄠卐啔䥄彏义佖䕋
+11 -13
View File
@@ -143,20 +143,11 @@ namespace
return false;
}
}
const bool addToMostRecentFileList = false;
auto newDocument = CCryEditApp::instance()->OpenDocumentFile(levelPath.toUtf8().data(),
addToMostRecentFileList, COpenSameLevelOptions::ReopenLevelIfSame);
auto previousDocument = GetIEditor()->GetDocument();
QString previousPathName = (previousDocument != nullptr) ? previousDocument->GetLevelPathName() : "";
auto newDocument = CCryEditApp::instance()->OpenDocumentFile(levelPath.toUtf8().data());
// the underlying document pointer doesn't change, so we can't check that; use the path name's instead
bool result = true;
if (newDocument == nullptr || newDocument->IsLevelLoadFailed() || (newDocument->GetLevelPathName() == previousPathName))
{
result = false;
}
return result;
return newDocument != nullptr && !newDocument->IsLevelLoadFailed();
}
bool PyOpenLevelNoPrompt(const char* pLevelName)
@@ -407,6 +398,11 @@ inline namespace Commands
{
return AZ::Debug::Trace::WaitForDebugger(timeoutSeconds);
}
AZStd::string PyGetFileAlias(AZStd::string alias)
{
return AZ::IO::FileIOBase::GetInstance()->GetAlias(alias.c_str());
}
}
namespace AzToolsFramework
@@ -457,6 +453,8 @@ namespace AzToolsFramework
addLegacyGeneral(behaviorContext->Method("attach_debugger", PyAttachDebugger, nullptr, "Prompts for attaching the debugger"));
addLegacyGeneral(behaviorContext->Method("wait_for_debugger", PyWaitForDebugger, behaviorContext->MakeDefaultValues(-1.f), "Pauses this thread execution until the debugger has been attached"));
addLegacyGeneral(behaviorContext->Method("get_file_alias", PyGetFileAlias, nullptr, "Retrieves path for IO alias"));
// this will put these methods into the 'azlmbr.legacy.checkout_dialog' module
auto addCheckoutDialog = [](AZ::BehaviorContext::GlobalMethodBuilder methodBuilder)
{
+1 -4
View File
@@ -12,8 +12,6 @@
// Notice : Refer to ViewportTitleDlg.cpp for a use case.
#ifndef CRYINCLUDE_EDITOR_CUSTOMRESOLUTIONDLG_H
#define CRYINCLUDE_EDITOR_CUSTOMRESOLUTIONDLG_H
#pragma once
#if !defined(Q_MOC_RUN)
@@ -28,6 +26,7 @@ namespace Ui
class CCustomResolutionDlg
: public QDialog
{
Q_OBJECT
public:
CCustomResolutionDlg(int w, int h, QWidget* pParent = nullptr);
~CCustomResolutionDlg();
@@ -42,5 +41,3 @@ protected:
QScopedPointer<Ui::CustomResolutionDlg> m_ui;
};
#endif // CRYINCLUDE_EDITOR_CUSTOMRESOLUTIONDLG_H
+3 -3
View File
@@ -211,9 +211,9 @@ public:
void Reset(QAction& action)
{
emit beginResetModel();
beginResetModel();
m_action = &action;
emit endResetModel();
endResetModel();
}
private:
@@ -266,7 +266,7 @@ QStringList CustomizeKeyboardDialog::BuildModels(QWidget* parent)
categories.append(category);
QMenu* menu = menuAction->menu();
m_menuActions[category] = GetAllActionsForMenu(menu, QStringLiteral(""));
m_menuActions[category] = GetAllActionsForMenu(menu, QString());
}
return categories;
+3 -3
View File
@@ -40,10 +40,10 @@ AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
namespace
{
// File name extension for python files
const QString s_kPythonFileNameSpec = "*.py";
const QString s_kPythonFileNameSpec("*.py");
// Tree root element name
const QString s_kRootElementName = "Python Scripts";
const QString s_kRootElementName("Python Scripts");
}
//////////////////////////////////////////////////////////////////////////
@@ -91,7 +91,7 @@ CPythonScriptsDialog::CPythonScriptsDialog(QWidget* parent)
{
AZ::IO::Path newSourcePath = jsonSourcePathPointer;
// Resolve any file aliases first - Do not use ResolvePath() as that assumes
// any relative path is underneath the @assets@ alias
// any relative path is underneath the @products@ alias
if (auto fileIoBase = AZ::IO::FileIOBase::GetInstance(); fileIoBase != nullptr)
{
AZ::IO::FixedMaxPath replacedAliasPath;
-71
View File
@@ -1,71 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "DimensionsDialog.h"
// Qt
#include <QButtonGroup>
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
#include <ui_DimensionsDialog.h>
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
/////////////////////////////////////////////////////////////////////////////
CDimensionsDialog::CDimensionsDialog(QWidget* pParent /*=nullptr*/)
: QDialog(pParent)
, m_group(new QButtonGroup(this))
, ui(new Ui::CDimensionsDialog)
{
ui->setupUi(this);
setWindowTitle(tr("Generate Terrain Texture"));
m_group->addButton(ui->Dim512, 512);
m_group->addButton(ui->Dim1024, 1024);
m_group->addButton(ui->Dim2048, 2048);
m_group->addButton(ui->Dim4096, 4096);
m_group->addButton(ui->Dim8192, 8192);
m_group->addButton(ui->Dim16384, 16384);
}
//////////////////////////////////////////////////////////////////////////
CDimensionsDialog::~CDimensionsDialog()
{
}
//////////////////////////////////////////////////////////////////////////
void CDimensionsDialog::SetDimensions(unsigned int iWidth)
{
////////////////////////////////////////////////////////////////////////
// Select a dimension option button in the dialog
////////////////////////////////////////////////////////////////////////
QAbstractButton* button = m_group->button(iWidth);
assert(button);
button->setChecked(true);
}
UINT CDimensionsDialog::GetDimensions()
{
////////////////////////////////////////////////////////////////////////
// Get the currently selected dimension option button in the dialog
////////////////////////////////////////////////////////////////////////
assert(m_group->checkedId() != -1);
return m_group->checkedId();
}
#include <moc_DimensionsDialog.cpp>
-47
View File
@@ -1,47 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#ifndef CRYINCLUDE_EDITOR_DIMENSIONSDIALOG_H
#define CRYINCLUDE_EDITOR_DIMENSIONSDIALOG_H
#if !defined(Q_MOC_RUN)
#include <QScopedPointer>
#include <QDialog>
#endif
class QButtonGroup;
namespace Ui {
class CDimensionsDialog;
}
class CDimensionsDialog
: public QDialog
{
Q_OBJECT
public:
CDimensionsDialog(QWidget* pParent = nullptr); // standard constructor
~CDimensionsDialog();
UINT GetDimensions();
void SetDimensions(unsigned int iWidth);
protected:
void UpdateData(bool fromUi = true); // DDX/DDV support
private:
QButtonGroup* m_group;
QScopedPointer<Ui::CDimensionsDialog> ui;
};
#endif // CRYINCLUDE_EDITOR_DIMENSIONSDIALOG_H
-120
View File
@@ -1,120 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CDimensionsDialog</class>
<widget class="QDialog" name="CDimensionsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>465</width>
<height>237</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="STATIC2">
<property name="title">
<string>Texture Dimensions (Texture Dimensions divided by Terrain Size = Texels per meter)</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="Dim512">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="text">
<string>512 x 512</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="Dim1024">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="text">
<string>1024 x 1024</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="Dim2048">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="text">
<string>2048 x 2048</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="Dim4096">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="text">
<string>4096 x 4096</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="Dim8192">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="text">
<string>8192 x 8192</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="Dim16384">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="text">
<string>16384 x 16384</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>CDimensionsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>77</x>
<y>294</y>
</hint>
<hint type="destinationlabel">
<x>7</x>
<y>296</y>
</hint>
</hints>
</connection>
</connections>
</ui>
-2
View File
@@ -68,8 +68,6 @@ void CDisplaySettings::SetObjectHideMask(int hideMask)
m_objectHideMask = hideMask;
gSettings.objectHideMask = m_objectHideMask;
GetIEditor()->Notify(eNotify_OnDisplayRenderUpdate);
};
//////////////////////////////////////////////////////////////////////////
-138
View File
@@ -1,138 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "DeepSelection.h"
// Editor
#include "Objects/BaseObject.h"
//! Functor for sorting selected objects on deep selection mode.
struct NearDistance
{
NearDistance(){}
bool operator()(const CDeepSelection::RayHitObject& lhs, const CDeepSelection::RayHitObject& rhs) const
{
return lhs.distance < rhs.distance;
}
};
//-----------------------------------------------------------------------------
CDeepSelection::CDeepSelection()
: m_Mode(DSM_NONE)
, m_previousMode(DSM_NONE)
, m_CandidateObjectCount(0)
, m_CurrentSelectedPos(-1)
{
m_LastPickPoint = QPoint(-1, -1);
}
//-----------------------------------------------------------------------------
CDeepSelection::~CDeepSelection()
{
}
//-----------------------------------------------------------------------------
void CDeepSelection::Reset(bool bResetLastPick)
{
for (int i = 0; i < m_CandidateObjectCount; ++i)
{
m_RayHitObjects[i].object->ClearFlags(OBJFLAG_NO_HITTEST);
}
m_CandidateObjectCount = 0;
m_CurrentSelectedPos = -1;
m_RayHitObjects.clear();
if (bResetLastPick)
{
m_LastPickPoint = QPoint(-1, -1);
}
}
//-----------------------------------------------------------------------------
void CDeepSelection::AddObject(float distance, CBaseObject* pObj)
{
m_RayHitObjects.push_back(RayHitObject(distance, pObj));
}
//-----------------------------------------------------------------------------
bool CDeepSelection::OnCycling (const QPoint& pt)
{
QPoint diff = m_LastPickPoint - pt;
LONG epsilon = 2;
m_LastPickPoint = pt;
if (abs(diff.x()) < epsilon && abs(diff.y()) < epsilon)
{
return true;
}
else
{
return false;
}
}
//-----------------------------------------------------------------------------
void CDeepSelection::ExcludeHitTest(int except)
{
int nExcept = except % m_CandidateObjectCount;
for (int i = 0; i < m_CandidateObjectCount; ++i)
{
m_RayHitObjects[i].object->SetFlags(OBJFLAG_NO_HITTEST);
}
m_RayHitObjects[nExcept].object->ClearFlags(OBJFLAG_NO_HITTEST);
}
//-----------------------------------------------------------------------------
int CDeepSelection::CollectCandidate(float fMinDistance, float fRange)
{
m_CandidateObjectCount = 0;
if (!m_RayHitObjects.empty())
{
std::sort(m_RayHitObjects.begin(), m_RayHitObjects.end(), NearDistance());
for (std::vector<CDeepSelection::RayHitObject>::iterator itr = m_RayHitObjects.begin();
itr != m_RayHitObjects.end(); ++itr)
{
if (itr->distance - fMinDistance < fRange)
{
++m_CandidateObjectCount;
}
else
{
break;
}
}
}
return m_CandidateObjectCount;
}
//-----------------------------------------------------------------------------
CBaseObject* CDeepSelection::GetCandidateObject(int index)
{
m_CurrentSelectedPos = index % m_CandidateObjectCount;
return m_RayHitObjects[m_CurrentSelectedPos].object;
}
//-----------------------------------------------------------------------------
//!
void CDeepSelection::SetMode(EDeepSelectionMode mode)
{
m_previousMode = m_Mode;
m_Mode = mode;
}
-87
View File
@@ -1,87 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description : Deep Selection Header
#ifndef CRYINCLUDE_EDITOR_EDITMODE_DEEPSELECTION_H
#define CRYINCLUDE_EDITOR_EDITMODE_DEEPSELECTION_H
#pragma once
class CBaseObject;
//! Deep Selection
//! Additional output information of HitContext on using "deep selection mode".
//! At the deep selection mode, it supports second selection pass for easy
//! selection on crowded area with two different method.
//! One is to show pop menu of candidate objects list. Another is the cyclic
//! selection on pick clicking.
class CDeepSelection
: public _i_reference_target_t
{
public:
//! Deep Selection Mode Definition
enum EDeepSelectionMode
{
DSM_NONE = 0, // Not using deep selection.
DSM_POP = 1, // Deep selection mode with pop context menu.
DSM_CYCLE = 2 // Deep selection mode with cyclic selection on each clinking same point.
};
//! Subclass for container of the selected object with hit distance.
struct RayHitObject
{
RayHitObject(float dist, CBaseObject* pObj)
: distance(dist)
, object(pObj)
{
}
float distance;
CBaseObject* object;
};
//! Constructor
CDeepSelection();
virtual ~CDeepSelection();
void Reset(bool bResetLastPick = false);
void AddObject(float distance, CBaseObject* pObj);
//! Check if clicking point is same position with last position,
//! to decide whether to continue cycling mode.
bool OnCycling (const QPoint& pt);
//! All objects in list are excluded for hitting test except one, current selection.
void ExcludeHitTest(int except);
void SetMode(EDeepSelectionMode mode);
inline EDeepSelectionMode GetMode() const { return m_Mode; }
inline EDeepSelectionMode GetPreviousMode() const { return m_previousMode; }
//! Collect object in the deep selection range. The distance from the minimum
//! distance is less than deep selection range.
int CollectCandidate(float fMinDistance, float fRange);
//! Return the candidate object in index position, then it is to be current
//! selection position.
CBaseObject* GetCandidateObject(int index);
//! Return the current selection position that is update in "GetCandidateObject"
//! function call.
inline int GetCurrentSelectPos() const { return m_CurrentSelectedPos; }
//! Return the number of objects in the deep selection range.
inline int GetCandidateObjectCount() const { return m_CandidateObjectCount; }
private:
//! Current mode
EDeepSelectionMode m_Mode;
EDeepSelectionMode m_previousMode;
//! Last picking point to check whether cyclic selection continue.
QPoint m_LastPickPoint;
//! List of the selected objects with ray hitting
std::vector<RayHitObject> m_RayHitObjects;
int m_CandidateObjectCount;
int m_CurrentSelectedPos;
};
#endif // CRYINCLUDE_EDITOR_EDITMODE_DEEPSELECTION_H
-1
View File
@@ -105,7 +105,6 @@
#include <CryFile.h>
#include <ISystem.h>
#include <IIndexedMesh.h>
#include <ITimer.h>
#include <IXml.h>
#include <IMovieSystem.h>
+1 -1
View File
@@ -17,7 +17,7 @@ void SetEditorEnvironment(SSystemGlobalEnvironment* pEnv)
void AttachEditorAZEnvironment(AZ::EnvironmentInstance azEnv)
{
AZ::Environment::Attach(azEnv, true);
AZ::Environment::Attach(azEnv);
}
void DetachEditorAZEnvironment()
+11 -25
View File
@@ -14,6 +14,8 @@
// Editor
#include "CryEdit.h"
#include <AzCore/Utils/Utils.h>
//////////////////////////////////////////////////////////////////////////
CEditorFileMonitor::CEditorFileMonitor()
{
@@ -177,26 +179,14 @@ void CEditorFileMonitor::OnFileMonitorChange(const SFileChangeInfo& rChange)
// Make file relative to PrimaryCD folder.
QString filename = rChange.filename;
// Remove game directory if present in path.
const QString rootPath =
QDir::fromNativeSeparators(QString::fromLatin1(Path::GetEditingRootFolder().c_str()));
if (filename.startsWith(rootPath, Qt::CaseInsensitive))
{
filename = filename.right(filename.length() - rootPath.length());
}
// Make path relative to the the project directory
AZ::IO::Path projectPath{ AZ::Utils::GetProjectPath() };
AZ::IO::FixedMaxPath projectRelativeFilePath = AZ::IO::PathView(filename.toUtf8().constData()).LexicallyProximate(
projectPath);
// Make sure there is no leading slash
if (!filename.isEmpty() && (filename[0] == '\\' || filename[0] == '/'))
if (!projectRelativeFilePath.empty())
{
filename = filename.mid(1);
}
if (!filename.isEmpty())
{
//remove game name. Make it relative to the game folder
const QString filenameRelGame = RemoveGameName(filename);
const int extIndex = filename.lastIndexOf('.');
const QString ext = filename.right(filename.length() - 1 - extIndex);
AZ::IO::PathView ext = projectRelativeFilePath.Extension();
// Check for File Monitor callback
std::vector<SFileChangeCallback>::iterator iter;
@@ -207,15 +197,11 @@ void CEditorFileMonitor::OnFileMonitorChange(const SFileChangeInfo& rChange)
// We compare against length of callback string, so we get directory matches as well as full filenames
if (sCallback.pListener)
{
if (sCallback.extension == "*" || ext.compare(sCallback.extension, Qt::CaseInsensitive) == 0)
if (sCallback.extension == "*" || AZ::IO::PathView(sCallback.extension.toUtf8().constData()) == ext)
{
if (filenameRelGame.compare(sCallback.item, Qt::CaseInsensitive) == 0)
if (AZ::IO::PathView(sCallback.item.toUtf8().constData()) == projectRelativeFilePath)
{
sCallback.pListener->OnFileChange(qPrintable(filenameRelGame), IFileChangeListener::EChangeType(rChange.changeType));
}
else if (filename.compare(sCallback.item, Qt::CaseInsensitive) == 0)
{
sCallback.pListener->OnFileChange(qPrintable(filename), IFileChangeListener::EChangeType(rChange.changeType));
sCallback.pListener->OnFileChange(qPrintable(projectRelativeFilePath.c_str()), IFileChangeListener::EChangeType(rChange.changeType));
}
}
}
@@ -13,8 +13,32 @@
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzFramework/Render/IntersectorInterface.h>
#include <AzToolsFramework/Viewport/ViewportMessages.h>
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
#include <AzToolsFramework/ViewportSelection/EditorTransformComponentSelectionRequestBus.h>
#include <EditorViewportSettings.h>
AZ_CVAR(
bool,
ed_cameraPinDefaultOrbit,
true,
nullptr,
AZ::ConsoleFunctorFlags::Null,
"Sets whether the default orbit point moves with the camera or not");
AZ_CVAR(
bool,
ed_cameraDefaultOrbitAxesOrtho,
true,
nullptr,
AZ::ConsoleFunctorFlags::Null,
"Sets whether to draw the default orbit point as orthographic or not");
AZ_CVAR(
float,
ed_cameraDefaultOrbitFadeDuration,
0.5f,
nullptr,
AZ::ConsoleFunctorFlags::Null,
"Sets how long the default orbit point should take to appear and disappear");
namespace SandboxEditor
{
static AzFramework::TranslateCameraInputChannelIds BuildTranslateCameraInputChannelIds()
@@ -94,6 +118,7 @@ namespace SandboxEditor
cameras.AddCamera(m_firstPersonPanCamera);
cameras.AddCamera(m_firstPersonTranslateCamera);
cameras.AddCamera(m_firstPersonScrollCamera);
cameras.AddCamera(m_firstPersonFocusCamera);
cameras.AddCamera(m_orbitCamera);
});
@@ -110,6 +135,7 @@ namespace SandboxEditor
viewportId, &AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Events::BeginCursorCapture);
}
};
const auto showCursor = [viewportId = m_viewportId]
{
if (SandboxEditor::CameraCaptureCursorForLook())
@@ -119,6 +145,15 @@ namespace SandboxEditor
}
};
const auto trackingTransform = [viewportId = m_viewportId]
{
bool tracking = false;
AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
tracking, viewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::IsTrackingTransform);
return tracking;
};
m_firstPersonRotateCamera = AZStd::make_shared<AzFramework::RotateCameraInput>(SandboxEditor::CameraFreeLookChannelId());
m_firstPersonRotateCamera->m_rotateSpeedFn = []
@@ -126,13 +161,18 @@ namespace SandboxEditor
return SandboxEditor::CameraRotateSpeed();
};
m_firstPersonRotateCamera->m_constrainPitch = [trackingTransform]
{
return !trackingTransform();
};
// default behavior is to hide the cursor but this can be disabled (useful for remote desktop)
// note: See CaptureCursorLook in the Settings Registry
m_firstPersonRotateCamera->SetActivationBeganFn(hideCursor);
m_firstPersonRotateCamera->SetActivationEndedFn(showCursor);
m_firstPersonPanCamera =
AZStd::make_shared<AzFramework::PanCameraInput>(SandboxEditor::CameraFreePanChannelId(), AzFramework::LookPan);
m_firstPersonPanCamera = AZStd::make_shared<AzFramework::PanCameraInput>(
SandboxEditor::CameraFreePanChannelId(), AzFramework::LookPan, AzFramework::TranslatePivotLook);
m_firstPersonPanCamera->m_panSpeedFn = []
{
@@ -151,8 +191,8 @@ namespace SandboxEditor
const auto translateCameraInputChannelIds = BuildTranslateCameraInputChannelIds();
m_firstPersonTranslateCamera =
AZStd::make_shared<AzFramework::TranslateCameraInput>(AzFramework::LookTranslation, translateCameraInputChannelIds);
m_firstPersonTranslateCamera = AZStd::make_shared<AzFramework::TranslateCameraInput>(
translateCameraInputChannelIds, AzFramework::LookTranslation, AzFramework::TranslatePivotLook);
m_firstPersonTranslateCamera->m_translateSpeedFn = []
{
@@ -164,49 +204,57 @@ namespace SandboxEditor
return SandboxEditor::CameraBoostMultiplier();
};
m_firstPersonScrollCamera = AZStd::make_shared<AzFramework::ScrollTranslationCameraInput>();
m_firstPersonScrollCamera = AZStd::make_shared<AzFramework::LookScrollTranslationCameraInput>();
m_firstPersonScrollCamera->m_scrollSpeedFn = []
{
return SandboxEditor::CameraScrollSpeed();
};
const auto pivotFn = []() -> AZStd::optional<AZ::Vector3>
{
// use the manipulator transform as the pivot point
AZStd::optional<AZ::Transform> entityPivot;
AzToolsFramework::EditorTransformComponentSelectionRequestBus::EventResult(
entityPivot, AzToolsFramework::GetEntityContextId(),
&AzToolsFramework::EditorTransformComponentSelectionRequestBus::Events::GetManipulatorTransform);
if (entityPivot.has_value())
{
return entityPivot->GetTranslation();
}
return AZStd::nullopt;
};
m_firstPersonFocusCamera =
AZStd::make_shared<AzFramework::FocusCameraInput>(SandboxEditor::CameraFocusChannelId(), AzFramework::FocusLook);
m_firstPersonFocusCamera->SetPivotFn(pivotFn);
m_orbitCamera = AZStd::make_shared<AzFramework::OrbitCameraInput>(SandboxEditor::CameraOrbitChannelId());
m_orbitCamera->SetLookAtFn(
[viewportId = m_viewportId](const AZ::Vector3& position, const AZ::Vector3& direction) -> AZStd::optional<AZ::Vector3>
m_orbitCamera->SetPivotFn(
[this, pivotFn](const AZ::Vector3& position, const AZ::Vector3& direction)
{
AZStd::optional<AZ::Vector3> lookAtAfterInterpolation;
AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
lookAtAfterInterpolation, viewportId,
&AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::LookAtAfterInterpolation);
// initially attempt to use the last set look at point after an interpolation has finished
if (lookAtAfterInterpolation.has_value())
// return the pivot
if (auto pivot = pivotFn())
{
return *lookAtAfterInterpolation;
return pivot.value();
}
const float RayDistance = 1000.0f;
AzFramework::RenderGeometry::RayRequest ray;
ray.m_startWorldPosition = position;
ray.m_endWorldPosition = position + direction * RayDistance;
ray.m_onlyVisible = true;
// start ticking and drawing (for the default pivot)
AZ::TickBus::Handler::BusConnect();
AzFramework::ViewportDebugDisplayEventBus::Handler::BusConnect(AzToolsFramework::GetEntityContextId());
AzFramework::RenderGeometry::RayResult renderGeometryIntersectionResult;
AzFramework::RenderGeometry::IntersectorBus::EventResult(
renderGeometryIntersectionResult, AzToolsFramework::GetEntityContextId(),
&AzFramework::RenderGeometry::IntersectorBus::Events::RayIntersect, ray);
// attempt a ray intersection with any visible mesh and return the intersection position if successful
if (renderGeometryIntersectionResult)
m_defaultOrbiting = true;
// calculate the default orbit point
if (!ed_cameraPinDefaultOrbit || m_orbitCamera->Beginning())
{
return renderGeometryIntersectionResult.m_worldPosition;
m_defaultOrbitPoint = position + direction * SandboxEditor::CameraDefaultOrbitDistance();
}
// if there is no selection or no intersection, fallback to default camera orbit behavior (ground plane
// intersection)
return {};
return m_defaultOrbitPoint;
});
m_orbitRotateCamera = AZStd::make_shared<AzFramework::RotateCameraInput>(SandboxEditor::CameraOrbitLookChannelId());
@@ -221,8 +269,13 @@ namespace SandboxEditor
return SandboxEditor::CameraOrbitYawRotationInverted();
};
m_orbitTranslateCamera =
AZStd::make_shared<AzFramework::TranslateCameraInput>(AzFramework::OrbitTranslation, translateCameraInputChannelIds);
m_orbitRotateCamera->m_constrainPitch = [trackingTransform]
{
return !trackingTransform();
};
m_orbitTranslateCamera = AZStd::make_shared<AzFramework::TranslateCameraInput>(
translateCameraInputChannelIds, AzFramework::LookTranslation, AzFramework::TranslateOffsetOrbit);
m_orbitTranslateCamera->m_translateSpeedFn = []
{
@@ -241,15 +294,15 @@ namespace SandboxEditor
return SandboxEditor::CameraScrollSpeed();
};
m_orbitDollyMoveCamera =
AZStd::make_shared<AzFramework::OrbitDollyCursorMoveCameraInput>(SandboxEditor::CameraOrbitDollyChannelId());
m_orbitDollyMoveCamera = AZStd::make_shared<AzFramework::OrbitDollyMotionCameraInput>(SandboxEditor::CameraOrbitDollyChannelId());
m_orbitDollyMoveCamera->m_cursorSpeedFn = []
m_orbitDollyMoveCamera->m_motionSpeedFn = []
{
return SandboxEditor::CameraDollyMotionSpeed();
};
m_orbitPanCamera = AZStd::make_shared<AzFramework::PanCameraInput>(SandboxEditor::CameraOrbitPanChannelId(), AzFramework::OrbitPan);
m_orbitPanCamera = AZStd::make_shared<AzFramework::PanCameraInput>(
SandboxEditor::CameraOrbitPanChannelId(), AzFramework::LookPan, AzFramework::TranslateOffsetOrbit);
m_orbitPanCamera->m_panSpeedFn = []
{
@@ -266,25 +319,33 @@ namespace SandboxEditor
return SandboxEditor::CameraPanInvertedY();
};
m_orbitFocusCamera =
AZStd::make_shared<AzFramework::FocusCameraInput>(SandboxEditor::CameraFocusChannelId(), AzFramework::FocusOrbit);
m_orbitFocusCamera->SetPivotFn(pivotFn);
m_orbitCamera->m_orbitCameras.AddCamera(m_orbitRotateCamera);
m_orbitCamera->m_orbitCameras.AddCamera(m_orbitTranslateCamera);
m_orbitCamera->m_orbitCameras.AddCamera(m_orbitDollyScrollCamera);
m_orbitCamera->m_orbitCameras.AddCamera(m_orbitDollyMoveCamera);
m_orbitCamera->m_orbitCameras.AddCamera(m_orbitPanCamera);
m_orbitCamera->m_orbitCameras.AddCamera(m_orbitFocusCamera);
}
void EditorModularViewportCameraComposer::OnEditorModularViewportCameraComposerSettingsChanged()
{
const auto translateCameraInputChannelIds = BuildTranslateCameraInputChannelIds();
m_firstPersonTranslateCamera->SetTranslateCameraInputChannelIds(translateCameraInputChannelIds);
m_orbitTranslateCamera->SetTranslateCameraInputChannelIds(translateCameraInputChannelIds);
m_firstPersonPanCamera->SetPanInputChannelId(SandboxEditor::CameraFreePanChannelId());
m_orbitPanCamera->SetPanInputChannelId(SandboxEditor::CameraOrbitPanChannelId());
m_firstPersonRotateCamera->SetRotateInputChannelId(SandboxEditor::CameraFreeLookChannelId());
m_orbitRotateCamera->SetRotateInputChannelId(SandboxEditor::CameraOrbitLookChannelId());
m_firstPersonFocusCamera->SetFocusInputChannelId(SandboxEditor::CameraFocusChannelId());
m_orbitCamera->SetOrbitInputChannelId(SandboxEditor::CameraOrbitChannelId());
m_orbitTranslateCamera->SetTranslateCameraInputChannelIds(translateCameraInputChannelIds);
m_orbitPanCamera->SetPanInputChannelId(SandboxEditor::CameraOrbitPanChannelId());
m_orbitRotateCamera->SetRotateInputChannelId(SandboxEditor::CameraOrbitLookChannelId());
m_orbitDollyMoveCamera->SetDollyInputChannelId(SandboxEditor::CameraOrbitDollyChannelId());
m_orbitFocusCamera->SetFocusInputChannelId(SandboxEditor::CameraFocusChannelId());
}
void EditorModularViewportCameraComposer::OnViewportViewEntityChanged(const AZ::EntityId& viewEntityId)
@@ -295,13 +356,78 @@ namespace SandboxEditor
AZ::TransformBus::EventResult(worldFromLocal, viewEntityId, &AZ::TransformBus::Events::GetWorldTM);
AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event(
m_viewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::SetReferenceFrame,
m_viewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::StartTrackingTransform,
worldFromLocal);
}
else
{
AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event(
m_viewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::ClearReferenceFrame);
m_viewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::StopTrackingTransform);
}
}
void EditorModularViewportCameraComposer::OnTick(const float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time)
{
const float delta = [duration = &ed_cameraDefaultOrbitFadeDuration, deltaTime]
{
if (*duration == 0.0f)
{
return 1.0f;
}
return deltaTime / *duration;
}();
if (m_defaultOrbiting)
{
m_defaultOrbitOpacity = AZStd::min(m_defaultOrbitOpacity + delta, 1.0f);
}
else
{
m_defaultOrbitOpacity = AZStd::max(m_defaultOrbitOpacity - delta, 0.0f);
if (m_defaultOrbitOpacity == 0.0f)
{
AZ::TickBus::Handler::BusDisconnect();
AzFramework::ViewportDebugDisplayEventBus::Handler::BusDisconnect();
}
}
m_defaultOrbiting = false;
}
static void DrawTransformAxis(
AzFramework::DebugDisplayRequests& display,
const AzFramework::CameraState& cameraState,
const AZ::Vector3& pivot,
const float axisLength,
const float alpha)
{
const int prevState = display.GetState();
display.DepthWriteOff();
display.DepthTestOff();
display.CullOff();
const float orthoScale =
ed_cameraDefaultOrbitAxesOrtho ? AzToolsFramework::CalculateScreenToWorldMultiplier(pivot, cameraState) : 1.0f;
display.SetColor(AZ::Color::CreateFromVector3AndFloat(AZ::Colors::Red.GetAsVector3(), alpha));
display.DrawLine(pivot, pivot + AZ::Vector3::CreateAxisX() * axisLength * orthoScale);
display.SetColor(AZ::Color::CreateFromVector3AndFloat(AZ::Colors::LawnGreen.GetAsVector3(), alpha));
display.DrawLine(pivot, pivot + AZ::Vector3::CreateAxisY() * axisLength * orthoScale);
display.SetColor(AZ::Color::CreateFromVector3AndFloat(AZ::Colors::Blue.GetAsVector3(), alpha));
display.DrawLine(pivot, pivot + AZ::Vector3::CreateAxisZ() * axisLength * orthoScale);
display.DepthWriteOn();
display.DepthTestOn();
display.CullOn();
display.SetState(prevState);
}
void EditorModularViewportCameraComposer::DisplayViewport(
[[maybe_unused]] const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay)
{
DrawTransformAxis(
debugDisplay, AzToolsFramework::GetCameraState(viewportInfo.m_viewportId), m_defaultOrbitPoint, 1.0f, m_defaultOrbitOpacity);
}
} // namespace SandboxEditor
@@ -9,6 +9,8 @@
#pragma once
#include <AtomToolsFramework/Viewport/ModularViewportCameraController.h>
#include <AzCore/Component/TickBus.h>
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
#include <AzFramework/Viewport/CameraInput.h>
#include <AzToolsFramework/API/EditorCameraBus.h>
#include <EditorModularViewportCameraComposerBus.h>
@@ -20,6 +22,8 @@ namespace SandboxEditor
class EditorModularViewportCameraComposer
: private EditorModularViewportCameraComposerNotificationBus::Handler
, private Camera::EditorCameraNotificationBus::Handler
, private AzFramework::ViewportDebugDisplayEventBus::Handler
, private AZ::TickBus::Handler
{
public:
SANDBOX_API explicit EditorModularViewportCameraComposer(AzFramework::ViewportId viewportId);
@@ -29,6 +33,12 @@ namespace SandboxEditor
SANDBOX_API AZStd::shared_ptr<AtomToolsFramework::ModularViewportCameraController> CreateModularViewportCameraController();
private:
// AzFramework::ViewportDebugDisplayEventBus overrides ...
void DisplayViewport(const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay) override;
// AZ::TickBus overrides ...
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
//! Setup all internal camera inputs.
void SetupCameras();
@@ -41,14 +51,20 @@ namespace SandboxEditor
AZStd::shared_ptr<AzFramework::RotateCameraInput> m_firstPersonRotateCamera;
AZStd::shared_ptr<AzFramework::PanCameraInput> m_firstPersonPanCamera;
AZStd::shared_ptr<AzFramework::TranslateCameraInput> m_firstPersonTranslateCamera;
AZStd::shared_ptr<AzFramework::ScrollTranslationCameraInput> m_firstPersonScrollCamera;
AZStd::shared_ptr<AzFramework::LookScrollTranslationCameraInput> m_firstPersonScrollCamera;
AZStd::shared_ptr<AzFramework::FocusCameraInput> m_firstPersonFocusCamera;
AZStd::shared_ptr<AzFramework::OrbitCameraInput> m_orbitCamera;
AZStd::shared_ptr<AzFramework::RotateCameraInput> m_orbitRotateCamera;
AZStd::shared_ptr<AzFramework::TranslateCameraInput> m_orbitTranslateCamera;
AZStd::shared_ptr<AzFramework::OrbitDollyScrollCameraInput> m_orbitDollyScrollCamera;
AZStd::shared_ptr<AzFramework::OrbitDollyCursorMoveCameraInput> m_orbitDollyMoveCamera;
AZStd::shared_ptr<AzFramework::OrbitDollyMotionCameraInput> m_orbitDollyMoveCamera;
AZStd::shared_ptr<AzFramework::PanCameraInput> m_orbitPanCamera;
AZStd::shared_ptr<AzFramework::FocusCameraInput> m_orbitFocusCamera;
AzFramework::ViewportId m_viewportId;
float m_defaultOrbitOpacity = 0.0f; //!< The default orbit axes opacity (to fade in and out).
AZ::Vector3 m_defaultOrbitPoint = AZ::Vector3::CreateZero(); //!< The orbit point to use when no entity is selected.
bool m_defaultOrbiting = false; //!< Is the camera default orbiting (orbiting when there's no selected entity).
};
} // namespace SandboxEditor

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