AttackDisplay work

This commit is contained in:
Glenn Maynard
2003-12-28 22:48:23 +00:00
parent a01daf6f8e
commit f70b462988
2 changed files with 53 additions and 9 deletions
+52 -7
View File
@@ -14,7 +14,21 @@
#include "ThemeManager.h" #include "ThemeManager.h"
#include "GameState.h" #include "GameState.h"
#include "ActorUtil.h" #include "ActorUtil.h"
#include "Character.h"
#include "RageLog.h"
#include "RageTextureManager.h"
#include <set>
CString GetAttackPath( const CString &sAttack )
{
CString ret = ssprintf( "AttackDisplay attack %s", sAttack.c_str() );
/* 1.5x -> 1_5x. If we pass a period to THEME->GetPathTo, it'll think
* we're looking for a specific file and not search. */
ret.Replace( ".", "_" );
return ret;
}
AttackDisplay::AttackDisplay() AttackDisplay::AttackDisplay()
{ {
@@ -22,15 +36,41 @@ AttackDisplay::AttackDisplay()
GAMESTATE->m_PlayMode != PLAY_MODE_RAVE ) GAMESTATE->m_PlayMode != PLAY_MODE_RAVE )
return; return;
m_textAttack.SetName( ssprintf("TextP%d",m_PlayerNumber+1) ); m_sprAttack.SetName( ssprintf("TextP%d",m_PlayerNumber+1) );
m_textAttack.LoadFromFont( THEME->GetPathToF("AttackDisplay") ); m_sprAttack.SetDiffuseAlpha( 0 ); // invisible
m_textAttack.SetDiffuseAlpha( 0 ); // invisible this->AddChild( &m_sprAttack );
this->AddChild( &m_textAttack );
} }
void AttackDisplay::Init( PlayerNumber pn ) void AttackDisplay::Init( PlayerNumber pn )
{ {
m_PlayerNumber = pn; m_PlayerNumber = pn;
if( GAMESTATE->m_PlayMode != PLAY_MODE_BATTLE &&
GAMESTATE->m_PlayMode != PLAY_MODE_RAVE )
return;
set<CString> attacks;
for( int al=0; al<NUM_ATTACK_LEVELS; al++ )
{
const Character *ch = GAMESTATE->m_pCurCharacters[pn];
ASSERT( ch );
const CString* asAttacks = ch->m_sAttacks[al];
for( int att = 0; att < NUM_ATTACKS_PER_LEVEL; ++att )
attacks.insert( asAttacks[att] );
}
for( set<CString>::const_iterator it = attacks.begin(); it != attacks.end(); ++it )
{
const CString ThemePath = GetAttackPath( *it );
const CString path = THEME->GetPathToG( ThemePath, true );
if( path == "" )
{
LOG->Trace( "Couldn't find \"%s\"", ThemePath.c_str() );
continue;
}
TEXTUREMAN->CacheTexture( path );
}
} }
@@ -65,7 +105,12 @@ void AttackDisplay::Update( float fDelta )
void AttackDisplay::SetAttack( const CString &sText ) void AttackDisplay::SetAttack( const CString &sText )
{ {
m_textAttack.SetDiffuseAlpha( 1 ); const CString path = THEME->GetPathToG( GetAttackPath( sText ), true );
m_textAttack.SetText( sText ); if( path == "" )
UtilOnCommand( m_textAttack, "AttackDisplay" ); return;
m_sprAttack.SetDiffuseAlpha( 1 );
m_sprAttack.Load( path );
const CString sName = ssprintf( "%sP%i", sText.c_str(), m_PlayerNumber+1 );
m_sprAttack.Command( THEME->GetMetric("AttackDisplay", sName + "OnCommand" ) );
} }
+1 -2
View File
@@ -13,7 +13,6 @@
#include "ActorFrame.h" #include "ActorFrame.h"
#include "Sprite.h" #include "Sprite.h"
#include "BitmapText.h"
#include "PlayerNumber.h" #include "PlayerNumber.h"
#include "GameConstantsAndTypes.h" // for TapNoteScore #include "GameConstantsAndTypes.h" // for TapNoteScore
@@ -31,7 +30,7 @@ public:
protected: protected:
PlayerNumber m_PlayerNumber; PlayerNumber m_PlayerNumber;
BitmapText m_textAttack; Sprite m_sprAttack;
}; };
#endif #endif