Esempio n. 1
0
bool CClientFXDB::ReadFXGroups( bool bText, ILTStream* pFxFile, CLinkList<FX_GROUP *> &collGroupFx )
{
	// Read in the number of FX groups in this file
	uint32 dwNumGroups;

	if( bText )
	{
		ReadTextFile( pFxFile, "%s %lu", &dwNumGroups );
	}
	else
	{
		pFxFile->Read(&dwNumGroups, sizeof(uint32));
	}

	//allocate a working buffer that keys can read properties into
	static const uint32		knMaxKeyProps = 512;
	FX_PROP*				pPropBuffer = debug_newa(FX_PROP, knMaxKeyProps);

	if(!pPropBuffer)
		return false;

	for( uint32 i = 0; i < dwNumGroups; i ++ )
	{
		// Create a new group.
		FX_GROUP *pFxGroup = debug_new( FX_GROUP );

		if( !ReadFXGroup( bText, pFxFile, pFxGroup, pPropBuffer, knMaxKeyProps ))
		{
			debug_deletea(pPropBuffer);
			return false;
		}

		collGroupFx.AddTail(pFxGroup);
	}

	//free our working buffer
	debug_deletea(pPropBuffer);

	return true;
}
Esempio n. 2
0
void CKeyControl::TrackKey(CLinkListNode<KEY> *pNode, CPoint ptAnchor, CPoint ptOffset)
{
	CPoint ptLast = ptAnchor;
	CPoint ptCur;

	int xOff = ptOffset.x - ptAnchor.x;
	int yOff = ptOffset.y - ptAnchor.y;

	pNode->m_Data.m_bSelected = TRUE;

	// Make a list of all the keys that are selected

	CLinkList<CLinkListNode<KEY> *> collSelKeys;

	CLinkListNode<KEY> *pKeyNode = m_collKeys.GetHead();

	while (pKeyNode)
	{
		if (pKeyNode->m_Data.m_bSelected) collSelKeys.AddTail(pKeyNode);
		
		pKeyNode = pKeyNode->m_pNext;
	}

	while (GetAsyncKeyState(VK_LBUTTON) & 0x8000)
	{
		GetCursorPos(&ptCur);
		ScreenToClient(&ptCur);

		ptCur.x -= xOff;
		ptCur.y -= yOff;

		if (ptCur != ptLast)
		{
			float tmKeyBase = (float)ptCur.x / (float)m_cx;
			float valBase   = (float)(m_cy - ptCur.y) / (float)m_cy;

			if (valBase < 0.0f) valBase = 0.0f;
			if (valBase > 1.0f) valBase = 1.0f;

			CLinkListNode<CLinkListNode<KEY> *> *pSelNode = collSelKeys.GetHead();

			while (pSelNode)
			{
				CLinkListNode<KEY> *pCurNode = pSelNode->m_Data;

				float tmKey = tmKeyBase - pNode->m_Data.m_tmAnchor;
				float val   = valBase - pNode->m_Data.m_valAnchor;

				float tmActual = tmKey + pCurNode->m_Data.m_tmAnchor;
				
				if (pCurNode->m_pPrev)
				{
					float tmPrevActual = pCurNode->m_pPrev->m_Data.m_tmAnchor + pCurNode->m_pPrev->m_Data.m_tmKey;

					if (tmPrevActual > tmActual)
					{
						tmKey = tmPrevActual - pCurNode->m_Data.m_tmAnchor;
					}
				}
				else
				{
					tmKey = 0.0f;
				}

				if (pCurNode->m_pNext)
				{
					float tmNextActual = pCurNode->m_pNext->m_Data.m_tmAnchor + pCurNode->m_pNext->m_Data.m_tmKey;

					if (tmNextActual < tmActual)
					{
						tmKey = tmNextActual - pCurNode->m_Data.m_tmAnchor;
					}
				}
				else
				{
					tmKey = 1.0f - pCurNode->m_Data.m_tmAnchor;
				}

				if (val + pCurNode->m_Data.m_valAnchor < 0.0f) val = -pCurNode->m_Data.m_valAnchor;
				if (val + pCurNode->m_Data.m_valAnchor > 1.0f) val = 1.0f - pCurNode->m_Data.m_valAnchor;

				pCurNode->m_Data.m_tmKey = tmKey;
				pCurNode->m_Data.m_val = val;

				pSelNode = pSelNode->m_pNext;
			}

			ptLast = ptCur;
		}
		
		Redraw(pNode);
	}

	// And update the new positions

	pNode = m_collKeys.GetHead();

	while (pNode)
	{
		pNode->m_Data.m_tmAnchor  += pNode->m_Data.m_tmKey;
		pNode->m_Data.m_valAnchor += pNode->m_Data.m_val;
		pNode->m_Data.m_tmKey = 0.0f;
		pNode->m_Data.m_val   = 0.0f;
		pNode->m_Data.m_bSelected = FALSE;
		
		pNode = pNode->m_pNext;
	}

	// And one final redraw to remove the selected stuff
	
	Redraw(NULL);
}