56904d1799
* Generic Cleanup Removals: * Unused cvars,member variables and defines * Windows media center edition support routines * CSystem - removed debug_GetCallStackRaw/GetRootWindowMessageHandler/ UnloadDLL/ShutdownModuleLibraries Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Fix CryMessageBox return values in Windows build Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Remove named selection group and a few smaller unused functionalities Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Remove ObjectManager export functionality + 2 deprecated functions Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Remove object legacy freeze/hide support from ObjectManager Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Remove ObjectManager duplicate name dection, as well as object renaming Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Remove ObjectManager serialization and selection callbacks Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * ObjectManager - remove MoveObjects/HitTestObject/EndEditParams and related members/functions Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Remove a bunch of unused clone related functionality + misc Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * ObjectManager - misc removals Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * ObjectManager - more removals Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Remove unused object selection/retrieval in ObjectManager and LoadObjects in ObjectLoader Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * CBaseObject - remove unused material layers mask support Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * More CBaseObject cleanups. Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * CBaseObject - remove SubObj functions and IMouseCreateCallback Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Remove unused procedural floor management, helper scale and tags. Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * CBaseObject - remove more unused methods. Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Removals in multiple places. CBaseObject - unused `OBJTYPE_DUMMY` flag removed, member `IsSameClass` CObjectArchive removed unused methods/members CObjectManager removed unused `Update` method Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * More removals IDisplayViewport - HitTestLine/GetGridStep/setHitcontext/ GetConstructionPlane Unused Cry_Matrix44 template specializations. Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * O3DE.exe Project-Centric "Open Editor" fix (#5852) * The O3DE.exe Open Editor button now attempts to open the Editor in the build directory of the project being opened. If their is no Editor within the build directory of the Project, it uses the Editor.exe in the current O3DE.exe executable directory if it exists Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Engine .gitignore now ignores the build directory if placed in the AutomatedTesting project Previously it was just ignoring a `[Bb]uild` directory if it was directly within the engine root. This change matches the behavior of the project templates. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Renamed the ProjectUtils GetEditorDirectory function to GetEditorExecutablePath Added a platform specific implementation for retrieving the path to the Editor executable in the GetEditorExectuablePath function. It first attempts to locate the Editor via checking the project build directory for an Editor executable before falling back to checking the binary directory of the currently running O3DE executable. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Correct the MacOS GetEditorExecutablePath to return the Editor path Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Adding missing C++20 std::erase implementations (#5735) There were already implementations for std::erase_if. This adds the counterpart AZStd::erase versions resolves #5734 Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * More removals and refactors `ShowMessage` and `CryMessageBox` return void now Simplify code in `CSystem::WarningV` Remove unused `CryGetTicksPerSec` Remove unused WinBase functionality Replace `nanosleep` call in WinBase with `std::this_thread::sleep_for` Remove unused Win32Wrapper routines Remove unused IFunctorBase.h and IEntityObjectListener.h Fix VectorAndArray.cpp compilation Use QMessageBox instead of CryMessageBox in the editor. Remove empty ArchiveVars platform specific files Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Fix test code. Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Remove an unused function Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * CBaseObject and undo description removals. Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * A bunch of removals * Remove IRenderNode * Remove editor's KDTree * Remove StatObjBus, InstanceStatObjEventBus::ReleaseData is redundant ( same functionality in the only available handler is triggered by `OnCryEditorCloseScene`) * Remove CExportManager::AddStatObj/AddMeshes/AddMesh, IExportManager::ExportSingleStatObj * Remove CIconManager/IIconManager::GetObject * Remove CBaseObject::IntersectRayMesh * Remove IIndexedMesh and related structs. * Unused IUndoObject::GetDescription and all derived implementations. * Unused CUndoBaseLibrary/CUndoBaseLibraryManager * Unused Matrix34_tpl typedefs * Legacy Xml classes cleanup Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Remove unused `Vec3ToVector3D` helper Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * fix - remove unused static variable Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> Co-authored-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
262 lines
6.6 KiB
C++
262 lines
6.6 KiB
C++
/*
|
|
* 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);
|
|
}
|
|
}
|