Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,89 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#pragma once
#include <SmartPointersHelpers.h>
#include <Serialization/IArchive.h>
#include <functor.h>
namespace Serialization
{
struct IActionButton;
DECLARE_SMART_POINTERS(IActionButton)
struct IActionButton
{
virtual ~IActionButton() {}
virtual void Callback() const = 0;
virtual const char* Icon() const = 0;
virtual IActionButtonPtr Clone() const = 0;
};
typedef Functor0 FunctorActionButtonCallback;
struct FunctorActionButton
: public IActionButton
{
FunctorActionButtonCallback callback;
string icon;
explicit FunctorActionButton(const FunctorActionButtonCallback& callback, const char* icon = "")
: callback(callback)
, icon(icon)
{
}
// IActionButton
virtual void Callback() const override
{
if (callback)
{
callback();
}
}
virtual const char* Icon() const override
{
return icon.c_str();
}
virtual IActionButtonPtr Clone() const override
{
return IActionButtonPtr(new FunctorActionButton(callback, icon.c_str()));
}
// ~IActionButton
};
inline bool Serialize(Serialization::IArchive& ar, FunctorActionButton& button, const char* name, const char* label)
{
if (ar.IsEdit())
{
return ar(Serialization::SStruct::ForEdit(static_cast<Serialization::IActionButton&>(button)), name, label);
}
else
{
return false;
}
}
inline FunctorActionButton ActionButton(const FunctorActionButtonCallback& callback, const char* icon = "")
{
return FunctorActionButton(callback, icon);
}
}
@@ -0,0 +1,64 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_BITFLAGS_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_BITFLAGS_H
#pragma once
#include <Serialization/Enum.h>
namespace Serialization {
class IArchive;
struct BitFlagsWrapper
{
int* variable;
unsigned int visibleMask;
const CEnumDescription* description;
void Serialize(IArchive& ar);
};
template<class Enum>
BitFlagsWrapper BitFlags(Enum& value)
{
BitFlagsWrapper wrapper;
wrapper.variable = (int*)&value;
wrapper.visibleMask = ~0U;
wrapper.description = &getEnumDescription<Enum>();
return wrapper;
}
template<class Enum>
BitFlagsWrapper BitFlags(int& value, int visibleMask = ~0)
{
BitFlagsWrapper wrapper;
wrapper.variable = &value;
wrapper.visibleMask = visibleMask;
wrapper.description = &getEnumDescription<Enum>();
return wrapper;
}
template<class Enum>
BitFlagsWrapper BitFlags(unsigned int& value, unsigned int visibleMask = ~0)
{
BitFlagsWrapper wrapper;
wrapper.variable = (int*)&value;
wrapper.visibleMask = visibleMask;
wrapper.description = &getEnumDescription<Enum>();
return wrapper;
}
}
#include "BitFlagsImpl.h"
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_BITFLAGS_H
@@ -0,0 +1,67 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_BITFLAGSIMPL_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_BITFLAGSIMPL_H
#pragma once
#include "Serialization/IArchive.h"
namespace Serialization {
inline void BitFlagsWrapper::Serialize(IArchive& ar)
{
const Serialization::CEnumDescription& desc = *description;
int count = desc.count();
if (ar.IsInput())
{
int previousValue = *variable;
for (int i = 0; i < count; ++i)
{
int flagValue = desc.valueByIndex(i);
if (!(flagValue & visibleMask))
{
continue;
}
bool flag = (previousValue & flagValue) == flagValue;
bool previousFlag = flag;
ar(flag, desc.nameByIndex(i), desc.labelByIndex(i));
if (flag != previousFlag)
{
if (flag)
{
*variable |= flagValue;
}
else
{
*variable &= ~flagValue;
}
}
}
}
else
{
for (int i = 0; i < count; ++i)
{
int flagValue = desc.valueByIndex(i);
if (!(flagValue & visibleMask))
{
continue;
}
bool flag = (*variable & flagValue) == flagValue;
ar(flag, desc.nameByIndex(i), desc.labelByIndex(i));
}
}
}
}
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_BITFLAGSIMPL_H
@@ -0,0 +1,43 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_COLORPICKER_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_COLORPICKER_H
#pragma once
#include <Cry_Math.h>
#include <Cry_Color.h>
#include <ISystem.h>
namespace Serialization
{
class IArchive;
struct ColorPicker
{
ColorF* color;
explicit ColorPicker(ColorF& color_)
: color(&color_)
{
}
// the function should stay virtual to ensure cross-dll calls are using right heap
virtual void SetColor(const ColorF* color_){* color = *color_; }
};
bool Serialize(Serialization::IArchive& ar, Serialization::ColorPicker& value, const char* name, const char* label);
} // namespace Serialization
#include "ColorPickerImpl.h"
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_COLORPICKER_H
@@ -0,0 +1,33 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_COLORPICKERIMPL_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_COLORPICKERIMPL_H
#pragma once
#include "../Color.h"
namespace Serialization
{
inline bool Serialize(Serialization::IArchive& ar, Serialization::ColorPicker& value, const char* name, const char* label)
{
if (ar.IsEdit())
{
return ar(Serialization::SStruct::ForEdit(value), name, label);
}
else
{
return ar(*value.color, name, label);
}
}
} // namespace Serialization
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_COLORPICKERIMPL_H
@@ -0,0 +1,19 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_JOINTNAME_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_JOINTNAME_H
#pragma once
#include <Serialization/Decorators/Resources.h>
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_JOINTNAME_H
@@ -0,0 +1,19 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_JOINTNAMEIMPL_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_JOINTNAMEIMPL_H
#pragma once
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_JOINTNAMEIMPL_H
@@ -0,0 +1,117 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_LOCALFRAME_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_LOCALFRAME_H
#pragma once
#include <Cry_Math.h>
#include "Serialization/Math.h"
namespace Serialization
{
class IArchive;
struct LocalPosition
{
Vec3* value;
int space;
const char* parentName;
const void* handle;
LocalPosition(Vec3& _vec, int _space, const char* _parentName, const void* _handle)
: value(&_vec)
, space(_space)
, parentName(_parentName)
, handle(_handle)
{
}
void Serialize(IArchive& ar);
};
struct LocalOrientation
{
Quat* value;
int space;
const char* parentName;
const void* handle;
LocalOrientation(Quat& _vec, int _space, const char* _parentName, const void* _handle)
: value(&_vec)
, space(_space)
, parentName(_parentName)
, handle(_handle)
{
}
void Serialize(IArchive& ar);
};
struct LocalFrame
{
Quat* rotation;
Vec3* position;
const char* parentName;
int rotationSpace;
int positionSpace;
const void* handle;
LocalFrame(Quat* _rotation, int _rotationSpace, Vec3* _position, int _positionSpace, const char* _parentName, const void* _handle)
: rotation(_rotation)
, position(_position)
, parentName(_parentName)
, rotationSpace(_rotationSpace)
, positionSpace(_positionSpace)
, handle(_handle)
{
}
void Serialize(IArchive& ar);
};
enum
{
SPACE_JOINT,
SPACE_ENTITY,
SPACE_JOINT_WITH_PARENT_ROTATION,
SPACE_JOINT_WITH_CHARACTER_ROTATION,
SPACE_SOCKET_RELATIVE_TO_JOINT,
SPACE_SOCKET_RELATIVE_TO_BINDPOSE
};
//position
inline LocalPosition LocalToEntity(Vec3& position, const void* handle = 0)
{
return LocalPosition(position, SPACE_ENTITY, "", handle ? handle : &position);
}
inline LocalPosition LocalToJoint(Vec3& position, const string& jointName, const void* handle = 0)
{
return LocalPosition(position, SPACE_JOINT, jointName.c_str(), handle ? handle : &position);
}
inline LocalPosition LocalToJointCharacterRotation(Vec3& position, const string& jointName, const void* handle = 0)
{
return LocalPosition(position, SPACE_JOINT_WITH_CHARACTER_ROTATION, jointName.c_str(), handle ? handle : &position);
}
bool Serialize(Serialization::IArchive& ar, Serialization::LocalPosition& value, const char* name, const char* label);
bool Serialize(Serialization::IArchive& ar, Serialization::LocalOrientation& value, const char* name, const char* label);
bool Serialize(Serialization::IArchive& ar, Serialization::LocalFrame& value, const char* name, const char* label);
}
#include "LocalFrameImpl.h"
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_LOCALFRAME_H
@@ -0,0 +1,89 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_LOCALFRAMEIMPL_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_LOCALFRAMEIMPL_H
#pragma once
#include "LocalFrame.h"
#include "Serialization/IArchive.h"
#include "Serialization/MathImpl.h"
namespace Serialization
{
inline void LocalPosition::Serialize(Serialization::IArchive& ar)
{
ar(value->x, "x", "^");
ar(value->y, "y", "^");
ar(value->z, "z", "^");
}
inline void LocalOrientation::Serialize(Serialization::IArchive& ar)
{
ar(Serialization::AsAng3(*value), "q", "^");
}
inline void LocalFrame::Serialize(Serialization::IArchive& ar)
{
ar(*position, "t", "<T");
ar(AsAng3(*rotation), "q", "<R");
}
inline bool Serialize(Serialization::IArchive& ar, Serialization::LocalPosition& value, const char* name, const char* label)
{
if (ar.IsEdit())
{
return ar(Serialization::SStruct(value), name, label);
}
else
{
return ar(*value.value, name, label);
}
}
inline bool Serialize(Serialization::IArchive& ar, Serialization::LocalOrientation& value, const char* name, const char* label)
{
if (ar.IsEdit())
{
return ar(Serialization::SStruct(value), name, label);
}
else
{
return ar(*value.value, name, label);
}
}
inline bool Serialize(Serialization::IArchive& ar, Serialization::LocalFrame& value, const char* name, const char* label)
{
if (ar.IsEdit())
{
return ar(Serialization::SStruct(value), name, label);
}
else
{
QuatT t(*value.rotation, *value.position);
if (!ar(t, name, label))
{
return false;
}
if (ar.IsInput())
{
*value.position = t.t;
*value.rotation = t.q;
}
return true;
}
}
}
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_LOCALFRAMEIMPL_H
@@ -0,0 +1,49 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_OUTPUTFILEPATH_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_OUTPUTFILEPATH_H
#pragma once
#include "Serialization/Strings.h"
namespace Serialization
{
class IArchive;
struct OutputFilePath
{
string* m_path;
// if we don't use dynamic filters we could replace following two with const char*
string filter;
string startFolder;
// filters are defined in the following format:
// "All Images (bmp, jpg, tga)|*.bmp;*.jpg;*.tga|Targa (tga)|*.tga"
explicit OutputFilePath(string& path, const char* filter = "All files|*.*", const char* startFolder = "")
: m_path(&path)
, filter(filter)
, startFolder(startFolder)
{
}
// the function should stay virtual to ensure cross-dll calls are using right heap
virtual void SetPath(const char* path) { *this->m_path = path; }
};
bool Serialize(Serialization::IArchive& ar, Serialization::OutputFilePath& value, const char* name, const char* label);
}
#include "OutputFilePathImpl.h"
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_OUTPUTFILEPATH_H
@@ -0,0 +1,32 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_OUTPUTFILEPATHIMPL_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_OUTPUTFILEPATHIMPL_H
#pragma once
namespace Serialization
{
inline bool Serialize(Serialization::IArchive& ar, Serialization::OutputFilePath& value, const char* name, const char* label)
{
if (ar.IsEdit())
{
return ar(Serialization::SStruct::ForEdit(value), name, label);
}
else
{
return ar(*value.m_path, name, label);
}
}
}
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_OUTPUTFILEPATHIMPL_H
@@ -0,0 +1,63 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RANGE_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RANGE_H
#pragma once
namespace Serialization
{
template<class T>
struct RangeDecorator
{
T* value;
T softMin;
T softMax;
T hardMin;
T hardMax;
};
template<class T>
RangeDecorator<T> Range(T& value, T hardMin, T hardMax)
{
RangeDecorator<T> r;
r.value = &value;
r.softMin = hardMin;
r.softMax = hardMax;
r.hardMin = hardMin;
r.hardMax = hardMax;
return r;
}
template<class T>
RangeDecorator<T> Range(T& value, T softMin, T softMax, T hardMin, T hardMax)
{
RangeDecorator<T> r;
r.value = &value;
r.softMin = softMin;
r.softMax = softMax;
r.hardMin = hardMin;
r.hardMax = hardMax;
return r;
}
namespace Decorators
{
// Obsolete name, will be removed. Please use Serialization::Range instead.
using Serialization::Range;
}
}
#include "RangeImpl.h"
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RANGE_H
@@ -0,0 +1,50 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RANGEIMPL_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RANGEIMPL_H
#pragma once
namespace Serialization
{
template<class T>
bool Serialize(IArchive& ar, RangeDecorator<T>& value, const char* name, const char* label)
{
if (ar.IsEdit())
{
if (!ar(SStruct::ForEdit(value), name, label))
{
return false;
}
}
else if (!ar(*value.value, name, label))
{
return false;
}
if (ar.IsInput())
{
if (*value.value < value.hardMin)
{
*value.value = value.hardMin;
}
if (*value.value > value.hardMax)
{
*value.value = value.hardMax;
}
}
return true;
}
}
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RANGEIMPL_H
@@ -0,0 +1,59 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RESOURCEFILEPATH_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RESOURCEFILEPATH_H
#pragma once
#include "Serialization/Strings.h"
namespace Serialization
{
class IArchive;
struct ResourceFilePath
{
enum
{
STRIP_EXTENSION = 1 << 0
};
string* m_path;
string filter;
bool group;
int flags;
// filters are defined in the following format:
// "All Images (bmp, jpg, tga)|*.bmp;*.jpg;*.tga|Targa (tga)|*.tga"
explicit ResourceFilePath(string& path, const char* filter = "", bool group = false, int flags = 0)
: m_path(&path)
, filter(filter)
, group(group)
, flags(flags)
{
}
// the function should stay virtual to ensure cross-dll calls are using right heap
virtual void SetPath(const char* path) { *this->m_path = path; }
};
inline ResourceFilePath MaterialPath(string& path)
{
return ResourceFilePath(path, "Material", false, ResourceFilePath::STRIP_EXTENSION);
}
bool Serialize(Serialization::IArchive& ar, Serialization::ResourceFilePath& value, const char* name, const char* label);
}
#include "ResourceFilePathImpl.h"
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RESOURCEFILEPATH_H
@@ -0,0 +1,32 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RESOURCEFILEPATHIMPL_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RESOURCEFILEPATHIMPL_H
#pragma once
namespace Serialization
{
inline bool Serialize(Serialization::IArchive& ar, Serialization::ResourceFilePath& value, const char* name, const char* label)
{
if (ar.IsEdit())
{
return ar(Serialization::SStruct::ForEdit(value), name, label);
}
else
{
return ar(*value.m_path, name, label);
}
}
}
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RESOURCEFILEPATHIMPL_H
@@ -0,0 +1,43 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RESOURCEFOLDERPATH_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RESOURCEFOLDERPATH_H
#pragma once
#include "Serialization/Strings.h"
namespace Serialization
{
class IArchive;
struct ResourceFolderPath
{
string* m_path;
string startFolder;
explicit ResourceFolderPath(string& path, const char* startFolder = "")
: m_path(&path)
, startFolder(startFolder)
{
}
// the function should stay virtual to ensure cross-dll calls are using right heap
virtual void SetPath(const char* path) { *this->m_path = path; }
};
bool Serialize(Serialization::IArchive& ar, Serialization::ResourceFolderPath& value, const char* name, const char* label);
}
#include "ResourceFolderPathImpl.h"
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RESOURCEFOLDERPATH_H
@@ -0,0 +1,34 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RESOURCEFOLDERPATHIMPL_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RESOURCEFOLDERPATHIMPL_H
#pragma once
#include "Serialization/IArchive.h"
namespace Serialization
{
inline bool Serialize(Serialization::IArchive& ar, Serialization::ResourceFolderPath& value, const char* name, const char* label)
{
if (ar.IsEdit())
{
return ar(Serialization::SStruct::ForEdit(value), name, label);
}
else
{
return ar(*value.m_path, name, label);
}
}
}
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RESOURCEFOLDERPATHIMPL_H
@@ -0,0 +1,100 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#pragma once
namespace Serialization
{
struct IResourceSelector
{
const char* resourceType;
virtual ~IResourceSelector() {}
virtual const char* GetValue() const = 0;
virtual void SetValue(const char* s) = 0;
virtual int GetId() const{ return -1; }
virtual const void* GetHandle() const = 0;
virtual Serialization::TypeID GetType() const = 0;
};
// Provides a way to annotate resource reference so different UI can be used
// for them. See IResourceSelector.h to see how selectors for specific types
// are registered.
//
// TString could be SCRCRef or CCryName as well.
//
// Do not use this class directly, instead use function that wraps it for
// specific type, see Resources.h for example.
template<class TString>
struct ResourceSelector
: IResourceSelector
{
TString& value;
const char* GetValue() const { return value.c_str(); }
void SetValue(const char* s) { value = s; }
const void* GetHandle() const { return &value; }
Serialization::TypeID GetType() const { return Serialization::TypeID::get<TString>(); }
ResourceSelector(TString& _value, const char* _resourceType)
: value(_value)
{
this->resourceType = _resourceType;
}
};
struct ResourceSelectorWithId
: IResourceSelector
{
string& value;
int id;
const char* GetValue() const { return value.c_str(); }
void SetValue(const char* s) { value = s; }
int GetId() const { return id; }
const void* GetHandle() const { return &value; }
Serialization::TypeID GetType() const { return Serialization::TypeID::get<string>(); }
ResourceSelectorWithId(string& _value, const char* _resourceType, int _id)
: value(_value)
, id(_id)
{
this->resourceType = _resourceType;
}
};
template<class T>
bool Serialize(IArchive& ar, ResourceSelector<T>& value, const char* name, const char* label)
{
if (ar.IsEdit())
{
return ar(Serialization::SStruct::ForEdit(static_cast<IResourceSelector&>(value)), name, label);
}
else
{
return ar(value.value, name, label);
}
}
inline bool Serialize(IArchive& ar, ResourceSelectorWithId& value, const char* name, const char* label)
{
if (ar.IsEdit())
{
return ar(Serialization::SStruct::ForEdit(static_cast<IResourceSelector&>(value)), name, label);
}
else
{
return ar(value.value, name, label);
}
}
}
@@ -0,0 +1,67 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RESOURCES_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RESOURCES_H
#pragma once
#include "ResourceSelector.h"
namespace Serialization
{
// animation resources
template<class T>
ResourceSelector<T> AnimationAlias(T& s) { return ResourceSelector<T>(s, "AnimationAlias"); } // "name" from animation set
template<class T>
ResourceSelector<T> AnimationPath(T& s) { return ResourceSelector<T>(s, "Animation"); }
inline ResourceSelectorWithId AnimationPathWithId(string& s, int id) { return ResourceSelectorWithId(s, "Animation", id); }
template<class T>
ResourceSelector<T> CharacterPath(T& s) { return ResourceSelector<T>(s, "Character"); }
template<class T>
ResourceSelector<T> CharacterPhysicsPath(T& s) { return ResourceSelector<T>(s, "CharacterPhysics"); }
template<class T>
ResourceSelector<T> CharacterRigPath(T& s) { return ResourceSelector<T>(s, "CharacterRig"); }
template<class T>
ResourceSelector<T> SkeletonPath(T& s) { return ResourceSelector<T>(s, "Skeleton"); }
template<class T>
ResourceSelector<T> SkeletonParamsPath(T& s) { return ResourceSelector<T>(s, "SkeletonParams"); } // CHRParams
template<class T>
ResourceSelector<T> JointName(T& s) { return ResourceSelector<T>(s, "Joint"); }
template<class T>
ResourceSelector<T> AttachmentName(T& s) { return ResourceSelector<T>(s, "Attachment"); }
// miscelaneous resources
template<class T>
ResourceSelector<T> SoundName(T& s) { return ResourceSelector<T>(s, "Sound"); }
template<class T>
ResourceSelector<T> DialogName(T& s) { return ResourceSelector<T>(s, "Dialog"); }
template<class T>
ResourceSelector<T> ForceFeedbackIdName(T& s) { return ResourceSelector<T>(s, "ForceFeedbackId"); }
template<class T>
ResourceSelector<T> ModelFilename(T& s) { return ResourceSelector<T>(s, "Model"); }
template<class T>
ResourceSelector<T> ParticleName(T& s) { return ResourceSelector<T>(s, "Particle"); }
namespace Decorators
{
// Decorators namespace is obsolete now, SHOULD NOT BE USED.
template<class T>
ResourceSelector<T> AnimationName(T& s) { return ResourceSelector<T>(s, "Animation"); }
using Serialization::SoundName;
using Serialization::AttachmentName;
template<class T>
ResourceSelector<T> ObjectFilename(T& s) { return ResourceSelector<T>(s, "Model"); }
using Serialization::JointName;
using Serialization::ForceFeedbackIdName;
}
}
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RESOURCES_H
@@ -0,0 +1,31 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#pragma once
#include "ResourceSelector.h"
namespace Serialization
{
template<class T>
ResourceSelector<T> AudioTrigger(T& s) { return ResourceSelector<T>(s, "AudioTrigger"); }
template<class T>
ResourceSelector<T> AudioSwitch(T& s) { return ResourceSelector<T>(s, "AudioSwitch"); }
template<class T>
ResourceSelector<T> AudioSwitchState(T& s) { return ResourceSelector<T>(s, "AudioSwitchState"); }
template<class T>
ResourceSelector<T> AudioRTPC(T& s) { return ResourceSelector<T>(s, "AudioRTPC"); }
template<class T>
ResourceSelector<T> AudioEnvironment(T& s) { return ResourceSelector<T>(s, "AudioEnvironment"); }
template<class T>
ResourceSelector<T> AudioPreloadRequest(T& s) { return ResourceSelector<T>(s, "AudioPreloadRequest"); }
};
@@ -0,0 +1,44 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RESOURCESIMPL_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RESOURCESIMPL_H
#pragma once
namespace Serialization
{
template<class T>
bool Serialize(IArchive& ar, ResourceSelector<T>& value, const char* name, const char* label)
{
if (ar.IsEdit())
{
return ar(Serialization::SStruct::ForEdit(static_cast<IResourceSelector&>(value)), name, label);
}
else
{
return ar(value.value, name, label);
}
}
inline bool Serialize(IArchive& ar, ResourceSelectorWithId& value, const char* name, const char* label)
{
if (ar.IsEdit())
{
return ar(Serialization::SStruct::ForEdit(static_cast<IResourceSelector&>(value)), name, label);
}
else
{
return ar(value.value, name, label);
}
}
}
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_RESOURCESIMPL_H
@@ -0,0 +1,88 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_SLIDER_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_SLIDER_H
#pragma once
namespace Serialization
{
class IArchive;
struct SSliderF
{
SSliderF(float* value, float _minLimit, float _maxLimit)
: valuePointer(value)
, minLimit(_minLimit)
, maxLimit(_maxLimit)
{
}
SSliderF()
: valuePointer(0)
, minLimit(0.0f)
, maxLimit(1.0f)
{
}
float* valuePointer;
float minLimit;
float maxLimit;
};
struct SSliderI
{
SSliderI(int* value, int minLimit, int maxLimit)
: valuePointer(value)
, minLimit(minLimit)
, maxLimit(maxLimit)
{
}
SSliderI()
: valuePointer(0)
, minLimit(0)
, maxLimit(1)
{
}
int* valuePointer;
int minLimit;
int maxLimit;
};
inline SSliderF Slider(float& value, float minLimit, float maxLimit)
{
return SSliderF(&value, minLimit, maxLimit);
}
inline SSliderI Slider(int& value, int minLimit, int maxLimit)
{
return SSliderI(&value, minLimit, maxLimit);
}
bool Serialize(IArchive& ar, SSliderF& slider, const char* name, const char* label);
bool Serialize(IArchive& ar, SSliderI& slider, const char* name, const char* label);
namespace Decorators
{
// OBSOLETE NAME, please use Serialization::Slider instead (without Decorators namespace)
using Serialization::Slider;
}
}
#include "SliderImpl.h"
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_SLIDER_H
@@ -0,0 +1,47 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_SLIDERIMPL_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_SLIDERIMPL_H
#pragma once
#include "Slider.h"
#include "Serialization/IArchive.h"
namespace Serialization
{
inline bool Serialize(IArchive& ar, SSliderF& slider, const char* name, const char* label)
{
if (ar.IsEdit())
{
return ar(SStruct::ForEdit(slider), name, label);
}
else
{
return ar(*slider.valuePointer, name, label);
}
}
inline bool Serialize(IArchive& ar, SSliderI& slider, const char* name, const char* label)
{
if (ar.IsEdit())
{
return ar(SStruct::ForEdit(slider), name, label);
}
else
{
return ar(*slider.valuePointer, name, label);
}
}
}
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_SLIDERIMPL_H
@@ -0,0 +1,44 @@
//-------------------------------------------------------------------------------
// Copyright (C) Amazon.com, Inc. or its affiliates.
// All Rights Reserved.
//
// Licensed under the terms set out in the LICENSE.HTML file included at the
// root of the distribution; you may not use this file except in compliance
// with the License.
//
// Do not remove or modify this notice or the LICENSE.HTML file. This file
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// either express or implied. See the License for the specific language
// governing permissions and limitations under the License.
//-------------------------------------------------------------------------------
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_SPRITE_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_SPRITE_H
#pragma once
namespace Serialization
{
class IArchive;
struct Sprite
{
string* m_path;
string m_filter;
string m_startFolder;
// filters are defined in the following format:
// "All Images (bmp, jpg, tga)|*.bmp;*.jpg;*.tga|Targa (tga)|*.tga"
explicit Sprite(string& path, const char* filter = "All files|*.*", const char* startFolder = "")
: m_path(&path)
, m_filter(filter)
, m_startFolder(startFolder)
{
}
};
bool Serialize(IArchive& ar, Sprite& value, const char* name, const char* label);
} // namespace Serialization
#include "SpriteImpl.h"
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_SPRITE_H
@@ -0,0 +1,35 @@
//-------------------------------------------------------------------------------
// Copyright (C) Amazon.com, Inc. or its affiliates.
// All Rights Reserved.
//
// Licensed under the terms set out in the LICENSE.HTML file included at the
// root of the distribution; you may not use this file except in compliance
// with the License.
//
// Do not remove or modify this notice or the LICENSE.HTML file. This file
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// either express or implied. See the License for the specific language
// governing permissions and limitations under the License.
//-------------------------------------------------------------------------------
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_SPRITEIMPL_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_SPRITEIMPL_H
#pragma once
namespace Serialization
{
inline bool Serialize(IArchive& ar, Sprite& value, const char* name, const char* label)
{
if (ar.IsEdit())
{
return ar(SStruct::ForEdit(value), name, label);
}
else
{
return ar(*value.m_path, name, label);
}
}
} // namespace Serialization
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_SPRITEIMPL_H
@@ -0,0 +1,49 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_TAGLIST_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_TAGLIST_H
#pragma once
#include <vector>
#include "Serialization/Strings.h"
namespace Serialization {
class IArchive;
}
struct ITagSource
{
virtual void AddRef() = 0;
virtual void Release() = 0;
virtual unsigned int TagCount(unsigned int group) const = 0;
virtual const char* TagValue(unsigned int group, unsigned int index) const = 0;
virtual const char* TagDescription(unsigned int group, unsigned int index) const = 0;
virtual const char* GroupName(unsigned int group) const = 0;
virtual unsigned int GroupCount() const = 0;
};
struct TagList
{
std::vector<Serialization::string>* tags;
TagList(std::vector<Serialization::string>& tags)
: tags(&tags)
{
}
};
bool Serialize(Serialization::IArchive& ar, TagList& tagList, const char* name, const char* label);
#include "TagListImpl.h"
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_TAGLIST_H
@@ -0,0 +1,40 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_TAGLISTIMPL_H
#define CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_TAGLISTIMPL_H
#pragma once
#include <vector>
#include "Serialization/IArchive.h"
#include "Serialization/Strings.h"
#include "Serialization/STL.h"
struct TagListContainer
: Serialization::ContainerSTL<std::vector<Serialization::string>, Serialization::string>
{
TagListContainer(TagList& tagList)
: ContainerSTL(tagList.tags)
{
}
Serialization::TypeID containerType() const override { return Serialization::TypeID::get<TagList>(); };
};
inline bool Serialize(Serialization::IArchive& ar, TagList& tagList, const char* name, const char* label)
{
TagListContainer container(tagList);
return ar(static_cast<Serialization::IContainer&>(container), name, label);
}
#endif // CRYINCLUDE_CRYCOMMON_SERIALIZATION_DECORATORS_TAGLISTIMPL_H