diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index d8e7b768c9..e80eddd88a 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -872,7 +872,6 @@ BannerOffCommand=hidden,1 [ScreenGameplay] ShowEvaluationOnFail=0 -PressBlockY=10 StaticBGY=240 StaticBGX=320 PrevScreenArcade=ScreenSelectMusic @@ -2918,8 +2917,8 @@ PulseZoom=1.2 TweenSeconds=0.05 [Player] -GrayArrowsYStandard=96 -GrayArrowsYReverse=384 +ReceptorArrowsYStandard=96 +ReceptorArrowsYReverse=384 JudgmentXOffsetOneSideP1=0 JudgmentXOffsetOneSideP2=0 JudgmentXOffsetBothSides=0 @@ -2965,10 +2964,6 @@ LabelX=0 LabelY=0 LabelOnCommand=horizalign,left -[GrayArrow] -StepZoom=0.75 -StepSeconds=0.10 - [CodeDetector] Easier1=Up,Up Easier2=MenuUp,MenuUp @@ -3620,7 +3615,7 @@ CharsZoomLarge=1.5 CharsSpacingY=40 ScrollingCharsColor=0.6,0.8,0.8,1 SelectedCharsColor=0.8,1,1,1 -GrayArrowsY=100 +ReceptorArrowsY=100 NumCharsToDrawBehind=2 NumCharsToDrawTotal=10 FakeBeatsPerSec=2.5 diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index bd0616cb1e..f9c10fe1f7 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -295,6 +295,7 @@ public: static float GetCommandLength( CString command ); virtual void SetState( int iNewState ) {}; + virtual void SetSecondsIntoAnimation( float fSeconds ) {}; virtual int GetNumStates() { return 1; }; protected: diff --git a/stepmania/src/ActorUtil.cpp b/stepmania/src/ActorUtil.cpp index 4834de5070..08eb59a0d4 100644 --- a/stepmania/src/ActorUtil.cpp +++ b/stepmania/src/ActorUtil.cpp @@ -37,9 +37,17 @@ static Actor* LoadActor( CString sPath ) CString sFileName; ini.GetValue( "Actor", "File", sFileName ); - CString sNewPath = Dirname( sPath ) + sFileName; + CString sDir = Dirname( sPath ); - sNewPath = DerefRedir( sNewPath ); + CStringArray asFiles; + GetDirListing( sDir + sFileName + "*", asFiles ); + + if( asFiles.empty() ) + RageException::Throw( "The actor file '%s' references a file '%s' which doesn't exist.", sPath.c_str(), sFileName.c_str() ); + else if( asFiles.size() > 1 ) + RageException::Throw( "The actor file '%s' references a file '%s' which has multiple matches.", sPath.c_str(), sFileName.c_str() ); + + CString sNewPath = DerefRedir( sDir + asFiles[0] ); /* XXX: How to handle translations? Maybe we should have one metrics section, * "Text", eg: @@ -71,9 +79,6 @@ static Actor* LoadActor( CString sPath ) } else { - if( !DoesFileExist(sNewPath) ) - RageException::Throw( "The actor file '%s' references a file '%s' which doesn't exist.", sPath.c_str(), sNewPath.c_str() ); - pActor = MakeActor( sNewPath ); } diff --git a/stepmania/src/GrayArrow.cpp b/stepmania/src/GrayArrow.cpp deleted file mode 100644 index e742b2d304..0000000000 --- a/stepmania/src/GrayArrow.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#include "global.h" -/* ------------------------------------------------------------------------------ - Class: GrayArrow - - Desc: A gray arrow that "receives" ColorNotes. - - Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. - Ben Nordstrom - Chris Danford ------------------------------------------------------------------------------ -*/ - -#include "GrayArrow.h" -#include "PrefsManager.h" -#include "GameState.h" -#include -#include "ThemeManager.h" -#include "NoteFieldPositioning.h" -#include "NoteSkinManager.h" - -#include "RageLog.h" - -CachedThemeMetricF GR_STEP_SECONDS ("GrayArrow","StepSeconds"); -CachedThemeMetricF GR_STEP_ZOOM ("GrayArrow","StepZoom"); - - -GrayArrow::GrayArrow() -{ - GR_STEP_SECONDS.Refresh(); - GR_STEP_ZOOM.Refresh(); - m_bIsPressed = false; - StopAnimating(); -} - -bool GrayArrow::Load( CString NoteSkin, PlayerNumber pn, int iColNo ) -{ - CString Button = g_NoteFieldMode[pn].GrayButtonNames[iColNo]; - if( Button == "" ) - Button = NoteSkinManager::ColToButtonName( iColNo ); - - CString sPath = NOTESKIN->GetPathTo( NoteSkin, Button, "receptor" ); - 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 -} - -void GrayArrow::Update( float fDeltaTime ) -{ - ASSERT( Sprite::GetNumStates() > 0 ); // you forgot to call Load() - - Sprite::Update( fDeltaTime ); - - /* XXX: get rid of this once we update the note skins */ - int IdleState = (GetNumStates() == 3)? 0: 1; - int OnState = (GetNumStates() == 3)? 1: 0; - int OffState = (GetNumStates() == 3)? 2: 1; - - if( !GAMESTATE->m_bPastHereWeGo ) - { - SetState( IdleState ); - return; - } - - /* These could be metrics or configurable. I'd prefer the flash to - * start on the beat, I think ... -glenn */ - - /* Start flashing 10% of a beat before the beat starts. */ - const float flash_offset = -0.1f; - - /* Flash for 20% of a beat. */ - const float flash_length = 0.2f; - - float cur_beat = GAMESTATE->m_fSongBeat; - - /* Beats can start in very negative territory (many BMR songs, Drop Out - * -Remix-). */ - cur_beat += 100.0f; - - cur_beat -= flash_offset; - float fPercentIntoBeat = fmodf(cur_beat, 1); - SetState( (fPercentIntoBeatdisplay[c].Load( c, m_PlayerNumber, skin, m_fYReverseOffsetPixels ); - nd->m_GrayArrowRow.Load( m_PlayerNumber, skin, m_fYReverseOffsetPixels ); + nd->m_ReceptorArrowRow.Load( m_PlayerNumber, skin, m_fYReverseOffsetPixels ); nd->m_GhostArrowRow.Load( m_PlayerNumber, skin, m_fYReverseOffsetPixels ); m_NoteDisplays[ skin ] = nd; @@ -156,13 +156,13 @@ void NoteField::Update( float fDeltaTime ) if( LastDisplay ) { cur->m_GhostArrowRow.CopyTweening( LastDisplay->m_GhostArrowRow ); - cur->m_GrayArrowRow.CopyTweening( LastDisplay->m_GrayArrowRow ); + cur->m_ReceptorArrowRow.CopyTweening( LastDisplay->m_ReceptorArrowRow ); } LastDisplay = cur; } - cur->m_GrayArrowRow.Update( fDeltaTime ); + cur->m_ReceptorArrowRow.Update( fDeltaTime ); cur->m_GhostArrowRow.Update( fDeltaTime ); if( m_fPercentFadeToFail >= 0 ) @@ -392,7 +392,7 @@ void NoteField::DrawPrimitives() ASSERT( !m_BeatToNoteDisplays.empty() ); NoteDisplayCols *cur = SearchForSongBeat(); - cur->m_GrayArrowRow.Draw(); + cur->m_ReceptorArrowRow.Draw(); // // Adjust draw range depending on some effects @@ -625,8 +625,8 @@ void NoteField::FadeToFail() // don't fade all over again if this is called twice } -void NoteField::Step( int iCol ) { SearchForSongBeat()->m_GrayArrowRow.Step( iCol ); } -void NoteField::UpdateBars( int iCol ) { SearchForSongBeat()->m_GrayArrowRow.UpdateBars( iCol ); } +void NoteField::Step( int iCol ) { SearchForSongBeat()->m_ReceptorArrowRow.Step( iCol ); } +void NoteField::SetPressed( int iCol ) { SearchForSongBeat()->m_ReceptorArrowRow.SetPressed( iCol ); } void NoteField::DidTapNote( int iCol, TapNoteScore score, bool bBright ) { SearchForSongBeat()->m_GhostArrowRow.DidTapNote( iCol, score, bBright ); } void NoteField::DidHoldNote( int iCol ) { SearchForSongBeat()->m_GhostArrowRow.DidHoldNote( iCol ); } void NoteField::DidTapMine( int iCol, TapNoteScore score ) { SearchForSongBeat()->m_GhostArrowRow.DidTapMine( iCol, score ); } diff --git a/stepmania/src/NoteField.h b/stepmania/src/NoteField.h index 9f4f03e480..1539e1b5b1 100644 --- a/stepmania/src/NoteField.h +++ b/stepmania/src/NoteField.h @@ -22,7 +22,7 @@ #include "NoteDataWithScoring.h" #include "NoteDisplay.h" #include "ArrowBackdrop.h" -#include "GrayArrowRow.h" +#include "ReceptorArrowRow.h" #include "GhostArrowRow.h" class Song; @@ -48,7 +48,7 @@ public: void CacheNoteSkin( CString skin ); void Step( int iCol ); - void UpdateBars( int iCol ); + void SetPressed( int iCol ); void DidTapNote( int iCol, TapNoteScore score, bool bBright ); void DidHoldNote( int iCol ); void DidTapMine( int iCol, TapNoteScore score ); @@ -76,7 +76,7 @@ protected: struct NoteDisplayCols { NoteDisplay display[MAX_NOTE_TRACKS]; - GrayArrowRow m_GrayArrowRow; + ReceptorArrowRow m_ReceptorArrowRow; GhostArrowRow m_GhostArrowRow; }; diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index e988454f35..45c9334564 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -35,8 +35,8 @@ #include "ScreenGameplay.h" /* for SM_ComboStopped */ #include "ScreenManager.h" -CachedThemeMetricF GRAY_ARROWS_Y_STANDARD ("Player","GrayArrowsYStandard"); -CachedThemeMetricF GRAY_ARROWS_Y_REVERSE ("Player","GrayArrowsYReverse"); +CachedThemeMetricF GRAY_ARROWS_Y_STANDARD ("Player","ReceptorArrowsYStandard"); +CachedThemeMetricF GRAY_ARROWS_Y_REVERSE ("Player","ReceptorArrowsYReverse"); #define JUDGMENT_X( p, both_sides ) THEME->GetMetricF("Player",both_sides ? "JudgmentXOffsetBothSides" : ssprintf("JudgmentXOffsetOneSideP%d",p+1)) #define JUDGMENT_Y THEME->GetMetricF("Player","JudgmentY") #define JUDGMENT_Y_REVERSE THEME->GetMetricF("Player","JudgmentYReverse") @@ -265,6 +265,9 @@ void PlayerMinus::Update( float fDeltaTime ) // UpdateTapNotesMissedOlderThan( GetMaxStepDistanceSeconds() ); + // + // update pressed flag + // int iNumCols = GAMESTATE->GetCurrentStyleDef()->m_iColsPerPlayer; for( int bar=0; bar < iNumCols; bar++ ) { @@ -272,7 +275,7 @@ void PlayerMinus::Update( float fDeltaTime ) const GameInput GameI = GAMESTATE->GetCurrentStyleDef()->StyleInputToGameInput( StyleI ); bool bIsHoldingButton = INPUTMAPPER->IsButtonDown( GameI ); if(bIsHoldingButton && !GAMESTATE->m_bDemonstrationOrJukebox) - m_pNoteField->UpdateBars(bar); + m_pNoteField->SetPressed(bar); } // @@ -567,7 +570,7 @@ void PlayerMinus::Step( int col, RageTimer tm ) //LOG->Trace( "iIndexStartLookingAt = %d, iNumElementsToExamine = %d", iIndexStartLookingAt, iNumElementsToExamine ); - bool bGrayArrowStep = true; + bool bReceptorArrowStep = true; if( iIndexOverlappingNote != -1 ) { @@ -816,7 +819,7 @@ void PlayerMinus::Step( int col, RageTimer tm ) if( score==TNS_MARVELOUS && !GAMESTATE->ShowMarvelous()) score = TNS_PERFECT; - bGrayArrowStep = score < TNS_GOOD; + bReceptorArrowStep = score < TNS_GOOD; // LOG->Trace("Note offset: %f (fSecondsFromPerfect = %f), Score: %i", fNoteOffset, fSecondsFromPerfect, score); @@ -856,7 +859,7 @@ void PlayerMinus::Step( int col, RageTimer tm ) - if( bGrayArrowStep ) + if( bReceptorArrowStep ) m_pNoteField->Step( col ); } diff --git a/stepmania/src/RageUtil.h b/stepmania/src/RageUtil.h index f67a7cae92..e9dc913269 100644 --- a/stepmania/src/RageUtil.h +++ b/stepmania/src/RageUtil.h @@ -65,6 +65,14 @@ inline void wrap( int &x, int n) x %= n; } +inline void wrap( float &x, float n) +{ + if (x<0) + x += ((-x/n)+1)*n; + + x = fmodf(x,n); +} + //----------------------------------------------------------------------------- diff --git a/stepmania/src/ReceptorArrow.cpp b/stepmania/src/ReceptorArrow.cpp new file mode 100644 index 0000000000..bb01cd075d --- /dev/null +++ b/stepmania/src/ReceptorArrow.cpp @@ -0,0 +1,84 @@ +#include "global.h" +/* +----------------------------------------------------------------------------- + Class: ReceptorArrow + + Desc: See header. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Ben Nordstrom + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "ReceptorArrow.h" +#include "PrefsManager.h" +#include "GameState.h" +#include +#include "ThemeManager.h" +#include "NoteFieldPositioning.h" +#include "NoteSkinManager.h" +#include "RageLog.h" +#include "RageUtil.h" + + +ReceptorArrow::ReceptorArrow() +{ + m_bIsPressed = false; + StopAnimating(); +} + +bool ReceptorArrow::Load( CString NoteSkin, PlayerNumber pn, int iColNo ) +{ + m_PlayerNumber = pn; + m_iColNo = iColNo; + + CString sButton = g_NoteFieldMode[pn].GrayButtonNames[iColNo]; + if( sButton == "" ) + sButton = NoteSkinManager::ColToButtonName( iColNo ); + + CString sPath; + m_pReceptorWaiting.Load( NOTESKIN->GetPathTo(NoteSkin,sButton,"receptor waiting") ); + m_pReceptorGo.Load( NOTESKIN->GetPathTo(NoteSkin,sButton,"receptor go") ); + m_sStepCommand = NOTESKIN->GetMetric(GAMESTATE->m_PlayerOptions[pn].m_sNoteSkin,"ReceptorArrow","StepCommand"); + + m_pPressBlock.Load( NOTESKIN->GetPathTo(NoteSkin,sButton,"KeypressBlock") ); + + this->AddChild( m_pReceptorWaiting ); + this->AddChild( m_pReceptorGo ); + this->AddChild( m_pPressBlock ); + + return true; +} + +void ReceptorArrow::Update( float fDeltaTime ) +{ + ActorFrame::Update( fDeltaTime ); + + float fPercentIntoBeat = GAMESTATE->m_fSongBeat; + wrap(fPercentIntoBeat, 1); /* Beats can start in very negative territory */ + + // TODO: Generalize this to allow any actor to animate based on the beat. + m_pReceptorWaiting->SetSecondsIntoAnimation( fPercentIntoBeat ); + m_pReceptorGo->SetSecondsIntoAnimation( fPercentIntoBeat ); + m_pPressBlock->SetSecondsIntoAnimation( fPercentIntoBeat ); + + // update pressblock alignment based on scroll direction + bool bReverse = GAMESTATE->m_PlayerOptions[m_PlayerNumber].GetReversePercentForColumn(m_iColNo) > 0.5; + m_pPressBlock->SetVertAlign( bReverse ? Actor::align_bottom : Actor::align_top ); +} + +void ReceptorArrow::Draw() +{ + m_pReceptorGo->SetHidden( !GAMESTATE->m_bPastHereWeGo ); + m_pReceptorWaiting->SetHidden( GAMESTATE->m_bPastHereWeGo ); + m_pPressBlock->SetHidden( !m_bIsPressed ); + + ActorFrame::Draw(); +} + +void ReceptorArrow::Step() +{ + m_pReceptorGo->Command( m_sStepCommand ); + m_pReceptorWaiting->Command( m_sStepCommand ); +} diff --git a/stepmania/src/ReceptorArrow.h b/stepmania/src/ReceptorArrow.h new file mode 100644 index 0000000000..7b781048b6 --- /dev/null +++ b/stepmania/src/ReceptorArrow.h @@ -0,0 +1,43 @@ +#ifndef ReceptorArrow_H +#define ReceptorArrow_H +/* +----------------------------------------------------------------------------- + Class: ReceptorArrow + + Desc: A gray arrow that "receives" the colorful note arrows. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Ben Nordstrom + Chris Danford +----------------------------------------------------------------------------- +*/ + + +#include "ActorFrame.h" +#include "ActorUtil.h" +#include "PlayerNumber.h" + +class ReceptorArrow : public ActorFrame +{ +public: + ReceptorArrow(); + bool Load( CString NoteSkin, PlayerNumber pn, int iColNo ); + + virtual void Draw(); + virtual void Update( float fDeltaTime ); + void Step(); + void SetPressed() { m_bIsPressed = true; }; +private: + + PlayerNumber m_PlayerNumber; + int m_iColNo; + + AutoActor m_pReceptorWaiting; + AutoActor m_pReceptorGo; + CString m_sStepCommand; + + AutoActor m_pPressBlock; + bool m_bIsPressed; +}; + +#endif diff --git a/stepmania/src/GrayArrowRow.cpp b/stepmania/src/ReceptorArrowRow.cpp similarity index 59% rename from stepmania/src/GrayArrowRow.cpp rename to stepmania/src/ReceptorArrowRow.cpp index 7d64d07541..dea467111e 100644 --- a/stepmania/src/GrayArrowRow.cpp +++ b/stepmania/src/ReceptorArrowRow.cpp @@ -1,7 +1,7 @@ #include "global.h" /* ----------------------------------------------------------------------------- - Class: GrayArrowRow + Class: ReceptorArrowRow Desc: See header. @@ -10,7 +10,7 @@ ----------------------------------------------------------------------------- */ -#include "GrayArrowRow.h" +#include "ReceptorArrowRow.h" #include "RageUtil.h" #include "GameConstantsAndTypes.h" #include "PrefsManager.h" @@ -20,12 +20,12 @@ #include "NoteFieldPositioning.h" -GrayArrowRow::GrayArrowRow() +ReceptorArrowRow::ReceptorArrowRow() { m_iNumCols = 0; } -void GrayArrowRow::Load( PlayerNumber pn, CString NoteSkin, float fYReverseOffset ) +void ReceptorArrowRow::Load( PlayerNumber pn, CString NoteSkin, float fYReverseOffset ) { m_PlayerNumber = pn; m_fYReverseOffsetPixels = fYReverseOffset; @@ -35,51 +35,51 @@ void GrayArrowRow::Load( PlayerNumber pn, CString NoteSkin, float fYReverseOffse m_iNumCols = pStyleDef->m_iColsPerPlayer; for( int c=0; cm_CurrentPlayerOptions[m_PlayerNumber].m_fDark) ); + m_ReceptorArrow[c].Update( fDeltaTime ); + m_ReceptorArrow[c].SetDiffuse( RageColor(1,1,1,1 - GAMESTATE->m_CurrentPlayerOptions[m_PlayerNumber].m_fDark) ); // set arrow XYZ const float fX = ArrowGetXPos( m_PlayerNumber, c, 0 ); const float fY = ArrowGetYPos( m_PlayerNumber, c, 0, m_fYReverseOffsetPixels ); const float fZ = ArrowGetZPos( m_PlayerNumber, c, 0 ); - m_GrayArrow[c].SetX( fX ); - m_GrayArrow[c].SetY( fY ); - m_GrayArrow[c].SetZ( fZ ); + m_ReceptorArrow[c].SetX( fX ); + m_ReceptorArrow[c].SetY( fY ); + m_ReceptorArrow[c].SetZ( fZ ); } } -void GrayArrowRow::DrawPrimitives() +void ReceptorArrowRow::DrawPrimitives() { for( int c=0; c= 0 && iCol < m_iNumCols ); - m_GrayArrow[iCol].Step(); + m_ReceptorArrow[iCol].Step(); } -void GrayArrowRow::UpdateBars( int iCol ) +void ReceptorArrowRow::SetPressed( int iCol ) { ASSERT( iCol >= 0 && iCol < m_iNumCols ); - m_GrayArrow[iCol].UpdateBars(); + m_ReceptorArrow[iCol].SetPressed(); } -void GrayArrowRow::CopyTweening( const GrayArrowRow &from ) +void ReceptorArrowRow::CopyTweening( const ReceptorArrowRow &from ) { for( int c=0; cGetMetricF("ScreenNameEntry","CharsSpacingY") #define SCROLLING_CHARS_COLOR THEME->GetMetricC("ScreenNameEntry","ScrollingCharsColor") #define SELECTED_CHARS_COLOR THEME->GetMetricC("ScreenNameEntry","SelectedCharsColor") -#define GRAY_ARROWS_Y THEME->GetMetricF("ScreenNameEntry","GrayArrowsY") +#define GRAY_ARROWS_Y THEME->GetMetricF("ScreenNameEntry","ReceptorArrowsY") #define NUM_CHARS_TO_DRAW_BEHIND THEME->GetMetricI("ScreenNameEntry","NumCharsToDrawBehind") #define NUM_CHARS_TO_DRAW_TOTAL THEME->GetMetricI("ScreenNameEntry","NumCharsToDrawTotal") #define FAKE_BEATS_PER_SEC THEME->GetMetricF("ScreenNameEntry","FakeBeatsPerSec") @@ -55,7 +55,7 @@ float g_fCharsZoomLarge; float g_fCharsSpacingY; RageColor g_ScrollingCharsColor; RageColor g_SelectedCharsColor; -float g_fGrayArrowsY; +float g_fReceptorArrowsY; int g_iNumCharsToDrawBehind; int g_iNumCharsToDrawTotal; float g_fFakeBeatsPerSec; @@ -104,7 +104,7 @@ ScreenNameEntry::ScreenNameEntry( CString sClassName ) : Screen( sClassName ) g_fCharsSpacingY = CHARS_SPACING_Y; g_ScrollingCharsColor = SCROLLING_CHARS_COLOR; g_SelectedCharsColor = SELECTED_CHARS_COLOR; - g_fGrayArrowsY = GRAY_ARROWS_Y; + g_fReceptorArrowsY = GRAY_ARROWS_Y; g_iNumCharsToDrawBehind = NUM_CHARS_TO_DRAW_BEHIND; g_iNumCharsToDrawTotal = NUM_CHARS_TO_DRAW_TOTAL; g_fFakeBeatsPerSec = FAKE_BEATS_PER_SEC; @@ -191,10 +191,10 @@ ScreenNameEntry::ScreenNameEntry( CString sClassName ) : Screen( sClassName ) /* Ensure that this is up-to-date. */ GAMESTATE->m_pPosition->Load( (PlayerNumber)p ); - m_GrayArrowRow[p].Load( (PlayerNumber)p, GAMESTATE->m_PlayerOptions[p].m_sNoteSkin, 0 ); - m_GrayArrowRow[p].SetX( (float)GAMESTATE->GetCurrentStyleDef()->m_iCenterX[p] ); - m_GrayArrowRow[p].SetY( SCREEN_TOP + 100 ); - this->AddChild( &m_GrayArrowRow[p] ); + m_ReceptorArrowRow[p].Load( (PlayerNumber)p, GAMESTATE->m_PlayerOptions[p].m_sNoteSkin, 0 ); + m_ReceptorArrowRow[p].SetX( (float)GAMESTATE->GetCurrentStyleDef()->m_iCenterX[p] ); + m_ReceptorArrowRow[p].SetY( SCREEN_TOP + 100 ); + this->AddChild( &m_ReceptorArrowRow[p] ); const StyleDef* pStyleDef = GAMESTATE->GetCurrentStyleDef(); @@ -368,7 +368,7 @@ void ScreenNameEntry::Input( const DeviceInput& DeviceI, const InputEventType ty int StringIndex = m_ColToStringIndex[StyleI.player][StyleI.col]; if(StringIndex != -1) { - m_GrayArrowRow[StyleI.player].Step( StyleI.col ); + m_ReceptorArrowRow[StyleI.player].Step( StyleI.col ); m_soundStep.Play(); char c = NAME_CHARS[GetClosestCharIndex(m_fFakeBeat)]; m_textSelectedChars[StyleI.player][StyleI.col].SetText( ssprintf("%c",c) ); diff --git a/stepmania/src/ScreenNameEntry.h b/stepmania/src/ScreenNameEntry.h index dfeaa116ea..04ae874682 100644 --- a/stepmania/src/ScreenNameEntry.h +++ b/stepmania/src/ScreenNameEntry.h @@ -13,7 +13,7 @@ #include "BitmapText.h" #include "Transition.h" #include "RandomSample.h" -#include "GrayArrowRow.h" +#include "ReceptorArrowRow.h" #include "BGAnimation.h" #include "MenuTimer.h" @@ -37,7 +37,7 @@ private: BGAnimation m_Background; - GrayArrowRow m_GrayArrowRow[NUM_PLAYERS]; + ReceptorArrowRow m_ReceptorArrowRow[NUM_PLAYERS]; BitmapText m_textSelectedChars[NUM_PLAYERS][ABS_MAX_RANKING_NAME_LENGTH]; BitmapText m_textScrollingChars[NUM_PLAYERS][ABS_MAX_RANKING_NAME_LENGTH]; BitmapText m_textCategory[NUM_PLAYERS]; diff --git a/stepmania/src/Sprite.cpp b/stepmania/src/Sprite.cpp index 5052c4c5d5..b19b2ce34c 100644 --- a/stepmania/src/Sprite.cpp +++ b/stepmania/src/Sprite.cpp @@ -24,6 +24,7 @@ #include "GameConstantsAndTypes.h" #include "SDL_utils.h" #include "ActorUtil.h" +#include "arch/ArchHooks/ArchHooks.h" Sprite::Sprite() { @@ -81,6 +82,8 @@ bool Sprite::LoadFromSpriteFile( RageTextureID ID ) { LOG->Trace( ssprintf("Sprite::LoadFromSpriteFile(%s)", ID.filename.c_str()) ); +retry: + //Init(); m_sSpritePath = ID.filename; @@ -102,7 +105,20 @@ bool Sprite::LoadFromSpriteFile( RageTextureID ID ) vector asElementPaths; GetDirListing( ID.filename + "*", asElementPaths, false, true ); if(asElementPaths.size() == 0) - RageException::Throw( "The sprite file '%s' points to a texture '%s' which doesn't exist.", m_sSpritePath.c_str(), ID.filename.c_str() ); + { + CString sMessage = ssprintf( "The sprite file '%s' points to a texture '%s' which doesn't exist.", m_sSpritePath.c_str(), ID.filename.c_str() ); + switch( HOOKS->MessageBoxAbortRetryIgnore(sMessage) ) + { + case ArchHooks::abort: + RageException::Throw( "Error reading value 'Texture' from %s.", m_sSpritePath.c_str() ); + case ArchHooks::retry: + goto retry; + case ArchHooks::ignore: + return false; + default: + ASSERT(0); + } + } if(asElementPaths.size() > 1) { CString message = ssprintf( @@ -206,6 +222,20 @@ bool Sprite::LoadFromTexture( RageTextureID ID ) } +void Sprite::UpdateAnimationState() +{ + // Don't bother with state switching logic if there's only one state. + // We already know what's going to show. + if( m_States.size() > 1 ) + { + while( m_fSecsIntoState > m_States[m_iCurState].fDelay ) // it's time to switch frames + { + // increment frame and reset the counter + m_fSecsIntoState -= m_States[m_iCurState].fDelay; // leave the left over time for the next frame + m_iCurState = (m_iCurState+1) % m_States.size(); + } + } +} void Sprite::Update( float fDelta ) { @@ -217,17 +247,8 @@ void Sprite::Update( float fDelta ) if( !m_pTexture ) // no texture, nothing to animate return; - // - // update animation frame - // m_fSecsIntoState += fDelta; - - while( m_fSecsIntoState > m_States[m_iCurState].fDelay ) // it's time to switch frames - { - // increment frame and reset the counter - m_fSecsIntoState -= m_States[m_iCurState].fDelay; // leave the left over time for the next frame - m_iCurState = (m_iCurState+1) % m_States.size(); - } + UpdateAnimationState(); // // update scrolling @@ -566,6 +587,13 @@ void Sprite::SetState( int iNewState ) m_fSecsIntoState = 0.0; } +void Sprite::SetSecondsIntoAnimation( float fSeconds ) +{ + SetState( 0 ); // rewind to the first state + m_fSecsIntoState = fSeconds; + UpdateAnimationState(); +} + CString Sprite::GetTexturePath() const { if( m_pTexture==NULL ) diff --git a/stepmania/src/Sprite.h b/stepmania/src/Sprite.h index f29182093d..513d750d83 100644 --- a/stepmania/src/Sprite.h +++ b/stepmania/src/Sprite.h @@ -26,6 +26,7 @@ public: virtual void DrawPrimitives(); virtual void Update( float fDeltaTime ); + void UpdateAnimationState(); // take m_fSecondsIntoState, and move to a new state /* Just a convenience function; load an image that'll be used in the * background. */ @@ -37,6 +38,7 @@ public: virtual void EnableAnimation( bool bEnable ); virtual void SetState( int iNewState ); + virtual void SetSecondsIntoAnimation( float fSeconds ); virtual int GetNumStates() { return m_States.size(); }; CString GetTexturePath() const; diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index 9683e4b16e..03c4dd5acd 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -58,14 +58,14 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 $(intdir)\verstub.obj kernel32.lib shell32.lib user32.lib gdi32.lib advapi32.lib winmm.lib /nologo /subsystem:windows /pdb:"../debug6/StepMania-debug.pdb" /map /debug /machine:I386 /nodefaultlib:"libcmtd.lib" /out:"../StepMania-debug.exe" # SUBTRACT BASE LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib -# ADD LINK32 $(intdir)\verstub.obj kernel32.lib gdi32.lib shell32.lib user32.lib advapi32.lib winmm.lib /nologo /subsystem:windows /map /debug /machine:I386 /nodefaultlib:"libcmtd.lib" /out:"../Program/StepMania-debug.exe" +# ADD LINK32 $(intdir)\verstub.obj kernel32.lib gdi32.lib shell32.lib user32.lib advapi32.lib winmm.lib /nologo /subsystem:windows /map /debug /machine:I386 /nodefaultlib:"libcmtd.lib" /out:"../../itg/Program/StepMania-debug.exe" # SUBTRACT LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib # Begin Special Build Tool IntDir=.\../Debug6 -TargetDir=\stepmania\stepmania\Program +TargetDir=\stepmania\itg\Program TargetName=StepMania-debug SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi # End Special Build Tool @@ -102,8 +102,8 @@ IntDir=.\Debug TargetDir=\stepmania\stepmania TargetName=default SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp \ - /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp \ + /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool @@ -143,7 +143,7 @@ IntDir=.\../Release6 TargetDir=\stepmania\stepmania\Program TargetName=StepMania SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi # End Special Build Tool @@ -184,8 +184,8 @@ IntDir=.\StepMania___Xbox_Release TargetDir=\stepmania\stepmania TargetName=default SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp \ - /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp \ + /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool @@ -3277,44 +3277,6 @@ SOURCE=.\GhostArrowRow.h # End Source File # Begin Source File -SOURCE=.\GrayArrow.cpp - -!IF "$(CFG)" == "StepMania - Win32 Debug" - -!ELSEIF "$(CFG)" == "StepMania - Xbox Debug" - -!ELSEIF "$(CFG)" == "StepMania - Win32 Release" - -!ELSEIF "$(CFG)" == "StepMania - Xbox Release" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\GrayArrow.h -# End Source File -# Begin Source File - -SOURCE=.\GrayArrowRow.cpp - -!IF "$(CFG)" == "StepMania - Win32 Debug" - -!ELSEIF "$(CFG)" == "StepMania - Xbox Debug" - -!ELSEIF "$(CFG)" == "StepMania - Win32 Release" - -!ELSEIF "$(CFG)" == "StepMania - Xbox Release" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\GrayArrowRow.h -# End Source File -# Begin Source File - SOURCE=.\HoldGhostArrow.cpp !IF "$(CFG)" == "StepMania - Win32 Debug" @@ -3547,6 +3509,44 @@ SOURCE=.\ProTimingDisplay.h # End Source File # Begin Source File +SOURCE=.\ReceptorArrow.cpp + +!IF "$(CFG)" == "StepMania - Win32 Debug" + +!ELSEIF "$(CFG)" == "StepMania - Xbox Debug" + +!ELSEIF "$(CFG)" == "StepMania - Win32 Release" + +!ELSEIF "$(CFG)" == "StepMania - Xbox Release" + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\ReceptorArrow.h +# End Source File +# Begin Source File + +SOURCE=.\ReceptorArrowRow.cpp + +!IF "$(CFG)" == "StepMania - Win32 Debug" + +!ELSEIF "$(CFG)" == "StepMania - Xbox Debug" + +!ELSEIF "$(CFG)" == "StepMania - Win32 Release" + +!ELSEIF "$(CFG)" == "StepMania - Xbox Release" + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\ReceptorArrowRow.h +# End Source File +# Begin Source File + SOURCE=.\ScoreDisplay.cpp !IF "$(CFG)" == "StepMania - Win32 Debug" diff --git a/stepmania/src/StepMania.vcproj b/stepmania/src/StepMania.vcproj index 1c69d5cc35..c9dc785496 100644 --- a/stepmania/src/StepMania.vcproj +++ b/stepmania/src/StepMania.vcproj @@ -1416,16 +1416,16 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\ RelativePath="GhostArrowRow.h"> + RelativePath=".\ReceptorArrow.cpp"> + RelativePath=".\ReceptorArrow.h"> + RelativePath="ReceptorArrowRow.cpp"> + RelativePath="ReceptorArrowRow.h">