Files
itgmania212121/stepmania/src/GrayArrow.cpp
T

111 lines
2.7 KiB
C++
Raw Normal View History

2003-02-16 04:01:45 +00:00
#include "global.h"
2002-02-28 19:40:40 +00:00
/*
-----------------------------------------------------------------------------
Class: GrayArrow
2002-04-28 20:42:32 +00:00
Desc: A gray arrow that "receives" ColorNotes.
2002-02-28 19:40:40 +00:00
2002-05-19 01:59:48 +00:00
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
2002-02-28 19:40:40 +00:00
Ben Nordstrom
Chris Danford
-----------------------------------------------------------------------------
*/
2001-12-01 23:46:09 +00:00
#include "GrayArrow.h"
2002-07-23 01:41:40 +00:00
#include "PrefsManager.h"
2002-07-28 20:28:37 +00:00
#include "GameState.h"
#include <math.h>
#include "ThemeManager.h"
2003-09-12 06:37:10 +00:00
#include "NoteFieldPositioning.h"
#include "NoteSkinManager.h"
2001-12-01 23:46:09 +00:00
2002-12-29 23:38:56 +00:00
#include "RageLog.h"
2002-07-28 20:28:37 +00:00
CachedThemeMetricF GR_STEP_SECONDS ("GrayArrow","StepSeconds");
CachedThemeMetricF GR_STEP_ZOOM ("GrayArrow","StepZoom");
2001-12-01 23:46:09 +00:00
GrayArrow::GrayArrow()
{
GR_STEP_SECONDS.Refresh();
GR_STEP_ZOOM.Refresh();
m_bIsPressed = false;
2001-12-01 23:46:09 +00:00
StopAnimating();
}
2003-09-15 08:26:31 +00:00
bool GrayArrow::Load( CString NoteSkin, PlayerNumber pn, int iColNo )
2003-09-12 06:37:10 +00:00
{
CString Button = g_NoteFieldMode[pn].GrayButtonNames[iColNo];
if( Button == "" )
Button = NoteSkinManager::ColToButtonName( iColNo );
2003-09-15 08:26:31 +00:00
CString sPath = NOTESKIN->GetPathTo( NoteSkin, Button, "receptor" );
2003-09-12 06:37:10 +00:00
bool ret = Sprite::Load( sPath );
// XXX
if( GetNumStates() != 2 &&
GetNumStates() != 3 )
RageException::Throw( "'%s' must have 2 or 3 frames", sPath.c_str() );
sPath = NOTESKIN->GetPathTo( NoteSkin, Button, "KeypressBlock" );
bool ret2 = m_sprPressBlock.Load( sPath );
m_sprPressBlock.SetXY(0, THEME->GetMetricF("ScreenGameplay","PressBlockY"));
return ret && ret2; // return both loaded or fail
2003-09-12 06:37:10 +00:00
}
2002-07-28 20:28:37 +00:00
void GrayArrow::Update( float fDeltaTime )
2001-12-01 23:46:09 +00:00
{
2002-08-28 22:42:40 +00:00
ASSERT( Sprite::GetNumStates() > 0 ); // you forgot to call Load()
2002-07-28 20:28:37 +00:00
Sprite::Update( fDeltaTime );
2003-01-26 04:23:01 +00:00
/* XXX: get rid of this once we update the note skins */
int IdleState = (GetNumStates() == 3)? 0: 1;
2003-01-26 04:58:49 +00:00
int OnState = (GetNumStates() == 3)? 1: 0;
int OffState = (GetNumStates() == 3)? 2: 1;
2003-01-26 04:23:01 +00:00
if( !GAMESTATE->m_bPastHereWeGo )
2003-01-25 11:05:12 +00:00
{
2003-01-26 04:23:01 +00:00
SetState( IdleState );
2003-01-26 02:21:47 +00:00
return;
2003-01-25 11:05:12 +00:00
}
2002-12-29 23:38:56 +00:00
2003-01-26 02:21:47 +00:00
/* These could be metrics or configurable. I'd prefer the flash to
2003-01-26 04:23:01 +00:00
* start on the beat, I think ... -glenn */
2002-12-29 23:38:56 +00:00
2003-01-26 02:21:47 +00:00
/* Start flashing 10% of a beat before the beat starts. */
const float flash_offset = -0.1f;
2002-12-29 23:38:56 +00:00
2003-01-26 02:21:47 +00:00
/* Flash for 20% of a beat. */
const float flash_length = 0.2f;
2002-12-29 23:38:56 +00:00
2003-01-26 02:21:47 +00:00
float cur_beat = GAMESTATE->m_fSongBeat;
2002-12-29 23:38:56 +00:00
2003-01-26 02:21:47 +00:00
/* Beats can start in very negative territory (many BMR songs, Drop Out
2003-01-26 04:23:01 +00:00
* -Remix-). */
2003-01-26 02:21:47 +00:00
cur_beat += 100.0f;
cur_beat -= flash_offset;
float fPercentIntoBeat = fmodf(cur_beat, 1);
2003-01-26 04:58:49 +00:00
SetState( (fPercentIntoBeat<flash_length)? OnState : OffState );
m_sprPressBlock.Update(fDeltaTime);
}
void GrayArrow::Draw()
{
Sprite::Draw();
if(m_bIsPressed)
{
m_sprPressBlock.Draw();
m_bIsPressed = false;
}
2001-12-01 23:46:09 +00:00
}
2002-02-24 01:43:11 +00:00
void GrayArrow::Step()
2001-12-01 23:46:09 +00:00
{
SetZoom( GR_STEP_ZOOM );
StopTweening();
BeginTweening( GR_STEP_SECONDS );
2003-04-12 06:16:12 +00:00
SetZoom( 1 );
2001-12-01 23:46:09 +00:00
}