Пример #1
0
/* Multiple Poly */
Poly MulPoly(const Poly p1,const Poly p2)
{
	Poly	tmp1,tmp2,p;
	Poly	p_mul;

	tmp1 = p1 -> next;
	tmp2 = p2 -> next;
	p_mul = (Poly)malloc(sizeof(struct Node));
	InitPoly(p_mul);
	p = p_mul;

	while (tmp1 != NULL){
		tmp2 = p2 -> next;
		while (tmp2 != NULL){
			p -> next = (Poly)malloc(sizeof(struct Node));
			p = p -> next;
			p -> exp = tmp1 -> exp + tmp2 -> exp;
			p -> coefficient = tmp1 -> coefficient * tmp2 -> coefficient;
			p -> next = NULL;
			tmp2 = tmp2 -> next;
		}
		tmp1 = tmp1 -> next;
	}

	/* Intergate Nodes whose "exp" are the same */
	p = p_mul -> next;
	while (p != NULL){
		tmp1 = p;
		while (tmp1 ->next != NULL){
			if (tmp1 -> next -> exp == p -> exp){
				p -> coefficient += tmp1 -> next -> coefficient;
				tmp2 = tmp1 -> next;
				tmp1 -> next = tmp2 -> next;
				free(tmp2);
				tmp1 = tmp1 -> next;
			}
			else	tmp1 = tmp1 -> next;
		}
		if (tmp1 -> exp == p -> exp){		/* Cope with the last Node of the p_mul */
			p -> coefficient += tmp1 -> coefficient;
			tmp1 -> exp = 0;		/* Set last Node's exp and coefficient val equal to "0" */
			tmp1 -> coefficient = 0;	/* So that when added to the rest of the list Node it does not make sense*/
		}
		p = p -> next;
	}

	return p_mul;
}
Пример #2
0
// Create the control
LTBOOL CLTGUIButton::Create (	uint32 nCommandID,
								uint32 nHelpID,
								HTEXTURE hNormal,
								HTEXTURE hSelected,
								HTEXTURE hDisabled,
								CLTGUICommandHandler *pCommandHandler,
								uint32 nParam1,
								uint32 nParam2)
{
	if (!hNormal) return LTFALSE;

	m_pCommandHandler	= pCommandHandler;

	SetTexture(hNormal,hSelected,hDisabled);

	InitPoly();

	CLTGUICtrl::Create(nCommandID, nHelpID, nParam1,nParam2);

    return LTTRUE;
}
Пример #3
0
/* Add Poly */
Poly AddPoly(const Poly p1,const Poly p2)
{
	Poly	tmp1,tmp2,p;
	Poly	p_sum;

	tmp1 = p1 -> next;
	tmp2 = p2 -> next;
	p_sum = (Poly)malloc(sizeof(struct Node));
	InitPoly(p_sum);
	p = p_sum;
	while (tmp1 != NULL && tmp2 != NULL){
		while (tmp1 -> coefficient != tmp2 -> coefficient){
			p -> next = (Poly)malloc(sizeof(struct Node));
			if (tmp1 -> exp > tmp2 -> exp){
				p -> next -> coefficient = tmp1 -> coefficient;
				p -> next -> exp = tmp1 -> exp;
				p -> next -> next = NULL;
				p = p -> next;
				tmp1 = tmp1 -> next;
			}
			else	{
				p -> next -> coefficient = tmp2 -> coefficient;
				p -> next -> exp = tmp2 -> exp;
				p -> next -> next = NULL;
				p = p -> next;
				tmp2 = tmp2 -> next;
			}
		}
		if (tmp1 -> exp == tmp2 ->exp){
			p -> next = (Poly)malloc(sizeof(struct Node));
			p -> next -> next = NULL;
			p -> next -> coefficient = tmp1 -> coefficient + tmp2 -> coefficient;
			p -> next -> exp = tmp1 -> exp;
			p = p -> next;
		}
	}

	if (tmp1 == NULL){
		while (tmp2 != NULL){
			p -> next = (Poly)malloc(sizeof(struct Node));
			p = p -> next;
			p -> next = NULL;
			p -> coefficient = tmp2 -> coefficient;
			p -> exp = tmp2 -> exp;
			tmp2 = tmp2 -> next;
				
		}
	}
	else if (tmp2 == NULL){
		while (tmp1 != NULL){
			p -> next = (Poly)malloc(sizeof(struct Node));
			p = p -> next;
			p -> next = NULL;
			p -> coefficient = tmp1 -> coefficient;
			p -> exp = tmp1 -> exp;
			tmp1 = tmp1 -> next;
		}
	}
			 
	return p_sum;
}
Пример #4
0
LTBOOL CHUDMessage::Create(MsgCreate &mc)
{
	if (!mc.pFont) return LTFALSE; 

	if (kMinDuration < 0.0f)
		kMinDuration = g_pLayoutMgr->GetMessageMinTime();
	if (kMinFade < 0.0f)
		kMinFade = g_pLayoutMgr->GetMessageMinFade();


	m_pFont = mc.pFont;


	if (!m_pText)
	{
		m_pText = g_pFontManager->CreateFormattedPolyString(m_pFont,"",0.0f,0.0f);
		if (!m_pText)
			return LTFALSE;
	}

	m_pText->SetText(mc.sString.c_str());


	m_nFontSize = mc.nFontSize;
	m_nBaseFontSize = mc.nFontSize;
	m_nTextColor = mc.nTextColor;
	m_nFixedWidth = mc.nWidth;

	m_bDropShadow = mc.bDropShadow;
	
	m_pText->SetColor(m_nTextColor);

	m_fInitTime = -1.0f;

	m_eJustify = mc.eJustify;
	m_fDuration = mc.fDuration * GetConsoleFloat("MessageDuration",1.0f);
	if (m_fDuration < kMinDuration)
		m_fDuration = kMinDuration;
	m_fFadeDur  = mc.fFadeDur * GetConsoleFloat("MessageDuration",1.0f);;
	if (m_fFadeDur < kMinFade)
		m_fFadeDur = kMinFade;

	m_hImage = mc.hImage;
	m_nBaseImageSize = mc.nImageSize;

	switch (m_eJustify)
	{
	case kMsgLeft:
		m_pText->SetAlignmentH(CUI_HALIGN_LEFT);
		break;
	case kMsgRight:
		m_pText->SetAlignmentH(CUI_HALIGN_RIGHT);
		break;
	case kMsgCenter:
		m_pText->SetAlignmentH(CUI_HALIGN_CENTER);
		break;
	};


	InitPoly();

	SetBasePos(LTIntPt(0,0));

	SetScale(g_pInterfaceResMgr->GetXRatio());

	m_bVisible = LTTRUE;

	

	return LTTRUE;
}