Remove ResourceSelectorHost and clean up/refactor related bits (#3050)

* Sever dependency on legacy resource selector host

Audio resource selectors (browse dialogs) no longer need to be
registered with the legacy IResourceSelectorHost system.  Set up a new
EBus specifically to handle browse button presses and directly invokes
the dialog.

Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>

* Hook up legacy audio control selector to new EBus

Remaining use of legacy audio selectors (trackview) need to be able to
bypass ResourceSelectorHost now.

Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>

* Removes ResourceSelectorHost and legacy selectors

This removes various Variable types that were tied to resource
selectors, such as GeomCache, Model, Animation, File.  Removes the
ResourceSelectorHost completely.  The two things that still appeared to
have selectors in TrackView are Audio Controls and Texture.  Fixed the
audio control selector to work via EBus and the Texture selector didn't
seem to work at all, but left it in as it was.

Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>

* Make the default audio selector return old value

Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>

* Fix some signed/unsigned comparison warnings

Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>

* Remove deleted function from Editor Mock

Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>

* Change audio selector api to use string_view

Per feedback.

Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>
monroegm-disable-blank-issue-2
amzn-phist 4 years ago committed by GitHub
parent b88a7faf64
commit d6b268e84e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,7 +10,6 @@
// Editor
#include "PropertyCtrl.h"
#include "PropertyAnimationCtrl.h"
#include "PropertyResourceCtrl.h"
#include "PropertyGenericCtrl.h"
#include "PropertyMiscCtrl.h"
@ -22,9 +21,7 @@ void RegisterReflectedVarHandlers()
if (!registered)
{
registered = true;
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew AnimationPropertyWidgetHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew FileResourceSelectorWidgetHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew ReverbPresetPropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew SequencePropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew SequenceIdPropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew LocalStringPropertyHandler());

@ -73,16 +73,6 @@ void GenericPopupPropertyEditor::SetPropertyType(PropertyType type)
m_propertyType = type;
}
void ReverbPresetPropertyEditor::onEditClicked()
{
CSelectEAXPresetDlg PresetDlg(this);
PresetDlg.SetCurrPreset(GetValue());
if (PresetDlg.exec() == QDialog::Accepted)
{
SetValue(PresetDlg.GetCurrPreset());
}
}
void SequencePropertyEditor::onEditClicked()
{
CSelectSequenceDialog gtDlg(this);

@ -96,15 +96,6 @@ public:
}
};
class ReverbPresetPropertyEditor
: public GenericPopupPropertyEditor
{
public:
ReverbPresetPropertyEditor(QWidget* pParent = nullptr)
: GenericPopupPropertyEditor(pParent){}
void onEditClicked() override;
};
class MissionObjPropertyEditor
: public GenericPopupPropertyEditor
{
@ -155,7 +146,6 @@ public:
// So we use our own
#define CONST_AZ_CRC(name, value) AZ::u32(value)
using ReverbPresetPropertyHandler = GenericPopupWidgetHandler<ReverbPresetPropertyEditor, CONST_AZ_CRC("ePropertyReverbPreset", 0x51469f38)>;
using MissionObjPropertyHandler = GenericPopupWidgetHandler<MissionObjPropertyEditor, CONST_AZ_CRC("ePropertyMissionObj", 0x4a2d0dc8)>;
using SequencePropertyHandler = GenericPopupWidgetHandler<SequencePropertyEditor, CONST_AZ_CRC("ePropertySequence", 0xdd1c7d44)>;
using SequenceIdPropertyHandler = GenericPopupWidgetHandler<SequenceIdPropertyEditor, CONST_AZ_CRC("ePropertySequenceId", 0x05983dcc)>;

@ -17,9 +17,9 @@
// AzToolsFramework
#include <AzToolsFramework/AssetBrowser/AssetSelectionModel.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/UI/PropertyEditor/PropertyAudioCtrl.h>
// Editor
#include "IResourceSelectorHost.h"
#include "Controls/QToolTipWidget.h"
#include "Controls/BitmapToolTip.h"
@ -35,8 +35,8 @@ BrowseButton::BrowseButton(PropertyType type, QWidget* parent /*= nullptr*/)
void BrowseButton::SetPathAndEmit(const QString& path)
{
//only emit if path changes, except for ePropertyGeomCache. Old property control
if (path != m_path || m_propertyType == ePropertyGeomCache)
//only emit if path changes. Old property control
if (path != m_path)
{
m_path = path;
emit PathChanged(m_path);
@ -78,21 +78,6 @@ private:
// Filters for texture.
selection = AssetSelectionModel::AssetGroupSelection("Texture");
}
else if (m_propertyType == ePropertyModel)
{
// Filters for models.
selection = AssetSelectionModel::AssetGroupSelection("Geometry");
}
else if (m_propertyType == ePropertyGeomCache)
{
// Filters for geom caches.
selection = AssetSelectionModel::AssetTypeSelection("Geom Cache");
}
else if (m_propertyType == ePropertyFile)
{
// Filters for files.
selection = AssetSelectionModel::AssetTypeSelection("File");
}
else
{
return;
@ -106,14 +91,7 @@ private:
switch (m_propertyType)
{
case ePropertyTexture:
case ePropertyModel:
newPath.replace("\\\\", "/");
}
switch (m_propertyType)
{
case ePropertyTexture:
case ePropertyModel:
case ePropertyFile:
if (newPath.size() > MAX_PATH)
{
newPath.resize(MAX_PATH);
@ -125,26 +103,51 @@ private:
}
};
class ResourceSelectorButton
class AudioControlSelectorButton
: public BrowseButton
{
public:
AZ_CLASS_ALLOCATOR(ResourceSelectorButton, AZ::SystemAllocator, 0);
AZ_CLASS_ALLOCATOR(AudioControlSelectorButton, AZ::SystemAllocator, 0);
ResourceSelectorButton(PropertyType type, QWidget* pParent = nullptr)
AudioControlSelectorButton(PropertyType type, QWidget* pParent = nullptr)
: BrowseButton(type, pParent)
{
setToolTip(tr("Select resource"));
setToolTip(tr("Select Audio Control"));
}
private:
void OnClicked() override
{
SResourceSelectorContext x;
x.parentWidget = this;
x.typeName = Prop::GetPropertyTypeToResourceType(m_propertyType);
QString newPath = GetIEditor()->GetResourceSelectorHost()->SelectResource(x, m_path);
SetPathAndEmit(newPath);
AZStd::string resourceResult;
auto ConvertLegacyAudioPropertyType = [](const PropertyType type) -> AzToolsFramework::AudioPropertyType
{
switch (type)
{
case ePropertyAudioTrigger:
return AzToolsFramework::AudioPropertyType::Trigger;
case ePropertyAudioRTPC:
return AzToolsFramework::AudioPropertyType::Rtpc;
case ePropertyAudioSwitch:
return AzToolsFramework::AudioPropertyType::Switch;
case ePropertyAudioSwitchState:
return AzToolsFramework::AudioPropertyType::SwitchState;
case ePropertyAudioEnvironment:
return AzToolsFramework::AudioPropertyType::Environment;
case ePropertyAudioPreloadRequest:
return AzToolsFramework::AudioPropertyType::Preload;
default:
return AzToolsFramework::AudioPropertyType::NumTypes;
}
};
auto propType = ConvertLegacyAudioPropertyType(m_propertyType);
if (propType != AzToolsFramework::AudioPropertyType::NumTypes)
{
AzToolsFramework::AudioControlSelectorRequestBus::EventResult(
resourceResult, propType, &AzToolsFramework::AudioControlSelectorRequestBus::Events::SelectResource,
AZStd::string_view{ m_path.toUtf8().constData() });
SetPathAndEmit(QString{ resourceResult.c_str() });
}
}
};
@ -235,18 +238,13 @@ void FileResourceSelectorWidget::SetPropertyType(PropertyType type)
AddButton(new TextureEditButton);
m_previewToolTip.reset(new CBitmapToolTip);
break;
case ePropertyModel:
case ePropertyGeomCache:
case ePropertyAudioTrigger:
case ePropertyAudioSwitch:
case ePropertyAudioSwitchState:
case ePropertyAudioRTPC:
case ePropertyAudioEnvironment:
case ePropertyAudioPreloadRequest:
AddButton(new ResourceSelectorButton(type));
break;
case ePropertyFile:
AddButton(new FileBrowseButton(type));
AddButton(new AudioControlSelectorButton(type));
break;
default:
break;

@ -1,93 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description : implementation file
#include "EditorDefs.h"
#include "ReflectedPropertiesPanel.h"
/////////////////////////////////////////////////////////////////////////////
// ReflectedPropertiesPanel dialog
ReflectedPropertiesPanel::ReflectedPropertiesPanel(QWidget* pParent)
: ReflectedPropertyControl(pParent)
{
}
//////////////////////////////////////////////////////////////////////////
void ReflectedPropertiesPanel::DeleteVars()
{
ClearVarBlock();
m_updateCallbacks.clear();
m_varBlock = nullptr;
}
//////////////////////////////////////////////////////////////////////////
void ReflectedPropertiesPanel::SetVarBlock(class CVarBlock* vb, ReflectedPropertyControl::UpdateVarCallback* updCallback, const char* category)
{
assert(vb);
m_varBlock = vb;
RemoveAllItems();
m_varBlock = vb;
AddVarBlock(m_varBlock, category);
SetUpdateCallback(AZStd::bind(&ReflectedPropertiesPanel::OnPropertyChanged, this, AZStd::placeholders::_1));
// When new object set all previous callbacks freed.
m_updateCallbacks.clear();
if (updCallback)
{
stl::push_back_unique(m_updateCallbacks, updCallback);
}
}
//////////////////////////////////////////////////////////////////////////
void ReflectedPropertiesPanel::AddVars(CVarBlock* vb, ReflectedPropertyControl::UpdateVarCallback* updCallback, const char* category)
{
assert(vb);
bool bNewBlock = false;
// Make a clone of properties.
if (!m_varBlock)
{
RemoveAllItems();
m_varBlock = vb->Clone(true);
AddVarBlock(m_varBlock, category);
bNewBlock = true;
}
m_varBlock->Wire(vb);
if (bNewBlock)
{
SetUpdateCallback(AZStd::bind(&ReflectedPropertiesPanel::OnPropertyChanged, this, AZStd::placeholders::_1));
// When new object set all previous callbacks freed.
m_updateCallbacks.clear();
}
if (updCallback)
{
stl::push_back_unique(m_updateCallbacks, updCallback);
}
}
void ReflectedPropertiesPanel::OnPropertyChanged(IVariable* pVar)
{
std::list<ReflectedPropertyControl::UpdateVarCallback*>::iterator iter;
for (iter = m_updateCallbacks.begin(); iter != m_updateCallbacks.end(); ++iter)
{
(*iter)->operator()(pVar);
}
}

@ -1,46 +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_REFLECTEDPROPERTIESPANEL_H
#define CRYINCLUDE_EDITOR_REFLECTEDPROPERTIESPANEL_H
#pragma once
#include "Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.h"
#include "Util/Variable.h"
/////////////////////////////////////////////////////////////////////////////
// ReflectedPropertiesPanel dialog
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
//This class is a port of ReflectedPropertiesPanel to use the ReflectedPropertyControl
class SANDBOX_API ReflectedPropertiesPanel
: public ReflectedPropertyControl
{
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
public:
ReflectedPropertiesPanel(QWidget* pParent = nullptr); // standard constructor
void DeleteVars();
void AddVars(class CVarBlock* vb, ReflectedPropertyControl::UpdateVarCallback* func = nullptr, const char* category = nullptr);
void SetVarBlock(class CVarBlock* vb, ReflectedPropertyControl::UpdateVarCallback* func = nullptr, const char* category = nullptr);
protected:
void OnPropertyChanged(IVariable* pVar);
protected:
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
TSmartPtr<CVarBlock> m_varBlock;
std::list<ReflectedPropertyControl::UpdateVarCallback*> m_updateCallbacks;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
#endif // CRYINCLUDE_EDITOR_REFLECTEDPROPERTIESPANEL_H

@ -255,9 +255,6 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
case ePropertySelection:
m_reflectedVarAdapter = new ReflectedVarEnumAdapter;
break;
case ePropertyAnimation:
m_reflectedVarAdapter = new ReflectedVarAnimationAdapter;
break;
case ePropertyColor:
m_reflectedVarAdapter = new ReflectedVarColorAdapter;
break;
@ -265,7 +262,6 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
m_reflectedVarAdapter = new ReflectedVarUserAdapter;
break;
case ePropertyEquip:
case ePropertyReverbPreset:
case ePropertyGameToken:
case ePropertyMissionObj:
case ePropertySequence:
@ -276,15 +272,12 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
m_reflectedVarAdapter = new ReflectedVarGenericPropertyAdapter(desc.m_type);
break;
case ePropertyTexture:
case ePropertyModel:
case ePropertyGeomCache:
case ePropertyAudioTrigger:
case ePropertyAudioSwitch:
case ePropertyAudioSwitchState:
case ePropertyAudioRTPC:
case ePropertyAudioEnvironment:
case ePropertyAudioPreloadRequest:
case ePropertyFile:
m_reflectedVarAdapter = new ReflectedVarResourceAdapter;
break;
case ePropertyFloatCurve:
@ -569,7 +562,6 @@ void ReflectedPropertyItem::SetValue(const QString& sValue, bool bRecordUndo, bo
break;
case ePropertyTexture:
case ePropertyModel:
value.replace('\\', '/');
break;
}
@ -578,8 +570,6 @@ void ReflectedPropertyItem::SetValue(const QString& sValue, bool bRecordUndo, bo
switch (m_type)
{
case ePropertyTexture:
case ePropertyModel:
case ePropertyFile:
if (value.length() >= MAX_PATH)
{
value = value.left(MAX_PATH);

@ -31,12 +31,6 @@ void ReflectedVarInit::setupReflection(AZ::SerializeContext* serializeContext)
->Field("description", &CReflectedVar::m_description)
->Field("varName", &CReflectedVar::m_varName);
serializeContext->Class <CReflectedVarAnimation, CReflectedVar >()
->Version(1)
->Field("animation", &CReflectedVarAnimation::m_animation)
->Field("entityID", &CReflectedVarAnimation::m_entityID)
;
serializeContext->Class <CReflectedVarResource, CReflectedVar >()
->Version(1)
->Field("path", &CReflectedVarResource::m_path)
@ -76,12 +70,6 @@ void ReflectedVarInit::setupReflection(AZ::SerializeContext* serializeContext)
AZ::EditContext* ec = serializeContext->GetEditContext();
if (ec)
{
ec->Class< CReflectedVarAnimation >("VarAnimation", "Animation")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::NameLabelOverride, &CReflectedVarAnimation::varName)
->Attribute(AZ::Edit::Attributes::DescriptionTextOverride, &CReflectedVarAnimation::description)
;
ec->Class< CReflectedVarResource >("VarResource", "Resource")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::NameLabelOverride, &CReflectedVarResource::varName)
@ -284,8 +272,6 @@ AZ::u32 CReflectedVarGenericProperty::handler()
return AZ_CRC("ePropertyShader", 0xc40932f1);
case ePropertyEquip:
return AZ_CRC("ePropertyEquip", 0x66ffd290);
case ePropertyReverbPreset:
return AZ_CRC("ePropertyReverbPreset", 0x51469f38);
case ePropertyDeprecated0:
return AZ_CRC("ePropertyCustomAction", 0x4ffa5ba5);
case ePropertyGameToken:

@ -265,32 +265,8 @@ public:
AZ::Vector3 m_color;
};
//Class to hold ePropertyAnimation (IVariable::DT_ANIMATION )
class CReflectedVarAnimation
: public CReflectedVar
{
public:
AZ_RTTI(CReflectedVarAnimation, "{635D982E-23EC-463F-8F33-4FC2C19D5673}", CReflectedVar)
CReflectedVarAnimation(const AZStd::string& name)
: CReflectedVar(name)
, m_entityID(0)
{}
CReflectedVarAnimation()
: m_entityID(0){}
AZStd::string varName() const { return m_varName; }
AZStd::string description() const { return m_description; }
AZStd::string m_animation;
AZ::EntityId m_entityID;
};
//Class to hold:
// ePropertyTexture (IVariable::DT_TEXTURE)
// ePropertyMaterial (IVariable::DT_MATERIAL)
// ePropertyModel (IVariable::DT_OBJECT)
// ePropertyGeomCache (IVariable::DT_GEOM_CACHE)
// ePropertyAudioTrigger (IVariable::DT_AUDIO_TRIGGER)
// ePropertyAudioSwitch (IVariable::DT_AUDIO_SWITCH )
// ePropertyAudioSwitchState (IVariable::DT_AUDIO_SWITCH_STATE)
@ -344,7 +320,6 @@ public:
AZStd::vector<AZStd::string> m_itemDescriptions;
};
//Class to hold ePropertyAnimation (IVariable::DT_ANIMATION )
class CReflectedVarSpline
: public CReflectedVar
{

@ -392,25 +392,6 @@ void ReflectedVarColorAdapter::SyncIVarToReflectedVar(IVariable *pVariable)
void ReflectedVarAnimationAdapter::SetVariable(IVariable *pVariable)
{
m_reflectedVar.reset(new CReflectedVarAnimation(pVariable->GetHumanName().toUtf8().data()));
m_reflectedVar->m_description = pVariable->GetDescription().toUtf8().data();
}
void ReflectedVarAnimationAdapter::SyncReflectedVarToIVar(IVariable *pVariable)
{
m_reflectedVar->m_entityID = static_cast<AZ::EntityId>(pVariable->GetUserData().value<AZ::u64>());
m_reflectedVar->m_animation = pVariable->GetDisplayValue().toUtf8().data();
}
void ReflectedVarAnimationAdapter::SyncIVarToReflectedVar(IVariable *pVariable)
{
pVariable->SetUserData(static_cast<AZ::u64>(m_reflectedVar->m_entityID));
pVariable->SetDisplayValue(m_reflectedVar->m_animation.c_str());
}
void ReflectedVarResourceAdapter::SetVariable(IVariable *pVariable)
{
m_reflectedVar.reset(new CReflectedVarResource(pVariable->GetHumanName().toUtf8().data()));
@ -429,7 +410,7 @@ void ReflectedVarResourceAdapter::SyncReflectedVarToIVar(IVariable *pVariable)
void ReflectedVarResourceAdapter::SyncIVarToReflectedVar(IVariable *pVariable)
{
const bool bForceModified = (m_reflectedVar->m_propertyType == ePropertyGeomCache);
const bool bForceModified = false;
pVariable->SetForceModified(bForceModified);
pVariable->SetDisplayValue(m_reflectedVar->m_path.c_str());

@ -218,20 +218,6 @@ AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
class EDITOR_CORE_API ReflectedVarAnimationAdapter
: 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<CReflectedVarAnimation > m_reflectedVar;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
class EDITOR_CORE_API ReflectedVarResourceAdapter
: public ReflectedVarAdapter
{

@ -130,7 +130,7 @@ public:
HotKey_BuildDefaults();
for (QPair<QString, QString> key : keys)
{
for (unsigned int j = 0; j < hotkeys.count(); j++)
for (int j = 0; j < hotkeys.count(); j++)
{
if (hotkeys[j].path.compare(key.first, Qt::CaseInsensitive) == 0)
{
@ -256,7 +256,7 @@ public:
hotkey.second = settings.value("keySequence").toString();
if (!hotkey.first.isEmpty())
{
for (unsigned int j = 0; j < hotkeys.count(); j++)
for (int j = 0; j < hotkeys.count(); j++)
{
if (hotkeys[j].path.compare(hotkey.first, Qt::CaseInsensitive) == 0)
{

@ -68,7 +68,6 @@ class CDisplaySettings;
struct SGizmoParameters;
class CLevelIndependentFileMan;
class CSelectionTreeManager;
struct IResourceSelectorHost;
struct SEditorSettings;
class CGameExporter;
class IAWSResourceManager;
@ -714,7 +713,6 @@ struct IEditor
virtual ESystemConfigSpec GetEditorConfigSpec() const = 0;
virtual ESystemConfigPlatform GetEditorConfigPlatform() const = 0;
virtual void ReloadTemplates() = 0;
virtual IResourceSelectorHost* GetResourceSelectorHost() = 0;
virtual void ShowStatusText(bool bEnable) = 0;
// Provides a way to extend the context menu of an object. The function gets called every time the menu is opened.

@ -67,7 +67,6 @@ AZ_POP_DISABLE_WARNING
#include "EditorFileMonitor.h"
#include "MainStatusBar.h"
#include "ResourceSelectorHost.h"
#include "Util/FileUtil_impl.h"
#include "Util/ImageUtil_impl.h"
#include "LogFileImpl.h"
@ -187,7 +186,6 @@ CEditorImpl::CEditorImpl()
m_pAnimationContext = new CAnimationContext;
m_pImageUtil = new CImageUtil_impl();
m_pResourceSelectorHost.reset(CreateResourceSelectorHost());
m_selectedRegion.min = Vec3(0, 0, 0);
m_selectedRegion.max = Vec3(0, 0, 0);
DetectVersion();

@ -290,7 +290,6 @@ public:
ESystemConfigPlatform GetEditorConfigPlatform() const;
void ReloadTemplates();
void AddErrorMessage(const QString& text, const QString& caption);
IResourceSelectorHost* GetResourceSelectorHost() { return m_pResourceSelectorHost.get(); }
virtual void ShowStatusText(bool bEnable);
void OnObjectContextMenuOpened(QMenu* pMenu, const CBaseObject* pObject);
@ -374,7 +373,6 @@ protected:
//! Export manager for exporting objects and a terrain from the game to DCC tools
CExportManager* m_pExportManager;
std::unique_ptr<CEditorFileMonitor> m_pEditorFileMonitor;
std::unique_ptr<IResourceSelectorHost> m_pResourceSelectorHost;
QString m_selectFileBuffer;
QString m_levelNameBuffer;

@ -65,7 +65,7 @@ struct HotKey
int size = (m_catSize < o_catSize) ? m_catSize : o_catSize;
//sort categories to keep them together
for (unsigned int i = 0; i < size; i++)
for (int i = 0; i < size; i++)
{
if (m_categories[i] < o_categories[i])
{

@ -1,135 +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
// The aim of IResourceSelectorHost is to unify resource selection dialogs in a one
// API that can be reused with plugins. It also makes possible to register new
// resource selectors dynamically, e.g. inside plugins.
//
// Here is how new selectors are created. In your implementation file you add handler function:
//
// #include "IResourceSelectorHost.h"
//
// QString SoundFileSelector(const SResourceSelectorContext& x, const QString& previousValue)
// {
// CMyModalDialog dialog(CWnd::FromHandle(x.parentWindow));
// ...
// return previousValue;
// }
// REGISTER_RESOURCE_SELECTOR("Sound", SoundFileSelector, "Icons/sound_16x16.png")
//
// Here is how it can be invoked directly:
//
// SResourceSelectorContext x;
// x.parentWindow = parent.GetSafeHwnd();
// x.typeName = "Sound";
// string newValue = GetIEditor()->GetResourceSelector()->SelectResource(x, previousValue).c_str();
//
// If you have your own resource selectors in the plugin you will need to run
//
// RegisterModuleResourceSelectors(GetIEditor()->GetResourceSelector())
//
// during plugin initialization.
//
// If you want to be able to pass some custom context to the selector (e.g. source of the information for the
// list of items or something similar) then you can add a poitner argument to your selector function, i.e.:
//
// QString SoundFileSelector(const SResourceSelectorContext& x, const QString& previousValue,
// SoundFileList* list) // your context argument
#include <QString>
class QWidget;
struct SResourceSelectorContext
{
const char* typeName;
// use either parentWidget or parentWindow (not both) until everything porting to QWidget.
QWidget* parentWidget;
unsigned int entityId;
void* contextObject;
SResourceSelectorContext()
: parentWidget(0)
, typeName(0)
, entityId(0)
, contextObject()
{
}
};
// TResourceSelecitonFunction is used to declare handlers for specific types.
//
// For canceled dialogs previousValue should be returned.
typedef QString (* TResourceSelectionFunction)(const SResourceSelectorContext& selectorContext, const QString& previousValue);
typedef QString (* TResourceSelectionFunctionWithContext)(const SResourceSelectorContext& selectorContext, const QString& previousValue, void* contextObject);
struct SStaticResourceSelectorEntry;
// See note at the beginning of the file.
struct IResourceSelectorHost
{
virtual ~IResourceSelectorHost() = default;
virtual QString SelectResource(const SResourceSelectorContext& context, const QString& previousValue) = 0;
virtual const char* ResourceIconPath(const char* typeName) const = 0;
virtual void RegisterResourceSelector(const SStaticResourceSelectorEntry* entry) = 0;
// secondary responsibility of this class is to store global selections
virtual void SetGlobalSelection(const char* resourceType, const char* value) = 0;
virtual const char* GetGlobalSelection(const char* resourceType) const = 0;
};
// ---------------------------------------------------------------------------
#define INTERNAL_RSH_COMBINE_UTIL(A, B) A##B
#define INTERNAL_RSH_COMBINE(A, B) INTERNAL_RSH_COMBINE_UTIL(A, B)
#define REGISTER_RESOURCE_SELECTOR(name, function, icon) \
static SStaticResourceSelectorEntry INTERNAL_RSH_COMBINE(selector_##function, __LINE__)((name), (function), (icon));
struct SStaticResourceSelectorEntry
{
const char* typeName;
TResourceSelectionFunction function;
TResourceSelectionFunctionWithContext functionWithContext;
const char* iconPath;
static SStaticResourceSelectorEntry*& GetFirst() { static SStaticResourceSelectorEntry* first; return first; }
SStaticResourceSelectorEntry* next;
SStaticResourceSelectorEntry(const char* typeName, TResourceSelectionFunction function, const char* icon)
: typeName(typeName)
, function(function)
, functionWithContext()
, iconPath(icon)
{
next = GetFirst();
GetFirst() = this;
}
template<class T>
SStaticResourceSelectorEntry(const char* typeName, QString (*function)(const SResourceSelectorContext&, const QString& previousValue, T * context), const char* icon)
: typeName(typeName)
, function()
, functionWithContext(TResourceSelectionFunctionWithContext(function))
, iconPath(icon)
{
next = GetFirst();
GetFirst() = this;
}
};
inline void RegisterModuleResourceSelectors(IResourceSelectorHost* editorResourceSelector)
{
for (SStaticResourceSelectorEntry* current = SStaticResourceSelectorEntry::GetFirst(); current != 0; current = current->next)
{
editorResourceSelector->RegisterResourceSelector(current);
}
}

@ -178,7 +178,6 @@ public:
MOCK_CONST_METHOD0(GetEditorConfigSpec, ESystemConfigSpec());
MOCK_CONST_METHOD0(GetEditorConfigPlatform, ESystemConfigPlatform());
MOCK_METHOD0(ReloadTemplates, void());
MOCK_METHOD0(GetResourceSelectorHost, IResourceSelectorHost* ());
MOCK_METHOD1(ShowStatusText, void(bool ));
MOCK_METHOD1(RegisterObjectContextMenuExtension, void(TContextMenuExtensionFunc ));
MOCK_METHOD0(GetEnv, SSystemGlobalEnvironment* ());

@ -9,7 +9,6 @@
#include "ComponentEntityEditorPlugin.h"
#include <LyViewPaneNames.h>
#include "IResourceSelectorHost.h"
#include "UI/QComponentEntityEditorMainWindow.h"
#include "UI/QComponentEntityEditorOutlinerWindow.h"
@ -180,8 +179,6 @@ ComponentEntityEditorPlugin::ComponentEntityEditorPlugin([[maybe_unused]] IEdito
RegisterViewPane<SliceRelationshipWidget>(LyViewPane::SliceRelationships, LyViewPane::CategoryTools, options);
}
RegisterModuleResourceSelectors(GetIEditor()->GetResourceSelectorHost());
ComponentEntityEditorPluginInternal::RegisterSandboxObjects();
// Check for common mistakes in component declarations

@ -82,7 +82,6 @@
#include <Editor/QtViewPaneManager.h>
#include <Editor/EditorViewportSettings.h>
#include <Editor/Util/PathUtil.h>
#include <IResourceSelectorHost.h>
#include "CryEdit.h"
#include "Undo/Undo.h"
@ -1387,16 +1386,6 @@ AZStd::string SandboxIntegrationManager::GetLevelName()
return AZStd::string(GetIEditor()->GetGameEngine()->GetLevelName().toUtf8().constData());
}
AZStd::string SandboxIntegrationManager::SelectResource(const AZStd::string& resourceType, const AZStd::string& previousValue)
{
SResourceSelectorContext context;
context.parentWidget = GetMainWindow();
context.typeName = resourceType.c_str();
QString resource = GetEditor()->GetResourceSelectorHost()->SelectResource(context, previousValue.c_str());
return AZStd::string(resource.toUtf8().constData());
}
void SandboxIntegrationManager::OnContextReset()
{
// Deselect everything.

@ -158,7 +158,6 @@ private:
void LaunchLuaEditor(const char* files) override;
bool IsLevelDocumentOpen() override;
AZStd::string GetLevelName() override;
AZStd::string SelectResource(const AZStd::string& resourceType, const AZStd::string& previousValue) override;
void OpenPinnedInspector(const AzToolsFramework::EntityIdSet& entities) override;
void ClosePinnedInspector(AzToolsFramework::EntityPropertyEditor* editor) override;
void GoToSelectedOrHighlightedEntitiesInViewports() override;

@ -1,163 +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 "ResourceSelectorHost.h"
// Qt
#include <QMessageBox>
#include <QString>
// AzToolsFramework
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/AssetBrowser/Search/Filter.h>
#include <AzToolsFramework/AssetBrowser/AssetSelectionModel.h>
class CResourceSelectorHost
: public IResourceSelectorHost
{
public:
CResourceSelectorHost()
{
RegisterModuleResourceSelectors(this);
}
QString SelectResource(const SResourceSelectorContext& context, const QString& previousValue) override
{
if (!context.typeName)
{
assert(false && "SResourceSelectorContext::typeName is not specified");
return QString();
}
TTypeMap::iterator it = m_typeMap.find(context.typeName);
if (it == m_typeMap.end())
{
QMessageBox::critical(QApplication::activeWindow(), QString(), QObject::tr("No Resource Selector is registered for resource type \"%1\"").arg(context.typeName));
return previousValue;
}
QString result = previousValue;
if (it->second->function)
{
result = it->second->function(context, previousValue);
}
else if (it->second->functionWithContext)
{
result = it->second->functionWithContext(context, previousValue, context.contextObject);
}
return result;
}
const char* ResourceIconPath(const char* typeName) const override
{
TTypeMap::const_iterator it = m_typeMap.find(typeName);
if (it != m_typeMap.end())
{
return it->second->iconPath;
}
return "";
}
void RegisterResourceSelector(const SStaticResourceSelectorEntry* entry) override
{
m_typeMap[entry->typeName] = entry;
}
void SetGlobalSelection(const char* resourceType, const char* value) override
{
if (!resourceType || !value)
{
return;
}
m_globallySelectedResources[resourceType] = value;
}
const char* GetGlobalSelection(const char* resourceType) const override
{
if (!resourceType)
{
return "";
}
auto it = m_globallySelectedResources.find(resourceType);
if (it != m_globallySelectedResources.end())
{
return it->second.c_str();
}
return "";
}
private:
using TTypeMap = std::map<AZStd::string, const SStaticResourceSelectorEntry *, stl::less_stricmp<AZStd::string>>;
TTypeMap m_typeMap;
std::map<AZStd::string, AZStd::string> m_globallySelectedResources;
};
// ---------------------------------------------------------------------------
IResourceSelectorHost* CreateResourceSelectorHost()
{
return new CResourceSelectorHost();
}
// ---------------------------------------------------------------------------
QString SoundFileSelector([[maybe_unused]] const SResourceSelectorContext& x, const QString& previousValue)
{
AssetSelectionModel selection = AssetSelectionModel::AssetTypeSelection("Audio");
AzToolsFramework::EditorRequests::Bus::Broadcast(&AzToolsFramework::EditorRequests::BrowseForAssets, selection);
if (selection.IsValid())
{
return Path::FullPathToGamePath(QString(selection.GetResult()->GetFullPath().c_str()));
}
else
{
return Path::FullPathToGamePath(previousValue);
}
}
REGISTER_RESOURCE_SELECTOR("Sound", SoundFileSelector, "")
// ---------------------------------------------------------------------------
QString ModelFileSelector([[maybe_unused]] const SResourceSelectorContext& x, const QString& previousValue)
{
AssetSelectionModel selection = AssetSelectionModel::AssetGroupSelection("Geometry");
AzToolsFramework::EditorRequests::Bus::Broadcast(&AzToolsFramework::EditorRequests::BrowseForAssets, selection);
if (selection.IsValid())
{
return Path::FullPathToGamePath(QString(selection.GetResult()->GetFullPath().c_str()));
}
else
{
return Path::FullPathToGamePath(previousValue);
}
}
REGISTER_RESOURCE_SELECTOR("Model", ModelFileSelector, "")
// ---------------------------------------------------------------------------
QString GeomCacheFileSelector([[maybe_unused]] const SResourceSelectorContext& x, const QString& previousValue)
{
AssetSelectionModel selection = AssetSelectionModel::AssetTypeSelection("Geom Cache");
AzToolsFramework::EditorRequests::Bus::Broadcast(&AzToolsFramework::EditorRequests::BrowseForAssets, selection);
if (selection.IsValid())
{
return Path::FullPathToGamePath(QString(selection.GetResult()->GetFullPath().c_str()));
}
else
{
return Path::FullPathToGamePath(previousValue);
}
}
REGISTER_RESOURCE_SELECTOR("GeomCache", GeomCacheFileSelector, "")

@ -1,18 +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_RESOURCESELECTORHOST_H
#define CRYINCLUDE_EDITOR_RESOURCESELECTORHOST_H
#pragma once
#include "IResourceSelectorHost.h"
IResourceSelectorHost* CreateResourceSelectorHost();
#endif // CRYINCLUDE_EDITOR_RESOURCESELECTORHOST_H

@ -351,7 +351,7 @@ void CVarBlock::EnableUpdateCallbacks(bool boEnable)
void CVarBlock::GatherUsedResourcesInVar(IVariable* pVar, CUsedResources& resources)
{
int type = pVar->GetDataType();
if (type == IVariable::DT_FILE || type == IVariable::DT_OBJECT || type == IVariable::DT_TEXTURE)
if (type == IVariable::DT_TEXTURE)
{
// this is file.
QString filename;

@ -142,15 +142,10 @@ struct IVariable
DT_PERCENT, //!< Percent data type, (Same as simple but value is from 0-1 and UI will be from 0-100).
DT_COLOR,
DT_ANGLE,
DT_FILE,
DT_TEXTURE,
DT_ANIMATION,
DT_OBJECT,
DT_SHADER,
DT_LOCAL_STRING,
DT_EQUIP,
DT_REVERBPRESET,
DT_DEPRECATED0, // formerly DT_MATERIAL
DT_MATERIALLOOKUP,
DT_EXTARRAY, // Extendable Array
DT_SEQUENCE, // Movie Sequence (DEPRECATED, use DT_SEQUENCE_ID, instead.)
@ -160,7 +155,6 @@ struct IVariable
DT_SEQUENCE_ID, // Movie Sequence
DT_LIGHT_ANIMATION, // Light Animation Node in the global Light Animation Set
DT_PARTICLE_EFFECT,
DT_GEOM_CACHE, // Geometry cache
DT_DEPRECATED, // formerly DT_FLARE
DT_AUDIO_TRIGGER,
DT_AUDIO_SWITCH,

@ -37,17 +37,12 @@ namespace Prop
{ IVariable::DT_CURVE | IVariable::DT_PERCENT, "FloatCurve", ePropertyFloatCurve, 13 },
{ IVariable::DT_CURVE | IVariable::DT_COLOR, "ColorCurve", ePropertyColorCurve, 1 },
{ IVariable::DT_ANGLE, "Angle", ePropertyAngle, 0 },
{ IVariable::DT_FILE, "File", ePropertyFile, 7 },
{ IVariable::DT_TEXTURE, "Texture", ePropertyTexture, 4 },
{ IVariable::DT_ANIMATION, "Animation", ePropertyAnimation, -1 },
{ IVariable::DT_MOTION, "Motion", ePropertyMotion, -1 },
{ IVariable::DT_OBJECT, "Model", ePropertyModel, 5 },
{ IVariable::DT_SIMPLE, "Selection", ePropertySelection, -1 },
{ IVariable::DT_SIMPLE, "List", ePropertyList, -1 },
{ IVariable::DT_SHADER, "Shader", ePropertyShader, 9 },
{ IVariable::DT_DEPRECATED0, "DEPRECATED", ePropertyDeprecated2, -1 },
{ IVariable::DT_EQUIP, "Equip", ePropertyEquip, 11 },
{ IVariable::DT_REVERBPRESET, "ReverbPreset", ePropertyReverbPreset, 11 },
{ IVariable::DT_LOCAL_STRING, "LocalString", ePropertyLocalString, 3 },
{ IVariable::DT_SEQUENCE, "Sequence", ePropertySequence, -1 },
{ IVariable::DT_MISSIONOBJ, "Mission Objective", ePropertyMissionObj, -1 },
@ -55,7 +50,6 @@ namespace Prop
{ IVariable::DT_SEQUENCE_ID, "SequenceId", ePropertySequenceId, -1 },
{ IVariable::DT_LIGHT_ANIMATION, "LightAnimation", ePropertyLightAnimation, -1 },
{ IVariable::DT_PARTICLE_EFFECT, "ParticleEffect", ePropertyParticleName, 3 },
{ IVariable::DT_GEOM_CACHE, "Geometry Cache", ePropertyGeomCache, 5 },
{ IVariable::DT_AUDIO_TRIGGER, "Audio Trigger", ePropertyAudioTrigger, 6 },
{ IVariable::DT_AUDIO_SWITCH, "Audio Switch", ePropertyAudioSwitch, 6 },
{ IVariable::DT_AUDIO_SWITCH_STATE, "Audio Switch", ePropertyAudioSwitchState, 6 },
@ -301,31 +295,4 @@ namespace Prop
return -1;
}
const char* GetPropertyTypeToResourceType(PropertyType type)
{
// The strings below are names used together with
// REGISTER_RESOURCE_SELECTOR. See IResourceSelector.h.
switch (type)
{
case ePropertyModel:
return "Model";
case ePropertyGeomCache:
return "GeomCache";
case ePropertyAudioTrigger:
return "AudioTrigger";
case ePropertyAudioSwitch:
return "AudioSwitch";
case ePropertyAudioSwitchState:
return "AudioSwitchState";
case ePropertyAudioRTPC:
return "AudioRTPC";
case ePropertyAudioEnvironment:
return "AudioEnvironment";
case ePropertyAudioPreloadRequest:
return "AudioPreloadRequest";
default:
return nullptr;
}
}
}

@ -28,16 +28,11 @@ enum PropertyType
ePropertyAngle,
ePropertyFloatCurve,
ePropertyColorCurve,
ePropertyFile,
ePropertyTexture,
ePropertyAnimation,
ePropertyModel,
ePropertySelection,
ePropertyList,
ePropertyShader,
ePropertyDeprecated2, // formerly ePropertyMaterial
ePropertyEquip,
ePropertyReverbPreset,
ePropertyLocalString,
ePropertyDeprecated0, // formerly ePropertyCustomAction
ePropertyGameToken,
@ -48,7 +43,6 @@ enum PropertyType
ePropertyLightAnimation,
ePropertyDeprecated1, // formerly ePropertyFlare
ePropertyParticleName,
ePropertyGeomCache,
ePropertyAudioTrigger,
ePropertyAudioSwitch,
ePropertyAudioSwitchState,

@ -289,7 +289,6 @@ set(FILES
Include/IPlugin.h
Include/IPreferencesPage.h
Include/IRenderListener.h
Include/IResourceSelectorHost.h
Include/ISourceControl.h
Include/ISubObjectSelectionReferenceFrameCalculator.h
Include/ITextureDatabaseUpdater.h
@ -360,8 +359,6 @@ set(FILES
Controls/TimelineCtrl.cpp
Controls/TimelineCtrl.h
Controls/WndGridHelper.h
Controls/ReflectedPropertyControl/PropertyAnimationCtrl.cpp
Controls/ReflectedPropertyControl/PropertyAnimationCtrl.h
Controls/ReflectedPropertyControl/PropertyGenericCtrl.cpp
Controls/ReflectedPropertyControl/PropertyGenericCtrl.h
Controls/ReflectedPropertyControl/PropertyMiscCtrl.cpp
@ -372,8 +369,6 @@ set(FILES
Controls/ReflectedPropertyControl/PropertyResourceCtrl.h
Controls/ReflectedPropertyControl/PropertyCtrl.cpp
Controls/ReflectedPropertyControl/PropertyCtrl.h
Controls/ReflectedPropertyControl/ReflectedPropertiesPanel.cpp
Controls/ReflectedPropertyControl/ReflectedPropertiesPanel.h
MainStatusBar.cpp
MainStatusBar.h
MainStatusBarItems.h
@ -590,8 +585,6 @@ set(FILES
FBXExporterDialog.ui
FileTypeUtils.cpp
LightmapCompiler/SimpleTriangleRasterizer.cpp
ResourceSelectorHost.cpp
ResourceSelectorHost.h
ToolBox.cpp
TrackViewNewSequenceDialog.cpp
TrackViewNewSequenceDialog.ui
@ -668,7 +661,6 @@ set(FILES
TrackView/2DBezierKeyUIControls.cpp
TrackView/AssetBlendKeyUIControls.cpp
TrackView/CaptureKeyUIControls.cpp
TrackView/CharacterKeyUIControls.cpp
TrackView/ConsoleKeyUIControls.cpp
TrackView/EventKeyUIControls.cpp
TrackView/GotoKeyUIControls.cpp

@ -841,9 +841,6 @@ namespace AzToolsFramework
*/
virtual AZStd::string GetComponentIconPath(const AZ::Uuid& /*componentType*/, AZ::Crc32 /*componentIconAttrib*/, AZ::Component* /*component*/) { return AZStd::string(); }
/// Resource Selector hook, returns a path for a resource.
virtual AZStd::string SelectResource(const AZStd::string& /*resourceType*/, const AZStd::string& /*previousValue*/) { return AZStd::string(); }
/**
* Calculate the navigation 2D radius in units of an agent given its Navigation Type Name
* @param angentTypeName the name that identifies the agent navigation type

@ -7,8 +7,8 @@
*/
#include "PropertyAudioCtrl.h"
#include "PropertyQTConstants.h"
#include <UI/PropertyEditor/PropertyAudioCtrl.h>
#include <UI/PropertyEditor/PropertyQTConstants.h>
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
@ -34,7 +34,7 @@ namespace AzToolsFramework
: QWidget(parent)
, m_browseEdit(nullptr)
, m_mainLayout(nullptr)
, m_propertyType(AudioPropertyType::Invalid)
, m_propertyType(AudioPropertyType::NumTypes)
{
// create the gui
m_mainLayout = new QHBoxLayout();
@ -96,7 +96,7 @@ namespace AzToolsFramework
return;
}
if (type != AudioPropertyType::Invalid)
if (type != AudioPropertyType::NumTypes)
{
m_propertyType = type;
}
@ -136,10 +136,11 @@ namespace AzToolsFramework
void AudioControlSelectorWidget::OnOpenAudioControlSelector()
{
AZStd::string resourceResult;
AZStd::string resourceType(GetResourceSelectorNameFromType(m_propertyType));
AZStd::string currentValue(m_controlName.toStdString().c_str());
EditorRequests::Bus::BroadcastResult(resourceResult, &EditorRequests::Bus::Events::SelectResource, resourceType, currentValue);
AZStd::string resourceResult;
AudioControlSelectorRequestBus::EventResult(
resourceResult, m_propertyType,
&AudioControlSelectorRequestBus::Events::SelectResource, currentValue);
SetControlName(QString(resourceResult.c_str()));
}
@ -167,12 +168,12 @@ namespace AzToolsFramework
{
case AudioPropertyType::Trigger:
return { "AudioTrigger" };
case AudioPropertyType::Rtpc:
return { "AudioRTPC" };
case AudioPropertyType::Switch:
return { "AudioSwitch" };
case AudioPropertyType::SwitchState:
return { "AudioSwitchState" };
case AudioPropertyType::Rtpc:
return { "AudioRTPC" };
case AudioPropertyType::Environment:
return { "AudioEnvironment" };
case AudioPropertyType::Preload:

@ -29,6 +29,27 @@ class QMimeData;
namespace AzToolsFramework
{
//=============================================================================
// Audio Control Selector Request Bus
// For connecting UI proper
//=============================================================================
class AudioControlSelectorRequests
: public AZ::EBusTraits
{
public:
// EBusTraits
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
using BusIdType = AudioPropertyType;
virtual AZStd::string SelectResource(AZStd::string_view previousValue)
{
return previousValue;
}
};
using AudioControlSelectorRequestBus = AZ::EBus<AudioControlSelectorRequests>;
//=============================================================================
// Audio Control Selector Widget
//=============================================================================

@ -18,15 +18,15 @@
namespace AzToolsFramework
{
//=========================================================================
enum class AudioPropertyType
enum class AudioPropertyType : AZ::u32
{
Invalid = 0,
Trigger,
Trigger = 0,
Rtpc,
Switch,
SwitchState,
Rtpc,
Environment,
Preload,
NumTypes,
};
//=========================================================================
@ -40,7 +40,7 @@ namespace AzToolsFramework
virtual ~CReflectedVarAudioControl() = default;
AZStd::string m_controlName;
AudioPropertyType m_propertyType = AudioPropertyType::Invalid;
AudioPropertyType m_propertyType = AudioPropertyType::NumTypes;
static void Reflect(AZ::ReflectContext* context)
{

@ -30,6 +30,8 @@ namespace AudioControls
: QDialog(pParent)
, m_eType(eType)
{
AZ_Assert(CAudioControlsEditorPlugin::GetATLModel() != nullptr, "ATLControlsDialog - ATL Model is null!");
setWindowTitle(GetWindowTitle(m_eType));
setWindowModality(Qt::ApplicationModal);

@ -14,8 +14,6 @@
#include <AudioControlsLoader.h>
#include <AudioControlsWriter.h>
#include <AudioResourceSelectors.h>
#include <IAudioSystem.h>
#include <IAudioSystemEditor.h>
#include <ImplementationManager.h>
@ -41,7 +39,6 @@ CAudioControlsEditorPlugin::CAudioControlsEditorPlugin(IEditor* editor)
QtViewOptions options;
options.canHaveMultipleInstances = true;
RegisterQtViewPane<CAudioControlsEditorWindow>(editor, LyViewPane::AudioControlsEditor, LyViewPane::CategoryOther, options);
RegisterAudioControlsResourceSelectors();
Audio::AudioSystemRequestBus::BroadcastResult(ms_pIAudioProxy, &Audio::AudioSystemRequestBus::Events::GetFreeAudioProxy);

@ -13,6 +13,7 @@
#include <AzCore/std/string/string_view.h>
#include <ATLControlsModel.h>
#include <AudioResourceSelectors.h>
#include <IAudioInterfacesCommonData.h>
#include <IAudioSystemEditor.h>
#include <QATLControlsTreeModel.h>
@ -68,6 +69,7 @@ private:
static AudioControls::FilepathSet ms_currentFilenames;
static Audio::IAudioProxy* ms_pIAudioProxy;
static Audio::TAudioControlID ms_nAudioTriggerID;
static CImplementationManager ms_implementationManager;
AudioControls::AudioControlSelectorHandler m_controlSelector;
};

@ -10,88 +10,45 @@
#include <AudioResourceSelectors.h>
#include <ATLControlsResourceDialog.h>
#include <AudioControlsEditorPlugin.h>
#include <Include/IResourceSelectorHost.h>
#include <QAudioControlEditorIcons.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <UI/PropertyEditor/PropertyAudioCtrlTypes.h>
namespace AudioControls
{
//-------------------------------------------------------------------------------------------//
QString ShowSelectDialog(const SResourceSelectorContext& context, const QString& pPreviousValue, const EACEControlType controlType)
AudioControlSelectorHandler::AudioControlSelectorHandler()
{
AZ_Assert(CAudioControlsEditorPlugin::GetATLModel() != nullptr, "AudioResourceSelectors - ATL Model is null!");
AZStd::string levelName;
AzToolsFramework::EditorRequestBus::BroadcastResult(levelName, &AzToolsFramework::EditorRequests::GetLevelName);
ATLControlsDialog dialog(context.parentWidget, controlType);
dialog.SetScope(levelName);
return dialog.ChooseItem(pPreviousValue.toUtf8().constData());
}
//-------------------------------------------------------------------------------------------//
QString AudioTriggerSelector(const SResourceSelectorContext& context, const QString& pPreviousValue)
for (AZ::u32 type = 0; type < static_cast<AZ::u32>(AzToolsFramework::AudioPropertyType::NumTypes); ++type)
{
return ShowSelectDialog(context, pPreviousValue, eACET_TRIGGER);
AzToolsFramework::AudioControlSelectorRequestBus::MultiHandler::BusConnect(
static_cast<AzToolsFramework::AudioPropertyType>(type));
}
//-------------------------------------------------------------------------------------------//
QString AudioSwitchSelector(const SResourceSelectorContext& context, const QString& pPreviousValue)
{
return ShowSelectDialog(context, pPreviousValue, eACET_SWITCH);
}
//-------------------------------------------------------------------------------------------//
QString AudioSwitchStateSelector(const SResourceSelectorContext& context, const QString& pPreviousValue)
AudioControlSelectorHandler::~AudioControlSelectorHandler()
{
return ShowSelectDialog(context, pPreviousValue, eACET_SWITCH_STATE);
AzToolsFramework::AudioControlSelectorRequestBus::MultiHandler::BusDisconnect();
}
//-------------------------------------------------------------------------------------------//
QString AudioRTPCSelector(const SResourceSelectorContext& context, const QString& pPreviousValue)
AZStd::string AudioControlSelectorHandler::SelectResource(AZStd::string_view previousValue)
{
return ShowSelectDialog(context, pPreviousValue, eACET_RTPC);
}
//-------------------------------------------------------------------------------------------//
QString AudioEnvironmentSelector(const SResourceSelectorContext& context, const QString& pPreviousValue)
using namespace AzToolsFramework;
if (auto busId = AudioControlSelectorRequestBus::GetCurrentBusId();
busId != nullptr)
{
return ShowSelectDialog(context, pPreviousValue, eACET_ENVIRONMENT);
}
//-------------------------------------------------------------------------------------------//
QString AudioPreloadRequestSelector(const SResourceSelectorContext& context, const QString& pPreviousValue)
{
return ShowSelectDialog(context, pPreviousValue, eACET_PRELOAD);
}
auto controlType = static_cast<EACEControlType>(*busId);
QWidget* parentWidget = nullptr;
AzToolsFramework::EditorRequestBus::BroadcastResult(parentWidget, &AzToolsFramework::EditorRequestBus::Events::GetMainWindow);
//-------------------------------------------------------------------------------------------//
static SStaticResourceSelectorEntry audioTriggerSelector(
"AudioTrigger", AudioTriggerSelector, ":/Icons/Trigger_Icon.svg");
static SStaticResourceSelectorEntry audioSwitchSelector(
"AudioSwitch", AudioSwitchSelector, ":/Icons/Switch_Icon.svg");
static SStaticResourceSelectorEntry audioStateSelector(
"AudioSwitchState", AudioSwitchStateSelector, ":/Icons/Property_Icon.png");
static SStaticResourceSelectorEntry audioRtpcSelector(
"AudioRTPC", AudioRTPCSelector, ":/Icons/RTPC_Icon.svg");
static SStaticResourceSelectorEntry audioEnvironmentSelector(
"AudioEnvironment", AudioEnvironmentSelector, ":/Icons/Environment_Icon.svg");
static SStaticResourceSelectorEntry audioPreloadSelector(
"AudioPreloadRequest", AudioPreloadRequestSelector, ":/Icons/Bank_Icon.png");
AZStd::string levelName;
AzToolsFramework::EditorRequestBus::BroadcastResult(levelName, &AzToolsFramework::EditorRequests::GetLevelName);
//-------------------------------------------------------------------------------------------//
void RegisterAudioControlsResourceSelectors()
{
if (IResourceSelectorHost* host = GetIEditor()->GetResourceSelectorHost();
host != nullptr)
{
host->RegisterResourceSelector(&audioTriggerSelector);
host->RegisterResourceSelector(&audioSwitchSelector);
host->RegisterResourceSelector(&audioStateSelector);
host->RegisterResourceSelector(&audioRtpcSelector);
host->RegisterResourceSelector(&audioEnvironmentSelector);
host->RegisterResourceSelector(&audioPreloadSelector);
ATLControlsDialog dialog(parentWidget, controlType);
dialog.SetScope(levelName);
return dialog.ChooseItem(previousValue.data());
}
return previousValue;
}
} // namespace AudioControls

@ -8,7 +8,16 @@
#pragma once
#include <AzToolsFramework/UI/PropertyEditor/PropertyAudioCtrl.h>
namespace AudioControls
{
void RegisterAudioControlsResourceSelectors();
class AudioControlSelectorHandler
: public AzToolsFramework::AudioControlSelectorRequestBus::MultiHandler
{
public:
AudioControlSelectorHandler();
~AudioControlSelectorHandler();
AZStd::string SelectResource(AZStd::string_view previousValue) override;
};
}

Loading…
Cancel
Save