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>
233 lines
6.3 KiB
C++
233 lines
6.3 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 "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>
|