Merge remote-tracking branch 'upstream/development' into Atom/santorac/RemixableMaterialTypes3

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
This commit is contained in:
santorac
2022-01-27 12:58:22 -08:00
951 changed files with 4248 additions and 86172 deletions
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:bfc2ef8c6dbf2fba078e27e4e94384099e090468e679327dd826a5cbf22b04ed
size 1019
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:708b12d41229afab78e0f7d59097ae3de855fea8525a920c5c214fc0ce79f1bd
size 1209
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fab63af9b50790dca25330058e70517987ea8bf11c00f9353dd951ebdbd1dbe5
size 5008
File diff suppressed because it is too large Load Diff
+9 -47
View File
@@ -44,51 +44,11 @@ include(cmake/SettingsRegistry.cmake)
include(cmake/TestImpactFramework/LYTestImpactFramework.cmake)
include(cmake/CMakeFiles.cmake)
include(cmake/O3DEJson.cmake)
include(cmake/Subdirectories.cmake)
################################################################################
# Subdirectory processing
################################################################################
# this function is building up the LY_EXTERNAL_SUBDIRS global property
function(add_engine_gem_json_external_subdirectories gem_path)
set(gem_json_path ${gem_path}/gem.json)
if(EXISTS ${gem_json_path})
read_json_external_subdirs(gem_external_subdirs ${gem_path}/gem.json)
foreach(gem_external_subdir ${gem_external_subdirs})
file(REAL_PATH ${gem_external_subdir} real_external_subdir BASE_DIRECTORY ${gem_path})
set_property(GLOBAL APPEND PROPERTY LY_EXTERNAL_SUBDIRS ${real_external_subdir})
add_engine_gem_json_external_subdirectories(${real_external_subdir})
endforeach()
endif()
endfunction()
function(add_engine_json_external_subdirectories)
read_json_external_subdirs(engine_external_subdirs ${LY_ROOT_FOLDER}/engine.json)
foreach(engine_external_subdir ${engine_external_subdirs})
file(REAL_PATH ${engine_external_subdir} real_external_subdir BASE_DIRECTORY ${LY_ROOT_FOLDER})
set_property(GLOBAL APPEND PROPERTY LY_EXTERNAL_SUBDIRS ${real_external_subdir})
add_engine_gem_json_external_subdirectories(${real_external_subdir})
endforeach()
endfunction()
function(add_subdirectory_on_externalsubdirs)
get_property(external_subdirs GLOBAL PROPERTY LY_EXTERNAL_SUBDIRS)
list(APPEND LY_EXTERNAL_SUBDIRS ${external_subdirs})
# Loop over the additional external subdirectories and invoke add_subdirectory on them
foreach(external_directory ${LY_EXTERNAL_SUBDIRS})
# Hash the external_directory name and append it to the Binary Directory section of add_subdirectory
# This is to deal with potential situations where multiple external directories has the same last directory name
# For example if D:/Company1/RayTracingGem and F:/Company2/Path/RayTracingGem were both added as a subdirectory
file(REAL_PATH ${external_directory} full_directory_path)
string(SHA256 full_directory_hash ${full_directory_path})
# Truncate the full_directory_hash down to 8 characters to avoid hitting the Windows 260 character path limit
# when the external subdirectory contains relative paths of significant length
string(SUBSTRING ${full_directory_hash} 0 8 full_directory_hash)
# Use the last directory as the suffix path to use for the Binary Directory
get_filename_component(directory_name ${external_directory} NAME)
add_subdirectory(${external_directory} ${CMAKE_BINARY_DIR}/External/${directory_name}-${full_directory_hash})
endforeach()
endfunction()
# Gather the list of o3de_manifest external Subdirectories
# into the LY_EXTERNAL_SUBDIRS_O3DE_MANIFEST_PROPERTY
add_o3de_manifest_json_external_subdirectories()
# Add the projects first so the Launcher can find them
include(cmake/Projects.cmake)
@@ -99,9 +59,11 @@ endif()
if(NOT INSTALLED_ENGINE)
# Add external subdirectories listed in the engine.json. LY_EXTERNAL_SUBDIRS is a cache variable so the user can add extra
# external subdirectories. This should go before adding the rest of the targets so the targets are availbe to the launcher.
# external subdirectories. This should go before adding the rest of the targets so the targets are available to the launcher.
add_engine_json_external_subdirectories()
add_subdirectory_on_externalsubdirs()
# Invoke add_subdirectory on external subdirectories that should be used a this point
add_subdirectory_on_external_subdirs()
# Add the rest of the targets
add_subdirectory(Assets)
@@ -114,7 +76,7 @@ if(NOT INSTALLED_ENGINE)
else()
ly_find_o3de_packages()
add_subdirectory_on_externalsubdirs()
add_subdirectory_on_external_subdirs()
endif()
################################################################################
@@ -1,73 +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 "AzAssetBrowserWindow.h"
#include "AzAssetBrowser/ui_AssetBrowserWindow.h"
#include <AzToolsFramework/AssetBrowser/UI/AssetTreeView.h>
#include <AzToolsFramework/AssetBrowser/UI/SortFilterProxyModel.hxx>
#include <AzToolsFramework/AssetBrowser/UI/AssetBrowserModel.h>
#include <AzToolsFramework/AssetBrowser/AssetCache/AssetCacheBus.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserRequestBus.h>
const char* ASSET_BROWSER_PREVIEW_NAME = "Asset Browser (PREVIEW)";
AzAssetBrowserWindow::AzAssetBrowserWindow(const QString& name, QWidget* parent)
: QDialog(parent)
, m_ui(new Ui::AssetBrowserWindowClass())
, m_assetDatabaseSortFilterProxyModel(new AssetBrowser::UI::SortFilterProxyModel(parent))
, m_name(name)
, m_assetBrowser(new AssetBrowser::UI::AssetTreeView(name, this))
{
EBUS_EVENT_RESULT(m_assetBrowserModel, AssetBrowser::AssetCache::AssetCacheRequestsBus, GetAssetBrowserModel);
AZ_Assert(m_assetBrowserModel, "Failed to get filebrowser model");
m_assetDatabaseSortFilterProxyModel->setSourceModel(m_assetBrowserModel);
m_ui->setupUi(this);
connect(m_ui->searchCriteriaWidget,
&AzToolsFramework::SearchCriteriaWidget::SearchCriteriaChanged,
m_assetDatabaseSortFilterProxyModel.data(),
&AssetBrowser::UI::SortFilterProxyModel::OnSearchCriteriaChanged);
connect(m_assetBrowser, &QTreeView::customContextMenuRequested, this, &AzAssetBrowserWindow::OnContextMenu);
}
AzAssetBrowserWindow::~AzAssetBrowserWindow()
{
m_assetBrowser->SaveState();
}
//////////////////////////////////////////////////////////////////////////
const AZ::Uuid& AzAssetBrowserWindow::GetClassID()
{
return AZ::AzTypeInfo<AzAssetBrowserWindow>::Uuid();
}
void AzAssetBrowserWindow::OnContextMenu(const QPoint& point)
{
(void)point;
//get the selected entries
QModelIndexList sourceIndexes;
for (const auto& index : m_assetBrowser->selectedIndexes())
{
sourceIndexes.push_back(m_assetDatabaseSortFilterProxyModel->mapToSource(index));
}
AZStd::vector<AssetBrowser::UI::Entry*> entries;
m_assetBrowserModel->SourceIndexesToAssetDatabaseEntries(sourceIndexes, entries);
if (entries.empty() || entries.size() > 1)
{
return;
}
auto entry = entries.front();
EBUS_EVENT(AssetBrowser::AssetBrowserRequestBus::Bus, OnItemContextMenu, this, entry);
}
#include <AzAssetBrowser/moc_AzAssetBrowserWindow.cpp>
@@ -1,57 +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
#if !defined(Q_MOC_RUN)
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/Math/Uuid.h>
#include <QDialog>
#endif
namespace Ui
{
class AssetBrowserWindowClass;
}
namespace AssetBrowser
{
namespace UI
{
class AssetTreeView;
class SortFilterProxyModel;
class AssetBrowserModel;
}
}
class AzAssetBrowserWindow
: public QDialog
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(AzAssetBrowserWindow, AZ::SystemAllocator, 0);
AZ_TYPE_INFO(AzAssetBrowserWindow, "{20238D23-2670-44BC-9110-A51374C18B5A}");
explicit AzAssetBrowserWindow(const QString& name = "default", QWidget* parent = nullptr);
virtual ~AzAssetBrowserWindow();
static const AZ::Uuid& GetClassID();
protected Q_SLOTS:
void OnContextMenu(const QPoint& point);
private:
QScopedPointer<Ui::AssetBrowserWindowClass> m_ui;
QScopedPointer<AssetBrowser::UI::AssetBrowserModel> m_assetDatabaseModel;
QScopedPointer<AssetBrowser::UI::SortFilterProxyModel> m_assetDatabaseSortFilterProxyModel;
QString m_name;
AssetBrowser::UI::AssetTreeView* m_assetBrowser;
AssetBrowser::UI::AssetBrowserModel* m_assetBrowserModel;
};
extern const char* ASSET_BROWSER_PREVIEW_NAME;
-186
View File
@@ -1,186 +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 "CVarMenu.h"
CVarMenu::CVarMenu(QWidget* parent)
: QMenu(parent)
{
}
void CVarMenu::AddCVarToggleItem(CVarToggle cVarToggle)
{
// Add CVar toggle action
QAction* action = addAction(cVarToggle.m_displayName);
connect(action, &QAction::triggered, [this, cVarToggle](bool checked)
{
// Update the CVar's value based on the action's new checked state
ICVar* cVar = gEnv->pConsole->GetCVar(cVarToggle.m_cVarName.toUtf8().data());
if (cVar)
{
SetCVar(cVar, checked ? cVarToggle.m_onValue : cVarToggle.m_offValue);
}
});
action->setCheckable(true);
// Initialize the action's checked state based on the associated CVar's value
ICVar* cVar = gEnv->pConsole->GetCVar(cVarToggle.m_cVarName.toUtf8().data());
bool checked = (cVar && cVar->GetFVal() == cVarToggle.m_onValue);
action->setChecked(checked);
}
void CVarMenu::AddCVarValuesItem(QString cVarName,
QString displayName,
CVarDisplayNameValuePairs availableCVarValues,
float offValue)
{
// Add a submenu offering multiple values for one CVar
QMenu* menu = addMenu(displayName);
QActionGroup* group = new QActionGroup(menu);
group->setExclusive(true);
ICVar* cVar = gEnv->pConsole->GetCVar(cVarName.toUtf8().data());
float cVarValue = cVar ? cVar->GetFVal() : 0.0f;
for (const auto& availableCVarValue : availableCVarValues)
{
QAction* action = menu->addAction(availableCVarValue.first);
action->setCheckable(true);
group->addAction(action);
float availableOnValue = availableCVarValue.second;
connect(action, &QAction::triggered, [this, action, cVarName, availableOnValue, offValue](bool checked)
{
ICVar* cVar = gEnv->pConsole->GetCVar(cVarName.toUtf8().data());
if (cVar)
{
if (!checked)
{
SetCVar(cVar, offValue);
}
else
{
// Toggle the CVar and update the action's checked state to
// allow none of the items to be checked in the exclusive group.
// Otherwise we could have just used the action's currently checked
// state and updated the CVar's value only
bool cVarOn = (cVar->GetFVal() == availableOnValue);
checked = !cVarOn;
SetCVar(cVar, checked ? availableOnValue : offValue);
action->setChecked(checked);
}
}
});
// Initialize the action's checked state based on the CVar's current value
bool checked = (cVarValue == availableOnValue);
action->setChecked(checked);
}
}
void CVarMenu::AddUniqueCVarsItem(QString displayName,
AZStd::vector<CVarToggle> availableCVars)
{
// Add a submenu of actions offering values for unique CVars
QMenu* menu = addMenu(displayName);
QActionGroup* group = new QActionGroup(menu);
group->setExclusive(true);
for (const CVarToggle& availableCVar : availableCVars)
{
QAction* action = menu->addAction(availableCVar.m_displayName);
action->setCheckable(true);
group->addAction(action);
connect(action, &QAction::triggered, [this, action, availableCVar, availableCVars](bool checked)
{
ICVar* cVar = gEnv->pConsole->GetCVar(availableCVar.m_cVarName.toUtf8().data());
if (cVar)
{
if (!checked)
{
SetCVar(cVar, availableCVar.m_offValue);
}
else
{
// Toggle the CVar and update the action's checked state to
// allow none of the items to be checked in the exclusive group.
// Otherwise we could have just used the action's currently checked
// state and updated the CVar's value only
bool cVarOn = (cVar->GetFVal() == availableCVar.m_onValue);
bool cVarChecked = !cVarOn;
SetCVar(cVar, cVarChecked ? availableCVar.m_onValue : availableCVar.m_offValue);
action->setChecked(cVarChecked);
if (cVarChecked)
{
// Set the rest of the CVars in the group to their off values
SetCVarsToOffValue(availableCVars, availableCVar);
}
}
}
});
// Initialize the action's checked state based on its associated CVar's current value
ICVar* cVar = gEnv->pConsole->GetCVar(availableCVar.m_cVarName.toUtf8().data());
bool cVarChecked = (cVar && cVar->GetFVal() == availableCVar.m_onValue);
action->setChecked(cVarChecked);
if (cVarChecked)
{
// Set the rest of the CVars in the group to their off values
SetCVarsToOffValue(availableCVars, availableCVar);
}
}
}
void CVarMenu::AddResetCVarsItem()
{
QAction* action = addAction(tr("Reset to Default"));
connect(action, &QAction::triggered, this, [this]()
{
for (auto it : m_originalCVarValues)
{
ICVar* cVar = gEnv->pConsole->GetCVar(it.first.c_str());
if (cVar)
{
cVar->Set(it.second);
}
}
});
}
void CVarMenu::SetCVarsToOffValue(const AZStd::vector<CVarToggle>& cVarToggles, const CVarToggle& excludeCVarToggle)
{
// Set all but the specified CVars to their off values
for (const CVarToggle& cVarToggle : cVarToggles)
{
if (cVarToggle.m_cVarName != excludeCVarToggle.m_cVarName
|| cVarToggle.m_onValue != excludeCVarToggle.m_onValue)
{
ICVar* cVar = gEnv->pConsole->GetCVar(cVarToggle.m_cVarName.toUtf8().data());
if (cVar)
{
SetCVar(cVar, cVarToggle.m_offValue);
}
}
}
}
void CVarMenu::SetCVar(ICVar* cVar, float newValue)
{
float oldValue = cVar->GetFVal();
cVar->Set(newValue);
// Store original value for CVar if not already in the list
m_originalCVarValues.emplace(AZStd::string(cVar->GetName()), oldValue);
}
void CVarMenu::AddSeparator()
{
addSeparator();
}
-65
View File
@@ -1,65 +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
#include <QMenu>
#include <QString>
#include <AzCore/std/string/string.h>
#include <AzCore/std/containers/unordered_map.h>
#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
{
QString m_cVarName;
QString m_displayName;
float m_onValue;
float m_offValue;
};
// List of a CVar's available values and their descriptions
using CVarDisplayNameValuePairs = AZStd::vector<AZStd::pair<QString, float>>;
CVarMenu(QWidget* parent = nullptr);
// Add an action that turns a CVar on/off
void AddCVarToggleItem(CVarToggle cVarToggle);
// Add a submenu of actions for a CVar that offers multiple values for exclusive selection
void AddCVarValuesItem(QString cVarName,
QString displayName,
CVarDisplayNameValuePairs availableCVarValues,
float offValue);
// Add a submenu of actions for exclusively turning unique CVars on/off
void AddUniqueCVarsItem(QString displayName,
AZStd::vector<CVarToggle> availableCVars);
// Add an action to reset all CVars to their original values before they
// were modified by this menu
void AddResetCVarsItem();
void AddSeparator();
private:
void SetCVarsToOffValue(const AZStd::vector<CVarToggle>& cVarToggles, const CVarToggle& excludeCVarToggle);
void SetCVar(ICVar* cVar, float newValue);
// Original CVar values before they were modified by this menu
AZStd::unordered_map<AZStd::string, float> m_originalCVarValues;
};
-30
View File
@@ -1,30 +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
#include <AzCore/EBus/EBus.h>
class CommandManagerRequests : public AZ::EBusTraits
{
public:
struct CommandDetails
{
AZStd::string m_name;
AZStd::vector<AZStd::string> m_arguments;
};
virtual AZStd::vector<AZStd::string> GetCommands() const = 0;
virtual void ExecuteCommand(const AZStd::string& commandLine) {}
virtual void GetCommandDetails(AZStd::string commandName, CommandDetails& outArguments) const = 0;
};
using CommandManagerRequestBus = AZ::EBus<CommandManagerRequests>;
-195
View File
@@ -1,195 +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 "ConfigGroup.h"
namespace Config
{
CConfigGroup::CConfigGroup()
{
}
CConfigGroup::~CConfigGroup()
{
for (IConfigVar* var : m_vars)
{
delete var;
}
}
void CConfigGroup::AddVar(IConfigVar* var)
{
m_vars.push_back(var);
}
AZ::u32 CConfigGroup::GetVarCount()
{
return aznumeric_cast<AZ::u32>(m_vars.size());
}
IConfigVar* CConfigGroup::GetVar(const char* szName)
{
for (IConfigVar* var : m_vars)
{
if (0 == _stricmp(szName, var->GetName().c_str()))
{
return var;
}
}
return nullptr;
}
const IConfigVar* CConfigGroup::GetVar(const char* szName) const
{
for (const IConfigVar* var : m_vars)
{
if (0 == _stricmp(szName, var->GetName().c_str()))
{
return var;
}
}
return nullptr;
}
IConfigVar* CConfigGroup::GetVar(AZ::u32 index)
{
if (index < m_vars.size())
{
return m_vars[index];
}
return nullptr;
}
const IConfigVar* CConfigGroup::GetVar(AZ::u32 index) const
{
if (index < m_vars.size())
{
return m_vars[index];
}
return nullptr;
}
void CConfigGroup::SaveToXML(XmlNodeRef node)
{
// save only values that don't have default values
for (const IConfigVar* var : m_vars)
{
if (var->IsFlagSet(IConfigVar::eFlag_DoNotSave) || var->IsDefault())
{
continue;
}
const char* szName = var->GetName().c_str();
switch (var->GetType())
{
case IConfigVar::eType_BOOL:
{
bool currentValue = false;
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_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)
{
// load values that are save-able
for (IConfigVar* var : m_vars)
{
if (var->IsFlagSet(IConfigVar::eFlag_DoNotSave))
{
continue;
}
const char* szName = var->GetName().c_str();
switch (var->GetType())
{
case IConfigVar::eType_BOOL:
{
bool currentValue = false;
var->GetDefault(&currentValue);
if (node->getAttr(szName, currentValue))
{
var->Set(&currentValue);
}
break;
}
case IConfigVar::eType_INT:
{
int currentValue = 0;
var->GetDefault(&currentValue);
if (node->getAttr(szName, currentValue))
{
var->Set(&currentValue);
}
break;
}
case IConfigVar::eType_FLOAT:
{
float currentValue = 0;
var->GetDefault(&currentValue);
if (node->getAttr(szName, currentValue))
{
var->Set(&currentValue);
}
break;
}
case IConfigVar::eType_STRING:
{
AZStd::string currentValue;
var->GetDefault(&currentValue);
QString readValue(currentValue.c_str());
if (node->getAttr(szName, readValue))
{
currentValue = readValue.toUtf8().data();
var->Set(&currentValue);
}
break;
}
}
}
}
}
-113
View File
@@ -1,113 +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
#include <AzCore/base.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/string/string.h>
struct ICVar;
class XmlNodeRef;
namespace Config
{
// Abstract configurable variable
struct IConfigVar
{
public:
enum EType
{
eType_BOOL,
eType_INT,
eType_FLOAT,
eType_STRING,
};
enum EFlags
{
eFlag_NoUI = 1 << 0,
eFlag_NoCVar = 1 << 1,
eFlag_DoNotSave = 1 << 2,
};
IConfigVar(const char* szName, const char* szDescription, EType varType, AZ::u8 flags)
: m_name(szName)
, m_description(szDescription)
, m_type(varType)
, m_flags(flags)
, m_ptr(nullptr)
{};
virtual ~IConfigVar() = default;
AZ_FORCE_INLINE EType GetType() const
{
return m_type;
}
AZ_FORCE_INLINE const AZStd::string& GetName() const
{
return m_name;
}
AZ_FORCE_INLINE const AZStd::string& GetDescription() const
{
return m_description;
}
AZ_FORCE_INLINE bool IsFlagSet(EFlags flag) const
{
return 0 != (m_flags & flag);
}
virtual void Get(void* outPtr) const = 0;
virtual void Set(const void* ptr) = 0;
virtual bool IsDefault() const = 0;
virtual void GetDefault(void* outPtr) const = 0;
virtual void Reset() = 0;
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;
AZ::u8 m_flags;
AZStd::string m_name;
AZStd::string m_description;
void* m_ptr;
ICVar* m_pCVar;
};
// Group of configuration variables with optional mapping to CVars
class CConfigGroup
{
private:
using TConfigVariables = AZStd::vector<IConfigVar*> ;
TConfigVariables m_vars;
using TConsoleVariables = AZStd::vector<ICVar*>;
TConsoleVariables m_consoleVars;
public:
CConfigGroup();
virtual ~CConfigGroup();
void AddVar(IConfigVar* var);
AZ::u32 GetVarCount();
IConfigVar* GetVar(const char* szName);
IConfigVar* GetVar(AZ::u32 index);
const IConfigVar* GetVar(const char* szName) const;
const IConfigVar* GetVar(AZ::u32 index) const;
void SaveToXML(XmlNodeRef node);
void LoadFromXML(XmlNodeRef node);
};
};
@@ -1,131 +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 "PropertyAnimationCtrl.h"
// Qt
#include <QHBoxLayout>
#include <QLabel>
#include <QToolButton>
// Editor
#include "Util/UIEnumerations.h"
#include "IResourceSelectorHost.h"
AnimationPropertyCtrl::AnimationPropertyCtrl(QWidget *pParent)
: QWidget(pParent)
{
m_animationLabel = new QLabel;
m_pApplyButton = new QToolButton;
m_pApplyButton->setIcon(QIcon(":/reflectedPropertyCtrl/img/apply.png"));
m_pApplyButton->setFocusPolicy(Qt::StrongFocus);
QHBoxLayout *pLayout = new QHBoxLayout(this);
pLayout->setContentsMargins(0, 0, 0, 0);
pLayout->addWidget(m_animationLabel, 1);
pLayout->addWidget(m_pApplyButton);
connect(m_pApplyButton, &QAbstractButton::clicked, this, &AnimationPropertyCtrl::OnApplyClicked);
};
AnimationPropertyCtrl::~AnimationPropertyCtrl()
{
}
void AnimationPropertyCtrl::SetValue(const CReflectedVarAnimation &animation)
{
m_animation = animation;
m_animationLabel->setText(animation.m_animation.c_str());
}
CReflectedVarAnimation AnimationPropertyCtrl::value() const
{
return m_animation;
}
void AnimationPropertyCtrl::OnApplyClicked()
{
QStringList cSelectedAnimations;
int nTotalAnimations(0);
int nCurrentAnimation(0);
QString combinedString = GetIEditor()->GetResourceSelectorHost()->GetGlobalSelection("animation");
SplitString(combinedString, cSelectedAnimations, ',');
nTotalAnimations = cSelectedAnimations.size();
for (nCurrentAnimation = 0; nCurrentAnimation < nTotalAnimations; ++nCurrentAnimation)
{
QString& rstrCurrentAnimAction = cSelectedAnimations[nCurrentAnimation];
if (!rstrCurrentAnimAction.isEmpty())
{
m_animation.m_animation = rstrCurrentAnimAction.toUtf8().data();
m_animationLabel->setText(m_animation.m_animation.c_str());
emit ValueChanged(m_animation);
}
}
}
QWidget* AnimationPropertyCtrl::GetFirstInTabOrder()
{
return m_pApplyButton;
}
QWidget* AnimationPropertyCtrl::GetLastInTabOrder()
{
return m_pApplyButton;
}
void AnimationPropertyCtrl::UpdateTabOrder()
{
setTabOrder(m_pApplyButton, m_pApplyButton);
}
QWidget* AnimationPropertyWidgetHandler::CreateGUI(QWidget *pParent)
{
AnimationPropertyCtrl* newCtrl = aznew AnimationPropertyCtrl(pParent);
connect(newCtrl, &AnimationPropertyCtrl::ValueChanged, newCtrl, [newCtrl]()
{
EBUS_EVENT(AzToolsFramework::PropertyEditorGUIMessages::Bus, RequestWrite, newCtrl);
});
return newCtrl;
}
void AnimationPropertyWidgetHandler::ConsumeAttribute(AnimationPropertyCtrl* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName)
{
Q_UNUSED(GUI);
Q_UNUSED(attrib);
Q_UNUSED(attrValue);
Q_UNUSED(debugName);
}
void AnimationPropertyWidgetHandler::WriteGUIValuesIntoProperty(size_t index, AnimationPropertyCtrl* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node)
{
Q_UNUSED(index);
Q_UNUSED(node);
CReflectedVarAnimation val = GUI->value();
instance = static_cast<property_t>(val);
}
bool AnimationPropertyWidgetHandler::ReadValuesIntoGUI(size_t index, AnimationPropertyCtrl* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node)
{
Q_UNUSED(index);
Q_UNUSED(node);
CReflectedVarAnimation val = instance;
GUI->SetValue(val);
return false;
}
#include <Controls/ReflectedPropertyControl/moc_PropertyAnimationCtrl.cpp>
@@ -1,78 +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_UTILS_PROPERTYANIMATIONCTRL_H
#define CRYINCLUDE_EDITOR_UTILS_PROPERTYANIMATIONCTRL_H
#pragma once
#if !defined(Q_MOC_RUN)
#include <AzCore/base.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
#include "ReflectedVar.h"
#include <QWidget>
#include <QPointer>
#endif
class QToolButton;
class QLabel;
class QHBoxLayout;
class AnimationPropertyCtrl
: public QWidget
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(AnimationPropertyCtrl, AZ::SystemAllocator, 0);
AnimationPropertyCtrl(QWidget* pParent = nullptr);
virtual ~AnimationPropertyCtrl();
CReflectedVarAnimation value() const;
QWidget* GetFirstInTabOrder();
QWidget* GetLastInTabOrder();
void UpdateTabOrder();
signals:
void ValueChanged(CReflectedVarAnimation value);
public slots:
void SetValue(const CReflectedVarAnimation& animation);
protected slots:
void OnApplyClicked();
private:
QToolButton* m_pApplyButton;
QLabel* m_animationLabel;
CReflectedVarAnimation m_animation;
};
class AnimationPropertyWidgetHandler
: QObject
, public AzToolsFramework::PropertyHandler < CReflectedVarAnimation, AnimationPropertyCtrl >
{
public:
AZ_CLASS_ALLOCATOR(AnimationPropertyWidgetHandler, AZ::SystemAllocator, 0);
virtual AZ::u32 GetHandlerName(void) const override { return AZ_CRC("Animation", 0x8d5284dc); }
virtual bool IsDefaultHandler() const override { return true; }
virtual QWidget* GetFirstInTabOrder(AnimationPropertyCtrl* widget) override { return widget->GetFirstInTabOrder(); }
virtual QWidget* GetLastInTabOrder(AnimationPropertyCtrl* widget) override { return widget->GetLastInTabOrder(); }
virtual void UpdateWidgetInternalTabbing(AnimationPropertyCtrl* widget) override { widget->UpdateTabOrder(); }
virtual QWidget* CreateGUI(QWidget* pParent) override;
virtual void ConsumeAttribute(AnimationPropertyCtrl* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
virtual void WriteGUIValuesIntoProperty(size_t index, AnimationPropertyCtrl* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
virtual bool ReadValuesIntoGUI(size_t index, AnimationPropertyCtrl* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
};
#endif // CRYINCLUDE_EDITOR_UTILS_PROPERTYANIMATIONCTRL_H
@@ -229,28 +229,16 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
break;
case ePropertyFloat:
case ePropertyAngle:
//if the Description has a valid global enumDB lookup, edit as an enum, otherwise use normal float editor
if (desc.m_pEnumDBItem)
m_reflectedVarAdapter = new ReflectedVarDBEnumAdapter;
else
m_reflectedVarAdapter = new ReflectedVarFloatAdapter;
m_reflectedVarAdapter = new ReflectedVarFloatAdapter;
break;
case ePropertyInt:
//if the Description has a valid global enumDB lookup, edit as an enum, otherwise use normal int editor
if (desc.m_pEnumDBItem)
m_reflectedVarAdapter = new ReflectedVarDBEnumAdapter;
else
m_reflectedVarAdapter = new ReflectedVarIntAdapter;
m_reflectedVarAdapter = new ReflectedVarIntAdapter;
break;
case ePropertyBool:
m_reflectedVarAdapter = new ReflectedVarBoolAdapter;
break;
case ePropertyString:
//if the Description has a valid global enumDB lookup, edit as an enum, otherwise use normal string editor
if (desc.m_pEnumDBItem)
m_reflectedVarAdapter = new ReflectedVarDBEnumAdapter;
else
m_reflectedVarAdapter = new ReflectedVarStringAdapter;
m_reflectedVarAdapter = new ReflectedVarStringAdapter;
break;
case ePropertySelection:
m_reflectedVarAdapter = new ReflectedVarEnumAdapter;
@@ -15,7 +15,6 @@
// Editor
#include "ReflectedPropertyCtrl.h"
#include "UIEnumsDatabase.h"
namespace {
@@ -254,41 +253,6 @@ void ReflectedVarEnumAdapter::OnVariableChange([[maybe_unused]] IVariable* pVari
}
}
void ReflectedVarDBEnumAdapter::SetVariable(IVariable *pVariable)
{
Prop::Description desc(pVariable);
m_pEnumDBItem = desc.m_pEnumDBItem;
m_reflectedVar.reset(new CReflectedVarEnum<AZStd::string>(pVariable->GetHumanName().toUtf8().data()));
if (m_pEnumDBItem)
{
for (int i = 0; i < m_pEnumDBItem->strings.size(); i++)
{
QString name = m_pEnumDBItem->strings[i];
m_reflectedVar->addEnum( m_pEnumDBItem->NameToValue(name).toUtf8().data(), name.toUtf8().data() );
}
}
}
void ReflectedVarDBEnumAdapter::SyncReflectedVarToIVar(IVariable *pVariable)
{
const AZStd::string valueStr = pVariable->GetDisplayValue().toUtf8().data();
const AZStd::string value = m_pEnumDBItem ? AZStd::string(m_pEnumDBItem->ValueToName(valueStr.c_str()).toUtf8().data()) : valueStr;
m_reflectedVar->setEnumByName(value);
}
void ReflectedVarDBEnumAdapter::SyncIVarToReflectedVar(IVariable *pVariable)
{
QString iVarVal = m_reflectedVar->m_selectedEnumName.c_str();
if (m_pEnumDBItem)
{
iVarVal = m_pEnumDBItem->NameToValue(iVarVal);
}
pVariable->SetDisplayValue(iVarVal);
}
void ReflectedVarVector2Adapter::SetVariable(IVariable *pVariable)
{
m_reflectedVar.reset(new CReflectedVarVector2(pVariable->GetHumanName().toUtf8().data()));
@@ -16,7 +16,6 @@
#include <QScopedPointer>
struct CUIEnumsDatabase_SEnum;
class ReflectedPropertyItem;
// Class to wrap the CReflectedVars and sync them with corresponding IVariable.
@@ -145,22 +144,6 @@ AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
bool m_updatingEnums;
};
class EDITOR_CORE_API ReflectedVarDBEnumAdapter
: public ReflectedVarAdapter
{
public:
void SetVariable(IVariable* pVariable) override;
void SyncReflectedVarToIVar(IVariable* pVariable) override;
void SyncIVarToReflectedVar(IVariable* pVariable) override;
CReflectedVar* GetReflectedVar() override { return m_reflectedVar.data(); }
private:
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
QScopedPointer<CReflectedVarEnum<AZStd::string> > m_reflectedVar;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
CUIEnumsDatabase_SEnum* m_pEnumDBItem;
};
class EDITOR_CORE_API ReflectedVarVector2Adapter
: public ReflectedVarAdapter
{
+1 -5
View File
@@ -1709,7 +1709,6 @@ bool CCryEditApp::InitInstance()
mainWindow->Initialize();
GetIEditor()->GetCommandManager()->RegisterAutoCommands();
GetIEditor()->AddUIEnums();
mainWindowWrapper->enableSaveRestoreGeometry("O3DE", "O3DE", "mainWindowGeometry");
m_pDocManager->OnFileNew();
@@ -1820,10 +1819,7 @@ bool CCryEditApp::InitInstance()
if (GetIEditor()->GetCommandManager()->IsRegistered("editor.open_lnm_editor"))
{
CCommand0::SUIInfo uiInfo;
#if !defined(NDEBUG)
bool ok =
#endif
GetIEditor()->GetCommandManager()->GetUIInfo("editor.open_lnm_editor", uiInfo);
[[maybe_unused]] bool ok = GetIEditor()->GetCommandManager()->GetUIInfo("editor.open_lnm_editor", uiInfo);
assert(ok);
}
+2 -42
View File
@@ -57,7 +57,6 @@
// LmbrCentral
#include <LmbrCentral/Audio/AudioSystemComponentBus.h>
#include <LmbrCentral/Rendering/EditorLightComponentBus.h> // for LmbrCentral::EditorLightComponentRequestBus
static const char* kAutoBackupFolder = "_autobackup";
static const char* kHoldFolder = "$tmp_hold"; // conform to the ignored file types $tmp[0-9]*_ regex
@@ -2130,52 +2129,13 @@ void CCryEditDoc::ReleaseXmlArchiveArray(TDocMultiArchive& arrXmlAr)
//////////////////////////////////////////////////////////////////////////
// AzToolsFramework::EditorEntityContextNotificationBus interface implementation
void CCryEditDoc::OnSliceInstantiated(const AZ::Data::AssetId& sliceAssetId, AZ::SliceComponent::SliceInstanceAddress& sliceAddress, const AzFramework::SliceInstantiationTicket& /*ticket*/)
void CCryEditDoc::OnSliceInstantiated([[maybe_unused]] const AZ::Data::AssetId& sliceAssetId, [[maybe_unused]] AZ::SliceComponent::SliceInstanceAddress& sliceAddress, [[maybe_unused]] const AzFramework::SliceInstantiationTicket& ticket)
{
if (m_envProbeSliceAssetId == sliceAssetId)
{
const AZ::SliceComponent::EntityList& entities = sliceAddress.GetInstance()->GetInstantiated()->m_entities;
const AZ::Uuid editorEnvProbeComponentId("{8DBD6035-583E-409F-AFD9-F36829A0655D}");
AzToolsFramework::EntityIdList entityIds;
entityIds.reserve(entities.size());
for (const AZ::Entity* entity : entities)
{
if (entity->FindComponent(editorEnvProbeComponentId))
{
// Update Probe Area size to cover the whole terrain
LmbrCentral::EditorLightComponentRequestBus::Event(entity->GetId(), &LmbrCentral::EditorLightComponentRequests::SetProbeAreaDimensions, AZ::Vector3(m_terrainSize, m_terrainSize, m_envProbeHeight));
// Force update the light to apply cubemap
LmbrCentral::EditorLightComponentRequestBus::Event(entity->GetId(), &LmbrCentral::EditorLightComponentRequests::RefreshLight);
}
entityIds.push_back(entity->GetId());
}
//Detach instantiated env probe entities from engine slice
AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Broadcast(
&AzToolsFramework::SliceEditorEntityOwnershipServiceRequests::DetachSliceEntities, entityIds);
sliceAddress.SetInstance(nullptr);
sliceAddress.SetReference(nullptr);
SetModifiedFlag(true);
SetModifiedModules(eModifiedEntities);
AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusDisconnect();
//save after level default slice fully instantiated
Save();
}
GetIEditor()->ResumeUndo();
}
void CCryEditDoc::OnSliceInstantiationFailed(const AZ::Data::AssetId& sliceAssetId, const AzFramework::SliceInstantiationTicket& /*ticket*/)
void CCryEditDoc::OnSliceInstantiationFailed([[maybe_unused]] const AZ::Data::AssetId& sliceAssetId, [[maybe_unused]] const AzFramework::SliceInstantiationTicket& ticket)
{
if (m_envProbeSliceAssetId == sliceAssetId)
{
AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusDisconnect();
AZ_Warning("Editor", false, "Failed to instantiate default environment probe slice.");
}
GetIEditor()->ResumeUndo();
}
//////////////////////////////////////////////////////////////////////////
-1
View File
@@ -200,7 +200,6 @@ protected:
QString m_pathName;
QString m_slicePathName;
QString m_title;
AZ::Data::AssetId m_envProbeSliceAssetId;
float m_terrainSize;
const char* m_envProbeSliceRelativePath = "EngineAssets/Slices/DefaultLevelSetup.slice";
const float m_envProbeHeight = 200.0f;
-29
View File
@@ -26,7 +26,6 @@
#include "Core/QtEditorApplication.h"
#include "CheckOutDialog.h"
#include "GameEngine.h"
#include "UndoConfigSpec.h"
#include "ViewManager.h"
#include "EditorViewportCamera.h"
@@ -369,21 +368,6 @@ namespace
inline namespace Commands
{
void PySetConfigSpec(int spec, int platform)
{
CUndo undo("Set Config Spec");
if (CUndo::IsRecording())
{
CUndo::Record(new CUndoConficSpec());
}
GetIEditor()->SetEditorConfigSpec((ESystemConfigSpec)spec, (ESystemConfigPlatform)platform);
}
int PyGetConfigSpec()
{
return static_cast<int>(GetIEditor()->GetEditorConfigSpec());
}
int PyGetConfigPlatform()
{
return static_cast<int>(GetIEditor()->GetEditorConfigPlatform());
@@ -434,9 +418,7 @@ namespace AzToolsFramework
addLegacyGeneral(behaviorContext->Method("set_current_view_rotation", PySetCurrentViewRotation, nullptr, "Sets the rotation of the current view as given x, y, z Euler angles in degrees."));
addLegacyGeneral(behaviorContext->Method("export_to_engine", CCryEditApp::Command_ExportToEngine, nullptr, "Exports the current level to the engine."));
addLegacyGeneral(behaviorContext->Method("set_config_spec", PySetConfigSpec, nullptr, "Sets the system config spec and platform."));
addLegacyGeneral(behaviorContext->Method("get_config_platform", PyGetConfigPlatform, nullptr, "Gets the system config platform."));
addLegacyGeneral(behaviorContext->Method("get_config_spec", PyGetConfigSpec, nullptr, "Gets the system config spec."));
addLegacyGeneral(behaviorContext->Method("set_result_to_success", PySetResultToSuccess, nullptr, "Sets the result of a script execution to success. Used only for Sandbox AutoTests."));
addLegacyGeneral(behaviorContext->Method("set_result_to_failure", PySetResultToFailure, nullptr, "Sets the result of a script execution to failure. Used only for Sandbox AutoTests."));
@@ -464,17 +446,6 @@ namespace AzToolsFramework
};
addCheckoutDialog(behaviorContext->Method("enable_for_all", PyCheckOutDialogEnableForAll, nullptr, "Enables the 'Apply to all' button in the checkout dialog; useful for allowing the user to apply a decision to check out files to multiple, related operations."));
behaviorContext->EnumProperty<ESystemConfigSpec::CONFIG_AUTO_SPEC>("SystemConfigSpec_Auto")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
behaviorContext->EnumProperty<ESystemConfigSpec::CONFIG_LOW_SPEC>("SystemConfigSpec_Low")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
behaviorContext->EnumProperty<ESystemConfigSpec::CONFIG_MEDIUM_SPEC>("SystemConfigSpec_Medium")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
behaviorContext->EnumProperty<ESystemConfigSpec::CONFIG_HIGH_SPEC>("SystemConfigSpec_High")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
behaviorContext->EnumProperty<ESystemConfigSpec::CONFIG_VERYHIGH_SPEC>("SystemConfigSpec_VeryHigh")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
behaviorContext->EnumProperty<ESystemConfigPlatform::CONFIG_INVALID_PLATFORM>("SystemConfigPlatform_InvalidPlatform")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
behaviorContext->EnumProperty<ESystemConfigPlatform::CONFIG_PC>("SystemConfigPlatform_Pc")
-17
View File
@@ -123,9 +123,7 @@
#include "Util/XmlTemplate.h"
// Utility classes.
#include "Util/bitarray.h"
#include "Util/RefCountBase.h"
#include "Util/TRefCountBase.h"
#include "Util/MemoryBlock.h"
#include "Util/PathUtil.h"
@@ -168,18 +166,3 @@
#ifdef LoadCursor
#undef LoadCursor
#endif
#ifdef _DEBUG
#if !defined(AZ_PLATFORM_LINUX)
#ifdef assert
#undef assert
#if defined(USE_AZ_ASSERT)
#define assert(condition) AZ_Assert(condition, "")
#else
#define assert CRY_ASSERT
#endif
#endif // !defined(AZ_PLATFORM_LINUX)
#endif
#endif
-24
View File
@@ -1,24 +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
#include <AzCore/EBus/EBus.h>
//! Allows handlers to be notified when settings are changed to refresh accordingly
class EditorPreferencesNotifications
: public AZ::EBusTraits
{
public:
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
//! Notifies about changes in the Editor Preferences
virtual void OnEditorPreferencesChanged() {}
};
using EditorPreferencesNotificationBus = AZ::EBus<EditorPreferencesNotifications>;
@@ -30,7 +30,6 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
serialize.Class<GeneralSettings>()
->Version(3)
->Field("PreviewPanel", &GeneralSettings::m_previewPanel)
->Field("ApplyConfigSpec", &GeneralSettings::m_applyConfigSpec)
->Field("EnableSourceControl", &GeneralSettings::m_enableSourceControl)
->Field("ClearConsole", &GeneralSettings::m_clearConsoleOnGameModeStart)
->Field("ConsoleBackgroundColorTheme", &GeneralSettings::m_consoleBackgroundColorTheme)
@@ -81,7 +80,6 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
{
editContext->Class<GeneralSettings>("General Settings", "General Editor Preferences")
->DataElement(AZ::Edit::UIHandlers::CheckBox, &GeneralSettings::m_previewPanel, "Show Geometry Preview Panel", "Show Geometry Preview Panel")
->DataElement(AZ::Edit::UIHandlers::CheckBox, &GeneralSettings::m_applyConfigSpec, "Hide objects by config spec", "Hide objects by config spec")
->DataElement(AZ::Edit::UIHandlers::CheckBox, &GeneralSettings::m_enableSourceControl, "Enable Source Control", "Enable Source Control")
->DataElement(
AZ::Edit::UIHandlers::CheckBox, &GeneralSettings::m_clearConsoleOnGameModeStart, "Clear Console at game startup", "Clear Console when game mode starts")
@@ -157,7 +155,6 @@ void CEditorPreferencesPage_General::OnApply()
{
//general settings
gSettings.bPreviewGeometryWindow = m_generalSettings.m_previewPanel;
gSettings.bApplyConfigSpecInEditor = m_generalSettings.m_applyConfigSpec;
gSettings.enableSourceControl = m_generalSettings.m_enableSourceControl;
gSettings.clearConsoleOnGameModeStart = m_generalSettings.m_clearConsoleOnGameModeStart;
gSettings.consoleBackgroundColorTheme = m_generalSettings.m_consoleBackgroundColorTheme;
@@ -195,7 +192,6 @@ void CEditorPreferencesPage_General::InitializeSettings()
{
//general settings
m_generalSettings.m_previewPanel = gSettings.bPreviewGeometryWindow;
m_generalSettings.m_applyConfigSpec = gSettings.bApplyConfigSpecInEditor;
m_generalSettings.m_enableSourceControl = gSettings.enableSourceControl;
m_generalSettings.m_clearConsoleOnGameModeStart = gSettings.clearConsoleOnGameModeStart;
m_generalSettings.m_consoleBackgroundColorTheme = gSettings.consoleBackgroundColorTheme;
@@ -45,7 +45,6 @@ private:
AZ_TYPE_INFO(GeneralSettings, "{C2AE8F6D-7AA6-499E-A3E8-ECCD0AC6F3D2}")
bool m_previewPanel;
bool m_applyConfigSpec;
bool m_enableSourceControl;
bool m_clearConsoleOnGameModeStart;
AzToolsFramework::ConsoleColorTheme m_consoleBackgroundColorTheme;
+22 -2
View File
@@ -89,6 +89,7 @@
#include <LmbrCentral/Rendering/EditorCameraCorrectionBus.h>
// Atom
#include <Atom/RPI.Public/RenderPipeline.h>
#include <Atom/RPI.Public/View.h>
#include <Atom/RPI.Public/ViewportContextManager.h>
#include <Atom/RPI.Public/ViewProviderBus.h>
@@ -584,7 +585,7 @@ void EditorViewportWidget::OnEditorNotifyEvent(EEditorNotifyEvent event)
m_renderViewport->SetScene(nullptr);
break;
case eNotify_OnEndSceneOpen:
case eNotify_OnEndLoad:
UpdateScene();
SetDefaultCamera();
break;
@@ -2324,7 +2325,26 @@ void EditorViewportWidget::UpdateScene()
{
AZ::RPI::SceneNotificationBus::Handler::BusDisconnect();
m_renderViewport->SetScene(mainScene);
AZ::RPI::SceneNotificationBus::Handler::BusConnect(m_renderViewport->GetViewportContext()->GetRenderScene()->GetId());
auto viewportContext = m_renderViewport->GetViewportContext();
AZ::RPI::SceneNotificationBus::Handler::BusConnect(viewportContext->GetRenderScene()->GetId());
// Don't enable the render pipeline until a level has been loaded
// Also show/hide the RenderViewportWidget accordingly so that we get the
// expected gradient background when no level is loaded
auto renderPipeline = viewportContext->GetCurrentPipeline();
if (renderPipeline)
{
if (GetIEditor()->IsLevelLoaded())
{
m_renderViewport->show();
renderPipeline->AddToRenderTick();
}
else
{
m_renderViewport->hide();
renderPipeline->RemoveFromRenderTick();
}
}
}
}
}
+1 -1
View File
@@ -14,7 +14,7 @@
#define CRYINCLUDE_EDITOR_CORE_ERRORRECORDER_H
#pragma once
#include "Include/EditorCoreAPI.h"
#include <EditorCoreAPI.h>
//////////////////////////////////////////////////////////////////////////
//! Automatic class to record and display error.
-3
View File
@@ -17,9 +17,6 @@
// forward declarations.
class CParticleItem;
#include <CryCommon/IValidator.h>
#include <CryCommon/smartptr.h>
#include "Objects/BaseObject.h"
#include "Include/EditorCoreAPI.h"
#include "Include/IErrorReport.h"
-28
View File
@@ -19,8 +19,6 @@
#include "Util/UndoUtil.h"
#include <CryVersion.h>
#include <WinWidgetId.h>
#include <AzCore/Component/EntityId.h>
#include <AzCore/Debug/Budget.h>
@@ -48,7 +46,6 @@ class ICommandManager;
class CEditorCommandManager;
class CHyperGraphManager;
class CConsoleSynchronization;
class CUIEnumsDatabase;
struct ISourceControl;
struct IEditorClassFactory;
struct ITransformManipulator;
@@ -66,11 +63,6 @@ struct SEditorSettings;
class CGameExporter;
class IAWSResourceManager;
namespace WinWidget
{
class WinWidgetManager;
}
struct ISystem;
struct IRenderer;
struct AABB;
@@ -323,17 +315,6 @@ enum MouseCallbackFlags
MK_CALLBACK_FLAGS = 0x100
};
//! Types of database items
enum EDataBaseItemType
{
EDB_TYPE_MATERIAL,
EDB_TYPE_PARTICLE,
EDB_TYPE_MUSIC,
EDB_TYPE_EAXPRESET,
EDB_TYPE_SOUNDMOOD,
EDB_TYPE_FLARE
};
enum EEditorPathName
{
EDITOR_PATH_OBJECTS,
@@ -597,10 +578,6 @@ struct IEditor
virtual bool SetViewFocus(const char* sViewClassName) = 0;
virtual void CloseView(const GUID& classId) = 0; // close ALL panels related to classId, used when unloading plugins.
// We want to open a view object but not wrap it in a view pane)
virtual QWidget* OpenWinWidget(WinWidgetId openId) = 0;
virtual WinWidget::WinWidgetManager* GetWinWidgetManager() const = 0;
//! Opens standard color selection dialog.
//! Initialized with the color specified in color parameter.
//! Returns true if selection is made and false if selection is canceled.
@@ -682,15 +659,10 @@ struct IEditor
//! Only returns true if source control is both available AND currently connected and functioning
virtual bool IsSourceControlConnected() = 0;
virtual CUIEnumsDatabase* GetUIEnumsDatabase() = 0;
virtual void AddUIEnums() = 0;
virtual void ReduceMemory() = 0;
//! Export manager for exporting objects and a terrain from the game to DCC tools
virtual IExportManager* GetExportManager() = 0;
//! Set current configuration spec of the editor.
virtual void SetEditorConfigSpec(ESystemConfigSpec spec, ESystemConfigPlatform platform) = 0;
virtual ESystemConfigSpec GetEditorConfigSpec() const = 0;
virtual ESystemConfigPlatform GetEditorConfigPlatform() const = 0;
virtual void ReloadTemplates() = 0;
virtual void ShowStatusText(bool bEnable) = 0;
+1 -65
View File
@@ -12,6 +12,7 @@
#include "EditorDefs.h"
#include "IEditorImpl.h"
#include <EditorCommonAPI.h>
// Qt
#include <QByteArray>
@@ -50,7 +51,6 @@
#include "GameEngine.h"
#include "ToolBox.h"
#include "MainWindow.h"
#include "UIEnumsDatabase.h"
#include "RenderHelpers/AxisHelper.h"
#include "Settings.h"
#include "Include/IObjectManager.h"
@@ -69,9 +69,6 @@
#include "Editor/AzAssetBrowser/AzAssetBrowserRequestHandler.h"
#include "Editor/AssetEditor/AssetEditorRequestsHandler.h"
// EditorCommon
#include <WinWidget/WinWidgetManager.h>
#include "Core/QtEditorApplication.h" // for Editor::EditorQtApplication
static CCryEditDoc * theDocument;
@@ -118,7 +115,6 @@ CEditorImpl::CEditorImpl()
, m_pErrorsDlg(nullptr)
, m_pSourceControl(nullptr)
, m_pSelectionTreeManager(nullptr)
, m_pUIEnumsDatabase(nullptr)
, m_pConsoleSync(nullptr)
, m_pSettingsManager(nullptr)
, m_pLevelIndependentFileMan(nullptr)
@@ -148,7 +144,6 @@ CEditorImpl::CEditorImpl()
regCtx.pCommandManager = m_pCommandManager;
regCtx.pClassFactory = m_pClassFactory;
m_pEditorFileMonitor.reset(new CEditorFileMonitor());
m_pUIEnumsDatabase = new CUIEnumsDatabase;
m_pDisplaySettings = new CDisplaySettings;
m_pDisplaySettings->LoadRegistry();
m_pPluginManager = new CPluginManager;
@@ -167,8 +162,6 @@ CEditorImpl::CEditorImpl()
DetectVersion();
RegisterTools();
m_winWidgetManager.reset(new WinWidget::WinWidgetManager);
m_pAssetDatabaseLocationListener = nullptr;
m_pAssetBrowserRequestHandler = nullptr;
m_assetEditorRequestsHandler = nullptr;
@@ -302,7 +295,6 @@ CEditorImpl::~CEditorImpl()
SAFE_DELETE(m_pCommandManager)
SAFE_DELETE(m_pClassFactory)
SAFE_DELETE(m_pLasLoadedLevelErrorReport)
SAFE_DELETE(m_pUIEnumsDatabase)
SAFE_DELETE(m_pSettingsManager);
@@ -837,20 +829,6 @@ const QtViewPane* CEditorImpl::OpenView(QString sViewClassName, bool reuseOpened
return QtViewPaneManager::instance()->OpenPane(sViewClassName, openMode);
}
QWidget* CEditorImpl::OpenWinWidget(WinWidgetId openId)
{
if (m_winWidgetManager)
{
return m_winWidgetManager->OpenWinWidget(openId);
}
return nullptr;
}
WinWidget::WinWidgetManager* CEditorImpl::GetWinWidgetManager() const
{
return m_winWidgetManager.get();
}
QWidget* CEditorImpl::FindView(QString viewClassName)
{
return QtViewPaneManager::instance()->GetView(viewClassName);
@@ -1491,48 +1469,6 @@ IExportManager* CEditorImpl::GetExportManager()
return m_pExportManager;
}
void CEditorImpl::AddUIEnums()
{
// Spec settings for shadow casting lights
AZStd::string SpecString[4];
QStringList types;
types.push_back("Never=0");
SpecString[0] = AZStd::string::format("VeryHigh Spec=%d", CONFIG_VERYHIGH_SPEC);
types.push_back(SpecString[0].c_str());
SpecString[1] = AZStd::string::format("High Spec=%d", CONFIG_HIGH_SPEC);
types.push_back(SpecString[1].c_str());
SpecString[2] = AZStd::string::format("Medium Spec=%d", CONFIG_MEDIUM_SPEC);
types.push_back(SpecString[2].c_str());
SpecString[3] = AZStd::string::format("Low Spec=%d", CONFIG_LOW_SPEC);
types.push_back(SpecString[3].c_str());
m_pUIEnumsDatabase->SetEnumStrings("CastShadows", types);
// Power-of-two percentages
AZStd::string percentStringPOT[5];
types.clear();
percentStringPOT[0] = AZStd::string::format("Default=%d", 0);
types.push_back(percentStringPOT[0].c_str());
percentStringPOT[1] = AZStd::string::format("12.5=%d", 1);
types.push_back(percentStringPOT[1].c_str());
percentStringPOT[2] = AZStd::string::format("25=%d", 2);
types.push_back(percentStringPOT[2].c_str());
percentStringPOT[3] = AZStd::string::format("50=%d", 3);
types.push_back(percentStringPOT[3].c_str());
percentStringPOT[4] = AZStd::string::format("100=%d", 4);
types.push_back(percentStringPOT[4].c_str());
m_pUIEnumsDatabase->SetEnumStrings("ShadowMinResPercent", types);
}
void CEditorImpl::SetEditorConfigSpec(ESystemConfigSpec spec, [[maybe_unused]]ESystemConfigPlatform platform)
{
gSettings.editorConfigSpec = spec;
}
ESystemConfigSpec CEditorImpl::GetEditorConfigSpec() const
{
return (ESystemConfigSpec)gSettings.editorConfigSpec;
}
ESystemConfigPlatform CEditorImpl::GetEditorConfigPlatform() const
{
return m_pSystem->GetConfigPlatform();
-15
View File
@@ -53,11 +53,6 @@ namespace Editor
class EditorQtApplication;
}
namespace WinWidget
{
class WinWidgetManager;
}
namespace AssetDatabase
{
class AssetDatabaseLocationListener;
@@ -221,9 +216,6 @@ public:
bool CloseView(const char* sViewClassName) override;
bool SetViewFocus(const char* sViewClassName) override;
QWidget* OpenWinWidget(WinWidgetId openId) override;
WinWidget::WinWidgetManager* GetWinWidgetManager() const override;
// close ALL panels related to classId, used when unloading plugins.
void CloseView(const GUID& classId) override;
bool SelectColor(QColor &color, QWidget *parent = 0) override;
@@ -276,14 +268,9 @@ public:
bool IsSourceControlConnected() override;
//! Setup Material Editor mode
void SetMatEditMode(bool bIsMatEditMode);
CUIEnumsDatabase* GetUIEnumsDatabase() override { return m_pUIEnumsDatabase; };
void AddUIEnums() override;
void ReduceMemory() override;
// Get Export manager
IExportManager* GetExportManager() override;
// Set current configuration spec of the editor.
void SetEditorConfigSpec(ESystemConfigSpec spec, ESystemConfigPlatform platform) override;
ESystemConfigSpec GetEditorConfigSpec() const override;
ESystemConfigPlatform GetEditorConfigPlatform() const override;
void ReloadTemplates() override;
void AddErrorMessage(const QString& text, const QString& caption);
@@ -355,7 +342,6 @@ protected:
CSelectionTreeManager* m_pSelectionTreeManager;
CUIEnumsDatabase* m_pUIEnumsDatabase;
//! CConsole Synchronization
CConsoleSynchronization* m_pConsoleSync;
//! Editor Settings Manager
@@ -369,7 +355,6 @@ protected:
QString m_selectFileBuffer;
QString m_levelNameBuffer;
std::unique_ptr<WinWidget::WinWidgetManager> m_winWidgetManager;
//! True if the editor is in material edit mode. Fast preview of materials.
//! In this mode only very limited functionality is available.
-20
View File
@@ -1,20 +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_IOBSERVABLE_H
#define CRYINCLUDE_EDITOR_IOBSERVABLE_H
#pragma once
//! Observable macro to be used in pure interfaces
#define DEFINE_OBSERVABLE_PURE_METHODS(observerClassName) \
virtual bool RegisterObserver(observerClassName * pObserver) = 0; \
virtual bool UnregisterObserver(observerClassName * pObserver) = 0; \
virtual void UnregisterAllObservers() = 0;
#endif // CRYINCLUDE_EDITOR_IOBSERVABLE_H
-2
View File
@@ -1,2 +0,0 @@
IDI_ICON1 ICON DISCARDABLE "..\\res\\lyeditor.ico"
-9
View File
@@ -1,9 +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
*
*/
#define IDI_ICON1 2
-6
View File
@@ -128,8 +128,6 @@ public:
MOCK_METHOD1(CloseView, bool(const char* ));
MOCK_METHOD1(SetViewFocus, bool(const char* ));
MOCK_METHOD1(CloseView, void(const GUID& ));
MOCK_METHOD1(OpenWinWidget, QWidget* (WinWidgetId ));
MOCK_CONST_METHOD0(GetWinWidgetManager, WinWidget::WinWidgetManager* ());
MOCK_METHOD2(SelectColor, bool(QColor &, QWidget *));
MOCK_METHOD0(GetUndoManager, class CUndoManager* ());
MOCK_METHOD0(BeginUndo, void());
@@ -167,12 +165,8 @@ public:
MOCK_METHOD0(GetSourceControl, ISourceControl* ());
MOCK_METHOD0(IsSourceControlAvailable, bool());
MOCK_METHOD0(IsSourceControlConnected, bool());
MOCK_METHOD0(GetUIEnumsDatabase, CUIEnumsDatabase* ());
MOCK_METHOD0(AddUIEnums, void());
MOCK_METHOD0(ReduceMemory, void());
MOCK_METHOD0(GetExportManager, IExportManager* ());
MOCK_METHOD2(SetEditorConfigSpec, void(ESystemConfigSpec , ESystemConfigPlatform ));
MOCK_CONST_METHOD0(GetEditorConfigSpec, ESystemConfigSpec());
MOCK_CONST_METHOD0(GetEditorConfigPlatform, ESystemConfigPlatform());
MOCK_METHOD0(ReloadTemplates, void());
MOCK_METHOD1(ShowStatusText, void(bool ));
@@ -66,9 +66,7 @@ namespace CryEditPythonBindingsUnitTests
EXPECT_TRUE(behaviorContext->m_methods.find("set_current_view_position") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("set_current_view_rotation") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("export_to_engine") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("set_config_spec") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("get_config_platform") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("get_config_spec") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("set_result_to_success") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("set_result_to_failure") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("idle_enable") != behaviorContext->m_methods.end());
@@ -25,7 +25,6 @@
#include <Mocks/ICVarMock.h>
#include <Mocks/ISystemMock.h>
#include <Mocks/IConsoleMock.h>
#include <Mocks/ILogMock.h>
#include <Mocks/IConsoleMock.h>
#include "IEditorMock.h"
-1
View File
@@ -72,7 +72,6 @@
#include "ToolbarManager.h"
#include "Core/QtEditorApplication.h"
#include "UndoDropDown.h"
#include "CVarMenu.h"
#include "EditorViewportSettings.h"
#include "KeyboardCustomizationSettings.h"
-1
View File
@@ -49,7 +49,6 @@ class ToolbarCustomizationDialog;
class QWidgetAction;
class ActionManager;
class ShortcutDispatcher;
class CVarMenu;
namespace AzQtComponents
{
+1 -52
View File
@@ -62,7 +62,7 @@ protected:
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//! Undo object for CBaseObject that only stores its transform, color, area and minSpec
//! Undo object for CBaseObject that only stores its transform, color, area
class CUndoBaseObjectMinimal
: public IUndoObject
{
@@ -84,7 +84,6 @@ private:
Vec3 scale;
QColor color;
float area;
int minSpec;
};
void SetTransformsFromState(CBaseObject* pObject, const StateStruct& state, bool bUndo);
@@ -253,7 +252,6 @@ CUndoBaseObjectMinimal::CUndoBaseObjectMinimal(CBaseObject* pObj, [[maybe_unused
m_undoState.scale = pObj->GetScale();
m_undoState.color = pObj->GetColor();
m_undoState.area = pObj->GetArea();
m_undoState.minSpec = pObj->GetMinSpec();
}
//////////////////////////////////////////////////////////////////////////
@@ -284,14 +282,12 @@ void CUndoBaseObjectMinimal::Undo(bool bUndo)
m_redoState.rotate = pObject->GetRotation();
m_redoState.color = pObject->GetColor();
m_redoState.area = pObject->GetArea();
m_redoState.minSpec = pObject->GetMinSpec();
}
SetTransformsFromState(pObject, m_undoState, bUndo);
pObject->ChangeColor(m_undoState.color);
pObject->SetArea(m_undoState.area);
pObject->SetMinSpec(m_undoState.minSpec, false);
using namespace AzToolsFramework;
ComponentEntityObjectRequestBus::Event(pObject, &ComponentEntityObjectRequestBus::Events::UpdatePreemptiveUndoCache);
@@ -310,7 +306,6 @@ void CUndoBaseObjectMinimal::Redo()
pObject->ChangeColor(m_redoState.color);
pObject->SetArea(m_redoState.area);
pObject->SetMinSpec(m_redoState.minSpec, false);
using namespace AzToolsFramework;
ComponentEntityObjectRequestBus::Event(pObject, &ComponentEntityObjectRequestBus::Events::UpdatePreemptiveUndoCache);
@@ -382,7 +377,6 @@ CBaseObject::CBaseObject()
, m_bMatrixInWorldSpace(false)
, m_bMatrixValid(false)
, m_bWorldBoxValid(false)
, m_nMinSpec(0)
, m_vDrawIconPos(0, 0, 0)
, m_nIconFlags(0)
{
@@ -413,7 +407,6 @@ bool CBaseObject::Init([[maybe_unused]] IEditor* ie, CBaseObject* prev, [[maybe_
SetLocalTM(prev->GetPos(), prev->GetRotation(), prev->GetScale());
SetArea(prev->GetArea());
SetColor(prev->GetColor());
SetMinSpec(prev->GetMinSpec(), false);
// Copy all basic variables.
EnableUpdateCallbacks(false);
@@ -1053,17 +1046,6 @@ void CBaseObject::SetSelected(bool bSelect)
}
}
//////////////////////////////////////////////////////////////////////////
bool CBaseObject::IsHiddenBySpec() const
{
if (!gSettings.bApplyConfigSpecInEditor)
{
return false;
}
return (m_nMinSpec != 0 && gSettings.editorConfigSpec != 0 && m_nMinSpec > static_cast<uint32>(gSettings.editorConfigSpec));
}
//////////////////////////////////////////////////////////////////////////
//! Returns true if object hidden.
bool CBaseObject::IsHidden() const
@@ -1107,7 +1089,6 @@ void CBaseObject::Serialize(CObjectArchive& ar)
Vec3 scale = m_scale;
Quat quat = m_rotate;
Ang3 angles(0, 0, 0);
uint32 nMinSpec = m_nMinSpec;
QColor color = m_color;
float flattenArea = m_flattenArea;
@@ -1135,12 +1116,6 @@ void CBaseObject::Serialize(CObjectArchive& ar)
xmlNode->getAttr("Parent", parentId);
xmlNode->getAttr("LookAt", lookatId);
xmlNode->getAttr("Material", mtlName);
xmlNode->getAttr("MinSpec", nMinSpec);
if (nMinSpec <= CONFIG_VERYHIGH_SPEC) // Ignore invalid values.
{
m_nMinSpec = nMinSpec;
}
bool bHidden = flags & OBJFLAG_HIDDEN;
bool bFrozen = flags & OBJFLAG_FROZEN;
@@ -1245,11 +1220,6 @@ void CBaseObject::Serialize(CObjectArchive& ar)
{
xmlNode->setAttr("Flags", flags);
}
if (m_nMinSpec != 0)
{
xmlNode->setAttr("MinSpec", (uint32)m_nMinSpec);
}
}
// Serialize variables after default entity parameters.
@@ -1300,11 +1270,6 @@ XmlNodeRef CBaseObject::Export([[maybe_unused]] const QString& levelPath, XmlNod
objNode->setAttr("Scale", scale);
}
if (m_nMinSpec != 0)
{
objNode->setAttr("MinSpec", (uint32)m_nMinSpec);
}
// Save variables.
CVarObject::Serialize(objNode, false);
@@ -2134,22 +2099,6 @@ bool CBaseObject::IsSimilarObject(CBaseObject* pObject)
return false;
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::SetMinSpec(uint32 nSpec, bool bSetChildren)
{
m_nMinSpec = nSpec;
UpdateVisibility(!IsHidden());
// Set min spec for all childs.
if (bSetChildren)
{
for (int i = static_cast<int>(m_childs.size()) - 1; i >= 0; --i)
{
m_childs[i]->SetMinSpec(nSpec, true);
}
}
}
//////////////////////////////////////////////////////////////////////////
EScaleWarningLevel CBaseObject::GetScaleWarningLevel() const
{
-10
View File
@@ -31,7 +31,6 @@ class CUndoBaseObject;
class CObjectManager;
class CGizmo;
class CObjectArchive;
struct SSubObjSelectionModifyContext;
struct SRayHitInfo;
class CPopupMenuItem;
class QMenu;
@@ -257,8 +256,6 @@ public:
//! Returns true if object hidden.
bool IsHidden() const;
//! Check against min spec.
bool IsHiddenBySpec() const;
//! Returns true if object frozen.
virtual bool IsFrozen() const;
//! Returns true if object is shared between missions.
@@ -466,12 +463,6 @@ public:
//! Check if specified object is very similar to this one.
virtual bool IsSimilarObject(CBaseObject* pObject);
//////////////////////////////////////////////////////////////////////////
// Object minimal usage spec (All/Low/Medium/High)
//////////////////////////////////////////////////////////////////////////
uint32 GetMinSpec() const { return m_nMinSpec; }
virtual void SetMinSpec(uint32 nSpec, bool bSetChildren = true);
//! In This function variables of the object must be initialized.
virtual void InitVariables() {};
@@ -669,7 +660,6 @@ private:
mutable uint32 m_bMatrixValid : 1;
mutable uint32 m_bWorldBoxValid : 1;
uint32 m_bInSelectionBox : 1;
uint32 m_nMinSpec : 8;
Vec3 m_vDrawIconPos;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
+1 -40
View File
@@ -200,7 +200,6 @@ CEntityObject::CEntityObject()
// Init Variables.
mv_castShadow = true;
mv_castShadowMinSpec = CONFIG_LOW_SPEC;
mv_outdoor = false;
mv_recvWind = false;
mv_renderNearest = false;
@@ -249,18 +248,10 @@ CEntityObject::~CEntityObject()
//////////////////////////////////////////////////////////////////////////
void CEntityObject::InitVariables()
{
mv_castShadowMinSpec.AddEnumItem("Never", END_CONFIG_SPEC_ENUM);
mv_castShadowMinSpec.AddEnumItem("Low", CONFIG_LOW_SPEC);
mv_castShadowMinSpec.AddEnumItem("Medium", CONFIG_MEDIUM_SPEC);
mv_castShadowMinSpec.AddEnumItem("High", CONFIG_HIGH_SPEC);
mv_castShadowMinSpec.AddEnumItem("VeryHigh", CONFIG_VERYHIGH_SPEC);
mv_castShadow.SetFlags(mv_castShadow.GetFlags() | IVariable::UI_INVISIBLE);
mv_castShadowMinSpec->SetFlags(mv_castShadowMinSpec->GetFlags() | IVariable::UI_UNSORTED);
AddVariable(mv_outdoor, "OutdoorOnly", tr("Outdoor Only"));
AddVariable(mv_castShadow, "CastShadow", tr("Cast Shadow"));
AddVariable(mv_castShadowMinSpec, "CastShadowMinspec", tr("Cast Shadow MinSpec"));
AddVariable(mv_ratioLOD, "LodRatio");
AddVariable(mv_viewDistanceMultiplier, "ViewDistanceMultiplier");
@@ -361,7 +352,6 @@ bool CEntityObject::ConvertFromObject(CBaseObject* object)
CEntityObject* pObject = ( CEntityObject* )object;
mv_outdoor = pObject->mv_outdoor;
mv_castShadowMinSpec = pObject->mv_castShadowMinSpec;
mv_ratioLOD = pObject->mv_ratioLOD;
mv_viewDistanceMultiplier = pObject->mv_viewDistanceMultiplier;
mv_hiddenInGame = pObject->mv_hiddenInGame;
@@ -521,22 +511,6 @@ void CEntityObject::AdjustLightProperties(CVarBlockPtr& properties, const char*
}
}
if (IVariable* pCastShadowVar = FindVariableInSubBlock(properties, pSubBlockVar, "nCastShadows"))
{
if (bCastShadowLegacy)
{
pCastShadowVar->SetDisplayValue("1");
}
pCastShadowVar->SetDataType(IVariable::DT_UIENUM);
pCastShadowVar->SetFlags(pCastShadowVar->GetFlags() | IVariable::UI_UNSORTED);
}
if (IVariable* pShadowMinRes = FindVariableInSubBlock(properties, pSubBlockVar, "nShadowMinResPercent"))
{
pShadowMinRes->SetDataType(IVariable::DT_UIENUM);
pShadowMinRes->SetFlags(pShadowMinRes->GetFlags() | IVariable::UI_UNSORTED);
}
if (IVariable* pFade = FindVariableInSubBlock(properties, pSubBlockVar, "vFadeDimensionsLeft"))
{
pFade->SetFlags(pFade->GetFlags() | IVariable::UI_INVISIBLE);
@@ -873,12 +847,6 @@ void CEntityObject::Serialize(CObjectArchive& ar)
RemoveAllEntityLinks();
PostLoad(ar);
}
if ((mv_castShadowMinSpec == CONFIG_LOW_SPEC) && !mv_castShadow) // backwards compatibility check
{
mv_castShadowMinSpec = END_CONFIG_SPEC_ENUM;
mv_castShadow = true;
}
}
else
{
@@ -1033,8 +1001,6 @@ XmlNodeRef CEntityObject::Export([[maybe_unused]] const QString& levelPath, XmlN
objNode->setAttr("ViewDistanceMultiplier", mv_viewDistanceMultiplier);
}
objNode->setAttr("CastShadowMinSpec", mv_castShadowMinSpec);
if (mv_recvWind)
{
objNode->setAttr("RecvWind", true);
@@ -1050,11 +1016,6 @@ XmlNodeRef CEntityObject::Export([[maybe_unused]] const QString& levelPath, XmlN
objNode->setAttr("OutdoorOnly", true);
}
if (GetMinSpec() != 0)
{
objNode->setAttr("MinSpec", ( uint32 )GetMinSpec());
}
if (mv_hiddenInGame)
{
objNode->setAttr("HiddenInGame", true);
@@ -1163,7 +1124,7 @@ void CEntityObject::UpdateVisibility(bool bVisible)
{
CBaseObject::UpdateVisibility(bVisible);
bool bVisibleWithSpec = bVisible && !IsHiddenBySpec();
bool bVisibleWithSpec = bVisible;
if (bVisibleWithSpec != static_cast<bool>(m_bVisible))
{
m_bVisible = bVisibleWithSpec;
-3
View File
@@ -174,8 +174,6 @@ public:
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
int GetCastShadowMinSpec() const { return mv_castShadowMinSpec; }
float GetRatioLod() const { return static_cast<float>(mv_ratioLOD); };
float GetViewDistanceMultiplier() const { return mv_viewDistanceMultiplier; }
@@ -306,7 +304,6 @@ protected:
//////////////////////////////////////////////////////////////////////////
CVariable<bool> mv_outdoor;
CVariable<bool> mv_castShadow; // Legacy, required for backwards compatibility
CSmartVariableEnum<int> mv_castShadowMinSpec;
CVariable<int> mv_ratioLOD;
CVariable<float> mv_viewDistanceMultiplier;
CVariable<bool> mv_hiddenInGame; // Entity is hidden in game (on start).
-62
View File
@@ -1,62 +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 "SubObjSelection.h"
SSubObjSelOptions g_SubObjSelOptions;
/*
//////////////////////////////////////////////////////////////////////////
bool CSubObjSelContext::IsEmpty() const
{
if (GetCount() == 0)
return false;
for (int i = 0; i < GetCount(); i++)
{
CSubObjectSelection *pSel = GetSelection(i);
if (!pSel->IsEmpty())
return true;
}
return false;
}
//////////////////////////////////////////////////////////////////////////
void CSubObjSelContext::ModifySelection( SSubObjSelectionModifyContext &modCtx )
{
for (int n = 0; n < GetCount(); n++)
{
CSubObjectSelection *pSel = GetSelection(n);
if (pSel->IsEmpty())
continue;
modCtx.pSubObjSelection = pSel;
pSel->pGeometry->SubObjSelectionModify( modCtx );
}
if (modCtx.type == SO_MODIFY_MOVE)
{
OnSelectionChange();
}
}
//////////////////////////////////////////////////////////////////////////
void CSubObjSelContext::AcceptModifySelection()
{
for (int n = 0; n < GetCount(); n++)
{
CSubObjectSelection *pSel = GetSelection(n);
if (pSel->IsEmpty())
continue;
if (pSel->pGeometry)
pSel->pGeometry->Update();
}
}
*/
-91
View File
@@ -1,91 +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_OBJECTS_SUBOBJSELECTION_H
#define CRYINCLUDE_EDITOR_OBJECTS_SUBOBJSELECTION_H
#pragma once
//////////////////////////////////////////////////////////////////////////
// Sub Object element type.
//////////////////////////////////////////////////////////////////////////
enum ESubObjElementType
{
SO_ELEM_NONE = 0,
SO_ELEM_VERTEX,
SO_ELEM_EDGE,
SO_ELEM_FACE,
SO_ELEM_POLYGON,
SO_ELEM_UV,
};
//////////////////////////////////////////////////////////////////////////
enum ESubObjDisplayType
{
SO_DISPLAY_WIREFRAME,
SO_DISPLAY_FLAT,
SO_DISPLAY_GEOMETRY,
};
//////////////////////////////////////////////////////////////////////////
// Options for sub-object selection.
//////////////////////////////////////////////////////////////////////////
struct SSubObjSelOptions
{
bool bSelectByVertex;
bool bIgnoreBackfacing;
int nMatID;
bool bSoftSelection;
float fSoftSelFalloff;
// Display options.
bool bDisplayBackfacing;
bool bDisplayNormals;
float fNormalsLength;
ESubObjDisplayType displayType;
SSubObjSelOptions()
{
bSelectByVertex = false;
bIgnoreBackfacing = false;
bSoftSelection = false;
nMatID = 0;
fSoftSelFalloff = 1;
bDisplayBackfacing = true;
bDisplayNormals = false;
displayType = SO_DISPLAY_FLAT;
fNormalsLength = 0.4f;
}
};
extern SSubObjSelOptions g_SubObjSelOptions;
//////////////////////////////////////////////////////////////////////////
enum ESubObjSelectionModifyType
{
SO_MODIFY_UNSELECT,
SO_MODIFY_MOVE,
SO_MODIFY_ROTATE,
SO_MODIFY_SCALE,
};
//////////////////////////////////////////////////////////////////////////
// This structure is passed when user is dragging sub object selection.
//////////////////////////////////////////////////////////////////////////
struct SSubObjSelectionModifyContext
{
CViewport* view;
ESubObjSelectionModifyType type;
Vec3 vValue;
Matrix34 worldRefFrame;
};
#endif // CRYINCLUDE_EDITOR_OBJECTS_SUBOBJSELECTION_H
-39
View File
@@ -15,45 +15,6 @@
#include "Util/GuidUtil.h"
#include <map>
//! Derive from this class to decrease the amount of work for creating a new class description
//! Provides standard reference counter implementation for IUnknown
class CRefCountClassDesc
: public IClassDesc
{
public:
virtual ~CRefCountClassDesc() { }
HRESULT STDMETHODCALLTYPE QueryInterface([[maybe_unused]] const IID& riid, [[maybe_unused]] void** ppvObj)
{
return E_NOINTERFACE;
}
ULONG STDMETHODCALLTYPE AddRef()
{
++m_nRefCount;
return m_nRefCount;
}
ULONG STDMETHODCALLTYPE Release()
{
int refs = m_nRefCount;
if (--m_nRefCount <= 0)
{
delete this;
}
return refs;
}
private:
int m_nRefCount;
};
// Use this for debugging unregistration problems.
//#define DEBUG_CLASS_NAME_REGISTRATION
//! Class factory is a common repository of all registered plugin classes,
//! Classes here can found by their class ID or all classes of given system class retrieved
class CRYEDIT_API CClassFactory
@@ -14,7 +14,6 @@
#include "UI/QComponentEntityEditorOutlinerWindow.h"
#include "UI/QComponentLevelEntityEditorMainWindow.h"
#include "UI/ComponentPalette/ComponentPaletteSettings.h"
#include "UI/ComponentPalette/ComponentPaletteWindow.h"
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/Component/EntityUtils.h>
@@ -1,3 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Manifest>
</Manifest>
@@ -69,7 +69,6 @@
#include "ISourceControl.h"
#include "UI/QComponentEntityEditorMainWindow.h"
#include <LmbrCentral/Rendering/EditorLightComponentBus.h>
#include <LmbrCentral/Scripting/TagComponentBus.h>
#include <LmbrCentral/Scripting/EditorTagComponentBus.h>
@@ -16,7 +16,6 @@
#include <qevent.h>
#include <qmimedata.h>
#include <LmbrCentral/Rendering/LensFlareAsset.h>
#include <LmbrCentral/Rendering/MeshAsset.h>
#include <AzCore/Memory/Memory.h>
@@ -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
*
*/
#include "CategoriesList.h"
ComponentCategoryList::ComponentCategoryList(QWidget* parent /*= nullptr*/)
: QTreeWidget(parent)
{
}
void ComponentCategoryList::Init()
{
setColumnCount(1);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setDragDropMode(QAbstractItemView::DragDropMode::DragOnly);
setDragEnabled(true);
setSelectionMode(QAbstractItemView::ExtendedSelection);
setAllColumnsShowFocus(true);
setStyleSheet("QTreeWidget { selection-background-color: rgba(255,255,255,0.2); }");
QStringList headers;
headers << tr("Categories");
setHeaderLabels(headers);
const QString parentCategoryIconPath = QString("Icons/PropertyEditor/Browse_on.png");
const QString categoryIconPath = QString("Icons/PropertyEditor/Browse.png");
QTreeWidgetItem* allCategory = new QTreeWidgetItem(this);
allCategory->setText(0, "All");
allCategory->setIcon(0, QIcon(categoryIconPath));
// Need this briefly to collect the list of available categories.
ComponentDataModel dataModel(this);
for (const auto& cat : dataModel.GetCategories())
{
QString categoryString = QString(cat.c_str());
QStringList categories = categoryString.split('/', Qt::SkipEmptyParts);
QTreeWidgetItem* parent = nullptr;
QTreeWidgetItem* categoryWidget = nullptr;
for (const auto& categoryName : categories)
{
if (parent)
{
categoryWidget = new QTreeWidgetItem(parent);
categoryWidget->setIcon(0, QIcon(categoryIconPath));
// Store the full category path in a user role because we'll need it to locate the actual category
categoryWidget->setData(0, Qt::UserRole, QVariant::fromValue(categoryString));
}
else
{
auto existingCategory = findItems(categoryName, Qt::MatchExactly);
if (existingCategory.empty())
{
categoryWidget = new QTreeWidgetItem(this);
categoryWidget->setIcon(0, QIcon(parentCategoryIconPath));
}
else
{
categoryWidget = static_cast<QTreeWidgetItem*>(existingCategory.first());
categoryWidget->setIcon(0, QIcon(parentCategoryIconPath));
}
}
parent = categoryWidget;
categoryWidget->setText(0, categoryName);
}
}
expandAll();
connect(this, &QTreeWidget::itemClicked, this, &ComponentCategoryList::OnItemClicked);
}
void ComponentCategoryList::OnItemClicked(QTreeWidgetItem* item, int /*column*/)
{
QVariant userData = item->data(0, Qt::UserRole);
if (userData.isValid())
{
// Send in the full category path, not just the child category name
emit OnCategoryChange(userData.value<QString>().toStdString().c_str());
}
else
{
emit OnCategoryChange(item->text(0).toStdString().c_str());
}
}
#include <UI/ComponentPalette/moc_CategoriesList.cpp>
@@ -1,39 +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
#if !defined(Q_MOC_RUN)
#include "ComponentDataModel.h"
#include <QTreeWidget>
#endif
//! ComponentCategoryList
//! Provides a list of all reflected categories that users can select for quick
//! filtering the filtered component list.
class ComponentCategoryList : public QTreeWidget
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(ComponentCategoryList, AZ::SystemAllocator, 0);
explicit ComponentCategoryList(QWidget* parent = nullptr);
void Init();
Q_SIGNALS:
void OnCategoryChange(const char* category);
protected:
// Will emit OnCategoryChange signal
void OnItemClicked(QTreeWidgetItem* item, int column);
};
@@ -1,547 +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 "ComponentDataModel.h"
#include "Include/IObjectManager.h"
#include "Objects/SelectionGroup.h"
#include <AzCore/Component/Entity.h>
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/Component/Component.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/ToolsComponents/ComponentMimeData.h>
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
#include <AzToolsFramework/Commands/EntityStateCommand.h>
#include <AzToolsFramework/ToolsComponents/TransformComponent.h>
#include <AzToolsFramework/API/EntityCompositionRequestBus.h>
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
#include <Editor/IEditor.h>
#include <Editor/Viewport.h>
#include <Editor/ViewManager.h>
#include <CryCommon/MathConversion.h>
#include <AzQtComponents/DragAndDrop/ViewportDragAndDrop.h>
#include <QMimeData>
namespace
{
// This is a helper function that given an object that derives from QAbstractItemModel,
// it will request the model's "ClassDataRole" class data for an entry and use that
// information to create a new entity with the selected components.
AZ::EntityId CreateEntityFromSelection(const QModelIndexList& selection, QAbstractItemModel* model)
{
AZ::Vector3 position = AZ::Vector3::CreateZero();
CViewport *view = GetIEditor()->GetViewManager()->GetGameViewport();
int width, height;
view->GetDimensions(&width, &height);
position = LYVec3ToAZVec3(view->ViewToWorld(QPoint(width / 2, height / 2)));
AZ::EntityId newEntityId;
EBUS_EVENT_RESULT(newEntityId, AzToolsFramework::EditorRequests::Bus, CreateNewEntityAtPosition, position, AZ::EntityId());
if (newEntityId.IsValid())
{
// Add all the selected components.
AZ::ComponentTypeList componentsToAdd;
for (auto index : selection)
{
// We only need to consider the first column, it's important that the data() function that
// returns ComponentDataModel::ClassDataRole also does so for the first column.
if (index.column() != 0)
{
continue;
}
QVariant classDataVariant = model->data(index, ComponentDataModel::ClassDataRole);
if (classDataVariant.isValid())
{
const AZ::SerializeContext::ClassData* classData = reinterpret_cast<const AZ::SerializeContext::ClassData*>(classDataVariant.value<void*>());
componentsToAdd.push_back(classData->m_typeId);
}
}
AzToolsFramework::EntityCompositionRequestBus::Broadcast(&AzToolsFramework::EntityCompositionRequests::AddComponentsToEntities, AzToolsFramework::EntityIdList{ newEntityId }, componentsToAdd);
return newEntityId;
}
return AZ::EntityId();
}
}
namespace ComponentDataUtilities
{
// This is a helper function to add the specified components to the selected entities, it relies on the provided
// QAbstractItemModel to determine the appropriate ClassData to use to create the components (given that some widgets
// may provide proxy models that alter the order).
void AddComponentsToSelectedEntities(const QModelIndexList& selectedComponents, QAbstractItemModel* model)
{
AzToolsFramework::EntityIdList selectedEntities;
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(selectedEntities, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
if (selectedEntities.empty())
{
return;
}
// Add all the selected components.
AZ::ComponentTypeList componentsToAdd;
for (auto index : selectedComponents)
{
// We only need to consider the first column, it's important that the data() function that
// returns ComponentDataModel::ClassDataRole also does so for the first column.
if (index.column() != 0)
{
continue;
}
QVariant classDataVariant = model->data(index, ComponentDataModel::ClassDataRole);
if (classDataVariant.isValid())
{
const AZ::SerializeContext::ClassData* classData = reinterpret_cast<const AZ::SerializeContext::ClassData*>(classDataVariant.value<void*>());
componentsToAdd.push_back(classData->m_typeId);
}
}
AzToolsFramework::EntityCompositionRequestBus::Broadcast(&AzToolsFramework::EntityCompositionRequests::AddComponentsToEntities, selectedEntities, componentsToAdd);
}
}
// ComponentDataModel
//////////////////////////////////////////////////////////////////////////
ComponentDataModel::ComponentDataModel(QObject* parent)
: QAbstractTableModel(parent)
{
AZ::SerializeContext* serializeContext = nullptr;
EBUS_EVENT_RESULT(serializeContext, AZ::ComponentApplicationBus, GetSerializeContext);
AZ_Assert(serializeContext, "Failed to acquire application serialize context.");
serializeContext->EnumerateDerived<AZ::Component>([this](const AZ::SerializeContext::ClassData* classData, const AZ::Uuid&) -> bool
{
bool allowed = false;
bool hidden = false;
AZStd::string category = "Miscellaneous";
if (classData->m_editData)
{
for (const AZ::Edit::ElementData& element : classData->m_editData->m_elements)
{
if (element.m_elementId == AZ::Edit::ClassElements::EditorData)
{
AZStd::string iconPath;
AzToolsFramework::EditorRequestBus::BroadcastResult(iconPath, &AzToolsFramework::EditorRequests::GetComponentTypeEditorIcon, classData->m_typeId);
if (!iconPath.empty())
{
m_componentIcons[classData->m_typeId] = QIcon(iconPath.c_str());
}
for (const AZ::Edit::AttributePair& attribPair : element.m_attributes)
{
if (attribPair.first == AZ::Edit::Attributes::AppearsInAddComponentMenu)
{
if (auto data = azdynamic_cast<AZ::Edit::AttributeData<AZ::Crc32>*>(attribPair.second))
{
if (data->Get(nullptr) == AZ_CRC("Game"))
{
allowed = true;
}
}
}
else if (attribPair.first == AZ::Edit::Attributes::AddableByUser)
{
// skip this component if user is not allowed to add it directly
if (auto data = azdynamic_cast<AZ::Edit::AttributeData<bool>*>(attribPair.second))
{
if (!data->Get(nullptr))
{
hidden = true;
}
}
}
else if (attribPair.first == AZ::Edit::Attributes::Category)
{
if (auto data = azdynamic_cast<AZ::Edit::AttributeData<const char*>*>(attribPair.second))
{
category = data->Get(nullptr);
}
}
}
break;
}
}
}
if (allowed && !hidden)
{
m_componentList.push_back(classData);
m_componentMap[category].push_back(classData);
m_categories.insert(category);
}
return true;
});
// we'd like viewport events
AzQtComponents::DragAndDropEventsBus::Handler::BusConnect(AzQtComponents::DragAndDropContexts::EditorViewport);
}
ComponentDataModel::~ComponentDataModel()
{
AzQtComponents::DragAndDropEventsBus::Handler::BusDisconnect();
}
Qt::ItemFlags ComponentDataModel::flags([[maybe_unused]] const QModelIndex &index) const
{
return Qt::ItemFlags(
Qt::ItemIsEnabled |
Qt::ItemIsDragEnabled |
Qt::ItemIsDropEnabled |
Qt::ItemIsSelectable);
}
const AZ::SerializeContext::ClassData* ComponentDataModel::GetClassData(const QModelIndex& index) const
{
int row = index.row();
if (row < 0 || row >= m_componentList.size())
{
return nullptr;
}
return m_componentList[row];
}
const char* ComponentDataModel::GetCategory(const AZ::SerializeContext::ClassData* classData)
{
if (classData)
{
if (auto editorDataElement = classData->m_editData->FindElementData(AZ::Edit::ClassElements::EditorData))
{
if (auto categoryAttribute = editorDataElement->FindAttribute(AZ::Edit::Attributes::Category))
{
if (auto categoryData = azdynamic_cast<AZ::Edit::AttributeData<const char*>*>(categoryAttribute))
{
const char* result = categoryData->Get(nullptr);
if (result)
{
return result;
}
}
}
}
}
return "";
}
QModelIndex ComponentDataModel::index(int row, int column, const QModelIndex &parent /*= QModelIndex()*/) const
{
if (row >= rowCount(parent) || column >= columnCount(parent))
{
return QModelIndex();
}
return createIndex(row, column, (void*)(m_componentList[row]));
}
QModelIndex ComponentDataModel::parent([[maybe_unused]] const QModelIndex &child) const
{
return QModelIndex();
}
int ComponentDataModel::rowCount([[maybe_unused]] const QModelIndex &parent /*= QModelIndex()*/) const
{
return static_cast<int>(m_componentList.size());
}
int ComponentDataModel::columnCount([[maybe_unused]] const QModelIndex &parent /*= QModelIndex()*/) const
{
return ColumnIndex::Count;
}
QVariant ComponentDataModel::data(const QModelIndex &index, int role /*= Qt::DisplayRole*/) const
{
if (index.isValid())
{
const AZ::SerializeContext::ClassData* classData = m_componentList[index.row()];
if (!classData)
{
return QVariant();
}
switch (role)
{
case ClassDataRole:
if (index.column() == 0) // Only get data for one column
{
return QVariant::fromValue<void*>(reinterpret_cast<void*>(const_cast<AZ::SerializeContext::ClassData*>(classData)));
}
break;
case Qt::DisplayRole:
{
if (index.column() == ColumnIndex::Name)
{
return QVariant(classData->m_editData->m_name);
}
else
if (index.column() == ColumnIndex::Category)
{
if (auto editorDataElement = classData->m_editData->FindElementData(AZ::Edit::ClassElements::EditorData))
{
if (auto categoryAttribute = editorDataElement->FindAttribute(AZ::Edit::Attributes::Category))
{
if (auto categoryData = azdynamic_cast<const AZ::Edit::AttributeData<const char*>*>(categoryAttribute))
{
return QVariant(categoryData->Get(nullptr));
}
}
}
}
}
break;
case Qt::ToolTipRole:
{
return QVariant(classData->m_editData->m_description);
}
case Qt::DecorationRole:
{
if (index.column() == ColumnIndex::Icon)
{
auto iconIterator = m_componentIcons.find(classData->m_typeId);
if (iconIterator != m_componentIcons.end())
{
return iconIterator->second;
}
}
}
break;
default:
break;
}
}
return QVariant();
}
QMimeData* ComponentDataModel::mimeData(const QModelIndexList& indices) const
{
QModelIndexList list;
// Filter out columns we are not interested in.
for (const QModelIndex& index : indices)
{
if (index.column() == 0)
{
list.push_back(index);
}
}
AZStd::vector<const AZ::SerializeContext::ClassData*> sortedList;
for (QModelIndex index : list)
{
QVariant classDataVariant = index.data(ComponentDataModel::ClassDataRole);
if (classDataVariant.isValid())
{
const AZ::SerializeContext::ClassData* classData = reinterpret_cast<const AZ::SerializeContext::ClassData*>(classDataVariant.value<void*>());
sortedList.push_back(classData);
}
}
QMimeData* mimeData = nullptr;
if (!sortedList.empty())
{
mimeData = AzToolsFramework::ComponentTypeMimeData::Create(sortedList).release();
}
return mimeData;
}
bool ComponentDataModel::CanAcceptDragAndDropEvent(QDropEvent* event, AzQtComponents::DragAndDropContextBase& context) const
{
using namespace AzToolsFramework;
using namespace AzQtComponents;
// if a listener with a higher priority already claimed this event, do not touch it.
if ((!event) || (event->isAccepted()) || (!event->mimeData()))
{
return false;
}
ViewportDragContext* contextVP = azrtti_cast<ViewportDragContext*>(&context);
if (!contextVP)
{
// not a viewport event. This is for some other GUI such as the main window itself.
return false;
}
AZStd::vector<const AZ::SerializeContext::ClassData*> componentClassDataList;
return AzToolsFramework::ComponentTypeMimeData::Get(event->mimeData(), componentClassDataList);
}
void ComponentDataModel::DragEnter(QDragEnterEvent* event, AzQtComponents::DragAndDropContextBase& context)
{
if (CanAcceptDragAndDropEvent(event, context))
{
event->setDropAction(Qt::CopyAction);
event->setAccepted(true);
// opportunities to show special highlights, or ghosted entities or previews here.
}
}
void ComponentDataModel::DragMove(QDragMoveEvent* event, AzQtComponents::DragAndDropContextBase& context)
{
if (CanAcceptDragAndDropEvent(event, context))
{
event->setDropAction(Qt::CopyAction);
event->setAccepted(true);
// opportunities to update special highlights, or ghosted entities or previews here.
}
}
void ComponentDataModel::DragLeave(QDragLeaveEvent* /*event*/)
{
// opportunities to remove ghosted entities or previews here.
}
void ComponentDataModel::Drop(QDropEvent* event, AzQtComponents::DragAndDropContextBase& context)
{
using namespace AzToolsFramework;
using namespace AzQtComponents;
// ALWAYS CHECK - you are not the only one connected to this bus, and someone else may have already
// handled the event or accepted the drop - it might not contain types relevant to you.
// you still get informed about the drop event in case you did some stuff in your gui and need to clean it up.
if (!CanAcceptDragAndDropEvent(event, context))
{
return;
}
// note that the above call already checks all the pointers such as event, or whether context is a VP context, mimetype, etc
ViewportDragContext* contextVP = azrtti_cast<ViewportDragContext*>(&context);
// we don't get given this action by Qt unless we already returned accepted from one of the other ones (such as drag move of drag enter)
event->setDropAction(Qt::CopyAction);
event->setAccepted(true);
AzToolsFramework::ScopedUndoBatch undo("Create entity from components");
const AZStd::string name = AZStd::string::format("Entity%d", GetIEditor()->GetObjectManager()->GetObjectCount());
AZ::Entity* newEntity = aznew AZ::Entity(name.c_str());
if (newEntity)
{
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(&AzToolsFramework::EditorEntityContextRequests::AddRequiredComponents, *newEntity);
auto* transformComponent = newEntity->FindComponent<AzToolsFramework::Components::TransformComponent>();
if (transformComponent)
{
transformComponent->SetWorldTM(AZ::Transform::CreateTranslation(contextVP->m_hitLocation));
}
// Add the entity to the editor context, which activates it and creates the sandbox object.
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(&AzToolsFramework::EditorEntityContextRequests::AddEditorEntity, newEntity);
// Prepare undo command last so it captures the final state of the entity.
AzToolsFramework::EntityCreateCommand* command = aznew AzToolsFramework::EntityCreateCommand(static_cast<AZ::u64>(newEntity->GetId()));
command->Capture(newEntity);
command->SetParent(undo.GetUndoBatch());
// Only need to add components to the new entity
AzToolsFramework::EntityIdList entities = { newEntity->GetId() };
AZStd::vector<const AZ::SerializeContext::ClassData*> componentClassDataList;
AzToolsFramework::ComponentTypeMimeData::Get(event->mimeData(), componentClassDataList);
AZ::ComponentTypeList componentsToAdd;
for (auto classData : componentClassDataList)
{
if (!classData)
{
continue;
}
componentsToAdd.push_back(classData->m_typeId);
}
AzToolsFramework::EntityCompositionRequests::AddComponentsOutcome addedComponentsResult = AZ::Failure(AZStd::string("Failed to call AddComponentsToEntities on EntityCompositionRequestBus"));
AzToolsFramework::EntityCompositionRequestBus::BroadcastResult(addedComponentsResult, &AzToolsFramework::EntityCompositionRequests::AddComponentsToEntities, entities, componentsToAdd);
ToolsApplicationRequests::Bus::Broadcast(&ToolsApplicationRequests::AddDirtyEntity, newEntity->GetId());
AzToolsFramework::ToolsApplicationRequestBus::Broadcast(&AzToolsFramework::ToolsApplicationRequests::SetSelectedEntities, entities);
}
}
AZ::EntityId ComponentDataProxyModel::NewEntityFromSelection(const QModelIndexList& selection)
{
return CreateEntityFromSelection(selection, this);
}
AZ::EntityId ComponentDataModel::NewEntityFromSelection(const QModelIndexList& selection)
{
return CreateEntityFromSelection(selection, this);
}
bool ComponentDataProxyModel::filterAcceptsRow(int sourceRow, [[maybe_unused]] const QModelIndex &sourceParent) const
{
if (m_selectedCategory.empty() && !filterRegExp().isValid())
return true;
ComponentDataModel* dataModel = static_cast<ComponentDataModel*>(sourceModel());
if (sourceRow < 0 || sourceRow >= dataModel->GetComponents().size())
{
return false;
}
const AZ::SerializeContext::ClassData* classData = dataModel->GetComponents()[sourceRow];
if (!classData)
{
return false;
}
// Get Category
if (!m_selectedCategory.empty())
{
AZStd::string currentCateogry = ComponentDataModel::GetCategory(classData);
if (AzFramework::StringFunc::Find(currentCateogry.c_str(), m_selectedCategory.c_str()))
{
return false;
}
}
if (filterRegExp().isValid())
{
QString componentName = QString::fromUtf8(classData->m_editData->m_name);
return componentName.contains(filterRegExp());
}
return true;
}
void ComponentDataProxyModel::SetSelectedCategory(const AZStd::string& category)
{
m_selectedCategory = category;
invalidate();
}
void ComponentDataProxyModel::ClearSelectedCategory()
{
m_selectedCategory.clear();
invalidate();
}
#include "UI/ComponentPalette/moc_ComponentDataModel.cpp"
@@ -1,128 +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
#if !defined(Q_MOC_RUN)
#include <QAbstractTableModel>
#include <QSortFilterProxyModel>
#include <AzCore/EBus/EBus.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Component/EntityId.h>
#include <AzCore/std/containers/set.h>
#include <AzCore/std/containers/vector.h>
#include <AzQtComponents/Buses/DragAndDrop.h>
#endif
namespace ComponentDataUtilities
{
// Given a list of selected components, use the provided model to get the components to add to any selected entities.
void AddComponentsToSelectedEntities(const QModelIndexList& selectedComponents, QAbstractItemModel* model);
}
class CViewport;
//! ComponentDataModel
//! Holds the data required to display components in a table, this includes component name, categories, icons.
class ComponentDataModel
: public QAbstractTableModel
, protected AzQtComponents::DragAndDropEventsBus::Handler // its okay if more than one of these is installed, the first one gets it.
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(ComponentDataModel, AZ::SystemAllocator, 0);
using ComponentClassList = AZStd::vector<const AZ::SerializeContext::ClassData*>;
using ComponentCategorySet = AZStd::set<AZStd::string>;
using ComponentClassMap = AZStd::unordered_map<AZStd::string, AZStd::vector<const AZ::SerializeContext::ClassData*>>;
using ComponentIconMap = AZStd::unordered_map<AZ::Uuid, QIcon>;
enum ColumnIndex
{
Icon,
Category,
Name,
Count
};
enum CustomRoles
{
ClassDataRole = Qt::UserRole + 1
};
ComponentDataModel(QObject* parent = nullptr);
~ComponentDataModel() override;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &child) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QMimeData* mimeData(const QModelIndexList& indexes) const override;
const AZ::SerializeContext::ClassData* GetClassData(const QModelIndex&) const;
AZ::EntityId NewEntityFromSelection(const QModelIndexList& selection);
static const char* GetCategory(const AZ::SerializeContext::ClassData* classData);
ComponentClassList& GetComponents() { return m_componentList; }
ComponentCategorySet& GetCategories() { return m_categories; }
protected:
//////////////////////////////////////////////////////////////////////////
// AzQtComponents::DragAndDropEventsBus::Handler
//////////////////////////////////////////////////////////////////////////
void DragEnter(QDragEnterEvent* event, AzQtComponents::DragAndDropContextBase& context) override;
void DragMove(QDragMoveEvent* event, AzQtComponents::DragAndDropContextBase& context) override;
void DragLeave(QDragLeaveEvent* event) override;
void Drop(QDropEvent* event, AzQtComponents::DragAndDropContextBase& context) override;
bool CanAcceptDragAndDropEvent(QDropEvent* event, AzQtComponents::DragAndDropContextBase& context) const;
ComponentClassList m_componentList;
ComponentClassMap m_componentMap;
ComponentIconMap m_componentIcons;
ComponentCategorySet m_categories;
};
//! ComponentDataProxyModel
//! FilterProxy for the ComponentDataModel is used along with the search criteria to filter the
//! list of components based on tags and/or selected category.
class ComponentDataProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(ComponentDataProxyModel, AZ::SystemAllocator, 0);
ComponentDataProxyModel(QObject* parent = nullptr)
: QSortFilterProxyModel(parent)
{}
// Creates a new entity and adds the selected components to it.
// It is specialized here to ensure it uses the correct indices according to the sorted data.
AZ::EntityId NewEntityFromSelection(const QModelIndexList& selection);
// Filters rows according to the specifed tags and/or selected category
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
// Set the category to filter by.
void SetSelectedCategory(const AZStd::string& category);
void ClearSelectedCategory();
protected:
AZStd::string m_selectedCategory;
};
@@ -1,116 +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 "ComponentPaletteWindow.h"
#include "ComponentDataModel.h"
#include "FavoriteComponentList.h"
#include "FilteredComponentList.h"
#include "CategoriesList.h"
#include <LyViewPaneNames.h>
#include <AzCore/Component/Component.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzToolsFramework/UI/SearchWidget/SearchCriteriaWidget.hxx>
#include <AzToolsFramework/ToolsComponents/ComponentMimeData.h>
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/API/ViewPaneOptions.h>
#include <QLabel>
#include <QKeyEvent>
ComponentPaletteWindow::ComponentPaletteWindow(QWidget* parent)
: QMainWindow(parent)
{
Init();
}
void ComponentPaletteWindow::Init()
{
layout()->setSizeConstraint(QLayout::SetMinimumSize);
QVBoxLayout* layout = new QVBoxLayout();
layout->setSizeConstraint(QLayout::SetMinimumSize);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
QHBoxLayout* gridLayout = new QHBoxLayout(nullptr);
gridLayout->setSizeConstraint(QLayout::SetMaximumSize);
gridLayout->setContentsMargins(0, 0, 0, 0);
gridLayout->setSpacing(0);
m_filterWidget = new AzToolsFramework::SearchCriteriaWidget(this);
QStringList tags;
tags << tr("name");
m_filterWidget->SetAcceptedTags(tags, tags[0]);
layout->addLayout(gridLayout, 1);
// Left Panel
QVBoxLayout* leftPaneLayout = new QVBoxLayout(this);
// Favorites
leftPaneLayout->addWidget(new QLabel(tr("Favorites")));
leftPaneLayout->addWidget(new QLabel(tr("Drag components here to add favorites.")));
FavoritesList* favorites = new FavoritesList();
favorites->Init();
leftPaneLayout->addWidget(favorites);
// Categories
m_categoryListWidget = new ComponentCategoryList();
m_categoryListWidget->Init();
leftPaneLayout->addWidget(m_categoryListWidget);
gridLayout->addLayout(leftPaneLayout);
// Right Panel
QVBoxLayout* rightPanelLayout = new QVBoxLayout(this);
gridLayout->addLayout(rightPanelLayout);
// Component list
m_componentListWidget = new FilteredComponentList(this);
m_componentListWidget->Init();
rightPanelLayout->addWidget(new QLabel(tr("Components")));
rightPanelLayout->addWidget(m_filterWidget, 0, Qt::AlignTop);
rightPanelLayout->addWidget(m_componentListWidget);
// The main window
QWidget* window = new QWidget();
window->setLayout(layout);
setCentralWidget(window);
connect(m_categoryListWidget, &ComponentCategoryList::OnCategoryChange, m_componentListWidget, &FilteredComponentList::SetCategory);
connect(m_filterWidget, &AzToolsFramework::SearchCriteriaWidget::SearchCriteriaChanged, m_componentListWidget, &FilteredComponentList::SearchCriteriaChanged);
}
void ComponentPaletteWindow::keyPressEvent(QKeyEvent* event)
{
if (event->modifiers().testFlag(Qt::ControlModifier) && event->key() == Qt::Key_F)
{
m_filterWidget->SelectTextEntryBox();
}
else
{
QMainWindow::keyPressEvent(event);
}
}
void ComponentPaletteWindow::RegisterViewClass()
{
using namespace AzToolsFramework;
ViewPaneOptions options;
options.canHaveMultipleInstances = true;
RegisterViewPane<ComponentPaletteWindow>("Component Palette", LyViewPane::CategoryOther, options);
}
#include <UI/ComponentPalette/moc_ComponentPaletteWindow.cpp>
@@ -1,59 +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
#if !defined(Q_MOC_RUN)
#include <AzCore/PlatformIncl.h>
#include <QMainWindow>
#include <AzCore/Math/Guid.h>
#endif
namespace AzToolsFramework
{
class SearchCriteriaWidget;
}
class ComponentCategoryList;
class FilteredComponentList;
class ComponentDataModel;
//! ComponentPaletteWindow
//! Provides a window with controls related to the Component Entity system. It provides an intuitive and organized
//! set of controls to display, sort, filter components. It provides mechanisms for creating entities by dragging
//! and dropping components into the viewport as well as from context menus.
class ComponentPaletteWindow
: public QMainWindow
{
Q_OBJECT
public:
explicit ComponentPaletteWindow(QWidget* parent = 0);
void Init();
static const GUID& GetClassID()
{
// {4236998F-1138-466D-9DF5-6533BFA1DFCA}
static const GUID guid =
{
0x4236998F, 0x1138, 0x466D, { 0x9D, 0xF5, 0x65, 0x33, 0xBF, 0xA1, 0xDF, 0xCA }
};
return guid;
}
static void RegisterViewClass();
protected:
ComponentCategoryList* m_categoryListWidget;
FilteredComponentList* m_componentListWidget;
AzToolsFramework::SearchCriteriaWidget* m_filterWidget;
void keyPressEvent(QKeyEvent* event) override;
};
@@ -1,392 +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 "FavoriteComponentList.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <Editor/CryEditDoc.h>
#include <Editor/ViewManager.h>
#include <QHeaderView>
#include <QMimeData>
// FavoritesList
//////////////////////////////////////////////////////////////////////////
FavoritesList::FavoritesList(QWidget* parent /*= nullptr*/)
: FilteredComponentList(parent)
{
}
FavoritesList::~FavoritesList()
{
FavoriteComponentListRequestBus::Handler::BusDisconnect();
}
void FavoritesList::Init()
{
FavoriteComponentListRequestBus::Handler::BusConnect();
FavoritesDataModel* favoritesDataModel = new FavoritesDataModel(this);
setModel(favoritesDataModel);
horizontalHeader()->setSectionResizeMode(ComponentDataModel::ColumnIndex::Name, QHeaderView::Stretch);
setShowGrid(false);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setSelectionMode(QAbstractItemView::SelectionMode::ExtendedSelection);
setStyleSheet("QTableView { selection-background-color: rgba(255,255,255,0.2); }");
setGridStyle(Qt::PenStyle::NoPen);
verticalHeader()->hide();
horizontalHeader()->hide();
setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
setShowGrid(false);
setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
setColumnWidth(ComponentDataModel::ColumnIndex::Icon, 32);
hideColumn(ComponentDataModel::ColumnIndex::Category);
setDragDropMode(QAbstractItemView::DragDrop);
setAcceptDrops(true);
horizontalHeader()->setSectionResizeMode(ComponentDataModel::ColumnIndex::Icon, QHeaderView::ResizeToContents);
setColumnWidth(ComponentDataModel::ColumnIndex::Icon, 32);
horizontalHeader()->setSectionResizeMode(ComponentDataModel::ColumnIndex::Category, QHeaderView::Stretch);
setColumnWidth(ComponentDataModel::ColumnIndex::Category, 90);
// Context menu
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, &QWidget::customContextMenuRequested, this, &FavoritesList::ShowContextMenu);
}
void FavoritesList::ShowContextMenu(const QPoint& pos)
{
// Only show if a level is loaded
if (!GetIEditor() || GetIEditor()->IsInGameMode())
{
return;
}
if ( model()->rowCount() == 0)
{
return;
}
QMenu contextMenu(tr("Context menu"), this);
QAction actionNewEntity(tr("Make entity with selected favorites"), this);
QAction actionAddToSelection(this);
if (GetIEditor()->GetDocument()->IsDocumentReady())
{
QObject::connect(&actionNewEntity, &QAction::triggered, this, [&] { ContextMenu_NewEntity(); });
contextMenu.addAction(&actionNewEntity);
AzToolsFramework::EntityIdList selectedEntities;
EBUS_EVENT_RESULT(selectedEntities, AzToolsFramework::ToolsApplicationRequests::Bus, GetSelectedEntities);
if (!selectedEntities.empty())
{
QString addToSelection = selectedEntities.size() > 1 ? tr("Add to selected entities") : tr("Add to selected entity");
actionAddToSelection.setText(addToSelection);
QObject::connect(&actionAddToSelection, &QAction::triggered, this, [&] { ContextMenu_AddToSelectedEntities(); });
contextMenu.addAction(&actionAddToSelection);
}
contextMenu.addSeparator();
}
QAction action(tr("Remove"), this);
QObject::connect(&action, &QAction::triggered, this, [&] { ContextMenu_RemoveSelectedFavorites(); });
contextMenu.addAction(&action);
contextMenu.exec(mapToGlobal(pos));
}
void FavoritesList::ContextMenu_RemoveSelectedFavorites()
{
FavoritesDataModel* dataModel = qobject_cast<FavoritesDataModel*>(model());
if (!selectedIndexes().empty())
{
dataModel->Remove(selectedIndexes());
}
}
void FavoritesList::rowsInserted([[maybe_unused]] const QModelIndex& parent, [[maybe_unused]] int start, [[maybe_unused]] int end)
{
resizeRowToContents(0);
}
void FavoritesList::AddFavorites(const AZStd::vector<const AZ::SerializeContext::ClassData*>& classDataContainer)
{
for (const AZ::SerializeContext::ClassData* classData : classDataContainer)
{
if (classData)
{
FavoritesDataModel* dataModel = qobject_cast<FavoritesDataModel*>(model());
dataModel->AddFavorite(classData);
}
}
}
void FavoritesList::dragEnterEvent(QDragEnterEvent* event)
{
if (event->mimeData()->hasFormat(AzToolsFramework::ComponentTypeMimeData::GetMimeType()))
{
event->acceptProposedAction();
}
}
void FavoritesList::dragMoveEvent(QDragMoveEvent* event)
{
if (event->source() == this)
{
event->ignore();
}
else
{
event->accept();
}
}
// FavoritesDataModel
//////////////////////////////////////////////////////////////////////////
int FavoritesDataModel::rowCount([[maybe_unused]] const QModelIndex &parent /*= QModelIndex()*/) const
{
return m_favorites.size();
}
int FavoritesDataModel::columnCount([[maybe_unused]] const QModelIndex &parent /*= QModelIndex()*/) const
{
return ColumnIndex::Count;
}
void FavoritesDataModel::SaveState()
{
AZStd::vector<AZ::Uuid> favorites;
for (const AZ::SerializeContext::ClassData* classData : m_favorites)
{
favorites.push_back(classData->m_typeId);
}
m_settings->SetFavorites(AZStd::move(favorites));
// Write the settings to file...
AZ::SerializeContext* serializeContext = nullptr;
EBUS_EVENT_RESULT(serializeContext, AZ::ComponentApplicationBus, GetSerializeContext);
AZ_Assert(serializeContext, "Serialize Context is null!");
char settingsPath[AZ_MAX_PATH_LEN] = { 0 };
AZ::IO::FileIOBase::GetInstance()->ResolvePath(ComponentPaletteSettings::GetSettingsFile(), settingsPath, AZ_MAX_PATH_LEN);
bool result = m_provider.Save(settingsPath, serializeContext);
(void)result;
AZ_Warning("ComponentPaletteSettings", result, "Failed to Save the Component Palette Settings!");
}
void FavoritesDataModel::LoadState()
{
// It is necessary to Load the settings file *before* you call UserSettings::CreateFind!
AZ::SerializeContext* serializeContext = nullptr;
EBUS_EVENT_RESULT(serializeContext, AZ::ComponentApplicationBus, GetSerializeContext);
AZ_Assert(serializeContext, "Serialize Context is null!");
char settingsPath[AZ_MAX_PATH_LEN] = { 0 };
AZ::IO::FileIOBase::GetInstance()->ResolvePath(ComponentPaletteSettings::GetSettingsFile(), settingsPath, AZ_MAX_PATH_LEN);
bool result = m_provider.Load(settingsPath, serializeContext);
(void)result;
// Create (if no file was found) or find the settings, this will populate the m_settings->m_favorites list.
m_settings = AZ::UserSettings::CreateFind<ComponentPaletteSettings>(AZ_CRC("ComponentPaletteSettings", 0x481d355b), m_providerId);
// Add favorites to the data model from loaded settings
for (const AZ::Uuid& favorite : m_settings->m_favorites)
{
const AZ::SerializeContext::ClassData* classData = serializeContext->FindClassData(favorite);
if (classData)
{
AddFavorite(classData, false);
}
}
}
void FavoritesDataModel::Remove(const QModelIndexList& indices)
{
beginResetModel();
auto newFavorites = m_favorites;
// swap here
for (auto index : indices)
{
// we're only dealing with columns and they're the only thing with class data anyways
if (index.column() == 0)
{
QVariant classDataVariant = index.data(ComponentDataModel::ClassDataRole);
if (classDataVariant.isValid())
{
const AZ::SerializeContext::ClassData* classData = reinterpret_cast<const AZ::SerializeContext::ClassData*>(classDataVariant.value<void*>());
newFavorites.removeAll(classData);
AZ_TracePrintf("Debug", "Removing: %s\n", classData->m_editData->m_name);
}
}
}
m_favorites.swap(newFavorites);
endResetModel();
SaveState();
}
QModelIndex FavoritesDataModel::index(int row, int column, const QModelIndex &parent) const
{
if (!hasIndex(row, column, parent))
{
return QModelIndex();
}
if (row >= rowCount(parent) || column >= columnCount(parent))
{
return QModelIndex();
}
return createIndex(row, column, (void*)(m_favorites[row]));
}
QVariant FavoritesDataModel::data(const QModelIndex &index, int role /*= Qt::DisplayRole*/) const
{
if (!index.isValid())
{
return QVariant();
}
const AZ::SerializeContext::ClassData* classData = m_favorites[index.row()];
if (!classData)
{
return QVariant();
}
switch (role)
{
case Qt::DisplayRole:
{
if (index.column() == ComponentDataModel::ColumnIndex::Name)
{
if (m_favorites.empty())
{
return QVariant(tr("You have 0 favorites.\nDrag some components here."));
}
return QVariant(classData->m_editData->m_name);
}
}
break;
case Qt::DecorationRole:
{
if (index.column() == ColumnIndex::Icon)
{
const AZ::SerializeContext::ClassData* iconClassData = m_favorites[index.row()];
auto iconIterator = m_componentIcons.find(iconClassData->m_typeId);
if (iconIterator != m_componentIcons.end())
{
return iconIterator->second;
}
return QVariant();
}
}
break;
case ClassDataRole:
if (index.column() == 0) // Only get data for one column
{
return QVariant::fromValue<void*>(reinterpret_cast<void*>(const_cast<AZ::SerializeContext::ClassData*>(classData)));
}
break;
default:
break;
}
return ComponentDataModel::data(index, role);
}
void FavoritesDataModel::SetSavedStateKey([[maybe_unused]] AZ::u32 key)
{
}
FavoritesDataModel::FavoritesDataModel(QWidget* parent /*= nullptr*/)
: ComponentDataModel(parent)
, m_providerId(AZ_CRC("ComponentPaletteSettingsProviderId"))
{
m_provider.Activate(m_providerId);
LoadState();
}
FavoritesDataModel::~FavoritesDataModel()
{
m_provider.Deactivate();
}
void FavoritesDataModel::AddFavorite(const AZ::SerializeContext::ClassData* classData, bool updateSettings)
{
beginResetModel();
if (m_favorites.indexOf(classData) < 0)
{
m_favorites.push_back(classData);
}
endResetModel();
if (updateSettings)
{
SaveState();
}
}
bool FavoritesDataModel::dropMimeData(const QMimeData *data, Qt::DropAction action, [[maybe_unused]] int row, [[maybe_unused]] int column, [[maybe_unused]] const QModelIndex &parent)
{
if (action == Qt::IgnoreAction)
{
return true;
}
if (data && data->hasFormat(AzToolsFramework::ComponentTypeMimeData::GetMimeType()))
{
AzToolsFramework::ComponentTypeMimeData::ClassDataContainer classDataContainer;
AzToolsFramework::ComponentTypeMimeData::Get(data, classDataContainer);
for (const AZ::SerializeContext::ClassData* classData : classDataContainer)
{
if (classData)
{
AddFavorite(classData);
}
}
return true;
}
return false;
}
#include <UI/ComponentPalette/moc_FavoriteComponentList.cpp>
@@ -1,117 +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
#if !defined(Q_MOC_RUN)
#include "ComponentDataModel.h"
#include "FilteredComponentList.h"
#include "ComponentPaletteSettings.h"
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/UserSettings/UserSettingsProvider.h>
#include <AzToolsFramework/ToolsComponents/ComponentMimeData.h>
#include <AzToolsFramework/ToolsComponents/ComponentAssetMimeDataContainer.h>
#endif
//! FavoriteComponentListRequest
//! Bus that provides a way for external features to record favorites
class FavoriteComponentListRequest : public AZ::EBusTraits
{
public:
virtual void AddFavorites(const AZStd::vector<const AZ::SerializeContext::ClassData*>&) = 0;
};
using FavoriteComponentListRequestBus = AZ::EBus<FavoriteComponentListRequest>;
//! FavoritesDataModel
//! Stores the list of component class data to display in the favorites control, offers persistence through user settings.
class FavoritesDataModel
: public ComponentDataModel
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(FavoritesDataModel, AZ::SystemAllocator, 0);
FavoritesDataModel(QWidget* parent = nullptr);
~FavoritesDataModel() override;
//! Add a favorite component
//! \param classData The ClassData information for the component to store as favorite
//! \param updateSettings Optional parameter used to determine if the persistent settings need to be updated.
void AddFavorite(const AZ::SerializeContext::ClassData* classData, bool updateSettings = true);
//! Remove all the specified items from the table
//! \param indices List of indices to remove from favorites
void Remove(const QModelIndexList& indices);
//! Save the list of favorite components to user settings
void SaveState();
//! Load the list of favorite components from user settings
void LoadState();
protected:
void SetSavedStateKey(AZ::u32 key);
// Qt handlers
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
// List of component class data
QList<const AZ::SerializeContext::ClassData*> m_favorites;
// The Palette settings and provider information for saving out the Favorites list
AZStd::intrusive_ptr<ComponentPaletteSettings> m_settings;
AZ::UserSettingsProvider m_provider;
AZ::u32 m_providerId;
};
//! FavoritesList
//! User customized list of favorite components, provides persistence.
class FavoritesList
: public FilteredComponentList
, FavoriteComponentListRequestBus::Handler
{
Q_OBJECT
public:
explicit FavoritesList(QWidget* parent = nullptr);
~FavoritesList() override;
void Init() override;
protected:
//////////////////////////////////////////////////////////////////////////
// FavoriteComponentListRequestBus
void AddFavorites(const AZStd::vector<const AZ::SerializeContext::ClassData*>& classDataContainer) override;
//////////////////////////////////////////////////////////////////////////
void rowsInserted(const QModelIndex& parent, int start, int end) override;
// Context menu handlers
void ShowContextMenu(const QPoint&);
void ContextMenu_RemoveSelectedFavorites();
// Validate data being dragged in
void dragEnterEvent(QDragEnterEvent * event) override;
void dragMoveEvent(QDragMoveEvent* event) override;
//! Handler used when dropping PaletteItems into the Viewport.
static void DragDropHandler(CViewport* viewport, int ptx, int pty, void* custom);
};
@@ -1,264 +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 "ComponentDataModel.h"
#include "FavoriteComponentList.h"
#include "FilteredComponentList.h"
#include "CryCommon/MathConversion.h"
#include "Editor/IEditor.h"
#include "Editor/ViewManager.h"
#include <Editor/CryEditDoc.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <QHeaderView>
void FilteredComponentList::Init()
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setDragDropMode(QAbstractItemView::DragDropMode::DragOnly);
setDragEnabled(true);
setSelectionMode(QAbstractItemView::SelectionMode::ExtendedSelection);
setStyleSheet("QTreeWidget { selection-background-color: rgba(255,255,255,0.2); }");
setGridStyle(Qt::PenStyle::NoPen);
verticalHeader()->hide();
horizontalHeader()->hide();
setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
setAcceptDrops(false);
m_componentDataModel = new ComponentDataModel(this);
ComponentDataProxyModel* componentDataProxyModel = new ComponentDataProxyModel(this);
componentDataProxyModel->setSourceModel(m_componentDataModel);
setModel(componentDataProxyModel);
QHeaderView* horizontalHeaderView = horizontalHeader();
horizontalHeaderView->setSectionResizeMode(ComponentDataModel::ColumnIndex::Icon, QHeaderView::ResizeToContents);
horizontalHeaderView->setSectionResizeMode(ComponentDataModel::ColumnIndex::Name, QHeaderView::Stretch);
setColumnWidth(ComponentDataModel::ColumnIndex::Icon, 32);
setShowGrid(false);
setColumnWidth(ComponentDataModel::ColumnIndex::Name, 90);
setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
sortByColumn(ComponentDataModel::ColumnIndex::Name, Qt::AscendingOrder);
hideColumn(ComponentDataModel::ColumnIndex::Category);
connect(model(), &QAbstractItemModel::rowsInserted, this, &FilteredComponentList::rowsInserted);
connect(model(), &QAbstractItemModel::rowsRemoved, this, &FilteredComponentList::rowsAboutToBeRemoved);
connect(model(), SIGNAL(modelReset()), SLOT(modelReset()));
// Context menu
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, &QWidget::customContextMenuRequested, this, &FilteredComponentList::ShowContextMenu);
}
void FilteredComponentList::ContextMenu_NewEntity()
{
AZ::EntityId entityId;
auto proxyDataModel = qobject_cast<ComponentDataProxyModel*>(model());
if (proxyDataModel)
{
entityId = proxyDataModel->NewEntityFromSelection(selectedIndexes());
}
else
{
auto dataModel = qobject_cast<ComponentDataModel*>(model());
if (dataModel)
{
entityId = dataModel->NewEntityFromSelection(selectedIndexes());
}
}
}
void FilteredComponentList::ContextMenu_AddToFavorites()
{
AZStd::vector<const AZ::SerializeContext::ClassData*> componentsToAdd;
for (auto index : selectedIndexes())
{
QVariant classDataVariant = index.data(ComponentDataModel::ClassDataRole);
if (classDataVariant.isValid())
{
auto classData = reinterpret_cast<const AZ::SerializeContext::ClassData*>(classDataVariant.value<void*>());
componentsToAdd.push_back(classData);
}
}
if (!componentsToAdd.empty())
{
EBUS_EVENT(FavoriteComponentListRequestBus, AddFavorites, componentsToAdd);
}
}
void FilteredComponentList::ContextMenu_AddToSelectedEntities()
{
ComponentDataUtilities::AddComponentsToSelectedEntities(selectedIndexes(), model());
}
void FilteredComponentList::ShowContextMenu(const QPoint& pos)
{
QMenu contextMenu(tr("Context menu"), this);
QAction actionNewEntity(tr("Create new entity with selected components"), this);
if (GetIEditor()->GetDocument()->IsDocumentReady())
{
QObject::connect(&actionNewEntity, &QAction::triggered, this, [this] { ContextMenu_NewEntity(); });
contextMenu.addAction(&actionNewEntity);
}
QAction actionAddFavorite(tr("Add to favorites"), this);
QObject::connect(&actionAddFavorite, &QAction::triggered, this, [this] { ContextMenu_AddToFavorites(); });
contextMenu.addAction(&actionAddFavorite);
QAction actionAddToSelection(this);
if (GetIEditor()->GetDocument()->IsDocumentReady())
{
AzToolsFramework::EntityIdList selectedEntities;
EBUS_EVENT_RESULT(selectedEntities, AzToolsFramework::ToolsApplicationRequests::Bus, GetSelectedEntities);
if (!selectedEntities.empty())
{
QString addToSelection = selectedEntities.size() > 1 ? tr("Add to selected entities") : tr("Add to selected entity");
actionAddToSelection.setText(addToSelection);
QObject::connect(&actionAddToSelection, &QAction::triggered, this, [this] { ContextMenu_AddToSelectedEntities(); });
contextMenu.addAction(&actionAddToSelection);
}
}
// TODO: Requires information panel implementation LMBR-28174
//QAction actionHelp(tr("Help"), this);
//QObject::connect(&actionHelp, &QAction::triggered, this, [&] {});
//contextMenu.addAction(&actionHelp);
contextMenu.exec(mapToGlobal(pos));
}
void FilteredComponentList::modelReset()
{
// Ensure that the category column is hidden
hideColumn(ComponentDataModel::ColumnIndex::Category);
}
FilteredComponentList::FilteredComponentList(QWidget* parent /*= nullptr*/)
: QTableView(parent)
{
}
FilteredComponentList::~FilteredComponentList()
{
}
void FilteredComponentList::SearchCriteriaChanged(QStringList& criteriaList, AzToolsFramework::FilterOperatorType filterOperator)
{
setUpdatesEnabled(false);
auto dataModel = qobject_cast<ComponentDataProxyModel*>(model());
if (dataModel)
{
// Go through the list of items and show/hide as needed due to filter.
QString filter;
for (const auto& criteria : criteriaList)
{
QString tag, text;
AzToolsFramework::SearchCriteriaButton::SplitTagAndText(criteria, tag, text);
AppendFilter(filter, text, filterOperator);
}
dataModel->setFilterRegExp(QRegExp(filter, Qt::CaseSensitivity::CaseInsensitive));
}
setUpdatesEnabled(true);
}
void FilteredComponentList::SetCategory(const char* category)
{
auto dataModel = qobject_cast<ComponentDataProxyModel*>(model());
if (dataModel)
{
if (!category || category[0] == 0 || azstricmp(category, "All") == 0)
{
dataModel->ClearSelectedCategory();
}
else
{
dataModel->SetSelectedCategory(category);
}
}
// Note: this ensures the category column remains hidden
hideColumn(ComponentDataModel::ColumnIndex::Category);
}
void FilteredComponentList::BuildFilter(QStringList& criteriaList, AzToolsFramework::FilterOperatorType filterOperator)
{
ClearFilterRegExp();
for (const auto& criteria : criteriaList)
{
QString tag, text;
AzToolsFramework::SearchCriteriaButton::SplitTagAndText(criteria, tag, text);
if (tag.isEmpty())
{
tag = "null";
}
QString filter = m_filtersRegExp[tag.toStdString().c_str()].pattern();
AppendFilter(filter, text, filterOperator);
SetFilterRegExp(tag.toStdString().c_str(), QRegExp(filter, Qt::CaseInsensitive));
}
}
void FilteredComponentList::AppendFilter(QString& filter, const QString& text, AzToolsFramework::FilterOperatorType filterOperator)
{
if (filterOperator == AzToolsFramework::FilterOperatorType::Or)
{
if (filter.isEmpty())
{
filter = text;
}
else
{
filter += "|" + text;
}
}
else if (filterOperator == AzToolsFramework::FilterOperatorType::And)
{
//using lookaheads to produce an "and" effect.
filter += "(?=.*" + text + ")";
}
}
void FilteredComponentList::SetFilterRegExp(const AZStd::string& filterType, const QRegExp& regExp)
{
m_filtersRegExp[filterType] = regExp;
}
void FilteredComponentList::ClearFilterRegExp(const AZStd::string& filterType /*= AZStd::string()*/)
{
if (filterType.empty())
{
for (auto& it : m_filtersRegExp)
{
it.second = QRegExp();
}
}
else
{
m_filtersRegExp[filterType] = QRegExp();
}
}
#include <UI/ComponentPalette/moc_FilteredComponentList.cpp>
@@ -1,68 +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
#if !defined(Q_MOC_RUN)
#include <QTableView>
#include <QWidget>
#include <AzToolsFramework/UI/SearchWidget/SearchCriteriaWidget.hxx>
#include <AzToolsFramework/UI/SearchWidget/SearchWidgetTypes.hxx>
#include <AzCore/Serialization/SerializeContext.h>
#include "ComponentDataModel.h"
#endif
namespace AZ
{
class SerializeContext;
class ClassData;
}
class ComponentDataModel;
//! FilteredComponentList
//! Provides a list of components that can be filtered according to search criteria provided and/or from
//! a category selection control.
class FilteredComponentList
: public QTableView
{
Q_OBJECT
public:
explicit FilteredComponentList(QWidget* parent = nullptr);
~FilteredComponentList() override;
virtual void Init();
void SearchCriteriaChanged(QStringList& criteriaList, AzToolsFramework::FilterOperatorType filterOperator);
void SetCategory(const char* category);
protected:
// Filtering support
void BuildFilter(QStringList& criteriaList, AzToolsFramework::FilterOperatorType filterOperator);
void AppendFilter(QString& filter, const QString& text, AzToolsFramework::FilterOperatorType filterOperator);
void SetFilterRegExp(const AZStd::string& filterType, const QRegExp& regExp);
void ClearFilterRegExp(const AZStd::string& filterType = AZStd::string());
// Context menu handlers
void ShowContextMenu(const QPoint&);
void ContextMenu_NewEntity();
void ContextMenu_AddToFavorites();
void ContextMenu_AddToSelectedEntities();
void modelReset();
AzToolsFramework::FilterByCategoryMap m_filtersRegExp;
ComponentDataModel* m_componentDataModel;
};
@@ -1,12 +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 "InformationPanel.h"
// TODO: LMBR-28174
@@ -1,11 +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
// TODO: LMBR-28174
@@ -20,19 +20,7 @@ set(FILES
UI/QComponentEntityEditorOutlinerWindow.cpp
UI/AssetCatalogModel.h
UI/AssetCatalogModel.cpp
UI/ComponentPalette/CategoriesList.h
UI/ComponentPalette/CategoriesList.cpp
UI/ComponentPalette/ComponentDataModel.h
UI/ComponentPalette/ComponentDataModel.cpp
UI/ComponentPalette/ComponentPaletteSettings.h
UI/ComponentPalette/ComponentPaletteWindow.h
UI/ComponentPalette/ComponentPaletteWindow.cpp
UI/ComponentPalette/FavoriteComponentList.h
UI/ComponentPalette/FavoriteComponentList.cpp
UI/ComponentPalette/FilteredComponentList.h
UI/ComponentPalette/FilteredComponentList.cpp
UI/ComponentPalette/InformationPanel.h
UI/ComponentPalette/InformationPanel.cpp
UI/Outliner/OutlinerDisplayOptionsMenu.h
UI/Outliner/OutlinerDisplayOptionsMenu.cpp
UI/Outliner/OutlinerTreeView.hxx
@@ -7,7 +7,6 @@
*/
#include <AssetImporterDocument.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <SceneAPI/SceneCore/Export/MtlMaterialExporter.h>
#include <Util/PathUtil.h>
#include <GFxFramework/MaterialIO/IMaterial.h>
@@ -1,10 +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 "../../Editor/RenderHelpers/AxisHelperShared.inl"
@@ -1,700 +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
*
*/
// Copied utils functions from CryPhysics that are used by non-physics systems
// This functions will be eventually removed, DO *NOT* use these functions
// TO-DO: Re-implement users using new code
// LY-109806
#pragma once
#include "Cry_Math.h"
namespace LegacyCryPhysicsUtils
{
namespace polynomial_tpl_IMPL
{
template<class ftype, int degree>
class polynomial_tpl
{
public:
explicit polynomial_tpl() { denom = (ftype)1; };
explicit polynomial_tpl(ftype op) { zero(); data[degree] = op; }
AZ_FORCE_INLINE polynomial_tpl& zero()
{
for (int i = 0; i <= degree; i++)
{
data[i] = 0;
}
denom = (ftype)1;
return *this;
}
polynomial_tpl(const polynomial_tpl<ftype, degree>& src) { *this = src; }
polynomial_tpl& operator=(const polynomial_tpl<ftype, degree>& src)
{
denom = src.denom;
for (int i = 0; i <= degree; i++)
{
data[i] = src.data[i];
}
return *this;
}
template<int degree1>
AZ_FORCE_INLINE polynomial_tpl& operator=(const polynomial_tpl<ftype, degree1>& src)
{
int i;
denom = src.denom;
for (i = 0; i <= min(degree, degree1); i++)
{
data[i] = src.data[i];
}
for (; i < degree; i++)
{
data[i] = 0;
}
return *this;
}
AZ_FORCE_INLINE polynomial_tpl& set(ftype* pdata)
{
for (int i = 0; i <= degree; i++)
{
data[degree - i] = pdata[i];
}
return *this;
}
AZ_FORCE_INLINE ftype& operator[](int idx) { return data[idx]; }
void calc_deriviative(polynomial_tpl<ftype, degree>& deriv, int curdegree = degree) const;
AZ_FORCE_INLINE polynomial_tpl& fixsign()
{
ftype sg = sgnnz(denom);
denom *= sg;
for (int i = 0; i <= degree; i++)
{
data[i] *= sg;
}
return *this;
}
int findroots(ftype start, ftype end, ftype* proots, int nIters = 20, int curdegree = degree, bool noDegreeCheck = false) const;
int nroots(ftype start, ftype end) const;
AZ_FORCE_INLINE ftype eval(ftype x) const
{
ftype res = 0;
for (int i = degree; i >= 0; i--)
{
res = res * x + data[i];
}
return res;
}
AZ_FORCE_INLINE ftype eval(ftype x, int subdegree) const
{
ftype res = data[subdegree];
for (int i = subdegree - 1; i >= 0; i--)
{
res = res * x + data[i];
}
return res;
}
AZ_FORCE_INLINE polynomial_tpl& operator+=(ftype op) { data[0] += op * denom; return *this; }
AZ_FORCE_INLINE polynomial_tpl& operator-=(ftype op) { data[0] -= op * denom; return *this; }
AZ_FORCE_INLINE polynomial_tpl operator*(ftype op) const
{
polynomial_tpl<ftype, degree> res;
res.denom = denom;
for (int i = 0; i <= degree; i++)
{
res.data[i] = data[i] * op;
}
return res;
}
AZ_FORCE_INLINE polynomial_tpl& operator*=(ftype op)
{
for (int i = 0; i <= degree; i++)
{
data[i] *= op;
}
return *this;
}
AZ_FORCE_INLINE polynomial_tpl operator/(ftype op) const
{
polynomial_tpl<ftype, degree> res = *this;
res.denom = denom * op;
return res;
}
AZ_FORCE_INLINE polynomial_tpl& operator/=(ftype op) { denom *= op; return *this; }
AZ_FORCE_INLINE polynomial_tpl<ftype, degree * 2> sqr() const { return *this * *this; }
ftype denom;
ftype data[degree + 1];
};
template <class ftype>
struct tagPolyE
{
inline static ftype polye() { return (ftype)1E-10; }
};
template<>
inline float tagPolyE<float>::polye() { return 1e-6f; }
template <class ftype>
inline ftype polye() { return tagPolyE<ftype>::polye(); }
// Don't use this macro; use AZStd::max instead. This is only here to make the template const arguments below readable
// and because Visual Studio 2013 doesn't have a const_expr version of std::max
#define deprecated_degmax(degree1, degree2) (((degree1) > (degree2)) ? (degree1) : (degree2))
template<class ftype, int degree>
AZ_FORCE_INLINE polynomial_tpl<ftype, degree> operator+(const polynomial_tpl<ftype, degree>& pn, ftype op)
{
polynomial_tpl<ftype, degree> res = pn;
res.data[0] += op * res.denom;
return res;
}
template<class ftype, int degree>
AZ_FORCE_INLINE polynomial_tpl<ftype, degree> operator-(const polynomial_tpl<ftype, degree>& pn, ftype op)
{
polynomial_tpl<ftype, degree> res = pn;
res.data[0] -= op * res.denom;
return res;
}
template<class ftype, int degree>
AZ_FORCE_INLINE polynomial_tpl<ftype, degree> operator+(ftype op, const polynomial_tpl<ftype, degree>& pn)
{
polynomial_tpl<ftype, degree> res = pn;
res.data[0] += op * res.denom;
return res;
}
template<class ftype, int degree>
AZ_FORCE_INLINE polynomial_tpl<ftype, degree> operator-(ftype op, const polynomial_tpl<ftype, degree>& pn)
{
polynomial_tpl<ftype, degree> res = pn;
res.data[0] -= op * res.denom;
for (int i = 0; i <= degree; i++)
{
res.data[i] = -res.data[i];
}
return res;
}
template<class ftype, int degree>
polynomial_tpl<ftype, degree * 2> AZ_FORCE_INLINE psqr(const polynomial_tpl<ftype, degree>& op) { return op * op; }
template <class ftype, int degree1, int degree2>
AZ_FORCE_INLINE polynomial_tpl<ftype, deprecated_degmax(degree1, degree2)> operator+(const polynomial_tpl<ftype, degree1>& op1, const polynomial_tpl<ftype, degree2>& op2)
{
polynomial_tpl<ftype, deprecated_degmax(degree1, degree2)> res;
int i;
for (i = 0; i <= min(degree1, degree2); i++)
{
res.data[i] = op1.data[i] * op2.denom + op2.data[i] * op1.denom;
}
for (; i <= degree1; i++)
{
res.data[i] = op1.data[i] * op2.denom;
}
for (; i <= degree2; i++)
{
res.data[i] = op2.data[i] * op1.denom;
}
res.denom = op1.denom * op2.denom;
return res;
}
template <class ftype, int degree1, int degree2>
AZ_FORCE_INLINE polynomial_tpl<ftype, deprecated_degmax(degree1, degree2)> operator-(const polynomial_tpl<ftype, degree1>& op1, const polynomial_tpl<ftype, degree2>& op2)
{
polynomial_tpl<ftype, deprecated_degmax(degree1, degree2)> res;
int i;
for (i = 0; i <= min(degree1, degree2); i++)
{
res.data[i] = op1.data[i] * op2.denom - op2.data[i] * op1.denom;
}
for (; i <= degree1; i++)
{
res.data[i] = op1.data[i] * op2.denom;
}
for (; i <= degree2; i++)
{
res.data[i] = op2.data[i] * op1.denom;
}
res.denom = op1.denom * op2.denom;
return res;
}
template <class ftype, int degree1, int degree2>
AZ_FORCE_INLINE polynomial_tpl<ftype, degree1>& operator+=(polynomial_tpl<ftype, degree1>& op1, const polynomial_tpl<ftype, degree2>& op2)
{
for (int i = 0; i < min(degree1, degree2); i++)
{
op1.data[i] = op1.data[i] * op2.denom + op2.data[i] * op1.denom;
}
op1.denom *= op2.denom;
return op1;
}
template <class ftype, int degree1, int degree2>
AZ_FORCE_INLINE polynomial_tpl<ftype, degree1>& operator-=(polynomial_tpl<ftype, degree1>& op1, const polynomial_tpl<ftype, degree2>& op2)
{
for (int i = 0; i < min(degree1, degree2); i++)
{
op1.data[i] = op1.data[i] * op2.denom - op2.data[i] * op1.denom;
}
op1.denom *= op2.denom;
return op1;
}
template <class ftype, int degree1, int degree2>
AZ_FORCE_INLINE polynomial_tpl<ftype, degree1 + degree2> operator*(const polynomial_tpl<ftype, degree1>& op1, const polynomial_tpl<ftype, degree2>& op2)
{
polynomial_tpl<ftype, degree1 + degree2> res;
res.zero();
int j;
switch (degree1)
{
case 8:
for (j = 0; j <= degree2; j++)
{
res.data[8 + j] += op1.data[8] * op2.data[j];
}
case 7:
for (j = 0; j <= degree2; j++)
{
res.data[7 + j] += op1.data[7] * op2.data[j];
}
case 6:
for (j = 0; j <= degree2; j++)
{
res.data[6 + j] += op1.data[6] * op2.data[j];
}
case 5:
for (j = 0; j <= degree2; j++)
{
res.data[5 + j] += op1.data[5] * op2.data[j];
}
case 4:
for (j = 0; j <= degree2; j++)
{
res.data[4 + j] += op1.data[4] * op2.data[j];
}
case 3:
for (j = 0; j <= degree2; j++)
{
res.data[3 + j] += op1.data[3] * op2.data[j];
}
case 2:
for (j = 0; j <= degree2; j++)
{
res.data[2 + j] += op1.data[2] * op2.data[j];
}
case 1:
for (j = 0; j <= degree2; j++)
{
res.data[1 + j] += op1.data[1] * op2.data[j];
}
case 0:
for (j = 0; j <= degree2; j++)
{
res.data[0 + j] += op1.data[0] * op2.data[j];
}
}
res.denom = op1.denom * op2.denom;
return res;
}
template <class ftype>
AZ_FORCE_INLINE void polynomial_divide(const polynomial_tpl<ftype, 8>& num, const polynomial_tpl<ftype, 8>& den, polynomial_tpl<ftype, 8>& quot,
polynomial_tpl<ftype, 8>& rem, int degree1, int degree2)
{
int i, j, k, l;
ftype maxel;
for (i = 0; i <= degree1; i++)
{
rem.data[i] = num.data[i];
}
for (i = 0; i <= degree1 - degree2; i++)
{
quot.data[i] = 0;
}
for (i = 1, maxel = fabs_tpl(num.data[0]); i <= degree1; i++)
{
maxel = max(maxel, num.data[i]);
}
for (maxel *= polye<ftype>(); degree1 >= 0 && fabs_tpl(num.data[degree1]) < maxel; degree1--)
{
;
}
for (i = 1, maxel = fabs_tpl(den.data[0]); i <= degree2; i++)
{
maxel = max(maxel, den.data[i]);
}
for (maxel *= polye<ftype>(); degree2 >= 0 && fabs_tpl(den.data[degree2]) < maxel; degree2--)
{
;
}
rem.denom = num.denom;
quot.denom = (ftype)1;
if (degree1 < 0 || degree2 < 0)
{
return;
}
for (k = degree1 - degree2, l = degree1; l >= degree2; l--, k--)
{
quot.data[k] = rem.data[l] * den.denom;
quot.denom *= den.data[degree2];
for (i = degree1 - degree2; i > k; i--)
{
quot.data[i] *= den.data[degree2];
}
for (i = degree2 - 1, j = l - 1; i >= 0; i--, j--)
{
rem.data[j] = rem.data[j] * den.data[degree2] - den.data[i] * rem.data[l];
}
for (; j >= 0; j--)
{
rem.data[j] *= den.data[degree2];
}
rem.denom *= den.data[degree2];
}
}
template <class ftype, int degree1, int degree2>
AZ_FORCE_INLINE polynomial_tpl<ftype, degree1 - degree2> operator/(const polynomial_tpl<ftype, degree1>& num, const polynomial_tpl<ftype, degree2>& den)
{
polynomial_tpl<ftype, degree1 - degree2> quot;
polynomial_tpl<ftype, degree1> rem;
polynomial_divide((polynomial_tpl<ftype, 8>&)num, (polynomial_tpl<ftype, 8>&)den, (polynomial_tpl<ftype, 8>&)quot,
(polynomial_tpl<ftype, 8>&)rem, degree1, degree2);
return quot;
}
template <class ftype, int degree1, int degree2>
AZ_FORCE_INLINE polynomial_tpl<ftype, degree2 - 1> operator%(const polynomial_tpl<ftype, degree1>& num, const polynomial_tpl<ftype, degree2>& den)
{
polynomial_tpl<ftype, degree1 - degree2> quot;
polynomial_tpl<ftype, degree1> rem;
polynomial_divide((polynomial_tpl<ftype, 8>&)num, (polynomial_tpl<ftype, 8>&)den, (polynomial_tpl<ftype, 8>&)quot,
(polynomial_tpl<ftype, 8>&)rem, degree1, degree2);
return (polynomial_tpl<ftype, degree2 - 1>&)rem;
}
template <class ftype, int degree>
AZ_FORCE_INLINE void polynomial_tpl<ftype, degree>::calc_deriviative(polynomial_tpl<ftype, degree>& deriv, int curdegree) const
{
for (int i = 0; i < curdegree; i++)
{
deriv.data[i] = data[i + 1] * (i + 1);
}
deriv.denom = denom;
}
template<typename to_t, typename from_t>
to_t* convert_type(from_t* input)
{
typedef union
{
to_t* to;
from_t* from;
} convert_union;
convert_union u;
u.from = input;
return u.to;
}
template <class ftype, int degree>
AZ_FORCE_INLINE int polynomial_tpl<ftype, degree>::nroots(ftype start, ftype end) const
{
polynomial_tpl<ftype, degree> f[degree + 1];
int i, j, sg_a, sg_b;
ftype val, prevval;
calc_deriviative(f[0]);
polynomial_divide(*convert_type<polynomial_tpl<ftype, 8> >(this), *convert_type< polynomial_tpl<ftype, 8> >(&f[0]), *convert_type<polynomial_tpl<ftype, 8> >(&f[degree]),
*convert_type<polynomial_tpl<ftype, 8> >(&f[1]), degree, degree - 1);
f[1].denom = -f[1].denom;
for (i = 2; i < degree; i++)
{
polynomial_divide(*convert_type<polynomial_tpl<ftype, 8> >(&f[i - 2]), *convert_type<polynomial_tpl<ftype, 8> >(&f[i - 1]), *convert_type<polynomial_tpl<ftype, 8> >(&f[degree]),
*convert_type<polynomial_tpl<ftype, 8> >(&f[i]), degree + 1 - i, degree - i);
f[i].denom = -f[i].denom;
if (fabs_tpl(f[i].denom) > (ftype)1E10)
{
for (j = 0; j <= degree - 1 - i; j++)
{
f[i].data[j] *= (ftype)1E-10;
}
f[i].denom *= (ftype)1E-10;
}
}
prevval = eval(start) * denom;
for (i = sg_a = 0; i < degree; i++, prevval = val)
{
val = f[i].eval(start, degree - 1 - i) * f[i].denom;
sg_a += isneg(val * prevval);
}
prevval = eval(end) * denom;
for (i = sg_b = 0; i < degree; i++, prevval = val)
{
val = f[i].eval(end, degree - 1 - i) * f[i].denom;
sg_b += isneg(val * prevval);
}
return fabs_tpl(sg_a - sg_b);
}
template<class ftype>
AZ_FORCE_INLINE ftype cubert_tpl(ftype x) { return fabs_tpl(x) > (ftype)1E-20 ? exp_tpl(log_tpl(fabs_tpl(x)) * (ftype)(1.0 / 3)) * sgnnz(x) : x; }
template<class ftype>
AZ_FORCE_INLINE ftype pow_tpl(ftype x, ftype pow) { return fabs_tpl(x) > (ftype)1E-20 ? exp_tpl(log_tpl(fabs_tpl(x)) * pow) * sgnnz(x) : x; }
template<class ftype>
AZ_FORCE_INLINE void swap(ftype* ptr, int i, int j) { ftype t = ptr[i]; ptr[i] = ptr[j]; ptr[j] = t; }
template <class ftype, int maxdegree>
int polynomial_tpl<ftype, maxdegree>::findroots(ftype start, ftype end, ftype* proots, [[maybe_unused]] int nIters, int degree, bool noDegreeCheck) const
{
AZ_UNUSED(nIters);
int i, j, nRoots = 0;
ftype maxel;
if (!noDegreeCheck)
{
for (i = 1, maxel = fabs_tpl(data[0]); i <= degree; i++)
{
maxel = max(maxel, data[i]);
}
for (maxel *= polye<ftype>(); degree > 0 && fabs_tpl(data[degree]) <= maxel; degree--)
{
;
}
}
if constexpr (maxdegree >= 1)
{
if (degree == 1)
{
proots[0] = data[0] / data[1];
nRoots = 1;
}
}
if constexpr (maxdegree >= 2)
{
if (degree == 2)
{
ftype a, b, c, d, bound[2], sg;
a = data[2];
b = data[1];
c = data[0];
d = aznumeric_cast<ftype>(sgnnz(a));
a *= d;
b *= d;
c *= d;
d = b * b - a * c * 4;
bound[0] = start * a * 2 + b;
bound[1] = end * a * 2 + b;
sg = aznumeric_cast<ftype>((sgnnz(bound[0] * bound[1]) + 1) >> 1);
bound[0] *= bound[0];
bound[1] *= bound[1];
bound[isneg(fabs_tpl(bound[1]) - fabs_tpl(bound[0]))] *= sg;
if (isnonneg(d) & inrange(d, bound[0], bound[1]))
{
d = sqrt_tpl(d);
a = (ftype)0.5 / a;
proots[nRoots] = (-b - d) * a;
nRoots += inrange(proots[nRoots], start, end);
proots[nRoots] = (-b + d) * a;
nRoots += inrange(proots[nRoots], start, end);
}
}
}
if constexpr (maxdegree >= 3)
{
if (degree == 3)
{
ftype t, a, b, c, a3, p, q, Q, Qr, Ar, Ai, phi;
t = (ftype)1.0 / data[3];
a = data[2] * t;
b = data[1] * t;
c = data[0] * t;
a3 = a * (ftype)(1.0 / 3);
p = b - a * a3;
q = (a3 * b - c) * (ftype)0.5 - cube(a3);
Q = cube(p * (ftype)(1.0 / 3)) + q * q;
Qr = sqrt_tpl(fabs_tpl(Q));
if (Q > 0)
{
proots[0] = cubert_tpl(q + Qr) + cubert_tpl(q - Qr) - a3;
nRoots = 1;
}
else
{
phi = atan2_tpl(Qr, q) * (ftype)(1.0 / 3);
t = pow_tpl(Qr * Qr + q * q, (ftype)(1.0 / 6));
Ar = t * cos_tpl(phi);
Ai = t * sin_tpl(phi);
proots[0] = 2 * Ar - a3;
proots[1] = aznumeric_cast<ftype>(-Ar + Ai * sqrt3 - a3);
proots[2] = aznumeric_cast<ftype>(-Ar - Ai * sqrt3 - a3);
i = idxmax3(proots);
swap(proots, i, 2);
i = isneg(proots[0] - proots[1]);
swap(proots, i, 1);
nRoots = 3;
}
}
}
if constexpr (maxdegree >= 4)
{
if (degree == 4)
{
ftype t, a3, a2, a1, a0, y, R, D, E, subroots[3];
const ftype e = (ftype)1E-9;
t = (ftype)1.0 / data[4];
a3 = data[3] * t;
a2 = data[2] * t;
a1 = data[1] * t;
a0 = data[0] * t;
polynomial_tpl<ftype, 3> p3aux;
ftype kp3aux[] = { 1, -a2, a1 * a3 - 4 * a0, 4 * a2 * a0 - a1 * a1 - a3 * a3 * a0 };
p3aux.set(kp3aux);
if (!p3aux.findroots((ftype)-1E20, (ftype)1E20, subroots))
{
return 0;
}
R = a3 * a3 * (ftype)0.25 - a2 + (y = subroots[0]);
if (R > -e)
{
if (R < e)
{
D = E = a3 * a3 * (ftype)(3.0 / 4) - 2 * a2;
t = y * y - 4 * a0;
if (t < -e)
{
return 0;
}
t = 2 * sqrt_tpl(max((ftype)0, t));
}
else
{
R = sqrt_tpl(max((ftype)0, R));
D = E = a3 * a3 * (ftype)(3.0 / 4) - R * R - 2 * a2;
t = (4 * a3 * a2 - 8 * a1 - a3 * a3 * a3) / R * (ftype)0.25;
}
if (D + t > -e)
{
D = sqrt_tpl(max((ftype)0, D + t));
proots[nRoots++] = a3 * (ftype)-0.25 + (R - D) * (ftype)0.5;
proots[nRoots++] = a3 * (ftype)-0.25 + (R + D) * (ftype)0.5;
}
if (E - t > -e)
{
E = sqrt_tpl(max((ftype)0, E - t));
proots[nRoots++] = a3 * (ftype)-0.25 - (R + E) * (ftype)0.5;
proots[nRoots++] = a3 * (ftype)-0.25 - (R - E) * (ftype)0.5;
}
if (nRoots == 4)
{
i = idxmax3(proots);
if (proots[3] < proots[i])
{
swap(proots, i, 3);
}
i = idxmax3(proots);
swap(proots, i, 2);
i = isneg(proots[0] - proots[1]);
swap(proots, i, 1);
}
}
}
}
if constexpr (maxdegree > 4)
{
if (degree > 4)
{
ftype roots[maxdegree + 1], prevroot, val, prevval[2], curval, bound[2], middle;
polynomial_tpl<ftype, maxdegree> deriv;
int nExtremes, iter, iBound;
calc_deriviative(deriv);
// find a subset of deriviative extremes between start and end
for (nExtremes = deriv.findroots(start, end, roots + 1, nIters, degree - 1) + 1; nExtremes > 1 && roots[nExtremes - 1] > end; nExtremes--)
{
;
}
for (i = 1; i < nExtremes && roots[i] < start; i++)
{
;
}
roots[i - 1] = start;
PREFAST_ASSUME(nExtremes < maxdegree + 1);
roots[nExtremes++] = end;
for (prevroot = start, prevval[0] = eval(start, degree), nRoots = 0; i < nExtremes; prevval[0] = val, prevroot = roots[i++])
{
val = eval(roots[i], degree);
if (val * prevval[0] < 0)
{
// we have exactly one root between prevroot and roots[i]
bound[0] = prevroot;
bound[1] = roots[i];
iter = 0;
do
{
middle = (bound[0] + bound[1]) * (ftype)0.5;
curval = eval(middle, degree);
iBound = isneg(prevval[0] * curval);
bound[iBound] = middle;
prevval[iBound] = curval;
} while (++iter < nIters);
proots[nRoots++] = middle;
}
}
}
}
for (i = 0; i < nRoots && proots[i] < start; i++)
{
;
}
for (; nRoots > i&& proots[nRoots - 1] > end; nRoots--)
{
;
}
for (j = i; j < nRoots; j++)
{
proots[j - i] = proots[j];
}
return nRoots - i;
}
} // namespace polynomial_tpl_IMPL
template<class ftype, int degree>
using polynomial_tpl = polynomial_tpl_IMPL::polynomial_tpl<ftype, degree>;
typedef polynomial_tpl<real, 3> P3;
typedef polynomial_tpl<real, 2> P2;
typedef polynomial_tpl<real, 1> P1;
typedef polynomial_tpl<float, 3> P3f;
typedef polynomial_tpl<float, 2> P2f;
typedef polynomial_tpl<float, 1> P1f;
} // namespace LegacyCryPhysicsUtils
@@ -1,172 +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 "DeepFilterProxyModel.h"
#include <QPalette>
DeepFilterProxyModel::DeepFilterProxyModel(QObject* parent)
: QSortFilterProxyModel(parent)
{
}
void DeepFilterProxyModel::setFilterString(const QString& filter)
{
m_filter = filter;
m_filterParts = m_filter.split(' ', Qt::SkipEmptyParts);
m_acceptCache.clear();
}
void DeepFilterProxyModel::invalidate()
{
QSortFilterProxyModel::invalidate();
m_acceptCache.clear();
}
QVariant DeepFilterProxyModel::data(const QModelIndex& index, int role) const
{
if (role == Qt::ForegroundRole)
{
QModelIndex sourceIndex = mapToSource(index);
if (matchFilter(sourceIndex.row(), sourceIndex.parent()))
{
return QSortFilterProxyModel::data(index, role);
}
else
{
return QPalette().color(QPalette::Disabled, QPalette::Text);
}
}
else
{
return QSortFilterProxyModel::data(index, role);
}
}
void DeepFilterProxyModel::setFilterWildcard(const QString& pattern)
{
m_acceptCache.clear();
QSortFilterProxyModel::setFilterWildcard(pattern);
}
bool DeepFilterProxyModel::matchFilter(int sourceRow, const QModelIndex& sourceParent) const
{
int columnCount = sourceModel()->columnCount(sourceParent);
for (int i = 0; i < m_filterParts.size(); ++i)
{
bool atLeastOneContains = false;
for (int j = 0; j < columnCount; ++j)
{
QModelIndex index = sourceModel()->index(sourceRow, j, sourceParent);
QVariant data = sourceModel()->data(index, Qt::DisplayRole);
QString str(data.toString());
if (str.isEmpty())
{
if (m_filterParts.empty())
{
atLeastOneContains = true;
}
}
else if (str.contains(m_filterParts[i], Qt::CaseInsensitive))
{
atLeastOneContains = true;
}
}
if (!atLeastOneContains)
{
return false;
}
}
return true;
}
bool DeepFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
{
if (matchFilter(sourceRow, sourceParent))
{
return true;
}
if (hasAcceptedChildrenCached(sourceRow, sourceParent))
{
return true;
}
return false;
}
bool DeepFilterProxyModel::hasAcceptedChildrenCached(int sourceRow, const QModelIndex& sourceParent) const
{
std::pair<QModelIndex, int> indexId = std::make_pair(sourceParent, sourceRow);
TAcceptCache::iterator it = m_acceptCache.find(indexId);
if (it == m_acceptCache.end())
{
bool result = hasAcceptedChildren(sourceRow, sourceParent);
m_acceptCache[indexId] = result;
return result;
}
else
{
return it->second;
}
}
bool DeepFilterProxyModel::hasAcceptedChildren(int sourceRow, const QModelIndex& sourceParent) const
{
QModelIndex item = sourceModel()->index(sourceRow, 0, sourceParent);
if (!item.isValid())
{
return false;
}
int childCount = item.model()->rowCount(item);
if (childCount == 0)
{
return false;
}
for (int i = 0; i < childCount; ++i)
{
if (filterAcceptsRow(i, item))
{
return true;
}
}
return false;
}
QModelIndex DeepFilterProxyModel::findFirstMatchingIndex(const QModelIndex& root)
{
int rowCount = this->rowCount(root);
for (int i = 0; i < rowCount; ++i)
{
QModelIndex index = this->index(i, 0, root);
if (!index.isValid())
{
continue;
}
QModelIndex sourceIndex = mapToSource(index);
if (!sourceIndex.isValid())
{
continue;
}
if (matchFilter(sourceIndex.row(), sourceIndex.parent()))
{
return index;
}
QModelIndex child = findFirstMatchingIndex(index);
if (child.isValid())
{
return child;
}
}
return QModelIndex();
}
@@ -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
*
*/
#ifndef CRYINCLUDE_EDITORCOMMON_DEEPFILTERPROXYMODEL_H
#define CRYINCLUDE_EDITORCOMMON_DEEPFILTERPROXYMODEL_H
#pragma once
#include <QSortFilterProxyModel>
#include <QModelIndex>
#include <QStringList>
#include "EditorCommonAPI.h"
class EDITOR_COMMON_API DeepFilterProxyModel
: public QSortFilterProxyModel
{
public:
DeepFilterProxyModel(QObject* parent);
void setFilterString(const QString& filter);
void invalidate();
QVariant data(const QModelIndex& index, int role) const override;
void setFilterWildcard(const QString& pattern);
bool matchFilter(int source_row, const QModelIndex& source_parent) const;
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
bool hasAcceptedChildrenCached(int source_row, const QModelIndex& source_parent) const;
bool hasAcceptedChildren(int source_row, const QModelIndex& source_parent) const;
QModelIndex findFirstMatchingIndex(const QModelIndex& root);
private:
QString m_filter;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
QStringList m_filterParts;
typedef std::map<std::pair<QModelIndex, int>, bool> TAcceptCache;
mutable TAcceptCache m_acceptCache;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
#endif // CRYINCLUDE_EDITORCOMMON_DEEPFILTERPROXYMODEL_H
@@ -1,9 +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 "../../Editor/Objects/DisplayContextShared.inl"
@@ -1,192 +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 "Ruler.h"
#include <QPainter>
#include <QPalette>
#include <AzCore/Casting/numeric_cast.h>
#include <AzCore/std/algorithm.h>
namespace DrawingPrimitives
{
enum
{
RULER_MIN_PIXELS_PER_TICK = 3,
};
std::vector<STick> CalculateTicks(uint size, Range visibleRange, Range rulerRange, int* pRulerPrecision, Range* pScreenRulerRange)
{
std::vector<STick> ticks;
if (size == 0)
{
if (pRulerPrecision)
{
*pRulerPrecision = 0;
}
return ticks;
}
const float pixelsPerUnit = visibleRange.Length() > 0.0f ? (float)size / visibleRange.Length() : 1.0f;
const float startTime = rulerRange.start;
const float endTime = rulerRange.end;
const float totalDuration = endTime - startTime;
const float ticksMinPower = log10f(RULER_MIN_PIXELS_PER_TICK);
const float ticksPowerDelta = ticksMinPower - log10f(pixelsPerUnit);
const int digitsAfterPoint = AZStd::max(-int(ceil(ticksPowerDelta)) - 1, 0);
if (pRulerPrecision)
{
*pRulerPrecision = digitsAfterPoint;
}
const float scaleStep = powf(10.0f, ceil(ticksPowerDelta));
const float scaleStepPixels = scaleStep * pixelsPerUnit;
const int numMarkers = int(totalDuration / scaleStep) + 1;
const float startTimeRound = int(startTime / scaleStep) * scaleStep;
const int startOffsetMod = int(startTime / scaleStep) % 10;
const int scaleOffsetPixels = aznumeric_cast<int>((startTime - startTimeRound) * pixelsPerUnit);
const int startX = aznumeric_cast<int>((rulerRange.start - visibleRange.start) * pixelsPerUnit);
const int endX = aznumeric_cast<int>(startX + (numMarkers - 1) * scaleStepPixels - scaleOffsetPixels);
if (pScreenRulerRange)
{
*pScreenRulerRange = Range(aznumeric_cast<float>(startX), aznumeric_cast<float>(endX));
}
const int startLoop = std::max((int)((scaleOffsetPixels - startX) / scaleStepPixels) - 1, 0);
const int endLoop = std::min((int)((size + scaleOffsetPixels - startX) / scaleStepPixels) + 1, numMarkers);
for (int i = startLoop; i < endLoop; ++i)
{
STick tick;
const int x = aznumeric_cast<int>(startX + i * scaleStepPixels - scaleOffsetPixels);
const float value = startTimeRound + i * scaleStep;
tick.m_bTenth = (startOffsetMod + i) % 10 != 0;
tick.m_position = x;
tick.m_value = value;
ticks.push_back(tick);
}
return ticks;
}
QColor Interpolate(const QColor& a, const QColor& b, float k)
{
float mk = 1.0f - k;
return QColor(aznumeric_cast<int>(a.red() * mk + b.red() * k),
aznumeric_cast<int>(a.green() * mk + b.green() * k),
aznumeric_cast<int>(a.blue() * mk + b.blue() * k),
aznumeric_cast<int>(a.alpha() * mk + b.alpha() * k));
}
void DrawTicks(const std::vector<STick>& ticks, QPainter& painter, const QPalette& palette, const STickOptions& options)
{
QColor midDark = DrawingPrimitives::Interpolate(palette.color(QPalette::Dark), palette.color(QPalette::Button), 0.5f);
painter.setPen(QPen(midDark));
const int height = options.m_rect.height();
const int top = options.m_rect.top();
for (const STick& tick : ticks)
{
const int x = tick.m_position + options.m_rect.left();
if (tick.m_bTenth)
{
painter.drawLine(QPoint(x, top + height - options.m_markHeight / 2), QPoint(x, top + height));
}
else
{
painter.drawLine(QPoint(x, top + height - options.m_markHeight), QPoint(x, top + height));
}
}
}
void DrawTicks(QPainter& painter, const QPalette& palette, const SRulerOptions& options)
{
const std::vector<STick> ticks = CalculateTicks(options.m_rect.width(), options.m_visibleRange, options.m_rulerRange, nullptr, nullptr);
DrawTicks(ticks, painter, palette, options);
}
void DrawRuler(QPainter& painter, const QPalette& palette, const SRulerOptions& options, int* pRulerPrecision)
{
int rulerPrecision;
Range screenRulerRange;
const std::vector<STick> ticks = CalculateTicks(options.m_rect.width(), options.m_visibleRange, options.m_rulerRange, &rulerPrecision, &screenRulerRange);
if (pRulerPrecision)
{
*pRulerPrecision = rulerPrecision;
}
if (options.m_shadowSize > 0)
{
QRect shadowRect = QRect(options.m_rect.left(), options.m_rect.height(), options.m_rect.width(), options.m_shadowSize);
QLinearGradient upperGradient(shadowRect.left(), shadowRect.top(), shadowRect.left(), shadowRect.bottom());
upperGradient.setColorAt(0.0f, QColor(0, 0, 0, 128));
upperGradient.setColorAt(1.0f, QColor(0, 0, 0, 0));
QBrush upperBrush(upperGradient);
painter.fillRect(shadowRect, upperBrush);
}
painter.fillRect(options.m_rect, DrawingPrimitives::Interpolate(palette.color(QPalette::Button), palette.color(QPalette::Midlight), 0.25f));
if (options.m_drawBackgroundCallback)
{
options.m_drawBackgroundCallback();
}
QColor midDark = DrawingPrimitives::Interpolate(palette.color(QPalette::Dark), palette.color(QPalette::Button), 0.5f);
painter.setPen(QPen(midDark));
QFont font;
font.setPixelSize(10);
painter.setFont(font);
char format[16] = "";
azsprintf(format, "%%.%df", rulerPrecision);
const int height = options.m_rect.height();
const int top = options.m_rect.top();
QString str;
for (const STick& tick : ticks)
{
const int x = tick.m_position + options.m_rect.left();
const float value = tick.m_value;
if (tick.m_bTenth)
{
painter.drawLine(QPoint(x, top + height - options.m_markHeight / 2), QPoint(x, top + height));
}
else
{
painter.drawLine(QPoint(x, top + height - options.m_markHeight), QPoint(x, top + height));
painter.setPen(palette.color(QPalette::Disabled, QPalette::Text));
str.asprintf(format, value);
painter.drawText(QPoint(x + 2, top + height - options.m_markHeight + 1), str);
painter.setPen(midDark);
}
}
painter.setPen(QPen(palette.color(QPalette::Dark)));
painter.drawLine(QPoint(aznumeric_cast<int>(options.m_rect.left() + screenRulerRange.start), 0), QPoint(aznumeric_cast<int>(options.m_rect.left() + screenRulerRange.start), options.m_rect.top() + height));
painter.drawLine(QPoint(aznumeric_cast<int>(options.m_rect.left() + screenRulerRange.end), 0), QPoint(aznumeric_cast<int>(options.m_rect.left() + screenRulerRange.end), options.m_rect.top() + height));
}
}
@@ -1,52 +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
#include "Range.h"
#include <functional>
#include <vector>
#include <QRect>
class QPainter;
class QPalette;
namespace DrawingPrimitives
{
struct SRulerOptions;
typedef std::function<void()> TDrawCallback;
struct SRulerOptions
{
QRect m_rect;
Range m_visibleRange;
Range m_rulerRange;
int m_textXOffset;
int m_textYOffset;
int m_markHeight;
int m_shadowSize;
TDrawCallback m_drawBackgroundCallback;
};
struct STick
{
bool m_bTenth;
int m_position;
float m_value;
};
typedef SRulerOptions STickOptions;
std::vector<STick> CalculateTicks(uint size, Range visibleRange, Range rulerRange, int* pRulerPrecision, Range* pScreenRulerRange);
void DrawTicks(const std::vector<STick>& ticks, QPainter& painter, const QPalette& palette, const STickOptions& options);
void DrawTicks(QPainter& painter, const QPalette& palette, const STickOptions& options);
void DrawRuler(QPainter& painter, const QPalette& palette, const SRulerOptions& options, int* pRulerPrecision);
}
@@ -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 "TimeSlider.h"
#include <QPainter>
#include <QPalette>
#include <AzCore/Casting/numeric_cast.h>
namespace DrawingPrimitives
{
void DrawTimeSlider(QPainter& painter, const QPalette& palette, const STimeSliderOptions& options)
{
QString text = QString::number(options.m_time, 'f', options.m_precision + 1);
QFontMetrics fm(painter.font());
const int textWidth = fm.horizontalAdvance(text) + fm.height();
const int markerHeight = fm.height();
const int thumbX = options.m_position;
const bool fits = thumbX + textWidth < options.m_rect.right();
const QRect timeRect(fits ? thumbX : thumbX - textWidth, 3, textWidth, fm.height());
painter.fillRect(timeRect.adjusted(fits ? 0 : -1, 0, fits ? 1 : 0, 0), options.m_bHasFocus ? palette.highlight() : palette.shadow());
painter.setPen(palette.color(QPalette::HighlightedText));
painter.drawText(timeRect.adjusted(fits ? 0 : aznumeric_cast<int>(markerHeight * 0.2f), -1, fits ? aznumeric_cast<int>(-markerHeight * 0.2f) : 0, 0), text, QTextOption(fits ? Qt::AlignRight : Qt::AlignLeft));
painter.setPen(palette.color(QPalette::Text));
painter.drawLine(QPointF(thumbX, 0), QPointF(thumbX, options.m_rect.height()));
QPointF points[3] =
{
QPointF(thumbX, markerHeight),
QPointF(thumbX - markerHeight * 0.66f, 0),
QPointF(thumbX + markerHeight * 0.66f, 0)
};
painter.setBrush(palette.base());
painter.setPen(palette.color(QPalette::Text));
painter.drawPolygon(points, 3);
}
}
@@ -1,31 +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
#include "Range.h"
#include <QRect>
class QPainter;
class QPalette;
namespace DrawingPrimitives
{
struct STimeSliderOptions
{
QRect m_rect;
int m_precision;
int m_position;
float m_time;
bool m_bHasFocus;
};
void DrawTimeSlider(QPainter& painter, const QPalette& palette, const STimeSliderOptions& options);
}
Binary file not shown.
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3e60156229cc8677e0294d297486f04bd78867ef4e0922b35444c8b45f78584d
size 1090
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fd29a16a1d1d9a363e4b154d51910c2cba2787fbbe1360cfd107b393053d2e49
size 1226
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:244005cde119238bbfc2815f36a343c6135c3233d0b72a5c97a6080604568e8f
size 1160
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:33176a8ea6b0798adf1114fdbea4b0f5c708f40c3d48a047b1cb0fa6ebcbbded
size 1181
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c122557745cc377768491ce59c5b5b17e54671aa59f7f87101766aa61758959e
size 939
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3c2a360a56a37bfae2bea16b495f5b6ee482caa28d0949e8eadea48fdaae654f
size 845
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:eb0f43228bdb5246ea3bfde0726f07e0df0468279610ba4c801b21e264b33123
size 765
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:97a2e879222323bc70787efbe2cbc1c47bbabb7b10df8465857e600a9084abb2
size 795
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:58e8476b7bec1ed8eddfde3d5228f58fcfba11329318f5dfef3d98eb99f3a897
size 1113
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a7847e8b7f3dd76395d893888916e4bd97ddf3f678d37d19836da04c2923791e
size 871
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:470266956c6911690299f29539c400122ae707f88d9b6ba3516faf196a8fd571
size 877
@@ -1,39 +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 "platform.h"
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
#include <afxwin.h>
#include <vector>
#include "QtViewPane.h"
#include "Include/IViewPane.h"
#include "Util/RefCountBase.h"
#include "QtWinMigrate/qwinwidget.h"
#include <QWidget>
#include <QEvent>
#include <QApplication>
#include <QCloseEvent>
#include <QHBoxLayout>
#include "QtUtil.h"
// ugly dependencies:
#include "Functor.h"
class CXmlArchive;
#include <IRenderer.h>
#include "Util/PathUtil.h"
// ^^^
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
@@ -1,26 +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
*
*/
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by EditorCommon.rc
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 1000
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 1000
#define _APS_NEXT_COMMAND_VALUE 32771
#endif
#endif
@@ -1,59 +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
#include "EditorCommonAPI.h"
#include "IEditor.h"
#include <WinWidget/WinWidgetManager.h>
#include <Core/QtEditorApplication.h>
#include <QWidget>
namespace WinWidget
{
template<class TWidget>
bool RegisterWinWidget()
{
static QWidget* winWidget {nullptr}; // Must declare outside of lambda
WinWidget::WinWidgetManager::WinWidgetCreateCall createCall = []() -> QWidget*
{
if (!winWidget)
{
winWidget = new QWidget(GetIEditor()->GetEditorMainWindow());
}
// Ensure only one instance of each window type exists
QList<TWidget*> existingWidgets = winWidget->findChildren<TWidget*>();
if (existingWidgets.size() > 0) // Note that the list should contain 0 or 1 entries
{
if (existingWidgets.first()->isVisible())
{
return nullptr; // TWidget type already in use - continue using it and don't create another
}
delete existingWidgets.first(); // Closed TWidget - remove
}
TWidget* createWidget = new TWidget(winWidget);
createWidget->Display();
return winWidget;
};
return GetIEditor()->GetWinWidgetManager()->RegisterWinWidget(TWidget::GetWWId(), createCall);
}
template<class TWidget>
void UnregisterWinWidget()
{
GetIEditor()->GetWinWidgetManager()->UnregisterWinWidget(TWidget::GetWWId());
}
}
@@ -1,70 +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 <WinWidget/WinWidgetManager.h>
namespace WinWidget
{
WinWidgetManager::WinWidgetManager()
: m_createCalls(size_t(WinWidgetId::NUM_WIN_WIDGET_IDS) + 1)
{
}
size_t WinWidgetManager::GetIndexForId(WinWidgetId thisId) const
{
size_t thisIndex = static_cast<size_t>(thisId);
if (thisIndex >= m_createCalls.size())
{
return 0;
}
return thisIndex;
}
WinWidgetManager::WinWidgetCreateCall WinWidgetManager::GetCreateCall(WinWidgetId thisId) const
{
size_t thisIndex = GetIndexForId(thisId);
if (!thisIndex)
{
return nullptr;
}
return m_createCalls[thisIndex];
}
bool WinWidgetManager::RegisterWinWidget(WinWidgetId thisId, WinWidgetCreateCall createCall)
{
size_t thisIndex = GetIndexForId(thisId);
if (m_createCalls[thisIndex] != nullptr)
{
return false;
}
m_createCalls[thisIndex] = createCall;
return true;
}
bool WinWidgetManager::UnregisterWinWidget(WinWidgetId thisId)
{
size_t thisIndex = GetIndexForId(thisId);
if (m_createCalls[thisIndex] == nullptr)
{
return false;
}
m_createCalls[thisIndex] = nullptr;
return true;
}
QWidget* WinWidgetManager::OpenWinWidget(WinWidgetId createId) const
{
WinWidgetManager::WinWidgetCreateCall createCall = GetCreateCall(createId);
if (!createCall)
{
return nullptr;
}
return createCall();
}
}
@@ -1,41 +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
#include <WinWidgetId.h>
#include "EditorCommonAPI.h"
#include <vector>
#include <functional>
class QWidget;
namespace WinWidget
{
class EDITOR_COMMON_API WinWidgetManager
{
public:
using WinWidgetCreateCall = std::function<QWidget*()>;
WinWidgetManager();
~WinWidgetManager() {}
bool RegisterWinWidget(WinWidgetId thisId, WinWidgetCreateCall createCall);
bool UnregisterWinWidget(WinWidgetId thisId);
QWidget* OpenWinWidget(WinWidgetId) const;
private:
WinWidgetCreateCall GetCreateCall(WinWidgetId thisId) const;
size_t GetIndexForId(WinWidgetId thisId) const;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
std::vector<WinWidgetCreateCall> m_createCalls;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
}
@@ -9,7 +9,6 @@
set(FILES
EditorCommon.h
EditorCommon.cpp
EditorCommon.rc
EditorCommonAPI.h
ActionOutput.h
ActionOutput.cpp
@@ -17,16 +16,4 @@ set(FILES
DockTitleBarWidget.h
SaveUtilities/AsyncSaveRunner.h
SaveUtilities/AsyncSaveRunner.cpp
AxisHelper.cpp
DisplayContext.cpp
DeepFilterProxyModel.cpp
DeepFilterProxyModel.h
Resource.h
DrawingPrimitives/Ruler.cpp
DrawingPrimitives/Ruler.h
DrawingPrimitives/TimeSlider.cpp
DrawingPrimitives/TimeSlider.h
WinWidget/WinWidget.h
WinWidget/WinWidgetManager.h
WinWidget/WinWidgetManager.cpp
)
@@ -1,61 +0,0 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
#pragma code_page(1252)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
@@ -7,7 +7,6 @@
#
set(FILES
FFMPEGPlugin.rc
main.cpp
FFMPEGPlugin.cpp
FFMPEGPlugin.h
@@ -1,22 +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
*
*/
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by FFMPEGPlugin.rc
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
@@ -1,4 +0,0 @@
<RCC>
<qresource prefix="/">
</qresource>
</RCC>
@@ -1,71 +0,0 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_P4 ICON "res\\p4.ico"
IDI_P4_ERROR ICON "res\\p4_error.ico"
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
@@ -13,8 +13,6 @@ set(FILES
PasswordDlg.h
PerforcePlugin.cpp
PerforcePlugin.h
PerforcePlugin.qrc
PerforceSourceControl.cpp
PerforceSourceControl.h
resource.h
)
@@ -1,23 +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
*
*/
#define IDI_P4 104
#define IDI_P4_ERROR 106
#define IDC_ERROR 1004
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 107
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1010
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
-183
View File
@@ -1,183 +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 : Generic report class, which contains arbitrary report entries.
#ifndef CRYINCLUDE_EDITOR_REPORT_H
#define CRYINCLUDE_EDITOR_REPORT_H
#pragma once
class IReportField
{
public:
virtual ~IReportField() {}
virtual const char* GetDescription() const = 0;
virtual const char* GetText() const = 0;
};
template <typename T, typename G>
class CReportField
: public IReportField
{
public:
typedef T Object;
typedef G TextGetter;
CReportField(Object& object, const char* description, TextGetter& getter);
virtual const char* GetDescription() const;
virtual const char* GetText() const;
private:
TextGetter m_getter;
string m_text;
string m_description;
};
class IReportRecord
{
public:
virtual ~IReportRecord() {}
virtual int GetFieldCount() const = 0;
virtual const char* GetFieldDescription(int fieldIndex) const = 0;
virtual const char* GetFieldText(int fieldIndex) const = 0;
};
template <typename T>
class CReportRecord
: public IReportRecord
{
public:
typedef T Object;
CReportRecord(Object& object);
virtual ~CReportRecord();
virtual int GetFieldCount() const;
virtual const char* GetFieldDescription(int fieldIndex) const;
virtual const char* GetFieldText(int fieldIndex) const;
template <typename G>
CReportField<Object, G>* AddField(const char* description, G& getter);
private:
Object m_object;
typedef std::vector<IReportField*> FieldContainer;
FieldContainer m_fields;
};
class CReport
{
public:
~CReport();
template <typename T>
CReportRecord<T>* AddRecord(T& object);
int GetRecordCount() const;
IReportRecord* GetRecord(int recordIndex);
void Clear();
private:
typedef std::vector<IReportRecord*> RecordContainer;
RecordContainer m_records;
};
template <typename T, typename G>
inline CReportField<T, G>::CReportField(Object& object, const char* description, TextGetter& getter)
: m_getter(getter)
, m_description(description)
{
m_text = m_getter(object);
}
template <typename T, typename G>
inline const char* CReportField<T, G>::GetDescription() const
{
return m_description.c_str();
}
template <typename T, typename G>
inline const char* CReportField<T, G>::GetText() const
{
return m_text.c_str();
}
template <typename T>
inline CReportRecord<T>::CReportRecord(Object& object)
: m_object(object)
{
}
template <typename T>
inline CReportRecord<T>::~CReportRecord()
{
for (FieldContainer::iterator it = m_fields.begin(); it != m_fields.end(); ++it)
{
delete (*it);
}
}
template <typename T>
inline int CReportRecord<T>::GetFieldCount() const
{
return m_fields.size();
}
template <typename T>
inline const char* CReportRecord<T>::GetFieldDescription(int fieldIndex) const
{
return m_fields[fieldIndex]->GetDescription();
}
template <typename T>
inline const char* CReportRecord<T>::GetFieldText(int fieldIndex) const
{
return m_fields[fieldIndex]->GetText();
}
template <typename T>
template <typename G>
inline CReportField<T, G>* CReportRecord<T>::AddField(const char* description, G& getter)
{
CReportField<Object, G>* field = new CReportField<Object, G>(m_object, description, getter);
m_fields.push_back(field);
return field;
}
inline CReport::~CReport()
{
Clear();
}
template <typename T>
inline CReportRecord<T>* CReport::AddRecord(T& object)
{
CReportRecord<T>* record = new CReportRecord<T>(object);
m_records.push_back(record);
return record;
}
inline int CReport::GetRecordCount() const
{
return m_records.size();
}
inline IReportRecord* CReport::GetRecord(int recordIndex)
{
return m_records[recordIndex];
}
inline void CReport::Clear()
{
for (RecordContainer::iterator it = m_records.begin(); it != m_records.end(); ++it)
{
delete (*it);
}
m_records.clear();
}
#endif // CRYINCLUDE_EDITOR_REPORT_H
-119
View File
@@ -1,119 +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 "ResizeResolutionDialog.h"
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
#include <ui_ResizeResolutionDialog.h>
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
class ResizeResolutionModel
: public QAbstractListModel
{
public:
ResizeResolutionModel(QObject* parent = nullptr);
int rowCount(const QModelIndex& parent = {}) const override;
int columnCount(const QModelIndex& parent = {}) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
int SizeRow(uint32 dwSize) const;
private:
static const int kNumSizes = 6;
};
ResizeResolutionModel::ResizeResolutionModel(QObject* parent)
: QAbstractListModel(parent)
{
}
int ResizeResolutionModel::rowCount(const QModelIndex& parent) const
{
return parent.isValid() ? 0 : kNumSizes;
}
int ResizeResolutionModel::columnCount(const QModelIndex& parent) const
{
return parent.isValid() ? 0 : 1;
}
QVariant ResizeResolutionModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid() || index.column() > 0 || index.row() >= kNumSizes)
{
return {};
}
const int size = 64 * (1 << index.row());
switch (role)
{
case Qt::DisplayRole:
return QStringLiteral("%1x%2").arg(size).arg(size);
case Qt::UserRole:
return size;
}
return {};
}
int ResizeResolutionModel::SizeRow(uint32 dwSize) const
{
// not a power of 2?
if (dwSize & (dwSize - 1))
{
return 0;
}
int row = 0;
for (auto i = dwSize / 64; i > 1; i >>= 1)
{
++row;
}
return row;
}
/////////////////////////////////////////////////////////////////////////////
// CResizeResolutionDialog dialog
CResizeResolutionDialog::CResizeResolutionDialog(QWidget* pParent /*=nullptr*/)
: QDialog(pParent)
, m_model(new ResizeResolutionModel(this))
, ui(new Ui::CResizeResolutionDialog)
{
ui->setupUi(this);
ui->m_resolution->setModel(m_model);
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
}
CResizeResolutionDialog::~CResizeResolutionDialog()
{
}
/////////////////////////////////////////////////////////////////////////////
void CResizeResolutionDialog::SetSize(uint32 dwSize)
{
ui->m_resolution->setCurrentIndex(m_model->SizeRow(dwSize));
}
/////////////////////////////////////////////////////////////////////////////
uint32 CResizeResolutionDialog::GetSize()
{
return ui->m_resolution->itemData(ui->m_resolution->currentIndex()).toInt();
}

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