Removed legacy editor DatabaseLibrary code.

Signed-off-by: Chris Galvan <chgalvan@amazon.com>
monroegm-disable-blank-issue-2
Chris Galvan 4 years ago
parent 14661af13f
commit fee88cf5c6

@ -1,232 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "BaseLibrary.h"
#include "BaseLibraryItem.h"
#include "Include/IBaseLibraryManager.h"
#include <Util/PathUtil.h>
#include <IFileUtil.h>
//////////////////////////////////////////////////////////////////////////
// CBaseLibrary implementation.
//////////////////////////////////////////////////////////////////////////
CBaseLibrary::CBaseLibrary(IBaseLibraryManager* pManager)
: m_pManager(pManager)
, m_bModified(false)
, m_bLevelLib(false)
, m_bNewLibrary(true)
{
}
//////////////////////////////////////////////////////////////////////////
CBaseLibrary::~CBaseLibrary()
{
m_items.clear();
}
//////////////////////////////////////////////////////////////////////////
IBaseLibraryManager* CBaseLibrary::GetManager()
{
return m_pManager;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibrary::RemoveAllItems()
{
AddRef();
for (int i = 0; i < m_items.size(); i++)
{
// Unregister item in case it was registered. It is ok if it wasn't. This is still safe to call.
m_pManager->UnregisterItem(m_items[i]);
// Clear library item.
m_items[i]->m_library = nullptr;
}
m_items.clear();
Release();
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibrary::SetName(const QString& name)
{
//the fullname of the items in the library will be changed due to library's name change
//so we need unregistered them and register them after their name changed.
for (int i = 0; i < m_items.size(); i++)
{
m_pManager->UnregisterItem(m_items[i]);
}
m_name = name;
for (int i = 0; i < m_items.size(); i++)
{
m_pManager->RegisterItem(m_items[i]);
}
SetModified();
}
//////////////////////////////////////////////////////////////////////////
const QString& CBaseLibrary::GetName() const
{
return m_name;
}
//////////////////////////////////////////////////////////////////////////
bool CBaseLibrary::Save()
{
return true;
}
//////////////////////////////////////////////////////////////////////////
bool CBaseLibrary::Load(const QString& filename)
{
m_filename = filename;
SetModified(false);
m_bNewLibrary = false;
return true;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibrary::SetModified(bool bModified)
{
if (bModified != m_bModified)
{
m_bModified = bModified;
emit Modified(bModified);
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibrary::AddItem(IDataBaseItem* item, bool bRegister)
{
CBaseLibraryItem* pLibItem = (CBaseLibraryItem*)item;
// Check if item is already assigned to this library.
if (pLibItem->m_library != this)
{
pLibItem->m_library = this;
m_items.push_back(pLibItem);
SetModified();
if (bRegister)
{
m_pManager->RegisterItem(pLibItem);
}
}
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibrary::GetItem(int index)
{
assert(index >= 0 && index < m_items.size());
return m_items[index];
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibrary::RemoveItem(IDataBaseItem* item)
{
for (int i = 0; i < m_items.size(); i++)
{
if (m_items[i] == item)
{
// Unregister item in case it was registered. It is ok if it wasn't. This is still safe to call.
m_pManager->UnregisterItem(m_items[i]);
m_items.erase(m_items.begin() + i);
SetModified();
break;
}
}
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibrary::FindItem(const QString& name)
{
for (int i = 0; i < m_items.size(); i++)
{
if (QString::compare(m_items[i]->GetName(), name, Qt::CaseInsensitive) == 0)
{
return m_items[i];
}
}
return nullptr;
}
bool CBaseLibrary::AddLibraryToSourceControl(const QString& fullPathName) const
{
IEditor* pEditor = GetIEditor();
IFileUtil* pFileUtil = pEditor ? pEditor->GetFileUtil() : nullptr;
if (pFileUtil)
{
return pFileUtil->CheckoutFile(fullPathName.toUtf8().data(), nullptr);
}
return false;
}
bool CBaseLibrary::SaveLibrary(const char* name, bool saveEmptyLibrary)
{
assert(name != nullptr);
if (name == nullptr)
{
CryFatalError("The library you are attempting to save has no name specified.");
return false;
}
QString fileName(GetFilename());
if (fileName.isEmpty() && !saveEmptyLibrary)
{
return false;
}
fileName = Path::GamePathToFullPath(fileName);
XmlNodeRef root = GetIEditor()->GetSystem()->CreateXmlNode(name);
Serialize(root, false);
bool bRes = XmlHelpers::SaveXmlNode(GetIEditor()->GetFileUtil(), root, fileName.toUtf8().data());
if (m_bNewLibrary)
{
AddLibraryToSourceControl(fileName);
m_bNewLibrary = false;
}
if (!bRes)
{
QByteArray filenameUtf8 = fileName.toUtf8();
AZStd::string strMessage = AZStd::string::format("The file %s is read-only and the save of the library couldn't be performed. Try to remove the \"read-only\" flag or check-out the file and then try again.", filenameUtf8.data());
CryMessageBox(strMessage.c_str(), "Saving Error", MB_OK | MB_ICONWARNING);
}
return bRes;
}
//CONFETTI BEGIN
void CBaseLibrary::ChangeItemOrder(CBaseLibraryItem* item, unsigned int newLocation)
{
std::vector<_smart_ptr<CBaseLibraryItem> > temp;
for (unsigned int i = 0; i < m_items.size(); i++)
{
if (i == newLocation)
{
temp.push_back(_smart_ptr<CBaseLibraryItem>(item));
}
if (m_items[i] != item)
{
temp.push_back(m_items[i]);
}
}
// If newLocation is greater than the original size, append the item to end of the list
if (newLocation >= m_items.size())
{
temp.push_back(_smart_ptr<CBaseLibraryItem>(item));
}
m_items = temp;
}
//CONFETTI END
#include <moc_BaseLibrary.cpp>

@ -1,129 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_BASELIBRARY_H
#define CRYINCLUDE_EDITOR_BASELIBRARY_H
#pragma once
#if !defined(Q_MOC_RUN)
#include "Include/IDataBaseLibrary.h"
#include "Include/IBaseLibraryManager.h"
#include "Include/EditorCoreAPI.h"
#include "Util/TRefCountBase.h"
#include <QObject>
#endif
// Ensure we don't try to dllimport when moc includes us
#if defined(Q_MOC_BUILD) && !defined(EDITOR_CORE)
#define EDITOR_CORE
#endif
/** This a base class for all Libraries used by Editor.
*/
class EDITOR_CORE_API CBaseLibrary
: public QObject
, public TRefCountBase<IDataBaseLibrary>
{
Q_OBJECT
public:
explicit CBaseLibrary(IBaseLibraryManager* pManager);
~CBaseLibrary();
//! Set library name.
virtual void SetName(const QString& name);
//! Get library name.
const QString& GetName() const override;
//! Set new filename for this library.
virtual bool SetFilename(const QString& filename, [[maybe_unused]] bool checkForUnique = true) { m_filename = filename.toLower(); return true; };
const QString& GetFilename() const override { return m_filename; };
bool Save() override = 0;
bool Load(const QString& filename) override = 0;
void Serialize(XmlNodeRef& node, bool bLoading) override = 0;
//! Mark library as modified.
void SetModified(bool bModified = true) override;
//! Check if library was modified.
bool IsModified() const override { return m_bModified; };
//////////////////////////////////////////////////////////////////////////
// Working with items.
//////////////////////////////////////////////////////////////////////////
//! Add a new prototype to library.
void AddItem(IDataBaseItem* item, bool bRegister = true) override;
//! Get number of known prototypes.
int GetItemCount() const override { return static_cast<int>(m_items.size()); }
//! Get prototype by index.
IDataBaseItem* GetItem(int index) override;
//! Delete item by pointer of item.
void RemoveItem(IDataBaseItem* item) override;
//! Delete all items from library.
void RemoveAllItems() override;
//! Find library item by name.
//! Using linear search.
IDataBaseItem* FindItem(const QString& name) override;
//! Check if this library is local level library.
bool IsLevelLibrary() const override { return m_bLevelLib; };
//! Set library to be level library.
void SetLevelLibrary(bool bEnable) override { m_bLevelLib = bEnable; };
//////////////////////////////////////////////////////////////////////////
//! Return manager for this library.
IBaseLibraryManager* GetManager() override;
// Saves the library with the main tag defined by the parameter name
bool SaveLibrary(const char* name, bool saveEmptyLibrary = false);
//CONFETTI BEGIN
// Used to change the library item order
void ChangeItemOrder(CBaseLibraryItem* item, unsigned int newLocation) override;
//CONFETTI END
signals:
void Modified(bool bModified);
private:
// Add the library to the source control
bool AddLibraryToSourceControl(const QString& fullPathName) const;
protected:
//! Name of the library.
QString m_name;
//! Filename of the library.
QString m_filename;
//! Flag set when library was modified.
bool m_bModified;
// Flag set when the library is just created and it's not yet saved for the first time.
bool m_bNewLibrary;
//! Level library is saved within the level .ly file and is local for this level.
bool m_bLevelLib;
//////////////////////////////////////////////////////////////////////////
// Manager.
IBaseLibraryManager* m_pManager;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
// Array of all our library items.
std::vector<_smart_ptr<CBaseLibraryItem> > m_items;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
#endif // CRYINCLUDE_EDITOR_BASELIBRARY_H

@ -1,261 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "BaseLibraryItem.h"
#include "BaseLibrary.h"
#include "BaseLibraryManager.h"
#include "Undo/IUndoObject.h"
#include <AzCore/Math/Uuid.h>
//undo object for multi-changes inside library item. such as set all variables to default values.
//For example: change particle emitter shape will lead to multiple variable changes
class CUndoBaseLibraryItem
: public IUndoObject
{
public:
CUndoBaseLibraryItem(IBaseLibraryManager *libMgr, CBaseLibraryItem* libItem, bool ignoreChild)
: m_libMgr(libMgr)
{
assert(libItem);
assert(libMgr);
m_itemPath = libItem->GetFullName();
//serialize the lib item to undo
m_undoCtx.node = GetIEditor()->GetSystem()->CreateXmlNode("Undo");
m_undoCtx.bIgnoreChilds = ignoreChild;
m_undoCtx.bLoading = false; //saving
m_undoCtx.bUniqName = false; //don't generate new name
m_undoCtx.bCopyPaste = true; //so it won't override guid
m_undoCtx.bUndo = true;
libItem->Serialize(m_undoCtx);
//evaluate size
XmlString xmlStr = m_undoCtx.node->getXML();
m_size = sizeof(CUndoBaseLibraryItem);
m_size += static_cast<int>(xmlStr.GetAllocatedMemory());
m_size += m_itemPath.length();
}
protected:
int GetSize() override
{
return m_size;
}
void Undo(bool bUndo) override
{
//find the libItem
IDataBaseItem *libItem = m_libMgr->FindItemByName(m_itemPath);
if (libItem == nullptr)
{
//the undo stack is not reliable any more..
assert(false);
return;
}
//save for redo
if (bUndo)
{
m_redoCtx.node = GetIEditor()->GetSystem()->CreateXmlNode("Redo");
m_redoCtx.bIgnoreChilds = m_undoCtx.bIgnoreChilds;
m_redoCtx.bLoading = false; //saving
m_redoCtx.bUniqName = false;
m_redoCtx.bCopyPaste = true;
m_redoCtx.bUndo = true;
libItem->Serialize(m_redoCtx);
XmlString xmlStr = m_redoCtx.node->getXML();
m_size += static_cast<int>(xmlStr.GetAllocatedMemory());
}
//load previous saved data
m_undoCtx.bLoading = true;
libItem->Serialize(m_undoCtx);
}
void Redo() override
{
//find the libItem
IDataBaseItem *libItem = m_libMgr->FindItemByName(m_itemPath);
if (libItem == nullptr || m_redoCtx.node == nullptr)
{
//the undo stack is not reliable any more..
assert(false);
return;
}
m_redoCtx.bLoading = true;
libItem->Serialize(m_redoCtx);
}
private:
QString m_itemPath;
IDataBaseItem::SerializeContext m_undoCtx; //saved before operation
IDataBaseItem::SerializeContext m_redoCtx; //saved after operation so used for redo
IBaseLibraryManager* m_libMgr;
int m_size;
};
//////////////////////////////////////////////////////////////////////////
// CBaseLibraryItem implementation.
//////////////////////////////////////////////////////////////////////////
CBaseLibraryItem::CBaseLibraryItem()
{
m_library = nullptr;
GenerateId();
m_bModified = false;
}
CBaseLibraryItem::~CBaseLibraryItem()
{
}
//////////////////////////////////////////////////////////////////////////
QString CBaseLibraryItem::GetFullName() const
{
QString name;
if (m_library)
{
name = m_library->GetName() + ".";
}
name += m_name;
return name;
}
//////////////////////////////////////////////////////////////////////////
QString CBaseLibraryItem::GetGroupName()
{
QString str = GetName();
int p = str.lastIndexOf('.');
if (p >= 0)
{
return str.mid(0, p);
}
return "";
}
//////////////////////////////////////////////////////////////////////////
QString CBaseLibraryItem::GetShortName()
{
QString str = GetName();
int p = str.lastIndexOf('.');
if (p >= 0)
{
return str.mid(p + 1);
}
p = str.lastIndexOf('/');
if (p >= 0)
{
return str.mid(p + 1);
}
return str;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryItem::SetName(const QString& name)
{
assert(m_library);
if (name == m_name)
{
return;
}
QString oldName = GetFullName();
m_name = name;
((CBaseLibraryManager*)m_library->GetManager())->OnRenameItem(this, oldName);
}
//////////////////////////////////////////////////////////////////////////
const QString& CBaseLibraryItem::GetName() const
{
return m_name;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryItem::GenerateId()
{
GUID guid = AZ::Uuid::CreateRandom();
SetGUID(guid);
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryItem::SetGUID(REFGUID guid)
{
if (m_library)
{
((CBaseLibraryManager*)m_library->GetManager())->RegisterItem(this, guid);
}
m_guid = guid;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryItem::Serialize(SerializeContext& ctx)
{
assert(m_library);
XmlNodeRef node = ctx.node;
if (ctx.bLoading)
{
QString name = m_name;
// Loading
node->getAttr("Name", name);
if (!ctx.bUniqName)
{
SetName(name);
}
else
{
SetName(GetLibrary()->GetManager()->MakeUniqueItemName(name));
}
if (!ctx.bCopyPaste)
{
GUID guid;
if (node->getAttr("Id", guid))
{
SetGUID(guid);
}
}
}
else
{
// Saving.
node->setAttr("Name", m_name.toUtf8().data());
node->setAttr("Id", m_guid);
node->setAttr("Library", GetLibrary()->GetName().toUtf8().data());
}
m_bModified = false;
}
//////////////////////////////////////////////////////////////////////////
IDataBaseLibrary* CBaseLibraryItem::GetLibrary() const
{
return m_library;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryItem::SetLibrary(CBaseLibrary* pLibrary)
{
m_library = pLibrary;
}
//! Mark library as modified.
void CBaseLibraryItem::SetModified(bool bModified)
{
m_bModified = bModified;
if (m_bModified && m_library != nullptr)
{
m_library->SetModified(bModified);
}
}

@ -1,114 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_BASELIBRARYITEM_H
#define CRYINCLUDE_EDITOR_BASELIBRARYITEM_H
#pragma once
#include "Include/IDataBaseItem.h"
#include "BaseLibrary.h"
#include <QMetaType>
class CBaseLibrary;
//////////////////////////////////////////////////////////////////////////
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
/** Base class for all items contained in BaseLibraray.
*/
class EDITOR_CORE_API CBaseLibraryItem
: public TRefCountBase<IDataBaseItem>
{
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
public:
CBaseLibraryItem();
~CBaseLibraryItem();
//! Set item name.
//! Its virtual, in case you want to override it in derrived item.
virtual void SetName(const QString& name);
//! Get item name.
const QString& GetName() const;
//! Get full item name, including name of library.
//! Name formed by adding dot after name of library
//! eg. library Pickup and item PickupRL form full item name: "Pickups.PickupRL".
QString GetFullName() const;
//! Get only nameof group from prototype.
QString GetGroupName();
//! Get short name of prototype without group.
QString GetShortName();
//! Return Library this item are contained in.
//! Item can only be at one library.
IDataBaseLibrary* GetLibrary() const;
void SetLibrary(CBaseLibrary* pLibrary);
//////////////////////////////////////////////////////////////////////////
//! Serialize library item to archive.
virtual void Serialize(SerializeContext& ctx);
//////////////////////////////////////////////////////////////////////////
//! Generate new unique id for this item.
void GenerateId();
//! Returns GUID of this material.
const GUID& GetGUID() const { return m_guid; }
//! Mark library as modified.
void SetModified(bool bModified = true);
//! Check if library was modified.
bool IsModified() const { return m_bModified; };
//! Returns true if the item is registered, otherwise false
bool IsRegistered() const { return m_bRegistered; };
//! Validate item for errors.
virtual void Validate() {};
//! Get number of sub childs.
virtual int GetChildCount() const { return 0; }
//! Get sub child by index.
virtual CBaseLibraryItem* GetChild([[maybe_unused]] int index) const { return nullptr; }
//////////////////////////////////////////////////////////////////////////
//! Gathers resources by this item.
virtual void GatherUsedResources([[maybe_unused]] CUsedResources& resources) {};
//! Get if stored item is enabled
virtual bool GetIsEnabled() { return true; };
int IsParticleItem = -1;
protected:
void SetGUID(REFGUID guid);
friend class CBaseLibrary;
friend class CBaseLibraryManager;
// Name of this prototype.
QString m_name;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
//! Reference to prototype library who contains this prototype.
_smart_ptr<CBaseLibrary> m_library;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
//! Every base library item have unique id.
GUID m_guid;
// True when item modified by editor.
bool m_bModified;
// True when item registered in manager.
bool m_bRegistered = false;
};
Q_DECLARE_METATYPE(CBaseLibraryItem*);
TYPEDEF_AUTOPTR(CBaseLibraryItem);
#endif // CRYINCLUDE_EDITOR_BASELIBRARYITEM_H

@ -1,822 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "BaseLibraryManager.h"
// Editor
#include "BaseLibraryItem.h"
#include "ErrorReport.h"
#include "Undo/IUndoObject.h"
//////////////////////////////////////////////////////////////////////////
// CBaseLibraryManager implementation.
//////////////////////////////////////////////////////////////////////////
CBaseLibraryManager::CBaseLibraryManager()
{
m_bUniqNameMap = false;
m_bUniqGuidMap = true;
GetIEditor()->RegisterNotifyListener(this);
}
//////////////////////////////////////////////////////////////////////////
CBaseLibraryManager::~CBaseLibraryManager()
{
ClearAll();
GetIEditor()->UnregisterNotifyListener(this);
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::ClearAll()
{
// Delete all items from all libraries.
for (int i = 0; i < m_libs.size(); i++)
{
m_libs[i]->RemoveAllItems();
}
// if we will not copy maps locally then destructors of the elements of
// the map will operate on the already invalid map object
// see:
// CBaseLibraryManager::UnregisterItem()
// CBaseLibraryManager::DeleteItem()
// CMaterial::~CMaterial()
ItemsGUIDMap itemsGuidMap;
ItemsNameMap itemsNameMap;
{
AZStd::lock_guard<AZStd::mutex> lock(m_itemsNameMapMutex);
std::swap(itemsGuidMap, m_itemsGuidMap);
std::swap(itemsNameMap, m_itemsNameMap);
m_libs.clear();
}
}
//////////////////////////////////////////////////////////////////////////
IDataBaseLibrary* CBaseLibraryManager::FindLibrary(const QString& library)
{
const int index = FindLibraryIndex(library);
return index == -1 ? nullptr : m_libs[index];
}
//////////////////////////////////////////////////////////////////////////
int CBaseLibraryManager::FindLibraryIndex(const QString& library)
{
QString lib = library;
lib.replace('\\', '/');
for (int i = 0; i < m_libs.size(); i++)
{
QString _lib = m_libs[i]->GetFilename();
_lib.replace('\\', '/');
if (QString::compare(lib, m_libs[i]->GetName(), Qt::CaseInsensitive) == 0 || QString::compare(lib, _lib, Qt::CaseInsensitive) == 0)
{
return i;
}
}
return -1;
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibraryManager::FindItem(REFGUID guid) const
{
CBaseLibraryItem* pMtl = stl::find_in_map(m_itemsGuidMap, guid, nullptr);
return pMtl;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::SplitFullItemName(const QString& fullItemName, QString& libraryName, QString& itemName)
{
int p;
p = fullItemName.indexOf('.');
if (p < 0 || !QString::compare(fullItemName.mid(p + 1), "mtl", Qt::CaseInsensitive))
{
libraryName = "";
itemName = fullItemName;
return;
}
libraryName = fullItemName.mid(0, p);
itemName = fullItemName.mid(p + 1);
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibraryManager::FindItemByName(const QString& fullItemName)
{
AZStd::lock_guard<AZStd::mutex> lock(m_itemsNameMapMutex);
return stl::find_in_map(m_itemsNameMap, fullItemName, nullptr);
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibraryManager::LoadItemByName(const QString& fullItemName)
{
QString libraryName, itemName;
SplitFullItemName(fullItemName, libraryName, itemName);
if (!FindLibrary(libraryName))
{
LoadLibrary(MakeFilename(libraryName));
}
return FindItemByName(fullItemName);
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibraryManager::FindItemByName(const char* fullItemName)
{
return FindItemByName(QString(fullItemName));
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibraryManager::LoadItemByName(const char* fullItemName)
{
return LoadItemByName(QString(fullItemName));
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibraryManager::CreateItem(IDataBaseLibrary* pLibrary)
{
assert(pLibrary);
// Add item to this library.
TSmartPtr<CBaseLibraryItem> pItem = MakeNewItem();
pLibrary->AddItem(pItem);
return pItem;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::DeleteItem(IDataBaseItem* pItem)
{
assert(pItem);
UnregisterItem((CBaseLibraryItem*)pItem);
if (pItem->GetLibrary())
{
pItem->GetLibrary()->RemoveItem(pItem);
}
}
//////////////////////////////////////////////////////////////////////////
IDataBaseLibrary* CBaseLibraryManager::LoadLibrary(const QString& inFilename, [[maybe_unused]] bool bReload)
{
if (auto lib = FindLibrary(inFilename))
{
return lib;
}
TSmartPtr<CBaseLibrary> pLib = MakeNewLibrary();
if (!pLib->Load(MakeFilename(inFilename)))
{
Error(QObject::tr("Failed to Load Item Library: %1").arg(inFilename).toUtf8().data());
return nullptr;
}
m_libs.push_back(pLib);
return pLib;
}
//////////////////////////////////////////////////////////////////////////
int CBaseLibraryManager::GetModifiedLibraryCount() const
{
int count = 0;
for (int i = 0; i < m_libs.size(); i++)
{
if (m_libs[i]->IsModified())
{
count++;
}
}
return count;
}
//////////////////////////////////////////////////////////////////////////
IDataBaseLibrary* CBaseLibraryManager::AddLibrary(const QString& library, bool bIsLevelLibrary, bool bIsLoading)
{
// Make a filename from name of library.
QString filename = library;
if (filename.indexOf(".xml") == -1) // if its already a filename, we don't do anything
{
filename.replace(' ', '_');
if (!bIsLevelLibrary)
{
filename = MakeFilename(library);
}
else
{
// if its the level library it gets saved in the level and should not be concatenated with any other file name
filename = filename + ".xml";
}
}
IDataBaseLibrary* pBaseLib = FindLibrary(library); //library name
if (!pBaseLib)
{
pBaseLib = FindLibrary(filename); //library file name
}
if (pBaseLib)
{
return pBaseLib;
}
CBaseLibrary* lib = MakeNewLibrary();
lib->SetName(library);
lib->SetLevelLibrary(bIsLevelLibrary);
lib->SetFilename(filename, !bIsLoading);
// set modified to true, so even empty particle libraries get saved
lib->SetModified(true);
m_libs.push_back(lib);
return lib;
}
//////////////////////////////////////////////////////////////////////////
QString CBaseLibraryManager::MakeFilename(const QString& library)
{
QString filename = library;
filename.replace(' ', '_');
filename.replace(".xml", "");
// make it contain the canonical libs path:
Path::ConvertBackSlashToSlash(filename);
QString LibsPath(GetLibsPath());
Path::ConvertBackSlashToSlash(LibsPath);
if (filename.left(LibsPath.length()).compare(LibsPath, Qt::CaseInsensitive) == 0)
{
filename = filename.mid(LibsPath.length());
}
return LibsPath + filename + ".xml";
}
//////////////////////////////////////////////////////////////////////////
bool CBaseLibraryManager::IsUniqueFilename(const QString& library)
{
QString resultPath = MakeFilename(library);
CCryFile xmlFile;
// If we can find a file for the path
return !xmlFile.Open(resultPath.toUtf8().data(), "rb");
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::DeleteLibrary(const QString& library, bool forceDeleteLevel)
{
for (int i = 0; i < m_libs.size(); i++)
{
if (QString::compare(library, m_libs[i]->GetName(), Qt::CaseInsensitive) == 0)
{
CBaseLibrary* pLibrary = m_libs[i];
// Check if not level library, they cannot be deleted.
if (!pLibrary->IsLevelLibrary() || forceDeleteLevel)
{
for (int j = 0; j < pLibrary->GetItemCount(); j++)
{
UnregisterItem((CBaseLibraryItem*)pLibrary->GetItem(j));
}
pLibrary->RemoveAllItems();
if (pLibrary->IsLevelLibrary())
{
m_pLevelLibrary = nullptr;
}
m_libs.erase(m_libs.begin() + i);
}
break;
}
}
}
//////////////////////////////////////////////////////////////////////////
IDataBaseLibrary* CBaseLibraryManager::GetLibrary(int index) const
{
assert(index >= 0 && index < m_libs.size());
return m_libs[index];
};
//////////////////////////////////////////////////////////////////////////
IDataBaseLibrary* CBaseLibraryManager::GetLevelLibrary() const
{
IDataBaseLibrary* pLevelLib = nullptr;
for (int i = 0; i < GetLibraryCount(); i++)
{
if (GetLibrary(i)->IsLevelLibrary())
{
pLevelLib = GetLibrary(i);
break;
}
}
return pLevelLib;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::SaveAllLibs()
{
for (int i = 0; i < GetLibraryCount(); i++)
{
// Check if library is modified.
IDataBaseLibrary* pLibrary = GetLibrary(i);
//Level library is saved when the level is saved
if (pLibrary->IsLevelLibrary())
{
continue;
}
if (pLibrary->IsModified())
{
if (pLibrary->Save())
{
pLibrary->SetModified(false);
}
}
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::Serialize(XmlNodeRef& node, bool bLoading)
{
static const char* const LEVEL_LIBRARY_TAG = "LevelLibrary";
QString rootNodeName = GetRootNodeName();
if (bLoading)
{
XmlNodeRef libs = node->findChild(rootNodeName.toUtf8().data());
if (libs)
{
for (int i = 0; i < libs->getChildCount(); i++)
{
// Load only library name.
XmlNodeRef libNode = libs->getChild(i);
if (strcmp(libNode->getTag(), LEVEL_LIBRARY_TAG) == 0)
{
if (!m_pLevelLibrary)
{
QString libName;
libNode->getAttr("Name", libName);
m_pLevelLibrary = static_cast<CBaseLibrary*>(AddLibrary(libName, true));
}
m_pLevelLibrary->Serialize(libNode, bLoading);
}
else
{
QString libName;
if (libNode->getAttr("Name", libName))
{
// Load this library.
if (!FindLibrary(libName))
{
LoadLibrary(MakeFilename(libName));
}
}
}
}
}
}
else
{
// Save all libraries.
XmlNodeRef libs = node->newChild(rootNodeName.toUtf8().data());
for (int i = 0; i < GetLibraryCount(); i++)
{
IDataBaseLibrary* pLib = GetLibrary(i);
if (pLib->IsLevelLibrary())
{
// Level libraries are saved in in level.
XmlNodeRef libNode = libs->newChild(LEVEL_LIBRARY_TAG);
pLib->Serialize(libNode, bLoading);
}
else
{
// Save only library name.
XmlNodeRef libNode = libs->newChild("Library");
libNode->setAttr("Name", pLib->GetName().toUtf8().data());
}
}
SaveAllLibs();
}
}
//////////////////////////////////////////////////////////////////////////
QString CBaseLibraryManager::MakeUniqueItemName(const QString& srcName, const QString& libName)
{
// unlikely we'll ever encounter more than 16
std::vector<AZStd::string> possibleDuplicates;
possibleDuplicates.reserve(16);
// search for strings in the database that might have a similar name (ignore case)
IDataBaseItemEnumerator* pEnum = GetItemEnumerator();
for (IDataBaseItem* pItem = pEnum->GetFirst(); pItem != nullptr; pItem = pEnum->GetNext())
{
//Check if the item is in the target library first.
IDataBaseLibrary* itemLibrary = pItem->GetLibrary();
QString itemLibraryName;
if (itemLibrary)
{
itemLibraryName = itemLibrary->GetName();
}
// Item is not in the library so there cannot be a naming conflict.
if (!libName.isEmpty() && !itemLibraryName.isEmpty() && itemLibraryName != libName)
{
continue;
}
const QString& name = pItem->GetName();
if (name.startsWith(srcName, Qt::CaseInsensitive))
{
possibleDuplicates.push_back(AZStd::string(name.toUtf8().data()));
}
}
pEnum->Release();
if (possibleDuplicates.empty())
{
return srcName;
}
std::sort(possibleDuplicates.begin(), possibleDuplicates.end(), [](const AZStd::string& strOne, const AZStd::string& strTwo)
{
// I can assume size sorting since if the length is different, either one of the two strings doesn't
// closely match the string we are trying to duplicate, or it's a bigger number (X1 vs X10)
if (strOne.size() != strTwo.size())
{
return strOne.size() < strTwo.size();
}
else
{
return azstricmp(strOne.c_str(), strTwo.c_str()) < 0;
}
}
);
int num = 0;
QString returnValue = srcName;
while (num < possibleDuplicates.size() && QString::compare(possibleDuplicates[num].c_str(), returnValue, Qt::CaseInsensitive) == 0)
{
returnValue = QStringLiteral("%1%2%3").arg(srcName).arg("_").arg(num);
++num;
}
return returnValue;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::Validate()
{
IDataBaseItemEnumerator* pEnum = GetItemEnumerator();
for (IDataBaseItem* pItem = pEnum->GetFirst(); pItem != nullptr; pItem = pEnum->GetNext())
{
pItem->Validate();
}
pEnum->Release();
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::RegisterItem(CBaseLibraryItem* pItem, REFGUID newGuid)
{
assert(pItem);
bool bNotify = false;
if (m_bUniqGuidMap)
{
REFGUID oldGuid = pItem->GetGUID();
if (!GuidUtil::IsEmpty(oldGuid))
{
m_itemsGuidMap.erase(oldGuid);
}
if (GuidUtil::IsEmpty(newGuid))
{
return;
}
CBaseLibraryItem* pOldItem = stl::find_in_map(m_itemsGuidMap, newGuid, nullptr);
if (!pOldItem)
{
pItem->m_guid = newGuid;
m_itemsGuidMap[newGuid] = pItem;
pItem->m_bRegistered = true;
bNotify = true;
}
else
{
if (pOldItem != pItem)
{
ReportDuplicateItem(pItem, pOldItem);
}
}
}
if (m_bUniqNameMap)
{
QString fullName = pItem->GetFullName();
if (!pItem->GetName().isEmpty())
{
CBaseLibraryItem* pOldItem = static_cast<CBaseLibraryItem*>(FindItemByName(fullName));
if (!pOldItem)
{
AZStd::lock_guard<AZStd::mutex> lock(m_itemsNameMapMutex);
m_itemsNameMap[fullName] = pItem;
pItem->m_bRegistered = true;
bNotify = true;
}
else
{
if (pOldItem != pItem)
{
ReportDuplicateItem(pItem, pOldItem);
}
}
}
}
// Notify listeners.
if (bNotify)
{
NotifyItemEvent(pItem, EDB_ITEM_EVENT_ADD);
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::RegisterItem(CBaseLibraryItem* pItem)
{
assert(pItem);
bool bNotify = false;
if (m_bUniqGuidMap)
{
if (GuidUtil::IsEmpty(pItem->GetGUID()))
{
return;
}
CBaseLibraryItem* pOldItem = stl::find_in_map(m_itemsGuidMap, pItem->GetGUID(), nullptr);
if (!pOldItem)
{
m_itemsGuidMap[pItem->GetGUID()] = pItem;
pItem->m_bRegistered = true;
bNotify = true;
}
else
{
if (pOldItem != pItem)
{
ReportDuplicateItem(pItem, pOldItem);
}
}
}
if (m_bUniqNameMap)
{
QString fullName = pItem->GetFullName();
if (!fullName.isEmpty())
{
CBaseLibraryItem* pOldItem = static_cast<CBaseLibraryItem*>(FindItemByName(fullName));
if (!pOldItem)
{
AZStd::lock_guard<AZStd::mutex> lock(m_itemsNameMapMutex);
m_itemsNameMap[fullName] = pItem;
pItem->m_bRegistered = true;
bNotify = true;
}
else
{
if (pOldItem != pItem)
{
ReportDuplicateItem(pItem, pOldItem);
}
}
}
}
// Notify listeners.
if (bNotify)
{
NotifyItemEvent(pItem, EDB_ITEM_EVENT_ADD);
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::SetRegisteredFlag(CBaseLibraryItem* pItem, bool bFlag)
{
pItem->m_bRegistered = bFlag;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::ReportDuplicateItem(CBaseLibraryItem* pItem, CBaseLibraryItem* pOldItem)
{
QString sLibName;
if (pOldItem->GetLibrary())
{
sLibName = pOldItem->GetLibrary()->GetName();
}
CErrorRecord err;
err.pItem = pItem;
err.error = QStringLiteral("Item %1 with duplicate GUID to loaded item %2 ignored").arg(pItem->GetFullName(), pOldItem->GetFullName());
GetIEditor()->GetErrorReport()->ReportError(err);
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::UnregisterItem(CBaseLibraryItem* pItem)
{
// Notify listeners.
NotifyItemEvent(pItem, EDB_ITEM_EVENT_DELETE);
if (!pItem)
{
return;
}
if (m_bUniqGuidMap)
{
m_itemsGuidMap.erase(pItem->GetGUID());
}
if (m_bUniqNameMap && !pItem->GetFullName().isEmpty())
{
AZStd::lock_guard<AZStd::mutex> lock(m_itemsNameMapMutex);
auto findIter = m_itemsNameMap.find(pItem->GetFullName());
if (findIter != m_itemsNameMap.end())
{
_smart_ptr<CBaseLibraryItem> item = findIter->second;
m_itemsNameMap.erase(findIter);
}
}
pItem->m_bRegistered = false;
}
//////////////////////////////////////////////////////////////////////////
QString CBaseLibraryManager::MakeFullItemName(IDataBaseLibrary* pLibrary, const QString& group, const QString& itemName)
{
assert(pLibrary);
QString name = pLibrary->GetName() + ".";
if (!group.isEmpty())
{
name += group + ".";
}
name += itemName;
return name;
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::GatherUsedResources(CUsedResources& resources)
{
IDataBaseItemEnumerator* pEnum = GetItemEnumerator();
for (IDataBaseItem* pItem = pEnum->GetFirst(); pItem != nullptr; pItem = pEnum->GetNext())
{
pItem->GatherUsedResources(resources);
}
pEnum->Release();
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItemEnumerator* CBaseLibraryManager::GetItemEnumerator()
{
if (m_bUniqNameMap)
{
return new CDataBaseItemEnumerator<ItemsNameMap>(&m_itemsNameMap);
}
else
{
return new CDataBaseItemEnumerator<ItemsGUIDMap>(&m_itemsGuidMap);
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::OnEditorNotifyEvent(EEditorNotifyEvent event)
{
switch (event)
{
case eNotify_OnBeginNewScene:
SetSelectedItem(nullptr);
ClearAll();
break;
case eNotify_OnBeginSceneOpen:
SetSelectedItem(nullptr);
ClearAll();
break;
case eNotify_OnCloseScene:
SetSelectedItem(nullptr);
ClearAll();
break;
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::OnRenameItem(CBaseLibraryItem* pItem, const QString& oldName)
{
m_itemsNameMapMutex.lock();
if (!oldName.isEmpty())
{
m_itemsNameMap.erase(oldName);
}
if (!pItem->GetFullName().isEmpty())
{
m_itemsNameMap[pItem->GetFullName()] = pItem;
}
m_itemsNameMapMutex.unlock();
OnItemChanged(pItem);
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::AddListener(IDataBaseManagerListener* pListener)
{
stl::push_back_unique(m_listeners, pListener);
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::RemoveListener(IDataBaseManagerListener* pListener)
{
stl::find_and_erase(m_listeners, pListener);
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::NotifyItemEvent(IDataBaseItem* pItem, EDataBaseItemEvent event)
{
// Notify listeners.
if (!m_listeners.empty())
{
for (int i = 0; i < m_listeners.size(); i++)
{
m_listeners[i]->OnDataBaseItemEvent(pItem, event);
}
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::OnItemChanged(IDataBaseItem* pItem)
{
NotifyItemEvent(pItem, EDB_ITEM_EVENT_CHANGED);
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::OnUpdateProperties(IDataBaseItem* pItem, bool bRefresh)
{
NotifyItemEvent(pItem, bRefresh ? EDB_ITEM_EVENT_UPDATE_PROPERTIES
: EDB_ITEM_EVENT_UPDATE_PROPERTIES_NO_EDITOR_REFRESH);
}
//////////////////////////////////////////////////////////////////////////
void CBaseLibraryManager::SetSelectedItem(IDataBaseItem* pItem)
{
if (m_pSelectedItem == pItem)
{
return;
}
m_pSelectedItem = (CBaseLibraryItem*)pItem;
NotifyItemEvent(m_pSelectedItem, EDB_ITEM_EVENT_SELECTED);
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibraryManager::GetSelectedItem() const
{
return m_pSelectedItem;
}
//////////////////////////////////////////////////////////////////////////
IDataBaseItem* CBaseLibraryManager::GetSelectedParentItem() const
{
return m_pSelectedParent;
}
void CBaseLibraryManager::ChangeLibraryOrder(IDataBaseLibrary* lib, unsigned int newLocation)
{
if (!lib || newLocation >= m_libs.size() || lib == m_libs[newLocation])
{
return;
}
for (int i = 0; i < m_libs.size(); i++)
{
if (lib == m_libs[i])
{
_smart_ptr<CBaseLibrary> curLib = m_libs[i];
m_libs.erase(m_libs.begin() + i);
m_libs.insert(m_libs.begin() + newLocation, curLib);
return;
}
}
}
bool CBaseLibraryManager::SetLibraryName(CBaseLibrary* lib, const QString& name)
{
// SetFilename will validate if the name is duplicate with exist libraries.
if (lib->SetFilename(MakeFilename(name)))
{
lib->SetName(name);
return true;
}
return false;
}

@ -1,226 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_BASELIBRARYMANAGER_H
#define CRYINCLUDE_EDITOR_BASELIBRARYMANAGER_H
#pragma once
#include "Include/IBaseLibraryManager.h"
#include "Include/IDataBaseItem.h"
#include "Include/IDataBaseLibrary.h"
#include "Include/IDataBaseManager.h"
#include "Util/TRefCountBase.h"
#include "Util/GuidUtil.h"
#include "BaseLibrary.h"
#include "Util/smartptr.h"
#include <EditorDefs.h>
#include <QtUtil.h>
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
/** Manages all Libraries and Items.
*/
class SANDBOX_API CBaseLibraryManager
: public IBaseLibraryManager
{
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
public:
CBaseLibraryManager();
~CBaseLibraryManager();
//! Clear all libraries.
void ClearAll() override;
//////////////////////////////////////////////////////////////////////////
// IDocListener implementation.
//////////////////////////////////////////////////////////////////////////
void OnEditorNotifyEvent(EEditorNotifyEvent event) override;
//////////////////////////////////////////////////////////////////////////
// Library items.
//////////////////////////////////////////////////////////////////////////
//! Make a new item in specified library.
IDataBaseItem* CreateItem(IDataBaseLibrary* pLibrary) override;
//! Delete item from library and manager.
void DeleteItem(IDataBaseItem* pItem) override;
//! Find Item by its GUID.
IDataBaseItem* FindItem(REFGUID guid) const override;
IDataBaseItem* FindItemByName(const QString& fullItemName) override;
IDataBaseItem* LoadItemByName(const QString& fullItemName) override;
virtual IDataBaseItem* FindItemByName(const char* fullItemName);
virtual IDataBaseItem* LoadItemByName(const char* fullItemName);
IDataBaseItemEnumerator* GetItemEnumerator() override;
//////////////////////////////////////////////////////////////////////////
// Set item currently selected.
void SetSelectedItem(IDataBaseItem* pItem) override;
// Get currently selected item.
IDataBaseItem* GetSelectedItem() const override;
IDataBaseItem* GetSelectedParentItem() const override;
//////////////////////////////////////////////////////////////////////////
// Libraries.
//////////////////////////////////////////////////////////////////////////
//! Add Item library.
IDataBaseLibrary* AddLibrary(const QString& library, bool bIsLevelLibrary = false, bool bIsLoading = true) override;
void DeleteLibrary(const QString& library, bool forceDeleteLevel = false) override;
//! Get number of libraries.
int GetLibraryCount() const override { return static_cast<int>(m_libs.size()); };
//! Get number of modified libraries.
int GetModifiedLibraryCount() const override;
//! Get Item library by index.
IDataBaseLibrary* GetLibrary(int index) const override;
//! Get Level Item library.
IDataBaseLibrary* GetLevelLibrary() const override;
//! Find Items Library by name.
IDataBaseLibrary* FindLibrary(const QString& library) override;
//! Find Items Library's index by name.
int FindLibraryIndex(const QString& library) override;
//! Load Items library.
IDataBaseLibrary* LoadLibrary(const QString& filename, bool bReload = false) override;
//! Save all modified libraries.
void SaveAllLibs() override;
//! Serialize property manager.
void Serialize(XmlNodeRef& node, bool bLoading) override;
//! Export items to game.
void Export([[maybe_unused]] XmlNodeRef& node) override {};
//! Returns unique name base on input name.
QString MakeUniqueItemName(const QString& name, const QString& libName = "") override;
QString MakeFullItemName(IDataBaseLibrary* pLibrary, const QString& group, const QString& itemName) override;
//! Root node where this library will be saved.
QString GetRootNodeName() override = 0;
//! Path to libraries in this manager.
QString GetLibsPath() override = 0;
//////////////////////////////////////////////////////////////////////////
//! Validate library items for errors.
void Validate() override;
//////////////////////////////////////////////////////////////////////////
void GatherUsedResources(CUsedResources& resources) override;
void AddListener(IDataBaseManagerListener* pListener) override;
void RemoveListener(IDataBaseManagerListener* pListener) override;
//////////////////////////////////////////////////////////////////////////
void RegisterItem(CBaseLibraryItem* pItem, REFGUID newGuid) override;
void RegisterItem(CBaseLibraryItem* pItem) override;
void UnregisterItem(CBaseLibraryItem* pItem) override;
// Only Used internally.
void OnRenameItem(CBaseLibraryItem* pItem, const QString& oldName) override;
// Called by items to indicated that they have been modified.
// Sends item changed event to listeners.
void OnItemChanged(IDataBaseItem* pItem) override;
void OnUpdateProperties(IDataBaseItem* pItem, bool bRefresh) override;
QString MakeFilename(const QString& library);
bool IsUniqueFilename(const QString& library) override;
//CONFETTI BEGIN
// Used to change the library item order
void ChangeLibraryOrder(IDataBaseLibrary* lib, unsigned int newLocation) override;
bool SetLibraryName(CBaseLibrary* lib, const QString& name) override;
protected:
void SplitFullItemName(const QString& fullItemName, QString& libraryName, QString& itemName);
void NotifyItemEvent(IDataBaseItem* pItem, EDataBaseItemEvent event);
void SetRegisteredFlag(CBaseLibraryItem* pItem, bool bFlag);
//////////////////////////////////////////////////////////////////////////
// Must be overriden.
//! Makes a new Item.
virtual CBaseLibraryItem* MakeNewItem() = 0;
virtual CBaseLibrary* MakeNewLibrary() = 0;
//////////////////////////////////////////////////////////////////////////
virtual void ReportDuplicateItem(CBaseLibraryItem* pItem, CBaseLibraryItem* pOldItem);
protected:
bool m_bUniqGuidMap;
bool m_bUniqNameMap;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
//! Array of all loaded entity items libraries.
std::vector<_smart_ptr<CBaseLibrary> > m_libs;
// There is always one current level library.
TSmartPtr<CBaseLibrary> m_pLevelLibrary;
// GUID to item map.
typedef std::map<GUID, _smart_ptr<CBaseLibraryItem>, guid_less_predicate> ItemsGUIDMap;
ItemsGUIDMap m_itemsGuidMap;
// Case insensitive name to items map.
typedef std::map<QString, _smart_ptr<CBaseLibraryItem>, stl::less_stricmp<QString>> ItemsNameMap;
ItemsNameMap m_itemsNameMap;
AZStd::mutex m_itemsNameMapMutex;
std::vector<IDataBaseManagerListener*> m_listeners;
// Currently selected item.
_smart_ptr<CBaseLibraryItem> m_pSelectedItem;
_smart_ptr<CBaseLibraryItem> m_pSelectedParent;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
//////////////////////////////////////////////////////////////////////////
template <class TMap>
class CDataBaseItemEnumerator
: public IDataBaseItemEnumerator
{
TMap* m_pMap;
typename TMap::iterator m_iterator;
public:
CDataBaseItemEnumerator(TMap* pMap)
{
assert(pMap);
m_pMap = pMap;
m_iterator = m_pMap->begin();
}
void Release() override { delete this; };
IDataBaseItem* GetFirst() override
{
m_iterator = m_pMap->begin();
if (m_iterator == m_pMap->end())
{
return 0;
}
return m_iterator->second;
}
IDataBaseItem* GetNext() override
{
if (m_iterator != m_pMap->end())
{
m_iterator++;
}
if (m_iterator == m_pMap->end())
{
return 0;
}
return m_iterator->second;
}
};
#endif // CRYINCLUDE_EDITOR_BASELIBRARYMANAGER_H

@ -7,7 +7,6 @@
*/
#include "EditorDefs.h"
#include "ErrorRecorder.h"
#include "BaseLibraryItem.h"
#include "Include/IErrorReport.h"

@ -14,6 +14,8 @@
#define CRYINCLUDE_EDITOR_CORE_ERRORRECORDER_H
#pragma once
#include "Include/EditorCoreAPI.h"
//////////////////////////////////////////////////////////////////////////
//! Automatic class to record and display error.
class EDITOR_CORE_API CErrorsRecorder

@ -67,24 +67,6 @@ QString CErrorRecord::GetErrorText() const
{
str += QString("\t ");
}
if (pItem)
{
switch (pItem->GetType())
{
case EDB_TYPE_MATERIAL:
str += QString("\t Material=\"");
break;
case EDB_TYPE_PARTICLE:
str += QString("\t Particle=\"");
break;
case EDB_TYPE_MUSIC:
str += QString("\t Music=\"");
break;
default:
str += QString("\t Item=\"");
}
str += pItem->GetFullName() + "\"";
}
if (pObject)
{
str += QString("\t Object=\"") + pObject->GetName() + "\"";
@ -101,7 +83,6 @@ CErrorReport::CErrorReport()
m_bImmediateMode = true;
m_bShowErrors = true;
m_pObject = nullptr;
m_pItem = nullptr;
m_pParticle = nullptr;
}
@ -140,10 +121,6 @@ void CErrorReport::ReportError(CErrorRecord& err)
{
err.pObject = m_pObject;
}
else if (err.pItem == nullptr && m_pItem != nullptr)
{
err.pItem = m_pItem;
}
m_errors.push_back(err);
}
bNoRecurse = false;
@ -255,12 +232,6 @@ void CErrorReport::SetCurrentValidatorObject(CBaseObject* pObject)
m_pObject = pObject;
}
//////////////////////////////////////////////////////////////////////////
void CErrorReport::SetCurrentValidatorItem(CBaseLibraryItem* pItem)
{
m_pItem = pItem;
}
//////////////////////////////////////////////////////////////////////////
void CErrorReport::SetCurrentFile(const QString& file)
{

@ -17,7 +17,6 @@
// forward declarations.
class CParticleItem;
#include "BaseLibraryItem.h"
#include "Objects/BaseObject.h"
#include "Include/IErrorReport.h"
#include "ErrorRecorder.h"
@ -56,16 +55,13 @@ public:
int count;
//! Object that caused this error.
_smart_ptr<CBaseObject> pObject;
//! Library Item that caused this error.
_smart_ptr<CBaseLibraryItem> pItem;
int flags;
CErrorRecord(CBaseObject* object, ESeverity _severity, const QString& _error, int _flags = 0, int _count = 0,
CBaseLibraryItem* item = 0, EValidatorModule _module = VALIDATOR_MODULE_EDITOR)
EValidatorModule _module = VALIDATOR_MODULE_EDITOR)
: severity(_severity)
, module(_module)
, pObject(object)
, pItem(item)
, flags(_flags)
, count(_count)
, error(_error)
@ -77,7 +73,6 @@ public:
severity = ESEVERITY_WARNING;
module = VALIDATOR_MODULE_EDITOR;
pObject = 0;
pItem = 0;
flags = 0;
count = 0;
}
@ -116,8 +111,6 @@ public:
//! Assign current Object to which new reported warnings are assigned.
void SetCurrentValidatorObject(CBaseObject* pObject);
//! Assign current Item to which new reported warnings are assigned.
void SetCurrentValidatorItem(CBaseLibraryItem* pItem);
//! Assign current filename.
void SetCurrentFile(const QString& file);
@ -127,7 +120,6 @@ private:
bool m_bImmediateMode;
bool m_bShowErrors;
_smart_ptr<CBaseObject> m_pObject;
_smart_ptr<CBaseLibraryItem> m_pItem;
CParticleItem* m_pParticle;
QString m_currentFilename;
};

@ -362,10 +362,6 @@ void CErrorReportDialog::CopyToClipboard()
{
str += QString::fromLatin1(" [Object: %1]").arg(pRecord->pObject->GetName());
}
if (pRecord->pItem)
{
str += QString::fromLatin1(" [Material: %1]").arg(pRecord->pItem->GetName());
}
str += QString::fromLatin1("\r\n");
}
}

@ -149,11 +149,7 @@ QVariant CErrorReportTableModel::data(const CErrorRecord& record, int column, in
case ColumnFile:
return record.file;
case ColumnObject:
if (record.pItem)
{
return record.pItem->GetFullName();
}
else if (record.pObject)
if (record.pObject)
{
return record.pObject->GetName();
}

@ -44,7 +44,6 @@ class CMusicManager;
struct IEditorParticleManager;
class CEAXPresetManager;
class CErrorReport;
class CBaseLibraryItem;
class ICommandManager;
class CEditorCommandManager;
class CHyperGraphManager;
@ -52,9 +51,7 @@ class CConsoleSynchronization;
class CUIEnumsDatabase;
struct ISourceControl;
struct IEditorClassFactory;
struct IDataBaseItem;
struct ITransformManipulator;
struct IDataBaseManager;
class IFacialEditor;
class CDialog;
#if defined(AZ_PLATFORM_WINDOWS)
@ -82,8 +79,6 @@ struct IEventLoopHook;
struct IErrorReport; // Vladimir@conffx
struct IFileUtil; // Vladimir@conffx
struct IEditorLog; // Vladimir@conffx
struct IEditorMaterialManager; // Vladimir@conffx
struct IBaseLibraryManager; // Vladimir@conffx
struct IImageUtil; // Vladimir@conffx
struct IEditorParticleUtils; // Leroy@conffx
struct ILogFile; // Vladimir@conffx
@ -519,10 +514,6 @@ struct IEditor
//! Get access to object manager.
virtual struct IObjectManager* GetObjectManager() = 0;
virtual CSettingsManager* GetSettingsManager() = 0;
//! Get DB manager that own items of specified type.
virtual IDataBaseManager* GetDBItemManager(EDataBaseItemType itemType) = 0;
virtual IBaseLibraryManager* GetMaterialManagerLibrary() = 0; // Vladimir@conffx
virtual IEditorMaterialManager* GetIEditorMaterialManager() = 0; // Vladimir@Conffx
//! Returns IconManager.
virtual IIconManager* GetIconManager() = 0;
//! Get Music Manager.

@ -892,11 +892,6 @@ void CEditorImpl::CloseView(const GUID& classId)
}
}
IDataBaseManager* CEditorImpl::GetDBItemManager([[maybe_unused]] EDataBaseItemType itemType)
{
return nullptr;
}
bool CEditorImpl::SelectColor(QColor& color, QWidget* parent)
{
const AZ::Color c = AzQtComponents::fromQColor(color);
@ -1624,18 +1619,6 @@ SEditorSettings* CEditorImpl::GetEditorSettings()
return &gSettings;
}
// Vladimir@Conffx
IBaseLibraryManager* CEditorImpl::GetMaterialManagerLibrary()
{
return nullptr;
}
// Vladimir@Conffx
IEditorMaterialManager* CEditorImpl::GetIEditorMaterialManager()
{
return nullptr;
}
IImageUtil* CEditorImpl::GetImageUtil()
{
return m_pImageUtil;

@ -157,7 +157,6 @@ public:
void LockSelection(bool bLock) override;
bool IsSelectionLocked() override;
IDataBaseManager* GetDBItemManager(EDataBaseItemType itemType) override;
CMusicManager* GetMusicManager() override { return m_pMusicManager; };
IEditorFileMonitor* GetFileMonitor() override;
@ -294,8 +293,6 @@ public:
void RegisterObjectContextMenuExtension(TContextMenuExtensionFunc func) override;
SSystemGlobalEnvironment* GetEnv() override;
IBaseLibraryManager* GetMaterialManagerLibrary() override; // Vladimir@Conffx
IEditorMaterialManager* GetIEditorMaterialManager() override; // Vladimir@Conffx
IImageUtil* GetImageUtil() override; // Vladimir@conffx
SEditorSettings* GetEditorSettings() override;
ILogFile* GetLogFile() override { return m_pLogFile; }

@ -1,143 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IBASELIBRARYMANAGER_H
#define CRYINCLUDE_EDITOR_INCLUDE_IBASELIBRARYMANAGER_H
#pragma once
#include <IEditor.h>
#include "Include/IDataBaseItem.h"
#include "Include/IDataBaseLibrary.h"
#include "Include/IDataBaseManager.h"
#include "Util/TRefCountBase.h"
class CBaseLibraryItem;
class CBaseLibrary;
struct IBaseLibraryManager
: public TRefCountBase<IDataBaseManager>
, public IEditorNotifyListener
{
//! Clear all libraries.
virtual void ClearAll() = 0;
//////////////////////////////////////////////////////////////////////////
// IDocListener implementation.
//////////////////////////////////////////////////////////////////////////
virtual void OnEditorNotifyEvent(EEditorNotifyEvent event) = 0;
//////////////////////////////////////////////////////////////////////////
// Library items.
//////////////////////////////////////////////////////////////////////////
//! Make a new item in specified library.
virtual IDataBaseItem* CreateItem(IDataBaseLibrary* pLibrary) = 0;
//! Delete item from library and manager.
virtual void DeleteItem(IDataBaseItem* pItem) = 0;
//! Find Item by its GUID.
virtual IDataBaseItem* FindItem(REFGUID guid) const = 0;
virtual IDataBaseItem* FindItemByName(const QString& fullItemName) = 0;
virtual IDataBaseItem* LoadItemByName(const QString& fullItemName) = 0;
virtual IDataBaseItemEnumerator* GetItemEnumerator() = 0;
//////////////////////////////////////////////////////////////////////////
// Set item currently selected.
virtual void SetSelectedItem(IDataBaseItem* pItem) = 0;
// Get currently selected item.
virtual IDataBaseItem* GetSelectedItem() const = 0;
virtual IDataBaseItem* GetSelectedParentItem() const = 0;
//////////////////////////////////////////////////////////////////////////
// Libraries.
//////////////////////////////////////////////////////////////////////////
//! Add Item library.
virtual IDataBaseLibrary* AddLibrary(const QString& library, bool isLevelLibrary = false, bool bIsLoading = true) = 0;
virtual void DeleteLibrary(const QString& library, bool forceDeleteLevel = false) = 0;
//! Get number of libraries.
virtual int GetLibraryCount() const = 0;
//! Get number of modified libraries.
virtual int GetModifiedLibraryCount() const = 0;
//! Get Item library by index.
virtual IDataBaseLibrary* GetLibrary(int index) const = 0;
//! Get Level Item library.
virtual IDataBaseLibrary* GetLevelLibrary() const = 0;
//! Find Items Library by name.
virtual IDataBaseLibrary* FindLibrary(const QString& library) = 0;
//! Find the Library's index by name.
virtual int FindLibraryIndex(const QString& library) = 0;
//! Load Items library.
#ifdef LoadLibrary
#undef LoadLibrary
#endif
virtual IDataBaseLibrary* LoadLibrary(const QString& filename, bool bReload = false) = 0;
//! Save all modified libraries.
virtual void SaveAllLibs() = 0;
//! Serialize property manager.
virtual void Serialize(XmlNodeRef& node, bool bLoading) = 0;
//! Export items to game.
virtual void Export(XmlNodeRef& node) = 0;
//! Returns unique name base on input name.
// Vera@conffx, add LibName parameter so we could make an unique name depends on input library.
// Arguments:
// - name: name of the item
// - libName: The library of the item. Given the library name, the function will return a unique name in the library
// Default value "": The function will ignore the library name and return a unique name in the manager
virtual QString MakeUniqueItemName(const QString& name, const QString& libName = "") = 0;
virtual QString MakeFullItemName(IDataBaseLibrary* pLibrary, const QString& group, const QString& itemName) = 0;
//! Root node where this library will be saved.
virtual QString GetRootNodeName() = 0;
//! Path to libraries in this manager.
virtual QString GetLibsPath() = 0;
//////////////////////////////////////////////////////////////////////////
//! Validate library items for errors.
virtual void Validate() = 0;
//////////////////////////////////////////////////////////////////////////
virtual void GatherUsedResources(CUsedResources& resources) = 0;
virtual void AddListener(IDataBaseManagerListener* pListener) = 0;
virtual void RemoveListener(IDataBaseManagerListener* pListener) = 0;
//////////////////////////////////////////////////////////////////////////
virtual void RegisterItem(CBaseLibraryItem* pItem, REFGUID newGuid) = 0;
virtual void RegisterItem(CBaseLibraryItem* pItem) = 0;
virtual void UnregisterItem(CBaseLibraryItem* pItem) = 0;
// Only Used internally.
virtual void OnRenameItem(CBaseLibraryItem* pItem, const QString& oldName) = 0;
// Called by items to indicated that they have been modified.
// Sends item changed event to listeners.
virtual void OnItemChanged(IDataBaseItem* pItem) = 0;
virtual void OnUpdateProperties(IDataBaseItem* pItem, bool bRefresh) = 0;
//CONFETTI BEGIN
// Used to change the library item order
virtual void ChangeLibraryOrder(IDataBaseLibrary* lib, unsigned int newLocation) = 0;
// simplifies the library renaming process
virtual bool SetLibraryName(CBaseLibrary* lib, const QString& name) = 0;
//Check if the file name is unique.
//Params: library: library name. NOT the file path.
virtual bool IsUniqueFilename(const QString& library) = 0;
//CONFETTI END
};
#endif // CRYINCLUDE_EDITOR_INCLUDE_IBASELIBRARYMANAGER_H

@ -1,92 +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_INCLUDE_IDATABASEITEM_H
#define CRYINCLUDE_EDITOR_INCLUDE_IDATABASEITEM_H
#pragma once
#include <qwindowdefs.h>
#include <IEditor.h>
struct IDataBaseLibrary;
class CUsedResources;
//////////////////////////////////////////////////////////////////////////
/** Base class for all items contained in BaseLibraray.
*/
struct IDataBaseItem
{
struct SerializeContext
{
XmlNodeRef node;
bool bUndo;
bool bLoading;
bool bCopyPaste;
bool bIgnoreChilds;
bool bUniqName;
SerializeContext()
: node(0)
, bLoading(false)
, bCopyPaste(false)
, bIgnoreChilds(false)
, bUniqName(false)
, bUndo(false) {};
SerializeContext(XmlNodeRef _node, bool bLoad)
: node(_node)
, bLoading(bLoad)
, bCopyPaste(false)
, bIgnoreChilds(false)
, bUniqName(false)
, bUndo(false) {};
SerializeContext(const SerializeContext& ctx)
: node(ctx.node)
, bLoading(ctx.bLoading)
, bCopyPaste(ctx.bCopyPaste)
, bIgnoreChilds(ctx.bIgnoreChilds)
, bUniqName(ctx.bUniqName)
, bUndo(ctx.bUndo) {};
};
virtual EDataBaseItemType GetType() const = 0;
//! Return Library this item are contained in.
//! Item can only be at one library.
virtual IDataBaseLibrary* GetLibrary() const = 0;
//! Change item name.
virtual void SetName(const QString& name) = 0;
//! Get item name.
virtual const QString& GetName() const = 0;
//! Get full item name, including name of library.
//! Name formed by adding dot after name of library
//! eg. library Pickup and item PickupRL form full item name: "Pickups.PickupRL".
virtual QString GetFullName() const = 0;
//! Get only nameof group from prototype.
virtual QString GetGroupName() = 0;
//! Get short name of prototype without group.
virtual QString GetShortName() = 0;
//! Serialize library item to archive.
virtual void Serialize(SerializeContext& ctx) = 0;
//! Generate new unique id for this item.
virtual void GenerateId() = 0;
//! Returns GUID of this material.
virtual const GUID& GetGUID() const = 0;
//! Validate item for errors.
virtual void Validate() {};
//! Gathers resources by this item.
virtual void GatherUsedResources([[maybe_unused]] CUsedResources& resources) {};
};
#endif // CRYINCLUDE_EDITOR_INCLUDE_IDATABASEITEM_H

@ -1,118 +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_INCLUDE_IDATABASELIBRARY_H
#define CRYINCLUDE_EDITOR_INCLUDE_IDATABASELIBRARY_H
#pragma once
struct IDataBaseManager;
struct IDataBaseItem;
class QString;
class XmlNodeRef;
//////////////////////////////////////////////////////////////////////////
// Description:
// Interface to access specific library of editor data base.
// Ex. Archetype library, Material Library.
// See Also:
// IDataBaseItem,IDataBaseManager
//////////////////////////////////////////////////////////////////////////
struct IDataBaseLibrary
{
// Description:
// Return IDataBaseManager interface to the manager for items stored in this library.
virtual IDataBaseManager* GetManager() = 0;
// Description:
// Return library name.
virtual const QString& GetName() const = 0;
// Description:
// Return filename where this library is stored.
virtual const QString& GetFilename() const = 0;
// Description:
// Save contents of library to file.
virtual bool Save() = 0;
// Description:
// Load library from file.
// Arguments:
// filename - Full specified library filename (relative to root game folder).
virtual bool Load(const QString& filename) = 0;
// Description:
// Serialize library parameters and items to/from XML node.
virtual void Serialize(XmlNodeRef& node, bool bLoading) = 0;
// Description:
// Marks library as modified, indicates that some item in library was modified.
virtual void SetModified(bool bModified = true) = 0;
// Description:
// Check if library parameters or any items where modified.
// If any item was modified library may need saving before closing editor.
virtual bool IsModified() const = 0;
// Description:
// Check if this library is not shared and internal to current level.
virtual bool IsLevelLibrary() const = 0;
// Description:
// Make this library accessible only from current Level. (not shared)
virtual void SetLevelLibrary(bool bEnable) = 0;
// Description:
// Associate a new item with the library.
// Watch out if item was already in another library.
virtual void AddItem(IDataBaseItem* pItem, bool bRegister = true) = 0;
// Description:
// Return number of items in library.
virtual int GetItemCount() const = 0;
// Description:
// Get item by index.
// See Also:
// GetItemCount
// Arguments:
// index - Index from 0 to GetItemCount()
virtual IDataBaseItem* GetItem(int index) = 0;
// Description:
// Remove item from library, does not destroy item,
// only unliks it from this library, to delete item use IDataBaseManager.
// See Also:
// AddItem
virtual void RemoveItem(IDataBaseItem* item) = 0;
// Description:
// Remove all items from library, does not destroy items,
// only unliks them from this library, to delete item use IDataBaseManager.
// See Also:
// RemoveItem,AddItem
virtual void RemoveAllItems() = 0;
// Description:
// Find item in library by name.
// This function usually uses linear search so it is not particularry fast.
// See Also:
// GetItem
virtual IDataBaseItem* FindItem(const QString& name) = 0;
//CONFETTI BEGIN
// Used to change the library item order
virtual void ChangeItemOrder(CBaseLibraryItem* item, unsigned int newLocation) = 0;
//CONFETTI END
};
#endif // CRYINCLUDE_EDITOR_INCLUDE_IDATABASELIBRARY_H

@ -1,134 +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_INCLUDE_IDATABASEMANAGER_H
#define CRYINCLUDE_EDITOR_INCLUDE_IDATABASEMANAGER_H
#pragma once
#include <QString>
struct IDataBaseItem;
struct IDataBaseLibrary;
class CUsedResources;
enum EDataBaseItemEvent
{
EDB_ITEM_EVENT_ADD,
EDB_ITEM_EVENT_DELETE,
EDB_ITEM_EVENT_CHANGED,
EDB_ITEM_EVENT_SELECTED,
EDB_ITEM_EVENT_UPDATE_PROPERTIES,
EDB_ITEM_EVENT_UPDATE_PROPERTIES_NO_EDITOR_REFRESH
};
//////////////////////////////////////////////////////////////////////////
// Description:
// Callback class to intercept item creation and deletion events.
//////////////////////////////////////////////////////////////////////////
struct IDataBaseManagerListener
{
virtual void OnDataBaseItemEvent(IDataBaseItem* pItem, EDataBaseItemEvent event) = 0;
};
//////////////////////////////////////////////////////////////////////////
// Description:
// his interface is used to enumerate al items registered to the database manager.
//////////////////////////////////////////////////////////////////////////
struct IDataBaseItemEnumerator
{
virtual ~IDataBaseItemEnumerator() = default;
virtual void Release() = 0;
virtual IDataBaseItem* GetFirst() = 0;
virtual IDataBaseItem* GetNext() = 0;
};
//////////////////////////////////////////////////////////////////////////
//
// Interface to the collection of all items or specific type
// in data base libraries.
//
//////////////////////////////////////////////////////////////////////////
struct IDataBaseManager
{
//! Clear all libraries.
virtual void ClearAll() = 0;
//////////////////////////////////////////////////////////////////////////
// Library items.
//////////////////////////////////////////////////////////////////////////
//! Make a new item in specified library.
virtual IDataBaseItem* CreateItem(IDataBaseLibrary* pLibrary) = 0;
//! Delete item from library and manager.
virtual void DeleteItem(IDataBaseItem* pItem) = 0;
//! Find Item by its GUID.
virtual IDataBaseItem* FindItem(REFGUID guid) const = 0;
virtual IDataBaseItem* FindItemByName(const QString& fullItemName) = 0;
virtual IDataBaseItemEnumerator* GetItemEnumerator() = 0;
// Select one item in DB.
virtual void SetSelectedItem(IDataBaseItem* pItem) = 0;
//////////////////////////////////////////////////////////////////////////
// Libraries.
//////////////////////////////////////////////////////////////////////////
//! Add Item library. Set isLevelLibrary to true if its the "level" library which gets saved inside the level
virtual IDataBaseLibrary* AddLibrary(const QString& library, bool isLevelLibrary = false, bool bIsLoading = true) = 0;
virtual void DeleteLibrary(const QString& library, bool forceDeleteLibrary = false) = 0;
//! Get number of libraries.
virtual int GetLibraryCount() const = 0;
//! Get Item library by index.
virtual IDataBaseLibrary* GetLibrary(int index) const = 0;
//! Find Items Library by name.
virtual IDataBaseLibrary* FindLibrary(const QString& library) = 0;
//! Load Items library.
#ifdef LoadLibrary
#undef LoadLibrary
#endif
virtual IDataBaseLibrary* LoadLibrary(const QString& filename, bool bReload = false) = 0;
//! Save all modified libraries.
virtual void SaveAllLibs() = 0;
//! Serialize property manager.
virtual void Serialize(XmlNodeRef& node, bool bLoading) = 0;
//! Export items to game.
virtual void Export([[maybe_unused]] XmlNodeRef& node) {};
//! Returns unique name base on input name.
virtual QString MakeUniqueItemName(const QString& name, const QString& libName = "") = 0;
virtual QString MakeFullItemName(IDataBaseLibrary* pLibrary, const QString& group, const QString& itemName) = 0;
//! Root node where this library will be saved.
virtual QString GetRootNodeName() = 0;
//! Path to libraries in this manager.
virtual QString GetLibsPath() = 0;
//////////////////////////////////////////////////////////////////////////
//! Validate library items for errors.
virtual void Validate() = 0;
// Description:
// Collects names of all resource files used by managed items.
// Arguments:
// resources - Structure where all filenames are collected.
virtual void GatherUsedResources(CUsedResources& resources) = 0;
//////////////////////////////////////////////////////////////////////////
// Register listeners.
virtual void AddListener(IDataBaseManagerListener* pListener) = 0;
virtual void RemoveListener(IDataBaseManagerListener* pListener) = 0;
};
#endif // CRYINCLUDE_EDITOR_INCLUDE_IDATABASEMANAGER_H

@ -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
*
*/
#pragma once
#include "BaseLibraryItem.h"
#include <IMaterial.h>
struct IEditorMaterial
: public CBaseLibraryItem
{
virtual int GetFlags() const = 0;
virtual IMaterial* GetMatInfo(bool bUseExistingEngineMaterial = false) = 0;
virtual void DisableHighlightForFrame() = 0;
};

@ -1,21 +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_MATERIAL_IEDITORMATERIALMANAGER_H
#define CRYINCLUDE_EDITOR_MATERIAL_IEDITORMATERIALMANAGER_H
#pragma once
#include <Include/IBaseLibraryManager.h>
#include <IMaterial.h>
struct IEditorMaterialManager
{
virtual void GotoMaterial(IMaterial* pMaterial) = 0;
};
#endif // CRYINCLUDE_EDITOR_MATERIAL_MATERIALMANAGER_H

@ -14,7 +14,6 @@
// forward declarations.
class CParticleItem;
class CBaseObject;
class CBaseLibraryItem;
class CErrorRecord;
class QString;
@ -52,9 +51,6 @@ struct IErrorReport
//! Assign current Object to which new reported warnings are assigned.
virtual void SetCurrentValidatorObject(CBaseObject* pObject) = 0;
//! Assign current Item to which new reported warnings are assigned.
virtual void SetCurrentValidatorItem(CBaseLibraryItem* pItem) = 0;
//! Assign current filename.
virtual void SetCurrentFile(const QString& file) = 0;
};

@ -85,9 +85,6 @@ public:
MOCK_METHOD0(IsSelectionLocked, bool());
MOCK_METHOD0(GetObjectManager, struct IObjectManager* ());
MOCK_METHOD0(GetSettingsManager, CSettingsManager* ());
MOCK_METHOD1(GetDBItemManager, IDataBaseManager* (EDataBaseItemType));
MOCK_METHOD0(GetMaterialManagerLibrary, IBaseLibraryManager* ());
MOCK_METHOD0(GetIEditorMaterialManager, IEditorMaterialManager* ());
MOCK_METHOD0(GetIconManager, IIconManager* ());
MOCK_METHOD0(GetMusicManager, CMusicManager* ());
MOCK_METHOD2(GetTerrainElevation, float(float , float ));

@ -408,20 +408,6 @@ void CTrackViewSequenceManager::OnSequenceRemoved(CTrackViewSequence* sequence)
}
}
////////////////////////////////////////////////////////////////////////////
void CTrackViewSequenceManager::OnDataBaseItemEvent([[maybe_unused]] IDataBaseItem* pItem, EDataBaseItemEvent event)
{
if (event != EDataBaseItemEvent::EDB_ITEM_EVENT_ADD)
{
const size_t numSequences = m_sequences.size();
for (size_t i = 0; i < numSequences; ++i)
{
m_sequences[i]->UpdateDynamicParams();
}
}
}
////////////////////////////////////////////////////////////////////////////
CTrackViewAnimNodeBundle CTrackViewSequenceManager::GetAllRelatedAnimNodes(const AZ::EntityId entityId) const
{

@ -13,13 +13,11 @@
#include "TrackViewSequence.h"
#include "IDataBaseManager.h"
#include <AzCore/Component/EntityBus.h>
class CTrackViewSequenceManager
: public IEditorNotifyListener
, public IDataBaseManagerListener
, public ITrackViewSequenceManager
, public AZ::EntitySystemBus::Handler
{
@ -65,8 +63,6 @@ private:
void OnSequenceAdded(CTrackViewSequence* pSequence);
void OnSequenceRemoved(CTrackViewSequence* pSequence);
void OnDataBaseItemEvent(IDataBaseItem* pItem, EDataBaseItemEvent event) override;
// AZ::EntitySystemBus
void OnEntityNameChanged(const AZ::EntityId& entityId, const AZStd::string& name) override;
void OnEntityDestruction(const AZ::EntityId& entityId) override;

@ -46,7 +46,6 @@ struct HitContext;
struct IRenderListener;
class CImageEx;
class QMenu;
struct IDataBaseItem;
/** Type of viewport.
*/
@ -230,8 +229,6 @@ public:
// Drag and drop support on viewports.
// To be overrided in derived classes.
//////////////////////////////////////////////////////////////////////////
virtual bool CanDrop([[maybe_unused]] const QPoint& point, [[maybe_unused]] IDataBaseItem* pItem) { return false; };
virtual void Drop([[maybe_unused]] const QPoint& point, [[maybe_unused]] IDataBaseItem* pItem) {};
virtual void SetGlobalDropCallback(DropCallback dropCallback, void* dropCallbackCustom)
{
m_dropCallback = dropCallback;

@ -7,17 +7,12 @@
#
set(FILES
BaseLibrary.h
BaseLibraryItem.h
UsedResources.h
UIEnumsDatabase.h
Include/EditorCoreAPI.cpp
Include/IErrorReport.h
Include/IBaseLibraryManager.h
Include/IFileUtil.h
Include/EditorCoreAPI.h
Include/IEditorMaterial.h
Include/IEditorMaterialManager.h
Include/IImageUtil.h
Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.qrc
Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.cpp
@ -35,8 +30,6 @@ set(FILES
Controls/QBitmapPreviewDialogImp.h
Controls/QToolTipWidget.h
Controls/QToolTipWidget.cpp
BaseLibraryItem.cpp
BaseLibrary.cpp
UsedResources.cpp
UIEnumsDatabase.cpp
LyViewPaneNames.h

@ -271,9 +271,6 @@ set(FILES
Include/HitContext.h
Include/ICommandManager.h
Include/IConsoleConnectivity.h
Include/IDataBaseItem.h
Include/IDataBaseLibrary.h
Include/IDataBaseManager.h
Include/IDisplayViewport.h
Include/IEditorClassFactory.h
Include/IEventLoopHook.h
@ -369,9 +366,6 @@ set(FILES
ActionManager.h
ShortcutDispatcher.cpp
ShortcutDispatcher.h
BaseLibraryManager.cpp
BaseLibraryItem.h
BaseLibraryManager.h
CheckOutDialog.cpp
CheckOutDialog.h
CheckOutDialog.ui

Loading…
Cancel
Save