2003-02-26 00:20:00 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
File: ActiveItemList.h
|
|
|
|
|
|
|
|
|
|
Desc: A graphic displayed in the ActiveItemList during Dancing.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Chris Danford
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ActiveItemList.h"
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "GameState.h"
|
|
|
|
|
#include "ThemeManager.h"
|
|
|
|
|
#include "Inventory.h"
|
|
|
|
|
#include "RageTimer.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TEXT_HORIZ_ALIGN( p ) THEME->GetMetricI("ActiveItemList",ssprintf("TextHorizAlignP%d",p+1))
|
|
|
|
|
#define TEXT_ZOOM THEME->GetMetricF("ActiveItemList","TextZoom")
|
|
|
|
|
#define SPACING_Y THEME->GetMetricF("ActiveItemList","SpacingY")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ActiveItemList::ActiveItemList()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-07 03:25:44 +00:00
|
|
|
void ActiveItemList::Init( PlayerNumber pn )
|
2003-02-26 00:20:00 +00:00
|
|
|
{
|
|
|
|
|
m_PlayerNumber = pn;
|
|
|
|
|
|
2003-04-07 23:06:33 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for( i=0; i<MAX_ACTIVE_ITEMS_LINES; i++ )
|
|
|
|
|
{
|
2003-04-12 17:39:27 +00:00
|
|
|
m_text[i].LoadFromFont( THEME->GetPathToF("Common normal") );
|
2003-04-07 23:06:33 +00:00
|
|
|
m_text[i].SetZoom( TEXT_ZOOM );
|
|
|
|
|
// m_text[i].SetText( "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" );
|
|
|
|
|
this->AddChild( &m_text[i] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( i=0; i<MAX_ACTIVE_ITEMS_LINES; i++ )
|
2003-02-26 00:20:00 +00:00
|
|
|
{
|
|
|
|
|
m_text[i].SetHorizAlign( (Actor::HorizAlign)TEXT_HORIZ_ALIGN(pn) );
|
2003-02-26 23:26:57 +00:00
|
|
|
bool bReverse = GAMESTATE->m_PlayerOptions[pn].m_fReverseScroll == 1;
|
2003-02-26 00:20:00 +00:00
|
|
|
float fHeight = SPACING_Y*MAX_ACTIVE_ITEMS_LINES * (bReverse ? 1 : -1 );
|
|
|
|
|
float fY = SCALE(i,0.f,MAX_ACTIVE_ITEMS_LINES,0.f,fHeight);
|
|
|
|
|
m_text[i].SetY( fY );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ActiveItemList::Update( float fDelta )
|
|
|
|
|
{
|
|
|
|
|
ActorFrame::Update( fDelta );
|
|
|
|
|
|
|
|
|
|
|
2003-04-07 03:25:44 +00:00
|
|
|
// refresh text only once every second
|
|
|
|
|
float fNowSeconds = RageTimer::GetTimeSinceStart();
|
|
|
|
|
float fLastSeconds = RageTimer::GetTimeSinceStart() - fDelta;
|
|
|
|
|
|
|
|
|
|
if( (int)fNowSeconds != (int)fLastSeconds )
|
2003-02-26 00:20:00 +00:00
|
|
|
{
|
2003-04-14 22:12:54 +00:00
|
|
|
GameState::Attack* sActiveAttacks = GAMESTATE->m_ActiveAttacks[m_PlayerNumber]; // NUM_INVENTORY_SLOTS
|
2003-04-07 03:25:44 +00:00
|
|
|
for( int s=0; s<NUM_INVENTORY_SLOTS; s++ )
|
2003-02-26 00:20:00 +00:00
|
|
|
{
|
2003-04-14 22:12:54 +00:00
|
|
|
GameState::Attack& a = sActiveAttacks[s];
|
2003-02-26 00:20:00 +00:00
|
|
|
|
2003-04-14 22:12:54 +00:00
|
|
|
CString sDisplayText = a.sModifier;
|
2003-04-07 03:25:44 +00:00
|
|
|
if( sDisplayText == "" )
|
|
|
|
|
m_text[s].SetText( "" );
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-04-14 22:12:54 +00:00
|
|
|
int iDisplaySecondsLeft = (int)(a.fSecsRemaining+1);
|
2003-04-07 03:25:44 +00:00
|
|
|
m_text[s].SetText( ssprintf("%s %02d:%02d", sDisplayText.GetString(), iDisplaySecondsLeft/60, iDisplaySecondsLeft%60) );
|
2003-02-26 00:20:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|