Example #1
0
int CHighScoreList::AddEntry (const CGameRecord &NewEntry)

//	AddEntry
//
//	Add another entry to the high score

	{
	int i, j;

	//	Score of 0 doesn't count

	if (NewEntry.GetScore() == 0)
		return -1;

	//	Modify the epitaph in the entry

	CGameRecord ModifiedEntry = NewEntry;
	if (strEquals(strWord(ModifiedEntry.GetEndGameEpitaph(), 0), CONSTLIT("was")))
		ModifiedEntry.SetEndGameEpitaph(strSubString(ModifiedEntry.GetEndGameEpitaph(), 4, -1));

	//	Find a spot on the list

	for (i = 0; i < m_iCount; i++)
		{
		if (ModifiedEntry.GetScore() > m_List[i].GetScore())
			break;
		}

	//	If we are the end of the list, then we didn't make the
	//	high score list.

	if (i == MAX_SCORES)
		return -1;

	//	Otherwise, move all scores below us by one

	m_bModified = true;

	if (m_iCount < MAX_SCORES)
		m_iCount++;

	for (j = m_iCount-2; j >= i; j--)
		m_List[j+1] = m_List[j];

	m_List[i] = ModifiedEntry;

	//	Player name

	m_sMostRecentPlayerName = ModifiedEntry.GetPlayerName();
	m_iMostRecentPlayerGenome = ModifiedEntry.GetPlayerGenome();

	return i;
	}
Example #2
0
void CTranscendenceWnd::CreateScoreAnimation (const CGameRecord &Stats, IAnimatron **retpAnimatron)

//	CreateScoreAnimation
//
//	Creates an animation of the given score

	{
	int i;
	int iDuration = 300;
	int x = m_rcIntroMain.left + RectWidth(m_rcIntroMain) / 2;
	int y = m_rcIntroMain.bottom - RectHeight(m_rcIntroMain) / 3;

	//	Create sequencer to hold everything

	CAniSequencer *pSeq = new CAniSequencer;

	//	Create the score

	CAniText *pCredit = new CAniText;
	pCredit->SetPropertyVector(CONSTLIT("position"), CVector((Metric)x, (Metric)y));
	pCredit->SetPropertyColor(CONSTLIT("color"), m_Fonts.rgbTitleColor);
	pCredit->SetPropertyString(CONSTLIT("text"), strFromInt(Stats.GetScore()));

	pCredit->SetPropertyFont(CONSTLIT("font"), &m_Fonts.Title);
	pCredit->SetFontFlags(CG16bitFont::AlignCenter);

	pCredit->AnimateLinearFade(iDuration, 30, 30);

	pSeq->AddTrack(pCredit, 0);
	y += m_Fonts.Title.GetHeight();

	//	Player name

	CAniText *pName = new CAniText;
	pName->SetPropertyVector(CONSTLIT("position"), CVector((Metric)x, (Metric)y));
	pName->SetPropertyColor(CONSTLIT("color"), m_Fonts.rgbTextColor);
	pName->SetPropertyString(CONSTLIT("text"), Stats.GetPlayerName());

	pName->SetPropertyFont(CONSTLIT("font"), &m_Fonts.SubTitle);
	pName->SetFontFlags(CG16bitFont::AlignCenter);

	pName->AnimateLinearFade(iDuration, 30, 30);

	pSeq->AddTrack(pName, 5);
	y += m_Fonts.SubTitle.GetHeight();

	//	Epitaph

	TArray<CString> EpitaphLines;
	m_Fonts.Header.BreakText(strCapitalize(Stats.GetEndGameEpitaph()), 512, &EpitaphLines);

	for (i = 0; i < EpitaphLines.GetCount(); i++)
		{
		CAniText *pLine = new CAniText;
		pLine->SetPropertyVector(CONSTLIT("position"), CVector((Metric)x, (Metric)y));
		pLine->SetPropertyColor(CONSTLIT("color"), m_Fonts.rgbTextColor);
		pLine->SetPropertyString(CONSTLIT("text"), EpitaphLines[i]);

		pLine->SetPropertyFont(CONSTLIT("font"), &m_Fonts.Header);
		pLine->SetFontFlags(CG16bitFont::AlignCenter);

		pLine->AnimateLinearFade(iDuration, 30, 30);

		pSeq->AddTrack(pLine, 5);
		y += m_Fonts.Header.GetHeight();
		}

	//	Done

	*retpAnimatron = pSeq;
	}