Beispiel #1
0
DWORD ISndStreamWAV::Read(PBYTE pbData,DWORD dwNumBytes)
{
    ASSERT(m_pSndFile);

    LTRACE( _T( "ISndStreamWAV::Read dwNumBytes %d  CurrentFilePos %ld TotalFileSize %ld " ),
            dwNumBytes,
            m_ddwCurrentFilePos,
            m_ddwTotalFileSize );

    m_ddwCurrentFilePos+= dwNumBytes;

    if ( m_ddwTotalFileSize )
    {
        SetPercent( (INT)( (double) m_ddwCurrentFilePos * 100.0 / m_ddwTotalFileSize ) );
    }
    else
    {
        SetPercent( 0 );
    }

    DWORD dwReturn = (DWORD)sf_read_short( m_pSndFile,(short*)pbData, dwNumBytes / sizeof( SHORT ) ) * sizeof( SHORT );

    LTRACE( _T( "ISndStreamWAV::Read returns %d " ),dwReturn );

    return dwReturn;
}
Beispiel #2
0
void MeterDisplay::LoadFromNode( const XNode* pNode )
{
	LOG->Trace( "MeterDisplay::LoadFromNode(%s)", ActorUtil::GetWhere(pNode).c_str() );

	const XNode *pStream = pNode->GetChild( "Stream" );
	if( pStream == nullptr )
	{
		LuaHelpers::ReportScriptErrorFmt("%s: MeterDisplay: missing the \"Stream\" attribute", ActorUtil::GetWhere(pNode).c_str());
		return;
	}
	m_sprStream.LoadActorFromNode( pStream, this );
	m_sprStream->SetName( "Stream" );
	//LOAD_ALL_COMMANDS( m_sprStream );
	this->AddChild( m_sprStream );

	const XNode* pChild = pNode->GetChild( "Tip" );
	if( pChild != nullptr )
	{
		m_sprTip.LoadActorFromNode( pChild, this );
		m_sprTip->SetName( "Tip" );
		//LOAD_ALL_COMMANDS( m_sprTip );
		this->AddChild( m_sprTip );
	}

	float fStreamWidth = 0;
	pNode->GetAttrValue( "StreamWidth", fStreamWidth );
	SetStreamWidth( fStreamWidth );

	SetPercent( 0.5f );

	ActorFrame::LoadFromNode( pNode );
}
Beispiel #3
0
void MeterDisplay::LoadFromNode( const XNode* pNode )
{
	LOG->Trace( "MeterDisplay::LoadFromNode(%s)", ActorUtil::GetWhere(pNode).c_str() );

	const XNode *pStream = pNode->GetChild( "Stream" );
	if( pStream == NULL )
		RageException::Throw( "%s: MeterDisplay: missing the \"Stream\" attribute", ActorUtil::GetWhere(pNode).c_str() );
	m_sprStream.LoadActorFromNode( pStream, this );
	m_sprStream->SetName( "Stream" );
	//LOAD_ALL_COMMANDS( m_sprStream );
	this->AddChild( m_sprStream );

	const XNode* pChild = pNode->GetChild( "Tip" );
	if( pChild != NULL )
	{
		m_sprTip.LoadActorFromNode( pChild, this );
		m_sprTip->SetName( "Tip" );
		//LOAD_ALL_COMMANDS( m_sprTip );
		this->AddChild( m_sprTip );
	}

	float fStreamWidth = 0;
	pNode->GetAttrValue( "StreamWidth", fStreamWidth );
	SetStreamWidth( fStreamWidth );

	SetPercent( 0.5f );

	ActorFrame::LoadFromNode( pNode );
}
Beispiel #4
0
// This method is called to reset the texmap back to its default values.
void Planet::Init() {
	// Reset the XYZGen or allocate a new one
	if (xyzGen) 
		xyzGen->Reset();
	else 
		ReplaceReference(0, GetNewDefaultXYZGen());	


//	ReplaceReference(1, CreateParameterBlock(pbdesc, 
//		PB_LENGTH, PLANET_PB_VERSION));
//	if (paramDlg) 
//		paramDlg->pmap->SetParamBlock(pblock);

	// Set the inital parameters
	// {10,20,80},{10,30,80},{10,40,90},{10,100,12},
	// {100,80,12},{80,20,8},{100,80,50},{100,100,100}
	SetColor(0, Color(0.04f, 0.08f, 0.31f), TimeValue(0));
	SetColor(1, Color(0.04f, 0.12f, 0.31f), TimeValue(0));
	SetColor(2, Color(0.04f, 0.16f, 0.31f), TimeValue(0));
	SetColor(3, Color(0.04f, 0.39f, 0.05f), TimeValue(0));
	SetColor(4, Color(0.39f, 0.31f, 0.05f), TimeValue(0));
	SetColor(5, Color(0.31f, 0.08f, 0.03f), TimeValue(0));
	SetColor(6, Color(0.39f, 0.31f, 0.20f), TimeValue(0));
	SetColor(7, Color(0.39f, 0.39f, 0.39f), TimeValue(0));

	SetSize(40.0f, TimeValue(0));
	SetIsland(0.5f, TimeValue(0));
	SetPercent(60.0f, TimeValue(0));
	SetSeed(12345, TimeValue(0));
	blend = 1;

	// Set the validity interval of the texture to empty
	texValidity.SetEmpty();
}
Beispiel #5
0
// --- Methods inherited from Tex3D ---
void Planet::ReadSXPData(TCHAR *name, void *sxpdata) {
	PlanetState *state = (PlanetState*)sxpdata;
	if (state != NULL && (state->version == PLANET_SXP_VERSION)) {
		SetSize(state->size, TimeValue(0));
		SetPercent(state->percent, TimeValue(0));
		SetIsland(state->island, TimeValue(0));
		SetSeed(state->seed, TimeValue(0));
	}
}
Bool SmplMatrixDialog::InitValues(void)
{
	SetInt32(GADGET_SMPL_MATRIX_DOCUMENT_PREVIEW, document_preview);
	SetInt32(GADGET_SMPL_MATRIX_TEXTURE_MODE, settings->tile_flags == TILE_REPEAT_BORDER ? 0 : 1);

	SetPercent(GADGET_SMPL_MATRIX_SLIDER_MIX, settings->matrix_opacity, 0.0, 100.0, 0.1);
	SetFloat(GADGET_SMPL_MATRIX_SLIDER_ANGLE, Rad(settings->angle), Rad(MIN_ANGLE), Rad(MAX_ANGLE), Rad(STEP_ANGLE), FORMAT_DEGREE);
	SetInt32(GADGET_SMPL_MATRIX_TYPE_POPUP, settings->type);

	return true;
}
Beispiel #7
0
void MeterDisplay::Load( RString sStreamPath, float fStreamWidth, RString sTipPath )
{
	m_sprStream.Load( sStreamPath );
	this->AddChild( m_sprStream );

	m_sprTip.Load( sTipPath );
	this->AddChild( m_sprTip );

	SetStreamWidth( fStreamWidth );
	SetPercent( 0.5f );
}
//---------------------------------------------------------------------------
void TSmartProgress::Set()
{
	float percent=0;

	finish = clock();
	if (Position>0 && finish-last>250){
		SetTime((Max-Position)*(finish-start)/Position);
		last=finish;

		percent=100.0*Position/Max;
		SetPercent(percent);
	}
}
Beispiel #9
0
void SongMeterDisplay::Update( float fDeltaTime )
{
	if( GAMESTATE->m_pCurSong )
	{
		float fSongStartSeconds = GAMESTATE->m_pCurSong->GetFirstSecond();
		float fSongEndSeconds = GAMESTATE->m_pCurSong->GetLastSecond();
		float fPercentPositionSong = SCALE( GAMESTATE->m_Position.m_fMusicSeconds, fSongStartSeconds, fSongEndSeconds, 0.0f, 1.0f );
		CLAMP( fPercentPositionSong, 0, 1 );

		SetPercent( fPercentPositionSong );
	}

	MeterDisplay::Update( fDeltaTime );
}
Beispiel #10
0
BOOL ISndStreamWinAmp::CloseStream()
{
	if ( FALSE == g_bFinished && TRUE == g_bInitialized )
	{
		g_bFinished = TRUE;
		m_WinAmpProp.pModule->Stop( );
	}

	SetPercent( 0 );
	g_bInitialized = FALSE;


	return TRUE;
}
Beispiel #11
0
void MeterDisplay::Load( const CString &sStreamPath, float fStreamWidth, const CString &sTipPath )
{
	m_fStreamWidth = fStreamWidth;

	m_sprStream.Load( sStreamPath );
	m_sprStream.SetZoomX( fStreamWidth / m_sprStream.GetUnzoomedWidth() );

	m_sprTip.Load( sTipPath );

	this->AddChild( &m_sprStream );
	this->AddChild( m_sprTip );

	SetPercent( 0.5f );
}
Beispiel #12
0
void SongMeterDisplay::Update( float fDeltaTime )
{
	if( GAMESTATE->get_curr_song() )
	{
		float fSongStartSeconds = GAMESTATE->get_curr_song()->GetFirstSecond();
		float fSongEndSeconds = GAMESTATE->get_curr_song()->GetLastSecond();
		float fPercentPositionSong = Rage::scale( GAMESTATE->m_Position.m_fMusicSeconds, fSongStartSeconds, fSongEndSeconds, 0.0f, 1.0f );
		fPercentPositionSong = Rage::clamp( fPercentPositionSong, 0.f, 1.f );

		SetPercent( fPercentPositionSong );
	}

	MeterDisplay::Update( fDeltaTime );
}
Beispiel #13
0
BOOL CProgressBar::Create(CFrameWnd* pParentWnd, String_64 *JobDescrip,
							DWORD dwStyle, UINT32 nID)
{
	ASSERT_VALID(pParentWnd);   // must have a parent

	CurrentPercent = -1;
	if (JobDescrip == NULL)
		JobDescription = NULL;
	else
		JobDescription = new String_64(*JobDescrip);
#if WIN32
	// this element of CControlBar does not exist in MFC 2.5 16-bit
	m_dwStyle = dwStyle;
#endif

#if _MFC_VER == 0x400
	// MFC 4 defers registering of window classes, so make sure the window class
	// is registered before we use it.
	// (code taken from mfc/src/bardock.cpp, in MFC 4)
	if (!AfxDeferRegisterClass(AFX_WNDCONTROLBAR_REG))
		return FALSE;
#endif


	// Work out the position of the bar.
	CRect rect;
	rect.SetRectEmpty();

	// create the window
	if (!CWnd::Create(_afxWndControlBar, NULL, dwStyle, rect, pParentWnd, nID))
		return FALSE;
		// NOTE: Parent must resize itself for control bar to be resized

	// set initial font and calculate bar height
	OnSetFont((WPARAM)m_hFont, 0);  			// initialize font height etc


	pParentWnd->RecalcLayout();					// Cause ourself to be shown
	SetPercent(0, TRUE);		// Force redraw of window _including background_

	return TRUE;
}
Beispiel #14
0
void SProgressBar::Construct( const FArguments& InArgs )
{
	check(InArgs._Style);

	MarqueeOffset = 0.0f;

	Style = InArgs._Style;

	SetPercent(InArgs._Percent);
	BarFillType = InArgs._BarFillType;
	
	BackgroundImage = InArgs._BackgroundImage;
	FillImage = InArgs._FillImage;
	MarqueeImage = InArgs._MarqueeImage;
	
	FillColorAndOpacity = InArgs._FillColorAndOpacity;
	BorderPadding = InArgs._BorderPadding;

	CurrentTickRate = 0.0f;
	MinimumTickRate = InArgs._RefreshRate;

	ActiveTimerHandle = RegisterActiveTimer(CurrentTickRate, FWidgetActiveTimerDelegate::CreateSP(this, &SProgressBar::ActiveTick));
}
//---------------------------------------------------------------------------
void TSmartProgress::Initialize(TWinControl *ParentWindow)
{
	TextPanel=new TPanel(ParentWindow);
	TextPanel->Parent=ParentWindow;
	TextPanel->Height=25;
	TextPanel->Align=alBottom;

	Parent=ParentWindow;
	Align=alClient;

	ProgressLabel=new TLabel(TextPanel);
	ProgressLabel->Parent=static_cast <TWinControl *> (TextPanel);
	ProgressLabel->Align=alLeft;
	SetPercent(0);

	TimeLabel=new TLabel(TextPanel);
	TimeLabel->Parent=static_cast <TWinControl *> (TextPanel);
	TimeLabel->Align=alRight;
	SetTime(0);

	Max=100;
	Min=0;
	Position=0;
}
Beispiel #16
0
void IProgressBar::AddPercent(float val)
{
	SetPercent(mPercent + val);
}
Beispiel #17
0
void CSnoopyProApp::DeinitializeWorkTicks(void)
{
    m_dwTotalWorkTicks = 1;
    m_dwWorkTicks = 0;
    SetPercent(0);
}
Beispiel #18
0
DWORD ISndStreamWinAmp::Read(PBYTE pbData,DWORD dwNumBytes)
{
	int		nReturn = 0;
	LONG	lastcount = 0;

	LTRACE3(	_T( "ISndStreamWinAmp::Read dwNumBytes %d  CurrentFilePos %d TotalFileSize %d " ),
				dwNumBytes,
				m_dwCurrentFilePos,
				m_dwTotalFileSize );

	m_dwCurrentFilePos+= dwNumBytes;

	int nCurrentTime = m_WinAmpProp.pModule->GetOutputTime();
	int nTotalTime = m_WinAmpProp.pModule->GetLength();

	if ( nTotalTime )
	{
		int t = g_nOutSampleRate*g_nNumChannels;
		int	l = 0;
		int ms = g_nFifoTotalBytes;

		if ( t )
		{
			l=ms%t;
			ms /= t;
			ms *= 1000;
			ms += (l*1000)/t;

			if (g_nBitsPerSample == 16)
				ms/=2;
		}
		else
		{
			ms = 0;
		}

		SetPercent( (INT)( (double) (nCurrentTime - ms) * 100.0 / nTotalTime ) );
	}
	else
	{
		SetPercent( 0 );
	}



	// wait for incoming data
	HANDLE pWaitEvents[2] = { (HANDLE)g_eFifoNotEmpty, (HANDLE)g_eFinished }; 

	int nEventIdx = WaitForMultipleObjects( 2, pWaitEvents, FALSE, INFINITE ) - WAIT_OBJECT_0 ;

	if ( 1 == nEventIdx )
	{
		nReturn = 0;
	}
	else
	{

		nReturn = g_pFifo[g_nFifoReadIdx].nBytesWritten;

		memcpy( pbData, g_pFifo[g_nFifoReadIdx].pbtBuffer, nReturn );


		LTRACE2( _T( "ISndStreamWinAmp::Read getting %d bytes from buffer %d (freebuffers = %d)" ), 
			g_pFifo[g_nFifoReadIdx].nBytesWritten,
			g_nFifoReadIdx,
			g_nFifoFreeBuffers
			);

		// lock access to FIFO parameters
		g_mFifoAcces.Lock();

		if ( g_nFifoFreeBuffers < WAPI_FIFO_NUM_BUFFERS )
		{
			g_nFifoFreeBuffers++;
		}

		if ( WAPI_FIFO_NUM_BUFFERS == g_nFifoFreeBuffers )
		{
			LTRACE( _T( "Reset g_eFifoNotEmpty Event" ) );
			g_eFifoNotEmpty.ResetEvent();
		}

		if ( 2 == g_nFifoFreeBuffers )
		{
			LTRACE( _T( "Set g_eFifoNotFull Event" ) );
			g_eFifoNotFull.SetEvent();
		}

		g_nFifoTotalBytes-= nReturn;

		// unlock access to FIFO parameters
		g_mFifoAcces.Unlock();

		// increase FIFO read index pointer
		g_nFifoReadIdx = ( ( g_nFifoReadIdx + 1 ) % WAPI_FIFO_NUM_BUFFERS );

		LTRACE( _T( "FreeBuffers on Read :%d, bytes in fifo %d" ),
				g_nFifoFreeBuffers,
				g_nFifoTotalBytes );

	}

	// update the bitrate info
	SetBitRate( g_nBitRate );

	LTRACE2( _T( "ISndStreamWinAmp::Read returns %d" ), nReturn );

	return nReturn;
}
Beispiel #19
0
DWORD ISndStreamMPEG::Read(PBYTE pbData,DWORD dwNumBytes)
{
	BOOL bEos=FALSE;

	static int nFrame=0;

	// check if file pointer is valid
	ASSERT(m_pFile);

	// check size of output buffer, must be larger than largest frame
	ASSERT(dwNumBytes>=4096);

	int nErrorCode=!MPGLIB_OK;
	int	nDataOutBuffer=0;



//	while ( (nErrorCode!=MPGLIB_OK) && (m_nDataInBuffer>0))
//	while ( (m_nDataInBuffer>0) && (nDataOutBuffer==0))
	// Try to decode a block, until were not at the end of the input stream
	// end till we have a decoded frame
	while ( (bEos==FALSE) && (nDataOutBuffer==0) )
	{

		// Try to decode the data
		nErrorCode= m_pDecode(	m_hStream,
								NULL,
								0,
								pbData,
								dwNumBytes,
								&nDataOutBuffer);

		if ( nErrorCode==MPGLIB_NEED_MORE )
		{
			DWORD dwRead= (m_dwBytesToDo>MPEG_WAV_BUFFERSIZE)?MPEG_WAV_BUFFERSIZE:m_dwBytesToDo;

			// Read MPEG data from disk
			dwRead=fread(m_pbDataInBuffer,1,dwRead,m_pFile);

			m_dwCurrentFilePos+= dwRead;

			if (dwRead!=0)
			{
				m_dwBytesToDo-=dwRead;

//				CString strTmp;
//				strTmp.Format("******* Read %d bytes at frame %d\n",dwRead,nFrame);
//				OutputDebugString(strTmp);

				// Fed new data to Decode library, and decode a frame
				nErrorCode = m_pDecode(m_hStream,
										m_pbDataInBuffer,
										dwRead,
										pbData,
										dwNumBytes,
										&nDataOutBuffer);
			}
			else
			{
				// Were stuck, no more data, and the decoder needs more
				bEos=TRUE;
			}

			// Get bitrate of this frame 
			SetBitRate(m_pGetBitRate());

		}

		if ( m_dwTotalFileSize )
		{
			SetPercent( (INT)( (double) m_dwCurrentFilePos * 100.0 / m_dwTotalFileSize ) );
		}
		else
		{
			SetPercent( 0 );
		}

	}

	nFrame++;
	return nDataOutBuffer;
}
Beispiel #20
0
void CSnoopyProApp::IncrementWorkTick(void)
{
    m_dwWorkTicks = min(m_dwWorkTicks + 1, m_dwTotalWorkTicks);
    ASSERT(0 != m_dwTotalWorkTicks);
    SetPercent(MulDiv(m_dwWorkTicks, 100, m_dwTotalWorkTicks));
}