Removal of CryString and related files/classes
This commit is contained in:
@@ -1,149 +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 "SkeletonHierarchy.h"
|
||||
|
||||
using namespace Skeleton;
|
||||
|
||||
/*
|
||||
|
||||
CHierarchy
|
||||
|
||||
*/
|
||||
|
||||
CHierarchy::CHierarchy()
|
||||
{
|
||||
}
|
||||
|
||||
CHierarchy::~CHierarchy()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
uint32 CHierarchy::AddNode(const char* name, const QuatT& pose, int32 parent)
|
||||
{
|
||||
int32 index = FindNodeIndexByName(name);
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
m_nodes.push_back(SNode());
|
||||
index = int32(m_nodes.size() - 1);
|
||||
}
|
||||
|
||||
m_nodes[index].name = name;
|
||||
m_nodes[index].pose = pose;
|
||||
m_nodes[index].parent = parent;
|
||||
return uint32(index);
|
||||
}
|
||||
|
||||
int32 CHierarchy::FindNodeIndexByName(const char* name) const
|
||||
{
|
||||
uint32 count = uint32(m_nodes.size());
|
||||
for (uint32 i = 0; i < count; ++i)
|
||||
{
|
||||
if (::_stricmp(m_nodes[i].name, name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
const CHierarchy::SNode* CHierarchy::FindNode(const char* name) const
|
||||
{
|
||||
int32 index = FindNodeIndexByName(name);
|
||||
return index < 0 ? nullptr : &m_nodes[index];
|
||||
}
|
||||
|
||||
void CHierarchy::CreateFrom(IDefaultSkeleton* pIDefaultSkeleton)
|
||||
{
|
||||
const uint32 jointCount = pIDefaultSkeleton->GetJointCount();
|
||||
|
||||
m_nodes.clear();
|
||||
m_nodes.reserve(jointCount);
|
||||
for (uint32 i = 0; i < jointCount; ++i)
|
||||
{
|
||||
m_nodes.push_back(SNode());
|
||||
|
||||
m_nodes.back().name = pIDefaultSkeleton->GetJointNameByID(int32(i));
|
||||
m_nodes.back().pose = pIDefaultSkeleton->GetDefaultAbsJointByID(int32(i));
|
||||
|
||||
m_nodes.back().parent = pIDefaultSkeleton->GetJointParentIDByID(int32(i));
|
||||
}
|
||||
|
||||
ValidateReferences();
|
||||
}
|
||||
|
||||
void CHierarchy::ValidateReferences()
|
||||
{
|
||||
uint32 nodeCount = m_nodes.size();
|
||||
if (!nodeCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint32 i = 0; i < nodeCount; ++i)
|
||||
{
|
||||
if (m_nodes[i].parent < nodeCount)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
m_nodes[i].parent = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void CHierarchy::AbsoluteToRelative(const QuatT* pSource, QuatT* pDestination)
|
||||
{
|
||||
uint32 count = uint32(m_nodes.size());
|
||||
std::vector<QuatT> absolutes(count);
|
||||
for (uint32 i = 0; i < count; ++i)
|
||||
{
|
||||
absolutes[i] = pSource[i];
|
||||
}
|
||||
|
||||
for (uint32 i = 0; i < count; ++i)
|
||||
{
|
||||
int32 parent = m_nodes[i].parent;
|
||||
if (parent < 0)
|
||||
{
|
||||
pDestination[i] = absolutes[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
pDestination[i].t = (absolutes[i].t - absolutes[parent].t) * absolutes[parent].q;
|
||||
pDestination[i].q = absolutes[parent].q.GetInverted() * absolutes[i].q;
|
||||
}
|
||||
}
|
||||
|
||||
bool CHierarchy::SerializeTo(XmlNodeRef& node)
|
||||
{
|
||||
XmlNodeRef hierarchy = node->newChild("Hierarchy");
|
||||
|
||||
uint32 nodeCount = uint32(m_nodes.size());
|
||||
std::vector<IXmlNode*> nodes(nodeCount);
|
||||
for (uint32 i = 0; i < nodeCount; ++i)
|
||||
{
|
||||
XmlNodeRef parent = hierarchy;
|
||||
if (m_nodes[i].parent > -1)
|
||||
{
|
||||
parent = nodes[m_nodes[i].parent];
|
||||
}
|
||||
|
||||
nodes[i] = parent->newChild("Node");
|
||||
nodes[i]->setAttr("name", m_nodes[i].name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_ANIMATION_SKELETONHIERARCHY_H
|
||||
#define CRYINCLUDE_EDITOR_ANIMATION_SKELETONHIERARCHY_H
|
||||
#pragma once
|
||||
|
||||
namespace Skeleton {
|
||||
class CHierarchy
|
||||
: public _reference_target_t
|
||||
{
|
||||
public:
|
||||
struct SNode
|
||||
{
|
||||
string name;
|
||||
QuatT pose;
|
||||
|
||||
int32 parent;
|
||||
|
||||
/* TODO: Implement
|
||||
uint32 childrenIndex;
|
||||
uint32 childrenCount;
|
||||
*/
|
||||
};
|
||||
|
||||
public:
|
||||
CHierarchy();
|
||||
~CHierarchy();
|
||||
|
||||
public:
|
||||
uint32 AddNode(const char* name, const QuatT& pose, int32 parent = -1);
|
||||
uint32 GetNodeCount() const { return uint32(m_nodes.size()); }
|
||||
SNode* GetNode(uint32 index) { return &m_nodes[index]; }
|
||||
const SNode* GetNode(uint32 index) const { return &m_nodes[index]; }
|
||||
int32 FindNodeIndexByName(const char* name) const;
|
||||
const SNode* FindNode(const char* name) const;
|
||||
void ClearNodes() { m_nodes.clear(); }
|
||||
|
||||
void CreateFrom(IDefaultSkeleton* rIDefaultSkeleton);
|
||||
void ValidateReferences();
|
||||
|
||||
void AbsoluteToRelative(const QuatT* pSource, QuatT* pDestination);
|
||||
|
||||
bool SerializeTo(XmlNodeRef& node);
|
||||
|
||||
private:
|
||||
std::vector<SNode> m_nodes;
|
||||
};
|
||||
} // namespace Skeleton
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_ANIMATION_SKELETONHIERARCHY_H
|
||||
@@ -1,368 +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 "SkeletonMapper.h"
|
||||
|
||||
using namespace Skeleton;
|
||||
|
||||
/*
|
||||
|
||||
CMapper
|
||||
|
||||
*/
|
||||
|
||||
CMapper::CMapper()
|
||||
{
|
||||
}
|
||||
|
||||
CMapper::~CMapper()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
void CMapper::CreateFromHierarchy()
|
||||
{
|
||||
m_nodes.clear();
|
||||
|
||||
uint32 nodeCount = m_hierarchy.GetNodeCount();
|
||||
m_nodes.resize(nodeCount);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
uint32 CMapper::CreateLocation(const char* name)
|
||||
{
|
||||
int32 index = FindLocation(name);
|
||||
if (index < 1)
|
||||
{
|
||||
CMapperLocation* pLocation = new CMapperLocation();
|
||||
pLocation->SetName(name);
|
||||
m_locations.push_back(pLocation);
|
||||
}
|
||||
return uint32(m_locations.size() - 1);
|
||||
}
|
||||
|
||||
void CMapper::ClearLocations()
|
||||
{
|
||||
uint32 count = uint32(m_nodes.size());
|
||||
for (uint32 i = 0; i < count; ++i)
|
||||
{
|
||||
m_nodes[i].position = nullptr;
|
||||
m_nodes[i].orientation = nullptr;
|
||||
}
|
||||
|
||||
m_locations.clear();
|
||||
}
|
||||
|
||||
int32 CMapper::FindLocation(const char* name) const
|
||||
{
|
||||
uint32 count = uint32(m_locations.size());
|
||||
for (uint32 i = 0; i < count; ++i)
|
||||
{
|
||||
if (::_stricmp(m_locations[i]->GetName(), name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return int32(i);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CMapper::SetLocation(CMapperLocation& location)
|
||||
{
|
||||
int32 index = FindLocation(location.GetName());
|
||||
if (index < 0)
|
||||
{
|
||||
m_locations.push_back(&location);
|
||||
return;
|
||||
}
|
||||
|
||||
m_locations[index] = &location;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
bool CMapper::CreateLocationsHierarchy(uint32 index, CHierarchy& hierarchy, int32 hierarchyParent)
|
||||
{
|
||||
if (NodeHasLocation(index))
|
||||
{
|
||||
const CHierarchy::SNode* pNode = m_hierarchy.GetNode(index);
|
||||
uint32 nodeIndex = hierarchy.AddNode(pNode->name, pNode->pose, hierarchyParent);
|
||||
hierarchyParent = uint32(nodeIndex);
|
||||
}
|
||||
|
||||
std::vector<uint32> children;
|
||||
GetChildrenIndices(index, children);
|
||||
uint32 childCount = uint32(children.size());
|
||||
for (uint32 i = 0; i < childCount; ++i)
|
||||
{
|
||||
CreateLocationsHierarchy(children[i], hierarchy, hierarchyParent);
|
||||
}
|
||||
|
||||
return hierarchy.GetNodeCount() != 0;
|
||||
}
|
||||
|
||||
bool CMapper::CreateLocationsHierarchy(CHierarchy& hierarchy)
|
||||
{
|
||||
hierarchy.ClearNodes();
|
||||
if (!CreateLocationsHierarchy(0, hierarchy, -1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
hierarchy.ValidateReferences();
|
||||
return true;
|
||||
}
|
||||
|
||||
void CMapper::Map(QuatT* pResult)
|
||||
{
|
||||
uint32 outputCount = m_hierarchy.GetNodeCount();
|
||||
std::vector<Quat> absolutes(outputCount);
|
||||
for (uint32 i = 0; i < outputCount; ++i)
|
||||
{
|
||||
pResult[i].SetIdentity();
|
||||
absolutes[i].SetIdentity();
|
||||
|
||||
CHierarchy::SNode* pNode = m_hierarchy.GetNode(i);
|
||||
if (!pNode)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CHierarchy::SNode* pParent = pNode->parent < 0 ?
|
||||
nullptr : m_hierarchy.GetNode(pNode->parent);
|
||||
if (pParent)
|
||||
{
|
||||
pResult[i].t =
|
||||
(pNode->pose.t - pParent->pose.t) * pParent->pose.q;
|
||||
}
|
||||
|
||||
if (m_nodes[i].position)
|
||||
{
|
||||
pResult[i].t = m_nodes[i].position->Compute().t;
|
||||
}
|
||||
|
||||
if (m_nodes[i].orientation)
|
||||
{
|
||||
absolutes[i] = m_nodes[i].orientation->Compute().q;
|
||||
}
|
||||
else if (pParent)
|
||||
{
|
||||
Quat relative = pParent->pose.q.GetInverted() * pNode->pose.q;
|
||||
absolutes[i] = absolutes[pNode->parent] * relative;
|
||||
}
|
||||
}
|
||||
|
||||
for (uint32 i = 0; i < outputCount; ++i)
|
||||
{
|
||||
CHierarchy::SNode* pNode = m_hierarchy.GetNode(i);
|
||||
if (!pNode)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CHierarchy::SNode* pParent = pNode->parent < 0 ?
|
||||
nullptr : m_hierarchy.GetNode(pNode->parent);
|
||||
if (!pParent)
|
||||
{
|
||||
pResult[i].q = absolutes[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
pResult[i].q = absolutes[i];
|
||||
if (!m_nodes[i].position)
|
||||
{
|
||||
pResult[i].t = pResult[pNode->parent].t +
|
||||
pResult[i].t * absolutes[pNode->parent].GetInverted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
bool CMapper::NodeHasLocation(uint32 index)
|
||||
{
|
||||
if (CMapperOperator* pOperator = m_nodes[index].position)
|
||||
{
|
||||
if (pOperator->IsOfClass("Location"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (pOperator->HasLinksOfClass("Location"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (CMapperOperator* pOperator = m_nodes[index].orientation)
|
||||
{
|
||||
if (pOperator->IsOfClass("Location"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (pOperator->HasLinksOfClass("Location"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CMapper::GetChildrenIndices(uint32 parent, std::vector<uint32>& children)
|
||||
{
|
||||
uint32 nodeCount = m_hierarchy.GetNodeCount();
|
||||
for (uint32 i = 0; i < nodeCount; ++i)
|
||||
{
|
||||
if (m_hierarchy.GetNode(i)->parent != parent)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
children.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
bool CMapper::ChildrenHaveLocation(uint32 index)
|
||||
{
|
||||
std::vector<uint32> children;
|
||||
GetChildrenIndices(index, children);
|
||||
|
||||
uint32 childrenCount = uint32(children.size());
|
||||
for (uint32 i = 0; i < childrenCount; ++i)
|
||||
{
|
||||
if (ChildrenHaveLocation(children[i]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMapper::NodeOrChildrenHaveLocation(uint32 index)
|
||||
{
|
||||
if (NodeHasLocation(index))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<uint32> children;
|
||||
GetChildrenIndices(index, children);
|
||||
|
||||
uint32 childrenCount = uint32(children.size());
|
||||
for (uint32 i = 0; i < childrenCount; ++i)
|
||||
{
|
||||
if (NodeOrChildrenHaveLocation(children[i]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMapper::SerializeTo(XmlNodeRef& node)
|
||||
{
|
||||
XmlNodeRef hierarchy = node->newChild("Hierarchy");
|
||||
|
||||
uint32 nodeCount = GetNodeCount();
|
||||
std::vector<IXmlNode*> nodes(nodeCount);
|
||||
for (uint32 i = 0; i < nodeCount; ++i)
|
||||
{
|
||||
if (!NodeOrChildrenHaveLocation(i))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CHierarchy::SNode* pNode = m_hierarchy.GetNode(i);
|
||||
if (!pNode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
XmlNodeRef xmlParent = hierarchy;
|
||||
int32 parent = pNode->parent;
|
||||
if (parent > -1)
|
||||
{
|
||||
xmlParent = nodes[parent];
|
||||
}
|
||||
|
||||
nodes[i] = xmlParent->newChild("Node");
|
||||
nodes[i]->setAttr("name", pNode->name);
|
||||
|
||||
if (CMapperOperator* pOperator = m_nodes[i].position)
|
||||
{
|
||||
XmlNodeRef position = nodes[i]->newChild("Position");
|
||||
XmlNodeRef child = position->newChild("Operator");
|
||||
if (!pOperator->SerializeWithLinksTo(child))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (CMapperOperator* pOperator = m_nodes[i].orientation)
|
||||
{
|
||||
XmlNodeRef orientation = nodes[i]->newChild("Orientation");
|
||||
XmlNodeRef child = orientation->newChild("Operator");
|
||||
if (!pOperator->SerializeWithLinksTo(child))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CMapper::SerializeFrom(XmlNodeRef& node, int32 parent)
|
||||
{
|
||||
int childCount = uint32(node->getChildCount());
|
||||
for (int i = 0; i < childCount; ++i)
|
||||
{
|
||||
XmlNodeRef child = node->getChild(i);
|
||||
if (::_stricmp(child->getTag(), "Node"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32 index = m_hierarchy.AddNode(child->getAttr("name"), QuatT(IDENTITY), parent);
|
||||
if (!SerializeFrom(child, int32(index)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CMapper::SerializeFrom(XmlNodeRef& node)
|
||||
{
|
||||
XmlNodeRef hierarchy = node->findChild("Hierarchy");
|
||||
if (!hierarchy)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_hierarchy.ClearNodes();
|
||||
|
||||
if (!SerializeFrom(hierarchy, -1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_nodes.resize(m_hierarchy.GetNodeCount());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,76 +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_ANIMATION_SKELETONMAPPER_H
|
||||
#define CRYINCLUDE_EDITOR_ANIMATION_SKELETONMAPPER_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "SkeletonHierarchy.h"
|
||||
#include "SkeletonMapperOperator.h"
|
||||
|
||||
namespace Skeleton {
|
||||
class CMapper
|
||||
{
|
||||
public:
|
||||
struct SNode
|
||||
{
|
||||
_smart_ptr<CMapperOperator> position;
|
||||
_smart_ptr<CMapperOperator> orientation;
|
||||
};
|
||||
|
||||
public:
|
||||
CMapper();
|
||||
~CMapper();
|
||||
|
||||
public:
|
||||
CHierarchy& GetHierarchy() { return m_hierarchy; }
|
||||
void CreateFromHierarchy();
|
||||
|
||||
uint32 GetNodeCount() const { return uint32(m_nodes.size()); }
|
||||
SNode* GetNode(uint32 index) { return &m_nodes[index]; }
|
||||
const SNode* GetNode(uint32 index) const { return &m_nodes[index]; }
|
||||
|
||||
uint32 CreateLocation(const char* name);
|
||||
void ClearLocations();
|
||||
int32 FindLocation(const char* name) const;
|
||||
|
||||
uint32 GetLocationCount() const { return uint32(m_locations.size()); }
|
||||
void SetLocation(CMapperLocation& location);
|
||||
CMapperLocation* GetLocation(uint32 index) { return m_locations[index]; }
|
||||
const CMapperLocation* GetLocation(uint32 index) const { return m_locations[index]; }
|
||||
|
||||
bool CreateLocationsHierarchy(CHierarchy& hierarchy);
|
||||
|
||||
void Map(QuatT* pResult);
|
||||
|
||||
bool SerializeTo(XmlNodeRef& node);
|
||||
bool SerializeFrom(XmlNodeRef& node);
|
||||
|
||||
private:
|
||||
bool NodeHasLocation(uint32 index);
|
||||
bool ChildrenHaveLocation(uint32 index);
|
||||
bool NodeOrChildrenHaveLocation(uint32 index);
|
||||
|
||||
bool SerializeFrom(XmlNodeRef& node, int32 parent);
|
||||
|
||||
bool CreateLocationsHierarchy(uint32 index, CHierarchy& hierarchy, int32 hierarchyParent = -1);
|
||||
|
||||
// TEMP
|
||||
void GetChildrenIndices(uint32 parent, std::vector<uint32>& children);
|
||||
|
||||
private:
|
||||
CHierarchy m_hierarchy;
|
||||
std::vector<_smart_ptr<CMapperLocation> > m_locations;
|
||||
|
||||
std::vector<SNode> m_nodes;
|
||||
};
|
||||
} // namespace Skeleton
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_ANIMATION_SKELETONMAPPER_H
|
||||
@@ -1,284 +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 "SkeletonMapperOperator.h"
|
||||
|
||||
using namespace Skeleton;
|
||||
|
||||
/*
|
||||
|
||||
CMapperOperatorDesc
|
||||
|
||||
*/
|
||||
|
||||
std::vector<CMapperOperatorDesc*> CMapperOperatorDesc::s_descs;
|
||||
|
||||
//
|
||||
|
||||
CMapperOperatorDesc::CMapperOperatorDesc(const char* name)
|
||||
{
|
||||
s_descs.push_back(this);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
CMapperOperator
|
||||
|
||||
*/
|
||||
|
||||
CMapperOperator::CMapperOperator(const char* className, uint32 positionCount, uint32 orientationCount)
|
||||
{
|
||||
m_className = className;
|
||||
m_position.resize(positionCount, nullptr);
|
||||
m_orientation.resize(orientationCount, nullptr);
|
||||
}
|
||||
|
||||
CMapperOperator::~CMapperOperator()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
bool CMapperOperator::IsOfClass(const char* className)
|
||||
{
|
||||
if (::_stricmp(m_className, className))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 CMapperOperator::HasLinksOfClass(const char* className)
|
||||
{
|
||||
uint32 count = 0;
|
||||
|
||||
uint32 positionCount = m_position.size();
|
||||
for (uint32 i = 0; i < positionCount; ++i)
|
||||
{
|
||||
CMapperOperator* pOperator = m_position[i];
|
||||
if (!pOperator)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pOperator->IsOfClass(className))
|
||||
{
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
uint32 orientationCount = m_orientation.size();
|
||||
for (uint32 i = 0; i < orientationCount; ++i)
|
||||
{
|
||||
CMapperOperator* pOperator = m_orientation[i];
|
||||
if (!pOperator)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pOperator->IsOfClass(className))
|
||||
{
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
bool CMapperOperator::SerializeTo(XmlNodeRef& node)
|
||||
{
|
||||
node->setAttr("class", m_className);
|
||||
|
||||
uint32 parameterCount = uint32(m_parameters.size());
|
||||
for (uint32 i = 0; i < parameterCount; ++i)
|
||||
{
|
||||
m_parameters[i]->Serialize(node, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CMapperOperator::SerializeFrom(XmlNodeRef& node)
|
||||
{
|
||||
uint32 parameterCount = uint32(m_parameters.size());
|
||||
for (uint32 i = 0; i < parameterCount; ++i)
|
||||
{
|
||||
m_parameters[i]->Serialize(node, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CMapperOperator::SerializeWithLinksTo(XmlNodeRef& node)
|
||||
{
|
||||
if (!SerializeTo(node))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 positionCount = uint32(m_position.size());
|
||||
for (uint32 i = 0; i < positionCount; ++i)
|
||||
{
|
||||
CMapperOperator* pOperator = m_position[i];
|
||||
if (!pOperator)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
XmlNodeRef position = node->newChild("Position");
|
||||
position->setAttr("index", i);
|
||||
|
||||
XmlNodeRef child = position->newChild("Operator");
|
||||
if (!pOperator->SerializeWithLinksTo(child))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint32 orientationCount = uint32(m_orientation.size());
|
||||
for (uint32 i = 0; i < orientationCount; ++i)
|
||||
{
|
||||
CMapperOperator* pOperator = m_orientation[i];
|
||||
if (!pOperator)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
XmlNodeRef orientation = node->newChild("Orientation");
|
||||
orientation->setAttr("index", i);
|
||||
|
||||
XmlNodeRef child = orientation->newChild("Operator");
|
||||
if (!pOperator->SerializeWithLinksTo(child))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CMapperOperator::SerializeWithLinksFrom(XmlNodeRef& node)
|
||||
{
|
||||
if (!SerializeFrom(node))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
|
||||
CMapperOperator_Transform
|
||||
|
||||
*/
|
||||
|
||||
class CMapperOperator_Transform
|
||||
: public CMapperOperator
|
||||
{
|
||||
public:
|
||||
CMapperOperator_Transform()
|
||||
: CMapperOperator("Transform", 1, 1)
|
||||
{
|
||||
m_pAngles = new CVariable<Vec3>();
|
||||
m_pAngles->SetName("rotation");
|
||||
m_pAngles->Set(Vec3(0.0f, 0.0f, 0.0f));
|
||||
m_pAngles->SetLimits(-180.0f, 180.0f);
|
||||
AddParameter(*m_pAngles);
|
||||
|
||||
m_pVector = new CVariable<Vec3>();
|
||||
m_pVector->SetName("vector");
|
||||
m_pVector->Set(Vec3(0.0f, 0.0f, 0.0f));
|
||||
AddParameter(*m_pVector);
|
||||
|
||||
m_pScale = new CVariable<Vec3>();
|
||||
m_pScale->SetName("scale");
|
||||
m_pScale->Set(Vec3(1.0f, 1.0f, 1.0f));
|
||||
AddParameter(*m_pScale);
|
||||
}
|
||||
|
||||
// CMapperOperator
|
||||
public:
|
||||
virtual QuatT CMapperOperator_Transform::Compute()
|
||||
{
|
||||
QuatT result(IDENTITY);
|
||||
m_pVector->Get(result.t);
|
||||
|
||||
Vec3 scale;
|
||||
m_pScale->Get(scale);
|
||||
|
||||
Vec3 angles;
|
||||
m_pAngles->Get(angles);
|
||||
|
||||
result.q = Quat::CreateRotationXYZ(
|
||||
Ang3(DEG2RAD(angles.x), DEG2RAD(angles.y), DEG2RAD(angles.z)));
|
||||
|
||||
if (CMapperOperator* pOperator = GetPosition(0))
|
||||
{
|
||||
result.t = pOperator->Compute().t.CompMul(scale) + result.t;
|
||||
}
|
||||
if (CMapperOperator* pOperator = GetOrientation(0))
|
||||
{
|
||||
result.q = pOperator->Compute().q * result.q;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
CVariable<Vec3>* m_pVector;
|
||||
CVariable<Vec3>* m_pAngles;
|
||||
CVariable<Vec3>* m_pScale;
|
||||
};
|
||||
|
||||
SkeletonMapperOperatorRegister(Transform, CMapperOperator_Transform)
|
||||
|
||||
class CMapperOperator_PositionsToOrientation
|
||||
: public CMapperOperator
|
||||
{
|
||||
public:
|
||||
CMapperOperator_PositionsToOrientation()
|
||||
: CMapperOperator("PositionsToOrientation", 3, 0)
|
||||
{
|
||||
}
|
||||
|
||||
// CMapperOperator
|
||||
public:
|
||||
virtual QuatT Compute()
|
||||
{
|
||||
CMapperOperator* pOperator0 = GetPosition(0);
|
||||
CMapperOperator* pOperator1 = GetPosition(1);
|
||||
CMapperOperator* pOperator2 = GetPosition(2);
|
||||
if (!pOperator0 || !pOperator1 || !pOperator2)
|
||||
{
|
||||
return QuatT(IDENTITY);
|
||||
}
|
||||
|
||||
Vec3 p0 = pOperator0->Compute().t;
|
||||
Vec3 p1 = pOperator1->Compute().t;
|
||||
Vec3 p2 = pOperator2->Compute().t;
|
||||
|
||||
Vec3 m = (p1 + p2) * 0.5f;
|
||||
Vec3 y = (m - p0).GetNormalized();
|
||||
Vec3 z = (p1 - p2).GetNormalized();
|
||||
Vec3 x = y % z;
|
||||
z = x % y;
|
||||
|
||||
Matrix33 m33;
|
||||
m33.SetFromVectors(x, y, z);
|
||||
QuatT result(IDENTITY);
|
||||
result.q = Quat(m33);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
SkeletonMapperOperatorRegister(PositionsToOrientation, CMapperOperator_PositionsToOrientation)
|
||||
@@ -1,164 +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_ANIMATION_SKELETONMAPPEROPERATOR_H
|
||||
#define CRYINCLUDE_EDITOR_ANIMATION_SKELETONMAPPEROPERATOR_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "../Util/Variable.h"
|
||||
|
||||
#undef GetClassName
|
||||
|
||||
#define SkeletonMapperOperatorRegister(name, className) \
|
||||
class CMapperOperatorDesc_##name \
|
||||
: public CMapperOperatorDesc \
|
||||
{ \
|
||||
public: \
|
||||
CMapperOperatorDesc_##name() \
|
||||
: CMapperOperatorDesc(#name) { } \
|
||||
protected: \
|
||||
virtual const char* GetName() { return #name; } \
|
||||
virtual CMapperOperator* Create() { return new className(); } \
|
||||
} mapperOperatorDesc__##name;
|
||||
|
||||
namespace Skeleton {
|
||||
class CMapperOperator;
|
||||
|
||||
class CMapperOperatorDesc
|
||||
{
|
||||
public:
|
||||
static uint32 GetCount() { return uint32(s_descs.size()); }
|
||||
static const char* GetName(uint32 index) { return s_descs[index]->GetName(); }
|
||||
static CMapperOperator* Create(uint32 index) { return s_descs[index]->Create(); }
|
||||
|
||||
private:
|
||||
static std::vector<CMapperOperatorDesc*> s_descs;
|
||||
|
||||
public:
|
||||
CMapperOperatorDesc(const char* name);
|
||||
|
||||
protected:
|
||||
virtual const char* GetName() = 0;
|
||||
virtual CMapperOperator* Create() = 0;
|
||||
};
|
||||
|
||||
class CMapperOperator
|
||||
: public _reference_target_t
|
||||
{
|
||||
protected:
|
||||
CMapperOperator(const char* className, uint32 positionCount, uint32 orientationCount);
|
||||
~CMapperOperator();
|
||||
|
||||
public:
|
||||
const char* GetClassName() { return m_className; }
|
||||
|
||||
uint32 GetPositionCount() const { return uint32(m_position.size()); }
|
||||
void SetPosition(uint32 index, CMapperOperator* pOperator) { m_position[index] = pOperator; }
|
||||
CMapperOperator* GetPosition(uint32 index) { return m_position[index]; }
|
||||
|
||||
uint32 GetOrientationCount() const { return uint32(m_orientation.size()); }
|
||||
void SetOrientation(uint32 index, CMapperOperator* pOperator) { m_orientation[index] = pOperator; }
|
||||
CMapperOperator* GetOrientation(uint32 index) { return m_orientation[index]; }
|
||||
|
||||
uint32 GetParameterCount() { return uint32(m_parameters.size()); }
|
||||
IVariable* GetParameter(uint32 index) { return m_parameters[index]; }
|
||||
|
||||
bool IsOfClass(const char* className);
|
||||
uint32 HasLinksOfClass(const char* className);
|
||||
|
||||
bool SerializeTo(XmlNodeRef& node);
|
||||
bool SerializeFrom(XmlNodeRef& node);
|
||||
|
||||
bool SerializeWithLinksTo(XmlNodeRef& node);
|
||||
bool SerializeWithLinksFrom(XmlNodeRef& node);
|
||||
|
||||
protected:
|
||||
void AddParameter(IVariable& variable) { m_parameters.push_back(&variable); }
|
||||
|
||||
public:
|
||||
virtual QuatT Compute() = 0;
|
||||
|
||||
private:
|
||||
const char* m_className;
|
||||
std::vector<_smart_ptr<CMapperOperator> > m_position;
|
||||
std::vector<_smart_ptr<CMapperOperator> > m_orientation;
|
||||
|
||||
std::vector<IVariablePtr> m_parameters;
|
||||
};
|
||||
|
||||
class CMapperLocation
|
||||
: public CMapperOperator
|
||||
{
|
||||
public:
|
||||
CMapperLocation()
|
||||
: CMapperOperator("Location", 0, 0)
|
||||
{
|
||||
m_pName = new CVariable<CString>();
|
||||
m_pName->SetName("name");
|
||||
m_pName->SetFlags(m_pName->GetFlags() | IVariable::UI_INVISIBLE);
|
||||
AddParameter(*m_pName);
|
||||
|
||||
m_pAxis = new CVariable<Vec3>();
|
||||
m_pAxis->SetName("axis");
|
||||
m_pAxis->SetLimits(-3.0f, +3.0f);
|
||||
m_pAxis->Set(Vec3(1.0f, 2.0f, 3.0f));
|
||||
AddParameter(*m_pAxis);
|
||||
|
||||
m_location = QuatT(IDENTITY);
|
||||
}
|
||||
|
||||
public:
|
||||
void SetName(const char* name) { m_pName->Set(name); }
|
||||
CString GetName() const { CString s; m_pName->Get(s); return s; }
|
||||
|
||||
void SetLocation(const QuatT& location) { m_location = location; }
|
||||
const QuatT& GetLocation() const { return m_location; }
|
||||
|
||||
// CMapperOperator
|
||||
public:
|
||||
virtual QuatT Compute()
|
||||
{
|
||||
Vec3 axis;
|
||||
m_pAxis->Get(axis);
|
||||
|
||||
uint32 x = fabs_tpl(axis.x);
|
||||
uint32 y = fabs_tpl(axis.y);
|
||||
uint32 z = fabs_tpl(axis.z);
|
||||
if (x < 1 || y < 1 || z < 1 ||
|
||||
x > 3 || y > 3 || y > 3 ||
|
||||
x == y || x == z || y == z)
|
||||
{
|
||||
return QuatT(IDENTITY);
|
||||
}
|
||||
|
||||
Matrix33 matrix;
|
||||
matrix.SetFromVectors(
|
||||
m_location.q.GetColumn(x - 1) * f32(::sgn(axis.x)),
|
||||
m_location.q.GetColumn(y - 1) * f32(::sgn(axis.y)),
|
||||
m_location.q.GetColumn(z - 1) * f32(::sgn(axis.z)));
|
||||
if (!matrix.IsOrthonormalRH(0.01f))
|
||||
{
|
||||
return QuatT(IDENTITY);
|
||||
}
|
||||
|
||||
QuatT result = m_location;
|
||||
result.q = Quat(matrix);
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
CVariable<CString>* m_pName;
|
||||
CVariable<Vec3>* m_pAxis;
|
||||
|
||||
QuatT m_location;
|
||||
};
|
||||
} // namespace Skeleton
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_ANIMATION_SKELETONMAPPEROPERATOR_H
|
||||
@@ -258,9 +258,8 @@ bool CBaseLibrary::SaveLibrary(const char* name, bool saveEmptyLibrary)
|
||||
}
|
||||
if (!bRes)
|
||||
{
|
||||
string strMessage;
|
||||
QByteArray filenameUtf8 = fileName.toUtf8();
|
||||
strMessage.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());
|
||||
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;
|
||||
|
||||
@@ -526,7 +526,7 @@ void CBaseLibraryManager::Serialize(XmlNodeRef& node, bool bLoading)
|
||||
QString CBaseLibraryManager::MakeUniqueItemName(const QString& srcName, const QString& libName)
|
||||
{
|
||||
// unlikely we'll ever encounter more than 16
|
||||
std::vector<string> possibleDuplicates;
|
||||
std::vector<AZStd::string> possibleDuplicates;
|
||||
possibleDuplicates.reserve(16);
|
||||
|
||||
// search for strings in the database that might have a similar name (ignore case)
|
||||
@@ -550,7 +550,7 @@ QString CBaseLibraryManager::MakeUniqueItemName(const QString& srcName, const QS
|
||||
const QString& name = pItem->GetName();
|
||||
if (name.startsWith(srcName, Qt::CaseInsensitive))
|
||||
{
|
||||
possibleDuplicates.push_back(string(name.toUtf8().data()));
|
||||
possibleDuplicates.push_back(AZStd::string(name.toUtf8().data()));
|
||||
}
|
||||
}
|
||||
pEnum->Release();
|
||||
@@ -560,7 +560,7 @@ QString CBaseLibraryManager::MakeUniqueItemName(const QString& srcName, const QS
|
||||
return srcName;
|
||||
}
|
||||
|
||||
std::sort(possibleDuplicates.begin(), possibleDuplicates.end(), [](const string& strOne, const string& strTwo)
|
||||
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)
|
||||
|
||||
@@ -79,9 +79,9 @@ CEditorCommandManager::~CEditorCommandManager()
|
||||
m_uiCommands.clear();
|
||||
}
|
||||
|
||||
string CEditorCommandManager::GetFullCommandName(const string& module, const string& name)
|
||||
AZStd::string CEditorCommandManager::GetFullCommandName(const AZStd::string& module, const AZStd::string& name)
|
||||
{
|
||||
string fullName = module;
|
||||
AZStd::string fullName = module;
|
||||
fullName += ".";
|
||||
fullName += name;
|
||||
return fullName;
|
||||
@@ -91,10 +91,10 @@ bool CEditorCommandManager::AddCommand(CCommand* pCommand, TPfnDeleter deleter)
|
||||
{
|
||||
assert(pCommand);
|
||||
|
||||
string module = pCommand->GetModule();
|
||||
string name = pCommand->GetName();
|
||||
AZStd::string module = pCommand->GetModule();
|
||||
AZStd::string name = pCommand->GetName();
|
||||
|
||||
if (IsRegistered(module, name) && m_bWarnDuplicate)
|
||||
if (IsRegistered(module.c_str(), name.c_str()) && m_bWarnDuplicate)
|
||||
{
|
||||
QString errMsg;
|
||||
|
||||
@@ -118,7 +118,7 @@ bool CEditorCommandManager::AddCommand(CCommand* pCommand, TPfnDeleter deleter)
|
||||
|
||||
bool CEditorCommandManager::UnregisterCommand(const char* module, const char* name)
|
||||
{
|
||||
string fullName = GetFullCommandName(module, name);
|
||||
AZStd::string fullName = GetFullCommandName(module, name);
|
||||
CommandTable::iterator itr = m_commands.find(fullName);
|
||||
|
||||
if (itr != m_commands.end())
|
||||
@@ -154,7 +154,7 @@ bool CEditorCommandManager::RegisterUICommand(
|
||||
return false;
|
||||
}
|
||||
|
||||
return AttachUIInfo(GetFullCommandName(module, name), uiInfo);
|
||||
return AttachUIInfo(GetFullCommandName(module, name).c_str(), uiInfo);
|
||||
}
|
||||
|
||||
bool CEditorCommandManager::AttachUIInfo(const char* fullCmdName, const CCommand0::SUIInfo& uiInfo)
|
||||
@@ -190,14 +190,14 @@ bool CEditorCommandManager::AttachUIInfo(const char* fullCmdName, const CCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CEditorCommandManager::GetUIInfo(const string& module, const string& name, CCommand0::SUIInfo& uiInfo) const
|
||||
bool CEditorCommandManager::GetUIInfo(const AZStd::string& module, const AZStd::string& name, CCommand0::SUIInfo& uiInfo) const
|
||||
{
|
||||
string fullName = GetFullCommandName(module, name);
|
||||
AZStd::string fullName = GetFullCommandName(module, name);
|
||||
|
||||
return GetUIInfo(fullName, uiInfo);
|
||||
}
|
||||
|
||||
bool CEditorCommandManager::GetUIInfo(const string& fullCmdName, CCommand0::SUIInfo& uiInfo) const
|
||||
bool CEditorCommandManager::GetUIInfo(const AZStd::string& fullCmdName, CCommand0::SUIInfo& uiInfo) const
|
||||
{
|
||||
CommandTable::const_iterator iter = m_commands.find(fullCmdName);
|
||||
|
||||
@@ -223,9 +223,9 @@ int CEditorCommandManager::GenNewCommandId()
|
||||
return uniqueId++;
|
||||
}
|
||||
|
||||
QString CEditorCommandManager::Execute(const string& module, const string& name, const CCommand::CArgs& args)
|
||||
QString CEditorCommandManager::Execute(const AZStd::string& module, const AZStd::string& name, const CCommand::CArgs& args)
|
||||
{
|
||||
string fullName = GetFullCommandName(module, name);
|
||||
AZStd::string fullName = GetFullCommandName(module, name);
|
||||
CommandTable::iterator iter = m_commands.find(fullName);
|
||||
|
||||
if (iter != m_commands.end())
|
||||
@@ -245,18 +245,18 @@ QString CEditorCommandManager::Execute(const string& module, const string& name,
|
||||
return "";
|
||||
}
|
||||
|
||||
QString CEditorCommandManager::Execute(const string& cmdLine)
|
||||
QString CEditorCommandManager::Execute(const AZStd::string& cmdLine)
|
||||
{
|
||||
string cmdTxt, argsTxt;
|
||||
AZStd::string cmdTxt, argsTxt;
|
||||
size_t argStart = cmdLine.find_first_of(' ');
|
||||
|
||||
cmdTxt = cmdLine.substr(0, argStart);
|
||||
argsTxt = "";
|
||||
|
||||
if (argStart != string::npos)
|
||||
if (argStart != AZStd::string::npos)
|
||||
{
|
||||
argsTxt = cmdLine.substr(argStart + 1);
|
||||
argsTxt.Trim();
|
||||
AZ::StringFunc::TrimWhiteSpace(argsTxt, true, true);
|
||||
}
|
||||
|
||||
CommandTable::iterator itr = m_commands.find(cmdTxt);
|
||||
@@ -301,7 +301,7 @@ void CEditorCommandManager::Execute(int commandId)
|
||||
}
|
||||
}
|
||||
|
||||
void CEditorCommandManager::GetCommandList(std::vector<string>& cmds) const
|
||||
void CEditorCommandManager::GetCommandList(std::vector<AZStd::string>& cmds) const
|
||||
{
|
||||
cmds.clear();
|
||||
cmds.reserve(m_commands.size());
|
||||
@@ -315,9 +315,9 @@ void CEditorCommandManager::GetCommandList(std::vector<string>& cmds) const
|
||||
std::sort(cmds.begin(), cmds.end());
|
||||
}
|
||||
|
||||
string CEditorCommandManager::AutoComplete(const string& substr) const
|
||||
AZStd::string CEditorCommandManager::AutoComplete(const AZStd::string& substr) const
|
||||
{
|
||||
std::vector<string> cmds;
|
||||
std::vector<AZStd::string> cmds;
|
||||
GetCommandList(cmds);
|
||||
|
||||
// If substring is empty return first command.
|
||||
@@ -358,7 +358,7 @@ string CEditorCommandManager::AutoComplete(const string& substr) const
|
||||
|
||||
bool CEditorCommandManager::IsRegistered(const char* module, const char* name) const
|
||||
{
|
||||
string fullName = GetFullCommandName(module, name);
|
||||
AZStd::string fullName = GetFullCommandName(module, name);
|
||||
CommandTable::const_iterator iter = m_commands.find(fullName);
|
||||
|
||||
if (iter != m_commands.end())
|
||||
@@ -373,7 +373,7 @@ bool CEditorCommandManager::IsRegistered(const char* module, const char* name) c
|
||||
|
||||
bool CEditorCommandManager::IsRegistered(const char* cmdLine_) const
|
||||
{
|
||||
string cmdTxt, argsTxt, cmdLine(cmdLine_);
|
||||
AZStd::string cmdTxt, argsTxt, cmdLine(cmdLine_);
|
||||
size_t argStart = cmdLine.find_first_of(' ');
|
||||
cmdTxt = cmdLine.substr(0, argStart);
|
||||
CommandTable::const_iterator iter = m_commands.find(cmdTxt);
|
||||
@@ -402,9 +402,9 @@ bool CEditorCommandManager::IsRegistered(int commandId) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void CEditorCommandManager::SetCommandAvailableInScripting(const string& module, const string& name)
|
||||
void CEditorCommandManager::SetCommandAvailableInScripting(const AZStd::string& module, const AZStd::string& name)
|
||||
{
|
||||
string fullName = GetFullCommandName(module, name);
|
||||
AZStd::string fullName = GetFullCommandName(module, name);
|
||||
CommandTable::iterator iter = m_commands.find(fullName);
|
||||
|
||||
if (iter != m_commands.end())
|
||||
@@ -413,7 +413,7 @@ void CEditorCommandManager::SetCommandAvailableInScripting(const string& module,
|
||||
}
|
||||
}
|
||||
|
||||
bool CEditorCommandManager::IsCommandAvailableInScripting(const string& fullCmdName) const
|
||||
bool CEditorCommandManager::IsCommandAvailableInScripting(const AZStd::string& fullCmdName) const
|
||||
{
|
||||
CommandTable::const_iterator iter = m_commands.find(fullCmdName);
|
||||
|
||||
@@ -425,16 +425,16 @@ bool CEditorCommandManager::IsCommandAvailableInScripting(const string& fullCmdN
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CEditorCommandManager::IsCommandAvailableInScripting(const string& module, const string& name) const
|
||||
bool CEditorCommandManager::IsCommandAvailableInScripting(const AZStd::string& module, const AZStd::string& name) const
|
||||
{
|
||||
string fullName = GetFullCommandName(module, name);
|
||||
AZStd::string fullName = GetFullCommandName(module, name);
|
||||
|
||||
return IsCommandAvailableInScripting(fullName);
|
||||
}
|
||||
|
||||
void CEditorCommandManager::LogCommand(const string& fullCmdName, const CCommand::CArgs& args) const
|
||||
void CEditorCommandManager::LogCommand(const AZStd::string& fullCmdName, const CCommand::CArgs& args) const
|
||||
{
|
||||
string cmdLine = fullCmdName;
|
||||
AZStd::string cmdLine = fullCmdName;
|
||||
|
||||
for (int i = 0; i < args.GetArgCount(); ++i)
|
||||
{
|
||||
@@ -509,7 +509,7 @@ void CEditorCommandManager::LogCommand(const string& fullCmdName, const CCommand
|
||||
|
||||
if (pScriptTermDialog)
|
||||
{
|
||||
string text = "> ";
|
||||
AZStd::string text = "> ";
|
||||
text += cmdLine;
|
||||
text += "\r\n";
|
||||
pScriptTermDialog->AppendText(text.c_str());
|
||||
@@ -526,14 +526,14 @@ QString CEditorCommandManager::ExecuteAndLogReturn(CCommand* pCommand, const CCo
|
||||
return result;
|
||||
}
|
||||
|
||||
void CEditorCommandManager::GetArgsFromString(const string& argsTxt, CCommand::CArgs& argList)
|
||||
void CEditorCommandManager::GetArgsFromString(const AZStd::string& argsTxt, CCommand::CArgs& argList)
|
||||
{
|
||||
const char quoteSymbol = '\'';
|
||||
int curPos = 0;
|
||||
int prevPos = 0;
|
||||
string arg = argsTxt.Tokenize(" ", curPos);
|
||||
|
||||
while (!arg.empty())
|
||||
AZStd::vector<AZStd::string> tokens;
|
||||
AZ::StringFunc::Tokenize(argsTxt, tokens, ' ');
|
||||
for(AZStd::string& arg : tokens)
|
||||
{
|
||||
if (arg[0] == quoteSymbol) // A special consideration for a quoted string
|
||||
{
|
||||
@@ -542,11 +542,11 @@ void CEditorCommandManager::GetArgsFromString(const string& argsTxt, CCommand::C
|
||||
size_t openingQuotePos = argsTxt.find(quoteSymbol, prevPos);
|
||||
size_t closingQuotePos = argsTxt.find(quoteSymbol, curPos);
|
||||
|
||||
if (closingQuotePos != string::npos)
|
||||
if (closingQuotePos != AZStd::string::npos)
|
||||
{
|
||||
arg = argsTxt.substr(openingQuotePos + 1, closingQuotePos - openingQuotePos - 1);
|
||||
size_t nextArgPos = argsTxt.find(' ', closingQuotePos + 1);
|
||||
curPos = nextArgPos != string::npos ? nextArgPos + 1 : argsTxt.length();
|
||||
curPos = nextArgPos != AZStd::string::npos ? nextArgPos + 1 : argsTxt.length();
|
||||
|
||||
for (; curPos < argsTxt.length(); ++curPos) // Skip spaces.
|
||||
{
|
||||
@@ -565,6 +565,5 @@ void CEditorCommandManager::GetArgsFromString(const string& argsTxt, CCommand::C
|
||||
|
||||
argList.Add(arg.c_str());
|
||||
prevPos = curPos;
|
||||
arg = argsTxt.Tokenize(" ", curPos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,20 +48,20 @@ public:
|
||||
const AZStd::function<void()>& functor,
|
||||
const CCommand0::SUIInfo& uiInfo);
|
||||
bool AttachUIInfo(const char* fullCmdName, const CCommand0::SUIInfo& uiInfo);
|
||||
bool GetUIInfo(const string& module, const string& name, CCommand0::SUIInfo& uiInfo) const;
|
||||
bool GetUIInfo(const string& fullCmdName, CCommand0::SUIInfo& uiInfo) const;
|
||||
QString Execute(const string& cmdLine);
|
||||
QString Execute(const string& module, const string& name, const CCommand::CArgs& args);
|
||||
bool GetUIInfo(const AZStd::string& module, const AZStd::string& name, CCommand0::SUIInfo& uiInfo) const;
|
||||
bool GetUIInfo(const AZStd::string& fullCmdName, CCommand0::SUIInfo& uiInfo) const;
|
||||
QString Execute(const AZStd::string& cmdLine);
|
||||
QString Execute(const AZStd::string& module, const AZStd::string& name, const CCommand::CArgs& args);
|
||||
void Execute(int commandId);
|
||||
void GetCommandList(std::vector<string>& cmds) const;
|
||||
void GetCommandList(std::vector<AZStd::string>& cmds) const;
|
||||
//! Used in the console dialog
|
||||
string AutoComplete(const string& substr) const;
|
||||
AZStd::string AutoComplete(const AZStd::string& substr) const;
|
||||
bool IsRegistered(const char* module, const char* name) const;
|
||||
bool IsRegistered(const char* cmdLine) const;
|
||||
bool IsRegistered(int commandId) const;
|
||||
void SetCommandAvailableInScripting(const string& module, const string& name);
|
||||
bool IsCommandAvailableInScripting(const string& module, const string& name) const;
|
||||
bool IsCommandAvailableInScripting(const string& fullCmdName) const;
|
||||
void SetCommandAvailableInScripting(const AZStd::string& module, const AZStd::string& name);
|
||||
bool IsCommandAvailableInScripting(const AZStd::string& module, const AZStd::string& name) const;
|
||||
bool IsCommandAvailableInScripting(const AZStd::string& fullCmdName) const;
|
||||
//! Turning off the warning is needed for reloading the ribbon bar.
|
||||
void TurnDuplicateWarningOn() { m_bWarnDuplicate = true; }
|
||||
void TurnDuplicateWarningOff() { m_bWarnDuplicate = false; }
|
||||
@@ -74,7 +74,7 @@ protected:
|
||||
};
|
||||
|
||||
//! A full command name to an actual command mapping
|
||||
typedef std::map<string, SCommandTableEntry> CommandTable;
|
||||
typedef std::map<AZStd::string, SCommandTableEntry> CommandTable;
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
CommandTable m_commands;
|
||||
|
||||
@@ -86,9 +86,9 @@ protected:
|
||||
bool m_bWarnDuplicate;
|
||||
|
||||
static int GenNewCommandId();
|
||||
static string GetFullCommandName(const string& module, const string& name);
|
||||
static void GetArgsFromString(const string& argsTxt, CCommand::CArgs& argList);
|
||||
void LogCommand(const string& fullCmdName, const CCommand::CArgs& args) const;
|
||||
static AZStd::string GetFullCommandName(const AZStd::string& module, const AZStd::string& name);
|
||||
static void GetArgsFromString(const AZStd::string& argsTxt, CCommand::CArgs& argList);
|
||||
void LogCommand(const AZStd::string& fullCmdName, const CCommand::CArgs& args) const;
|
||||
QString ExecuteAndLogReturn(CCommand* pCommand, const CCommand::CArgs& args);
|
||||
};
|
||||
|
||||
|
||||
@@ -127,9 +127,9 @@ namespace Config
|
||||
|
||||
case IConfigVar::eType_STRING:
|
||||
{
|
||||
string currentValue = nullptr;
|
||||
AZStd::string currentValue;
|
||||
var->Get(¤tValue);
|
||||
node->setAttr(szName, currentValue);
|
||||
node->setAttr(szName, currentValue.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,7 @@ namespace Config
|
||||
|
||||
case IConfigVar::eType_STRING:
|
||||
{
|
||||
string currentValue = nullptr;
|
||||
AZStd::string currentValue;
|
||||
var->GetDefault(¤tValue);
|
||||
QString readValue(currentValue.c_str());
|
||||
if (node->getAttr(szName, readValue))
|
||||
|
||||
@@ -47,12 +47,12 @@ namespace Config
|
||||
return m_type;
|
||||
}
|
||||
|
||||
ILINE const string& GetName() const
|
||||
ILINE const AZStd::string& GetName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
ILINE const string& GetDescription() const
|
||||
ILINE const AZStd::string& GetDescription() const
|
||||
{
|
||||
return m_description;
|
||||
}
|
||||
@@ -71,13 +71,13 @@ namespace Config
|
||||
static EType TranslateType(const bool&) { return eType_BOOL; }
|
||||
static EType TranslateType(const int&) { return eType_INT; }
|
||||
static EType TranslateType(const float&) { return eType_FLOAT; }
|
||||
static EType TranslateType(const string&) { return eType_STRING; }
|
||||
static EType TranslateType(const AZStd::string&) { return eType_STRING; }
|
||||
|
||||
protected:
|
||||
EType m_type;
|
||||
uint8 m_flags;
|
||||
string m_name;
|
||||
string m_description;
|
||||
AZStd::string m_name;
|
||||
AZStd::string m_description;
|
||||
void* m_ptr;
|
||||
ICVar* m_pCVar;
|
||||
};
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "EditorDefs.h"
|
||||
#include "ControlMRU.h"
|
||||
|
||||
IMPLEMENT_XTP_CONTROL(CControlMRU, CXTPControlRecentFileList)
|
||||
|
||||
bool CControlMRU::DoesFileExist(CString& sFileName)
|
||||
{
|
||||
return (_access(sFileName.GetBuffer(), 0) == 0);
|
||||
}
|
||||
|
||||
void CControlMRU::OnCalcDynamicSize(DWORD dwMode)
|
||||
{
|
||||
CRecentFileList* pRecentFileList = GetRecentFileList();
|
||||
|
||||
if (!pRecentFileList)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CString* pArrNames = pRecentFileList->m_arrNames;
|
||||
|
||||
assert(pArrNames != nullptr);
|
||||
if (!pArrNames)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while (m_nIndex + 1 < m_pControls->GetCount())
|
||||
{
|
||||
CXTPControl* pControl = m_pControls->GetAt(m_nIndex + 1);
|
||||
assert(pControl);
|
||||
if (pControl->GetID() >= GetFirstMruID()
|
||||
&& pControl->GetID() <= GetFirstMruID() + pRecentFileList->m_nSize)
|
||||
{
|
||||
m_pControls->Remove(pControl);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_pParent->IsCustomizeMode())
|
||||
{
|
||||
m_dwHideFlags = 0;
|
||||
SetEnabled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pArrNames[0].IsEmpty())
|
||||
{
|
||||
SetCaption(CString(MAKEINTRESOURCE(IDS_NORECENTFILE_CAPTION)));
|
||||
SetDescription("No recently opened files");
|
||||
m_dwHideFlags = 0;
|
||||
SetEnabled(false);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetCaption(CString(MAKEINTRESOURCE(IDS_RECENTFILE_CAPTION)));
|
||||
SetDescription("Open this document");
|
||||
}
|
||||
|
||||
m_dwHideFlags |= xtpHideGeneric;
|
||||
|
||||
CString sCurDir = (Path::GetEditingGameDataFolder() + "\\").c_str();
|
||||
int nCurDir = sCurDir.GetLength();
|
||||
|
||||
CString strName;
|
||||
CString strTemp;
|
||||
int iLastValidMRU = 0;
|
||||
|
||||
for (int iMRU = 0; iMRU < pRecentFileList->m_nSize; iMRU++)
|
||||
{
|
||||
if (!pRecentFileList->GetDisplayName(strName, iMRU, sCurDir.GetBuffer(), nCurDir))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (DoesFileExist(pArrNames[iMRU]))
|
||||
{
|
||||
CString sCurEntryDir = pArrNames[iMRU].Left(nCurDir);
|
||||
|
||||
if (sCurEntryDir.CompareNoCase(sCurDir) != 0)
|
||||
{
|
||||
//unavailable entry (wrong directory)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//invalid entry (not existing)
|
||||
continue;
|
||||
}
|
||||
|
||||
int nId = iMRU + GetFirstMruID();
|
||||
|
||||
CXTPControl* pControl = m_pControls->Add(xtpControlButton, nId, _T(""), m_nIndex + iLastValidMRU + 1, true);
|
||||
assert(pControl);
|
||||
|
||||
pControl->SetCaption(CXTPControlWindowList::ConstructCaption(strName, iLastValidMRU + 1));
|
||||
pControl->SetFlags(xtpFlagManualUpdate);
|
||||
pControl->SetBeginGroup(iLastValidMRU == 0 && m_nIndex != 0);
|
||||
pControl->SetParameter(pArrNames[iMRU]);
|
||||
|
||||
CString sDescription = "Open file: " + pArrNames[iMRU];
|
||||
pControl->SetDescription(sDescription);
|
||||
|
||||
if ((GetFlags() & xtpFlagWrapRow) && iMRU == 0)
|
||||
{
|
||||
pControl->SetFlags(pControl->GetFlags() | xtpFlagWrapRow);
|
||||
}
|
||||
|
||||
++iLastValidMRU;
|
||||
}
|
||||
|
||||
//if no entry was valid, treat as none would exist
|
||||
if (iLastValidMRU == 0)
|
||||
{
|
||||
SetCaption(CString(MAKEINTRESOURCE(IDS_NORECENTFILE_CAPTION)));
|
||||
SetDescription("No recently opened files");
|
||||
m_dwHideFlags = 0;
|
||||
SetEnabled(false);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
#ifndef CRYINCLUDE_EDITOR_CONTROLMRU_H
|
||||
#define CRYINCLUDE_EDITOR_CONTROLMRU_H
|
||||
|
||||
class CControlMRU
|
||||
: public CXTPControlRecentFileList
|
||||
{
|
||||
protected:
|
||||
virtual void OnCalcDynamicSize(DWORD dwMode);
|
||||
|
||||
private:
|
||||
DECLARE_XTP_CONTROL(CControlMRU)
|
||||
bool DoesFileExist(CString& sFileName);
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_CONTROLMRU_H
|
||||
@@ -180,7 +180,7 @@ bool ConsoleLineEdit::event(QEvent* ev)
|
||||
|
||||
if (newStr.isEmpty())
|
||||
{
|
||||
newStr = GetIEditor()->GetCommandManager()->AutoComplete(cstring.toUtf8().data());
|
||||
newStr = GetIEditor()->GetCommandManager()->AutoComplete(cstring.toUtf8().data()).c_str();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ void ConsoleLineEdit::keyPressEvent(QKeyEvent* ev)
|
||||
{
|
||||
if (commandManager->IsRegistered(str.toUtf8().data()))
|
||||
{
|
||||
commandManager->Execute(QtUtil::ToString(str));
|
||||
commandManager->Execute(str.toUtf8().data());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -566,15 +566,15 @@ static void OnVariableUpdated([[maybe_unused]] int row, ICVar* pCVar)
|
||||
static CVarBlock* VarBlockFromConsoleVars()
|
||||
{
|
||||
IConsole* console = GetIEditor()->GetSystem()->GetIConsole();
|
||||
std::vector<const char*> cmds;
|
||||
AZStd::vector<AZStd::string_view> cmds;
|
||||
cmds.resize(console->GetNumVars());
|
||||
size_t cmdCount = console->GetSortedVars(&cmds[0], cmds.size());
|
||||
size_t cmdCount = console->GetSortedVars(cmds);
|
||||
|
||||
CVarBlock* vb = new CVarBlock;
|
||||
IVariable* pVariable = nullptr;
|
||||
for (int i = 0; i < cmdCount; i++)
|
||||
{
|
||||
ICVar* pCVar = console->GetCVar(cmds[i]);
|
||||
ICVar* pCVar = console->GetCVar(cmds[i].data());
|
||||
if (!pCVar)
|
||||
{
|
||||
continue;
|
||||
@@ -606,7 +606,7 @@ static CVarBlock* VarBlockFromConsoleVars()
|
||||
pCVar->AddOnChangeFunctor(onChange);
|
||||
|
||||
pVariable->SetDescription(pCVar->GetHelp());
|
||||
pVariable->SetName(cmds[i]);
|
||||
pVariable->SetName(cmds[i].data());
|
||||
|
||||
// Transfer the custom limits have they have been set for this variable
|
||||
if (pCVar->HasCustomLimits())
|
||||
|
||||
@@ -1,543 +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 "ConsoleSCBMFC.h"
|
||||
#include "PropertiesDialog.h"
|
||||
#include "QtViewPaneManager.h"
|
||||
#include "Core/QtEditorApplication.h"
|
||||
|
||||
#include <Controls/ui_ConsoleSCBMFC.h>
|
||||
|
||||
#include <QtUtil.h>
|
||||
#include <QtUtilWin.h>
|
||||
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QScopedPointer>
|
||||
#include <QtCore/QPoint>
|
||||
#include <QtGui/QCursor>
|
||||
#include <QtGui/QMouseEvent>
|
||||
#include <QtWidgets/QStyle>
|
||||
#include <QtWidgets/QStyleFactory>
|
||||
#include <QtWidgets/QMenu>
|
||||
#include <QtWidgets/QScrollBar>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
namespace MFC
|
||||
{
|
||||
|
||||
static CPropertiesDialog* gPropertiesDlg = nullptr;
|
||||
static CString mfc_popup_helper(HWND hwnd, int x, int y);
|
||||
static CConsoleSCB* s_consoleSCB = nullptr;
|
||||
|
||||
static QString RemoveColorCode(const QString& text, int& iColorCode)
|
||||
{
|
||||
QString cleanString;
|
||||
cleanString.reserve(text.size());
|
||||
|
||||
const int textSize = text.size();
|
||||
for (int i = 0; i < textSize; ++i)
|
||||
{
|
||||
QChar c = text.at(i);
|
||||
bool isLast = i == textSize - 1;
|
||||
if (c == '$' && !isLast && text.at(i + 1).isDigit())
|
||||
{
|
||||
if (iColorCode == 0)
|
||||
{
|
||||
iColorCode = text.at(i + 1).digitValue();
|
||||
}
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c == '\r' || c == '\n')
|
||||
{
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
|
||||
cleanString.append(c);
|
||||
}
|
||||
|
||||
return cleanString;
|
||||
}
|
||||
|
||||
ConsoleLineEdit::ConsoleLineEdit(QWidget* parent)
|
||||
: QLineEdit(parent)
|
||||
, m_historyIndex(0)
|
||||
, m_bReusedHistory(false)
|
||||
{
|
||||
}
|
||||
|
||||
void ConsoleLineEdit::mousePressEvent(QMouseEvent* ev)
|
||||
{
|
||||
if (ev->type() == QEvent::MouseButtonPress && ev->button() & Qt::RightButton)
|
||||
{
|
||||
Q_EMIT variableEditorRequested();
|
||||
}
|
||||
|
||||
QLineEdit::mousePressEvent(ev);
|
||||
}
|
||||
|
||||
void ConsoleLineEdit::mouseDoubleClickEvent(QMouseEvent* ev)
|
||||
{
|
||||
Q_EMIT variableEditorRequested();
|
||||
}
|
||||
|
||||
bool ConsoleLineEdit::event(QEvent* ev)
|
||||
{
|
||||
// Tab key doesn't go to keyPressEvent(), must be processed here
|
||||
|
||||
if (ev->type() != QEvent::KeyPress)
|
||||
{
|
||||
return QLineEdit::event(ev);
|
||||
}
|
||||
|
||||
QKeyEvent* ke = static_cast<QKeyEvent*>(ev);
|
||||
if (ke->key() != Qt::Key_Tab)
|
||||
{
|
||||
return QLineEdit::event(ev);
|
||||
}
|
||||
|
||||
QString inputStr = text();
|
||||
QString newStr;
|
||||
|
||||
QStringList tokens = inputStr.split(" ");
|
||||
inputStr = tokens.isEmpty() ? QString() : tokens.first();
|
||||
IConsole* console = GetIEditor()->GetSystem()->GetIConsole();
|
||||
|
||||
const bool ctrlPressed = ke->modifiers() & Qt::ControlModifier;
|
||||
CString cstring = QtUtil::ToCString(inputStr); // TODO: Use QString once the backend stops using QString
|
||||
if (ctrlPressed)
|
||||
{
|
||||
newStr = QtUtil::ToString(console->AutoCompletePrev(cstring));
|
||||
}
|
||||
else
|
||||
{
|
||||
newStr = QtUtil::ToString(console->ProcessCompletion(cstring));
|
||||
newStr = QtUtil::ToString(console->AutoComplete(cstring));
|
||||
|
||||
if (newStr.isEmpty())
|
||||
{
|
||||
newStr = QtUtil::ToQString(GetIEditor()->GetCommandManager()->AutoComplete(QtUtil::ToString(newStr)));
|
||||
}
|
||||
}
|
||||
|
||||
if (!newStr.isEmpty())
|
||||
{
|
||||
newStr += " ";
|
||||
setText(newStr);
|
||||
}
|
||||
|
||||
deselect();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConsoleLineEdit::keyPressEvent(QKeyEvent* ev)
|
||||
{
|
||||
IConsole* console = GetIEditor()->GetSystem()->GetIConsole();
|
||||
auto commandManager = GetIEditor()->GetCommandManager();
|
||||
|
||||
console->ResetAutoCompletion();
|
||||
|
||||
switch (ev->key())
|
||||
{
|
||||
case Qt::Key_Enter:
|
||||
case Qt::Key_Return:
|
||||
{
|
||||
QString str = text().trimmed();
|
||||
if (!str.isEmpty())
|
||||
{
|
||||
if (commandManager->IsRegistered(QtUtil::ToCString(str)))
|
||||
{
|
||||
commandManager->Execute(QtUtil::ToString(str));
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogFile::WriteLine(QtUtil::ToCString(str));
|
||||
GetIEditor()->GetSystem()->GetIConsole()->ExecuteString(QtUtil::ToCString(str));
|
||||
}
|
||||
|
||||
// If a history command was reused directly via up arrow enter, do not reset history index
|
||||
if (m_history.size() > 0 && m_historyIndex < m_history.size() && m_history[m_historyIndex] == str)
|
||||
{
|
||||
m_bReusedHistory = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_historyIndex = m_history.size();
|
||||
}
|
||||
|
||||
// Do not add the same string if it is the top of the stack, but allow duplicate entries otherwise
|
||||
if (m_history.isEmpty() || m_history.back() != str)
|
||||
{
|
||||
m_history.push_back(str);
|
||||
if (!m_bReusedHistory)
|
||||
{
|
||||
m_historyIndex = m_history.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_historyIndex = m_history.size();
|
||||
}
|
||||
|
||||
setText(QString());
|
||||
break;
|
||||
}
|
||||
case Qt::Key_AsciiTilde: // ~
|
||||
case Qt::Key_Agrave: // `
|
||||
// disable log.
|
||||
GetIEditor()->ShowConsole(false);
|
||||
setText(QString());
|
||||
m_historyIndex = m_history.size();
|
||||
break;
|
||||
case Qt::Key_Escape:
|
||||
setText(QString());
|
||||
m_historyIndex = m_history.size();
|
||||
break;
|
||||
case Qt::Key_Up:
|
||||
DisplayHistory(false /*bForward*/);
|
||||
break;
|
||||
case Qt::Key_Down:
|
||||
DisplayHistory(true /*bForward*/);
|
||||
break;
|
||||
default:
|
||||
QLineEdit::keyPressEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
void ConsoleLineEdit::DisplayHistory(bool bForward)
|
||||
{
|
||||
if (m_history.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Immediately after reusing a history entry, ensure up arrow re-displays command just used
|
||||
if (!m_bReusedHistory || bForward)
|
||||
{
|
||||
m_historyIndex = static_cast<unsigned int>(clamp_tpl(static_cast<int>(m_historyIndex) + (bForward ? 1 : -1), 0, m_history.size() - 1));
|
||||
}
|
||||
m_bReusedHistory = false;
|
||||
|
||||
setText(m_history[m_historyIndex]);
|
||||
}
|
||||
|
||||
ConsoleTextEdit::ConsoleTextEdit(QWidget* parent)
|
||||
: QTextEdit(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Lines CConsoleSCB::s_pendingLines;
|
||||
|
||||
CConsoleSCB::CConsoleSCB(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::ConsoleMFC())
|
||||
, m_richEditTextLength(0)
|
||||
, m_backgroundTheme(gSettings.consoleBackgroundColorTheme)
|
||||
{
|
||||
m_lines = s_pendingLines;
|
||||
s_pendingLines.clear();
|
||||
s_consoleSCB = this;
|
||||
ui->setupUi(this);
|
||||
setMinimumHeight(120);
|
||||
|
||||
// Setup the color table for the default (light) theme
|
||||
m_colorTable << QColor(0, 0, 0)
|
||||
<< QColor(0, 0, 0)
|
||||
<< QColor(0, 0, 200) // blue
|
||||
<< QColor(0, 200, 0) // green
|
||||
<< QColor(200, 0, 0) // red
|
||||
<< QColor(0, 200, 200) // cyan
|
||||
<< QColor(128, 112, 0) // yellow
|
||||
<< QColor(200, 0, 200) // red+blue
|
||||
<< QColor(0x000080ff)
|
||||
<< QColor(0x008f8f8f);
|
||||
OnStyleSettingsChanged();
|
||||
|
||||
connect(ui->button, &QPushButton::clicked, this, &CConsoleSCB::showVariableEditor);
|
||||
connect(ui->lineEdit, &MFC::ConsoleLineEdit::variableEditorRequested, this, &MFC::CConsoleSCB::showVariableEditor);
|
||||
connect(Editor::EditorQtApplication::instance(), &Editor::EditorQtApplication::skinChanged, this, &MFC::CConsoleSCB::OnStyleSettingsChanged);
|
||||
|
||||
if (GetIEditor()->IsInConsolewMode())
|
||||
{
|
||||
// Attach / register edit box
|
||||
//CLogFile::AttachEditBox(m_edit.GetSafeHwnd()); // FIXME
|
||||
}
|
||||
}
|
||||
|
||||
CConsoleSCB::~CConsoleSCB()
|
||||
{
|
||||
s_consoleSCB = nullptr;
|
||||
delete gPropertiesDlg;
|
||||
gPropertiesDlg = nullptr;
|
||||
CLogFile::AttachEditBox(nullptr);
|
||||
}
|
||||
|
||||
void CConsoleSCB::RegisterViewClass()
|
||||
{
|
||||
QtViewOptions opts;
|
||||
opts.preferedDockingArea = Qt::BottomDockWidgetArea;
|
||||
opts.isDeletable = false;
|
||||
opts.isStandard = true;
|
||||
opts.showInMenu = true;
|
||||
opts.builtInActionId = ID_VIEW_CONSOLEWINDOW;
|
||||
opts.sendViewPaneNameBackToAmazonAnalyticsServers = true;
|
||||
RegisterQtViewPane<CConsoleSCB>(GetIEditor(), LyViewPane::Console, LyViewPane::CategoryTools, opts);
|
||||
}
|
||||
|
||||
void CConsoleSCB::OnStyleSettingsChanged()
|
||||
{
|
||||
ui->button->setIcon(QIcon(QString(":/controls/img/cvar_dark.bmp")));
|
||||
|
||||
// Set the debug/warning text colors appropriately for the background theme
|
||||
// (e.g. not have black text on black background)
|
||||
QColor textColor = Qt::black;
|
||||
m_backgroundTheme = gSettings.consoleBackgroundColorTheme;
|
||||
if (m_backgroundTheme == SEditorSettings::ConsoleColorTheme::Dark)
|
||||
{
|
||||
textColor = Qt::white;
|
||||
}
|
||||
m_colorTable[0] = textColor;
|
||||
m_colorTable[1] = textColor;
|
||||
|
||||
QColor bgColor;
|
||||
if (!GetIEditor()->IsInConsolewMode() && CConsoleSCB::GetCreatedInstance() && m_backgroundTheme == SEditorSettings::ConsoleColorTheme::Dark)
|
||||
{
|
||||
bgColor = Qt::black;
|
||||
}
|
||||
else
|
||||
{
|
||||
bgColor = Qt::white;
|
||||
}
|
||||
|
||||
ui->textEdit->setStyleSheet(QString("QTextEdit{ background: %1 }").arg(bgColor.name(QColor::HexRgb)));
|
||||
|
||||
// Clear out the console text when we change our background color since
|
||||
// some of the previous text colors may not be appropriate for the
|
||||
// new background color
|
||||
ui->textEdit->clear();
|
||||
}
|
||||
|
||||
void CConsoleSCB::showVariableEditor()
|
||||
{
|
||||
const QPoint cursorPos = QCursor::pos();
|
||||
CString str = mfc_popup_helper(0, cursorPos.x(), cursorPos.y());
|
||||
if (!str.IsEmpty())
|
||||
{
|
||||
ui->lineEdit->setText(QtUtil::ToQString(str));
|
||||
}
|
||||
}
|
||||
|
||||
void CConsoleSCB::SetInputFocus()
|
||||
{
|
||||
ui->lineEdit->setFocus();
|
||||
ui->lineEdit->setText(QString());
|
||||
}
|
||||
|
||||
void CConsoleSCB::AddToConsole(const QString& text, bool bNewLine)
|
||||
{
|
||||
m_lines.push_back({ text, bNewLine });
|
||||
FlushText();
|
||||
}
|
||||
|
||||
void CConsoleSCB::FlushText()
|
||||
{
|
||||
if (m_lines.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Store our current cursor in case we need to restore it, and check if
|
||||
// the user has scrolled the text edit away from the bottom
|
||||
const QTextCursor oldCursor = ui->textEdit->textCursor();
|
||||
QScrollBar* scrollBar = ui->textEdit->verticalScrollBar();
|
||||
const int oldScrollValue = scrollBar->value();
|
||||
bool scrolledOffBottom = oldScrollValue != scrollBar->maximum();
|
||||
|
||||
ui->textEdit->moveCursor(QTextCursor::End);
|
||||
QTextCursor textCursor = ui->textEdit->textCursor();
|
||||
|
||||
while (!m_lines.empty())
|
||||
{
|
||||
ConsoleLine line = m_lines.front();
|
||||
m_lines.pop_front();
|
||||
|
||||
int iColor = 0;
|
||||
QString text = MFC::RemoveColorCode(line.text, iColor);
|
||||
if (iColor < 0 || iColor >= m_colorTable.size())
|
||||
{
|
||||
iColor = 0;
|
||||
}
|
||||
|
||||
if (line.newLine)
|
||||
{
|
||||
text = QtUtil::trimRight(text);
|
||||
text = "\r\n" + text;
|
||||
}
|
||||
|
||||
QTextCharFormat format;
|
||||
const QColor color(m_colorTable[iColor]);
|
||||
format.setForeground(color);
|
||||
|
||||
if (iColor != 0)
|
||||
{
|
||||
format.setFontWeight(QFont::Bold);
|
||||
}
|
||||
|
||||
textCursor.setCharFormat(format);
|
||||
textCursor.insertText(text);
|
||||
}
|
||||
|
||||
// If the user has selected some text in the text edit area or has scrolled
|
||||
// away from the bottom, then restore the previous cursor and keep the scroll
|
||||
// bar in the same location
|
||||
if (oldCursor.hasSelection() || scrolledOffBottom)
|
||||
{
|
||||
ui->textEdit->setTextCursor(oldCursor);
|
||||
scrollBar->setValue(oldScrollValue);
|
||||
}
|
||||
// Otherwise scroll to the bottom so the latest text can be seen
|
||||
else
|
||||
{
|
||||
scrollBar->setValue(scrollBar->maximum());
|
||||
}
|
||||
}
|
||||
|
||||
QSize CConsoleSCB::minimumSizeHint() const
|
||||
{
|
||||
return QSize(-1, -1);
|
||||
}
|
||||
|
||||
QSize CConsoleSCB::sizeHint() const
|
||||
{
|
||||
return QSize(100, 100);
|
||||
}
|
||||
|
||||
/** static */
|
||||
void CConsoleSCB::AddToPendingLines(const QString& text, bool bNewLine)
|
||||
{
|
||||
s_pendingLines.push_back({ text, bNewLine });
|
||||
}
|
||||
|
||||
static CVarBlock* VarBlockFromConsoleVars()
|
||||
{
|
||||
IConsole* console = GetIEditor()->GetSystem()->GetIConsole();
|
||||
std::vector<const char*> cmds;
|
||||
cmds.resize(console->GetNumVars());
|
||||
size_t cmdCount = console->GetSortedVars(&cmds[0], cmds.size());
|
||||
|
||||
CVarBlock* vb = new CVarBlock;
|
||||
IVariable* pVariable = 0;
|
||||
for (int i = 0; i < cmdCount; i++)
|
||||
{
|
||||
ICVar* pCVar = console->GetCVar(cmds[i]);
|
||||
if (!pCVar)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int varType = pCVar->GetType();
|
||||
|
||||
switch (varType)
|
||||
{
|
||||
case CVAR_INT:
|
||||
pVariable = new CVariable<int>();
|
||||
pVariable->Set(pCVar->GetIVal());
|
||||
break;
|
||||
case CVAR_FLOAT:
|
||||
pVariable = new CVariable<float>();
|
||||
pVariable->Set(pCVar->GetFVal());
|
||||
break;
|
||||
case CVAR_STRING:
|
||||
pVariable = new CVariable<CString>();
|
||||
pVariable->Set(pCVar->GetString());
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
pVariable->SetDescription(pCVar->GetHelp());
|
||||
pVariable->SetName(cmds[i]);
|
||||
|
||||
if (pVariable)
|
||||
{
|
||||
vb->AddVariable(pVariable);
|
||||
}
|
||||
}
|
||||
return vb;
|
||||
}
|
||||
|
||||
static void OnConsoleVariableUpdated(IVariable* pVar)
|
||||
{
|
||||
if (!pVar)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CString varName = pVar->GetName();
|
||||
ICVar* pCVar = GetIEditor()->GetSystem()->GetIConsole()->GetCVar(varName);
|
||||
if (!pCVar)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (pVar->GetType() == IVariable::INT)
|
||||
{
|
||||
int val;
|
||||
pVar->Get(val);
|
||||
pCVar->Set(val);
|
||||
}
|
||||
else if (pVar->GetType() == IVariable::FLOAT)
|
||||
{
|
||||
float val;
|
||||
pVar->Get(val);
|
||||
pCVar->Set(val);
|
||||
}
|
||||
else if (pVar->GetType() == IVariable::STRING)
|
||||
{
|
||||
CString val;
|
||||
pVar->Get(val);
|
||||
pCVar->Set(val);
|
||||
}
|
||||
}
|
||||
|
||||
static CString mfc_popup_helper(HWND hwnd, int x, int y)
|
||||
{
|
||||
IConsole* console = GetIEditor()->GetSystem()->GetIConsole();
|
||||
|
||||
TSmartPtr<CVarBlock> vb = VarBlockFromConsoleVars();
|
||||
XmlNodeRef node;
|
||||
if (!gPropertiesDlg)
|
||||
{
|
||||
gPropertiesDlg = new CPropertiesDialog("Console Variables", node, AfxGetMainWnd(), true);
|
||||
}
|
||||
if (!gPropertiesDlg->m_hWnd)
|
||||
{
|
||||
gPropertiesDlg->Create(CPropertiesDialog::IDD, AfxGetMainWnd());
|
||||
gPropertiesDlg->SetUpdateCallback(AZStd::bind(OnConsoleVariableUpdated, AZStd::placeholders::_1));
|
||||
}
|
||||
gPropertiesDlg->ShowWindow(SW_SHOW);
|
||||
gPropertiesDlg->BringWindowToTop();
|
||||
gPropertiesDlg->GetPropertyCtrl()->AddVarBlock(vb);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
CConsoleSCB* CConsoleSCB::GetCreatedInstance()
|
||||
{
|
||||
return s_consoleSCB;
|
||||
}
|
||||
|
||||
} // namespace MFC
|
||||
|
||||
#include <Controls/moc_ConsoleSCBMFC.cpp>
|
||||
@@ -400,7 +400,7 @@ void CFolderTreeCtrl::RemoveEmptyFolderItems(const QString& folder)
|
||||
|
||||
void CFolderTreeCtrl::Edit(const QString& path)
|
||||
{
|
||||
CFileUtil::EditTextFile(QtUtil::ToString(path), 0, IFileUtil::FILE_TYPE_SCRIPT);
|
||||
CFileUtil::EditTextFile(path.toUtf8().data(), 0, IFileUtil::FILE_TYPE_SCRIPT);
|
||||
}
|
||||
|
||||
void CFolderTreeCtrl::ShowInExplorer(const QString& path)
|
||||
|
||||
@@ -132,7 +132,9 @@ void LocalStringPropertyEditor::onEditClicked()
|
||||
if (pMgr->GetLocalizedInfoByIndex(i, sInfo))
|
||||
{
|
||||
item.desc = tr("English Text:\r\n");
|
||||
item.desc += QString::fromWCharArray(Unicode::Convert<wstring>(sInfo.sUtf8TranslatedText).c_str());
|
||||
AZStd::wstring utf8TranslatedTextW;
|
||||
AZStd::to_wstring(utf8TranslatedTextW, sInfo.sUtf8TranslatedText);
|
||||
item.desc += QString::fromWCharArray(utf8TranslatedTextW.c_str());
|
||||
item.name = sInfo.sKey;
|
||||
items.push_back(item);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ private:
|
||||
std::vector<int> keySelectionFlags;
|
||||
_smart_ptr<ISplineBackup> undo;
|
||||
_smart_ptr<ISplineBackup> redo;
|
||||
string id;
|
||||
AZStd::string id;
|
||||
ISplineInterpolator* pSpline;
|
||||
};
|
||||
|
||||
|
||||
@@ -53,8 +53,8 @@ class QRubberBand;
|
||||
class ISplineSet
|
||||
{
|
||||
public:
|
||||
virtual ISplineInterpolator* GetSplineFromID(const string& id) = 0;
|
||||
virtual string GetIDFromSpline(ISplineInterpolator* pSpline) = 0;
|
||||
virtual ISplineInterpolator* GetSplineFromID(const AZStd::string& id) = 0;
|
||||
virtual AZStd::string GetIDFromSpline(ISplineInterpolator* pSpline) = 0;
|
||||
virtual int GetSplineCount() const = 0;
|
||||
virtual int GetKeyCountAtTime(float time, float threshold) const = 0;
|
||||
};
|
||||
|
||||
@@ -206,11 +206,8 @@ namespace
|
||||
|
||||
static void LogToDebug([[maybe_unused]] QtMsgType Type, [[maybe_unused]] const QMessageLogContext& Context, const QString& message)
|
||||
{
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
OutputDebugStringW(L"Qt: ");
|
||||
OutputDebugStringW(reinterpret_cast<const wchar_t*>(message.utf16()));
|
||||
OutputDebugStringW(L"\n");
|
||||
#endif
|
||||
AZ::Debug::Platform::OutputToDebugger("Qt", message.toUtf8().data());
|
||||
AZ::Debug::Platform::OutputToDebugger(nullptr, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
AZ::AllocatorScope<AZ::OSAllocator, AZ::SystemAllocator, AZ::LegacyAllocator, CryStringAllocator> m_allocatorScope;
|
||||
AZ::AllocatorScope<AZ::OSAllocator, AZ::SystemAllocator, AZ::LegacyAllocator> m_allocatorScope;
|
||||
SSystemGlobalEnvironment m_stubEnv;
|
||||
AZ::IO::LocalFileIO m_fileIO;
|
||||
NiceMock<CryPakMock>* m_cryPak;
|
||||
|
||||
+12
-17
@@ -286,7 +286,7 @@ bool CCryDocManager::DoPromptFileName(QString& fileName, [[maybe_unused]] UINT n
|
||||
|
||||
return false;
|
||||
}
|
||||
CCryEditDoc* CCryDocManager::OpenDocumentFile(LPCTSTR lpszFileName, bool bAddToMRU)
|
||||
CCryEditDoc* CCryDocManager::OpenDocumentFile(const char* lpszFileName, bool bAddToMRU)
|
||||
{
|
||||
assert(lpszFileName != nullptr);
|
||||
|
||||
@@ -801,12 +801,12 @@ void CCryEditApp::InitDirectory()
|
||||
// Needed to work with custom memory manager.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CCryEditDoc* CCrySingleDocTemplate::OpenDocumentFile(LPCTSTR lpszPathName, bool bMakeVisible /*= true*/)
|
||||
CCryEditDoc* CCrySingleDocTemplate::OpenDocumentFile(const char* lpszPathName, bool bMakeVisible /*= true*/)
|
||||
{
|
||||
return OpenDocumentFile(lpszPathName, true, bMakeVisible);
|
||||
}
|
||||
|
||||
CCryEditDoc* CCrySingleDocTemplate::OpenDocumentFile(LPCTSTR lpszPathName, bool bAddToMRU, [[maybe_unused]] bool bMakeVisible)
|
||||
CCryEditDoc* CCrySingleDocTemplate::OpenDocumentFile(const char* lpszPathName, bool bAddToMRU, [[maybe_unused]] bool bMakeVisible)
|
||||
{
|
||||
CCryEditDoc* pCurDoc = GetIEditor()->GetDocument();
|
||||
|
||||
@@ -845,7 +845,7 @@ CCryEditDoc* CCrySingleDocTemplate::OpenDocumentFile(LPCTSTR lpszPathName, bool
|
||||
return pCurDoc;
|
||||
}
|
||||
|
||||
CCrySingleDocTemplate::Confidence CCrySingleDocTemplate::MatchDocType(LPCTSTR lpszPathName, CCryEditDoc*& rpDocMatch)
|
||||
CCrySingleDocTemplate::Confidence CCrySingleDocTemplate::MatchDocType(const char* lpszPathName, CCryEditDoc*& rpDocMatch)
|
||||
{
|
||||
assert(lpszPathName != nullptr);
|
||||
rpDocMatch = nullptr;
|
||||
@@ -1864,11 +1864,6 @@ void CCryEditApp::UnregisterEventLoopHook(IEventLoopHook* pHookToRemove)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::LoadFile(QString fileName)
|
||||
{
|
||||
//CEditCommandLineInfo cmdLine;
|
||||
//ProcessCommandLine(cmdinfo);
|
||||
|
||||
//bool bBuilding = false;
|
||||
//CString file = cmdLine.SpanExcluding()
|
||||
if (GetIEditor()->GetViewManager()->GetViewCount() == 0)
|
||||
{
|
||||
return;
|
||||
@@ -3193,7 +3188,7 @@ bool CCryEditApp::CreateLevel(bool& wasCreateLevelOperationCancelled)
|
||||
GetIEditor()->GetDocument()->DeleteTemporaryLevel();
|
||||
}
|
||||
|
||||
if (levelName.length() == 0 || !CryStringUtils::IsValidFileName(levelName.toUtf8().data()))
|
||||
if (levelName.length() == 0 || !AZ::StringFunc::Path::IsValid(levelName.toUtf8().data()))
|
||||
{
|
||||
QMessageBox::critical(AzToolsFramework::GetActiveWindow(), QString(), QObject::tr("Level name is invalid, please choose another name."));
|
||||
return false;
|
||||
@@ -3226,13 +3221,16 @@ bool CCryEditApp::CreateLevel(bool& wasCreateLevelOperationCancelled)
|
||||
DWORD dw = GetLastError();
|
||||
|
||||
#ifdef WIN32
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
wchar_t windowsErrorMessageW[ERROR_LEN];
|
||||
windowsErrorMessageW[0] = L'\0';
|
||||
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
nullptr,
|
||||
dw,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
windowsErrorMessage.data(),
|
||||
windowsErrorMessage.length(), nullptr);
|
||||
windowsErrorMessageW,
|
||||
ERROR_LEN, nullptr);
|
||||
_getcwd(cwd.data(), cwd.length());
|
||||
AZStd::to_string(windowsErrorMessage.data(), ERROR_LEN, windowsErrorMessageW);
|
||||
#else
|
||||
windowsErrorMessage = strerror(dw);
|
||||
cwd = QDir::currentPath().toUtf8();
|
||||
@@ -3306,7 +3304,7 @@ void CCryEditApp::OnOpenSlice()
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CCryEditDoc* CCryEditApp::OpenDocumentFile(LPCTSTR lpszFileName)
|
||||
CCryEditDoc* CCryEditApp::OpenDocumentFile(const char* lpszFileName)
|
||||
{
|
||||
if (m_openingLevel)
|
||||
{
|
||||
@@ -4001,15 +3999,12 @@ struct CryAllocatorsRAII
|
||||
CryAllocatorsRAII()
|
||||
{
|
||||
AZ_Assert(!AZ::AllocatorInstance<AZ::LegacyAllocator>::IsReady(), "Expected allocator to not be initialized, hunt down the static that is initializing it");
|
||||
AZ_Assert(!AZ::AllocatorInstance<CryStringAllocator>::IsReady(), "Expected allocator to not be initialized, hunt down the static that is initializing it");
|
||||
|
||||
AZ::AllocatorInstance<AZ::LegacyAllocator>::Create();
|
||||
AZ::AllocatorInstance<CryStringAllocator>::Create();
|
||||
}
|
||||
|
||||
~CryAllocatorsRAII()
|
||||
{
|
||||
AZ::AllocatorInstance<CryStringAllocator>::Destroy();
|
||||
AZ::AllocatorInstance<AZ::LegacyAllocator>::Destroy();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -174,7 +174,7 @@ public:
|
||||
virtual bool InitInstance();
|
||||
virtual int ExitInstance(int exitCode = 0);
|
||||
virtual bool OnIdle(LONG lCount);
|
||||
virtual CCryEditDoc* OpenDocumentFile(LPCTSTR lpszFileName);
|
||||
virtual CCryEditDoc* OpenDocumentFile(const char* lpszFileName);
|
||||
|
||||
CCryDocManager* GetDocManager() { return m_pDocManager; }
|
||||
|
||||
@@ -448,9 +448,9 @@ public:
|
||||
~CCrySingleDocTemplate() {};
|
||||
// avoid creating another CMainFrame
|
||||
// close other type docs before opening any things
|
||||
virtual CCryEditDoc* OpenDocumentFile(LPCTSTR lpszPathName, bool bAddToMRU, bool bMakeVisible);
|
||||
virtual CCryEditDoc* OpenDocumentFile(LPCTSTR lpszPathName, bool bMakeVisible = true);
|
||||
virtual Confidence MatchDocType(LPCTSTR lpszPathName, CCryEditDoc*& rpDocMatch);
|
||||
virtual CCryEditDoc* OpenDocumentFile(const char* lpszPathName, bool bAddToMRU, bool bMakeVisible);
|
||||
virtual CCryEditDoc* OpenDocumentFile(const char* lpszPathName, bool bMakeVisible = TRUE);
|
||||
virtual Confidence MatchDocType(const char* lpszPathName, CCryEditDoc*& rpDocMatch);
|
||||
|
||||
private:
|
||||
const QMetaObject* m_documentClass = nullptr;
|
||||
@@ -467,7 +467,7 @@ public:
|
||||
virtual void OnFileNew();
|
||||
virtual bool DoPromptFileName(QString& fileName, UINT nIDSTitle,
|
||||
DWORD lFlags, bool bOpenFileDialog, CDocTemplate* pTemplate);
|
||||
virtual CCryEditDoc* OpenDocumentFile(LPCTSTR lpszFileName, bool bAddToMRU);
|
||||
virtual CCryEditDoc* OpenDocumentFile(const char* lpszFileName, bool bAddToMRU);
|
||||
|
||||
QVector<CCrySingleDocTemplate*> m_templateList;
|
||||
};
|
||||
|
||||
@@ -418,8 +418,8 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
|
||||
Audio::AudioSystemRequestBus::BroadcastResult(controlsPath, &Audio::AudioSystemRequestBus::Events::GetControlsPath);
|
||||
QString sAudioLevelPath(controlsPath);
|
||||
sAudioLevelPath += "levels/";
|
||||
string const sLevelNameOnly = PathUtil::GetFileName(fileName.toUtf8().data());
|
||||
sAudioLevelPath += sLevelNameOnly;
|
||||
AZStd::string const sLevelNameOnly = PathUtil::GetFileName(fileName.toUtf8().data());
|
||||
sAudioLevelPath += sLevelNameOnly.c_str();
|
||||
QByteArray path = sAudioLevelPath.toUtf8();
|
||||
Audio::SAudioManagerRequestData<Audio::eAMRT_PARSE_CONTROLS_DATA> oAMData(path, Audio::eADS_LEVEL_SPECIFIC);
|
||||
Audio::SAudioRequest oAudioRequestData;
|
||||
@@ -1909,7 +1909,7 @@ void CCryEditDoc::LogLoadTime(int time) const
|
||||
|
||||
CLogFile::FormatLine("[LevelLoadTime] Level %s loaded in %d seconds", level.toUtf8().data(), time / 1000);
|
||||
#if defined(AZ_PLATFORM_WINDOWS)
|
||||
SetFileAttributes(filename.toUtf8().data(), FILE_ATTRIBUTE_ARCHIVE);
|
||||
SetFileAttributesW(filename.toStdWString().c_str(), FILE_ATTRIBUTE_ARCHIVE);
|
||||
#endif
|
||||
|
||||
QFile file(filename);
|
||||
@@ -2134,7 +2134,7 @@ void CCryEditDoc::OnEnvironmentPropertyChanged(IVariable* pVar)
|
||||
childNode->setAttr("value", childValue.toUtf8().data());
|
||||
}
|
||||
|
||||
QString CCryEditDoc::GetCryIndexPath(const LPCTSTR levelFilePath) const
|
||||
QString CCryEditDoc::GetCryIndexPath(const char* levelFilePath) const
|
||||
{
|
||||
QString levelPath = Path::GetPath(levelFilePath);
|
||||
QString levelName = Path::GetFileName(levelFilePath);
|
||||
|
||||
@@ -180,7 +180,7 @@ protected:
|
||||
void OnStartLevelResourceList();
|
||||
static void OnValidateSurfaceTypesChanged(ICVar*);
|
||||
|
||||
QString GetCryIndexPath(const LPCTSTR levelFilePath) const;
|
||||
QString GetCryIndexPath(const char* levelFilePath) const;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// SliceEditorEntityOwnershipServiceNotificationBus::Handler
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace
|
||||
const char* PyGetCurrentLevelName()
|
||||
{
|
||||
// Using static member to capture temporary data
|
||||
static string tempLevelName;
|
||||
static AZ::IO::FixedMaxPathString tempLevelName;
|
||||
tempLevelName = GetIEditor()->GetGameEngine()->GetLevelName().toUtf8().data();
|
||||
return tempLevelName.c_str();
|
||||
}
|
||||
@@ -218,7 +218,7 @@ namespace
|
||||
const char* PyGetCurrentLevelPath()
|
||||
{
|
||||
// Using static member to capture temporary data
|
||||
static string tempLevelPath;
|
||||
static AZ::IO::FixedMaxPathString tempLevelPath;
|
||||
tempLevelPath = GetIEditor()->GetGameEngine()->GetLevelPath().toUtf8().data();
|
||||
return tempLevelPath.c_str();
|
||||
}
|
||||
|
||||
@@ -55,10 +55,10 @@ bool CEditorFileMonitor::RegisterListener(IFileChangeListener* pListener, const
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static string CanonicalizePath(const char* path)
|
||||
static AZStd::string CanonicalizePath(const char* path)
|
||||
{
|
||||
auto canon = QFileInfo(path).canonicalFilePath();
|
||||
return canon.isEmpty() ? string(path) : string(canon.toUtf8());
|
||||
return canon.isEmpty() ? AZStd::string(path) : AZStd::string(canon.toUtf8());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -66,8 +66,8 @@ bool CEditorFileMonitor::RegisterListener(IFileChangeListener* pListener, const
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
string gameFolder = Path::GetEditingGameDataFolder().c_str();
|
||||
string naivePath;
|
||||
AZStd::string gameFolder = Path::GetEditingGameDataFolder().c_str();
|
||||
AZStd::string naivePath;
|
||||
CFileChangeMonitor* fileChangeMonitor = CFileChangeMonitor::Instance();
|
||||
AZ_Assert(fileChangeMonitor, "CFileChangeMonitor singleton missing.");
|
||||
|
||||
@@ -75,12 +75,12 @@ bool CEditorFileMonitor::RegisterListener(IFileChangeListener* pListener, const
|
||||
// Append slash in preparation for appending the second part.
|
||||
naivePath = PathUtil::AddSlash(naivePath);
|
||||
naivePath += sFolderRelativeToGame;
|
||||
naivePath.replace('/', '\\');
|
||||
AZ::StringFunc::Replace(naivePath, '/', '\\');
|
||||
|
||||
// Remove the final slash if the given item is a folder so the file change monitor correctly picks up on it.
|
||||
naivePath = PathUtil::RemoveSlash(naivePath);
|
||||
|
||||
string canonicalizedPath = CanonicalizePath(naivePath.c_str());
|
||||
AZStd::string canonicalizedPath = CanonicalizePath(naivePath.c_str());
|
||||
|
||||
if (fileChangeMonitor->IsDirectory(canonicalizedPath.c_str()) || fileChangeMonitor->IsFile(canonicalizedPath.c_str()))
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace
|
||||
SEfResTexture* pTex = pRes->GetTextureResource(nSlot);
|
||||
if (pTex)
|
||||
{
|
||||
cry_strcat(outName, Path::GamePathToFullPath(pTex->m_Name.c_str()).toUtf8().data());
|
||||
azstrcat(outName, AZ_ARRAY_SIZE(outName), Path::GamePathToFullPath(pTex->m_Name.c_str()).toUtf8().data());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ Export::CObject::CObject(const char* pName)
|
||||
|
||||
nParent = -1;
|
||||
|
||||
cry_strcpy(name, pName);
|
||||
azstrcpy(name, AZ_ARRAY_SIZE(name), pName);
|
||||
|
||||
materialName[0] = '\0';
|
||||
|
||||
@@ -101,7 +101,7 @@ Export::CObject::CObject(const char* pName)
|
||||
|
||||
void Export::CObject::SetMaterialName(const char* pName)
|
||||
{
|
||||
cry_strcpy(materialName, pName);
|
||||
azstrcpy(materialName, AZ_ARRAY_SIZE(materialName), pName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -378,14 +378,14 @@ void CGameExporter::ExportFileList(const QString& path, const QString& levelName
|
||||
{
|
||||
// process the folder of the specified map name, producing a filelist.xml file
|
||||
// that can later be used for map downloads
|
||||
string newpath;
|
||||
AZStd::string newpath;
|
||||
|
||||
QString filename = levelName;
|
||||
string mapname = (filename + ".dds").toUtf8().data();
|
||||
string metaname = (filename + ".xml").toUtf8().data();
|
||||
AZStd::string filename = levelName.toUtf8().data();
|
||||
AZStd::string mapname = (filename + ".dds");
|
||||
AZStd::string metaname = (filename + ".xml");
|
||||
|
||||
XmlNodeRef rootNode = gEnv->pSystem->CreateXmlNode("download");
|
||||
rootNode->setAttr("name", filename.toUtf8().data());
|
||||
rootNode->setAttr("name", filename.c_str());
|
||||
rootNode->setAttr("type", "Map");
|
||||
XmlNodeRef indexNode = rootNode->newChild("index");
|
||||
if (indexNode)
|
||||
@@ -434,9 +434,9 @@ void CGameExporter::ExportFileList(const QString& path, const QString& levelName
|
||||
newFileNode->setAttr("size", handle.m_fileDesc.nSize);
|
||||
|
||||
unsigned char md5[16];
|
||||
string filenameToHash = GetIEditor()->GetGameEngine()->GetLevelPath().toUtf8().data();
|
||||
AZStd::string filenameToHash = GetIEditor()->GetGameEngine()->GetLevelPath().toUtf8().data();
|
||||
filenameToHash += "/";
|
||||
filenameToHash += string{ handle.m_filename.data(), handle.m_filename.size() };
|
||||
filenameToHash += AZStd::string{ handle.m_filename.data(), handle.m_filename.size() };
|
||||
if (gEnv->pCryPak->ComputeMD5(filenameToHash.data(), md5))
|
||||
{
|
||||
char md5string[33];
|
||||
|
||||
@@ -91,20 +91,6 @@ void CGenericSelectItemDialog::ReloadTree()
|
||||
|
||||
QTreeWidgetItem* hSelected = nullptr;
|
||||
|
||||
/*
|
||||
std::vector<CString>::const_iterator iter = m_items.begin();
|
||||
while (iter != m_items.end())
|
||||
{
|
||||
const CString& itemName = *iter;
|
||||
HTREEITEM hItem = m_tree.InsertItem(itemName, 0, 0, TVI_ROOT, TVI_SORT);
|
||||
if (!m_preselect.IsEmpty() && m_preselect.CompareNoCase(itemName) == 0)
|
||||
{
|
||||
hSelected = hItem;
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
*/
|
||||
|
||||
std::map<QString, QTreeWidgetItem*, less_qstring_icmp> items;
|
||||
|
||||
QRegularExpression sep(QStringLiteral("[\\/.") + m_treeSeparator + QStringLiteral("]+"));
|
||||
|
||||
+19
-16
@@ -26,6 +26,7 @@ AZ_POP_DISABLE_WARNING
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/JSON/document.h>
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
// AzFramework
|
||||
#include <AzFramework/Terrain/TerrainDataRequestBus.h>
|
||||
@@ -1107,16 +1108,18 @@ void CEditorImpl::DetectVersion()
|
||||
DWORD dwHandle;
|
||||
UINT len;
|
||||
|
||||
char ver[1024 * 8];
|
||||
wchar_t ver[1024 * 8];
|
||||
|
||||
GetModuleFileName(nullptr, exe, _MAX_PATH);
|
||||
AZ::Utils::GetExecutablePath(exe, _MAX_PATH);
|
||||
AZStd::wstring exeW;
|
||||
AZStd::to_wstring(exeW, exe);
|
||||
|
||||
int verSize = GetFileVersionInfoSize(exe, &dwHandle);
|
||||
int verSize = GetFileVersionInfoSizeW(exeW.c_str(), &dwHandle);
|
||||
if (verSize > 0)
|
||||
{
|
||||
GetFileVersionInfo(exe, dwHandle, 1024 * 8, ver);
|
||||
GetFileVersionInfoW(exeW.c_str(), dwHandle, 1024 * 8, ver);
|
||||
VS_FIXEDFILEINFO* vinfo;
|
||||
VerQueryValue(ver, "\\", (void**)&vinfo, &len);
|
||||
VerQueryValueW(ver, L"\\", (void**)&vinfo, &len);
|
||||
|
||||
m_fileVersion.v[0] = vinfo->dwFileVersionLS & 0xFFFF;
|
||||
m_fileVersion.v[1] = vinfo->dwFileVersionLS >> 16;
|
||||
@@ -1557,31 +1560,31 @@ IExportManager* CEditorImpl::GetExportManager()
|
||||
void CEditorImpl::AddUIEnums()
|
||||
{
|
||||
// Spec settings for shadow casting lights
|
||||
string SpecString[4];
|
||||
AZStd::string SpecString[4];
|
||||
QStringList types;
|
||||
types.push_back("Never=0");
|
||||
SpecString[0].Format("VeryHigh Spec=%d", CONFIG_VERYHIGH_SPEC);
|
||||
SpecString[0] = AZStd::string::format("VeryHigh Spec=%d", CONFIG_VERYHIGH_SPEC);
|
||||
types.push_back(SpecString[0].c_str());
|
||||
SpecString[1].Format("High Spec=%d", CONFIG_HIGH_SPEC);
|
||||
SpecString[1] = AZStd::string::format("High Spec=%d", CONFIG_HIGH_SPEC);
|
||||
types.push_back(SpecString[1].c_str());
|
||||
SpecString[2].Format("Medium Spec=%d", CONFIG_MEDIUM_SPEC);
|
||||
SpecString[2] = AZStd::string::format("Medium Spec=%d", CONFIG_MEDIUM_SPEC);
|
||||
types.push_back(SpecString[2].c_str());
|
||||
SpecString[3].Format("Low Spec=%d", CONFIG_LOW_SPEC);
|
||||
SpecString[3] = AZStd::string::format("Low Spec=%d", CONFIG_LOW_SPEC);
|
||||
types.push_back(SpecString[3].c_str());
|
||||
m_pUIEnumsDatabase->SetEnumStrings("CastShadows", types);
|
||||
|
||||
// Power-of-two percentages
|
||||
string percentStringPOT[5];
|
||||
AZStd::string percentStringPOT[5];
|
||||
types.clear();
|
||||
percentStringPOT[0].Format("Default=%d", 0);
|
||||
percentStringPOT[0] = AZStd::string::format("Default=%d", 0);
|
||||
types.push_back(percentStringPOT[0].c_str());
|
||||
percentStringPOT[1].Format("12.5=%d", 1);
|
||||
percentStringPOT[1] = AZStd::string::format("12.5=%d", 1);
|
||||
types.push_back(percentStringPOT[1].c_str());
|
||||
percentStringPOT[2].Format("25=%d", 2);
|
||||
percentStringPOT[2] = AZStd::string::format("25=%d", 2);
|
||||
types.push_back(percentStringPOT[2].c_str());
|
||||
percentStringPOT[3].Format("50=%d", 3);
|
||||
percentStringPOT[3] = AZStd::string::format("50=%d", 3);
|
||||
types.push_back(percentStringPOT[3].c_str());
|
||||
percentStringPOT[4].Format("100=%d", 4);
|
||||
percentStringPOT[4] = AZStd::string::format("100=%d", 4);
|
||||
types.push_back(percentStringPOT[4].c_str());
|
||||
m_pUIEnumsDatabase->SetEnumStrings("ShadowMinResPercent", types);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "Util/EditorUtils.h"
|
||||
|
||||
inline string ToString(const QString& s)
|
||||
inline AZStd::string ToString(const QString& s)
|
||||
{
|
||||
return s.toUtf8().data();
|
||||
}
|
||||
@@ -27,10 +27,10 @@ class CCommand
|
||||
{
|
||||
public:
|
||||
CCommand(
|
||||
const string& module,
|
||||
const string& name,
|
||||
const string& description,
|
||||
const string& example)
|
||||
const AZStd::string& module,
|
||||
const AZStd::string& name,
|
||||
const AZStd::string& description,
|
||||
const AZStd::string& example)
|
||||
: m_module(module)
|
||||
, m_name(name)
|
||||
, m_description(description)
|
||||
@@ -79,20 +79,20 @@ public:
|
||||
}
|
||||
int GetArgCount() const
|
||||
{ return m_args.size(); }
|
||||
const string& GetArg(int i) const
|
||||
const AZStd::string& GetArg(int i) const
|
||||
{
|
||||
assert(0 <= i && i < GetArgCount());
|
||||
return m_args[i];
|
||||
}
|
||||
private:
|
||||
DynArray<string> m_args;
|
||||
DynArray<AZStd::string> m_args;
|
||||
unsigned char m_stringFlags; // This is needed to quote string parameters when logging a command.
|
||||
};
|
||||
|
||||
const string& GetName() const { return m_name; }
|
||||
const string& GetModule() const { return m_module; }
|
||||
const string& GetDescription() const { return m_description; }
|
||||
const string& GetExample() const { return m_example; }
|
||||
const AZStd::string& GetName() const { return m_name; }
|
||||
const AZStd::string& GetModule() const { return m_module; }
|
||||
const AZStd::string& GetDescription() const { return m_description; }
|
||||
const AZStd::string& GetExample() const { return m_example; }
|
||||
|
||||
void SetAvailableInScripting() { m_bAlsoAvailableInScripting = true; };
|
||||
bool IsAvailableInScripting() const { return m_bAlsoAvailableInScripting; }
|
||||
@@ -104,15 +104,15 @@ public:
|
||||
|
||||
protected:
|
||||
friend class CEditorCommandManager;
|
||||
string m_module;
|
||||
string m_name;
|
||||
string m_description;
|
||||
string m_example;
|
||||
AZStd::string m_module;
|
||||
AZStd::string m_name;
|
||||
AZStd::string m_description;
|
||||
AZStd::string m_example;
|
||||
bool m_bAlsoAvailableInScripting;
|
||||
|
||||
template <typename T>
|
||||
static string ToString_(T t) { return ::ToString(t); }
|
||||
static inline string ToString_(const char* val)
|
||||
static AZStd::string ToString_(T t) { return ::ToString(t); }
|
||||
static inline AZStd::string ToString_(const char* val)
|
||||
{ return val; }
|
||||
template <typename T>
|
||||
static bool FromString_(T& t, const char* s) { return ::FromString(t, s); }
|
||||
@@ -137,8 +137,8 @@ class CCommand0
|
||||
: public CCommand
|
||||
{
|
||||
public:
|
||||
CCommand0(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand0(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<void()>& functor)
|
||||
: CCommand(module, name, description, example)
|
||||
, m_functor(functor) {}
|
||||
@@ -146,10 +146,10 @@ public:
|
||||
// UI metadata for this command, if any
|
||||
struct SUIInfo
|
||||
{
|
||||
string caption;
|
||||
string tooltip;
|
||||
string description;
|
||||
string iconFilename;
|
||||
AZStd::string caption;
|
||||
AZStd::string tooltip;
|
||||
AZStd::string description;
|
||||
AZStd::string iconFilename;
|
||||
int iconIndex;
|
||||
int commandId; // Windows command id
|
||||
|
||||
@@ -179,8 +179,8 @@ class CCommand0wRet
|
||||
: public CCommand
|
||||
{
|
||||
public:
|
||||
CCommand0wRet(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand0wRet(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<RT()>& functor);
|
||||
|
||||
QString Execute(const CArgs& args);
|
||||
@@ -195,8 +195,8 @@ class CCommand1
|
||||
: public CCommand
|
||||
{
|
||||
public:
|
||||
CCommand1(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand1(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<void(LIST(1, P))>& functor);
|
||||
|
||||
QString Execute(const CArgs& args);
|
||||
@@ -211,8 +211,8 @@ class CCommand1wRet
|
||||
: public CCommand
|
||||
{
|
||||
public:
|
||||
CCommand1wRet(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand1wRet(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<RT(LIST(1, P))>& functor);
|
||||
|
||||
QString Execute(const CArgs& args);
|
||||
@@ -227,8 +227,8 @@ class CCommand2
|
||||
: public CCommand
|
||||
{
|
||||
public:
|
||||
CCommand2(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand2(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<void(LIST(2, P))>& functor);
|
||||
|
||||
QString Execute(const CArgs& args);
|
||||
@@ -243,8 +243,8 @@ class CCommand2wRet
|
||||
: public CCommand
|
||||
{
|
||||
public:
|
||||
CCommand2wRet(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand2wRet(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<RT(LIST(2, P))>& functor);
|
||||
|
||||
QString Execute(const CArgs& args);
|
||||
@@ -259,8 +259,8 @@ class CCommand3
|
||||
: public CCommand
|
||||
{
|
||||
public:
|
||||
CCommand3(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand3(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<void(LIST(3, P))>& functor);
|
||||
|
||||
QString Execute(const CArgs& args);
|
||||
@@ -275,8 +275,8 @@ class CCommand3wRet
|
||||
: public CCommand
|
||||
{
|
||||
public:
|
||||
CCommand3wRet(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand3wRet(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<RT(LIST(3, P))>& functor);
|
||||
|
||||
QString Execute(const CArgs& args);
|
||||
@@ -291,8 +291,8 @@ class CCommand4
|
||||
: public CCommand
|
||||
{
|
||||
public:
|
||||
CCommand4(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand4(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<void(LIST(4, P))>& functor);
|
||||
|
||||
QString Execute(const CArgs& args);
|
||||
@@ -307,8 +307,8 @@ class CCommand4wRet
|
||||
: public CCommand
|
||||
{
|
||||
public:
|
||||
CCommand4wRet(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand4wRet(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<RT(LIST(4, P))>& functor);
|
||||
|
||||
QString Execute(const CArgs& args);
|
||||
@@ -323,8 +323,8 @@ class CCommand5
|
||||
: public CCommand
|
||||
{
|
||||
public:
|
||||
CCommand5(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand5(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<void(LIST(5, P))>& functor);
|
||||
|
||||
QString Execute(const CArgs& args);
|
||||
@@ -339,8 +339,8 @@ class CCommand6
|
||||
: public CCommand
|
||||
{
|
||||
public:
|
||||
CCommand6(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand6(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<void(LIST(6, P))>& functor);
|
||||
|
||||
QString Execute(const CArgs& args);
|
||||
@@ -353,8 +353,8 @@ protected:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename RT>
|
||||
CCommand0wRet<RT>::CCommand0wRet(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand0wRet<RT>::CCommand0wRet(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<RT()>& functor)
|
||||
: CCommand(module, name, description, example)
|
||||
, m_functor(functor)
|
||||
@@ -373,8 +373,8 @@ QString CCommand0wRet<RT>::Execute(const CCommand::CArgs& args)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <LIST(1, typename P)>
|
||||
CCommand1<LIST(1, P)>::CCommand1(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand1<LIST(1, P)>::CCommand1(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<void(LIST(1, P))>& functor)
|
||||
: CCommand(module, name, description, example)
|
||||
, m_functor(functor)
|
||||
@@ -410,8 +410,8 @@ QString CCommand1<LIST(1, P)>::Execute(const CCommand::CArgs& args)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <LIST(1, typename P), typename RT>
|
||||
CCommand1wRet<LIST(1, P), RT>::CCommand1wRet(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand1wRet<LIST(1, P), RT>::CCommand1wRet(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<RT(LIST(1, P))>& functor)
|
||||
: CCommand(module, name, description, example)
|
||||
, m_functor(functor)
|
||||
@@ -448,8 +448,8 @@ QString CCommand1wRet<LIST(1, P), RT>::Execute(const CCommand::CArgs& args)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <LIST(2, typename P)>
|
||||
CCommand2<LIST(2, P)>::CCommand2(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand2<LIST(2, P)>::CCommand2(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<void(LIST(2, P))>& functor)
|
||||
: CCommand(module, name, description, example)
|
||||
, m_functor(functor)
|
||||
@@ -487,8 +487,8 @@ QString CCommand2<LIST(2, P)>::Execute(const CCommand::CArgs& args)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <LIST(2, typename P), typename RT>
|
||||
CCommand2wRet<LIST(2, P), RT>::CCommand2wRet(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand2wRet<LIST(2, P), RT>::CCommand2wRet(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<RT(LIST(2, P))>& functor)
|
||||
: CCommand(module, name, description, example)
|
||||
, m_functor(functor)
|
||||
@@ -527,8 +527,8 @@ QString CCommand2wRet<LIST(2, P), RT>::Execute(const CCommand::CArgs& args)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <LIST(3, typename P)>
|
||||
CCommand3<LIST(3, P)>::CCommand3(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand3<LIST(3, P)>::CCommand3(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<void(LIST(3, P))>& functor)
|
||||
: CCommand(module, name, description, example)
|
||||
, m_functor(functor)
|
||||
@@ -568,8 +568,8 @@ QString CCommand3<LIST(3, P)>::Execute(const CCommand::CArgs& args)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <LIST(3, typename P), typename RT>
|
||||
CCommand3wRet<LIST(3, P), RT>::CCommand3wRet(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand3wRet<LIST(3, P), RT>::CCommand3wRet(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<RT(LIST(3, P))>& functor)
|
||||
: CCommand(module, name, description, example)
|
||||
, m_functor(functor)
|
||||
@@ -610,8 +610,8 @@ QString CCommand3wRet<LIST(3, P), RT>::Execute(const CCommand::CArgs& args)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <LIST(4, typename P)>
|
||||
CCommand4<LIST(4, P)>::CCommand4(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand4<LIST(4, P)>::CCommand4(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<void(LIST(4, P))>& functor)
|
||||
: CCommand(module, name, description, example)
|
||||
, m_functor(functor)
|
||||
@@ -654,8 +654,8 @@ QString CCommand4<LIST(4, P)>::Execute(const CCommand::CArgs& args)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <LIST(4, typename P), typename RT>
|
||||
CCommand4wRet<LIST(4, P), RT>::CCommand4wRet(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand4wRet<LIST(4, P), RT>::CCommand4wRet(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<RT(LIST(4, P))>& functor)
|
||||
: CCommand(module, name, description, example)
|
||||
, m_functor(functor)
|
||||
@@ -699,8 +699,8 @@ QString CCommand4wRet<LIST(4, P), RT>::Execute(const CCommand::CArgs& args)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <LIST(5, typename P)>
|
||||
CCommand5<LIST(5, P)>::CCommand5(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand5<LIST(5, P)>::CCommand5(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<void(LIST(5, P))>& functor)
|
||||
: CCommand(module, name, description, example)
|
||||
, m_functor(functor)
|
||||
@@ -745,8 +745,8 @@ QString CCommand5<LIST(5, P)>::Execute(const CCommand::CArgs& args)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <LIST(6, typename P)>
|
||||
CCommand6<LIST(6, P)>::CCommand6(const string& module, const string& name,
|
||||
const string& description, const string& example,
|
||||
CCommand6<LIST(6, P)>::CCommand6(const AZStd::string& module, const AZStd::string& name,
|
||||
const AZStd::string& description, const AZStd::string& example,
|
||||
const AZStd::function<void(LIST(6, P))>& functor)
|
||||
: CCommand(module, name, description, example)
|
||||
, m_functor(functor)
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "StringUtils.h"
|
||||
#include "../Include/SandboxAPI.h"
|
||||
|
||||
class QWidget;
|
||||
|
||||
@@ -98,7 +98,7 @@ CLevelFileDialog::CLevelFileDialog(bool openDialog, QWidget* parent)
|
||||
connect(ui->nameLineEdit, &QLineEdit::textChanged, this, &CLevelFileDialog::OnNameChanged);
|
||||
}
|
||||
|
||||
// reject invalid file names (see CryStringUtils::IsValidFileName)
|
||||
// reject invalid file names
|
||||
ui->nameLineEdit->setValidator(new QRegExpValidator(QRegExp("^[a-zA-Z0-9_\\-./]*$"), ui->nameLineEdit));
|
||||
|
||||
ReloadTree();
|
||||
@@ -315,7 +315,7 @@ void CLevelFileDialog::OnNewFolder()
|
||||
const QString newFolderName = inputDlg.textValue();
|
||||
const QString newFolderPath = parentFullPath + "/" + newFolderName;
|
||||
|
||||
if (!CryStringUtils::IsValidFileName(newFolderName.toUtf8().data()))
|
||||
if (!AZ::StringFunc::Path::IsValid(newFolderName.toUtf8().data()))
|
||||
{
|
||||
QMessageBox box(this);
|
||||
box.setText(tr("Please enter a single, valid folder name(standard English alphanumeric characters only)"));
|
||||
@@ -416,7 +416,7 @@ bool CLevelFileDialog::ValidateSaveLevelPath(QString& errorMessage) const
|
||||
const QString enteredPath = GetEnteredPath();
|
||||
const QString levelPath = GetLevelPath();
|
||||
|
||||
if (!CryStringUtils::IsValidFileName(Path::GetFileName(levelPath).toUtf8().data()))
|
||||
if (!AZ::StringFunc::Path::IsValid(Path::GetFileName(levelPath).toUtf8().data()))
|
||||
{
|
||||
errorMessage = tr("Please enter a valid level name (standard English alphanumeric characters only)");
|
||||
return false;
|
||||
|
||||
+15
-14
@@ -180,14 +180,14 @@ void CLogFile::FormatLineV(const char * format, va_list argList)
|
||||
void CLogFile::AboutSystem()
|
||||
{
|
||||
char szBuffer[MAX_LOGBUFFER_SIZE];
|
||||
wchar_t szBufferW[MAX_LOGBUFFER_SIZE];
|
||||
#if defined(AZ_PLATFORM_WINDOWS) || defined(AZ_PLATFORM_LINUX)
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Write the system informations to the log
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
char szProfileBuffer[128];
|
||||
char szLanguageBuffer[64];
|
||||
//char szCPUModel[64];
|
||||
wchar_t szLanguageBufferW[64];
|
||||
//wchar_t szCPUModel[64];
|
||||
MEMORYSTATUS MemoryStatus;
|
||||
#endif // defined(AZ_PLATFORM_WINDOWS) || defined(AZ_PLATFORM_LINUX)
|
||||
|
||||
@@ -201,11 +201,13 @@ void CLogFile::AboutSystem()
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Get system language
|
||||
GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SENGLANGUAGE,
|
||||
szLanguageBuffer, sizeof(szLanguageBuffer));
|
||||
GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT, LOCALE_SENGLANGUAGE,
|
||||
szLanguageBufferW, sizeof(szLanguageBufferW));
|
||||
AZStd::string szLanguageBuffer;
|
||||
AZStd::to_string(szLanguageBuffer, szLanguageBufferW);
|
||||
|
||||
// Format and send OS information line
|
||||
azsnprintf(szBuffer, MAX_LOGBUFFER_SIZE, "Current Language: %s ", szLanguageBuffer);
|
||||
azsnprintf(szBuffer, MAX_LOGBUFFER_SIZE, "Current Language: %s ", szLanguageBuffer.c_str());
|
||||
CryLog("%s", szBuffer);
|
||||
#else
|
||||
QLocale locale;
|
||||
@@ -294,7 +296,8 @@ AZ_POP_DISABLE_WARNING
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
str += " (";
|
||||
GetWindowsDirectory(szBuffer, sizeof(szBuffer));
|
||||
GetWindowsDirectoryW(szBufferW, sizeof(szBufferW));
|
||||
AZStd::to_string(szBuffer, MAX_LOGBUFFER_SIZE, szBufferW);
|
||||
str += szBuffer;
|
||||
str += ")";
|
||||
CryLog("%s", str.toUtf8().data());
|
||||
@@ -381,12 +384,13 @@ AZ_POP_DISABLE_WARNING
|
||||
|
||||
#if defined(AZ_PLATFORM_WINDOWS)
|
||||
EnumDisplaySettings(nullptr, ENUM_CURRENT_SETTINGS, &DisplayConfig);
|
||||
GetPrivateProfileString("boot.description", "display.drv",
|
||||
"(Unknown graphics card)", szProfileBuffer, sizeof(szProfileBuffer),
|
||||
"system.ini");
|
||||
GetPrivateProfileStringW(L"boot.description", L"display.drv",
|
||||
L"(Unknown graphics card)", szLanguageBufferW, sizeof(szLanguageBufferW),
|
||||
L"system.ini");
|
||||
AZStd::to_string(szLanguageBuffer, szLanguageBufferW);
|
||||
azsnprintf(szBuffer, MAX_LOGBUFFER_SIZE, "Current display mode is %dx%dx%d, %s",
|
||||
DisplayConfig.dmPelsWidth, DisplayConfig.dmPelsHeight,
|
||||
DisplayConfig.dmBitsPerPel, szProfileBuffer);
|
||||
DisplayConfig.dmBitsPerPel, szLanguageBuffer.c_str());
|
||||
CryLog("%s", szBuffer);
|
||||
#else
|
||||
auto screen = QGuiApplication::primaryScreen();
|
||||
@@ -568,9 +572,6 @@ void CLogFile::OnWriteToConsole(const char* sText, bool bNewLine)
|
||||
}
|
||||
if (bNewLine)
|
||||
{
|
||||
//str = CString("\r\n") + str.TrimLeft();
|
||||
//str = CString("\r\n") + str;
|
||||
//str = CString("\r") + str;
|
||||
str = QString("\r\n") + str;
|
||||
str = str.trimmed();
|
||||
}
|
||||
|
||||
@@ -1687,7 +1687,7 @@ void MainWindow::OnUpdateConnectionStatus()
|
||||
|
||||
status = tr("Pending Jobs : %1 Failed Jobs : %2").arg(m_connectionListener->GetJobsCount()).arg(failureCount);
|
||||
|
||||
statusBar->SetItem(QtUtil::ToQString("connection"), status, tooltip, icon);
|
||||
statusBar->SetItem("connection", status, tooltip, icon);
|
||||
|
||||
if (m_showAPDisconnectDialog && m_connectionListener->GetState() != EConnectionState::Connected)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ bool CMailer::SendMail(const char* subject,
|
||||
GetCurrentDirectoryW(sizeof(dir), dir);
|
||||
|
||||
// Load MAPI dll
|
||||
HMODULE hMAPILib = LoadLibraryA("MAPI32.DLL");
|
||||
HMODULE hMAPILib = LoadLibraryW(L"MAPI32.DLL");
|
||||
LPMAPISENDMAIL lpfnMAPISendMail = (LPMAPISENDMAIL) GetProcAddress(hMAPILib, "MAPISendMail");
|
||||
|
||||
int numRecipients = (int)_recipients.size();
|
||||
@@ -60,11 +60,11 @@ bool CMailer::SendMail(const char* subject,
|
||||
// Handle Recipients
|
||||
MapiRecipDesc* recipients = new MapiRecipDesc[numRecipients];
|
||||
|
||||
std::vector<string> addresses;
|
||||
std::vector<AZStd::string> addresses;
|
||||
addresses.resize(numRecipients);
|
||||
for (i = 0; i < numRecipients; i++)
|
||||
{
|
||||
addresses[i] = string("SMTP:") + _recipients[i];
|
||||
addresses[i] = AZStd::string("SMTP:") + _recipients[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < numRecipients; i++)
|
||||
|
||||
@@ -125,8 +125,8 @@ namespace
|
||||
|
||||
bool CPluginManager::LoadPlugins(const char* pPathWithMask)
|
||||
{
|
||||
QString strPath = QtUtil::ToQString(PathUtil::GetPath(pPathWithMask));
|
||||
QString strMask = QString::fromUtf8(PathUtil::GetFile(pPathWithMask));
|
||||
QString strPath = PathUtil::GetPath(pPathWithMask).c_str();
|
||||
QString strMask = PathUtil::GetFile(pPathWithMask);
|
||||
|
||||
CLogFile::WriteLine("[Plugin Manager] Loading plugins...");
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
return m_editor;
|
||||
}
|
||||
|
||||
const string& GetToolName() const
|
||||
const AZStd::string& GetToolName() const
|
||||
{
|
||||
return m_toolName;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ private:
|
||||
IEditor* const m_editor;
|
||||
|
||||
// Tool name
|
||||
string m_toolName;
|
||||
AZStd::string m_toolName;
|
||||
|
||||
// Context provider for the Asset Browser
|
||||
AZ::AssetBrowserContextProvider m_assetBrowserContextProvider;
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
|
||||
#include "FFMPEGPlugin.h"
|
||||
#include "CryString.h"
|
||||
typedef CryStringT<char> string;
|
||||
#include "Include/ICommandManager.h"
|
||||
#include "Util/PathUtil.h"
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "ProjectSettingsContainer.h"
|
||||
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzCore/JSON/prettywriter.h>
|
||||
#include <AzCore/JSON/stringbuffer.h>
|
||||
#include <AzCore/XML/rapidxml_print.h>
|
||||
|
||||
@@ -41,7 +41,7 @@ void LoadPSApi()
|
||||
{
|
||||
if (!g_hPSAPI)
|
||||
{
|
||||
g_hPSAPI = LoadLibraryA("psapi.dll");
|
||||
g_hPSAPI = LoadLibraryW(L"psapi.dll");
|
||||
|
||||
if (g_hPSAPI)
|
||||
{
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <CryString.h>
|
||||
#include "UnicodeFunctions.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDropEvent>
|
||||
@@ -36,29 +34,6 @@ public:
|
||||
|
||||
namespace QtUtil
|
||||
{
|
||||
// From QString to CryString
|
||||
inline CryStringT<char> ToString(const QString& str)
|
||||
{
|
||||
return Unicode::Convert<CryStringT<char> >(str);
|
||||
}
|
||||
|
||||
// From CryString to QString
|
||||
inline QString ToQString(const CryStringT<char>& str)
|
||||
{
|
||||
return Unicode::Convert<QString>(str);
|
||||
}
|
||||
|
||||
// From const char * to QString
|
||||
inline QString ToQString(const char* str, size_t len = -1)
|
||||
{
|
||||
if (len == -1)
|
||||
{
|
||||
len = strlen(str);
|
||||
}
|
||||
return Unicode::Convert<QString>(str, str + len);
|
||||
}
|
||||
|
||||
// Replacement for CString::trimRight()
|
||||
inline QString trimRight(const QString& str)
|
||||
{
|
||||
// We prepend a char, so that the left doesn't get trimmed, then we remove it after trimming
|
||||
|
||||
@@ -68,12 +68,12 @@ void CQuickAccessBar::OnInitDialog()
|
||||
|
||||
// Add console variables & commands.
|
||||
IConsole* console = GetIEditor()->GetSystem()->GetIConsole();
|
||||
std::vector<const char*> cmds;
|
||||
AZStd::vector<AZStd::string_view> cmds;
|
||||
cmds.resize(console->GetNumVars());
|
||||
size_t cmdCount = console->GetSortedVars(&cmds[0], cmds.size());
|
||||
size_t cmdCount = console->GetSortedVars(cmds);
|
||||
for (int i = 0; i < cmdCount; ++i)
|
||||
{
|
||||
m_model->setStringList(m_model->stringList() += cmds[i]);
|
||||
m_model->setStringList(m_model->stringList() += cmds[i].data());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,10 +97,10 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
using TTypeMap = std::map<string, const SStaticResourceSelectorEntry*, stl::less_stricmp<string>>;
|
||||
using TTypeMap = std::map<AZStd::string, const SStaticResourceSelectorEntry *, stl::less_stricmp<AZStd::string>>;
|
||||
TTypeMap m_typeMap;
|
||||
|
||||
std::map<string, string> m_globallySelectedResources;
|
||||
std::map<AZStd::string, AZStd::string> m_globallySelectedResources;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -37,7 +37,7 @@ CSelectSequenceDialog::GetItems(std::vector<SItem>& outItems)
|
||||
{
|
||||
IAnimSequence* pSeq = pMovieSys->GetSequence(i);
|
||||
SItem item;
|
||||
string fullname = pSeq->GetName();
|
||||
AZStd::string fullname = pSeq->GetName();
|
||||
item.name = fullname.c_str();
|
||||
outItems.push_back(item);
|
||||
}
|
||||
|
||||
@@ -661,22 +661,6 @@ void SEditorSettings::Save()
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
SaveValue("Settings\\Slices", "DynamicByDefault", sliceSettings.dynamicByDefault);
|
||||
|
||||
/*
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Save paths.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
for (int id = 0; id < EDITOR_PATH_LAST; id++)
|
||||
{
|
||||
for (int i = 0; i < searchPaths[id].size(); i++)
|
||||
{
|
||||
CString path = searchPaths[id][i];
|
||||
CString key;
|
||||
key.Format( "Paths","Path_%.2d_%.2d",id,i );
|
||||
SaveValue( "Paths",key,path );
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
s_editorSettings()->sync();
|
||||
|
||||
// --- Settings Registry values
|
||||
|
||||
@@ -607,7 +607,7 @@ void CSettingsManager::SerializeCVars(XmlNodeRef& node, bool bLoad)
|
||||
int nCurrentVariable(0);
|
||||
IConsole* piConsole(nullptr);
|
||||
ICVar* piVariable(nullptr);
|
||||
std::vector<char*> cszVariableNames;
|
||||
AZStd::vector<AZStd::string_view> cszVariableNames;
|
||||
|
||||
char* szKey(nullptr);
|
||||
char* szValue(nullptr);
|
||||
@@ -660,9 +660,9 @@ void CSettingsManager::SerializeCVars(XmlNodeRef& node, bool bLoad)
|
||||
XmlNodeRef cvarsNode = XmlHelpers::CreateXmlNode(CVARS_NODE);
|
||||
|
||||
nNumberOfVariables = piConsole->GetNumVisibleVars();
|
||||
cszVariableNames.resize(nNumberOfVariables, nullptr);
|
||||
cszVariableNames.resize(nNumberOfVariables);
|
||||
|
||||
if (piConsole->GetSortedVars((const char**)&cszVariableNames.front(), nNumberOfVariables, nullptr) != nNumberOfVariables)
|
||||
if (piConsole->GetSortedVars(cszVariableNames) != nNumberOfVariables)
|
||||
{
|
||||
assert(false);
|
||||
return;
|
||||
@@ -670,12 +670,12 @@ void CSettingsManager::SerializeCVars(XmlNodeRef& node, bool bLoad)
|
||||
|
||||
for (nCurrentVariable = 0; nCurrentVariable < cszVariableNames.size(); ++nCurrentVariable)
|
||||
{
|
||||
if (_stricmp(cszVariableNames[nCurrentVariable], "_TestFormatMessage") == 0)
|
||||
if (_stricmp(cszVariableNames[nCurrentVariable].data(), "_TestFormatMessage") == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
piVariable = piConsole->GetCVar(cszVariableNames[nCurrentVariable]);
|
||||
piVariable = piConsole->GetCVar(cszVariableNames[nCurrentVariable].data());
|
||||
if (!piVariable)
|
||||
{
|
||||
assert(false);
|
||||
@@ -683,7 +683,7 @@ void CSettingsManager::SerializeCVars(XmlNodeRef& node, bool bLoad)
|
||||
}
|
||||
|
||||
newCVarNode = XmlHelpers::CreateXmlNode(CVAR_NODE);
|
||||
newCVarNode->setAttr(cszVariableNames[nCurrentVariable], piVariable->GetString());
|
||||
newCVarNode->setAttr(cszVariableNames[nCurrentVariable].data(), piVariable->GetString());
|
||||
cvarsNode->addChild(newCVarNode);
|
||||
}
|
||||
|
||||
|
||||
@@ -379,7 +379,7 @@ void CToolBoxManager::Load(QString xmlpath, AmazonToolbar* pToolbar, bool bToolb
|
||||
AZ::IO::FixedMaxPathString engineRoot = AZ::Utils::GetEnginePath();
|
||||
QDir engineDir = !engineRoot.empty() ? QDir(QString(engineRoot.c_str())) : QDir::current();
|
||||
|
||||
string enginePath = PathUtil::AddSlash(engineDir.absolutePath().toUtf8().data());
|
||||
AZStd::string enginePath = PathUtil::AddSlash(engineDir.absolutePath().toUtf8().data());
|
||||
|
||||
for (int i = 0; i < toolBoxNode->getChildCount(); ++i)
|
||||
{
|
||||
@@ -405,11 +405,11 @@ void CToolBoxManager::Load(QString xmlpath, AmazonToolbar* pToolbar, bool bToolb
|
||||
continue;
|
||||
}
|
||||
|
||||
string shelfPath = PathUtil::GetParentDirectory(xmlpath.toUtf8().data());
|
||||
string fullIconPath = enginePath + PathUtil::AddSlash(shelfPath.c_str());
|
||||
AZStd::string shelfPath = PathUtil::GetParentDirectory(xmlpath.toUtf8().data());
|
||||
AZStd::string fullIconPath = enginePath + PathUtil::AddSlash(shelfPath.c_str());
|
||||
fullIconPath.append(iconPath.toUtf8().data());
|
||||
|
||||
pMacro->SetIconPath(fullIconPath);
|
||||
pMacro->SetIconPath(fullIconPath.c_str());
|
||||
|
||||
QString toolTip(macroNode->getAttr("tooltip"));
|
||||
pMacro->action()->setToolTip(toolTip);
|
||||
|
||||
@@ -818,12 +818,12 @@ void CToolsConfigPage::FillConsoleCmds()
|
||||
{
|
||||
QStringList commands;
|
||||
IConsole* console = GetIEditor()->GetSystem()->GetIConsole();
|
||||
std::vector<const char*> cmds;
|
||||
AZStd::vector<AZStd::string_view> cmds;
|
||||
cmds.resize(console->GetNumVars());
|
||||
size_t cmdCount = console->GetSortedVars(&cmds[0], cmds.size());
|
||||
size_t cmdCount = console->GetSortedVars(cmds);
|
||||
for (int i = 0; i < cmdCount; ++i)
|
||||
{
|
||||
commands.push_back(cmds[i]);
|
||||
commands.push_back(cmds[i].data());
|
||||
}
|
||||
m_completionModel->setStringList(commands);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
CFileUtil::ScanDirectory((Path::GetEditingGameDataFolder() + "/Fonts/").c_str(), "*.xml", fa, true);
|
||||
for (size_t i = 0; i < fa.size(); ++i)
|
||||
{
|
||||
string name = fa[i].filename.toUtf8().data();
|
||||
AZStd::string name = fa[i].filename.toUtf8().data();
|
||||
PathUtil::RemoveExtension(name);
|
||||
mv_font->AddEnumItem(name.c_str(), name.c_str());
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ void CCommentNodeAnimator::AnimateCommentTextTrack(CTrackViewTrack* pTrack, cons
|
||||
if (commentKey.m_duration > 0 && ac.time < keyHandle.GetTime() + commentKey.m_duration)
|
||||
{
|
||||
m_commentContext.m_strComment = commentKey.m_strComment;
|
||||
cry_strcpy(m_commentContext.m_strFont, commentKey.m_strFont.c_str());
|
||||
azstrcpy(m_commentContext.m_strFont, AZ_ARRAY_SIZE(m_commentContext.m_strFont), commentKey.m_strFont.c_str());
|
||||
m_commentContext.m_color = commentKey.m_color;
|
||||
m_commentContext.m_align = commentKey.m_align;
|
||||
m_commentContext.m_size = commentKey.m_size;
|
||||
|
||||
@@ -91,7 +91,7 @@ bool CSequenceKeyUIControls::OnKeySelectionChange(CTrackViewKeyBundle& selectedK
|
||||
bool bNotParent = !bNotMe || pCurrentSequence->IsAncestorOf(pSequence) == false;
|
||||
if (bNotMe && bNotParent)
|
||||
{
|
||||
string seqName = pCurrentSequence->GetName();
|
||||
AZStd::string seqName = pCurrentSequence->GetName();
|
||||
|
||||
QString ownerIdString = CTrackViewDialog::GetEntityIdAsString(pCurrentSequence->GetSequenceComponentEntityId());
|
||||
mv_sequence->AddEnumItem(seqName.c_str(), ownerIdString);
|
||||
|
||||
@@ -1010,13 +1010,13 @@ bool CTrackViewAnimNode::SetName(const char* pName)
|
||||
}
|
||||
}
|
||||
|
||||
string oldName = GetName();
|
||||
AZStd::string oldName = GetName();
|
||||
m_animNode->SetName(pName);
|
||||
|
||||
CTrackViewSequence* sequence = GetSequence();
|
||||
AZ_Assert(sequence, "Nodes should never have a null sequence.");
|
||||
|
||||
sequence->OnNodeRenamed(this, oldName);
|
||||
sequence->OnNodeRenamed(this, oldName.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2808,10 +2808,10 @@ void CTrackViewDopeSheetBase::DrawKeys(CTrackViewTrack* pTrack, QPainter* painte
|
||||
}
|
||||
else
|
||||
{
|
||||
cry_strcpy(keydesc, "{");
|
||||
azstrcpy(keydesc, AZ_ARRAY_SIZE(keydesc), "{");
|
||||
}
|
||||
cry_strcat(keydesc, pDescription);
|
||||
cry_strcat(keydesc, "}");
|
||||
azstrcat(keydesc, AZ_ARRAY_SIZE(keydesc), pDescription);
|
||||
azstrcat(keydesc, AZ_ARRAY_SIZE(keydesc), "}");
|
||||
// Draw key description text.
|
||||
// Find next key.
|
||||
const QRect textRect(QPoint(x + 10, rect.top()), QPoint(x1, rect.bottom()));
|
||||
|
||||
@@ -61,7 +61,7 @@ void CTrackViewFindDlg::FillData()
|
||||
ObjName obj;
|
||||
obj.m_objName = pNode->GetName();
|
||||
obj.m_directorName = pNode->HasDirectorAsParent() ? pNode->HasDirectorAsParent()->GetName() : "";
|
||||
string fullname = seq->GetName();
|
||||
AZStd::string fullname = seq->GetName();
|
||||
obj.m_seqName = fullname.c_str();
|
||||
m_objs.push_back(obj);
|
||||
}
|
||||
|
||||
@@ -2516,7 +2516,7 @@ int CTrackViewNodesCtrl::GetMatNameAndSubMtlIndexFromName(QString& matName, cons
|
||||
if (const char* pCh = strstr(nodeName, ".["))
|
||||
{
|
||||
char matPath[MAX_PATH];
|
||||
cry_strcpy(matPath, nodeName, (size_t)(pCh - nodeName));
|
||||
azstrncpy(matPath, AZ_ARRAY_SIZE(matPath), nodeName, (size_t)(pCh - nodeName));
|
||||
matName = matPath;
|
||||
pCh += 2;
|
||||
if ((*pCh) != 0)
|
||||
|
||||
@@ -1073,7 +1073,7 @@ std::deque<CTrackViewTrack*> CTrackViewSequence::GetMatchingTracks(CTrackViewAni
|
||||
{
|
||||
std::deque<CTrackViewTrack*> matchingTracks;
|
||||
|
||||
const string trackName = trackNode->getAttr("name");
|
||||
const AZStd::string trackName = trackNode->getAttr("name");
|
||||
|
||||
CAnimParamType animParamType;
|
||||
animParamType.LoadFromXml(trackNode);
|
||||
@@ -1133,11 +1133,11 @@ void CTrackViewSequence::GetMatchedPasteLocationsRec(std::vector<TMatchedTrackLo
|
||||
for (unsigned int nodeIndex = 0; nodeIndex < numChildNodes; ++nodeIndex)
|
||||
{
|
||||
XmlNodeRef xmlChildNode = clipboardNode->getChild(nodeIndex);
|
||||
const string tagName = xmlChildNode->getTag();
|
||||
const AZStd::string tagName = xmlChildNode->getTag();
|
||||
|
||||
if (tagName == "Node")
|
||||
{
|
||||
const string nodeName = xmlChildNode->getAttr("name");
|
||||
const AZStd::string nodeName = xmlChildNode->getAttr("name");
|
||||
|
||||
int nodeType = static_cast<int>(AnimNodeType::Invalid);
|
||||
xmlChildNode->getAttr("type", nodeType);
|
||||
@@ -1159,7 +1159,7 @@ void CTrackViewSequence::GetMatchedPasteLocationsRec(std::vector<TMatchedTrackLo
|
||||
}
|
||||
else if (tagName == "Track")
|
||||
{
|
||||
const string trackName = xmlChildNode->getAttr("name");
|
||||
const AZStd::string trackName = xmlChildNode->getAttr("name");
|
||||
|
||||
CAnimParamType trackParamType;
|
||||
trackParamType.Serialize(xmlChildNode, true);
|
||||
|
||||
@@ -81,7 +81,7 @@ void CTVNewSequenceDialog::OnOK()
|
||||
for (int k = 0; k < GetIEditor()->GetSequenceManager()->GetCount(); ++k)
|
||||
{
|
||||
CTrackViewSequence* pSequence = GetIEditor()->GetSequenceManager()->GetSequenceByIndex(k);
|
||||
QString fullname = QtUtil::ToQString(pSequence->GetName());
|
||||
QString fullname = pSequence->GetName();
|
||||
|
||||
if (fullname.compare(m_sequenceName, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ int CAutoDirectoryRestoreFileDialog::exec()
|
||||
foreach(const QString&fileName, selectedFiles())
|
||||
{
|
||||
QFileInfo info(fileName);
|
||||
if (!CryStringUtils::IsValidFileName(info.fileName().toStdString().c_str()))
|
||||
if (!AZ::StringFunc::Path::IsValid(info.fileName().toStdString().c_str()))
|
||||
{
|
||||
QMessageBox::warning(this, tr("Error"), tr("Please select a valid file name (standard English alphanumeric characters only)"));
|
||||
problem = true;
|
||||
|
||||
@@ -30,30 +30,6 @@ void HeapCheck::Check([[maybe_unused]] const char* file, [[maybe_unused]] int li
|
||||
_ASSERTE(_CrtCheckMemory());
|
||||
#endif
|
||||
|
||||
/*
|
||||
int heapstatus = _heapchk();
|
||||
switch( heapstatus )
|
||||
{
|
||||
case _HEAPOK:
|
||||
break;
|
||||
case _HEAPEMPTY:
|
||||
break;
|
||||
case _HEAPBADBEGIN:
|
||||
{
|
||||
CString str;
|
||||
str.Format( "Bad Start of Heap, at file %s line:%d",file,line );
|
||||
MessageBox( nullptr,str,"Heap Check",MB_OK );
|
||||
}
|
||||
break;
|
||||
case _HEAPBADNODE:
|
||||
{
|
||||
CString str;
|
||||
str.Format( "Bad Node in Heap, at file %s line:%d",file,line );
|
||||
MessageBox( nullptr,str,"Heap Check",MB_OK );
|
||||
}
|
||||
break;
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <IXml.h>
|
||||
#include "Util/FileUtil.h"
|
||||
#include <Cry_Color.h>
|
||||
#include <CryCommon/ISystem.h>
|
||||
|
||||
//! Typedef for quaternion.
|
||||
//typedef CryQuat Quat;
|
||||
|
||||
@@ -264,7 +264,7 @@ void CFileUtil::EditTextureFile(const char* textureFile, [[maybe_unused]] bool b
|
||||
}
|
||||
|
||||
bool failedToLaunch = true;
|
||||
QByteArray textureEditorPath = gSettings.textureEditor.toUtf8();
|
||||
const QString& textureEditorPath = gSettings.textureEditor;
|
||||
|
||||
// Give the user a warning if they don't have a texture editor configured
|
||||
if (textureEditorPath.isEmpty())
|
||||
@@ -278,8 +278,7 @@ void CFileUtil::EditTextureFile(const char* textureFile, [[maybe_unused]] bool b
|
||||
// Use the Win32 API calls to open the right editor; the OS knows how to do this even better than
|
||||
// Qt does.
|
||||
QString fullTexturePathFixedForWindows = QString(fullTexturePath.data()).replace('/', '\\');
|
||||
QByteArray fullTexturePathFixedForWindowsUtf8 = fullTexturePathFixedForWindows.toUtf8();
|
||||
HINSTANCE hInst = ShellExecute(nullptr, "open", textureEditorPath.data(), fullTexturePathFixedForWindowsUtf8.data(), nullptr, SW_SHOWNORMAL);
|
||||
HINSTANCE hInst = ShellExecuteW(nullptr, L"open", textureEditorPath.toStdWString().c_str(), fullTexturePathFixedForWindows.toStdWString().c_str(), nullptr, SW_SHOWNORMAL);
|
||||
failedToLaunch = ((DWORD_PTR)hInst <= 32);
|
||||
#elif defined(AZ_PLATFORM_MAC)
|
||||
failedToLaunch = QProcess::execute(QString("/usr/bin/open"), {"-a", gSettings.textureEditor, QString(fullTexturePath.data()) }) != 0;
|
||||
@@ -298,7 +297,7 @@ void CFileUtil::EditTextureFile(const char* textureFile, [[maybe_unused]] bool b
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CFileUtil::EditMayaFile(const char* filepath, const bool bExtractFromPak, const bool bUseGameFolder)
|
||||
{
|
||||
QString dosFilepath = QtUtil::ToQString(PathUtil::ToDosPath(filepath));
|
||||
QString dosFilepath = PathUtil::ToDosPath(filepath).c_str();
|
||||
if (bExtractFromPak)
|
||||
{
|
||||
ExtractFile(dosFilepath);
|
||||
@@ -313,7 +312,7 @@ bool CFileUtil::EditMayaFile(const char* filepath, const bool bExtractFromPak, c
|
||||
dosFilepath = sGameFolder + '\\' + filepath;
|
||||
}
|
||||
|
||||
dosFilepath = PathUtil::ToDosPath(dosFilepath.toUtf8().data());
|
||||
dosFilepath = PathUtil::ToDosPath(dosFilepath.toUtf8().data()).c_str();
|
||||
}
|
||||
|
||||
const char* engineRoot;
|
||||
@@ -1304,7 +1303,7 @@ IFileUtil::ECopyTreeResult CFileUtil::CopyTree(const QString& strSourceDirectory
|
||||
// all with the same names and all with the same files names inside. If you would make a depth-first search
|
||||
// you could end up with the files from the deepest folder in ALL your folders.
|
||||
|
||||
std::vector<string> ignoredPatterns;
|
||||
std::vector<AZStd::string> ignoredPatterns;
|
||||
StringHelpers::Split(ignoreFilesAndFolders, "|", false, ignoredPatterns);
|
||||
|
||||
QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags;
|
||||
@@ -1330,7 +1329,7 @@ IFileUtil::ECopyTreeResult CFileUtil::CopyTree(const QString& strSourceDirectory
|
||||
const QString fileName = QFileInfo(filePath).fileName();
|
||||
|
||||
bool ignored = false;
|
||||
for (const string& ignoredFile : ignoredPatterns)
|
||||
for (const AZStd::string& ignoredFile : ignoredPatterns)
|
||||
{
|
||||
if (StringHelpers::CompareIgnoreCase(fileName.toStdString().c_str(), ignoredFile.c_str()) == 0)
|
||||
{
|
||||
@@ -2159,13 +2158,14 @@ uint32 CFileUtil::GetAttributes(const char* filename, bool bUseSourceControl /*=
|
||||
return SCC_FILE_ATTRIBUTE_READONLY | SCC_FILE_ATTRIBUTE_INPAK;
|
||||
}
|
||||
|
||||
DWORD dwAttrib = ::GetFileAttributes(file.GetAdjustedFilename());
|
||||
if (dwAttrib == INVALID_FILE_ATTRIBUTES)
|
||||
|
||||
const char* adjustedFile = file.GetAdjustedFilename();
|
||||
if (!AZ::IO::SystemFile::Exists(adjustedFile))
|
||||
{
|
||||
return SCC_FILE_ATTRIBUTE_INVALID;
|
||||
}
|
||||
|
||||
if (dwAttrib & FILE_ATTRIBUTE_READONLY)
|
||||
if (!AZ::IO::SystemFile::IsWritable(adjustedFile))
|
||||
{
|
||||
return SCC_FILE_ATTRIBUTE_NORMAL | SCC_FILE_ATTRIBUTE_READONLY;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "CryThread.h"
|
||||
#include "StringUtils.h"
|
||||
#include "../Include/SandboxAPI.h"
|
||||
#include <QString>
|
||||
#include <QFileInfo>
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_UTIL_IXMLHISTORYMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_UTIL_IXMLHISTORYMANAGER_H
|
||||
#pragma once
|
||||
|
||||
|
||||
// Helper class to handle Redo/Undo on set of Xml nodes
|
||||
struct IXmlUndoEventHandler
|
||||
{
|
||||
virtual bool SaveToXml(XmlNodeRef& xmlNode) = 0;
|
||||
virtual bool LoadFromXml(const XmlNodeRef& xmlNode) = 0;
|
||||
virtual bool ReloadFromXml(const XmlNodeRef& xmlNode) = 0;
|
||||
};
|
||||
|
||||
struct IXmlHistoryEventListener
|
||||
{
|
||||
enum EHistoryEventType
|
||||
{
|
||||
eHET_HistoryDeleted,
|
||||
eHET_HistoryCleared,
|
||||
eHET_HistorySaved,
|
||||
|
||||
eHET_VersionChanged,
|
||||
eHET_VersionAdded,
|
||||
|
||||
eHET_HistoryInvalidate,
|
||||
|
||||
eHET_HistoryGroupChanged,
|
||||
eHET_HistoryGroupAdded,
|
||||
eHET_HistoryGroupRemoved,
|
||||
};
|
||||
virtual void OnEvent(EHistoryEventType event, void* pData = nullptr) = 0;
|
||||
};
|
||||
|
||||
struct IXmlHistoryView
|
||||
{
|
||||
virtual bool LoadXml(int typeId, const XmlNodeRef& xmlNode, IXmlUndoEventHandler*& pUndoEventHandler, uint32 userindex) = 0;
|
||||
virtual void UnloadXml(int typeId) = 0;
|
||||
};
|
||||
|
||||
struct IXmlHistoryManager
|
||||
{
|
||||
// Undo/Redo
|
||||
virtual bool Undo() = 0;
|
||||
virtual bool Redo() = 0;
|
||||
virtual bool Goto(int historyNum) = 0;
|
||||
virtual void RecordUndo(IXmlUndoEventHandler* pEventHandler, const char* desc) = 0;
|
||||
virtual void UndoEventHandlerDestroyed(IXmlUndoEventHandler* pEventHandler, uint32 typeId = 0, bool destoryForever = false) = 0;
|
||||
virtual void RestoreUndoEventHandler(IXmlUndoEventHandler* pEventHandler, uint32 typeId) = 0;
|
||||
|
||||
virtual void RegisterEventListener(IXmlHistoryEventListener* pEventListener) = 0;
|
||||
virtual void UnregisterEventListener(IXmlHistoryEventListener* pEventListener) = 0;
|
||||
|
||||
// History
|
||||
virtual void ClearHistory(bool flagAsSaved = false) = 0;
|
||||
virtual int GetVersionCount() const = 0;
|
||||
virtual const string& GetVersionDesc(int number) const = 0;
|
||||
virtual int GetCurrentVersionNumber() const = 0;
|
||||
|
||||
// Views
|
||||
virtual void RegisterView(IXmlHistoryView* pView) = 0;
|
||||
virtual void UnregisterView(IXmlHistoryView* pView) = 0;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_UTIL_IXMLHISTORYMANAGER_H
|
||||
@@ -24,8 +24,7 @@ bool CImageASC::Save(const QString& fileName, const CFloatImage& image)
|
||||
uint32 height = image.GetHeight();
|
||||
float* pixels = image.GetData();
|
||||
|
||||
string fileHeader;
|
||||
fileHeader.Format(
|
||||
AZStd::string fileHeader = AZStd::string::format(
|
||||
// Number of columns and rows in the data
|
||||
"ncols %d\n"
|
||||
"nrows %d\n"
|
||||
|
||||
@@ -399,8 +399,8 @@ bool CImageTIF::SaveRAW(const QString& fileName, const void* pData, int width, i
|
||||
|
||||
if (preset && preset[0])
|
||||
{
|
||||
string tiffphotoshopdata, valueheader;
|
||||
string presetkeyvalue = string("/preset=") + string(preset);
|
||||
AZStd::string tiffphotoshopdata, valueheader;
|
||||
AZStd::string presetkeyvalue = AZStd::string("/preset=") + AZStd::string(preset);
|
||||
|
||||
valueheader.push_back('\x1C');
|
||||
valueheader.push_back('\x02');
|
||||
@@ -472,7 +472,7 @@ const char* CImageTIF::GetPreset(const QString& fileName)
|
||||
libtiffDummyWriteProc, libtiffDummySeekProc,
|
||||
libtiffDummyCloseProc, libtiffDummySizeProc, libtiffDummyMapFileProc, libtiffDummyUnmapFileProc);
|
||||
|
||||
string strReturn;
|
||||
AZStd::string strReturn;
|
||||
char* preset = nullptr;
|
||||
int size;
|
||||
if (tif)
|
||||
|
||||
@@ -86,8 +86,7 @@ bool CImageUtil::SavePGM(const QString& fileName, const CImageEx& image)
|
||||
uint32* pixels = image.GetData();
|
||||
|
||||
// Create the file header.
|
||||
string fileHeader;
|
||||
fileHeader.Format(
|
||||
AZStd::string fileHeader = AZStd::string::format(
|
||||
// P2 = PGM header for ASCII output. (P5 is PGM header for binary output)
|
||||
"P2\n"
|
||||
// width and height of the image
|
||||
|
||||
@@ -15,24 +15,21 @@
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h> // for ebus events
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <AzFramework/IO/LocalFileIO.h>
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace
|
||||
{
|
||||
string g_currentModName; // folder name only!
|
||||
}
|
||||
|
||||
namespace Path
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SplitPath(const QString& rstrFullPathFilename, QString& rstrDriveLetter, QString& rstrDirectory, QString& rstrFilename, QString& rstrExtension)
|
||||
{
|
||||
string strFullPathString(rstrFullPathFilename.toUtf8().data());
|
||||
string strDriveLetter;
|
||||
string strDirectory;
|
||||
string strFilename;
|
||||
string strExtension;
|
||||
AZStd::string strFullPathString(rstrFullPathFilename.toUtf8().data());
|
||||
AZStd::string strDriveLetter;
|
||||
AZStd::string strDirectory;
|
||||
AZStd::string strFilename;
|
||||
AZStd::string strExtension;
|
||||
|
||||
char* szPath((char*)strFullPathString.c_str());
|
||||
char* pchLastPosition(szPath);
|
||||
@@ -81,16 +78,16 @@ namespace Path
|
||||
strFilename.assign(pchLastPosition, pchCurrentPosition);
|
||||
}
|
||||
|
||||
rstrDriveLetter = strDriveLetter;
|
||||
rstrDirectory = strDirectory;
|
||||
rstrFilename = strFilename;
|
||||
rstrExtension = strExtension;
|
||||
rstrDriveLetter = strDriveLetter.c_str();
|
||||
rstrDirectory = strDirectory.c_str();
|
||||
rstrFilename = strFilename.c_str();
|
||||
rstrExtension = strExtension.c_str();
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void GetDirectoryQueue(const QString& rstrSourceDirectory, QStringList& rcstrDirectoryTree)
|
||||
{
|
||||
string strCurrentDirectoryName;
|
||||
string strSourceDirectory(rstrSourceDirectory.toUtf8().data());
|
||||
AZStd::string strCurrentDirectoryName;
|
||||
AZStd::string strSourceDirectory(rstrSourceDirectory.toUtf8().data());
|
||||
const char* szSourceDirectory(strSourceDirectory.c_str());
|
||||
const char* pchCurrentPosition(szSourceDirectory);
|
||||
const char* pchLastPosition(szSourceDirectory);
|
||||
@@ -207,14 +204,7 @@ namespace Path
|
||||
|
||||
bool IsFolder(const char* pPath)
|
||||
{
|
||||
DWORD attrs = GetFileAttributes(pPath);
|
||||
|
||||
if (attrs == FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return AZ::IO::FileIOBase::GetInstance()->IsDirectory(pPath);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -255,16 +245,16 @@ namespace Path
|
||||
/// Get the data folder
|
||||
AZStd::string GetEditingGameDataFolder()
|
||||
{
|
||||
// query the editor root. The bus exists in case we want tools to be able to override this.
|
||||
// Define here the mod name
|
||||
static AZ::IO::FixedMaxPathString s_currentModName;
|
||||
|
||||
|
||||
if (g_currentModName.empty())
|
||||
if (s_currentModName.empty())
|
||||
{
|
||||
return GetGameAssetsFolder();
|
||||
}
|
||||
AZStd::string str(GetGameAssetsFolder());
|
||||
str += "Mods\\";
|
||||
str += g_currentModName;
|
||||
str += s_currentModName.c_str();
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -93,7 +93,7 @@ namespace Path
|
||||
#endif
|
||||
file = path_buffer;
|
||||
}
|
||||
inline void Split(const string& filepath, string& path, string& file)
|
||||
inline void Split(const AZStd::string& filepath, AZStd::string& path, AZStd::string& file)
|
||||
{
|
||||
char path_buffer[_MAX_PATH];
|
||||
char drive[_MAX_DRIVE];
|
||||
@@ -101,12 +101,12 @@ namespace Path
|
||||
char fname[_MAX_FNAME];
|
||||
char ext[_MAX_EXT];
|
||||
#ifdef AZ_COMPILER_MSVC
|
||||
_splitpath_s(filepath, drive, AZ_ARRAY_SIZE(drive), dir, AZ_ARRAY_SIZE(dir), 0, 0, 0, 0);
|
||||
_splitpath_s(filepath.c_str(), drive, AZ_ARRAY_SIZE(drive), dir, AZ_ARRAY_SIZE(dir), 0, 0, 0, 0);
|
||||
_makepath_s(path_buffer, AZ_ARRAY_SIZE(path_buffer), drive, dir, 0, 0);
|
||||
path = path_buffer;
|
||||
_makepath_s(path_buffer, AZ_ARRAY_SIZE(path_buffer), 0, 0, fname, ext);
|
||||
#else
|
||||
_splitpath(filepath, drive, dir, fname, ext);
|
||||
_splitpath(filepath.c_str(), drive, dir, fname, ext);
|
||||
_makepath(path_buffer, drive, dir, 0, 0);
|
||||
path = path_buffer;
|
||||
_makepath(path_buffer, 0, 0, fname, ext);
|
||||
@@ -137,7 +137,7 @@ namespace Path
|
||||
filename = fname;
|
||||
fext = ext;
|
||||
}
|
||||
inline void Split(const string& filepath, string& path, string& filename, string& fext)
|
||||
inline void Split(const AZStd::string& filepath, AZStd::string& path, AZStd::string& filename, AZStd::string& fext)
|
||||
{
|
||||
char path_buffer[_MAX_PATH];
|
||||
char drive[_MAX_DRIVE];
|
||||
@@ -145,10 +145,10 @@ namespace Path
|
||||
char fname[_MAX_FNAME];
|
||||
char ext[_MAX_EXT];
|
||||
#ifdef AZ_COMPILER_MSVC
|
||||
_splitpath_s(filepath, drive, AZ_ARRAY_SIZE(drive), dir, AZ_ARRAY_SIZE(dir), fname, AZ_ARRAY_SIZE(fname), ext, AZ_ARRAY_SIZE(ext));
|
||||
_splitpath_s(filepath.c_str(), drive, AZ_ARRAY_SIZE(drive), dir, AZ_ARRAY_SIZE(dir), fname, AZ_ARRAY_SIZE(fname), ext, AZ_ARRAY_SIZE(ext));
|
||||
_makepath_s(path_buffer, AZ_ARRAY_SIZE(path_buffer), drive, dir, 0, 0);
|
||||
#else
|
||||
_splitpath(filepath, drive, dir, fname, ext);
|
||||
_splitpath(filepath.c_str(), drive, dir, fname, ext);
|
||||
_makepath(path_buffer, drive, dir, 0, 0);
|
||||
#endif
|
||||
path = path_buffer;
|
||||
@@ -230,7 +230,7 @@ namespace Path
|
||||
}
|
||||
|
||||
template<size_t size>
|
||||
inline bool EndsWithSlash(CryStackStringT<char, size>* path)
|
||||
inline bool EndsWithSlash(AZStd::fixed_string<size>* path)
|
||||
{
|
||||
if ((!path) || (path->empty()))
|
||||
{
|
||||
@@ -271,7 +271,7 @@ namespace Path
|
||||
}
|
||||
|
||||
template<size_t size>
|
||||
inline void AddBackslash(CryStackStringT<char, size>* path)
|
||||
inline void AddBackslash(AZStd::fixed_string<size>* path)
|
||||
{
|
||||
if (path->empty())
|
||||
{
|
||||
@@ -284,7 +284,7 @@ namespace Path
|
||||
}
|
||||
|
||||
template<size_t size>
|
||||
inline void AddSlash(CryStackStringT<char, size>* path)
|
||||
inline void AddSlash(AZStd::fixed_string<size>* path)
|
||||
{
|
||||
if (path->empty())
|
||||
{
|
||||
@@ -357,7 +357,7 @@ namespace Path
|
||||
{
|
||||
return CaselessPaths(GetRelativePath(path, true));
|
||||
}
|
||||
inline string FullPathToGamePath(const char* path)
|
||||
inline AZStd::string FullPathToGamePath(const char* path)
|
||||
{
|
||||
return CaselessPaths(GetRelativePath(path, true)).toUtf8().data();
|
||||
}
|
||||
@@ -394,7 +394,7 @@ namespace Path
|
||||
inline QString GetAudioLocalizationFolder(bool returnAbsolutePath)
|
||||
{
|
||||
// Omit the trailing slash!
|
||||
QString sLocalizationFolder(QString(PathUtil::GetLocalizationFolder()).left(static_cast<int>(PathUtil::GetLocalizationFolder().size()) - 1));
|
||||
QString sLocalizationFolder(QString(PathUtil::GetLocalizationFolder().c_str()).left(static_cast<int>(PathUtil::GetLocalizationFolder().size()) - 1));
|
||||
|
||||
if (!sLocalizationFolder.isEmpty())
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,210 +11,18 @@
|
||||
#define CRYINCLUDE_CRYCOMMONTOOLS_STRINGHELPERS_H
|
||||
#pragma once
|
||||
|
||||
#include <CryString.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
|
||||
namespace StringHelpers
|
||||
{
|
||||
// compares two strings to see if they are the same or different, case sensitive
|
||||
// returns 0 if the strings are the same, a -1 if the first string is bigger, or a 1 if the second string is bigger
|
||||
int Compare(const string& str0, const string& str1);
|
||||
int Compare(const wstring& str0, const wstring& str1);
|
||||
|
||||
// compares two strings to see if they are the same or different, case is ignored
|
||||
// returns 0 if the strings are the same, a -1 if the first string is bigger, or a 1 if the second string is bigger
|
||||
int CompareIgnoreCase(const string& str0, const string& str1);
|
||||
int CompareIgnoreCase(const wstring& str0, const wstring& str1);
|
||||
int CompareIgnoreCase(const AZStd::string& str0, const AZStd::string& str1);
|
||||
int CompareIgnoreCase(const AZStd::wstring& str0, const AZStd::wstring& str1);
|
||||
|
||||
void Split(const AZStd::string& str, const AZStd::string& separator, bool bReturnEmptyPartsToo, std::vector<AZStd::string>& outParts);
|
||||
void Split(const AZStd::wstring& str, const AZStd::wstring& separator, bool bReturnEmptyPartsToo, std::vector<AZStd::wstring>& outParts);
|
||||
|
||||
// compares two strings to see if they are the same, case senstive
|
||||
// returns true if they are the same or false if they are different
|
||||
bool Equals(const string& str0, const string& str1);
|
||||
bool Equals(const wstring& str0, const wstring& str1);
|
||||
|
||||
// compares two strings to see if they are the same, case is ignored
|
||||
// returns true if they are the same or false if they are different
|
||||
bool EqualsIgnoreCase(const string& str0, const string& str1);
|
||||
bool EqualsIgnoreCase(const wstring& str0, const wstring& str1);
|
||||
|
||||
// checks to see if a string starts with a specified string, case sensitive
|
||||
// returns true if the string does start with a specified string or false if it does not
|
||||
bool StartsWith(const string& str, const string& pattern);
|
||||
bool StartsWith(const wstring& str, const wstring& pattern);
|
||||
|
||||
// checks to see if a string starts with a specified string, case is ignored
|
||||
// returns true if the string does start with a specified string or false if it does not
|
||||
bool StartsWithIgnoreCase(const string& str, const string& pattern);
|
||||
bool StartsWithIgnoreCase(const wstring& str, const wstring& pattern);
|
||||
|
||||
// checks to see if a string ends with a specified string, case sensitive
|
||||
// returns true if the string does end with a specified string or false if it does not
|
||||
bool EndsWith(const string& str, const string& pattern);
|
||||
bool EndsWith(const wstring& str, const wstring& pattern);
|
||||
|
||||
// checks to see if a string ends with a specified string, case is ignored
|
||||
// returns true if the string does end with a specified string or false if it does not
|
||||
bool EndsWithIgnoreCase(const string& str, const string& pattern);
|
||||
bool EndsWithIgnoreCase(const wstring& str, const wstring& pattern);
|
||||
|
||||
// checks to see if a string contains a specified string, case sensitive
|
||||
// returns true if the string does contain the specified string or false if it does not
|
||||
bool Contains(const string& str, const string& pattern);
|
||||
bool Contains(const wstring& str, const wstring& pattern);
|
||||
|
||||
// checks to see if a string contains a specified string, case is ignored
|
||||
// returns true if the string does contain the specified string or false if it does not
|
||||
bool ContainsIgnoreCase(const string& str, const string& pattern);
|
||||
bool ContainsIgnoreCase(const wstring& str, const wstring& pattern);
|
||||
|
||||
// checks to see if a string contains a wildcard string pattern, case sensitive
|
||||
// returns true if the string does match the wildcard string pattern or false if it does not
|
||||
bool MatchesWildcards(const string& str, const string& wildcards);
|
||||
bool MatchesWildcards(const wstring& str, const wstring& wildcards);
|
||||
|
||||
// checks to see if a string contains a wildcard string pattern, case is ignored
|
||||
// returns true if the string does match the wildcard string pattern or false if it does not
|
||||
bool MatchesWildcardsIgnoreCase(const string& str, const string& wildcards);
|
||||
bool MatchesWildcardsIgnoreCase(const wstring& str, const wstring& wildcards);
|
||||
|
||||
bool MatchesWildcardsIgnoreCaseExt(const string& str, const string& wildcards, std::vector<string>& wildcardMatches);
|
||||
bool MatchesWildcardsIgnoreCaseExt(const wstring& str, const wstring& wildcards, std::vector<wstring>& wildcardMatches);
|
||||
|
||||
string TrimLeft(const string& s);
|
||||
wstring TrimLeft(const wstring& s);
|
||||
|
||||
string TrimRight(const string& s);
|
||||
wstring TrimRight(const wstring& s);
|
||||
|
||||
string Trim(const string& s);
|
||||
wstring Trim(const wstring& s);
|
||||
|
||||
string RemoveDuplicateSpaces(const string& s);
|
||||
wstring RemoveDuplicateSpaces(const wstring& s);
|
||||
|
||||
// converts a string with upper case characters to be all lower case
|
||||
// returns the string in all lower case
|
||||
string MakeLowerCase(const string& s);
|
||||
wstring MakeLowerCase(const wstring& s);
|
||||
|
||||
// converts a string with lower case characters to be all upper case
|
||||
// returns the string in all upper case
|
||||
string MakeUpperCase(const string& s);
|
||||
wstring MakeUpperCase(const wstring& s);
|
||||
|
||||
// replace a specified character in a string with a specified replacement character
|
||||
// returns string with specified character replaced
|
||||
string Replace(const string& s, char oldChar, char newChar);
|
||||
wstring Replace(const wstring& s, wchar_t oldChar, wchar_t newChar);
|
||||
|
||||
void ConvertStringByRef(string& out, const string& in);
|
||||
void ConvertStringByRef(wstring& out, const string& in);
|
||||
void ConvertStringByRef(string& out, const wstring& in);
|
||||
void ConvertStringByRef(wstring& out, const wstring& in);
|
||||
|
||||
template <typename O, typename I>
|
||||
O ConvertString(const I& in)
|
||||
{
|
||||
O out;
|
||||
ConvertStringByRef(out, in);
|
||||
return out;
|
||||
}
|
||||
|
||||
void Split(const string& str, const string& separator, bool bReturnEmptyPartsToo, std::vector<string>& outParts);
|
||||
void Split(const wstring& str, const wstring& separator, bool bReturnEmptyPartsToo, std::vector<wstring>& outParts);
|
||||
|
||||
void SplitByAnyOf(const string& str, const string& separators, bool bReturnEmptyPartsToo, std::vector<string>& outParts);
|
||||
void SplitByAnyOf(const wstring& str, const wstring& separators, bool bReturnEmptyPartsToo, std::vector<wstring>& outParts);
|
||||
|
||||
string FormatVA(const char* const format, va_list parg);
|
||||
wstring FormatVA(const wchar_t* const format, va_list parg);
|
||||
|
||||
inline string Format(const char* const format, ...)
|
||||
{
|
||||
if ((format == 0) || (format[0] == 0))
|
||||
{
|
||||
return string();
|
||||
}
|
||||
va_list parg;
|
||||
va_start(parg, format);
|
||||
const string result = FormatVA(format, parg);
|
||||
va_end(parg);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline wstring Format(const wchar_t* const format, ...)
|
||||
{
|
||||
if ((format == 0) || (format[0] == 0))
|
||||
{
|
||||
return wstring();
|
||||
}
|
||||
va_list parg;
|
||||
va_start(parg, format);
|
||||
const wstring result = FormatVA(format, parg);
|
||||
va_end(parg);
|
||||
return result;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SafeCopy(char* const pDstBuffer, const size_t dstBufferSizeInBytes, const char* const pSrc);
|
||||
void SafeCopy(wchar_t* const pDstBuffer, const size_t dstBufferSizeInBytes, const wchar_t* const pSrc);
|
||||
|
||||
void SafeCopyPadZeros(char* const pDstBuffer, const size_t dstBufferSizeInBytes, const char* const pSrc);
|
||||
void SafeCopyPadZeros(wchar_t* const pDstBuffer, const size_t dstBufferSizeInBytes, const wchar_t* const pSrc);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ASCII
|
||||
// ANSI (system default Windows ANSI code page)
|
||||
// UTF-8
|
||||
// UTF-16
|
||||
|
||||
// ASCII -> UTF-16
|
||||
|
||||
bool Utf16ContainsAsciiOnly(const wchar_t* wstr);
|
||||
string ConvertAsciiUtf16ToAscii(const wchar_t* wstr);
|
||||
wstring ConvertAsciiToUtf16(const char* str);
|
||||
|
||||
// UTF-8 <-> UTF-16
|
||||
#if defined(AZ_PLATFORM_WINDOWS)
|
||||
wstring ConvertUtf8ToUtf16(const char* str);
|
||||
string ConvertUtf16ToUtf8(const wchar_t* wstr);
|
||||
|
||||
inline string ConvertUtfToUtf8(const char* str)
|
||||
{
|
||||
return string(str);
|
||||
}
|
||||
|
||||
inline string ConvertUtfToUtf8(const wchar_t* wstr)
|
||||
{
|
||||
return ConvertUtf16ToUtf8(wstr);
|
||||
}
|
||||
|
||||
inline wstring ConvertUtfToUtf16(const char* str)
|
||||
{
|
||||
return ConvertUtf8ToUtf16(str);
|
||||
}
|
||||
|
||||
inline wstring ConvertUtfToUtf16(const wchar_t* wstr)
|
||||
{
|
||||
return wstring(wstr);
|
||||
}
|
||||
|
||||
// ANSI <-> UTF-8, UTF-16
|
||||
|
||||
wstring ConvertAnsiToUtf16(const char* str);
|
||||
string ConvertUtf16ToAnsi(const wchar_t* wstr, char badChar);
|
||||
|
||||
inline string ConvertAnsiToUtf8(const char* str)
|
||||
{
|
||||
return ConvertUtf16ToUtf8(ConvertAnsiToUtf16(str).c_str());
|
||||
}
|
||||
inline string ConvertUtf8ToAnsi(const char* str, char badChar)
|
||||
{
|
||||
return ConvertUtf16ToAnsi(ConvertUtf8ToUtf16(str).c_str(), badChar);
|
||||
}
|
||||
#endif
|
||||
|
||||
// ANSI -> ASCII
|
||||
string ConvertAnsiToAscii(const char* str, char badChar);
|
||||
}
|
||||
#endif // CRYINCLUDE_CRYCOMMONTOOLS_STRINGHELPERS_H
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Description : Utility class to help in STL algorithms on containers with
|
||||
// CStrings when intending to use case insensitive searches or sorting for
|
||||
// example.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_UTIL_STRINGNOCASEPREDICATE_H
|
||||
#define CRYINCLUDE_EDITOR_UTIL_STRINGNOCASEPREDICATE_H
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
Utility class to help in STL algorithms on containers with CStrings
|
||||
when intending to use case insensitive searches or sorting for example.
|
||||
|
||||
e.g.
|
||||
std::vector< CString > v;
|
||||
...
|
||||
std::sort( v.begin(), v.end(), CStringNoCasePredicate::LessThan() );
|
||||
std::find_if( v.begin(), v.end(), CStringNoCasePredicate::Equal( stringImLookingFor ) );
|
||||
*/
|
||||
class CStringNoCasePredicate
|
||||
{
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct Equal
|
||||
{
|
||||
Equal(const QString& referenceString)
|
||||
: m_referenceString(referenceString)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator() (const QString& arg) const
|
||||
{
|
||||
return (m_referenceString.compare(arg, Qt::CaseInsensitive) == 0);
|
||||
}
|
||||
|
||||
private:
|
||||
const QString& m_referenceString;
|
||||
};
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct LessThan
|
||||
{
|
||||
bool operator() (const QString& arg1, const QString& arg2) const
|
||||
{
|
||||
return (arg1.CompareNoCase(arg2) < 0);
|
||||
}
|
||||
};
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
};
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_UTIL_STRINGNOCASEPREDICATE_H
|
||||
@@ -1,875 +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 "XmlHistoryManager.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
SXmlHistory::SXmlHistory(CXmlHistoryManager* pManager, const XmlNodeRef& xmlBaseVersion, uint32 typeId)
|
||||
: m_pManager(pManager)
|
||||
, m_typeId(typeId)
|
||||
, m_DeletedVersion(-1)
|
||||
, m_SavedVersion(-1)
|
||||
{
|
||||
int newVersionNumber = m_pManager->GetCurrentVersionNumber() + (m_pManager->IsPreparedForNextVersion() ? 1 : 0);
|
||||
m_xmlVersionList[ newVersionNumber ] = xmlBaseVersion;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void SXmlHistory::AddToHistory(const XmlNodeRef& newXmlVersion)
|
||||
{
|
||||
int newVersionNumber = m_pManager->IncrementVersion(this);
|
||||
m_xmlVersionList[ newVersionNumber ] = newXmlVersion;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
const XmlNodeRef& SXmlHistory::Undo(bool* bVersionExist)
|
||||
{
|
||||
m_pManager->Undo();
|
||||
return GetCurrentVersion(bVersionExist);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
const XmlNodeRef& SXmlHistory::Redo()
|
||||
{
|
||||
m_pManager->Redo();
|
||||
return GetCurrentVersion();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
const XmlNodeRef& SXmlHistory::GetCurrentVersion(bool* bVersionExist, int* iVersionNumber) const
|
||||
{
|
||||
int currentVersion = m_pManager->GetCurrentVersionNumber();
|
||||
|
||||
TXmlVersionMap::const_iterator it = m_xmlVersionList.begin();
|
||||
TXmlVersionMap::const_iterator previt = m_xmlVersionList.begin();
|
||||
while (it != m_xmlVersionList.end())
|
||||
{
|
||||
if (it->first > currentVersion)
|
||||
{
|
||||
break;
|
||||
}
|
||||
previt = it;
|
||||
++it;
|
||||
}
|
||||
|
||||
if (bVersionExist)
|
||||
{
|
||||
*bVersionExist = currentVersion >= m_xmlVersionList.begin()->first;
|
||||
}
|
||||
if (iVersionNumber)
|
||||
{
|
||||
*iVersionNumber = previt->first;
|
||||
}
|
||||
|
||||
return previt->second;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
bool SXmlHistory::IsModified() const
|
||||
{
|
||||
int currVersion;
|
||||
GetCurrentVersion(nullptr, &currVersion);
|
||||
return m_SavedVersion != currVersion;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void SXmlHistory::FlagAsDeleted()
|
||||
{
|
||||
assert(m_pManager->IsPreparedForNextVersion());
|
||||
m_DeletedVersion = m_pManager->GetCurrentVersionNumber() + 1;
|
||||
m_SavedVersion = -1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void SXmlHistory::FlagAsSaved()
|
||||
{
|
||||
if (Exist())
|
||||
{
|
||||
int currVersion;
|
||||
GetCurrentVersion(nullptr, &currVersion);
|
||||
m_SavedVersion = currVersion;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
bool SXmlHistory::Exist() const
|
||||
{
|
||||
// int currentVersion = m_pManager->GetCurrentVersionNumber();
|
||||
// bool deleted = m_DeletedVersion != -1 && currentVersion >= m_DeletedVersion;
|
||||
// bool exist = currentVersion >= m_xmlVersionList.begin()->first;
|
||||
// return !deleted && exist;
|
||||
int currentVersion = m_pManager->GetCurrentVersionNumber();
|
||||
return currentVersion >= m_xmlVersionList.begin()->first && (m_DeletedVersion == -1 || currentVersion < m_DeletedVersion);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void SXmlHistory::ClearRedo()
|
||||
{
|
||||
int currentVersion = m_pManager->GetCurrentVersionNumber();
|
||||
if (m_DeletedVersion > currentVersion + (m_pManager->IsPreparedForNextVersion() ? 1 : 0))
|
||||
{
|
||||
m_DeletedVersion = -1;
|
||||
}
|
||||
TXmlVersionMap::iterator it = m_xmlVersionList.begin();
|
||||
for (; it != m_xmlVersionList.end(); ++it)
|
||||
{
|
||||
if (it->first > currentVersion)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (it != m_xmlVersionList.end())
|
||||
{
|
||||
++it;
|
||||
while (it != m_xmlVersionList.end())
|
||||
{
|
||||
m_xmlVersionList.erase(it++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void SXmlHistory::ClearHistory(bool flagAsSaved)
|
||||
{
|
||||
bool wasModified = !flagAsSaved && IsModified();
|
||||
m_DeletedVersion = Exist() ? -1 : 0;
|
||||
ClearRedo();
|
||||
XmlNodeRef latest = m_xmlVersionList.rbegin()->second;
|
||||
m_xmlVersionList.clear();
|
||||
m_xmlVersionList[ 0 ] = latest;
|
||||
m_SavedVersion = wasModified ? -1 : 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
SXmlHistoryGroup::SXmlHistoryGroup(CXmlHistoryManager* pManager, uint32 typeId)
|
||||
: m_pManager(pManager)
|
||||
, m_typeId(typeId)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
SXmlHistory* SXmlHistoryGroup::GetHistory(int index) const
|
||||
{
|
||||
THistoryList::const_iterator it = m_List.begin();
|
||||
while (index > 0 && it != m_List.end())
|
||||
{
|
||||
++it;
|
||||
if ((*it)->Exist())
|
||||
{
|
||||
--index;
|
||||
}
|
||||
}
|
||||
return it != m_List.end() ? *it : nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
int SXmlHistoryGroup::GetHistoryCount() const
|
||||
{
|
||||
int count = 0;
|
||||
for (THistoryList::const_iterator it = m_List.begin(); it != m_List.end(); ++it)
|
||||
{
|
||||
if ((*it)->Exist())
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
SXmlHistory* SXmlHistoryGroup::GetHistoryByTypeId(uint32 typeId, int index /*= 0*/) const
|
||||
{
|
||||
for (int i = 0; i < GetHistoryCount(); ++i)
|
||||
{
|
||||
SXmlHistory* pHistory = GetHistory(i);
|
||||
if (pHistory->GetTypeId() == typeId)
|
||||
{
|
||||
index--;
|
||||
}
|
||||
if (index == -1)
|
||||
{
|
||||
return pHistory;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
int SXmlHistoryGroup::GetHistoryCountByTypeId(uint32 typeId) const
|
||||
{
|
||||
int res = 0;
|
||||
for (int i = 0; i < GetHistoryCount(); ++i)
|
||||
{
|
||||
if (GetHistory(i)->GetTypeId() == typeId)
|
||||
{
|
||||
res++;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
int SXmlHistoryGroup::CreateXmlHistory(uint32 typeId, const XmlNodeRef& xmlBaseVersion)
|
||||
{
|
||||
if (m_pManager)
|
||||
{
|
||||
m_List.push_back(m_pManager->CreateXmlHistory(typeId, xmlBaseVersion));
|
||||
return m_List.size() - 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
int SXmlHistoryGroup::GetHistoryIndex(const SXmlHistory* pHistory) const
|
||||
{
|
||||
int index = 0;
|
||||
for (THistoryList::const_iterator it = m_List.begin(); it != m_List.end(); ++it)
|
||||
{
|
||||
if (*it == pHistory)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
CXmlHistoryManager::CXmlHistoryManager()
|
||||
: m_CurrentVersion(0)
|
||||
, m_LatestVersion(0)
|
||||
, m_pExclusiveListener(nullptr)
|
||||
, m_RecordNextVersion(false)
|
||||
, m_pExActiveGroup(nullptr)
|
||||
, m_bIsActiveGroupEx(false)
|
||||
{
|
||||
m_pNullGroup = new SXmlHistoryGroup(this, (uint32) - 1);
|
||||
}
|
||||
|
||||
CXmlHistoryManager::~CXmlHistoryManager()
|
||||
{
|
||||
delete m_pNullGroup;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
bool CXmlHistoryManager::Undo()
|
||||
{
|
||||
if (m_CurrentVersion > 0)
|
||||
{
|
||||
int prevVersion = m_CurrentVersion;
|
||||
const SXmlHistoryGroup* pPrevCurrGroup = GetActiveGroup();
|
||||
m_CurrentVersion--;
|
||||
ReloadCurrentVersion(pPrevCurrGroup, prevVersion);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
bool CXmlHistoryManager::Redo()
|
||||
{
|
||||
if (m_CurrentVersion < m_LatestVersion)
|
||||
{
|
||||
int prevVersion = m_CurrentVersion;
|
||||
const SXmlHistoryGroup* pPrevCurrGroup = GetActiveGroup();
|
||||
m_CurrentVersion++;
|
||||
ReloadCurrentVersion(pPrevCurrGroup, prevVersion);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
bool CXmlHistoryManager::Goto(int historyNum)
|
||||
{
|
||||
if (historyNum >= 0 && historyNum <= m_LatestVersion)
|
||||
{
|
||||
int prevVersion = m_CurrentVersion;
|
||||
const SXmlHistoryGroup* pPrevCurrGroup = GetActiveGroup();
|
||||
m_CurrentVersion = historyNum;
|
||||
ReloadCurrentVersion(pPrevCurrGroup, prevVersion);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::RecordUndo(IXmlUndoEventHandler* pEventHandler, const char* desc)
|
||||
{
|
||||
ClearRedo();
|
||||
SXmlHistory* pChangedXml = m_UndoEventHandlerMap[ pEventHandler ].CurrentData;
|
||||
assert(pChangedXml);
|
||||
|
||||
XmlNodeRef newData = gEnv->pSystem->CreateXmlNode();
|
||||
#if !defined(NDEBUG)
|
||||
bool bRes =
|
||||
#endif
|
||||
pEventHandler->SaveToXml(newData);
|
||||
assert(bRes);
|
||||
|
||||
TXmlHistotyGroupPtrList activeGroups = m_HistoryInfoMap[ m_CurrentVersion ].ActiveGroups;
|
||||
|
||||
pChangedXml->AddToHistory(newData);
|
||||
m_UndoEventHandlerMap[ pEventHandler ].HistoryData[ m_CurrentVersion ] = pChangedXml;
|
||||
m_HistoryInfoMap[ m_CurrentVersion ].HistoryDescription = desc;
|
||||
m_HistoryInfoMap[ m_CurrentVersion ].IsNullUndo = false;
|
||||
m_HistoryInfoMap[ m_CurrentVersion ].ActiveGroups = activeGroups;
|
||||
m_HistoryInfoMap[ m_CurrentVersion ].HistoryInvalidated = false;
|
||||
NotifyUndoEventListener(IXmlHistoryEventListener::eHET_VersionAdded);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::UndoEventHandlerDestroyed(IXmlUndoEventHandler* pEventHandler, uint32 typeId /*= 0*/, bool destoryForever /*= false*/)
|
||||
{
|
||||
if (destoryForever)
|
||||
{
|
||||
UnregisterUndoEventHandler(pEventHandler);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_InvalidHandlerMap[typeId] = pEventHandler;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::RestoreUndoEventHandler(IXmlUndoEventHandler* pEventHandler, uint32 typeId)
|
||||
{
|
||||
TInvalidUndoEventListener::iterator it = m_InvalidHandlerMap.find(typeId);
|
||||
if (it != m_InvalidHandlerMap.end())
|
||||
{
|
||||
IXmlUndoEventHandler* pLastHandler = it->second;
|
||||
TUndoEventHandlerMap::iterator lastit = m_UndoEventHandlerMap.find(pLastHandler);
|
||||
if (lastit != m_UndoEventHandlerMap.end())
|
||||
{
|
||||
m_UndoEventHandlerMap[pEventHandler] = lastit->second;
|
||||
m_UndoEventHandlerMap.erase(lastit);
|
||||
}
|
||||
m_InvalidHandlerMap.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::RegisterEventListener(IXmlHistoryEventListener* pEventListener)
|
||||
{
|
||||
stl::push_back_unique(m_EventListener, pEventListener);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::UnregisterEventListener(IXmlHistoryEventListener* pEventListener)
|
||||
{
|
||||
m_EventListener.remove(pEventListener);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::PrepareForNextVersion()
|
||||
{
|
||||
assert(!m_RecordNextVersion);
|
||||
m_RecordNextVersion = true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::RecordNextVersion(SXmlHistory* pHistory, XmlNodeRef newData, const char* undoDesc /*= nullptr*/)
|
||||
{
|
||||
assert(m_RecordNextVersion);
|
||||
RegisterUndoEventHandler(this, pHistory);
|
||||
m_newHistoryData = newData;
|
||||
RecordUndo(this, undoDesc ? undoDesc : "<UNDEFINED>");
|
||||
m_RecordNextVersion = false;
|
||||
m_HistoryInfoMap[ m_CurrentVersion ].HistoryInvalidated = true;
|
||||
UnregisterUndoEventHandler(this);
|
||||
SetActiveGroupInt(GetActiveGroup());
|
||||
NotifyUndoEventListener(IXmlHistoryEventListener::eHET_HistoryInvalidate);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
bool CXmlHistoryManager::SaveToXml(XmlNodeRef& xmlNode)
|
||||
{
|
||||
assert(m_newHistoryData);
|
||||
xmlNode = m_newHistoryData;
|
||||
return true;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::ClearHistory(bool flagAsSaved)
|
||||
{
|
||||
TXmlHistotyGroupPtrList activeGropus = m_HistoryInfoMap[ m_CurrentVersion ].ActiveGroups;
|
||||
for (TXmlHistoryList::iterator it = m_XmlHistoryList.begin(); it != m_XmlHistoryList.end(); ++it)
|
||||
{
|
||||
it->ClearHistory(flagAsSaved);
|
||||
}
|
||||
|
||||
SetActiveGroup(nullptr);
|
||||
|
||||
m_CurrentVersion = 0;
|
||||
m_LatestVersion = 0;
|
||||
|
||||
m_UndoEventHandlerMap.clear();
|
||||
m_HistoryInfoMap.clear();
|
||||
|
||||
m_HistoryInfoMap[ 0 ].HistoryDescription = "New History";
|
||||
m_HistoryInfoMap[ 0 ].ActiveGroups = activeGropus;
|
||||
NotifyUndoEventListener(IXmlHistoryEventListener::eHET_HistoryCleared);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
const string& CXmlHistoryManager::GetVersionDesc(int number) const
|
||||
{
|
||||
THistoryInfoMap::const_iterator it = m_HistoryInfoMap.find(number);
|
||||
if (it != m_HistoryInfoMap.end())
|
||||
{
|
||||
return it->second.HistoryDescription;
|
||||
}
|
||||
|
||||
static string undef("UNDEFINED");
|
||||
return undef;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::RegisterView(IXmlHistoryView* pView)
|
||||
{
|
||||
stl::push_back_unique(m_Views, pView);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::UnregisterView(IXmlHistoryView* pView)
|
||||
{
|
||||
m_Views.remove(pView);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
SXmlHistoryGroup* CXmlHistoryManager::CreateXmlGroup(uint32 typeId)
|
||||
{
|
||||
m_Groups.push_back(SXmlHistoryGroup(this, typeId));
|
||||
return &(*m_Groups.rbegin());
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::AddXmlGroup(const SXmlHistoryGroup* pGroup, const char* undoDesc /*= nullptr*/)
|
||||
{
|
||||
RecordUndoInternal(undoDesc ? undoDesc : "New XML Group added");
|
||||
m_HistoryInfoMap[ m_CurrentVersion ].ActiveGroups.push_back(pGroup);
|
||||
NotifyUndoEventListener(IXmlHistoryEventListener::eHET_HistoryGroupAdded, (void*)pGroup);
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::RemoveXmlGroup(const SXmlHistoryGroup* pGroup, const char* undoDesc /*= nullptr*/)
|
||||
{
|
||||
bool unload = m_HistoryInfoMap[ m_CurrentVersion ].CurrGroup == pGroup;
|
||||
RecordUndoInternal(undoDesc ? undoDesc : "XML Group deleted");
|
||||
TXmlHistotyGroupPtrList& list = m_HistoryInfoMap[ m_CurrentVersion ].ActiveGroups;
|
||||
stl::find_and_erase(list, pGroup);
|
||||
if (unload)
|
||||
{
|
||||
SetActiveGroupInt(nullptr);
|
||||
}
|
||||
m_HistoryInfoMap[ m_CurrentVersion ].CurrGroup = m_pNullGroup;
|
||||
NotifyUndoEventListener(IXmlHistoryEventListener::eHET_HistoryGroupRemoved, (void*)pGroup);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::SetActiveGroup(const SXmlHistoryGroup* pGroup, const char* displayName /*= nullptr*/, const TGroupIndexMap& groupIndex /*= TGroupIndexMap()*/, bool setExternal /*= false*/)
|
||||
{
|
||||
TGroupIndexMap userIndex;
|
||||
const SXmlHistoryGroup* pActiveGroup = GetActiveGroup(userIndex);
|
||||
if (pGroup != pActiveGroup || userIndex != groupIndex || setExternal)
|
||||
{
|
||||
const bool isEx = m_CurrentVersion != m_LatestVersion || setExternal;
|
||||
m_pExActiveGroup = const_cast<SXmlHistoryGroup*>(pGroup);
|
||||
m_ExCurrentIndex = groupIndex;
|
||||
m_bIsActiveGroupEx = true;
|
||||
SetActiveGroupInt(pGroup, displayName, !isEx, groupIndex);
|
||||
m_bIsActiveGroupEx = isEx;
|
||||
}
|
||||
}
|
||||
|
||||
void CXmlHistoryManager::SetActiveGroupInt(const SXmlHistoryGroup* pGroup, const char* displayName /*= nullptr*/, bool bRecordNullUndo /*= false*/, const TGroupIndexMap& groupIndex /*= TGroupIndexMap()*/)
|
||||
{
|
||||
UnloadInt();
|
||||
|
||||
TEventHandlerList eventHandler;
|
||||
string undoDesc;
|
||||
|
||||
if (pGroup)
|
||||
{
|
||||
for (TViews::iterator it = m_Views.begin(); it != m_Views.end(); ++it)
|
||||
{
|
||||
IXmlHistoryView* pView = *it;
|
||||
|
||||
std::map<uint32, int> userIndexCount;
|
||||
|
||||
for (SXmlHistoryGroup::THistoryList::const_iterator history = pGroup->m_List.begin(); history != pGroup->m_List.end(); ++history)
|
||||
{
|
||||
std::map<uint32, int>::iterator it2 = userIndexCount.find((*history)->GetTypeId());
|
||||
if (it2 == userIndexCount.end())
|
||||
{
|
||||
userIndexCount[ (*history)->GetTypeId() ] = 0;
|
||||
}
|
||||
uint32 userindex = userIndexCount[ (*history)->GetTypeId() ];
|
||||
IXmlUndoEventHandler* pEventHandler = nullptr;
|
||||
TGroupIndexMap::const_iterator indexIter = groupIndex.find((*history)->GetTypeId());
|
||||
if (indexIter == groupIndex.end() || indexIter->second == userindex)
|
||||
{
|
||||
if ((*history)->Exist())
|
||||
{
|
||||
if (pView->LoadXml((*history)->GetTypeId(), (*history)->GetCurrentVersion(), pEventHandler, userindex))
|
||||
{
|
||||
if (pEventHandler)
|
||||
{
|
||||
m_UndoHandlerViewMap[ pEventHandler ] = pView;
|
||||
RegisterUndoEventHandler(pEventHandler, *history);
|
||||
eventHandler.push_back(pEventHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((*history)->Exist())
|
||||
{
|
||||
userIndexCount[ (*history)->GetTypeId() ]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
undoDesc.Format("Changed View to \"%s\"", displayName ? displayName : "UNDEFINED");
|
||||
}
|
||||
else
|
||||
{
|
||||
undoDesc = "Unloaded Views";
|
||||
for (TUndoEventHandlerMap::iterator it = m_UndoEventHandlerMap.begin(); it != m_UndoEventHandlerMap.end(); ++it)
|
||||
{
|
||||
eventHandler.push_back(it->first);
|
||||
}
|
||||
pGroup = m_pNullGroup;
|
||||
}
|
||||
|
||||
if (bRecordNullUndo)
|
||||
{
|
||||
RecordNullUndo(eventHandler, undoDesc.c_str());
|
||||
m_HistoryInfoMap[ m_CurrentVersion ].CurrGroup = pGroup;
|
||||
m_HistoryInfoMap[ m_CurrentVersion ].CurrUserIndex = groupIndex;
|
||||
}
|
||||
NotifyUndoEventListener(IXmlHistoryEventListener::eHET_HistoryGroupChanged);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
const SXmlHistoryGroup* CXmlHistoryManager::GetActiveGroup() const
|
||||
{
|
||||
TGroupIndexMap userIndex;
|
||||
return GetActiveGroup(userIndex);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
const SXmlHistoryGroup* CXmlHistoryManager::GetActiveGroup(TGroupIndexMap& currUserIndex /*out*/) const
|
||||
{
|
||||
if (m_bIsActiveGroupEx)
|
||||
{
|
||||
currUserIndex = m_ExCurrentIndex;
|
||||
return m_pExActiveGroup;
|
||||
}
|
||||
|
||||
int currVersion = m_CurrentVersion;
|
||||
do
|
||||
{
|
||||
THistoryInfoMap::const_iterator it = m_HistoryInfoMap.find(currVersion);
|
||||
if (it != m_HistoryInfoMap.end())
|
||||
{
|
||||
const SXmlHistoryGroup* pGroup = it->second.CurrGroup;
|
||||
if (it != m_HistoryInfoMap.end() && pGroup)
|
||||
{
|
||||
currUserIndex = it->second.CurrUserIndex;
|
||||
return pGroup == m_pNullGroup ? nullptr : pGroup;
|
||||
}
|
||||
}
|
||||
currVersion--;
|
||||
} while (currVersion >= 0);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
SXmlHistory* CXmlHistoryManager::CreateXmlHistory(uint32 typeId, const XmlNodeRef& xmlBaseVersion)
|
||||
{
|
||||
m_XmlHistoryList.push_back(SXmlHistory(this, xmlBaseVersion, typeId));
|
||||
return &(*m_XmlHistoryList.rbegin());
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::DeleteXmlHistory(const SXmlHistory* pXmlHistry)
|
||||
{
|
||||
for (TXmlHistoryList::iterator it = m_XmlHistoryList.begin(); it != m_XmlHistoryList.end(); ++it)
|
||||
{
|
||||
if (&(*it) == pXmlHistry)
|
||||
{
|
||||
m_XmlHistoryList.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::UnloadInt()
|
||||
{
|
||||
for (TViews::iterator it = m_Views.begin(); it != m_Views.end(); ++it)
|
||||
{
|
||||
IXmlHistoryView* pView = *it;
|
||||
pView->UnloadXml(-1);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
namespace
|
||||
{
|
||||
template< class T >
|
||||
void ClearAfterVersion(T& container, int version)
|
||||
{
|
||||
auto foundit = container.end();
|
||||
do
|
||||
{
|
||||
auto it = container.find(version);
|
||||
if (it != container.end())
|
||||
{
|
||||
foundit = it;
|
||||
break;
|
||||
}
|
||||
version--;
|
||||
} while (version >= 0);
|
||||
if (foundit != container.end())
|
||||
{
|
||||
for (auto it = ++foundit; it != container.end(); )
|
||||
{
|
||||
container.erase(it++);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CXmlHistoryManager::ClearRedo()
|
||||
{
|
||||
ClearAfterVersion(m_HistoryInfoMap, m_CurrentVersion);
|
||||
for (TUndoEventHandlerMap::iterator it = m_UndoEventHandlerMap.begin(); it != m_UndoEventHandlerMap.end(); ++it)
|
||||
{
|
||||
ClearAfterVersion(it->second.HistoryData, m_CurrentVersion);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::DeleteAll()
|
||||
{
|
||||
ClearHistory();
|
||||
m_Groups.clear();
|
||||
m_UndoEventHandlerMap.clear();
|
||||
NotifyUndoEventListener(IXmlHistoryEventListener::eHET_HistoryDeleted);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::FlagHistoryAsSaved()
|
||||
{
|
||||
for (TXmlHistoryList::iterator it = m_XmlHistoryList.begin(); it != m_XmlHistoryList.end(); ++it)
|
||||
{
|
||||
it->FlagAsSaved();
|
||||
}
|
||||
NotifyUndoEventListener(IXmlHistoryEventListener::eHET_HistorySaved);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::RecordNullUndo(const TEventHandlerList& eventHandler, const char* desc, bool isNull /*= true*/)
|
||||
{
|
||||
TXmlHistotyGroupPtrList activeGroups = m_HistoryInfoMap[ m_CurrentVersion ].ActiveGroups;
|
||||
|
||||
// if current version is already null undo, overwrite it instead of create a new version
|
||||
if (m_HistoryInfoMap[ m_CurrentVersion ].IsNullUndo && isNull)
|
||||
{
|
||||
assert(m_CurrentVersion);
|
||||
m_CurrentVersion--;
|
||||
}
|
||||
|
||||
ClearRedo();
|
||||
IncrementVersion();
|
||||
|
||||
for (TEventHandlerList::const_iterator it = eventHandler.begin(); it != eventHandler.end(); ++it)
|
||||
{
|
||||
SXmlHistory* pChangedXml = m_UndoEventHandlerMap[ *it ].CurrentData;
|
||||
m_UndoEventHandlerMap[ *it ].HistoryData[ m_CurrentVersion ] = pChangedXml;
|
||||
}
|
||||
m_HistoryInfoMap[ m_CurrentVersion ].HistoryDescription = desc;
|
||||
m_HistoryInfoMap[ m_CurrentVersion ].IsNullUndo = isNull;
|
||||
m_HistoryInfoMap[ m_CurrentVersion ].ActiveGroups = activeGroups;
|
||||
m_HistoryInfoMap[ m_CurrentVersion ].HistoryInvalidated = false;
|
||||
NotifyUndoEventListener(IXmlHistoryEventListener::eHET_VersionAdded);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::ReloadCurrentVersion(const SXmlHistoryGroup* pPrevGroup, int prevVersion)
|
||||
{
|
||||
m_bIsActiveGroupEx = false;
|
||||
const SXmlHistoryGroup* pActiveGroup = GetActiveGroup();
|
||||
|
||||
bool bInvalidated = false;
|
||||
int start = min(prevVersion, m_CurrentVersion);
|
||||
int end = max(prevVersion, m_CurrentVersion);
|
||||
for (int i = start; i <= end; ++i)
|
||||
{
|
||||
if (m_HistoryInfoMap[i].HistoryInvalidated)
|
||||
{
|
||||
bInvalidated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bInvalidated && pPrevGroup == pActiveGroup)
|
||||
{
|
||||
for (TUndoEventHandlerMap::iterator it = m_UndoEventHandlerMap.begin(); it != m_UndoEventHandlerMap.end(); ++it)
|
||||
{
|
||||
IXmlUndoEventHandler* pEventHandler = it->first;
|
||||
if (!IsEventHandlerValid(pEventHandler))
|
||||
{
|
||||
assert(false);
|
||||
continue;
|
||||
}
|
||||
SXmlHistory* pXmlHistory = GetLatestHistory(m_UndoEventHandlerMap[ pEventHandler ]); /*m_UndoEventHandlerMap[ pEventHandler ].HistoryData[ m_CurrentVersion ];*/
|
||||
if (pXmlHistory)
|
||||
{
|
||||
if (pXmlHistory->Exist())
|
||||
{
|
||||
pEventHandler->ReloadFromXml(pXmlHistory->GetCurrentVersion());
|
||||
}
|
||||
}
|
||||
}
|
||||
NotifyUndoEventListener(IXmlHistoryEventListener::eHET_VersionChanged);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetActiveGroupInt(pActiveGroup);
|
||||
}
|
||||
|
||||
if (bInvalidated)
|
||||
{
|
||||
NotifyUndoEventListener(IXmlHistoryEventListener::eHET_HistoryInvalidate);
|
||||
}
|
||||
|
||||
TXmlHistotyGroupPtrList oldActiveGroups = m_HistoryInfoMap[ prevVersion ].ActiveGroups;
|
||||
TXmlHistotyGroupPtrList newActiveGroups = m_HistoryInfoMap[ m_CurrentVersion ].ActiveGroups;
|
||||
|
||||
RemoveListFromList(newActiveGroups, oldActiveGroups);
|
||||
RemoveListFromList(oldActiveGroups, m_HistoryInfoMap[ m_CurrentVersion ].ActiveGroups);
|
||||
|
||||
for (TXmlHistotyGroupPtrList::iterator it = newActiveGroups.begin(); it != newActiveGroups.end(); ++it)
|
||||
{
|
||||
NotifyUndoEventListener(IXmlHistoryEventListener::eHET_HistoryGroupAdded, (void*) *it);
|
||||
}
|
||||
|
||||
for (TXmlHistotyGroupPtrList::iterator it = oldActiveGroups.begin(); it != oldActiveGroups.end(); ++it)
|
||||
{
|
||||
NotifyUndoEventListener(IXmlHistoryEventListener::eHET_HistoryGroupRemoved, (void*) *it);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::RemoveListFromList(TXmlHistotyGroupPtrList& list, const TXmlHistotyGroupPtrList& removeList)
|
||||
{
|
||||
for (TXmlHistotyGroupPtrList::const_iterator rit = removeList.begin(); rit != removeList.end(); ++rit)
|
||||
{
|
||||
for (TXmlHistotyGroupPtrList::iterator it = list.begin(); it != list.end(); ++it)
|
||||
{
|
||||
if (*it == *rit)
|
||||
{
|
||||
list.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
SXmlHistory* CXmlHistoryManager::GetLatestHistory(SUndoEventHandlerData& eventHandlerData)
|
||||
{
|
||||
int currVersion = m_CurrentVersion;
|
||||
do
|
||||
{
|
||||
THistoryVersionMap::iterator it = eventHandlerData.HistoryData.find(currVersion);
|
||||
if (it != eventHandlerData.HistoryData.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
currVersion--;
|
||||
} while (currVersion >= 0);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::NotifyUndoEventListener(IXmlHistoryEventListener::EHistoryEventType event, void* pData)
|
||||
{
|
||||
if (m_pExclusiveListener)
|
||||
{
|
||||
m_pExclusiveListener->OnEvent(event, pData);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (TEventListener::iterator it = m_EventListener.begin(); it != m_EventListener.end(); ++it)
|
||||
{
|
||||
(*it)->OnEvent(event, pData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
int CXmlHistoryManager::IncrementVersion([[maybe_unused]] SXmlHistory* pXmlHistry)
|
||||
{
|
||||
for (TXmlHistoryList::iterator it = m_XmlHistoryList.begin(); it != m_XmlHistoryList.end(); ++it)
|
||||
{
|
||||
it->ClearRedo();
|
||||
}
|
||||
return IncrementVersion();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
int CXmlHistoryManager::IncrementVersion()
|
||||
{
|
||||
m_CurrentVersion++;
|
||||
m_LatestVersion = m_CurrentVersion;
|
||||
return m_CurrentVersion;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::RegisterUndoEventHandler(IXmlUndoEventHandler* pEventHandler, SXmlHistory* pXmlData)
|
||||
{
|
||||
m_UndoEventHandlerMap[ pEventHandler ].CurrentData = pXmlData;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::UnregisterUndoEventHandler(IXmlUndoEventHandler* pEventHandler)
|
||||
{
|
||||
TUndoEventHandlerMap::iterator it = m_UndoEventHandlerMap.find(pEventHandler);
|
||||
if (it != m_UndoEventHandlerMap.end())
|
||||
{
|
||||
m_UndoEventHandlerMap.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CXmlHistoryManager::RecordUndoInternal(const char* desc)
|
||||
{
|
||||
TEventHandlerList eventHandler;
|
||||
for (TUndoEventHandlerMap::iterator it = m_UndoEventHandlerMap.begin(); it != m_UndoEventHandlerMap.end(); ++it)
|
||||
{
|
||||
eventHandler.push_back(it->first);
|
||||
}
|
||||
RecordNullUndo(eventHandler, desc, false);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
bool CXmlHistoryManager::IsEventHandlerValid(IXmlUndoEventHandler* pEventHandler)
|
||||
{
|
||||
for (TInvalidUndoEventListener::iterator it = m_InvalidHandlerMap.begin(); it != m_InvalidHandlerMap.end(); ++it)
|
||||
{
|
||||
if (it->second == pEventHandler)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1,218 +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_UTIL_XMLHISTORYMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_UTIL_XMLHISTORYMANAGER_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "IXmlHistoryManager.h"
|
||||
|
||||
class CXmlHistoryManager;
|
||||
|
||||
struct SXmlHistory
|
||||
{
|
||||
public:
|
||||
SXmlHistory(CXmlHistoryManager* pManager, const XmlNodeRef& xmlBaseVersion, uint32 typeId);
|
||||
|
||||
void AddToHistory(const XmlNodeRef& newXmlVersion);
|
||||
|
||||
const XmlNodeRef& Undo(bool* bVersionExist = nullptr);
|
||||
const XmlNodeRef& Redo();
|
||||
const XmlNodeRef& GetCurrentVersion(bool* bVersionExist = nullptr, int* iVersionNumber = nullptr) const;
|
||||
bool IsModified() const;
|
||||
uint32 GetTypeId() const {return m_typeId; }
|
||||
void FlagAsDeleted();
|
||||
void FlagAsSaved();
|
||||
bool Exist() const;
|
||||
|
||||
private:
|
||||
friend class CXmlHistoryManager;
|
||||
|
||||
void ClearRedo();
|
||||
void ClearHistory(bool flagAsSaved);
|
||||
|
||||
private:
|
||||
CXmlHistoryManager* m_pManager;
|
||||
uint32 m_typeId;
|
||||
int m_DeletedVersion;
|
||||
int m_SavedVersion;
|
||||
|
||||
typedef std::map< int, XmlNodeRef > TXmlVersionMap;
|
||||
TXmlVersionMap m_xmlVersionList;
|
||||
};
|
||||
|
||||
|
||||
struct SXmlHistoryGroup
|
||||
{
|
||||
SXmlHistoryGroup(CXmlHistoryManager* pManager, uint32 typeId);
|
||||
|
||||
SXmlHistory* GetHistory(int index) const;
|
||||
int GetHistoryCount() const;
|
||||
|
||||
SXmlHistory* GetHistoryByTypeId(uint32 typeId, int index = 0) const;
|
||||
int GetHistoryCountByTypeId(uint32 typeId) const;
|
||||
|
||||
int CreateXmlHistory(uint32 typeId, const XmlNodeRef& xmlBaseVersion);
|
||||
uint32 GetTypeId() const {return m_typeId; }
|
||||
|
||||
int GetHistoryIndex(const SXmlHistory* pHistory) const;
|
||||
|
||||
private:
|
||||
friend class CXmlHistoryManager;
|
||||
CXmlHistoryManager* m_pManager;
|
||||
uint32 m_typeId;
|
||||
|
||||
typedef std::list< SXmlHistory* > THistoryList;
|
||||
THistoryList m_List;
|
||||
};
|
||||
|
||||
typedef std::map<uint32, int> TGroupIndexMap;
|
||||
|
||||
|
||||
class CXmlHistoryManager
|
||||
: public IXmlHistoryManager
|
||||
, public IXmlUndoEventHandler
|
||||
{
|
||||
public:
|
||||
CXmlHistoryManager();
|
||||
~CXmlHistoryManager();
|
||||
|
||||
// Undo/Redo
|
||||
bool Undo();
|
||||
bool Redo();
|
||||
bool Goto(int historyNum);
|
||||
void RecordUndo(IXmlUndoEventHandler* pEventHandler, const char* desc);
|
||||
void UndoEventHandlerDestroyed(IXmlUndoEventHandler* pEventHandler, uint32 typeId = 0, bool destoryForever = false);
|
||||
void RestoreUndoEventHandler(IXmlUndoEventHandler* pEventHandler, uint32 typeId);
|
||||
|
||||
void PrepareForNextVersion();
|
||||
void RecordNextVersion(SXmlHistory* pHistory, XmlNodeRef newData, const char* undoDesc = nullptr);
|
||||
bool IsPreparedForNextVersion() const {return m_RecordNextVersion; }
|
||||
|
||||
void RegisterEventListener(IXmlHistoryEventListener* pEventListener);
|
||||
void UnregisterEventListener(IXmlHistoryEventListener* pEventListener);
|
||||
void SetExclusiveListener(IXmlHistoryEventListener* pEventListener) { m_pExclusiveListener = pEventListener; }
|
||||
|
||||
// History
|
||||
void ClearHistory(bool flagAsSaved = false);
|
||||
int GetVersionCount() const { return m_LatestVersion; }
|
||||
const string& GetVersionDesc(int number) const;
|
||||
int GetCurrentVersionNumber() const { return m_CurrentVersion; }
|
||||
|
||||
// Views
|
||||
void RegisterView(IXmlHistoryView* pView);
|
||||
void UnregisterView(IXmlHistoryView* pView);
|
||||
|
||||
// Xml History Groups
|
||||
SXmlHistoryGroup* CreateXmlGroup(uint32 typeId);
|
||||
void SetActiveGroup(const SXmlHistoryGroup* pGroup, const char* displayName = nullptr, const TGroupIndexMap& groupIndex = TGroupIndexMap(), bool setExternal = false);
|
||||
const SXmlHistoryGroup* GetActiveGroup() const;
|
||||
const SXmlHistoryGroup* GetActiveGroup(TGroupIndexMap& currUserIndex /*out*/) const;
|
||||
void AddXmlGroup(const SXmlHistoryGroup* pGroup, const char* undoDesc = nullptr);
|
||||
void RemoveXmlGroup(const SXmlHistoryGroup* pGroup, const char* undoDesc = nullptr);
|
||||
|
||||
void DeleteAll();
|
||||
|
||||
void FlagHistoryAsSaved();
|
||||
|
||||
virtual bool SaveToXml(XmlNodeRef& xmlNode);
|
||||
virtual bool LoadFromXml([[maybe_unused]] const XmlNodeRef& xmlNode) { return false; };
|
||||
virtual bool ReloadFromXml([[maybe_unused]] const XmlNodeRef& xmlNode) { return false; };
|
||||
|
||||
private:
|
||||
typedef std::list< SXmlHistory > TXmlHistoryList;
|
||||
TXmlHistoryList m_XmlHistoryList;
|
||||
int m_CurrentVersion;
|
||||
int m_LatestVersion;
|
||||
SXmlHistoryGroup* m_pNullGroup; // hack for unload view ...
|
||||
XmlNodeRef m_newHistoryData;
|
||||
bool m_RecordNextVersion;
|
||||
bool m_bIsActiveGroupEx;
|
||||
SXmlHistoryGroup* m_pExActiveGroup;
|
||||
TGroupIndexMap m_ExCurrentIndex;
|
||||
|
||||
typedef std::list< SXmlHistoryGroup > TXmlHistotyGroupList;
|
||||
TXmlHistotyGroupList m_Groups;
|
||||
|
||||
// event listener
|
||||
typedef std::list< IXmlHistoryEventListener* > TEventListener;
|
||||
TEventListener m_EventListener;
|
||||
IXmlHistoryEventListener* m_pExclusiveListener;
|
||||
|
||||
// views
|
||||
typedef std::list< IXmlHistoryView* > TViews;
|
||||
TViews m_Views;
|
||||
|
||||
typedef std::list< const SXmlHistoryGroup* > TXmlHistotyGroupPtrList;
|
||||
// history
|
||||
struct SHistoryInfo
|
||||
{
|
||||
SHistoryInfo()
|
||||
: IsNullUndo(false)
|
||||
, CurrGroup(nullptr)
|
||||
, HistoryInvalidated(false) {}
|
||||
|
||||
const SXmlHistoryGroup* CurrGroup;
|
||||
TGroupIndexMap CurrUserIndex;
|
||||
string HistoryDescription;
|
||||
bool IsNullUndo;
|
||||
bool HistoryInvalidated;
|
||||
TXmlHistotyGroupPtrList ActiveGroups;
|
||||
};
|
||||
typedef std::map< int, SHistoryInfo > THistoryInfoMap;
|
||||
THistoryInfoMap m_HistoryInfoMap;
|
||||
|
||||
// undo event handler
|
||||
typedef std::map< int, SXmlHistory* > THistoryVersionMap;
|
||||
struct SUndoEventHandlerData
|
||||
{
|
||||
SUndoEventHandlerData()
|
||||
: CurrentData(nullptr) {}
|
||||
|
||||
SXmlHistory* CurrentData;
|
||||
THistoryVersionMap HistoryData;
|
||||
};
|
||||
typedef std::map< IXmlUndoEventHandler*, SUndoEventHandlerData > TUndoEventHandlerMap;
|
||||
TUndoEventHandlerMap m_UndoEventHandlerMap;
|
||||
|
||||
typedef std::map< IXmlUndoEventHandler*, IXmlHistoryView* > TUndoHandlerViewMap;
|
||||
TUndoHandlerViewMap m_UndoHandlerViewMap;
|
||||
|
||||
typedef std::map< uint32, IXmlUndoEventHandler* > TInvalidUndoEventListener;
|
||||
TInvalidUndoEventListener m_InvalidHandlerMap;
|
||||
|
||||
private:
|
||||
friend struct SXmlHistory;
|
||||
friend struct SXmlHistoryGroup;
|
||||
|
||||
int IncrementVersion(SXmlHistory* pXmlHistry);
|
||||
int IncrementVersion();
|
||||
SXmlHistory* CreateXmlHistory(uint32 typeId, const XmlNodeRef& xmlBaseVersion);
|
||||
void DeleteXmlHistory(const SXmlHistory* pXmlHistry);
|
||||
|
||||
void RegisterUndoEventHandler(IXmlUndoEventHandler* pEventHandler, SXmlHistory* pXmlData);
|
||||
void UnregisterUndoEventHandler(IXmlUndoEventHandler* pEventHandler);
|
||||
typedef std::list< IXmlUndoEventHandler* > TEventHandlerList;
|
||||
void RecordNullUndo(const TEventHandlerList& eventHandler, const char* desc, bool isNull = true);
|
||||
void ReloadCurrentVersion(const SXmlHistoryGroup* pPrevGroup, int prevVersion);
|
||||
SXmlHistory* GetLatestHistory(SUndoEventHandlerData& eventHandlerData);
|
||||
void NotifyUndoEventListener(IXmlHistoryEventListener::EHistoryEventType event, void* pData = nullptr);
|
||||
|
||||
void SetActiveGroupInt(const SXmlHistoryGroup* pGroup, const char* displayName = nullptr, bool bRecordNullUndo = false, const TGroupIndexMap& groupIndex = TGroupIndexMap());
|
||||
void UnloadInt();
|
||||
void ClearRedo();
|
||||
|
||||
void RecordUndoInternal(const char* desc);
|
||||
void RemoveListFromList(TXmlHistotyGroupPtrList& list, const TXmlHistotyGroupPtrList& removeList);
|
||||
|
||||
bool IsEventHandlerValid(IXmlUndoEventHandler* pEventHandler);
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_UTIL_XMLHISTORYMANAGER_H
|
||||
@@ -498,9 +498,7 @@ set(FILES
|
||||
UndoViewPosition.h
|
||||
UndoViewRotation.h
|
||||
Util/GeometryUtil.h
|
||||
Util/IXmlHistoryManager.h
|
||||
Util/KDTree.h
|
||||
Util/XmlHistoryManager.h
|
||||
WipFeaturesDlg.h
|
||||
WipFeaturesDlg.ui
|
||||
WipFeaturesDlg.qrc
|
||||
@@ -735,14 +733,12 @@ set(FILES
|
||||
Util/PredefinedAspectRatios.h
|
||||
Util/StringHelpers.cpp
|
||||
Util/StringHelpers.h
|
||||
Util/StringNoCasePredicate.h
|
||||
Util/TRefCountBase.h
|
||||
Util/Triangulate.cpp
|
||||
Util/Triangulate.h
|
||||
Util/Util.h
|
||||
Util/XmlArchive.cpp
|
||||
Util/XmlArchive.h
|
||||
Util/XmlHistoryManager.cpp
|
||||
Util/XmlTemplate.cpp
|
||||
Util/XmlTemplate.h
|
||||
Util/bitarray.h
|
||||
|
||||
@@ -38,7 +38,6 @@ namespace AZ
|
||||
void DebugBreak();
|
||||
#endif
|
||||
void Terminate(int exitCode);
|
||||
void OutputToDebugger(const char* window, const char* message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,11 @@ namespace AZ
|
||||
{
|
||||
namespace Debug
|
||||
{
|
||||
namespace Platform
|
||||
{
|
||||
void OutputToDebugger(const char* window, const char* message);
|
||||
}
|
||||
|
||||
/// Global instance to the tracer.
|
||||
extern class Trace g_tracer;
|
||||
|
||||
|
||||
@@ -51,88 +51,86 @@
|
||||
# define azvscprintf(_format, _va_list) _vscprintf(_format, _va_list)
|
||||
# define azscwprintf _scwprintf
|
||||
# define azvscwprintf _vscwprintf
|
||||
# define azstrtok(_buffer, _size, _delim, _context) strtok_s(_buffer, _delim, _context)
|
||||
# define azstrcat strcat_s
|
||||
# define azstrncat strncat_s
|
||||
# define strtoll _strtoi64
|
||||
# define strtoull _strtoui64
|
||||
# define azsscanf sscanf_s
|
||||
# define azstrcpy strcpy_s
|
||||
# define azstrncpy strncpy_s
|
||||
# define azstricmp _stricmp
|
||||
# define azstrnicmp _strnicmp
|
||||
# define azisfinite _finite
|
||||
# define azltoa _ltoa_s
|
||||
# define azitoa _itoa_s
|
||||
# define azui64toa _ui64toa_s
|
||||
# define azswscanf swscanf_s
|
||||
# define azwcsicmp _wcsicmp
|
||||
# define azwcsnicmp _wcsnicmp
|
||||
# define azmemicmp _memicmp
|
||||
# define azstrtok(_buffer, _size, _delim, _context) strtok_s(_buffer, _delim, _context)
|
||||
# define azstrcat(_dest, _destSize, _src) strcat_s(_dest, _destSize, _src)
|
||||
# define azstrncat(_dest, _destSize, _src, _count) strncat_s(_dest, _destSize, _src, _count)
|
||||
# define strtoll _strtoi64
|
||||
# define strtoull _strtoui64
|
||||
# define azsscanf sscanf_s
|
||||
# define azstrcpy(_dest, _destSize, _src) strcpy_s(_dest, _destSize, _src)
|
||||
# define azstrncpy(_dest, _destSize, _src, _count) strncpy_s(_dest, _destSize, _src, _count)
|
||||
# define azstricmp _stricmp
|
||||
# define azstrnicmp _strnicmp
|
||||
# define azisfinite _finite
|
||||
# define azltoa _ltoa_s
|
||||
# define azitoa _itoa_s
|
||||
# define azui64toa _ui64toa_s
|
||||
# define azswscanf swscanf_s
|
||||
# define azwcsicmp _wcsicmp
|
||||
# define azwcsnicmp _wcsnicmp
|
||||
|
||||
// note: for cross-platform compatibility, do not use the return value of azfopen. On Windows, it's an errno_t and 0 indicates success. On other platforms, the return value is a FILE*, and a 0 value indicates failure.
|
||||
# define azfopen fopen_s
|
||||
# define azfscanf fscanf_s
|
||||
# define azfopen(_fp, _filename, _attrib) fopen_s(_fp, _filename, _attrib)
|
||||
# define azfscanf fscanf_s
|
||||
|
||||
# define azsprintf(_buffer, ...) sprintf_s(_buffer, AZ_ARRAY_SIZE(_buffer), __VA_ARGS__)
|
||||
# define azstrlwr _strlwr_s
|
||||
# define azvsprintf vsprintf_s
|
||||
# define azwcscpy wcscpy_s
|
||||
# define azstrtime _strtime_s
|
||||
# define azstrdate _strdate_s
|
||||
# define azlocaltime(time, result) localtime_s(result, time)
|
||||
# define azsprintf(_buffer, ...) sprintf_s(_buffer, AZ_ARRAY_SIZE(_buffer), __VA_ARGS__)
|
||||
# define azstrlwr _strlwr_s
|
||||
# define azvsprintf vsprintf_s
|
||||
# define azwcscpy wcscpy_s
|
||||
# define azstrtime _strtime_s
|
||||
# define azstrdate _strdate_s
|
||||
# define azlocaltime(time, result) localtime_s(result, time)
|
||||
#else
|
||||
# define azsnprintf snprintf
|
||||
# define azvsnprintf vsnprintf
|
||||
# define azsnprintf snprintf
|
||||
# define azvsnprintf vsnprintf
|
||||
# if AZ_TRAIT_COMPILER_DEFINE_AZSWNPRINTF_AS_SWPRINTF
|
||||
# define azsnwprintf swprintf
|
||||
# define azvsnwprintf vswprintf
|
||||
# define azsnwprintf swprintf
|
||||
# define azvsnwprintf vswprintf
|
||||
# else
|
||||
# define azsnwprintf snwprintf
|
||||
# define azvsnwprintf vsnwprintf
|
||||
# define azsnwprintf snwprintf
|
||||
# define azvsnwprintf vsnwprintf
|
||||
# endif
|
||||
# define azscprintf(...) azsnprintf(nullptr, static_cast<size_t>(0), __VA_ARGS__);
|
||||
# define azvscprintf(_format, _va_list) azvsnprintf(nullptr, static_cast<size_t>(0), _format, _va_list);
|
||||
# define azscwprintf(...) azsnwprintf(nullptr, static_cast<size_t>(0), __VA_ARGS__);
|
||||
# define azvscwprintf(_format, _va_list) azvsnwprintf(nullptr, static_cast<size_t>(0), _format, _va_list);
|
||||
# define azstrtok(_buffer, _size, _delim, _context) strtok(_buffer, _delim)
|
||||
# define azstrcat(_dest, _destSize, _src) strcat(_dest, _src)
|
||||
# define azstrncat(_dest, _destSize, _src, _count) strncat(_dest, _src, _count)
|
||||
# define azsscanf sscanf
|
||||
# define azstrcpy(_dest, _destSize, _src) strcpy(_dest, _src)
|
||||
# define azstrncpy(_dest, _destSize, _src, _count) strncpy(_dest, _src, _count)
|
||||
# define azstricmp strcasecmp
|
||||
# define azstrnicmp strncasecmp
|
||||
# define azscprintf(...) azsnprintf(nullptr, static_cast<size_t>(0), __VA_ARGS__);
|
||||
# define azvscprintf(_format, _va_list) azvsnprintf(nullptr, static_cast<size_t>(0), _format, _va_list);
|
||||
# define azscwprintf(...) azsnwprintf(nullptr, static_cast<size_t>(0), __VA_ARGS__);
|
||||
# define azvscwprintf(_format, _va_list) azvsnwprintf(nullptr, static_cast<size_t>(0), _format, _va_list);
|
||||
# define azstrtok(_buffer, _size, _delim, _context) strtok(_buffer, _delim)
|
||||
# define azstrcat(_dest, _destSize, _src) strcat(_dest, _src)
|
||||
# define azstrncat(_dest, _destSize, _src, _count) strncat(_dest, _src, _count)
|
||||
# define azsscanf sscanf
|
||||
# define azstrcpy(_dest, _destSize, _src) strcpy(_dest, _src)
|
||||
# define azstrncpy(_dest, _destSize, _src, _count) strncpy(_dest, _src, _count)
|
||||
# define azstricmp strcasecmp
|
||||
# define azstrnicmp strncasecmp
|
||||
# if defined(NDK_REV_MAJOR) && NDK_REV_MAJOR < 16
|
||||
# define azisfinite __isfinitef
|
||||
# define azisfinite __isfinitef
|
||||
# else
|
||||
# define azisfinite isfinite
|
||||
# define azisfinite isfinite
|
||||
# endif
|
||||
# define azltoa(_value, _buffer, _size, _radix) ltoa(_value, _buffer, _radix)
|
||||
# define azitoa(_value, _buffer, _size, _radix) itoa(_value, _buffer, _radix)
|
||||
# define azui64toa(_value, _buffer, _size, _radix) _ui64toa(_value, _buffer, _radix)
|
||||
# define azswscanf swscanf
|
||||
# define azwcsicmp wcsicmp
|
||||
# define azwcsnicmp wcsnicmp
|
||||
# define azmemicmp memicmp
|
||||
# define azltoa(_value, _buffer, _size, _radix) ltoa(_value, _buffer, _radix)
|
||||
# define azitoa(_value, _buffer, _size, _radix) itoa(_value, _buffer, _radix)
|
||||
# define azui64toa(_value, _buffer, _size, _radix) _ui64toa(_value, _buffer, _radix)
|
||||
# define azswscanf swscanf
|
||||
# define azwcsicmp wcscasecmp
|
||||
# define azwcsnicmp wcsnicmp
|
||||
|
||||
// note: for cross-platform compatibility, do not use the return value of azfopen. On Windows, it's an errno_t and 0 indicates success. On other platforms, the return value is a FILE*, and a 0 value indicates failure.
|
||||
# define azfopen(_fp, _filename, _attrib) *(_fp) = fopen(_filename, _attrib)
|
||||
# define azfscanf fscanf
|
||||
# define azfopen(_fp, _filename, _attrib) *(_fp) = fopen(_filename, _attrib)
|
||||
# define azfscanf fscanf
|
||||
|
||||
# define azsprintf sprintf
|
||||
# define azstrlwr(_buffer, _size) strlwr(_buffer)
|
||||
# define azvsprintf vsprintf
|
||||
# define azwcscpy(_dest, _size, _buffer) wcscpy(_dest, _buffer)
|
||||
# define azstrtime _strtime
|
||||
# define azstrdate _strdate
|
||||
# define azlocaltime localtime_r
|
||||
# define azsprintf sprintf
|
||||
# define azstrlwr(_buffer, _size) strlwr(_buffer)
|
||||
# define azvsprintf vsprintf
|
||||
# define azwcscpy(_dest, _size, _buffer) wcscpy(_dest, _buffer)
|
||||
# define azstrtime _strtime
|
||||
# define azstrdate _strdate
|
||||
# define azlocaltime localtime_r
|
||||
#endif
|
||||
|
||||
#if AZ_TRAIT_USE_POSIX_STRERROR_R
|
||||
# define azstrerror_s(_dst, _num, _err) strerror_r(_err, _dst, _num)
|
||||
# define azstrerror_s(_dst, _num, _err) strerror_r(_err, _dst, _num)
|
||||
#else
|
||||
# define azstrerror_s strerror_s
|
||||
# define azstrerror_s strerror_s
|
||||
#endif
|
||||
|
||||
#define AZ_INVALID_POINTER reinterpret_cast<void*>(0x0badf00dul)
|
||||
|
||||
@@ -38,13 +38,13 @@ namespace AZStd
|
||||
|
||||
binary_semaphore(bool initialState = false)
|
||||
{
|
||||
m_event = CreateEvent(nullptr, false, initialState, nullptr);
|
||||
m_event = CreateEventW(nullptr, false, initialState, nullptr);
|
||||
AZ_Assert(m_event != NULL, "CreateEvent error: %d\n", GetLastError());
|
||||
}
|
||||
binary_semaphore(const char* name, bool initialState = false)
|
||||
{
|
||||
(void)name; // name is used only for debug, if we pass it to the semaphore it will become named semaphore
|
||||
m_event = CreateEvent(nullptr, false, initialState, nullptr);
|
||||
m_event = CreateEventW(nullptr, false, initialState, nullptr);
|
||||
AZ_Assert(m_event != NULL, "CreateEvent error: %d\n", GetLastError());
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzCore/std/string/fixed_string.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <wctype.h>
|
||||
@@ -30,41 +31,93 @@ namespace AZStd
|
||||
template<size_t Size = sizeof(wchar_t)>
|
||||
struct WCharTPlatformConverter
|
||||
{
|
||||
template<class Allocator1>
|
||||
static inline void to_string(AZStd::basic_string<string::value_type, string::traits_type, Allocator1>& dest, const wchar_t* first, const wchar_t* last)
|
||||
static_assert(Size == size_t{ 2 } || Size == size_t{ 4 }, "only wchar_t types of size 2 or 4 can be converted to utf8");
|
||||
|
||||
template<class Allocator>
|
||||
static inline void to_string(AZStd::basic_string<string::value_type, string::traits_type, Allocator>& dest, AZStd::wstring_view src)
|
||||
{
|
||||
if constexpr (Size == 2)
|
||||
{
|
||||
Utf8::Unchecked::utf16to8(first, last, AZStd::back_inserter(dest));
|
||||
Utf8::Unchecked::utf16to8(src.begin(), src.end(), AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
else if constexpr (Size == 4)
|
||||
{
|
||||
Utf8::Unchecked::utf32to8(first, last, AZStd::back_inserter(dest));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Workaround to defer static_assert evaluation until this function is invoked by using the template parameter
|
||||
using StringType = AZStd::basic_string<string::value_type, string::traits_type, Allocator1>;
|
||||
static_assert(!AZStd::is_same_v<StringType, StringType>, "only wchar_t types of size 2 or 4 can be converted to utf8");
|
||||
Utf8::Unchecked::utf32to8(src.begin(), src.end(), AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
}
|
||||
|
||||
template<class Allocator1>
|
||||
static inline void to_wstring(AZStd::basic_string<wstring::value_type, wstring::traits_type, Allocator1>& dest, const char* first, const char* last)
|
||||
template<size_t MaxElementCount>
|
||||
static inline void to_string(AZStd::basic_fixed_string<string::value_type, MaxElementCount, string::traits_type>& dest, AZStd::wstring_view src)
|
||||
{
|
||||
if constexpr (Size == 2)
|
||||
{
|
||||
Utf8::Unchecked::utf8to16(first, last, AZStd::back_inserter(dest));
|
||||
Utf8::Unchecked::utf16to8(src.begin(), src.end(), AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
else if constexpr (Size == 4)
|
||||
{
|
||||
Utf8::Unchecked::utf8to32(first, last, AZStd::back_inserter(dest));
|
||||
Utf8::Unchecked::utf32to8(src.begin(), src.end(), AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
static inline char* to_string(char* dest, size_t destSize, AZStd::wstring_view src)
|
||||
{
|
||||
if constexpr (Size == 2)
|
||||
{
|
||||
// Workaround to defer static_assert evaluation until this function is invoked by using the template parameter
|
||||
using StringType = AZStd::basic_string<string::value_type, string::traits_type, Allocator1>;
|
||||
static_assert(!AZStd::is_same_v<StringType, StringType>, "Cannot convert a utf8 string to a wchar_t that isn't size 2 or 4");
|
||||
return Utf8::Unchecked::utf16to8(src.begin(), src.end(), dest, destSize);
|
||||
}
|
||||
else if constexpr (Size == 4)
|
||||
{
|
||||
return Utf8::Unchecked::utf32to8(src.begin(), src.end(), dest, destSize);
|
||||
}
|
||||
}
|
||||
|
||||
static inline size_t to_string_length(AZStd::wstring_view src)
|
||||
{
|
||||
if constexpr (Size == 2)
|
||||
{
|
||||
return Utf8::Unchecked::utf16ToUtf8BytesRequired(src.begin(), src.end());
|
||||
}
|
||||
else if constexpr (Size == 4)
|
||||
{
|
||||
return Utf8::Unchecked::utf32ToUtf8BytesRequired(src.begin(), src.end());
|
||||
}
|
||||
}
|
||||
|
||||
template<class Allocator>
|
||||
static inline void to_wstring(AZStd::basic_string<wstring::value_type, wstring::traits_type, Allocator>& dest, AZStd::string_view src)
|
||||
{
|
||||
if constexpr (Size == 2)
|
||||
{
|
||||
Utf8::Unchecked::utf8to16(src.begin(), src.end(), AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
else if constexpr (Size == 4)
|
||||
{
|
||||
Utf8::Unchecked::utf8to32(src.begin(), src.end(), AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
}
|
||||
|
||||
template<size_t MaxElementCount>
|
||||
static inline void to_wstring(AZStd::basic_fixed_string<wstring::value_type, MaxElementCount, wstring::traits_type>& dest, AZStd::string_view src)
|
||||
{
|
||||
if constexpr (Size == 2)
|
||||
{
|
||||
Utf8::Unchecked::utf8to16(src.begin(), src.end(), AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
else if constexpr (Size == 4)
|
||||
{
|
||||
Utf8::Unchecked::utf8to32(src.begin(), src.end(), AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
}
|
||||
|
||||
static inline wchar_t* to_wstring(wchar_t* dest, size_t destSize, AZStd::string_view src)
|
||||
{
|
||||
if constexpr (Size == 2)
|
||||
{
|
||||
return Utf8::Unchecked::utf8to16(src.begin(), src.end(), dest, destSize);
|
||||
}
|
||||
else if constexpr (Size == 4)
|
||||
{
|
||||
return Utf8::Unchecked::utf8to32(src.begin(), src.end(), dest, destSize);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -244,26 +297,32 @@ namespace AZStd
|
||||
inline AZStd::string to_string(long double val) { AZStd::string str; to_string(str, val); return str; }
|
||||
|
||||
// In our engine we assume AZStd::string is Utf8 encoded!
|
||||
template<class Allocator1>
|
||||
void to_string(AZStd::basic_string<string::value_type, string::traits_type, Allocator1>& dest, const wchar_t* str, size_t srcLen = 0)
|
||||
template<class Allocator>
|
||||
void to_string(AZStd::basic_string<string::value_type, string::traits_type, Allocator>& dest, AZStd::wstring_view src)
|
||||
{
|
||||
dest.clear();
|
||||
Internal::WCharTPlatformConverter<>::to_string(dest, src);
|
||||
}
|
||||
|
||||
if (srcLen == 0)
|
||||
{
|
||||
srcLen = wcslen(str);
|
||||
}
|
||||
template<size_t MaxElementCount>
|
||||
void to_string(AZStd::basic_fixed_string<string::value_type, MaxElementCount, string::traits_type>& dest, AZStd::wstring_view src)
|
||||
{
|
||||
dest.clear();
|
||||
Internal::WCharTPlatformConverter<>::to_string(dest, src);
|
||||
}
|
||||
|
||||
if (srcLen > 0)
|
||||
inline void to_string(char* dest, size_t destSize, AZStd::wstring_view src)
|
||||
{
|
||||
char* endStr = Internal::WCharTPlatformConverter<>::to_string(dest, destSize, src);
|
||||
if (endStr < (dest + destSize))
|
||||
{
|
||||
Internal::WCharTPlatformConverter<>::to_string(dest, str, str + srcLen);
|
||||
*endStr = '\0'; // null terminator
|
||||
}
|
||||
}
|
||||
|
||||
template<class Allocator1, class Allocator2>
|
||||
void to_string(AZStd::basic_string<string::value_type, string::traits_type, Allocator1>& dest, const AZStd::basic_string<wstring::value_type, wstring::traits_type, Allocator2>& src)
|
||||
inline size_t to_string_length(AZStd::wstring_view src)
|
||||
{
|
||||
return to_string(dest, src.c_str(), src.length());
|
||||
return Internal::WCharTPlatformConverter<>::to_string_length(src);
|
||||
}
|
||||
|
||||
template<class Allocator>
|
||||
@@ -362,26 +421,27 @@ namespace AZStd
|
||||
inline AZStd::wstring to_wstring(unsigned long long val) { AZStd::wstring wstr; to_wstring(wstr, val); return wstr; }
|
||||
inline AZStd::wstring to_wstring(long double val) { AZStd::wstring wstr; to_wstring(wstr, val); return wstr; }
|
||||
|
||||
template<class Allocator1>
|
||||
void to_wstring(AZStd::basic_string<wstring::value_type, wstring::traits_type, Allocator1>& dest, const char* str, size_t strLen = 0)
|
||||
template<class Allocator>
|
||||
void to_wstring(AZStd::basic_string<wstring::value_type, wstring::traits_type, Allocator>& dest, AZStd::string_view src)
|
||||
{
|
||||
dest.clear();
|
||||
|
||||
if (strLen == 0)
|
||||
{
|
||||
strLen = strlen(str);
|
||||
}
|
||||
|
||||
if (strLen > 0)
|
||||
{
|
||||
Internal::WCharTPlatformConverter<>::to_wstring(dest, str, str + strLen);
|
||||
}
|
||||
Internal::WCharTPlatformConverter<>::to_wstring(dest, src);
|
||||
}
|
||||
|
||||
template<class Allocator1, class Allocator2>
|
||||
void to_wstring(AZStd::basic_string<wstring::value_type, wstring::traits_type, Allocator1>& dest, const AZStd::basic_string<string::value_type, string::traits_type, Allocator2>& src)
|
||||
template<size_t MaxElementCount>
|
||||
void to_wstring(AZStd::basic_fixed_string<wstring::value_type, MaxElementCount, wstring::traits_type>& dest, AZStd::string_view src)
|
||||
{
|
||||
return to_wstring(dest, src.c_str(), src.length());
|
||||
dest.clear();
|
||||
Internal::WCharTPlatformConverter<>::to_wstring(dest, src);
|
||||
}
|
||||
|
||||
inline void to_wstring(wchar_t* dest, size_t destSize, AZStd::string_view src)
|
||||
{
|
||||
wchar_t* endWStr = Internal::WCharTPlatformConverter<>::to_wstring(dest, destSize, src);
|
||||
if (endWStr < (dest + destSize))
|
||||
{
|
||||
*endWStr = '\0'; // null terminator
|
||||
}
|
||||
}
|
||||
|
||||
// Convert a range of chars to lower case
|
||||
|
||||
@@ -92,33 +92,58 @@ namespace Utf8::Unchecked
|
||||
return temp;
|
||||
}
|
||||
|
||||
static Iterator to_utf8_sequence(AZ::u32 cp, Iterator result)
|
||||
static Iterator to_utf8_sequence(AZ::u32 cp, Iterator& result, size_t& resultMaxSize)
|
||||
{
|
||||
if (cp < 0x80)
|
||||
{
|
||||
// one octet
|
||||
resultMaxSize -= 1; // no need to check the calling function will exit the loop
|
||||
*(result++) = static_cast<AZ::u8>(cp);
|
||||
}
|
||||
else if (cp < 0x800)
|
||||
{
|
||||
// two octets
|
||||
*(result++) = static_cast<AZ::u8>((cp >> 6) | 0xc0);
|
||||
*(result++) = static_cast<AZ::u8>((cp & 0x3f) | 0x80);
|
||||
if (resultMaxSize >= 2)
|
||||
{
|
||||
*(result++) = static_cast<AZ::u8>((cp >> 6) | 0xc0);
|
||||
*(result++) = static_cast<AZ::u8>((cp & 0x3f) | 0x80);
|
||||
resultMaxSize -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
resultMaxSize = 0;
|
||||
}
|
||||
}
|
||||
else if (cp < 0x10000)
|
||||
{
|
||||
// three octets
|
||||
*(result++) = static_cast<AZ::u8>((cp >> 12) | 0xe0);
|
||||
*(result++) = static_cast<AZ::u8>(((cp >> 6) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<AZ::u8>((cp & 0x3f) | 0x80);
|
||||
if (resultMaxSize >= 3)
|
||||
{
|
||||
*(result++) = static_cast<AZ::u8>((cp >> 12) | 0xe0);
|
||||
*(result++) = static_cast<AZ::u8>(((cp >> 6) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<AZ::u8>((cp & 0x3f) | 0x80);
|
||||
resultMaxSize -= 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
resultMaxSize = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// four octets
|
||||
*(result++) = static_cast<AZ::u8>((cp >> 18) | 0xf0);
|
||||
*(result++) = static_cast<AZ::u8>(((cp >> 12) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<AZ::u8>(((cp >> 6) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<AZ::u8>((cp & 0x3f) | 0x80);
|
||||
if (resultMaxSize >= 4)
|
||||
{
|
||||
*(result++) = static_cast<AZ::u8>((cp >> 18) | 0xf0);
|
||||
*(result++) = static_cast<AZ::u8>(((cp >> 12) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<AZ::u8>(((cp >> 6) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<AZ::u8>((cp & 0x3f) | 0x80);
|
||||
resultMaxSize -= 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
resultMaxSize = 0;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -155,8 +180,99 @@ namespace Utf8::Unchecked
|
||||
};
|
||||
|
||||
template <typename u16bit_iterator, typename Utf8Iterator>
|
||||
Utf8Iterator utf16to8(u16bit_iterator start, u16bit_iterator end, Utf8Iterator result)
|
||||
Utf8Iterator utf16to8(u16bit_iterator start, u16bit_iterator end, Utf8Iterator result, size_t resultMaxSize)
|
||||
{
|
||||
while (start != end && resultMaxSize > 0)
|
||||
{
|
||||
AZ::u32 cp = Utf8::Internal::mask16(*start++);
|
||||
// Take care of surrogate pairs first
|
||||
if (Utf8::Internal::is_lead_surrogate(cp))
|
||||
{
|
||||
AZ::u32 trail_surrogate = Utf8::Internal::mask16(*start++);
|
||||
cp = (cp << 10) + trail_surrogate + Internal::SURROGATE_OFFSET;
|
||||
}
|
||||
octet_iterator<Utf8Iterator>::to_utf8_sequence(cp, result, resultMaxSize);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename u16bit_iterator, typename Utf8Iterator>
|
||||
u16bit_iterator utf8to16(Utf8Iterator start, Utf8Iterator end, u16bit_iterator result, size_t resultMaxSize)
|
||||
{
|
||||
octet_iterator utf8Start(start);
|
||||
octet_iterator utf8Last(end);
|
||||
while (utf8Start != utf8Last && resultMaxSize > 0)
|
||||
{
|
||||
AZ::u32 cp = *utf8Start++;
|
||||
if (cp > 0xffff)
|
||||
{
|
||||
//make a surrogate pair
|
||||
if (resultMaxSize >= 2)
|
||||
{
|
||||
*result++ = static_cast<AZ::u16>((cp >> 10) + Internal::LEAD_OFFSET);
|
||||
*result++ = static_cast<AZ::u16>((cp & 0x3ff) + Internal::TRAIL_SURROGATE_MIN);
|
||||
resultMaxSize -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
resultMaxSize = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*result++ = static_cast<AZ::u16>(cp);
|
||||
resultMaxSize -= 1;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Utf8Iterator, typename u32bit_iterator>
|
||||
Utf8Iterator utf32to8(u32bit_iterator start, u32bit_iterator end, Utf8Iterator result, size_t resultMaxSize)
|
||||
{
|
||||
while (start != end && resultMaxSize > 0)
|
||||
{
|
||||
octet_iterator<Utf8Iterator>::to_utf8_sequence(*start++, result, resultMaxSize);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Utf8Iterator, typename u32bit_iterator>
|
||||
u32bit_iterator utf8to32(Utf8Iterator start, Utf8Iterator end, u32bit_iterator result, size_t resultMaxSize)
|
||||
{
|
||||
octet_iterator utf8Start(start);
|
||||
octet_iterator utf8Last(end);
|
||||
while (utf8Start != utf8Last && resultMaxSize > 0)
|
||||
{
|
||||
*result++ = *utf8Start++;
|
||||
--resultMaxSize;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static constexpr size_t utf8_codepoint_length(AZ::u32 cp)
|
||||
{
|
||||
if (cp < 0x80)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (cp < 0x800)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
else if (cp < 0x10000)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
template <typename u16bit_iterator>
|
||||
size_t utf16ToUtf8BytesRequired(u16bit_iterator start, u16bit_iterator end)
|
||||
{
|
||||
size_t bytesRequired = 0;
|
||||
while (start != end)
|
||||
{
|
||||
AZ::u32 cp = Utf8::Internal::mask16(*start++);
|
||||
@@ -166,56 +282,23 @@ namespace Utf8::Unchecked
|
||||
AZ::u32 trail_surrogate = Utf8::Internal::mask16(*start++);
|
||||
cp = (cp << 10) + trail_surrogate + Internal::SURROGATE_OFFSET;
|
||||
}
|
||||
octet_iterator<Utf8Iterator>::to_utf8_sequence(cp, result);
|
||||
bytesRequired += utf8_codepoint_length(cp);
|
||||
}
|
||||
return result;
|
||||
return bytesRequired;
|
||||
}
|
||||
|
||||
template <typename u16bit_iterator, typename Utf8Iterator>
|
||||
u16bit_iterator utf8to16(Utf8Iterator start, Utf8Iterator end, u16bit_iterator result)
|
||||
{
|
||||
octet_iterator utf8Start(start);
|
||||
octet_iterator utf8Last(end);
|
||||
while (utf8Start != utf8Last)
|
||||
{
|
||||
AZ::u32 cp = *utf8Start++;
|
||||
if (cp > 0xffff)
|
||||
{
|
||||
//make a surrogate pair
|
||||
*result++ = static_cast<AZ::u16>((cp >> 10) + Internal::LEAD_OFFSET);
|
||||
*result++ = static_cast<AZ::u16>((cp & 0x3ff) + Internal::TRAIL_SURROGATE_MIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
*result++ = static_cast<AZ::u16>(cp);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Utf8Iterator, typename u32bit_iterator>
|
||||
Utf8Iterator utf32to8(u32bit_iterator start, u32bit_iterator end, Utf8Iterator result)
|
||||
template <typename u32bit_iterator>
|
||||
size_t utf32ToUtf8BytesRequired(u32bit_iterator start, u32bit_iterator end)
|
||||
{
|
||||
size_t bytesRequired = 0;
|
||||
while (start != end)
|
||||
{
|
||||
octet_iterator<Utf8Iterator>::to_utf8_sequence(*start++, result);
|
||||
bytesRequired += utf8_codepoint_length(*start++);
|
||||
}
|
||||
|
||||
return result;
|
||||
return bytesRequired;
|
||||
}
|
||||
|
||||
template <typename Utf8Iterator, typename u32bit_iterator>
|
||||
u32bit_iterator utf8to32(Utf8Iterator start, Utf8Iterator end, u32bit_iterator result)
|
||||
{
|
||||
octet_iterator utf8Start(start);
|
||||
octet_iterator utf8Last(end);
|
||||
while (utf8Start != utf8Last)
|
||||
{
|
||||
*result++ = *utf8Start++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
} // namespace Utf8::Unchecked
|
||||
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace AZ
|
||||
|
||||
void OutputToDebugger(const char*, const char*)
|
||||
{
|
||||
// std::cout << title << ": " << message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzCore/Debug/TraceMessagesDrillerBus.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <AzCore/std/string/fixed_string.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -22,7 +24,7 @@ namespace AZ
|
||||
LPTOP_LEVEL_EXCEPTION_FILTER g_previousExceptionHandler = nullptr;
|
||||
#endif
|
||||
|
||||
const int g_maxMessageLength = 4096;
|
||||
constexpr int g_maxMessageLength = 4096;
|
||||
|
||||
namespace Debug
|
||||
{
|
||||
@@ -58,19 +60,18 @@ namespace AZ
|
||||
TerminateProcess(GetCurrentProcess(), exitCode);
|
||||
}
|
||||
|
||||
void OutputToDebugger(const char* window, const char* message)
|
||||
void OutputToDebugger([[maybe_unused]] const char* window, const char* message)
|
||||
{
|
||||
AZ_UNUSED(window);
|
||||
#ifdef _UNICODE
|
||||
wchar_t messageW[g_maxMessageLength];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, messageW, message, g_maxMessageLength - 1) == 0)
|
||||
AZStd::fixed_wstring<g_maxMessageLength> tmpW;
|
||||
if(window)
|
||||
{
|
||||
OutputDebugStringW(messageW);
|
||||
AZStd::to_wstring(tmpW, window);
|
||||
tmpW += L": ";
|
||||
OutputDebugStringW(tmpW.c_str());
|
||||
tmpW.clear();
|
||||
}
|
||||
#else // !_UNICODE
|
||||
OutputDebugString(message);
|
||||
#endif // !_UNICODE
|
||||
AZStd::to_wstring(tmpW, message);
|
||||
OutputDebugStringW(tmpW.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace
|
||||
//=========================================================================
|
||||
DWORD GetAttributes(const char* fileName)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
wchar_t fileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, fileNameW, fileName, AZ_ARRAY_SIZE(fileNameW) - 1) == 0)
|
||||
@@ -39,9 +38,6 @@ namespace
|
||||
{
|
||||
return INVALID_FILE_ATTRIBUTES;
|
||||
}
|
||||
#else //!_UNICODE
|
||||
return GetFileAttributes(fileName);
|
||||
#endif // !_UNICODE
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
@@ -51,7 +47,6 @@ namespace
|
||||
//=========================================================================
|
||||
BOOL SetAttributes(const char* fileName, DWORD fileAttributes)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
wchar_t fileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, fileNameW, fileName, AZ_ARRAY_SIZE(fileNameW) - 1) == 0)
|
||||
@@ -62,9 +57,6 @@ namespace
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
#else //!_UNICODE
|
||||
return SetFileAttributes(fileName, fileAttributes);
|
||||
#endif // !_UNICODE
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
@@ -76,7 +68,6 @@ namespace
|
||||
// * GetLastError() on Windows-like platforms
|
||||
// * errno on Unix platforms
|
||||
//=========================================================================
|
||||
#if defined(_UNICODE)
|
||||
bool CreateDirRecursive(wchar_t* dirPath)
|
||||
{
|
||||
if (CreateDirectoryW(dirPath, nullptr))
|
||||
@@ -112,53 +103,6 @@ namespace
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
bool CreateDirRecursive(char* dirPath)
|
||||
{
|
||||
if (CreateDirectory(dirPath, nullptr))
|
||||
{
|
||||
return true; // Created without error
|
||||
}
|
||||
DWORD error = GetLastError();
|
||||
if (error == ERROR_PATH_NOT_FOUND)
|
||||
{
|
||||
// try to create our parent hierarchy
|
||||
for (size_t i = strlen(dirPath); i > 0; --i)
|
||||
{
|
||||
if (dirPath[i] == '/' || dirPath[i] == '\\')
|
||||
{
|
||||
char delimiter = dirPath[i];
|
||||
dirPath[i] = 0; // null-terminate at the previous slash
|
||||
bool ret = CreateDirRecursive(dirPath);
|
||||
dirPath[i] = delimiter; // restore slash
|
||||
if (ret)
|
||||
{
|
||||
// now that our parent is created, try to create again
|
||||
if (CreateDirectory(dirPath, nullptr))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
DWORD creationError = GetLastError();
|
||||
if (creationError == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
DWORD attributes = GetFileAttributes(dirPath);
|
||||
return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// if we reach here then there was no parent folder to create, so we failed for other reasons
|
||||
}
|
||||
else if (error == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
DWORD attributes = GetFileAttributes(dirPath);
|
||||
return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const SystemFile::FileHandleType PlatformSpecificInvalidHandle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
@@ -208,7 +152,6 @@ bool SystemFile::PlatformOpen(int mode, int platformFlags)
|
||||
CreatePath(m_fileName.c_str());
|
||||
}
|
||||
|
||||
# ifdef _UNICODE
|
||||
wchar_t fileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
m_handle = INVALID_HANDLE_VALUE;
|
||||
@@ -216,9 +159,6 @@ bool SystemFile::PlatformOpen(int mode, int platformFlags)
|
||||
{
|
||||
m_handle = CreateFileW(fileNameW, dwDesiredAccess, dwShareMode, 0, dwCreationDisposition, dwFlagsAndAttributes, 0);
|
||||
}
|
||||
# else //!_UNICODE
|
||||
m_handle = CreateFile(m_fileName.c_str(), dwDesiredAccess, dwShareMode, 0, dwCreationDisposition, dwFlagsAndAttributes, 0);
|
||||
# endif // !_UNICODE
|
||||
|
||||
if (m_handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@@ -417,7 +357,6 @@ namespace Platform
|
||||
HANDLE hFile;
|
||||
int lastError;
|
||||
|
||||
#ifdef _UNICODE
|
||||
wchar_t filterW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
hFile = INVALID_HANDLE_VALUE;
|
||||
@@ -425,39 +364,28 @@ namespace Platform
|
||||
{
|
||||
hFile = FindFirstFile(filterW, &fd);
|
||||
}
|
||||
#else // !_UNICODE
|
||||
hFile = FindFirstFile(filter, &fd);
|
||||
#endif // !_UNICODE
|
||||
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
const char* fileName;
|
||||
|
||||
#ifdef _UNICODE
|
||||
char fileNameA[AZ_MAX_PATH_LEN];
|
||||
fileName = NULL;
|
||||
if (wcstombs_s(&numCharsConverted, fileNameA, fd.cFileName, AZ_ARRAY_SIZE(fileNameA) - 1) == 0)
|
||||
{
|
||||
fileName = fileNameA;
|
||||
}
|
||||
#else // !_UNICODE
|
||||
fileName = fd.cFileName;
|
||||
#endif // !_UNICODE
|
||||
|
||||
cb(fileName, (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0);
|
||||
|
||||
// List all the other files in the directory.
|
||||
while (FindNextFile(hFile, &fd) != 0)
|
||||
while (FindNextFileW(hFile, &fd) != 0)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
fileName = NULL;
|
||||
if (wcstombs_s(&numCharsConverted, fileNameA, fd.cFileName, AZ_ARRAY_SIZE(fileNameA) - 1) == 0)
|
||||
{
|
||||
fileName = fileNameA;
|
||||
}
|
||||
#else // !_UNICODE
|
||||
fileName = fd.cFileName;
|
||||
#endif // !_UNICODE
|
||||
|
||||
cb(fileName, (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0);
|
||||
}
|
||||
@@ -483,16 +411,12 @@ namespace Platform
|
||||
{
|
||||
HANDLE handle = nullptr;
|
||||
|
||||
#ifdef _UNICODE
|
||||
wchar_t fileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, fileNameW, fileName, AZ_ARRAY_SIZE(fileNameW) - 1) == 0)
|
||||
{
|
||||
handle = CreateFileW(fileNameW, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
||||
}
|
||||
#else // !_UNICODE
|
||||
handle = CreateFileA(fileName, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
||||
#endif // !_UNICODE
|
||||
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@@ -524,16 +448,12 @@ namespace Platform
|
||||
WIN32_FILE_ATTRIBUTE_DATA data = { 0 };
|
||||
BOOL result = FALSE;
|
||||
|
||||
#ifdef _UNICODE
|
||||
wchar_t fileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, fileNameW, fileName, AZ_ARRAY_SIZE(fileNameW) - 1) == 0)
|
||||
{
|
||||
result = GetFileAttributesExW(fileNameW, GetFileExInfoStandard, &data);
|
||||
}
|
||||
#else // !_UNICODE
|
||||
result = GetFileAttributesExA(fileName, GetFileExInfoStandard, &data);
|
||||
#endif // !_UNICODE
|
||||
|
||||
if (result)
|
||||
{
|
||||
@@ -553,7 +473,6 @@ namespace Platform
|
||||
|
||||
bool Delete(const char* fileName)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
wchar_t fileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, fileNameW, fileName, AZ_ARRAY_SIZE(fileNameW) - 1) == 0)
|
||||
@@ -568,20 +487,12 @@ namespace Platform
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#else // !_UNICODE
|
||||
if (DeleteFile(fileName) == 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, fileName, (int)GetLastError());
|
||||
return false;
|
||||
}
|
||||
#endif // !_UNICODE
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Rename(const char* sourceFileName, const char* targetFileName, bool overwrite)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
wchar_t sourceFileNameW[AZ_MAX_PATH_LEN];
|
||||
wchar_t targetFileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
@@ -598,13 +509,6 @@ namespace Platform
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#else // !_UNICODE
|
||||
if (MoveFileEx(sourceFileName, targetFileName, overwrite ? MOVEFILE_REPLACE_EXISTING : 0) == 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, sourceFileName, (int)GetLastError());
|
||||
return false;
|
||||
}
|
||||
#endif // !_UNICODE
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -639,7 +543,6 @@ namespace Platform
|
||||
{
|
||||
if (dirName)
|
||||
{
|
||||
#if defined(_UNICODE)
|
||||
wchar_t dirPath[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, dirPath, dirName, AZ_ARRAY_SIZE(dirPath) - 1) == 0)
|
||||
@@ -651,18 +554,6 @@ namespace Platform
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#else
|
||||
char dirPath[AZ_MAX_PATH_LEN];
|
||||
if (azstrcpy(dirPath, AZ_ARRAY_SIZE(dirPath), dirName) == 0)
|
||||
{
|
||||
bool success = CreateDirRecursive(dirPath);
|
||||
if (!success)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, dirName, (int)GetLastError());
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -671,16 +562,12 @@ namespace Platform
|
||||
{
|
||||
if (dirName)
|
||||
{
|
||||
#if defined(_UNICODE)
|
||||
wchar_t dirNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, dirNameW, dirName, AZ_ARRAY_SIZE(dirNameW) - 1) == 0)
|
||||
{
|
||||
return RemoveDirectory(dirNameW) != 0;
|
||||
}
|
||||
#else
|
||||
return RemoveDirectory(dirName) != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
-5
@@ -98,7 +98,6 @@ namespace AZ
|
||||
|
||||
bool alreadyLoaded = false;
|
||||
|
||||
# ifdef _UNICODE
|
||||
wchar_t fileNameW[MAX_PATH];
|
||||
size_t numCharsConverted;
|
||||
errno_t wcharResult = mbstowcs_s(&numCharsConverted, fileNameW, m_fileName.c_str(), AZ_ARRAY_SIZE(fileNameW) - 1);
|
||||
@@ -114,10 +113,6 @@ namespace AZ
|
||||
m_handle = NULL;
|
||||
return LoadStatus::LoadFailure;
|
||||
}
|
||||
# else //!_UNICODE
|
||||
alreadyLoaded = NULL != GetModuleHandleA(m_fileName.c_str());
|
||||
m_handle = LoadLibraryA(m_fileName.c_str());
|
||||
# endif // !_UNICODE
|
||||
|
||||
if (m_handle)
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/std/optional.h>
|
||||
#include <AzCore/std/string/fixed_string.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -29,7 +30,8 @@ namespace AZ
|
||||
result.m_pathIncludesFilename = true;
|
||||
// Platform specific get exe path: http://stackoverflow.com/a/1024937
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulefilenamea
|
||||
const DWORD pathLen = GetModuleFileNameA(nullptr, exeStorageBuffer, static_cast<DWORD>(exeStorageSize));
|
||||
wchar_t pathBufferW[AZ::IO::MaxPathLength] = { 0 };
|
||||
const DWORD pathLen = GetModuleFileNameW(nullptr, pathBufferW, static_cast<DWORD>(AZStd::size(pathBufferW)));
|
||||
const DWORD errorCode = GetLastError();
|
||||
if (pathLen == exeStorageSize && errorCode == ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
@@ -39,6 +41,18 @@ namespace AZ
|
||||
{
|
||||
result.m_pathStored = ExecutablePathResult::GeneralError;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t utf8PathSize = AZStd::to_string_length({ pathBufferW, pathLen });
|
||||
if (utf8PathSize >= exeStorageSize)
|
||||
{
|
||||
result.m_pathStored = ExecutablePathResult::BufferSizeNotLargeEnough;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZStd::to_string(exeStorageBuffer, exeStorageSize, pathBufferW);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -71,27 +71,11 @@ extern "C"
|
||||
using LPSECURITY_ATTRIBUTES = SECURITY_ATTRIBUTES*;
|
||||
|
||||
// Semaphore
|
||||
AZ_DLL_IMPORT HANDLE _stdcall CreateSemaphoreA(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lInitialCount, LONG lMaximumCount, LPCSTR lpName);
|
||||
AZ_DLL_IMPORT HANDLE _stdcall CreateSemaphoreW(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lInitialCount, LONG lMaximumCount, LPCWSTR lpName);
|
||||
AZ_DLL_IMPORT BOOL _stdcall ReleaseSemaphore(HANDLE hSemaphore, LONG lReleaseCount, LPLONG lpPreviousCount);
|
||||
#ifndef CreateSemaphore
|
||||
#ifdef UNICODE
|
||||
#define CreateSemaphore CreateSemaphoreW
|
||||
#else
|
||||
#define CreateSemaphore CreateSemaphoreA
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Event
|
||||
AZ_DLL_IMPORT HANDLE _stdcall CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName);
|
||||
AZ_DLL_IMPORT HANDLE _stdcall CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCWSTR lpName);
|
||||
#ifndef CreateEvent
|
||||
#ifdef UNICODE
|
||||
#define CreateEvent CreateEventW
|
||||
#else
|
||||
#define CreateEvent CreateEventA
|
||||
#endif
|
||||
#endif
|
||||
AZ_DLL_IMPORT BOOL _stdcall SetEvent(HANDLE);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -15,14 +15,14 @@ namespace AZStd
|
||||
{
|
||||
inline semaphore::semaphore(unsigned int initialCount, unsigned int maximumCount)
|
||||
{
|
||||
m_semaphore = CreateSemaphore(NULL, initialCount, maximumCount, 0);
|
||||
m_semaphore = CreateSemaphoreW(NULL, initialCount, maximumCount, 0);
|
||||
AZ_Assert(m_semaphore != NULL, "CreateSemaphore error: %d\n", GetLastError());
|
||||
}
|
||||
|
||||
inline semaphore::semaphore(const char* name, unsigned int initialCount, unsigned int maximumCount)
|
||||
{
|
||||
(void)name; // name is used only for debug, if we pass it to the semaphore it will become named semaphore
|
||||
m_semaphore = CreateSemaphore(NULL, initialCount, maximumCount, 0);
|
||||
m_semaphore = CreateSemaphoreW(NULL, initialCount, maximumCount, 0);
|
||||
AZ_Assert(m_semaphore != NULL, "CreateSemaphore error: %d\n", GetLastError());
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <AzCore/Debug/Trace.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -14,8 +15,9 @@ namespace AZ
|
||||
{
|
||||
namespace Platform
|
||||
{
|
||||
void OutputToDebugger(const char*, const char*)
|
||||
void OutputToDebugger([[maybe_unused]] const char* title, [[maybe_unused]] const char* message)
|
||||
{
|
||||
// std::cout << title << ": " << message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,20 +29,19 @@ namespace AZ
|
||||
return errno;
|
||||
}
|
||||
|
||||
void SharedMemory_Mac::ComposeMutexName(char* dest, size_t length, const char* name)
|
||||
void ComposeName(char* dest, size_t length, const char* name, const char* suffix)
|
||||
{
|
||||
azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name));
|
||||
|
||||
// sem_open doesn't support paths bigger than 31, so call it s_Mtx.
|
||||
// While this is enough for Profiler, maybe the code should be smarter
|
||||
// and trim the name instead
|
||||
azsnprintf(dest, length, "/tmp/%s_Mtx", name);
|
||||
azsnprintf(dest, length, "/tmp/%s_%s", name, suffix);
|
||||
}
|
||||
|
||||
SharedMemory_Common::CreateResult SharedMemory_Mac::Create(const char* name, unsigned int size, bool openIfCreated)
|
||||
{
|
||||
char fullName[256];
|
||||
ComposeMutexName(fullName, AZ_ARRAY_SIZE(fullName), name);
|
||||
azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name));
|
||||
ComposeName(fullName, AZ_ARRAY_SIZE(fullName), name, "Mtx");
|
||||
|
||||
m_globalMutex = sem_open(fullName, O_CREAT | O_EXCL, 0600, 1);
|
||||
int error = errno;
|
||||
@@ -59,7 +58,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
// Create the file mapping.
|
||||
azsnprintf(fullName, AZ_ARRAY_SIZE(fullName), "%s_Data", name);
|
||||
ComposeName(fullName, AZ_ARRAY_SIZE(fullName), name, "Data");
|
||||
m_mapHandle = shm_open(fullName, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||
error = errno;
|
||||
if (error == EEXIST)
|
||||
@@ -80,7 +79,8 @@ namespace AZ
|
||||
bool SharedMemory_Mac::Open(const char* name)
|
||||
{
|
||||
char fullName[256];
|
||||
ComposeMutexName(fullName, AZ_ARRAY_SIZE(fullName), name);
|
||||
azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name));
|
||||
ComposeName(fullName, AZ_ARRAY_SIZE(fullName), name, "Mtx");
|
||||
|
||||
m_globalMutex = sem_open(fullName, 0);
|
||||
AZ_Warning("AZSystem", m_globalMutex != nullptr, "Failed to open OS mutex [%s]\n", m_name);
|
||||
@@ -90,7 +90,7 @@ namespace AZ
|
||||
return false;
|
||||
}
|
||||
|
||||
azsnprintf(fullName, AZ_ARRAY_SIZE(fullName), "%s_Data", name);
|
||||
ComposeName(fullName, AZ_ARRAY_SIZE(fullName), name, "Data");
|
||||
m_mapHandle = shm_open(fullName, O_RDWR, 0600);
|
||||
if (m_mapHandle == -1)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace AZ
|
||||
|
||||
static int GetLastError();
|
||||
|
||||
void ComposeMutexName(char* dest, size_t length, const char* name);
|
||||
CreateResult Create(const char* name, unsigned int size, bool openIfCreated);
|
||||
bool Open(const char* name);
|
||||
void Close();
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace AZ {
|
||||
{
|
||||
case CBA_EVENT:
|
||||
evt = (PIMAGEHLP_CBA_EVENT)CallbackData;
|
||||
_tprintf(_T("%s"), (PTSTR)evt->desc);
|
||||
printf("%s", evt->desc);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -301,7 +301,7 @@ namespace AZ {
|
||||
return;
|
||||
}
|
||||
|
||||
const HMODULE hNtDll = GetModuleHandle(_T("ntdll.dll"));
|
||||
const HMODULE hNtDll = GetModuleHandleW(L"ntdll.dll");
|
||||
m_LdrRegisterDllNotification = reinterpret_cast<PLDR_REGISTER_DLL_NOTIFICATION>(GetProcAddress(hNtDll, "LdrRegisterDllNotification"));
|
||||
|
||||
if (m_LdrRegisterDllNotification)
|
||||
@@ -325,7 +325,7 @@ namespace AZ {
|
||||
return;
|
||||
}
|
||||
|
||||
const HMODULE hNtDll = GetModuleHandle(_T("ntdll.dll"));
|
||||
const HMODULE hNtDll = GetModuleHandleW(L"ntdll.dll");
|
||||
m_LdrUnregisterDllNotification = reinterpret_cast<PLDR_UNREGISTER_DLL_NOTIFICATION>(GetProcAddress(hNtDll, "LdrUnregisterDllNotification"));
|
||||
|
||||
if (m_LdrUnregisterDllNotification)
|
||||
@@ -610,8 +610,8 @@ namespace AZ {
|
||||
if (GetFileVersionInfoA(szImg, dwHandle, dwSize, vData) != 0)
|
||||
{
|
||||
UINT len;
|
||||
TCHAR szSubBlock[] = _T("\\");
|
||||
if (VerQueryValue(vData, szSubBlock, (LPVOID*) &fInfo, &len) == 0)
|
||||
TCHAR szSubBlock[] = L"\\";
|
||||
if (VerQueryValueW(vData, szSubBlock, (LPVOID*) &fInfo, &len) == 0)
|
||||
{
|
||||
fInfo = NULL;
|
||||
}
|
||||
@@ -712,7 +712,7 @@ namespace AZ {
|
||||
typedef BOOL (__stdcall * tM32N)(HANDLE hSnapshot, LPMODULEENTRY32 lpme);
|
||||
|
||||
// try both dlls...
|
||||
const TCHAR* dllname[] = { _T("kernel32.dll"), _T("tlhelp32.dll") };
|
||||
const TCHAR* dllname[] = { L"kernel32.dll", L"tlhelp32.dll" };
|
||||
HINSTANCE hToolhelp = NULL;
|
||||
tCT32S pCT32S = NULL;
|
||||
tM32F pM32F = NULL;
|
||||
@@ -823,7 +823,7 @@ namespace AZ {
|
||||
const SIZE_T TTBUFLEN = 8096;
|
||||
int cnt = 0;
|
||||
|
||||
hPsapi = LoadLibrary(_T("psapi.dll"));
|
||||
hPsapi = LoadLibraryW(L"psapi.dll");
|
||||
if (hPsapi == NULL)
|
||||
{
|
||||
return FALSE;
|
||||
@@ -957,10 +957,10 @@ cleanup:
|
||||
// In that scenario, we may try to load and older dbghelp.dll which could cause issues
|
||||
// To overcome this, we try to load dbghelp.dll from the Win 10 SDK folder, if that doesn't
|
||||
// work, load the default.
|
||||
g_dbgHelpDll = LoadLibrary(_T(R"(C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\dbghelp.dll)"));
|
||||
g_dbgHelpDll = LoadLibraryW(LR"(C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\dbghelp.dll)");
|
||||
if (g_dbgHelpDll == NULL)
|
||||
{
|
||||
g_dbgHelpDll = LoadLibrary(_T("dbghelp.dll"));
|
||||
g_dbgHelpDll = LoadLibrary(L"dbghelp.dll");
|
||||
}
|
||||
}
|
||||
if (g_dbgHelpDll == NULL)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <AzCore/std/typetraits/decay.h>
|
||||
#include <AzCore/std/typetraits/is_unsigned.h>
|
||||
#include <AzCore/StringFunc/StringFunc.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
|
||||
namespace AZ::IO
|
||||
{
|
||||
@@ -467,8 +468,10 @@ namespace AZ::IO
|
||||
DWORD createFlags = m_constructionOptions.m_enableUnbufferedReads ? (FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING) : FILE_FLAG_OVERLAPPED;
|
||||
DWORD shareMode = (m_constructionOptions.m_enableSharing || data.m_sharedRead) ? FILE_SHARE_READ: 0;
|
||||
|
||||
file = ::CreateFile(
|
||||
data.m_path.GetAbsolutePath(), // file name
|
||||
AZStd::wstring filenameW;
|
||||
AZStd::to_wstring(filenameW, data.m_path.GetAbsolutePath());
|
||||
file = ::CreateFileW(
|
||||
filenameW.c_str(), // file name
|
||||
FILE_GENERIC_READ, // desired access
|
||||
shareMode, // share mode
|
||||
nullptr, // security attributes
|
||||
@@ -806,7 +809,9 @@ namespace AZ::IO
|
||||
}
|
||||
|
||||
WIN32_FILE_ATTRIBUTE_DATA attributes;
|
||||
if (::GetFileAttributesEx(fileExists.m_path.GetAbsolutePath(), GetFileExInfoStandard, &attributes))
|
||||
AZStd::wstring filenameW;
|
||||
AZStd::to_wstring(filenameW, fileExists.m_path.GetAbsolutePath());
|
||||
if (::GetFileAttributesExW(filenameW.c_str(), GetFileExInfoStandard, &attributes))
|
||||
{
|
||||
if ((attributes.dwFileAttributes != INVALID_FILE_ATTRIBUTES) &&
|
||||
((attributes.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0))
|
||||
@@ -863,7 +868,9 @@ namespace AZ::IO
|
||||
else
|
||||
{
|
||||
WIN32_FILE_ATTRIBUTE_DATA attributes;
|
||||
if (::GetFileAttributesEx(command.m_path.GetAbsolutePath(), GetFileExInfoStandard, &attributes) &&
|
||||
AZStd::wstring filenameW;
|
||||
AZStd::to_wstring(filenameW, command.m_path.GetAbsolutePath());
|
||||
if (::GetFileAttributesExW(filenameW.c_str(), GetFileExInfoStandard, &attributes) &&
|
||||
(attributes.dwFileAttributes != INVALID_FILE_ATTRIBUTES) && ((attributes.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0))
|
||||
{
|
||||
fileSize.LowPart = attributes.nFileSizeLow;
|
||||
|
||||
+2
-2
@@ -290,7 +290,7 @@ namespace AZ::IO
|
||||
static bool CollectHardwareInfo(HardwareInformation& hardwareInfo, bool addAllDrives, bool reportHardware)
|
||||
{
|
||||
char drives[512];
|
||||
if (::GetLogicalDriveStrings(sizeof(drives) - 1, drives))
|
||||
if (::GetLogicalDriveStringsA(sizeof(drives) - 1, drives))
|
||||
{
|
||||
AZStd::unordered_map<DWORD, DriveInformation> driveMappings;
|
||||
char* driveIt = drives;
|
||||
@@ -318,7 +318,7 @@ namespace AZ::IO
|
||||
deviceName += driveIt;
|
||||
deviceName.erase(deviceName.length() - 1); // Erase the slash.
|
||||
|
||||
HANDLE deviceHandle = ::CreateFile(
|
||||
HANDLE deviceHandle = ::CreateFileA(
|
||||
deviceName.c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr);
|
||||
if (deviceHandle != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
#include <AzCore/IPC/SharedMemory.h>
|
||||
#include <AzCore/std/parallel/spin_mutex.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <AzCore/std/string/fixed_string.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -20,16 +22,18 @@ namespace AZ
|
||||
{
|
||||
}
|
||||
|
||||
void SharedMemory_Windows::ComposeMutexName(char* dest, size_t length, const char* name)
|
||||
void ComposeName(AZStd::fixed_wstring<256>& dest, const char* name, const wchar_t* suffix)
|
||||
{
|
||||
azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name));
|
||||
azsnprintf(dest, length, "%s_Mutex", name);
|
||||
AZStd::to_wstring(dest, name);
|
||||
dest += L"_";
|
||||
dest += suffix;
|
||||
}
|
||||
|
||||
SharedMemory_Common::CreateResult SharedMemory_Windows::Create(const char* name, unsigned int size, bool openIfCreated)
|
||||
{
|
||||
char fullName[256];
|
||||
ComposeMutexName(fullName, AZ_ARRAY_SIZE(fullName), name);
|
||||
azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name));
|
||||
AZStd::fixed_wstring<256> fullName;
|
||||
ComposeName(fullName, name, L"Mutex");
|
||||
|
||||
// Security attributes
|
||||
SECURITY_ATTRIBUTES secAttr;
|
||||
@@ -41,7 +45,7 @@ namespace AZ
|
||||
SetSecurityDescriptorDacl(secAttr.lpSecurityDescriptor, TRUE, 0, FALSE);
|
||||
|
||||
// Obtain global mutex
|
||||
m_globalMutex = CreateMutex(&secAttr, FALSE, fullName);
|
||||
m_globalMutex = CreateMutexW(&secAttr, FALSE, fullName.c_str());
|
||||
DWORD error = GetLastError();
|
||||
if (m_globalMutex == NULL || (error == ERROR_ALREADY_EXISTS && openIfCreated == false))
|
||||
{
|
||||
@@ -50,8 +54,8 @@ namespace AZ
|
||||
}
|
||||
|
||||
// Create the file mapping.
|
||||
azsnprintf(fullName, AZ_ARRAY_SIZE(fullName), "%s_Data", name);
|
||||
m_mapHandle = CreateFileMapping(INVALID_HANDLE_VALUE, &secAttr, PAGE_READWRITE, 0, size, fullName);
|
||||
ComposeName(fullName, name, L"Data");
|
||||
m_mapHandle = CreateFileMappingW(INVALID_HANDLE_VALUE, &secAttr, PAGE_READWRITE, 0, size, fullName.c_str());
|
||||
error = GetLastError();
|
||||
if (m_mapHandle == NULL || (error == ERROR_ALREADY_EXISTS && openIfCreated == false))
|
||||
{
|
||||
@@ -64,10 +68,11 @@ namespace AZ
|
||||
|
||||
bool SharedMemory_Windows::Open(const char* name)
|
||||
{
|
||||
char fullName[256];
|
||||
ComposeMutexName(fullName, AZ_ARRAY_SIZE(fullName), name);
|
||||
azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name));
|
||||
AZStd::fixed_wstring<256> fullName;
|
||||
ComposeName(fullName, name, L"Mutex");
|
||||
|
||||
m_globalMutex = OpenMutex(SYNCHRONIZE, TRUE, fullName);
|
||||
m_globalMutex = OpenMutex(SYNCHRONIZE, TRUE, fullName.c_str());
|
||||
AZ_Warning("AZSystem", m_globalMutex != NULL, "Failed to open OS mutex [%s]\n", m_name);
|
||||
if (m_globalMutex == NULL)
|
||||
{
|
||||
@@ -75,8 +80,8 @@ namespace AZ
|
||||
return false;
|
||||
}
|
||||
|
||||
azsnprintf(fullName, AZ_ARRAY_SIZE(fullName), "%s_Data", name);
|
||||
m_mapHandle = OpenFileMapping(FILE_MAP_WRITE, false, fullName);
|
||||
ComposeName(fullName, name, L"Data");
|
||||
m_mapHandle = OpenFileMapping(FILE_MAP_WRITE, false, fullName.c_str());
|
||||
if (m_mapHandle == NULL)
|
||||
{
|
||||
AZ_TracePrintf("AZSystem", "OpenFileMapping %s failed with error %d\n", m_name, GetLastError());
|
||||
|
||||
@@ -41,9 +41,6 @@ namespace AZ
|
||||
HANDLE m_mapHandle;
|
||||
HANDLE m_globalMutex;
|
||||
int m_lastLockResult;
|
||||
|
||||
private:
|
||||
void ComposeMutexName(char* dest, size_t length, const char* name);
|
||||
};
|
||||
|
||||
using SharedMemory_Platform = SharedMemory_Windows;
|
||||
|
||||
+10
-3
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <AzCore/Math/MathUtils.h>
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -105,11 +106,17 @@ namespace
|
||||
{
|
||||
// Set the text for window title, message, buttons.
|
||||
info = (DlgInfo*)lParam;
|
||||
SetWindowText(hDlg, info->m_title.c_str());
|
||||
SetWindowText(GetDlgItem(hDlg, 0), info->m_message.c_str());
|
||||
AZStd::wstring titleW;
|
||||
AZStd::to_wstring(titleW, info->m_title.c_str());
|
||||
SetWindowTextW(hDlg, titleW.c_str());
|
||||
AZStd::wstring messageW;
|
||||
AZStd::to_wstring(messageW, info->m_message.c_str());
|
||||
SetWindowTextW(GetDlgItem(hDlg, 0), messageW.c_str());
|
||||
for (int i = 0; i < info->m_options.size(); i++)
|
||||
{
|
||||
SetWindowText(GetDlgItem(hDlg, i + 1), info->m_options[i].c_str());
|
||||
AZStd::wstring optionW;
|
||||
AZStd::to_wstring(optionW, info->m_options[i].c_str());
|
||||
SetWindowTextW(GetDlgItem(hDlg, i + 1), optionW.c_str());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define UNICODE
|
||||
//#define NOGDICAPMASKS //- CC_*, LC_*, PC_*, CP_*, TC_*, RC_
|
||||
//#define NOVIRTUALKEYCODES //- VK_*
|
||||
//#define NOWINMESSAGES //- WM_*, EM_*, LB_*, CB_*
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user