#include "global.h" #include "GraphDisplay.h" #include "ThemeManager.h" #include "RageTextureManager.h" #include "RageDisplay.h" #include "RageUtil.h" #include "StageStats.h" //#define DIVIDE_LINE_WIDTH THEME->GetMetricI(m_sName,"TexturedBottomHalf") GraphDisplay::GraphDisplay() { m_pTexture = NULL; } void GraphDisplay::Load( const CString &TexturePath, float height ) { m_Position = 1; memset( m_CurValues, 0, sizeof(m_CurValues) ); memset( m_DestValues, 0, sizeof(m_DestValues) ); memset( m_LastValues, 0, sizeof(m_LastValues) ); Unload(); m_pTexture = TEXTUREMAN->LoadTexture( TexturePath ); m_size.x = (float) m_pTexture->GetSourceWidth(); m_size.y = (float) m_pTexture->GetSourceHeight(); for( int i = 0; i < VALUE_RESOLUTION; ++i ) m_CurValues[i] = height; UpdateVerts(); } void GraphDisplay::Unload() { if( m_pTexture != NULL ) TEXTUREMAN->UnloadTexture( m_pTexture ); m_pTexture = NULL; } void GraphDisplay::LoadFromStageStats( const PlayerStageStats &s ) { memcpy( m_LastValues, m_CurValues, sizeof(m_CurValues) ); m_Position = 0; s.GetLifeRecord( m_DestValues, VALUE_RESOLUTION ); for( unsigned i=0; iGetTextureCoordRect( 0 ); for( int i = 0; i < NumSlices; ++i ) { const float Left = SCALE( float(i), 0.0f, float(NumSlices), tex->left, tex->right ); const float Right = SCALE( float(i+1), 0.0f, float(NumSlices), tex->left, tex->right ); const float LeftTop = SCALE( float(m_CurValues[i]), 0.0f, 1.0f, tex->bottom, tex->top ); const float RightTop = SCALE( float(m_CurValues[i+1]), 0.0f, 1.0f, tex->bottom, tex->top ); Slices[i*4+0].t = RageVector2( Left, LeftTop ); // top left Slices[i*4+1].t = RageVector2( Left, tex->bottom ); // bottom left Slices[i*4+2].t = RageVector2( Right, tex->bottom ); // bottom right Slices[i*4+3].t = RageVector2( Right, RightTop ); // top right } } void GraphDisplay::Update( float fDeltaTime ) { ActorFrame::Update( fDeltaTime ); if( m_Position == 1 ) return; m_Position = clamp( m_Position+fDeltaTime, 0, 1 ); for( int i = 0; i < VALUE_RESOLUTION; ++i ) m_CurValues[i] = m_DestValues[i]*m_Position + m_LastValues[i]*(1-m_Position); UpdateVerts(); } void GraphDisplay::DrawPrimitives() { Actor::SetGlobalRenderStates(); // set Actor-specified render states DISPLAY->ClearAllTextures(); DISPLAY->SetTexture( 0, m_pTexture ); // don't bother setting texture render states for a null texture //Actor::SetTextureRenderStates(); DISPLAY->DrawQuads( Slices, ARRAYSIZE(Slices) ); DISPLAY->SetTexture( 0, NULL ); } /* * (c) 2003 Glenn Maynard * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, and/or sell copies of the Software, and to permit persons to * whom the Software is furnished to do so, provided that the above * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */