/* Copyright (c) 2002-2012 Croteam Ltd. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "stdh.h" #include #include "Credits.h" static CStaticStackArray _astrCredits; static BOOL _bCreditsOn = FALSE; static PIX pixW = 0; static PIX pixH = 0; static PIX pixJ = 0; static FLOAT fResolutionScaling; static PIX pixLineHeight; static CTString strEmpty; static FLOAT _fSpeed = 2.0f; static BOOL _bUseRealTime = FALSE; static CTimerValue _tvStart; static FLOAT _tmStart; FLOAT GetTime(void) { if(!_bUseRealTime) { return _pTimer->GetLerpedCurrentTick()-_tmStart; } else { return (_pTimer->GetHighPrecisionTimer()-_tvStart).GetSeconds();; } } void PrintOneLine(CDrawPort *pdp, const CTString &strText) { pdp->SetTextScaling( fResolutionScaling); pdp->SetTextAspect( 1.0f); pdp->PutTextC( strText, pixW/2, pixJ, C_WHITE|255); pixJ+=pixLineHeight; } static void LoadOneFile(const CTFileName &fnm) { try { // open the file CTFileStream strm; strm.Open_t(fnm); // count number of lines INDEX ctLines = 0; while(!strm.AtEOF()) { CTString strLine; strm.GetLine_t(strLine); ctLines++; } strm.SetPos_t(0); // allocate that much CTString *astr = _astrCredits.Push(ctLines); // load all lines for(INDEX iLine = 0; iLineGetLerpedCurrentTick(); } else { _bUseRealTime = TRUE; _tvStart = _pTimer->GetHighPrecisionTimer(); } } } // turn credits off void Credits_Off(void) { if (!_bCreditsOn) { return; } _bCreditsOn = FALSE; _astrCredits.Clear(); } // render credits to given drawport FLOAT Credits_Render(CDrawPort *pdp) { if (!_bCreditsOn) { return 0; } CDrawPort dpWide; pdp->MakeWideScreen(&dpWide); pdp->Unlock(); dpWide.Lock(); FLOAT fTime = GetTime(); pixW = dpWide.GetWidth(); pixH = dpWide.GetHeight(); fResolutionScaling = (FLOAT)pixW / 640.0f; dpWide.SetFont( _pfdDisplayFont); pixLineHeight = floor(20*fResolutionScaling); const FLOAT fLinesPerSecond = _fSpeed; FLOAT fOffset = fTime*fLinesPerSecond; INDEX ctLinesOnScreen = pixH/pixLineHeight; INDEX iLine1 = fOffset; pixJ = iLine1*pixLineHeight-fOffset*pixLineHeight; iLine1-=ctLinesOnScreen; INDEX ctLines = _astrCredits.Count(); BOOL bOver = TRUE; for (INDEX i = iLine1; i=0 && iLineLock(); if (bOver) { return 0; } else if (ctLines-iLine1