diff --git a/stepmania/src/LifeMeter.cpp b/stepmania/src/LifeMeter.cpp new file mode 100644 index 0000000000..d6f4efbf5a --- /dev/null +++ b/stepmania/src/LifeMeter.cpp @@ -0,0 +1,42 @@ +#include "global.h" +#include "LifeMeter.h" +#include "LifeMeterBar.h" +#include "LifeMeterBattery.h" +#include "LifeMeterTime.h" + +LifeMeter *LifeMeter::MakeLifeMeter( SongOptions::LifeType t ) +{ + switch( t ) + { + case SongOptions::LIFE_BAR: return new LifeMeterBar; + case SongOptions::LIFE_BATTERY: return new LifeMeterBattery; + case SongOptions::LIFE_TIME: return new LifeMeterTime; + default: + ASSERT(0); + } +} + +/* + * (c) 2005 Glenn Maynard + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons to + * whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ diff --git a/stepmania/src/LifeMeter.h b/stepmania/src/LifeMeter.h index f0d0f5f14d..e0ddf88645 100644 --- a/stepmania/src/LifeMeter.h +++ b/stepmania/src/LifeMeter.h @@ -4,6 +4,7 @@ #include "PlayerNumber.h" #include "GameConstantsAndTypes.h" #include "ActorFrame.h" +#include "SongOptions.h" class PlayerState; class PlayerStageStats; @@ -35,6 +36,8 @@ public: virtual void UpdateNonstopLifebar(int cleared, int total, int ProgressiveLifebarDifficulty) = 0; virtual void ForceFail() = 0; + static LifeMeter *MakeLifeMeter( SongOptions::LifeType t ); + protected: const PlayerState *m_pPlayerState; PlayerStageStats *m_pPlayerStageStats; diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index d455d1f3d2..59cbbc8f61 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -8,9 +8,7 @@ #include "SongManager.h" #include "Steps.h" #include "RageLog.h" -#include "LifeMeterBar.h" -#include "LifeMeterBattery.h" -#include "LifeMeterTime.h" +#include "LifeMeter.h" #include "GameState.h" #include "ScoreDisplayNormal.h" #include "ScoreDisplayPercentage.h" @@ -562,21 +560,7 @@ void ScreenGameplay::Init() if( !GAMESTATE->IsPlayerEnabled(pi->m_pn) && !SHOW_LIFE_METER_FOR_DISABLED_PLAYERS ) continue; // skip - switch( GAMESTATE->m_SongOptions.m_LifeType ) - { - case SongOptions::LIFE_BAR: - pi->m_pLifeMeter = new LifeMeterBar; - break; - case SongOptions::LIFE_BATTERY: - pi->m_pLifeMeter = new LifeMeterBattery; - break; - case SongOptions::LIFE_TIME: - pi->m_pLifeMeter = new LifeMeterTime; - break; - default: - ASSERT(0); - } - + pi->m_pLifeMeter = LifeMeter::MakeLifeMeter( GAMESTATE->m_SongOptions.m_LifeType ); pi->m_pLifeMeter->Load( pi->GetPlayerState(), pi->GetPlayerStageStats() ); pi->m_pLifeMeter->SetName( ssprintf("Life%s",pi->GetName().c_str()) ); SET_XY( pi->m_pLifeMeter );