add character face support
This commit is contained in:
@@ -88,8 +88,6 @@ void Banner::SetScrolling( bool bScroll, float Percent)
|
||||
|
||||
void Banner::LoadFromSong( Song* pSong ) // NULL means no song
|
||||
{
|
||||
Sprite::EnableShadow( false );
|
||||
|
||||
if( pSong == NULL ) LoadFallback();
|
||||
else if( pSong->HasBanner() ) Load( pSong->GetBannerPath() );
|
||||
else LoadFallback();
|
||||
|
||||
@@ -100,4 +100,16 @@ CString Character::GetIconPath()
|
||||
else
|
||||
return as[0];
|
||||
}
|
||||
CString Character::GetHeadPath()
|
||||
{
|
||||
CStringArray as;
|
||||
GetDirListing( m_sCharDir+"head*.png", as, false, true );
|
||||
GetDirListing( m_sCharDir+"head*.jpg", as, false, true );
|
||||
GetDirListing( m_sCharDir+"head*.gif", as, false, true );
|
||||
GetDirListing( m_sCharDir+"head*.bmp", as, false, true );
|
||||
if( as.empty() )
|
||||
return "";
|
||||
else
|
||||
return as[0];
|
||||
}
|
||||
|
||||
|
||||
@@ -38,9 +38,7 @@ public:
|
||||
|
||||
CString m_sAttacks[NUM_ATTACK_LEVELS][NUM_ATTACKS_PER_LEVEL];
|
||||
|
||||
CString GetNormalHeadPath();
|
||||
CString GetHappyHeadPath();
|
||||
CString GetAngryHeadPath();
|
||||
CString GetHeadPath();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#include "global.h"
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
Class: CharacterHead
|
||||
|
||||
Desc: See header.
|
||||
|
||||
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "CharacterHead.h"
|
||||
#include "RageUtil.h"
|
||||
#include "GameConstantsAndTypes.h"
|
||||
#include "MusicWheel.h"
|
||||
#include "CharacterHead.h"
|
||||
#include "RageTimer.h"
|
||||
#include <math.h>
|
||||
#include "ThemeManager.h"
|
||||
#include "GameState.h"
|
||||
#include "Character.h"
|
||||
|
||||
|
||||
const float SECONDS_TO_SHOW_FACE = 1.5f;
|
||||
|
||||
|
||||
CharacterHead::CharacterHead()
|
||||
{
|
||||
}
|
||||
|
||||
void CharacterHead::LoadFromCharacter( Character* pCharacter )
|
||||
{
|
||||
CString sHeadPath = pCharacter->GetHeadPath();
|
||||
if( sHeadPath.empty() )
|
||||
return;
|
||||
|
||||
Load( sHeadPath );
|
||||
ASSERT( this->GetNumStates() == NUM_FACES );
|
||||
StopAnimating();
|
||||
SetFace( normal );
|
||||
}
|
||||
|
||||
void CharacterHead::Update( float fDelta )
|
||||
{
|
||||
if( m_fSecondsUntilReturnToNormal > 0 )
|
||||
{
|
||||
m_fSecondsUntilReturnToNormal -= fDelta;
|
||||
|
||||
if( m_fSecondsUntilReturnToNormal < 0 )
|
||||
{
|
||||
m_fSecondsUntilReturnToNormal = 0;
|
||||
this->SetState( normal );
|
||||
}
|
||||
}
|
||||
|
||||
if( GAMESTATE->m_fOpponentHealthPercent == 0 )
|
||||
this->SetState( defeated );
|
||||
|
||||
Sprite::Update( fDelta );
|
||||
}
|
||||
|
||||
void CharacterHead::SetFace( Face face )
|
||||
{
|
||||
if( GAMESTATE->m_fOpponentHealthPercent == 0 )
|
||||
return;
|
||||
|
||||
this->SetState( face );
|
||||
m_fSecondsUntilReturnToNormal = SECONDS_TO_SHOW_FACE;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef CharacterHead_H
|
||||
#define CharacterHead_H
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
Class: CharacterHead
|
||||
|
||||
Desc: A little graphic to the left of the song's text banner in the MusicWheel.
|
||||
|
||||
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "Sprite.h"
|
||||
class Character;
|
||||
|
||||
class CharacterHead : public Sprite
|
||||
{
|
||||
public:
|
||||
CharacterHead();
|
||||
|
||||
void LoadFromCharacter( Character* pCharacter );
|
||||
|
||||
virtual void Update( float fDelta );
|
||||
|
||||
enum Face { normal=0, taunt, attack, damage, defeated, reserved, NUM_FACES };
|
||||
void SetFace( Face face );
|
||||
|
||||
protected:
|
||||
float m_fSecondsUntilReturnToNormal;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -14,17 +14,35 @@
|
||||
#include "GameState.h"
|
||||
|
||||
|
||||
const float METER_WIDTH = 550;
|
||||
|
||||
const float FACE_X[NUM_PLAYERS] = { -300, +300 };
|
||||
const float FACE_Y[NUM_PLAYERS] = { 0, 0 };
|
||||
|
||||
|
||||
CombinedLifeMeterTug::CombinedLifeMeterTug()
|
||||
{
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
int p;
|
||||
for( p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
m_Stream[p].Load( THEME->GetPathToG(ssprintf("CombinedLifeMeterTug stream p%d",p+1)), 550 );
|
||||
m_Stream[p].Load( THEME->GetPathToG(ssprintf("CombinedLifeMeterTug stream p%d",p+1)), METER_WIDTH );
|
||||
this->AddChild( &m_Stream[p] );
|
||||
}
|
||||
m_Stream[PLAYER_2].SetZoomX( -1 );
|
||||
|
||||
m_sprFrame.Load( THEME->GetPathToG(ssprintf("CombinedLifeMeterTug frame")) );
|
||||
this->AddChild( &m_sprFrame );
|
||||
|
||||
|
||||
for( p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
Character* pCharacter = GAMESTATE->m_pCurCharacters[p];
|
||||
ASSERT( pCharacter );
|
||||
|
||||
m_Head[p].LoadFromCharacter( pCharacter );
|
||||
m_Head[p].SetXY( FACE_X[p], FACE_Y[p] );
|
||||
this->AddChild( &m_Head[p] );
|
||||
}
|
||||
}
|
||||
|
||||
void CombinedLifeMeterTug::Update( float fDelta )
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "LifeMeter.h"
|
||||
#include "Sprite.h"
|
||||
#include "MeterDisplay.h"
|
||||
#include "CharacterHead.h"
|
||||
|
||||
|
||||
class CombinedLifeMeterTug : public CombinedLifeMeter
|
||||
@@ -33,6 +34,8 @@ protected:
|
||||
|
||||
MeterDisplay m_Stream[NUM_PLAYERS];
|
||||
Sprite m_sprFrame;
|
||||
|
||||
CharacterHead m_Head[NUM_PLAYERS];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user