Files
itgmania212121/stepmania/src/ActiveAttackList.cpp
T

97 lines
2.4 KiB
C++
Raw Normal View History

2004-03-17 06:01:17 +00:00
#include "global.h"
/*
-----------------------------------------------------------------------------
File: ActiveAttackList.h
Desc: A graphic displayed in the ActiveAttackList during Dancing.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "ActiveAttackList.h"
#include "RageUtil.h"
#include "GameState.h"
#include "ThemeManager.h"
#include "Inventory.h"
#include "RageTimer.h"
ActiveAttackList::ActiveAttackList()
{
}
void ActiveAttackList::Init( PlayerNumber pn )
{
m_PlayerNumber = pn;
}
void ActiveAttackList::Update( float fDelta )
{
BitmapText::Update( fDelta );
2004-03-24 07:37:35 +00:00
bool bTimeToUpdate =
GAMESTATE->m_bAttackBeganThisUpdate[m_PlayerNumber] ||
GAMESTATE->m_bAttackEndedThisUpdate[m_PlayerNumber];
2004-03-17 06:01:17 +00:00
2004-03-24 07:13:35 +00:00
if( bTimeToUpdate )
2004-03-17 06:01:17 +00:00
{
CString s;
const AttackArray& attacks = GAMESTATE->m_ActiveAttacks[m_PlayerNumber]; // NUM_INVENTORY_SLOTS
// clear all lines, then add all active attacks
2004-03-17 06:26:01 +00:00
for( unsigned i=0; i<attacks.size(); i++ )
2004-03-17 06:01:17 +00:00
{
const Attack& attack = attacks[i];
if( !attack.bOn )
continue; /* hasn't started yet */
2004-03-21 18:49:25 +00:00
CString sMods = attack.sModifier;
CStringArray asMods;
split( sMods, ", ", asMods );
2004-03-22 00:54:31 +00:00
for( unsigned j=0; j<asMods.size(); j++ )
{
2004-03-21 18:49:25 +00:00
CString& sMod = asMods[j];
2004-03-21 17:51:58 +00:00
2004-03-21 18:49:25 +00:00
// Strip out the approach speed token
if( !sMod.empty() && sMod[0]=='*' )
{
int iPos = sMod.Find(' ');
if( iPos != -1 )
sMod.erase( sMod.begin(), sMod.begin()+iPos+1 );
}
// Strip out "100% "
#define PERCENT_100 "100% "
if( !strncmp( sMod, PERCENT_100, sizeof(PERCENT_100)) )
{
sMod.erase( sMod.begin(), sMod.begin()+sizeof(PERCENT_100) );
}
// Capitalize all tokens
CStringArray asTokens;
split( sMod, " ", asTokens );
2004-03-22 00:54:31 +00:00
for( unsigned i=0; i<asTokens.size(); i++ )
2004-04-17 22:21:40 +00:00
asTokens[i] = Capitalize( asTokens[i] );
2004-04-26 04:54:33 +00:00
/* Theme the mod name (the last string). Allow this to not exist, since
* characters might use modifiers that don't exist in the theme. */
if( THEME->HasMetric( "OptionNames", asTokens.back() ) )
asTokens.back() = THEME->GetMetric( "OptionNames", asTokens.back() );
2004-04-17 22:21:40 +00:00
sMod = join( " ", asTokens );
2004-03-21 18:49:25 +00:00
if( s.empty() )
s = sMod;
else
s = sMod + "\n" + s;
}
2004-03-17 06:01:17 +00:00
}
this->SetText( s ); // BitmapText will not rebuild vertices if these strings are the same.
}
}