Updated outdated IArchive documentation and got rid of old template reader/writer classes
This commit is contained in:
parent
1bc95a30a5
commit
64e0aa8a44
|
@ -29,29 +29,19 @@
|
|||
* 2. As a global/friend function with this signature: void Serialize(IArchive&, YourClass&)
|
||||
*
|
||||
* Use the << operator to serialize data members to the archive. All data being serialized must be
|
||||
* wrapped in one of the SERIAL macros. The SERIAL macro ensures that all serialized parameters are
|
||||
* associated with a name. This name makes the output file more easily human-readable as well as helps
|
||||
* ensure that files are easily backwards-compatible if parameters are moved or added/removed.
|
||||
* wrapped in a call to SerialParameter(), which allows each value to be associated with a name
|
||||
* and other parameters. This primarily helps make the output files more human-readable and
|
||||
* assists with backwards compatibility, as well as customizing how each parameter is serialized.
|
||||
*
|
||||
* Polymorphism is supported. There are two requirements for a polymorphic class to work with the
|
||||
* serialization system. First, the base class must contain a virtual Type() function that returns
|
||||
* an integral value (an enum or an integer), as well as a virtual Serialize(IArchive&) function.
|
||||
* Second, there must be a factory object with a SpawnObject(u32) method that takes the same Type value
|
||||
* and returns an object of the correct class.
|
||||
* serialization system. First, the base class must contain a virtual Type() function, as well as
|
||||
* a virtual Serialize(IArchive&) function. Second, the class must have a static ArchiveConstructor()
|
||||
* method that takes the a Type value (which should be the same type as Type() returns), and returns
|
||||
* an object of the correct class.
|
||||
*
|
||||
* Containers are also supported. Containers require a different macro that allows you to specify the
|
||||
* name of the elements in the container. The currently-supported containers are std::vector, std::list,
|
||||
* and std::set. Support for more container types can be added to the bottom of this file.
|
||||
*
|
||||
* These are the available SERIAL macros:
|
||||
* - SERIAL(ParamName, ParamValue) [generic parameter]
|
||||
* - SERIAL_HEX(ParamName, ParamValue) [integral parameter serialized as a hex number for improved readability]
|
||||
* - SERIAL_ABSTRACT(ParamName, ParamValue, Factory) [polymorphic parameter]
|
||||
* - SERIAL_CONTAINER(ParamName, Container, ElementName) [container parameter]
|
||||
* - SERIAL_ABSTRACT_CONTAINER(ParamName, Container, ElementName, Factory) [container of polymorphic objects parameter]
|
||||
*
|
||||
* Each of these has a variant with _AUTO at the end that allows you to exclude ParamName (the name of the
|
||||
* variable will be used as the parameter name instead).
|
||||
* SerialParameter() can take flags that provides hints to the serializer. This can either customize
|
||||
* how the parameter is displayed in the file, or it can modify how the serialization is done under
|
||||
* the hood. For a list of possible hints, check the definition of ESerialHint.
|
||||
*/
|
||||
|
||||
/** ESerialHint - Parameter hint flags */
|
||||
|
@ -61,7 +51,7 @@ enum ESerialHint
|
|||
SH_Optional = 0x2, // The parameter should not be written to the file if its value matches the default value.
|
||||
SH_NeverSave = 0x4, // The parameter should not be saved to files.
|
||||
SH_AlwaysSave = 0x8, // The parameter should always be saved regardless of if it matches the default value.
|
||||
SH_Attribute = 0x10, // The parameter is an attribute of another parameter. Attributes cannot have children.
|
||||
SH_Attribute = 0x10, // The parameter is an attribute of its parent. Attributes cannot have children.
|
||||
SH_IgnoreName = 0x20, // The parameter name will not be used to validate file data. May yield incorrect results if used improperly!
|
||||
SH_InheritHints = 0x40, // The parameter will inherit hints from its parent parameter (except for this flag).
|
||||
SH_Proxy = 0x80, // The parameter is a proxy of the parent and will display inline instead of as a child parameter.
|
||||
|
|
|
@ -102,7 +102,6 @@ HEADERS += \
|
|||
Resource/Factory/CScanLoader.h \
|
||||
Resource/Factory/CScriptLoader.h \
|
||||
Resource/Factory/CStringLoader.h \
|
||||
Resource/Factory/CTemplateLoader.h \
|
||||
Resource/Factory/CTextureDecoder.h \
|
||||
Resource/Factory/CWorldLoader.h \
|
||||
Resource/Model/CBasicModel.h \
|
||||
|
@ -274,7 +273,6 @@ SOURCES += \
|
|||
Resource/Factory/CScanLoader.cpp \
|
||||
Resource/Factory/CScriptLoader.cpp \
|
||||
Resource/Factory/CStringLoader.cpp \
|
||||
Resource/Factory/CTemplateLoader.cpp \
|
||||
Resource/Factory/CTextureDecoder.cpp \
|
||||
Resource/Factory/CWorldLoader.cpp \
|
||||
Resource/Model/CBasicModel.cpp \
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "CGameProject.h"
|
||||
#include "IUIRelay.h"
|
||||
#include "Core/Resource/Factory/CTemplateLoader.h"
|
||||
#include "Core/Resource/Script/CGameTemplate.h"
|
||||
#include <Common/Serialization/XML.h>
|
||||
#include <nod/nod.hpp>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "CScriptLoader.h"
|
||||
#include "CTemplateLoader.h"
|
||||
#include "Core/GameProject/CResourceStore.h"
|
||||
#include "Core/Resource/Script/CGameTemplate.h"
|
||||
#include "Core/Resource/Script/NGameList.h"
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,64 +0,0 @@
|
|||
#ifndef CTEMPLATELOADER_H
|
||||
#define CTEMPLATELOADER_H
|
||||
|
||||
// Old code! This is being kept around for now in case there is a reason to need to load the old templates.
|
||||
// Template loading is handled by the serializer now. This code should only be used if there is a reason that
|
||||
// the new templates need to be regenerated (i.e. if any data from the old templates is missing on the new ones).
|
||||
#define USE_LEGACY_TEMPLATE_LOADER 0
|
||||
|
||||
#if USE_LEGACY_TEMPLATE_LOADER
|
||||
#include "Core/Resource/Script/CGameTemplate.h"
|
||||
#include "Core/Resource/Script/CScriptTemplate.h"
|
||||
#include "Core/Resource/Script/Property/IProperty.h"
|
||||
#include "Core/Resource/Script/Property/CEnumProperty.h"
|
||||
#include "Core/Resource/Script/Property/CFlagsProperty.h"
|
||||
#include <tinyxml2.h>
|
||||
|
||||
class CTemplateLoader
|
||||
{
|
||||
static const TString mskTemplatesDir;
|
||||
static const TString mskGameListPath;
|
||||
|
||||
CGameTemplate *mpGameTemplate;
|
||||
EGame mGame;
|
||||
TString mTemplatesDir;
|
||||
TString mGameDir;
|
||||
|
||||
// Constructor
|
||||
CTemplateLoader(const TString& rkTemplatesDir)
|
||||
: mTemplatesDir(rkTemplatesDir) {}
|
||||
|
||||
// Load Property
|
||||
IProperty* LoadProperty(tinyxml2::XMLElement* pElem, CScriptTemplate* pScript, CStructProperty* pParentStruct, const TString& rkTemplateName);
|
||||
IProperty* CreateProperty(u32 ID, EPropertyType Type, const TString& rkName, CScriptTemplate* pScript, CStructProperty* pStruct);
|
||||
|
||||
CStructProperty* LoadStructArchetype(const TString& rkTemplateFileName);
|
||||
CEnumProperty* LoadEnumArchetype(const TString& rkTemplateFileName, bool bIsChoice);
|
||||
CFlagsProperty* LoadFlagsArchetype(const TString& rkTemplateFileName);
|
||||
|
||||
void LoadProperties(tinyxml2::XMLElement* pPropertiesElem, CScriptTemplate* pScript, CStructProperty* pStruct, const TString& rkTemplateName);
|
||||
void LoadEnumerators(tinyxml2::XMLElement* pEnumeratorsElem, CEnumProperty* pEnum, const TString& rkTemplateName);
|
||||
void LoadBitFlags(tinyxml2::XMLElement* pFlagsElem, CFlagsProperty* pFlags, const TString& rkTemplateName);
|
||||
|
||||
// Load Script Object
|
||||
CScriptTemplate* LoadScriptTemplate(tinyxml2::XMLDocument* pDoc, const TString& rkTemplateName, u32 ObjectID);
|
||||
|
||||
// Load Game
|
||||
CGameTemplate* LoadGameInfo(tinyxml2::XMLNode* pNode);
|
||||
void LoadGameTemplate(tinyxml2::XMLDocument* pDoc, CGameTemplate* pGame);
|
||||
|
||||
// Utility
|
||||
static void OpenXML(const TString& rkPath, tinyxml2::XMLDocument& rDoc);
|
||||
static TString ErrorName(tinyxml2::XMLError Error);
|
||||
|
||||
public:
|
||||
static void LoadGameList();
|
||||
static void LoadGameTemplates(EGame Game);
|
||||
static void LoadAllGames();
|
||||
static void LoadPropertyList(tinyxml2::XMLDocument* pDoc, const TString& rkListName);
|
||||
|
||||
static void SaveGameList();
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // CTEMPLATELOADER_H
|
|
@ -95,9 +95,6 @@ struct SPropertyTemplatePath
|
|||
/** CGameTemplate - Per-game template data */
|
||||
class CGameTemplate
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class CTemplateWriter;
|
||||
|
||||
EGame mGame;
|
||||
TString mSourceFile;
|
||||
bool mFullyLoaded;
|
||||
|
|
|
@ -43,9 +43,6 @@ struct SAttachment
|
|||
*/
|
||||
class CScriptTemplate
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class CTemplateWriter;
|
||||
|
||||
public:
|
||||
enum ERotationType {
|
||||
eRotationEnabled, eRotationDisabled
|
||||
|
|
|
@ -23,7 +23,6 @@ struct SScriptArray
|
|||
class CArrayProperty : public TTypedProperty<u32, EPropertyType::Array>
|
||||
{
|
||||
friend class IProperty;
|
||||
friend class CTemplateLoader;
|
||||
|
||||
/** This class inherits from TTypedPropertyNew<int> in order to expose the array
|
||||
* count value (the first member of SScriptArray). Outside users can edit this
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
class CAssetProperty : public TSerializeableTypedProperty<CAssetID, EPropertyType::Asset>
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class IProperty;
|
||||
|
||||
CResTypeFilter mTypeFilter;
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
template<EPropertyType TypeEnum>
|
||||
class TEnumPropertyBase : public TSerializeableTypedProperty<s32, TypeEnum>
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class IProperty;
|
||||
|
||||
struct SEnumValue
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
class CFlagsProperty : public TSerializeableTypedProperty<u32, EPropertyType::Flags>
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class IProperty;
|
||||
|
||||
struct SBitFlag
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
class CPointerProperty : public TTypedProperty<void*, EPropertyType::Pointer>
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class IProperty;
|
||||
|
||||
CPointerProperty(EGame Game)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "CPropertyNameGenerator.h"
|
||||
#include "IUIRelay.h"
|
||||
#include "Core/Resource/Factory/CTemplateLoader.h"
|
||||
#include "Core/Resource/Script/CGameTemplate.h"
|
||||
#include "Core/Resource/Script/NPropertyMap.h"
|
||||
#include <Common/Hash/CCRC32.h>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
class CStructProperty : public IProperty
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class IProperty;
|
||||
|
||||
public:
|
||||
|
|
|
@ -111,9 +111,6 @@ enum class ECookPreference
|
|||
/** New property class */
|
||||
class IProperty
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class CPropertyFactory;
|
||||
|
||||
protected:
|
||||
/** Flags */
|
||||
FPropertyFlags mFlags;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include "ui_CTemplateEditDialog.h"
|
||||
|
||||
#include "Editor/UICommon.h"
|
||||
#include <Core/Resource/Factory/CTemplateLoader.h>
|
||||
#include <Core/Resource/Script/CGameTemplate.h>
|
||||
#include <Core/Resource/Script/NGameList.h>
|
||||
#include <Core/Resource/Script/NPropertyMap.h>
|
||||
|
|
Loading…
Reference in New Issue