示例#1
0
void AnimatorBar::FrameSerialize(CArchive& ar)
{
	if(ar.IsLoading())
	{
		POSITION Pos = film_strip.GetFirstSelectedItemPosition();
		
		int Count;
		ar >> Count;
		vector<int> ToSelect;

		for(int a = 0; a < Count; a ++)
		{
			application->resources.images.push_back(CImageResource());
			application->resources.images_changed = true;
			CImageResource* image = &application->resources.images.back();
			image->Serialize(ar);
			image->m_FixedID = application->m_ImageFixID++;

			POSITION pos = film_strip.GetFirstSelectedItemPosition();
		
			if(pos)
			{
				if(m_pCurrentAnimation->supportsFrames())
				{
					int nItem = film_strip.GetNextSelectedItem(pos);
					m_pCurrentAnimation->m_Images.insert( m_pCurrentAnimation->m_Images.begin() + nItem + a, image->m_FixedID);
					ToSelect.push_back(nItem + a);
				}
			}

			else
			{
				if(m_pCurrentAnimation->supportsFrames())
				{
					m_pCurrentAnimation->m_Images.push_back( image->m_FixedID);
					ToSelect.push_back(m_pCurrentAnimation->m_Images.size());
				}
			}			

			int iFrameTime = 0;
			ar >> iFrameTime;
			
			if(m_pCurrentAnimation->supportsFrames())
			{
				m_pCurrentAnimation->m_FrameTimes.push_back(iFrameTime);
			}
		}

		UpdateFilmStrip();
		for(int c = 0 ; c < ToSelect.size(); c++)
			film_strip.SetItemState (ToSelect[c], LVIS_SELECTED, LVIS_SELECTED);
	}
void CAnimationEditorDlg::FrameSerialize(CArchive& ar)
{
	// This function is only called for copying and pasting frames

	if(ar.IsLoading())
	{
		POSITION pos = m_Frames.GetFirstSelectedItemPosition();
		int count;
		ar >> count;
		vector<int> ToSelect;
		for(int a = 0; a < count; a ++)
		{
			m_pApplication->m_imageBank.push_back(CImageResource());
			m_pApplication->m_imageBankHasChanged = true;
			CImageResource* image = &m_pApplication->m_imageBank.back();
			image->Serialize(ar);
			image->m_FixedID = m_pApplication->m_ImageFixID++;

			POSITION pos = m_Frames.GetFirstSelectedItemPosition();
			if(pos)
			{
				int nItem = m_Frames.GetNextSelectedItem(pos);
				m_CurrentAnimation->m_Images.insert( m_CurrentAnimation->m_Images.begin() + nItem + a, image->m_FixedID);
				ToSelect.push_back(nItem + a);
			}
			else
			{
				m_CurrentAnimation->m_Images.push_back( image->m_FixedID);
				ToSelect.push_back(m_CurrentAnimation->m_Images.size());
			}			

			int iFrameTime = 0;
			ar >> iFrameTime;
			m_CurrentAnimation->m_FrameTimes.push_back(iFrameTime);
		}

		UpdateList();
		for(int c = 0 ; c < ToSelect.size(); c++)
			m_Frames.SetItemState (ToSelect[c], LVIS_SELECTED, LVIS_SELECTED);

	}
示例#3
0
void CAnimation::SerializeFromOtherApplicationStep(CApplication* app)
{
		application = app;

		m_FixedID = app->m_AnimationFixID++;
		// This function is used when an animation has been serialized for use in another application
		// Basically the images themselves get loaded later, but we need to allocate blank images first.
		//If the application isn't already in the map, we create it...it doesn't matter
		for(int f = 0; f < m_Images.size(); f++)
		{
			int& newimage = m_Images[f];
			map<int, int>& imagefromto = app->m_imagefrom_imageto_map[app->m_drag_app_from];

			// now the important part...we need to see if we've done this before
			if( imagefromto.find(newimage) == imagefromto.end())
			{
				//damn it hasn't been done before...we have work to do
				app->resources.images.push_back(CImageResource());
				app->resources.images_changed = true;

				if(app->resources.FindImageResourceFromNumber(newimage))
				{
					app->images_to_save[newimage] = 0; 
				}
				newimage = imagefromto[newimage] = app->m_ImageFixID++;
				app->resources.images.back().m_FixedID = newimage;
				// we use the imagefromto map later to put our bitmaps that we serialized at the end of CDragObjects into
				// our blank imageBank spots
			}
			else
			{
				// Yeah! we've been here and done it! 
				newimage = imagefromto[newimage];
			}
		}
		for(list<CAnimation>::iterator a = m_SubAnimations.begin(); a != m_SubAnimations.end(); a++)
			a->SerializeFromOtherApplicationStep(app);

	}