From 7f582052423b972d1dc39806b72139d0fa0f77d3 Mon Sep 17 00:00:00 2001 From: Thad Ward Date: Sun, 31 Aug 2003 07:28:19 +0000 Subject: [PATCH] BeginnerHelper fixes: change IsPlayerEnabled() to IsHumanPlayer() check to see if we can use the BeginnerHelper before attempting to use it. Disable BeginnerHelper for non-Dance game types. --- stepmania/src/Background.cpp | 10 +++----- stepmania/src/BeginnerHelper.cpp | 44 ++++++++++++++++++++++---------- stepmania/src/BeginnerHelper.h | 4 ++- stepmania/src/ScreenGameplay.cpp | 16 +++++------- 4 files changed, 44 insertions(+), 30 deletions(-) diff --git a/stepmania/src/Background.cpp b/stepmania/src/Background.cpp index ac2e5cfd50..fe9ac10137 100644 --- a/stepmania/src/Background.cpp +++ b/stepmania/src/Background.cpp @@ -26,6 +26,7 @@ #include // for fmodf #include "DancingCharacters.h" #include "arch/arch.h" +#include "BeginnerHelper.h" const float FADE_SECONDS = 1.0f; @@ -68,16 +69,11 @@ Background::Background() bool bOneOrMoreChars = false; bool bShowingBeginnerHelper = false; for( int p=0; pIsPlayerEnabled(p) ) + if( GAMESTATE->IsHumanPlayer(p) ) { bOneOrMoreChars = true; - - // if playing dance magic mode vs. the CPU, skip next condition - if (GAMESTATE->m_PlayMode == PLAY_MODE_RAVE) - continue; - //Disable dancing characters if BH will be showing. - if( (PREFSMAN->m_bShowBeginnerHelper) || (GAMESTATE->m_pCurNotes[p]->GetDifficulty() == DIFFICULTY_BEGINNER ) ) + if( (PREFSMAN->m_bShowBeginnerHelper) && BeginnerHelper::CanUse() && (GAMESTATE->m_pCurNotes[p]->GetDifficulty() == DIFFICULTY_BEGINNER ) ) bShowingBeginnerHelper = true; } diff --git a/stepmania/src/BeginnerHelper.cpp b/stepmania/src/BeginnerHelper.cpp index e9e6c3607b..b9f7dd5ee0 100644 --- a/stepmania/src/BeginnerHelper.cpp +++ b/stepmania/src/BeginnerHelper.cpp @@ -77,10 +77,20 @@ void BeginnerHelper::AddPlayer( int pn, NoteData *pNotes ) m_NoteData[pn].CopyAll( pNotes ); } -void BeginnerHelper::Initialize( int iDancePadType ) +bool BeginnerHelper::CanUse() +{ + return ((GAMESTATE->m_CurGame == GAME_DANCE) && + (DoesFileExist("Characters" SLASH "DancePad-DDR.txt")) && + (DoesFileExist("Characters" SLASH "DancePads-DDR.txt")) ); +} + +bool BeginnerHelper::Initialize( int iDancePadType ) { ASSERT( !m_bInitialized ); + if (!CanUse()) // if we can't be used, bail now. + return false; + // Load the StepCircle, Background, and flash animation m_sBackground.Load( THEME->GetPathToG("BeginnerHelper background") ); m_sBackground.SetXY( CENTER_X, CENTER_Y); @@ -97,21 +107,29 @@ void BeginnerHelper::Initialize( int iDancePadType ) }*/ // Load the DancePad + switch(iDancePadType) + { + case 0: break; // No pad + case 1: + if (!DoesFileExist("Characters" SLASH "DancePad-DDR.txt") ) + return false; // can't initialize without the required pad model. bail + m_mDancePad.LoadMilkshapeAscii( "Characters" SLASH "DancePad-DDR.txt" ); + break; + case 2: + if (!DoesFileExist("Characters" SLASH "DancePads-DDR.txt") ) + return false; // can't initialize without the required pad model. bail + m_mDancePad.LoadMilkshapeAscii( "Characters" SLASH "DancePads-DDR.txt" ); + break; + } m_mDancePad.SetHorizAlign( align_left ); m_mDancePad.SetRotationX( DANCEPAD_ANGLE ); m_mDancePad.SetX(HELPER_X); m_mDancePad.SetY(HELPER_Y); m_mDancePad.SetZoom( 23 ); // Pad should always be 3 units bigger in zoom than the dancer. - switch(iDancePadType) - { - case 0: break; // No pad - case 1:m_mDancePad.LoadMilkshapeAscii( "Characters" SLASH "DancePad-DDR.txt" ); break; - case 2:m_mDancePad.LoadMilkshapeAscii( "Characters" SLASH "DancePads-DDR.txt" ); break; - } for( int pl=0; plIsPlayerEnabled(pl)) + if( !GAMESTATE->IsHumanPlayer(pl)) continue; // if there is no character set, try loading a random one. @@ -144,7 +162,7 @@ void BeginnerHelper::Initialize( int iDancePadType ) } } - m_bInitialized = true; + return (m_bInitialized = true); } void BeginnerHelper::FlashOnce() @@ -178,7 +196,7 @@ void BeginnerHelper::DrawPrimitives() m_sStepCircle[scd].Draw(); // Should be drawn before the dancer, but after the pad, so it is drawn over the pad and under the dancer. for( int pn=0; pnIsPlayerEnabled(pn) ) + if( GAMESTATE->IsHumanPlayer(pn) ) m_mDancer[pn].Draw(); DISPLAY->SetLightOff( 0 ); @@ -189,7 +207,7 @@ void BeginnerHelper::Step( int pn, int CSTEP ) { LOG->Trace( "BeginnerHelper::Step()" ); // First make sure this player is on beginner mode and enabled... The difficulty check may be redundant, tho. - if( (GAMESTATE->IsPlayerEnabled(pn)) && (GAMESTATE->m_pCurNotes[pn]->GetDifficulty() == DIFFICULTY_BEGINNER) ) + if( (GAMESTATE->IsHumanPlayer(pn)) && (GAMESTATE->m_pCurNotes[pn]->GetDifficulty() == DIFFICULTY_BEGINNER) ) { ShowStepCircle( pn, CSTEP); m_mDancer[pn].StopTweening(); @@ -226,7 +244,7 @@ void BeginnerHelper::Update( float fDeltaTime ) for(int pn = 0; pn < NUM_PLAYERS; pn++ ) { - if( !( GAMESTATE->IsPlayerEnabled(pn) && GAMESTATE->m_pCurNotes[pn]->GetDifficulty() == DIFFICULTY_BEGINNER) ) + if( !( GAMESTATE->IsHumanPlayer(pn) && GAMESTATE->m_pCurNotes[pn]->GetDifficulty() == DIFFICULTY_BEGINNER) ) continue; // skip if( (m_NoteData[pn].IsThereATapAtRow( BeatToNoteRowNotRounded((GAMESTATE->m_fSongBeat+0.01f)) ) ) ) @@ -261,7 +279,7 @@ void BeginnerHelper::Update( float fDeltaTime ) for( int pu=0; puIsPlayerEnabled(pu)) + if(!GAMESTATE->IsHumanPlayer(pu)) continue; m_mDancer[pu].Update( beat ); //Update dancers diff --git a/stepmania/src/BeginnerHelper.h b/stepmania/src/BeginnerHelper.h index ab5971f5a6..76c1e71edc 100644 --- a/stepmania/src/BeginnerHelper.h +++ b/stepmania/src/BeginnerHelper.h @@ -27,7 +27,9 @@ public: ActorFrame m_afDancerSuite; // So we can easily rotate or whatever without disturbing the Background. void FlashOnce(); - void Initialize( int iDancePadType ); + bool Initialize( int iDancePadType ); + bool IsInitialized() { return m_bInitialized; } + static bool CanUse(); void AddPlayer( int pn, NoteData *pNotes ); void SetFlash(CString sFilename, float fX, float fY); void ShowStepCircle( int pn, int CSTEP ); diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 1bb3c12637..76314221ae 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -779,25 +779,23 @@ void ScreenGameplay::LoadNextSong() // Check to see if any players are in beginner mode. // Note: steps can be different if turn modifiers are used. - if( PREFSMAN->m_bShowBeginnerHelper ) + if( PREFSMAN->m_bShowBeginnerHelper && BeginnerHelper::CanUse()) { bool anybeginners = false; for( int pb=0; pbIsPlayerEnabled(pb) && GAMESTATE->m_pCurNotes[pb]->GetDifficulty() == DIFFICULTY_BEGINNER ) + if( GAMESTATE->IsHumanPlayer(pb) && GAMESTATE->m_pCurNotes[pb]->GetDifficulty() == DIFFICULTY_BEGINNER ) { anybeginners = true; m_BeginnerHelper.AddPlayer( pb, &m_Player[pb] ); } - if(anybeginners) + if(anybeginners && m_BeginnerHelper.Initialize( 2 )) // Init for doubles { - m_Background.Unload(); // BeginnerHelper has it's own BG control. - m_Background.StopAnimating(); - - m_BeginnerHelper.Initialize( 2 ); // Init for doubles - m_BeginnerHelper.SetX( CENTER_X ); - m_BeginnerHelper.SetY( CENTER_Y ); + m_Background.Unload(); // BeginnerHelper has it's own BG control. + m_Background.StopAnimating(); + m_BeginnerHelper.SetX( CENTER_X ); + m_BeginnerHelper.SetY( CENTER_Y ); } else {