当前位置: 首页>>代码示例>>C++>>正文


C++ CLayer::Serialize方法代码示例

本文整理汇总了C++中CLayer::Serialize方法的典型用法代码示例。如果您正苦于以下问题:C++ CLayer::Serialize方法的具体用法?C++ CLayer::Serialize怎么用?C++ CLayer::Serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CLayer的用法示例。


在下文中一共展示了CLayer::Serialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SerializeAllZLists

void CLayoutEditor::SerializeAllZLists(CArchive* ar)
{
	// This is not a normal serialize function - it is never used to save and load. It is only used by the undo system.
	if(ar->IsLoading())
	{
/*
TODO: clear everything , free everything, reserialze, update
*/

		// We need to remove existing data.
		POSITION pos = layout->layers.GetHeadPosition();
		for (int j = 0; j < layout->layers.GetCount(); j++)
		{
			delete layout->layers.GetNext(pos);
		}
		layout->layers.RemoveAll();
		

		int c;
		*ar >> c;

		for (int j = 0; j < c; j++)
		{
			CLayer* lyr = new CLayer("", 0);
			lyr->Serialize(*ar);
			layout->layers.AddTail(lyr);
	
			int groupcount;
			*ar >> (int)groupcount;

			for(int j = 0; j < groupcount; j++)
			{
				int id;
				*ar >> id;

				CObj* group;
				long longid = id;
				layout->objects.Lookup(longid, group);
				group->m_groupObjects.RemoveAll();

				int zcount;
				*ar >> zcount;


				for (int i = 0; i < zcount; i++)
				{
					long instance;
					*ar >> instance;
					
					group->m_groupObjects.AddTail(instance);
				}

			}	
		}
	}
开发者ID:segafan,项目名称:Construct-classic,代码行数:55,代码来源:LayoutEditor.cpp

示例2: Serialize

bool CLayout::Serialize(CArchive& ar)
{
	CString ExpectedName = "CLayout";
	int     Version      = 5;

	if (!SerializeClassHeader(ExpectedName, Version, ar))
		return false;

	g_pFrame = this;
	if(ar.IsLoading())
	{
		ar >> identifier >> m_w >> m_h >> m_Name >> m_clr >> m_unboundedScrolling >> application_background;
		
		m_ObjectFrameIsLockedTo = 0;
		m_oTemporyBehaviorInfo=0;	// used inbetwen creation of tempory Behaviors for modifying properties - I use it so if an edittime function is called, we can work out from what object it is if the identifier is -1
		m_pTempMovExt=0;	// used inbetwen creation of tempory Behaviors for modifying properties - I use it so if an edittime function is called, we can work out from what object it is if the identifier is -1
		m_oControlBehaviorInfo=0;	// If you tell a Behavior to be in control of the frame editor this is used
		m_pControlBehaviorExt=0;// If you tell a Behavior to be in control of the frame editor this is used
		m_pControlBehaviorData=0;	// If you tell a Behavior to be in control of the frame editor, this is used to serialize to once unlocked.
		m_pControlBehaviorDataSize=0;
		m_ParentObjectFrameIsLockedTo=0;

		objects.RemoveAll();
		long objCnt;

		ar >> objCnt;
		CObj *o;
		int i;
		for (i = 0; i < objCnt; i++) 
		{
			long nKey;
			ar >> nKey;
			o = new CObj();

			if (!o->Serialize(ar))
				return false;

			objects.SetAt(nKey, o);
		}

		ar >> objCnt;
		CLayer *layer;
		for (i = 0; i < objCnt; i++)
		{
			layer = new CLayer("", LAYER_NORMAL);

			if (!layer->Serialize(ar))
				return false;

			layers.AddTail(layer);
			if (i == 1)
				current_layer = layer;
		}

		if (Version < 4)
		{
			// add non-layout layer if one doesn't exist
			if (layers.GetHead()->m_layerType != LAYER_NONFRAME)
			{
				CString layer_name;
				layer_name.Format("Non-layout");
				CLayer* nonlayout_layer = new CLayer(layer_name, LAYER_NONFRAME);
				nonlayout_layer->m_state = LAYSTATE_HIDDEN;

				nonlayout_layer->m_layerID = application->m_layerID++;
				layers.AddHead(nonlayout_layer);
			}
		}

		ar >> temporary_event_sheet_id;

		// This changed in v2; make sure the function knows
		if (Version >= 2)
			layoutKeys.Serialize(ar, true);
		else
			layoutKeys.Serialize(ar, false);

		// V3: save grid details
		if (Version >= 3) {
			ar >> m_Grid >> m_SnapMovements >> m_SnapResize >> m_GridWidth >> m_GridHeight;
		}
开发者ID:aolko,项目名称:construct,代码行数:81,代码来源:CLayout.cpp

示例3: PerformAction

CAction* CLayoutEditor::PerformAction(CAction *action, BOOL bRepeat)
{
	// variables
	long id, gid, prevObj, objLayer;
	long i, oid;
	CLayer *lyr;
	CObj *o, *o2;
	CObjType *oT;
	CObjList objs;
	CString text;
	BOOL b, tb;
	BOOL bMoreInstances;
	POSITION pos, pos2;

	g_pLayoutView = this;
	g_pFrame = layout;
	g_pApp = application;

	long tid, tprevObj, tobjLayer, tglobalID;

	// do stuff
	CArchive *ar = action->Unprepare1();
	CAction *actionNew = new CAction();
	if (bRepeat)
		actionNew->m_bGroup = FALSE;
	CArchive *arNew = actionNew->Prepare1();

	switch (action->m_type) 
	{
	case ACTION_MOVESIZE:
		*ar >> id;
		o = GetObject(id);
		
		// START UNDO INFO //
		actionNew->m_type = ACTION_MOVESIZE;
		tid = o->GetInstanceID();
		*arNew << tid;
		o->Serialize(*arNew);
		// END UNDO INFO //

		o->Serialize(*ar);

		InitializeObject(o);
		g_PropertyBar->Update(this, TYPE_OBJECT, &m_sel, layout, &layout->objects, application); // show object props
		break;

	case ACTION_CHANGETYPE:
		*ar >> id;
		
		// START UNDO INFO //
		actionNew->m_type = ACTION_CHANGETYPE;
		*arNew << id;
		application->object_types[id]->Serialize(*arNew);
		// END UNDO INFO //
		
		application->object_types[id]->Serialize(*ar);

		g_PropertyBar->Update(this, TYPE_OBJECT, &m_sel, layout, &layout->objects, application); // show object props
		break;

	case ACTION_CHANGELAYER:
		*ar >> id;
		
		pos = layout->layers.GetHeadPosition();
		for (i = 0; i < layout->layers.GetCount(); i++)
		{
			lyr = layout->layers.GetPrev(pos);
			if( lyr->m_layerID == id)
				break;
		}
		
		// START UNDO INFO //
		actionNew->m_type = ACTION_CHANGELAYER;
		*arNew << id;
		lyr->Serialize(*arNew);
		// END UNDO INFO //

		lyr->Serialize(*ar);

		g_PropertyBar->Update(this, TYPE_LAYER, &m_sel, layout, &layout->objects, application, 0, lyr); // show object props
		break;
		
	case ACTION_SETVISIBLE:
		*ar >> id >> b;
		o = GetObject(id);
		
		// START UNDO INFO //
		actionNew->m_type = ACTION_SETVISIBLE;
		tid = o->GetInstanceID();
		tb = !b;
		*arNew << tid << tb;
		// END UNDO INFO //

		o->SetVisible(b);
		break;
		
	case ACTION_SETLOCK:
		*ar >> id >> b;
		o = GetObject(id);
		
//.........这里部分代码省略.........
开发者ID:segafan,项目名称:Construct-classic,代码行数:101,代码来源:Undo.cpp


注:本文中的CLayer::Serialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。