2003-02-16 04:01:45 +00:00
#include "global.h"
2002-05-20 08:59:37 +00:00
#include "ScreenGameplay.h"
#include "SongManager.h"
#include "ScreenManager.h"
#include "GameConstantsAndTypes.h"
2002-07-23 01:41:40 +00:00
#include "PrefsManager.h"
2006-11-21 05:02:55 +00:00
#include "GamePreferences.h"
2002-05-20 08:59:37 +00:00
#include "GameManager.h"
2006-09-16 03:17:18 +00:00
#include "RageFileManager.h"
2005-07-03 02:49:42 +00:00
#include "Steps.h"
2002-05-20 08:59:37 +00:00
#include "RageLog.h"
2005-10-27 21:55:24 +00:00
#include "LifeMeter.h"
2002-07-23 01:41:40 +00:00
#include "GameState.h"
#include "ScoreDisplayNormal.h"
2003-10-05 05:24:50 +00:00
#include "ScoreDisplayPercentage.h"
2005-04-21 11:16:01 +00:00
#include "ScoreDisplayLifeTime.h"
2002-07-23 01:41:40 +00:00
#include "ScoreDisplayOni.h"
2003-04-07 05:14:27 +00:00
#include "ScoreDisplayRave.h"
2002-11-11 04:53:31 +00:00
#include "ThemeManager.h"
2003-01-25 07:40:47 +00:00
#include "RageTimer.h"
2005-10-08 02:10:32 +00:00
#include "ScoreKeeperNormal.h"
2003-06-30 18:08:27 +00:00
#include "ScoreKeeperRave.h"
2003-03-19 12:43:49 +00:00
#include "LyricsLoader.h"
2003-04-13 21:17:14 +00:00
#include "ActorUtil.h"
2007-01-18 09:12:50 +00:00
#include "RageSoundManager.h"
2007-01-16 02:32:27 +00:00
#include "RageSoundReader.h"
2003-04-22 04:54:04 +00:00
#include "RageTextureManager.h"
2004-07-08 00:10:34 +00:00
#include "GameSoundManager.h"
2003-06-30 18:08:27 +00:00
#include "CombinedLifeMeterTug.h"
2003-07-08 19:56:56 +00:00
#include "Inventory.h"
2003-07-17 20:10:07 +00:00
#include "Course.h"
2003-08-07 06:36:34 +00:00
#include "NoteDataUtil.h"
2005-02-21 06:22:46 +00:00
#include "UnlockManager.h"
2003-11-16 04:45:12 +00:00
#include "LightsManager.h"
2003-12-17 10:21:31 +00:00
#include "ProfileManager.h"
2005-02-16 03:25:45 +00:00
#include "StatsManager.h"
2004-01-11 23:33:56 +00:00
#include "PlayerAI.h" // for NUM_SKILL_LEVELS
2004-03-16 22:10:45 +00:00
#include "NetworkSyncManager.h"
2004-05-23 00:53:20 +00:00
#include "Foreach.h"
2004-08-19 01:18:11 +00:00
#include "DancingCharacters.h"
2004-09-21 06:07:12 +00:00
#include "ScreenDimensions.h"
2004-11-06 20:36:04 +00:00
#include "ThemeMetric.h"
2004-12-20 21:27:24 +00:00
#include "PlayerState.h"
2005-01-15 02:01:26 +00:00
#include "Style.h"
2005-01-30 02:43:32 +00:00
#include "LuaManager.h"
2005-02-06 08:48:55 +00:00
#include "MemoryCardManager.h"
2005-03-20 09:52:48 +00:00
#include "CommonMetrics.h"
2005-05-08 04:10:16 +00:00
#include "InputMapper.h"
#include "Game.h"
2005-08-23 21:38:51 +00:00
#include "ActiveAttackList.h"
#include "Player.h"
2008-03-11 10:41:11 +00:00
#include "DifficultyDisplay.h"
2005-11-22 21:18:45 +00:00
#include "XmlFile.h"
2006-02-04 18:37:26 +00:00
#include "Background.h"
#include "Foreground.h"
2006-02-04 20:14:04 +00:00
#include "ScreenSaveSync.h"
2006-02-06 01:23:25 +00:00
#include "AdjustSync.h"
2006-06-13 01:10:37 +00:00
#include "SongUtil.h"
2008-03-09 01:51:34 +00:00
#include "Song.h"
2006-10-02 05:53:56 +00:00
#include "XmlFileUtil.h"
2008-02-20 04:43:47 +00:00
#include "WorkoutManager.h"
2003-03-19 12:43:49 +00:00
2002-05-20 08:59:37 +00:00
//
2002-07-23 01:41:40 +00:00
// Defines
2002-05-20 08:59:37 +00:00
//
2004-05-31 08:58:43 +00:00
#define SHOW_LIFE_METER_FOR_DISABLED_PLAYERS THEME->GetMetricB(m_sName,"ShowLifeMeterForDisabledPlayers")
2006-02-04 20:14:04 +00:00
#define SHOW_SCORE_IN_RAVE THEME->GetMetricB(m_sName,"ShowScoreInRave")
#define SONG_POSITION_METER_WIDTH THEME->GetMetricF(m_sName,"SongPositionMeterWidth")
#define PLAYER_X( sName, styleType ) THEME->GetMetricF(m_sName,ssprintf("Player%s%sX",sName.c_str(),StyleTypeToString(styleType).c_str()))
#define STOP_COURSE_EARLY THEME->GetMetricB(m_sName,"StopCourseEarly") // evaluate this every time it's used
2003-04-22 14:32:48 +00:00
2005-02-26 06:22:40 +00:00
static ThemeMetric < float > INITIAL_BACKGROUND_BRIGHTNESS ( "ScreenGameplay" , "InitialBackgroundBrightness" );
2004-11-06 20:36:04 +00:00
static ThemeMetric < float > SECONDS_BETWEEN_COMMENTS ( "ScreenGameplay" , "SecondsBetweenComments" );
2006-11-16 00:57:48 +00:00
static ThemeMetric < RString > SCORE_KEEPER_CLASS ( "ScreenGameplay" , "ScoreKeeperClass" );
2003-04-13 21:17:14 +00:00
2005-03-28 08:01:36 +00:00
AutoScreenMessage ( SM_PlayGo )
2002-05-20 08:59:37 +00:00
// received while STATE_DANCING
2005-03-28 08:01:36 +00:00
AutoScreenMessage ( SM_LoadNextSong )
AutoScreenMessage ( SM_StartLoadingNextSong )
2005-03-23 08:48:38 +00:00
2002-05-20 08:59:37 +00:00
// received while STATE_OUTRO
2006-02-04 20:14:04 +00:00
AutoScreenMessage ( SM_DoPrevScreen )
AutoScreenMessage ( SM_DoNextScreen )
2002-05-20 08:59:37 +00:00
2003-01-25 07:40:47 +00:00
// received while STATE_INTRO
2005-03-28 08:01:36 +00:00
AutoScreenMessage ( SM_StartHereWeGo )
AutoScreenMessage ( SM_StopHereWeGo )
2002-05-20 08:59:37 +00:00
2006-02-23 23:50:32 +00:00
AutoScreenMessage ( SM_BattleTrickLevel1 );
AutoScreenMessage ( SM_BattleTrickLevel2 );
AutoScreenMessage ( SM_BattleTrickLevel3 );
2006-02-28 01:13:44 +00:00
static Preference < bool > g_bCenter1Player ( "Center1Player" , false );
static Preference < bool > g_bShowLyrics ( "ShowLyrics" , true );
2006-02-04 20:14:04 +00:00
static Preference < float > g_fNetStartOffset ( "NetworkStartOffset" , - 3.0 );
2006-02-28 01:13:44 +00:00
static Preference < bool > g_bEasterEggs ( "EasterEggs" , true );
2003-10-25 07:58:10 +00:00
2005-08-23 21:38:51 +00:00
2005-08-23 23:48:23 +00:00
PlayerInfo :: PlayerInfo ()
2005-08-23 21:38:51 +00:00
{
m_pn = PLAYER_INVALID ;
2006-10-07 03:43:41 +00:00
m_mp = MultiPlayer_Invalid ;
2005-08-23 21:38:51 +00:00
m_bIsDummy = false ;
2007-07-12 11:01:25 +00:00
m_iDummyIndex = 0 ;
2007-10-26 21:50:04 +00:00
m_iAddToDifficulty = 0 ;
2005-08-23 21:38:51 +00:00
m_pLifeMeter = NULL ;
m_ptextCourseSongNumber = NULL ;
m_ptextStepsDescription = NULL ;
m_pPrimaryScoreDisplay = NULL ;
m_pSecondaryScoreDisplay = NULL ;
m_pPrimaryScoreKeeper = NULL ;
m_pSecondaryScoreKeeper = NULL ;
m_ptextPlayerOptions = NULL ;
m_pActiveAttackList = NULL ;
m_pPlayer = NULL ;
m_pInventory = NULL ;
2008-03-24 04:38:14 +00:00
m_pDifficultyDisplay = NULL ;
2005-08-23 21:38:51 +00:00
}
2007-10-26 21:50:04 +00:00
void PlayerInfo :: Load ( PlayerNumber pn , MultiPlayer mp , bool bShowNoteField , int iAddToDifficulty )
2005-08-23 21:38:51 +00:00
{
m_pn = pn ;
m_mp = mp ;
2007-05-14 04:04:52 +00:00
m_bPlayerEnabled = IsEnabled ();
2005-08-23 21:38:51 +00:00
m_bIsDummy = false ;
2007-10-26 21:50:04 +00:00
m_iAddToDifficulty = iAddToDifficulty ;
2005-08-23 21:38:51 +00:00
m_pLifeMeter = NULL ;
m_ptextCourseSongNumber = NULL ;
m_ptextStepsDescription = NULL ;
2005-08-26 17:39:53 +00:00
if ( ! IsMultiPlayer () )
2005-08-23 21:38:51 +00:00
{
2005-08-26 17:39:53 +00:00
switch ( GAMESTATE -> m_PlayMode )
{
case PLAY_MODE_REGULAR :
case PLAY_MODE_NONSTOP :
case PLAY_MODE_BATTLE :
case PLAY_MODE_RAVE :
if ( PREFSMAN -> m_bPercentageScoring )
m_pPrimaryScoreDisplay = new ScoreDisplayPercentage ;
else
m_pPrimaryScoreDisplay = new ScoreDisplayNormal ;
break ;
case PLAY_MODE_ONI :
case PLAY_MODE_ENDLESS :
2006-08-05 02:38:05 +00:00
if ( GAMESTATE -> m_SongOptions . GetStage (). m_LifeType == SongOptions :: LIFE_TIME )
2005-08-26 17:39:53 +00:00
m_pPrimaryScoreDisplay = new ScoreDisplayLifeTime ;
else
m_pPrimaryScoreDisplay = new ScoreDisplayOni ;
break ;
default :
ASSERT ( 0 );
}
2005-08-23 21:38:51 +00:00
}
2006-07-10 00:47:59 +00:00
PlayerState * const pPlayerState = GetPlayerState ();
PlayerStageStats * const pPlayerStageStats = GetPlayerStageStats ();
2005-08-23 21:38:51 +00:00
2005-08-26 17:39:53 +00:00
if ( m_pPrimaryScoreDisplay )
2006-07-10 00:47:59 +00:00
m_pPrimaryScoreDisplay -> Init ( pPlayerState , pPlayerStageStats );
2005-08-23 21:38:51 +00:00
switch ( GAMESTATE -> m_PlayMode )
{
case PLAY_MODE_RAVE :
m_pSecondaryScoreDisplay = new ScoreDisplayRave ;
2006-01-18 22:37:06 +00:00
m_pSecondaryScoreDisplay -> SetName ( "ScoreDisplayRave" );
2005-08-23 21:38:51 +00:00
break ;
}
if ( m_pSecondaryScoreDisplay )
2006-07-10 00:47:59 +00:00
m_pSecondaryScoreDisplay -> Init ( pPlayerState , pPlayerStageStats );
2005-08-23 21:38:51 +00:00
2006-11-16 00:57:48 +00:00
m_pPrimaryScoreKeeper = ScoreKeeper :: MakeScoreKeeper ( SCORE_KEEPER_CLASS , pPlayerState , pPlayerStageStats );
2005-08-23 21:38:51 +00:00
switch ( GAMESTATE -> m_PlayMode )
{
case PLAY_MODE_RAVE :
2006-07-10 00:47:59 +00:00
m_pSecondaryScoreKeeper = new ScoreKeeperRave ( pPlayerState , pPlayerStageStats );
2005-08-23 21:38:51 +00:00
break ;
}
m_ptextPlayerOptions = NULL ;
m_pActiveAttackList = NULL ;
2007-03-02 06:52:20 +00:00
m_pPlayer = new Player ( m_NoteData , bShowNoteField );
2005-08-23 21:38:51 +00:00
m_pInventory = NULL ;
2008-03-24 04:38:14 +00:00
m_pDifficultyDisplay = NULL ;
2005-08-23 21:38:51 +00:00
if ( IsMultiPlayer () )
{
2006-08-05 02:38:05 +00:00
pPlayerState -> m_PlayerOptions = GAMESTATE -> m_pPlayerState [ PLAYER_1 ] -> m_PlayerOptions ;
2005-08-23 21:38:51 +00:00
}
}
2007-10-26 21:50:04 +00:00
void PlayerInfo :: LoadDummyP1 ( int iDummyIndex , int iAddToDifficulty )
2005-08-23 21:38:51 +00:00
{
m_pn = PLAYER_1 ;
2007-07-12 11:01:25 +00:00
m_bPlayerEnabled = IsEnabled ();
2005-08-23 21:38:51 +00:00
m_bIsDummy = true ;
2007-07-12 11:01:25 +00:00
m_iDummyIndex = iDummyIndex ;
2007-10-26 21:50:04 +00:00
m_iAddToDifficulty = iAddToDifficulty ;
2005-08-23 21:38:51 +00:00
// don't init any of the scoring objects
2007-03-02 06:52:20 +00:00
m_pPlayer = new Player ( m_NoteData , true );
2005-08-23 21:38:51 +00:00
2007-07-18 02:01:50 +00:00
// PlayerOptions needs to be set now so that we load the correct NoteSkin.
2005-08-23 21:38:51 +00:00
m_PlayerStateDummy = * GAMESTATE -> m_pPlayerState [ PLAYER_1 ];
}
2005-08-23 23:48:23 +00:00
PlayerInfo ::~ PlayerInfo ()
2005-08-23 21:38:51 +00:00
{
SAFE_DELETE ( m_pLifeMeter );
SAFE_DELETE ( m_ptextCourseSongNumber );
SAFE_DELETE ( m_ptextStepsDescription );
SAFE_DELETE ( m_pPrimaryScoreDisplay );
SAFE_DELETE ( m_pSecondaryScoreDisplay );
SAFE_DELETE ( m_pPrimaryScoreKeeper );
SAFE_DELETE ( m_pSecondaryScoreKeeper );
SAFE_DELETE ( m_ptextPlayerOptions );
SAFE_DELETE ( m_pActiveAttackList );
SAFE_DELETE ( m_pPlayer );
SAFE_DELETE ( m_pInventory );
2008-03-24 04:38:14 +00:00
SAFE_DELETE ( m_pDifficultyDisplay );
2005-08-23 21:38:51 +00:00
}
2005-08-23 23:48:23 +00:00
void PlayerInfo :: ShowOniGameOver ()
2005-08-23 21:38:51 +00:00
{
m_sprOniGameOver -> PlayCommand ( "Die" );
}
2005-08-23 23:48:23 +00:00
PlayerState * PlayerInfo :: GetPlayerState ()
2005-08-23 21:38:51 +00:00
{
if ( m_bIsDummy )
return & m_PlayerStateDummy ;
return IsMultiPlayer () ?
GAMESTATE -> m_pMultiPlayerState [ GetPlayerStateAndStageStatsIndex () ] :
GAMESTATE -> m_pPlayerState [ GetPlayerStateAndStageStatsIndex () ];
}
2005-08-23 23:48:23 +00:00
PlayerStageStats * PlayerInfo :: GetPlayerStageStats ()
2005-08-23 21:38:51 +00:00
{
2007-08-20 10:45:28 +00:00
// multiplayer chooses the PlayerStageStats with the highest score on StageFinalized
if ( m_bIsDummy || IsMultiPlayer () )
2005-08-23 21:38:51 +00:00
return & m_PlayerStageStatsDummy ;
2007-08-20 10:45:28 +00:00
return & STATSMAN -> m_CurStageStats . m_player [ GetPlayerStateAndStageStatsIndex () ];
2005-08-23 21:38:51 +00:00
}
2005-08-23 23:48:23 +00:00
bool PlayerInfo :: IsEnabled ()
2005-08-23 21:38:51 +00:00
{
if ( m_pn != PLAYER_INVALID )
return GAMESTATE -> IsPlayerEnabled ( m_pn );
2006-10-07 03:43:41 +00:00
if ( m_mp != MultiPlayer_Invalid )
2005-08-23 21:38:51 +00:00
return GAMESTATE -> IsMultiPlayerEnabled ( m_mp );
else if ( m_bIsDummy )
return true ;
ASSERT ( 0 );
return false ;
}
2005-08-23 23:48:23 +00:00
vector < PlayerInfo >:: iterator
GetNextEnabledPlayerInfo ( vector < PlayerInfo >:: iterator iter , vector < PlayerInfo > & v )
2005-08-23 21:38:51 +00:00
{
2006-06-16 20:23:02 +00:00
for ( ; iter != v . end (); ++ iter )
2005-08-23 21:38:51 +00:00
{
2007-05-14 04:04:52 +00:00
if ( ! iter -> m_bPlayerEnabled )
2005-08-23 21:38:51 +00:00
continue ;
return iter ;
}
return iter ;
}
2005-08-23 23:48:23 +00:00
vector < PlayerInfo >:: iterator
GetNextEnabledPlayerInfoNotDummy ( vector < PlayerInfo >:: iterator iter , vector < PlayerInfo > & v )
2005-08-23 21:38:51 +00:00
{
for ( ; iter != v . end (); iter ++ )
{
if ( iter -> m_bIsDummy )
continue ;
2007-05-14 04:04:52 +00:00
if ( ! iter -> m_bPlayerEnabled )
2005-08-23 21:38:51 +00:00
continue ;
return iter ;
}
return iter ;
}
2005-08-23 23:48:23 +00:00
vector < PlayerInfo >:: iterator
GetNextEnabledPlayerNumberInfo ( vector < PlayerInfo >:: iterator iter , vector < PlayerInfo > & v )
2005-08-23 21:38:51 +00:00
{
2006-06-16 20:23:02 +00:00
for ( ; iter != v . end (); ++ iter )
2005-08-23 21:38:51 +00:00
{
if ( iter -> m_bIsDummy )
continue ;
2007-05-14 04:04:52 +00:00
if ( ! iter -> m_bPlayerEnabled )
2005-08-23 21:38:51 +00:00
continue ;
2006-10-07 03:43:41 +00:00
if ( iter -> m_mp != MultiPlayer_Invalid )
2005-08-23 21:38:51 +00:00
continue ;
return iter ;
}
return iter ;
}
2005-08-23 23:48:23 +00:00
vector < PlayerInfo >:: iterator
GetNextPlayerNumberInfo ( vector < PlayerInfo >:: iterator iter , vector < PlayerInfo > & v )
2005-08-23 21:38:51 +00:00
{
2006-06-16 20:23:02 +00:00
for ( ; iter != v . end (); ++ iter )
2005-08-23 21:38:51 +00:00
{
if ( iter -> m_bIsDummy )
continue ;
if ( iter -> m_pn == PLAYER_INVALID )
continue ;
return iter ;
}
return iter ;
}
2005-08-23 23:48:23 +00:00
vector < PlayerInfo >:: iterator
GetNextVisiblePlayerInfo ( vector < PlayerInfo >:: iterator iter , vector < PlayerInfo > & v )
2005-08-23 21:38:51 +00:00
{
2006-06-16 20:23:02 +00:00
for ( ; iter != v . end (); ++ iter )
2005-08-23 21:38:51 +00:00
{
2007-09-16 21:22:09 +00:00
if ( ! iter -> m_pPlayer -> HasVisibleParts () )
2005-08-23 21:38:51 +00:00
continue ;
return iter ;
}
return iter ;
}
2006-01-15 19:49:02 +00:00
ScreenGameplay :: ScreenGameplay ()
2002-05-20 08:59:37 +00:00
{
2006-02-04 18:37:26 +00:00
m_pSongBackground = NULL ;
m_pSongForeground = NULL ;
2004-02-18 02:31:43 +00:00
}
2002-05-20 08:59:37 +00:00
2006-02-05 04:29:10 +00:00
void ScreenGameplay :: Init ()
2004-02-18 02:31:43 +00:00
{
2007-01-16 02:32:27 +00:00
SubscribeToMessage ( "Judgment" );
2006-07-23 23:55:16 +00:00
PLAYER_TYPE . Load ( m_sName , "PlayerType" );
2006-10-27 10:19:08 +00:00
PLAYER_INIT_COMMAND . Load ( m_sName , "PlayerInitCommand" );
2006-07-23 23:55:16 +00:00
GIVE_UP_START_TEXT . Load ( m_sName , "GiveUpStartText" );
GIVE_UP_BACK_TEXT . Load ( m_sName , "GiveUpBackText" );
GIVE_UP_ABORTED_TEXT . Load ( m_sName , "GiveUpAbortedText" );
MUSIC_FADE_OUT_SECONDS . Load ( m_sName , "MusicFadeOutSeconds" );
2007-05-01 02:25:38 +00:00
OUT_TRANSITION_LENGTH . Load ( m_sName , "OutTransitionLength" );
COURSE_TRANSITION_LENGTH . Load ( m_sName , "CourseTransitionLength" );
2007-05-01 19:43:41 +00:00
BEGIN_FAILED_DELAY . Load ( m_sName , "BeginFailedDelay" );
2007-02-26 01:46:50 +00:00
MIN_SECONDS_TO_STEP . Load ( m_sName , "MinSecondsToStep" );
MIN_SECONDS_TO_MUSIC . Load ( m_sName , "MinSecondsToMusic" );
MIN_SECONDS_TO_STEP_NEXT_SONG . Load ( m_sName , "MinSecondsToStepNextSong" );
2006-07-23 23:55:16 +00:00
START_GIVES_UP . Load ( m_sName , "StartGivesUp" );
BACK_GIVES_UP . Load ( m_sName , "BackGivesUp" );
GIVING_UP_GOES_TO_PREV_SCREEN . Load ( m_sName , "GivingUpGoesToPrevScreen" );
2007-05-30 20:22:57 +00:00
FAIL_ON_MISS_COMBO . Load ( m_sName , "FailOnMissCombo" );
2006-07-23 23:55:16 +00:00
ALLOW_CENTER_1_PLAYER . Load ( m_sName , "AllowCenter1Player" );
2006-02-04 18:37:26 +00:00
2006-10-04 02:44:52 +00:00
if ( UseSongBackgroundAndForeground () )
2006-02-04 18:37:26 +00:00
{
m_pSongBackground = new Background ;
m_pSongForeground = new Foreground ;
}
2006-01-15 19:48:11 +00:00
2005-04-01 12:35:49 +00:00
ScreenWithMenuElements :: Init ();
2005-01-03 22:44:19 +00:00
2006-06-12 09:19:07 +00:00
this -> FillPlayerInfo ( m_vPlayerInfo );
ASSERT_M ( ! m_vPlayerInfo . empty (), "m_vPlayerInfo must be filled by FillPlayerInfo" );
2006-01-18 20:29:52 +00:00
/* Pause MEMCARDMAN. If a memory card is removed, we don't want to interrupt the
2005-02-06 08:48:55 +00:00
* player by making a noise until the game finishes. */
2005-02-06 10:10:38 +00:00
if ( ! GAMESTATE -> m_bDemonstrationOrJukebox )
MEMCARDMAN -> PauseMountingThread ();
2005-02-06 08:48:55 +00:00
2004-10-25 03:47:22 +00:00
m_pSoundMusic = NULL ;
2005-03-11 02:52:40 +00:00
m_bPaused = false ;
2004-10-25 03:47:22 +00:00
2003-11-13 00:39:36 +00:00
m_pCombinedLifeMeter = NULL ;
2003-03-09 00:55:49 +00:00
2003-02-04 21:36:30 +00:00
if ( GAMESTATE -> m_pCurSong == NULL && GAMESTATE -> m_pCurCourse == NULL )
2005-01-03 21:05:40 +00:00
return ; // ScreenDemonstration will move us to the next screen. We just need to survive for one update without crashing.
2003-01-19 21:05:03 +00:00
2004-03-30 03:55:54 +00:00
/* Save settings to the profile now. Don't do this on extra stages, since the
2007-02-22 07:18:05 +00:00
* user doesn't have full control; saving would force profiles to Difficulty_Hard
2004-03-30 03:55:54 +00:00
* and save over their default modifiers every time someone got an extra stage.
* Do this before course modifiers are set up. */
2007-04-25 00:30:30 +00:00
if ( ! GAMESTATE -> IsAnExtraStage () )
2004-03-30 03:55:54 +00:00
{
FOREACH_HumanPlayer ( pn )
GAMESTATE -> SaveCurrentSettingsToProfile ( pn );
}
2005-02-23 04:46:05 +00:00
/* Called once per stage (single song or single course). */
GAMESTATE -> BeginStage ();
2003-04-14 22:12:54 +00:00
2003-04-07 21:24:14 +00:00
2002-08-28 22:42:40 +00:00
2003-01-10 02:22:07 +00:00
2003-04-07 21:24:14 +00:00
// fill in difficulty of CPU players with that of the first human player
2006-01-18 07:43:17 +00:00
FOREACH_PotentialCpuPlayer ( p )
2006-03-14 02:23:45 +00:00
GAMESTATE -> m_pCurSteps [ p ]. Set ( GAMESTATE -> m_pCurSteps [ GAMESTATE -> GetFirstHumanPlayer () ] );
2003-04-07 21:24:14 +00:00
2005-01-03 23:29:40 +00:00
/* Increment the course play count. */
if ( GAMESTATE -> IsCourseMode () && ! GAMESTATE -> m_bDemonstrationOrJukebox )
FOREACH_EnabledPlayer ( p )
PROFILEMAN -> IncrementCoursePlayCount ( GAMESTATE -> m_pCurCourse , GAMESTATE -> m_pCurTrail [ p ], p );
2003-03-26 23:08:05 +00:00
2007-04-24 00:25:54 +00:00
STATSMAN -> m_CurStageStats . m_Stage = GAMESTATE -> GetCurrentStage ();
2007-04-24 02:08:31 +00:00
STATSMAN -> m_CurStageStats . m_iStageIndex = GAMESTATE -> m_iCurrentStageIndex ;
2006-11-14 11:13:21 +00:00
STATSMAN -> m_CurStageStats . m_playMode = GAMESTATE -> m_PlayMode ;
STATSMAN -> m_CurStageStats . m_pStyle = GAMESTATE -> GetCurrentStyle ();
2003-09-06 01:20:56 +00:00
2005-03-18 07:53:16 +00:00
/* Record combo rollover. */
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfoNotDummy ( m_vPlayerInfo , pi )
pi -> GetPlayerStageStats () -> UpdateComboList ( 0 , true );
2003-09-06 01:20:56 +00:00
2002-05-20 08:59:37 +00:00
m_DancingState = STATE_INTRO ;
2003-08-07 07:34:42 +00:00
// Set this in LoadNextSong()
//m_fTimeLeftBeforeDancingComment = SECONDS_BETWEEN_COMMENTS;
2005-05-07 09:58:23 +00:00
2003-04-13 00:44:50 +00:00
m_bZeroDeltaOnNextUpdate = false ;
2005-05-07 09:58:23 +00:00
2003-03-08 08:03:22 +00:00
2006-02-04 18:37:26 +00:00
if ( m_pSongBackground )
{
m_pSongBackground -> SetName ( "SongBackground" );
m_pSongBackground -> SetDrawOrder ( DRAW_ORDER_BEFORE_EVERYTHING );
2006-09-23 03:57:11 +00:00
ActorUtil :: LoadAllCommands ( * m_pSongBackground , m_sName );
2006-02-04 18:37:26 +00:00
this -> AddChild ( m_pSongBackground );
}
2004-01-07 00:13:32 +00:00
2006-02-04 18:37:26 +00:00
if ( m_pSongForeground )
{
m_pSongForeground -> SetName ( "SongForeground" );
m_pSongForeground -> SetDrawOrder ( DRAW_ORDER_OVERLAY + 1 ); // on top of the overlay, but under transitions
2006-09-23 03:57:11 +00:00
ActorUtil :: LoadAllCommands ( * m_pSongForeground , m_sName );
2006-02-04 18:37:26 +00:00
this -> AddChild ( m_pSongForeground );
}
2004-01-07 00:13:32 +00:00
2005-03-11 02:06:39 +00:00
if ( PREFSMAN -> m_bShowBeginnerHelper )
{
m_BeginnerHelper . SetDrawOrder ( DRAW_ORDER_BEFORE_EVERYTHING );
m_BeginnerHelper . SetXY ( SCREEN_CENTER_X , SCREEN_CENTER_Y );
this -> AddChild ( & m_BeginnerHelper );
}
2003-10-08 23:32:08 +00:00
2005-01-03 23:20:11 +00:00
if ( ! GAMESTATE -> m_bDemonstrationOrJukebox ) // only load if we're going to use it
2003-04-13 23:22:27 +00:00
{
2004-05-31 08:58:43 +00:00
m_Toasty . Load ( THEME -> GetPathB ( m_sName , "toasty" ) );
2003-04-13 23:22:27 +00:00
this -> AddChild ( & m_Toasty );
}
2006-01-18 07:43:17 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2002-05-27 08:23:27 +00:00
{
2007-07-12 11:01:25 +00:00
RString sName = ssprintf ( "Player%s" , pi -> GetName (). c_str ());
pi -> m_pPlayer -> SetName ( sName );
2005-08-23 21:38:51 +00:00
// If pi->m_pn is set, then the player will be visible. If not, then it's not
// visible and don't bother setting its position.
2003-03-02 06:16:03 +00:00
2007-08-27 12:03:17 +00:00
float fPlayerX ;
if ( GAMESTATE -> m_bMultiplayer && ! pi -> m_bIsDummy )
{
2005-08-26 17:39:53 +00:00
fPlayerX = SCREEN_CENTER_X ;
2007-08-27 12:03:17 +00:00
}
else
{
fPlayerX = PLAYER_X ( pi -> GetName (), GAMESTATE -> GetCurrentStyle () -> m_StyleType );
if ( Center1Player () )
fPlayerX = SCREEN_CENTER_X ;
}
2005-08-26 17:39:53 +00:00
2006-10-27 10:19:08 +00:00
pi -> m_pPlayer -> SetX ( fPlayerX );
pi -> m_pPlayer -> RunCommands ( PLAYER_INIT_COMMAND );
2005-08-23 21:38:51 +00:00
this -> AddChild ( pi -> m_pPlayer );
2007-03-06 22:51:50 +00:00
pi -> m_pPlayer -> PlayCommand ( "On" );
2005-08-23 21:38:51 +00:00
}
2002-08-01 21:55:40 +00:00
2006-01-18 07:43:17 +00:00
FOREACH_EnabledPlayerInfoNotDummy ( m_vPlayerInfo , pi )
2005-08-23 21:38:51 +00:00
{
2007-09-16 21:22:09 +00:00
if ( pi -> m_pPlayer -> HasVisibleParts () )
2005-08-23 21:38:51 +00:00
{
pi -> m_sprOniGameOver . Load ( THEME -> GetPathG ( m_sName , "oni gameover" ) );
pi -> m_sprOniGameOver -> SetName ( ssprintf ( "OniGameOver%s" , pi -> GetName (). c_str ()) );
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY ( pi -> m_sprOniGameOver );
2005-08-23 21:38:51 +00:00
this -> AddChild ( pi -> m_sprOniGameOver );
}
2002-05-27 08:23:27 +00:00
}
2002-05-20 08:59:37 +00:00
2005-03-19 00:03:53 +00:00
m_NextSong . Load ( THEME -> GetPathB ( m_sName , "next course song" ) );
m_NextSong . SetDrawOrder ( DRAW_ORDER_TRANSITIONS - 1 );
this -> AddChild ( & m_NextSong );
2002-08-01 21:55:40 +00:00
2003-11-19 12:33:52 +00:00
//
// Add combined life meter
2003-07-08 19:56:56 +00:00
//
switch ( GAMESTATE -> m_PlayMode )
{
2003-08-19 04:27:50 +00:00
case PLAY_MODE_BATTLE :
2003-07-08 19:56:56 +00:00
case PLAY_MODE_RAVE :
2003-08-19 04:27:50 +00:00
m_pCombinedLifeMeter = new CombinedLifeMeterTug ;
2004-05-31 08:58:43 +00:00
m_pCombinedLifeMeter -> SetName ( "CombinedLife" );
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY ( * m_pCombinedLifeMeter );
2003-07-08 19:56:56 +00:00
this -> AddChild ( m_pCombinedLifeMeter );
break ;
}
2004-04-06 02:05:34 +00:00
//
// Before the lifemeter loads, if Networking is required
// we need to wait, so that there is no Dead On Start issues.
// if you wait too long at the second checkpoint, you will
// appear dead when you begin your game.
//
2004-07-15 16:17:41 +00:00
NSMAN -> StartRequest ( 0 );
2004-04-06 02:05:34 +00:00
2003-07-08 19:56:56 +00:00
//
2003-11-19 12:33:52 +00:00
// Add individual life meter
2003-07-08 19:56:56 +00:00
//
2003-06-30 18:08:27 +00:00
switch ( GAMESTATE -> m_PlayMode )
2002-05-20 08:59:37 +00:00
{
2004-06-11 06:05:35 +00:00
case PLAY_MODE_REGULAR :
2003-06-30 18:08:27 +00:00
case PLAY_MODE_ONI :
case PLAY_MODE_NONSTOP :
case PLAY_MODE_ENDLESS :
2005-08-23 21:38:51 +00:00
FOREACH_PlayerNumberInfo ( m_vPlayerInfo , pi )
2002-07-23 01:41:40 +00:00
{
2005-08-23 21:38:51 +00:00
if ( ! GAMESTATE -> IsPlayerEnabled ( pi -> m_pn ) && ! SHOW_LIFE_METER_FOR_DISABLED_PLAYERS )
2003-07-08 19:56:56 +00:00
continue ; // skip
2006-08-05 02:38:05 +00:00
pi -> m_pLifeMeter = LifeMeter :: MakeLifeMeter ( GAMESTATE -> m_SongOptions . GetStage (). m_LifeType );
2005-08-23 21:38:51 +00:00
pi -> m_pLifeMeter -> Load ( pi -> GetPlayerState (), pi -> GetPlayerStageStats () );
pi -> m_pLifeMeter -> SetName ( ssprintf ( "Life%s" , pi -> GetName (). c_str ()) );
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY ( pi -> m_pLifeMeter );
2005-08-23 21:38:51 +00:00
this -> AddChild ( pi -> m_pLifeMeter );
2003-06-30 18:08:27 +00:00
}
break ;
2003-11-19 12:33:52 +00:00
case PLAY_MODE_BATTLE :
case PLAY_MODE_RAVE :
break ;
2002-05-20 08:59:37 +00:00
}
2005-08-24 20:45:57 +00:00
m_bShowScoreboard = false ;
2005-08-24 20:44:15 +00:00
2005-08-15 02:10:57 +00:00
#if !defined(WITHOUT_NETWORKING)
2005-08-24 20:45:57 +00:00
// Only used in SMLAN/SMOnline:
2007-02-22 06:56:17 +00:00
if ( NSMAN -> useSMserver && GAMESTATE -> GetCurrentStyle () -> m_StyleType != StyleType_OnePlayerTwoSides )
2004-08-13 08:24:11 +00:00
{
2005-08-24 20:45:57 +00:00
m_bShowScoreboard = PREFSMAN -> m_bEnableScoreboard . Get ();
2004-12-01 20:42:15 +00:00
PlayerNumber pn = GAMESTATE -> GetFirstDisabledPlayer ();
2006-01-17 06:58:06 +00:00
if ( pn != PLAYER_INVALID && m_bShowScoreboard )
2005-08-23 21:38:51 +00:00
{
2004-12-01 20:42:15 +00:00
FOREACH_NSScoreBoardColumn ( col )
2004-08-18 05:16:45 +00:00
{
2004-12-01 20:42:15 +00:00
m_Scoreboard [ col ]. LoadFromFont ( THEME -> GetPathF ( m_sName , "scoreboard" ) );
m_Scoreboard [ col ]. SetShadowLength ( 0 );
m_Scoreboard [ col ]. SetName ( ssprintf ( "ScoreboardC%iP%i" , col + 1 , pn + 1 ) );
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY ( m_Scoreboard [ col ] );
2004-12-01 20:42:15 +00:00
m_Scoreboard [ col ]. SetText ( NSMAN -> m_Scoreboard [ col ] );
m_Scoreboard [ col ]. SetVertAlign ( align_top );
2005-08-24 20:45:57 +00:00
this -> AddChild ( & m_Scoreboard [ col ] );
2004-08-18 05:16:45 +00:00
}
2005-08-23 21:38:51 +00:00
}
2004-08-13 08:24:11 +00:00
}
2005-08-15 02:10:57 +00:00
#endif
2002-05-20 08:59:37 +00:00
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2002-05-20 08:59:37 +00:00
{
2003-11-26 06:40:03 +00:00
// primary score display
2005-08-23 21:38:51 +00:00
if ( pi -> m_pPrimaryScoreDisplay )
2002-08-13 23:26:46 +00:00
{
2005-08-23 21:38:51 +00:00
pi -> m_pPrimaryScoreDisplay -> SetName ( ssprintf ( "Score%s" , pi -> GetName (). c_str ()) );
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY ( pi -> m_pPrimaryScoreDisplay );
2005-08-23 21:38:51 +00:00
if ( GAMESTATE -> m_PlayMode != PLAY_MODE_RAVE || SHOW_SCORE_IN_RAVE ) /* XXX: ugly */
this -> AddChild ( pi -> m_pPrimaryScoreDisplay );
2002-08-28 22:42:40 +00:00
}
2003-11-26 06:40:03 +00:00
// secondary score display
2005-08-23 21:38:51 +00:00
if ( pi -> m_pSecondaryScoreDisplay )
2003-11-26 06:40:03 +00:00
{
2005-08-23 21:38:51 +00:00
pi -> m_pSecondaryScoreDisplay -> SetName ( ssprintf ( "SecondaryScore%s" , pi -> GetName (). c_str ()) );
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY ( pi -> m_pSecondaryScoreDisplay );
2005-08-23 21:38:51 +00:00
this -> AddChild ( pi -> m_pSecondaryScoreDisplay );
2003-11-26 06:40:03 +00:00
}
2003-07-08 19:56:56 +00:00
}
2003-11-29 11:16:36 +00:00
//
// Add stage / SongNumber
//
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerNumberInfo ( m_vPlayerInfo , pi )
{
if ( GAMESTATE -> IsCourseMode () )
{
ASSERT ( pi -> m_ptextCourseSongNumber == NULL );
pi -> m_ptextCourseSongNumber = new BitmapText ;
pi -> m_ptextCourseSongNumber -> LoadFromFont ( THEME -> GetPathF ( m_sName , "song num" ) );
pi -> m_ptextCourseSongNumber -> SetShadowLength ( 0 );
pi -> m_ptextCourseSongNumber -> SetName ( ssprintf ( "SongNumber%s" , pi -> GetName (). c_str ()) );
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY ( pi -> m_ptextCourseSongNumber );
2005-08-23 21:38:51 +00:00
pi -> m_ptextCourseSongNumber -> SetText ( "" );
pi -> m_ptextCourseSongNumber -> SetDiffuse ( RageColor ( 0 , 0.5f , 1 , 1 ) ); // light blue
this -> AddChild ( pi -> m_ptextCourseSongNumber );
}
ASSERT ( pi -> m_ptextStepsDescription == NULL );
pi -> m_ptextStepsDescription = new BitmapText ;
pi -> m_ptextStepsDescription -> LoadFromFont ( THEME -> GetPathF ( m_sName , "StepsDescription" ) );
pi -> m_ptextStepsDescription -> SetName ( ssprintf ( "StepsDescription%s" , pi -> GetName (). c_str ()) );
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY ( pi -> m_ptextStepsDescription );
2005-08-23 21:38:51 +00:00
this -> AddChild ( pi -> m_ptextStepsDescription );
2003-11-29 11:16:36 +00:00
2006-01-18 20:34:35 +00:00
//
// Player/Song options
//
2005-08-23 21:38:51 +00:00
ASSERT ( pi -> m_ptextPlayerOptions == NULL );
pi -> m_ptextPlayerOptions = new BitmapText ;
pi -> m_ptextPlayerOptions -> LoadFromFont ( THEME -> GetPathF ( m_sName , "player options" ) );
pi -> m_ptextPlayerOptions -> SetShadowLength ( 0 );
pi -> m_ptextPlayerOptions -> SetName ( ssprintf ( "PlayerOptions%s" , pi -> GetName (). c_str ()) );
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY ( pi -> m_ptextPlayerOptions );
2005-08-23 21:38:51 +00:00
this -> AddChild ( pi -> m_ptextPlayerOptions );
2002-05-20 08:59:37 +00:00
2006-01-18 20:35:55 +00:00
//
// Difficulty icon and meter
//
2008-03-24 04:38:14 +00:00
ASSERT ( pi -> m_pDifficultyDisplay == NULL );
pi -> m_pDifficultyDisplay = new DifficultyDisplay ;
2008-03-27 10:11:40 +00:00
pi -> m_pDifficultyDisplay -> Load ( "DifficultyDisplayGameplay" , pi -> GetPlayerState () );
2008-03-24 04:38:14 +00:00
pi -> m_pDifficultyDisplay -> SetName ( ssprintf ( "DifficultyDisplay%s" , pi -> GetName (). c_str ()) );
PlayerNumber pn = pi -> GetStepsAndTrailIndex ();
if ( pn != PlayerNumber_Invalid )
pi -> m_pDifficultyDisplay -> PlayCommand ( "Set" + pi -> GetName () );
2008-03-24 12:00:51 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY ( pi -> m_pDifficultyDisplay );
2008-03-24 04:38:14 +00:00
this -> AddChild ( pi -> m_pDifficultyDisplay );
2004-05-31 06:04:30 +00:00
2006-01-18 20:31:51 +00:00
// switch( GAMESTATE->m_PlayMode )
// {
// case PLAY_MODE_BATTLE:
// pi->m_pInventory = new Inventory;
// pi->m_pInventory->Load( p );
// this->AddChild( pi->m_pInventory );
// break;
// }
2002-06-14 22:25:22 +00:00
}
2006-01-18 20:35:55 +00:00
m_textSongOptions . LoadFromFont ( THEME -> GetPathF ( m_sName , "song options" ) );
m_textSongOptions . SetShadowLength ( 0 );
m_textSongOptions . SetName ( "SongOptions" );
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY ( m_textSongOptions );
2006-08-05 02:38:05 +00:00
m_textSongOptions . SetText ( GAMESTATE -> m_SongOptions . GetStage (). GetLocalizedString () );
2006-01-18 20:35:55 +00:00
this -> AddChild ( & m_textSongOptions );
FOREACH_VisiblePlayerInfo ( m_vPlayerInfo , pi )
{
ASSERT ( pi -> m_pActiveAttackList == NULL );
pi -> m_pActiveAttackList = new ActiveAttackList ;
pi -> m_pActiveAttackList -> LoadFromFont ( THEME -> GetPathF ( m_sName , "ActiveAttackList" ) );
pi -> m_pActiveAttackList -> Init ( pi -> GetPlayerState () );
pi -> m_pActiveAttackList -> SetName ( ssprintf ( "ActiveAttackList%s" , pi -> GetName (). c_str ()) );
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY ( pi -> m_pActiveAttackList );
2006-01-18 20:35:55 +00:00
this -> AddChild ( pi -> m_pActiveAttackList );
}
2006-02-28 01:13:44 +00:00
if ( g_bShowLyrics )
2007-03-03 04:54:22 +00:00
{
m_LyricDisplay . SetName ( "Lyrics" );
LOAD_ALL_COMMANDS ( m_LyricDisplay );
2004-12-01 20:42:15 +00:00
this -> AddChild ( & m_LyricDisplay );
2007-03-03 04:54:22 +00:00
}
2003-01-11 08:55:21 +00:00
2005-01-03 23:20:11 +00:00
if ( ! GAMESTATE -> m_bDemonstrationOrJukebox ) // only load if we're going to use it
2003-03-09 00:55:49 +00:00
{
2004-05-31 08:58:43 +00:00
m_Ready . Load ( THEME -> GetPathB ( m_sName , "ready" ) );
2003-03-09 00:55:49 +00:00
this -> AddChild ( & m_Ready );
2004-05-31 08:58:43 +00:00
m_Go . Load ( THEME -> GetPathB ( m_sName , "go" ) );
2003-03-09 00:55:49 +00:00
this -> AddChild ( & m_Go );
2004-05-31 08:58:43 +00:00
m_Failed . Load ( THEME -> GetPathB ( m_sName , "failed" ) );
2004-05-02 03:01:27 +00:00
m_Failed . SetDrawOrder ( DRAW_ORDER_TRANSITIONS - 1 ); // on top of everything else
2003-03-09 00:55:49 +00:00
this -> AddChild ( & m_Failed );
2004-05-31 08:58:43 +00:00
m_textDebug . LoadFromFont ( THEME -> GetPathF ( "Common" , "normal" ) );
2003-04-13 21:17:14 +00:00
m_textDebug . SetName ( "Debug" );
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY ( m_textDebug );
2005-03-12 07:27:48 +00:00
m_textDebug . SetDrawOrder ( DRAW_ORDER_TRANSITIONS - 1 ); // just under transitions, over the foreground
2003-03-16 23:17:48 +00:00
this -> AddChild ( & m_textDebug );
2007-01-25 00:50:57 +00:00
m_GameplayAssist . Init ();
2003-03-09 00:55:49 +00:00
2006-08-06 02:37:42 +00:00
if ( GAMESTATE -> IsAnExtraStage () ) // only load if we're going to use it
2003-03-09 00:55:49 +00:00
{
2004-05-31 08:58:43 +00:00
m_textSurviveTime . LoadFromFont ( THEME -> GetPathF ( m_sName , "survive time" ) );
2004-03-20 02:59:08 +00:00
m_textSurviveTime . SetShadowLength ( 0 );
2003-04-13 21:17:14 +00:00
m_textSurviveTime . SetName ( "SurviveTime" );
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY ( m_textSurviveTime );
2004-05-02 03:01:27 +00:00
m_textSurviveTime . SetDrawOrder ( DRAW_ORDER_TRANSITIONS - 1 );
2003-03-09 00:55:49 +00:00
m_textSurviveTime . SetDiffuse ( RageColor ( 1 , 1 , 1 , 0 ) );
this -> AddChild ( & m_textSurviveTime );
}
2006-01-18 20:29:52 +00:00
2003-07-08 19:56:56 +00:00
switch ( GAMESTATE -> m_PlayMode )
2003-05-13 13:35:32 +00:00
{
2003-08-19 04:27:50 +00:00
case PLAY_MODE_BATTLE :
2004-05-31 08:58:43 +00:00
m_soundBattleTrickLevel1 . Load ( THEME -> GetPathS ( m_sName , "battle trick level1" ), true );
m_soundBattleTrickLevel2 . Load ( THEME -> GetPathS ( m_sName , "battle trick level2" ), true );
m_soundBattleTrickLevel3 . Load ( THEME -> GetPathS ( m_sName , "battle trick level3" ), true );
2003-07-08 19:56:56 +00:00
break ;
2003-05-13 13:35:32 +00:00
}
2003-03-09 00:55:49 +00:00
}
2006-02-04 18:37:26 +00:00
if ( m_pSongBackground )
m_pSongBackground -> Init ();
2006-01-18 20:33:17 +00:00
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
{
2007-03-02 06:52:20 +00:00
RString sType = PLAYER_TYPE ;
if ( pi -> m_bIsDummy )
sType += "Dummy" ;
2005-08-23 21:38:51 +00:00
pi -> m_pPlayer -> Init (
2007-03-02 06:52:20 +00:00
sType ,
2005-08-23 21:38:51 +00:00
pi -> GetPlayerState (),
pi -> GetPlayerStageStats (),
pi -> m_pLifeMeter ,
2005-03-18 03:17:52 +00:00
m_pCombinedLifeMeter ,
2005-08-23 21:38:51 +00:00
pi -> m_pPrimaryScoreDisplay ,
pi -> m_pSecondaryScoreDisplay ,
pi -> m_pInventory ,
pi -> m_pPrimaryScoreKeeper ,
pi -> m_pSecondaryScoreKeeper );
}
2005-03-18 03:17:52 +00:00
2005-03-18 07:53:16 +00:00
//
// fill in m_apSongsQueue, m_vpStepsQueue, m_asModifiersQueue
//
InitSongQueues ();
2007-05-31 01:14:23 +00:00
// Fill StageStats
STATSMAN -> m_CurStageStats . m_vpPossibleSongs = m_apSongsQueue ;
FOREACH ( PlayerInfo , m_vPlayerInfo , pi )
{
if ( pi -> GetPlayerStageStats () )
pi -> GetPlayerStageStats () -> m_vpPossibleSteps = pi -> m_vpStepsQueue ;
}
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2005-03-18 07:53:16 +00:00
{
2005-08-23 21:38:51 +00:00
ASSERT ( ! pi -> m_vpStepsQueue . empty () );
2007-05-31 01:14:23 +00:00
if ( pi -> GetPlayerStageStats () )
pi -> GetPlayerStageStats () -> m_bJoined = true ;
2005-08-23 21:38:51 +00:00
if ( pi -> m_pPrimaryScoreKeeper )
pi -> m_pPrimaryScoreKeeper -> Load ( m_apSongsQueue , pi -> m_vpStepsQueue , pi -> m_asModifiersQueue );
if ( pi -> m_pSecondaryScoreKeeper )
pi -> m_pSecondaryScoreKeeper -> Load ( m_apSongsQueue , pi -> m_vpStepsQueue , pi -> m_asModifiersQueue );
2005-03-18 07:53:16 +00:00
}
2005-03-18 02:57:03 +00:00
2005-10-10 04:50:53 +00:00
GAMESTATE -> m_bGameplayLeadIn . Set ( true );
2005-03-18 02:57:03 +00:00
/* LoadNextSong first, since that positions some elements which need to be
* positioned before we TweenOnScreen. */
LoadNextSong ();
2003-09-06 03:25:45 +00:00
m_GiveUpTimer . SetZero ();
2002-05-20 08:59:37 +00:00
}
2006-02-28 21:55:58 +00:00
bool ScreenGameplay :: Center1Player () const
{
/* Perhaps this should be handled better by defining a new
* StyleType for ONE_PLAYER_ONE_CREDIT_AND_ONE_COMPUTER,
* but for now just ignore Center1Player when it's Battle or Rave
* Mode. This doesn't begin to address two-player solo (6 arrows) */
return g_bCenter1Player &&
( bool ) ALLOW_CENTER_1_PLAYER &&
GAMESTATE -> m_PlayMode != PLAY_MODE_BATTLE &&
GAMESTATE -> m_PlayMode != PLAY_MODE_RAVE &&
2007-02-22 06:56:17 +00:00
GAMESTATE -> GetCurrentStyle () -> m_StyleType == StyleType_OnePlayerOneSide ;
2006-02-28 21:55:58 +00:00
}
2005-01-03 23:29:40 +00:00
//
// fill in m_apSongsQueue, m_vpStepsQueue, m_asModifiersQueue
//
void ScreenGameplay :: InitSongQueues ()
{
LOG -> Trace ( "InitSongQueues" );
2005-11-02 20:02:47 +00:00
2005-01-03 23:29:40 +00:00
if ( GAMESTATE -> IsCourseMode () )
{
Course * pCourse = GAMESTATE -> m_pCurCourse ;
ASSERT ( pCourse );
m_apSongsQueue . clear ();
PlayerNumber pnMaster = GAMESTATE -> m_MasterPlayerNumber ;
Trail * pTrail = GAMESTATE -> m_pCurTrail [ pnMaster ];
2005-01-31 04:41:25 +00:00
ASSERT ( pTrail );
2005-01-03 23:29:40 +00:00
FOREACH_CONST ( TrailEntry , pTrail -> m_vEntries , e )
2005-01-31 04:41:25 +00:00
{
ASSERT ( e -> pSong );
2005-01-03 23:29:40 +00:00
m_apSongsQueue . push_back ( e -> pSong );
2005-01-31 04:41:25 +00:00
}
2005-01-03 23:29:40 +00:00
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2005-01-03 23:29:40 +00:00
{
2005-08-23 21:38:51 +00:00
Trail * pTrail = GAMESTATE -> m_pCurTrail [ pi -> GetStepsAndTrailIndex () ];
2005-01-03 23:29:40 +00:00
ASSERT ( pTrail );
2005-08-23 21:38:51 +00:00
pi -> m_vpStepsQueue . clear ();
pi -> m_asModifiersQueue . clear ();
2005-01-03 23:29:40 +00:00
FOREACH_CONST ( TrailEntry , pTrail -> m_vEntries , e )
{
2006-11-12 03:26:25 +00:00
ASSERT ( e -> pSteps );
pi -> m_vpStepsQueue . push_back ( e -> pSteps );
2005-01-03 23:29:40 +00:00
AttackArray a ;
e -> GetAttackArray ( a );
2005-08-23 21:38:51 +00:00
pi -> m_asModifiersQueue . push_back ( a );
2005-01-03 23:29:40 +00:00
}
2005-11-02 20:02:47 +00:00
2006-01-18 21:07:25 +00:00
// In a survival course, override stored mods
2005-11-02 20:02:47 +00:00
if ( pCourse -> GetCourseType () == COURSE_TYPE_SURVIVAL )
{
2006-08-05 04:47:01 +00:00
pi -> GetPlayerState () -> m_PlayerOptions . FromString ( ModsLevel_Stage , "clearall," + CommonMetrics :: DEFAULT_MODIFIERS . GetValue () );
2005-11-02 20:02:47 +00:00
pi -> GetPlayerState () -> RebuildPlayerOptionsFromActiveAttacks ();
}
2005-01-03 23:29:40 +00:00
}
}
else
{
m_apSongsQueue . push_back ( GAMESTATE -> m_pCurSong );
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2005-01-03 23:29:40 +00:00
{
2005-08-23 21:38:51 +00:00
Steps * pSteps = GAMESTATE -> m_pCurSteps [ pi -> GetStepsAndTrailIndex () ];
pi -> m_vpStepsQueue . push_back ( pSteps );
2005-04-26 07:02:10 +00:00
AttackArray aa ;
2005-08-23 21:38:51 +00:00
pi -> m_asModifiersQueue . push_back ( aa );
2005-01-03 23:29:40 +00:00
}
}
2007-08-21 01:36:22 +00:00
2007-10-27 09:04:27 +00:00
if ( GAMESTATE -> m_bMultiplayer )
2007-08-21 01:36:22 +00:00
{
2007-10-27 09:04:27 +00:00
for ( int i = 0 ; i < ( int ) m_apSongsQueue . size (); i ++ )
2007-08-21 01:36:22 +00:00
{
2007-10-27 09:04:27 +00:00
Song * pSong = m_apSongsQueue [ i ];
2007-10-26 21:50:04 +00:00
2007-10-27 09:04:27 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2007-08-21 01:36:22 +00:00
{
2007-10-27 09:04:27 +00:00
Steps * pOldSteps = pi -> m_vpStepsQueue [ i ];
vector < Steps *> vpSteps ;
SongUtil :: GetSteps ( pSong , vpSteps , pOldSteps -> m_StepsType );
StepsUtil :: SortNotesArrayByDifficulty ( vpSteps );
vector < Steps *>:: iterator iter = find ( vpSteps . begin (), vpSteps . end (), pOldSteps );
int iIndexBase = 0 ;
if ( iter != vpSteps . end () )
{
iIndexBase = iter - vpSteps . begin ();
CLAMP ( iIndexBase , 0 , vpSteps . size () - GAMESTATE -> m_iNumMultiplayerNoteFields );
}
2007-10-26 21:50:04 +00:00
int iIndexToUse = iIndexBase + pi -> m_iAddToDifficulty ;
CLAMP ( iIndexToUse , 0 , vpSteps . size () - 1 );
Steps * pSteps = vpSteps [ iIndexToUse ];
2007-08-21 01:36:22 +00:00
pi -> m_vpStepsQueue [ i ] = pSteps ;
}
}
}
2005-01-03 23:29:40 +00:00
}
2002-05-20 08:59:37 +00:00
ScreenGameplay ::~ ScreenGameplay ()
{
2004-04-25 23:17:08 +00:00
if ( this -> IsFirstUpdate () )
{
/* We never received any updates. That means we were deleted without being
* used, and never actually played. (This can happen when backing out of
* ScreenStage.) Cancel the stage. */
GAMESTATE -> CancelStage ();
}
2002-07-31 19:40:40 +00:00
LOG -> Trace ( "ScreenGameplay::~ScreenGameplay()" );
2005-08-26 17:39:53 +00:00
2006-03-24 18:20:35 +00:00
SAFE_DELETE ( m_pSongBackground );
SAFE_DELETE ( m_pSongForeground );
2002-07-23 01:41:40 +00:00
2005-02-06 10:10:38 +00:00
if ( ! GAMESTATE -> m_bDemonstrationOrJukebox )
MEMCARDMAN -> UnPauseMountingThread ();
2005-02-06 08:48:55 +00:00
2003-06-30 18:08:27 +00:00
SAFE_DELETE ( m_pCombinedLifeMeter );
2004-11-05 06:36:49 +00:00
if ( m_pSoundMusic )
m_pSoundMusic -> StopPlaying ();
2003-05-13 13:35:32 +00:00
2007-01-25 00:50:57 +00:00
m_GameplayAssist . StopPlaying ();
2004-12-03 01:29:23 +00:00
NSMAN -> ReportSongOver ();
2002-05-20 08:59:37 +00:00
}
2002-07-28 20:28:37 +00:00
bool ScreenGameplay :: IsLastSong ()
2002-06-24 22:04:31 +00:00
{
2008-02-20 04:15:36 +00:00
if ( WORKOUTMAN -> m_pCurWorkout != NULL && GAMESTATE -> m_bWorkoutGoalComplete )
return true ;
2003-03-26 23:08:05 +00:00
if ( GAMESTATE -> m_pCurCourse && GAMESTATE -> m_pCurCourse -> m_bRepeat )
return false ;
2005-04-06 06:12:23 +00:00
return GAMESTATE -> GetCourseSongIndex () >= ( int ) m_apSongsQueue . size () - 1 ; // GetCourseSongIndex() is 0-based
2002-07-28 20:28:37 +00:00
}
2005-04-11 07:59:27 +00:00
void ScreenGameplay :: SetupSong ( int iSongIndex )
2003-12-23 02:18:27 +00:00
{
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2004-10-24 10:45:30 +00:00
{
2005-04-11 07:59:27 +00:00
/* This is the first beat that can be changed without it being visible. Until
* we draw for the first time, any beat can be changed. */
2005-08-23 21:38:51 +00:00
pi -> GetPlayerState () -> m_fLastDrawnBeat = - 100 ;
2007-07-12 11:01:25 +00:00
Steps * pSteps = pi -> m_vpStepsQueue [ iSongIndex ];
GAMESTATE -> m_pCurSteps [ pi -> GetStepsAndTrailIndex () ]. Set ( pSteps );
2004-10-24 10:45:30 +00:00
2005-04-11 07:59:27 +00:00
/* Load new NoteData into Player. Do this before
* RebuildPlayerOptionsFromActiveAttacks or else transform mods will get
2005-08-23 21:38:51 +00:00
* propogated to GAMESTATE->m_pPlayerOptions too early and be double-applied
2005-04-11 07:59:27 +00:00
* to the NoteData:
* once in Player::Load, then again in Player::ApplyActiveAttacks. This
* is very bad for transforms like AddMines.
*/
NoteData originalNoteData ;
2007-07-12 11:01:25 +00:00
pSteps -> GetNoteData ( originalNoteData );
2004-03-21 18:27:25 +00:00
2005-04-11 07:59:27 +00:00
const Style * pStyle = GAMESTATE -> GetCurrentStyle ();
NoteData ndTransformed ;
2005-08-23 21:38:51 +00:00
pStyle -> GetTransformedNoteDataForStyle ( pi -> GetStepsAndTrailIndex (), originalNoteData , ndTransformed );
2005-04-11 07:59:27 +00:00
2006-01-12 19:24:13 +00:00
// HACK: Apply NoteSkins from global course options. Do this before Player::Load,
// since it needs to know which note skin to load.
pi -> GetPlayerState () -> m_ModsToApply . clear ();
for ( unsigned i = 0 ; i < pi -> m_asModifiersQueue [ iSongIndex ]. size (); ++ i )
{
Attack a = pi -> m_asModifiersQueue [ iSongIndex ][ i ];
if ( a . fStartSecond != 0 )
continue ;
a . fStartSecond = - 1 ; // now
PlayerOptions po ;
po . FromString ( a . sModifiers );
if ( po . m_sNoteSkin . empty () )
continue ;
a . sModifiers = po . m_sNoteSkin ;
2006-01-13 05:22:02 +00:00
pi -> GetPlayerState () -> LaunchAttack ( a );
2006-01-12 19:24:13 +00:00
}
2007-06-10 23:47:35 +00:00
/* Update attack bOn flags, and rebuild Current-level options
* from Song-level options. The current NoteSkin could have changed
* because of an attack ending.
*/
pi -> GetPlayerState () -> Update ( 0 );
2005-04-11 07:59:27 +00:00
// load player
{
2006-07-17 00:58:33 +00:00
pi -> m_NoteData = ndTransformed ;
NoteDataUtil :: RemoveAllTapsOfType ( pi -> m_NoteData , TapNote :: autoKeysound );
pi -> m_pPlayer -> Load ();
2005-04-11 07:59:27 +00:00
}
// load auto keysounds
{
NoteData nd = ndTransformed ;
NoteDataUtil :: RemoveAllTapsExceptForType ( nd , TapNote :: autoKeysound );
2005-08-23 21:38:51 +00:00
m_AutoKeysounds . Load ( pi -> GetStepsAndTrailIndex (), nd );
2005-04-11 07:59:27 +00:00
}
2007-01-16 01:39:04 +00:00
{
RString sType ;
switch ( GAMESTATE -> m_SongOptions . GetCurrent (). m_SoundEffectType )
{
2007-01-16 02:15:10 +00:00
case SongOptions :: SOUNDEFFECT_OFF : sType = "SoundEffectControl_Off" ; break ;
2007-01-16 01:39:04 +00:00
case SongOptions :: SOUNDEFFECT_SPEED : sType = "SoundEffectControl_Speed" ; break ;
case SongOptions :: SOUNDEFFECT_PITCH : sType = "SoundEffectControl_Pitch" ; break ;
}
pi -> m_SoundEffectControl . Load ( sType , pi -> GetPlayerState (), & pi -> m_NoteData );
}
2005-04-11 07:59:27 +00:00
// Put course options into effect. Do this after Player::Load so
// that mods aren't double-applied.
2005-08-23 21:38:51 +00:00
pi -> GetPlayerState () -> m_ModsToApply . clear ();
for ( unsigned i = 0 ; i < pi -> m_asModifiersQueue [ iSongIndex ]. size (); ++ i )
2005-04-11 07:59:27 +00:00
{
2005-08-23 21:38:51 +00:00
Attack a = pi -> m_asModifiersQueue [ iSongIndex ][ i ];
2005-04-11 07:59:27 +00:00
if ( a . fStartSecond == 0 )
a . fStartSecond = - 1 ; // now
2006-01-13 05:22:02 +00:00
pi -> GetPlayerState () -> LaunchAttack ( a );
2006-08-05 04:47:01 +00:00
GAMESTATE -> m_SongOptions . FromString ( ModsLevel_Song , a . sModifiers );
2005-04-11 07:59:27 +00:00
}
/* Update attack bOn flags. */
2006-07-17 00:58:33 +00:00
pi -> GetPlayerState () -> Update ( 0 );
2005-04-11 07:59:27 +00:00
/* Hack: Course modifiers that are set to start immediately shouldn't tween on. */
2006-08-05 05:50:11 +00:00
pi -> GetPlayerState () -> m_PlayerOptions . SetCurrentToLevel ( ModsLevel_Stage );
2003-12-23 02:18:27 +00:00
}
}
2005-09-09 21:49:29 +00:00
void ScreenGameplay :: ReloadCurrentSong ()
{
FOREACH_EnabledPlayerInfoNotDummy ( m_vPlayerInfo , pi )
2006-11-14 11:13:21 +00:00
pi -> GetPlayerStageStats () -> m_iSongsPlayed -- ;
2005-09-09 21:49:29 +00:00
LoadNextSong ();
}
2003-01-25 07:40:47 +00:00
void ScreenGameplay :: LoadNextSong ()
2002-07-28 20:28:37 +00:00
{
GAMESTATE -> ResetMusicStatistics ();
2004-04-18 18:42:42 +00:00
2007-08-24 20:29:01 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2004-04-18 18:42:42 +00:00
{
2006-11-14 11:13:21 +00:00
pi -> GetPlayerStageStats () -> m_iSongsPlayed ++ ;
2005-08-23 21:38:51 +00:00
if ( pi -> m_ptextCourseSongNumber )
2006-11-14 11:13:21 +00:00
pi -> m_ptextCourseSongNumber -> SetText ( ssprintf ( "%d" , pi -> GetPlayerStageStats () -> m_iSongsPassed + 1 ) );
2004-04-18 18:42:42 +00:00
}
2003-02-24 02:45:01 +00:00
2006-01-11 02:25:23 +00:00
if ( GAMESTATE -> m_bMultiplayer )
2007-08-24 20:29:01 +00:00
{
FOREACH_ENUM ( MultiPlayer , mp )
this -> UpdateStageStats ( mp );
}
2006-01-11 02:25:23 +00:00
2003-03-26 23:08:05 +00:00
int iPlaySongIndex = GAMESTATE -> GetCourseSongIndex ();
iPlaySongIndex %= m_apSongsQueue . size ();
2005-02-24 12:27:30 +00:00
GAMESTATE -> m_pCurSong . Set ( m_apSongsQueue [ iPlaySongIndex ] );
2006-11-14 11:13:21 +00:00
STATSMAN -> m_CurStageStats . m_vpPlayedSongs . push_back ( GAMESTATE -> m_pCurSong );
2003-12-15 06:24:59 +00:00
2004-07-30 07:18:21 +00:00
// No need to do this here. We do it in SongFinished().
//GAMESTATE->RemoveAllActiveAttacks();
2006-08-06 02:11:48 +00:00
/* If we're in battery mode, force FailImmediate. We assume in Player::Step that
2004-08-25 08:56:58 +00:00
* failed players can't step. */
2006-08-05 02:38:05 +00:00
if ( GAMESTATE -> m_SongOptions . GetCurrent (). m_LifeType == SongOptions :: LIFE_BATTERY )
2007-05-12 23:48:29 +00:00
{
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
PO_GROUP_ASSIGN ( pi -> GetPlayerState () -> m_PlayerOptions , ModsLevel_Song , m_FailType , PlayerOptions :: FAIL_IMMEDIATE );
}
2004-08-25 08:56:58 +00:00
2006-08-05 02:38:05 +00:00
m_textSongOptions . SetText ( GAMESTATE -> m_SongOptions . GetCurrent (). GetString () );
2002-06-24 22:04:31 +00:00
2005-04-11 07:59:27 +00:00
SetupSong ( iPlaySongIndex );
2005-08-23 21:38:51 +00:00
Song * pSong = GAMESTATE -> m_pCurSong ;
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2002-06-14 22:25:22 +00:00
{
2005-08-23 21:38:51 +00:00
Steps * pSteps = GAMESTATE -> m_pCurSteps [ pi -> GetStepsAndTrailIndex () ];
2007-05-31 04:48:42 +00:00
++ pi -> GetPlayerStageStats () -> m_iStepsPlayed ;
2004-06-06 21:30:47 +00:00
2005-08-23 21:38:51 +00:00
ASSERT ( GAMESTATE -> m_pCurSteps [ pi -> GetStepsAndTrailIndex () ] );
if ( pi -> m_ptextStepsDescription )
pi -> m_ptextStepsDescription -> SetText ( pSteps -> GetDescription () );
2004-06-06 21:30:47 +00:00
/* Increment the play count even if the player fails. (It's still popular,
* even if the people playing it aren't good at it.) */
2005-01-03 23:20:11 +00:00
if ( ! GAMESTATE -> m_bDemonstrationOrJukebox )
2005-08-23 21:38:51 +00:00
{
if ( pi -> m_pn != PLAYER_INVALID )
PROFILEMAN -> IncrementStepsPlayCount ( pSong , pSteps , pi -> m_pn );
}
2004-06-06 21:30:47 +00:00
2005-08-23 21:38:51 +00:00
if ( pi -> m_ptextPlayerOptions )
2006-08-05 02:38:05 +00:00
pi -> m_ptextPlayerOptions -> SetText ( pi -> GetPlayerState () -> m_PlayerOptions . GetCurrent (). GetString () );
2005-08-23 21:38:51 +00:00
if ( pi -> m_pActiveAttackList )
pi -> m_pActiveAttackList -> Refresh ();
2004-06-06 21:30:47 +00:00
// reset oni game over graphic
2007-02-19 09:49:23 +00:00
SET_XY_AND_ON_COMMAND ( pi -> m_sprOniGameOver );
2004-06-06 21:30:47 +00:00
2006-11-14 11:13:21 +00:00
if ( GAMESTATE -> m_SongOptions . GetCurrent (). m_LifeType == SongOptions :: LIFE_BATTERY && pi -> GetPlayerStageStats () -> m_bFailed ) // already failed
2005-08-23 21:38:51 +00:00
pi -> ShowOniGameOver ();
2004-06-06 21:30:47 +00:00
2006-11-09 04:58:03 +00:00
if ( GAMESTATE -> m_SongOptions . GetCurrent (). m_LifeType == SongOptions :: LIFE_BAR && pi -> m_pLifeMeter )
pi -> m_pLifeMeter -> UpdateNonstopLifebar ();
2004-06-06 21:30:47 +00:00
2008-03-24 04:38:14 +00:00
if ( pi -> m_pDifficultyDisplay )
pi -> m_pDifficultyDisplay -> SetFromSteps ( pSteps );
2004-06-06 21:30:47 +00:00
/* The actual note data for scoring is the base class of Player. This includes
* transforms, like Wide. Otherwise, the scoring will operate on the wrong data. */
2005-08-23 21:38:51 +00:00
if ( pi -> m_pPrimaryScoreKeeper )
2006-07-17 00:58:33 +00:00
pi -> m_pPrimaryScoreKeeper -> OnNextSong ( GAMESTATE -> GetCourseSongIndex (), pSteps , & pi -> m_pPlayer -> GetNoteData () );
2005-08-23 21:38:51 +00:00
if ( pi -> m_pSecondaryScoreKeeper )
2006-07-17 00:58:33 +00:00
pi -> m_pSecondaryScoreKeeper -> OnNextSong ( GAMESTATE -> GetCourseSongIndex (), pSteps , & pi -> m_pPlayer -> GetNoteData () );
2004-06-06 21:30:47 +00:00
2005-08-23 21:38:51 +00:00
// Don't mess with the PlayerController of the Dummy player
if ( ! pi -> m_bIsDummy )
2004-06-06 21:30:47 +00:00
{
2005-08-23 21:38:51 +00:00
if ( GAMESTATE -> m_bDemonstrationOrJukebox )
{
pi -> GetPlayerState () -> m_PlayerController = PC_CPU ;
pi -> GetPlayerState () -> m_iCpuSkill = 5 ;
}
else if ( GAMESTATE -> IsCpuPlayer ( pi -> GetStepsAndTrailIndex ()) )
{
pi -> GetPlayerState () -> m_PlayerController = PC_CPU ;
int iMeter = pSteps -> GetMeter ();
int iNewSkill = SCALE ( iMeter , MIN_METER , MAX_METER , 0 , NUM_SKILL_LEVELS - 1 );
/* Watch out: songs aren't actually bound by MAX_METER. */
iNewSkill = clamp ( iNewSkill , 0 , NUM_SKILL_LEVELS - 1 );
pi -> GetPlayerState () -> m_iCpuSkill = iNewSkill ;
}
else
{
2006-11-21 05:02:55 +00:00
pi -> GetPlayerState () -> m_PlayerController = GamePreferences :: m_AutoPlay ;
2005-08-23 21:38:51 +00:00
}
}
2005-04-24 11:03:02 +00:00
}
2005-08-23 21:38:51 +00:00
bool bAllReverse = true ;
bool bAtLeastOneReverse = false ;
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2004-12-20 21:27:24 +00:00
{
2006-08-05 02:38:05 +00:00
if ( pi -> GetPlayerState () -> m_PlayerOptions . GetCurrent (). m_fScrolls [ PlayerOptions :: SCROLL_REVERSE ] == 1 )
2005-08-23 21:38:51 +00:00
bAtLeastOneReverse = true ;
else
bAllReverse = false ;
}
2003-02-28 20:50:28 +00:00
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2003-02-28 20:50:28 +00:00
{
2006-08-05 02:38:05 +00:00
bool bReverse = pi -> GetPlayerState () -> m_PlayerOptions . GetCurrent (). m_fScrolls [ PlayerOptions :: SCROLL_REVERSE ] == 1 ;
2004-05-31 06:04:30 +00:00
2008-03-24 04:38:14 +00:00
if ( pi -> m_pDifficultyDisplay )
pi -> m_pDifficultyDisplay -> PlayCommand ( bReverse ? "SetReverse" : "SetNoReverse" );
2003-02-28 20:50:28 +00:00
}
2007-03-03 04:54:22 +00:00
m_LyricDisplay . PlayCommand ( bAllReverse ? "SetReverse" : bAtLeastOneReverse ? "SetOneReverse" : "SetNoReverse" );
2003-06-04 20:40:32 +00:00
2003-03-19 19:58:22 +00:00
// Load lyrics
// XXX: don't load this here
2003-03-20 18:51:14 +00:00
LyricsLoader LL ;
if ( GAMESTATE -> m_pCurSong -> HasLyrics () )
LL . LoadFromLRCFile ( GAMESTATE -> m_pCurSong -> GetLyricsPath (), * GAMESTATE -> m_pCurSong );
2003-04-13 00:44:50 +00:00
/* Set up song-specific graphics. */
2003-08-20 09:19:46 +00:00
2003-08-27 13:36:22 +00:00
// Check to see if any players are in beginner mode.
// Note: steps can be different if turn modifiers are used.
2003-12-02 19:11:51 +00:00
if ( PREFSMAN -> m_bShowBeginnerHelper )
2003-08-24 23:18:20 +00:00
{
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerNumberInfo ( m_vPlayerInfo , pi )
2004-04-18 18:42:42 +00:00
{
2007-04-01 06:55:01 +00:00
PlayerNumber pn = pi -> GetStepsAndTrailIndex ();
if ( GAMESTATE -> IsHumanPlayer ( pn ) && GAMESTATE -> m_pCurSteps [ pn ] -> GetDifficulty () == Difficulty_Beginner )
m_BeginnerHelper . AddPlayer ( pn , pi -> m_pPlayer -> GetNoteData () );
2004-04-18 18:42:42 +00:00
}
2003-12-02 19:11:51 +00:00
}
2003-08-27 13:36:22 +00:00
2006-02-04 18:37:26 +00:00
if ( m_pSongBackground )
m_pSongBackground -> Unload ();
2005-03-11 02:06:39 +00:00
if ( ! PREFSMAN -> m_bShowBeginnerHelper || ! m_BeginnerHelper . Initialize ( 2 ) )
2003-12-02 19:11:51 +00:00
{
2007-02-13 06:32:26 +00:00
m_BeginnerHelper . SetVisible ( false );
2005-03-11 02:06:39 +00:00
/* BeginnerHelper disabled, or failed to load. */
2006-02-04 18:37:26 +00:00
if ( m_pSongBackground )
m_pSongBackground -> LoadFromSong ( GAMESTATE -> m_pCurSong );
2005-03-11 02:06:39 +00:00
2005-01-03 23:20:11 +00:00
if ( ! GAMESTATE -> m_bDemonstrationOrJukebox )
2004-04-19 20:28:10 +00:00
{
/* This will fade from a preset brightness to the actual brightness (based
* on prefs and "cover"). The preset brightness may be 0 (to fade from
* black), or it might be 1, if the stage screen has the song BG and we're
* coming from it (like Pump). This used to be done in SM_PlayReady, but
* that means it's impossible to snap to the new brightness immediately. */
2006-02-04 18:37:26 +00:00
if ( m_pSongBackground )
{
m_pSongBackground -> SetBrightness ( INITIAL_BACKGROUND_BRIGHTNESS );
m_pSongBackground -> FadeToActualBrightness ();
}
2004-04-19 20:28:10 +00:00
}
2003-08-20 09:19:46 +00:00
}
2005-03-11 02:06:39 +00:00
else
2005-04-21 04:27:13 +00:00
{
2007-02-13 06:32:26 +00:00
m_BeginnerHelper . SetVisible ( true );
2005-04-21 04:27:13 +00:00
}
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2005-04-21 04:27:13 +00:00
{
2006-11-14 11:13:21 +00:00
if ( ! pi -> GetPlayerStageStats () -> m_bFailed )
2005-04-21 04:27:13 +00:00
{
// give a little life back between stages
2005-08-23 21:38:51 +00:00
if ( pi -> m_pLifeMeter )
pi -> m_pLifeMeter -> OnLoadSong ();
if ( pi -> m_pPrimaryScoreDisplay )
pi -> m_pPrimaryScoreDisplay -> OnLoadSong ();
if ( pi -> m_pSecondaryScoreDisplay )
pi -> m_pSecondaryScoreDisplay -> OnLoadSong ();
2005-04-21 04:27:13 +00:00
}
}
2005-04-21 11:16:01 +00:00
if ( m_pCombinedLifeMeter )
m_pCombinedLifeMeter -> OnLoadSong ();
2005-04-21 04:27:13 +00:00
2003-08-20 09:19:46 +00:00
2006-02-04 18:37:26 +00:00
if ( m_pSongBackground )
m_pSongForeground -> LoadFromSong ( GAMESTATE -> m_pCurSong );
2003-04-13 00:44:50 +00:00
2004-02-16 05:29:33 +00:00
m_fTimeSinceLastDancingComment = 0 ;
2003-08-07 07:34:42 +00:00
2006-02-04 18:37:26 +00:00
/* m_soundMusic and m_pSongBackground take a very long time to load,
2005-03-19 00:03:53 +00:00
* so cap fDelta at 0 so m_NextSong will show up on screen.
2003-08-01 11:41:13 +00:00
* -Chris */
2003-04-13 00:44:50 +00:00
m_bZeroDeltaOnNextUpdate = true ;
2005-05-07 09:58:23 +00:00
SCREENMAN -> ZeroNextUpdate ();
2004-03-30 07:44:29 +00:00
//
2004-04-22 05:25:58 +00:00
// Load cabinet lights data
2004-03-30 07:44:29 +00:00
//
2005-05-04 06:48:34 +00:00
LoadLights ();
2005-03-18 07:08:05 +00:00
/* Load the music last, since it may start streaming and we don't want the music
* to compete with other loading. */
m_AutoKeysounds . FinishLoading ();
m_pSoundMusic = m_AutoKeysounds . GetSound ();
2007-01-16 01:39:04 +00:00
/* Give SoundEffectControls the new RageSoundReaders. */
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
{
2007-04-24 05:53:41 +00:00
RageSoundReader * pPlayerSound = m_AutoKeysounds . GetPlayerSound ( pi -> m_pn );
if ( pPlayerSound == NULL && pi -> m_pn == GAMESTATE -> m_MasterPlayerNumber )
pPlayerSound = m_AutoKeysounds . GetSharedSound ();
pi -> m_SoundEffectControl . SetSoundReader ( pPlayerSound );
2007-01-16 01:39:04 +00:00
}
2007-10-26 10:09:43 +00:00
MESSAGEMAN -> Broadcast ( "DoneLoadingNextSong" );
2003-01-25 07:40:47 +00:00
}
2005-05-04 06:48:34 +00:00
void ScreenGameplay :: LoadLights ()
{
if ( ! LIGHTSMAN -> IsEnabled () )
return ;
2005-06-02 21:47:27 +00:00
//
// First, check if the song has explicit lights
//
2005-05-04 06:48:34 +00:00
m_CabinetLightsNoteData . Init ();
ASSERT ( GAMESTATE -> m_pCurSong );
2007-02-22 07:18:05 +00:00
const Steps * pSteps = SongUtil :: GetClosestNotes ( GAMESTATE -> m_pCurSong , STEPS_TYPE_LIGHTS_CABINET , Difficulty_Medium );
2005-05-04 06:48:34 +00:00
if ( pSteps != NULL )
{
pSteps -> GetNoteData ( m_CabinetLightsNoteData );
2005-05-04 06:53:25 +00:00
return ;
2005-05-04 06:48:34 +00:00
}
2005-05-04 06:53:25 +00:00
2005-06-02 21:47:27 +00:00
//
// No explicit lights. Create autogen lights.
//
2006-01-22 01:00:06 +00:00
RString sDifficulty = PREFSMAN -> m_sLightsStepsDifficulty ;
vector < RString > asDifficulties ;
2005-05-04 08:20:12 +00:00
split ( sDifficulty , "," , asDifficulties );
2006-10-07 04:39:48 +00:00
Difficulty d1 = Difficulty_Invalid ;
2005-05-04 08:20:12 +00:00
if ( asDifficulties . size () > 0 )
d1 = StringToDifficulty ( asDifficulties [ 0 ] );
2006-06-13 01:10:37 +00:00
pSteps = SongUtil :: GetClosestNotes ( GAMESTATE -> m_pCurSong , GAMESTATE -> GetCurrentStyle () -> m_StepsType , d1 );
2005-05-04 08:20:12 +00:00
// If we can't find anything at all, stop.
if ( pSteps == NULL )
return ;
NoteData TapNoteData1 ;
pSteps -> GetNoteData ( TapNoteData1 );
if ( asDifficulties . size () > 1 )
{
Difficulty d2 = StringToDifficulty ( asDifficulties [ 1 ] );
2006-06-13 01:10:37 +00:00
const Steps * pSteps2 = SongUtil :: GetClosestNotes ( GAMESTATE -> m_pCurSong , GAMESTATE -> GetCurrentStyle () -> m_StepsType , d2 );
2005-05-04 08:20:12 +00:00
if ( pSteps != NULL && pSteps2 != NULL && pSteps != pSteps2 )
{
NoteData TapNoteData2 ;
pSteps2 -> GetNoteData ( TapNoteData2 );
NoteDataUtil :: LoadTransformedLightsFromTwo ( TapNoteData1 , TapNoteData2 , m_CabinetLightsNoteData );
return ;
}
/* fall through */
}
2008-03-24 08:53:05 +00:00
NoteDataUtil :: LoadTransformedLights ( TapNoteData1 , m_CabinetLightsNoteData , GameManager :: GetStepsTypeInfo ( STEPS_TYPE_LIGHTS_CABINET ). iNumTracks );
2005-05-04 06:48:34 +00:00
}
2007-02-26 00:53:27 +00:00
void ScreenGameplay :: StartPlayingSong ( float fMinTimeToNotes , float fMinTimeToMusic )
2003-01-25 07:40:47 +00:00
{
2007-02-26 00:41:31 +00:00
ASSERT ( fMinTimeToNotes >= 0 );
ASSERT ( fMinTimeToMusic >= 0 );
2003-01-25 08:32:57 +00:00
2006-12-10 08:59:13 +00:00
m_pSoundMusic -> SetProperty ( "AccurateSync" , true );
2004-02-28 02:09:46 +00:00
RageSoundParams p ;
2006-11-30 07:32:38 +00:00
p . m_fSpeed = GAMESTATE -> m_SongOptions . GetCurrent (). m_fMusicRate ;
2004-02-28 02:09:46 +00:00
p . StopMode = RageSoundParams :: M_CONTINUE ;
2007-02-26 01:09:02 +00:00
{
const float fFirstBeat = GAMESTATE -> m_pCurSong -> m_fFirstBeat ;
const float fFirstSecond = GAMESTATE -> m_pCurSong -> GetElapsedTimeFromBeat ( fFirstBeat );
float fStartDelay = fMinTimeToNotes - fFirstSecond ;
fStartDelay = max ( fStartDelay , fMinTimeToMusic );
p . m_StartSecond = - fStartDelay ;
}
2004-02-28 02:09:46 +00:00
2005-02-24 21:44:08 +00:00
ASSERT ( ! m_pSoundMusic -> IsPlaying () );
2007-05-01 02:25:38 +00:00
{
float fSecondsToStartFadingOutMusic , fSecondsToStartTransitioningOut ;
GetMusicEndTiming ( fSecondsToStartFadingOutMusic , fSecondsToStartTransitioningOut );
if ( fSecondsToStartFadingOutMusic < GAMESTATE -> m_pCurSong -> m_fMusicLengthSeconds )
{
p . m_fFadeOutSeconds = MUSIC_FADE_OUT_SECONDS ;
p . m_LengthSeconds = fSecondsToStartFadingOutMusic + MUSIC_FADE_OUT_SECONDS - p . m_StartSecond ;
}
}
2004-10-25 03:47:22 +00:00
m_pSoundMusic -> Play ( & p );
2005-04-16 03:46:14 +00:00
if ( m_bPaused )
m_pSoundMusic -> Pause ( true );
2003-01-25 07:40:47 +00:00
2004-01-29 05:20:27 +00:00
/* Make sure GAMESTATE->m_fMusicSeconds is set up. */
GAMESTATE -> m_fMusicSeconds = - 5000 ;
2004-05-21 00:58:48 +00:00
UpdateSongPosition ( 0 );
2004-01-29 05:20:27 +00:00
ASSERT ( GAMESTATE -> m_fMusicSeconds > - 4000 ); /* make sure the "fake timer" code doesn't trigger */
2002-06-14 22:25:22 +00:00
}
2005-03-11 02:52:40 +00:00
2005-04-21 02:07:02 +00:00
void ScreenGameplay :: PauseGame ( bool bPause , GameController gc )
2005-03-11 02:52:40 +00:00
{
if ( m_bPaused == bPause )
{
LOG -> Trace ( "ScreenGameplay::PauseGame(%i) received, but already in that state; ignored" , bPause );
return ;
}
2005-03-11 04:12:48 +00:00
/* Don't pause if we're already tweening out. */
if ( bPause && m_DancingState == STATE_OUTRO )
return ;
2005-04-01 02:34:22 +00:00
AbortGiveUp ( false );
2005-03-11 04:12:48 +00:00
2005-03-11 02:52:40 +00:00
m_bPaused = bPause ;
2005-04-21 02:07:02 +00:00
m_PauseController = gc ;
2005-03-11 02:52:40 +00:00
m_pSoundMusic -> Pause ( bPause );
2005-03-11 03:33:41 +00:00
if ( bPause )
this -> PlayCommand ( "Pause" );
else
this -> PlayCommand ( "Unpause" );
2005-03-11 03:54:40 +00:00
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
{
pi -> m_pPlayer -> SetPaused ( m_bPaused );
}
2005-03-11 02:52:40 +00:00
}
2002-10-12 00:32:47 +00:00
// play assist ticks
2004-01-12 09:36:01 +00:00
void ScreenGameplay :: PlayTicks ()
2002-10-12 00:32:47 +00:00
{
2005-08-23 21:38:51 +00:00
Player & player = * m_vPlayerInfo [ 0 ]. m_pPlayer ;
2006-07-17 00:58:33 +00:00
const NoteData & nd = player . GetNoteData ();
2007-01-25 00:50:57 +00:00
m_GameplayAssist . PlayTicks ( nd );
2002-10-12 00:32:47 +00:00
}
2002-06-14 22:25:22 +00:00
2004-02-16 05:29:33 +00:00
/* Play announcer "type" if it's been at least fSeconds since the last announcer. */
2006-01-22 01:00:06 +00:00
void ScreenGameplay :: PlayAnnouncer ( RString type , float fSeconds )
2004-02-16 05:29:33 +00:00
{
if ( GAMESTATE -> m_fOpponentHealthPercent == 0 )
return ; // Shut the announcer up
2004-03-08 04:30:57 +00:00
/* Don't play in demonstration. */
if ( GAMESTATE -> m_bDemonstrationOrJukebox )
return ;
2004-02-16 05:29:33 +00:00
/* Don't play before the first beat, or after we're finished. */
if ( m_DancingState != STATE_DANCING )
return ;
2004-02-21 17:21:03 +00:00
if ( GAMESTATE -> m_pCurSong == NULL || // this will be true on ScreenDemonstration sometimes
GAMESTATE -> m_fSongBeat < GAMESTATE -> m_pCurSong -> m_fFirstBeat )
2004-02-16 05:29:33 +00:00
return ;
if ( m_fTimeSinceLastDancingComment < fSeconds )
return ;
m_fTimeSinceLastDancingComment = 0 ;
2004-04-12 20:11:36 +00:00
SOUND -> PlayOnceFromAnnouncer ( type );
2004-02-16 05:29:33 +00:00
}
2002-10-29 01:26:10 +00:00
2004-05-21 00:58:48 +00:00
void ScreenGameplay :: UpdateSongPosition ( float fDeltaTime )
{
2004-10-25 03:47:22 +00:00
if ( ! m_pSoundMusic -> IsPlaying () )
2004-05-21 00:58:48 +00:00
return ;
RageTimer tm ;
2004-10-25 03:47:22 +00:00
const float fSeconds = m_pSoundMusic -> GetPositionSeconds ( NULL , & tm );
2004-05-21 00:58:48 +00:00
const float fAdjust = SOUND -> GetFrameTimingAdjustment ( fDeltaTime );
GAMESTATE -> UpdateSongPosition ( fSeconds + fAdjust , GAMESTATE -> m_pCurSong -> m_Timing , tm + fAdjust );
}
2006-01-18 20:45:05 +00:00
void ScreenGameplay :: BeginScreen ()
{
if ( GAMESTATE -> m_pCurSong == NULL )
return ;
2006-02-07 08:12:47 +00:00
ScreenWithMenuElements :: BeginScreen ();
2006-01-18 20:45:05 +00:00
SOUND -> PlayOnceFromAnnouncer ( "gameplay intro" ); // crowd cheer
//
// Get the transitions rolling
//
if ( GAMESTATE -> m_bDemonstrationOrJukebox )
{
2007-02-26 01:46:50 +00:00
StartPlayingSong ( MIN_SECONDS_TO_STEP , MIN_SECONDS_TO_MUSIC );
2006-01-18 20:45:05 +00:00
}
else if ( NSMAN -> useSMserver )
{
//If we're using networking, we must not have any
//delay. If we do this can cause inconsistancy
//on different computers and differet themes
StartPlayingSong ( 0 , 0 );
m_pSoundMusic -> Stop ();
float startOffset = g_fNetStartOffset ;
NSMAN -> StartRequest ( 1 );
RageSoundParams p ;
2006-11-30 07:32:38 +00:00
p . m_fSpeed = 1.0f ; //Force 1.0 playback speed
2006-01-18 20:45:05 +00:00
p . StopMode = RageSoundParams :: M_CONTINUE ;
p . m_StartSecond = startOffset ;
2006-12-10 08:59:13 +00:00
m_pSoundMusic -> SetProperty ( "AccurateSync" , true );
2006-01-18 20:45:05 +00:00
m_pSoundMusic -> Play ( & p );
UpdateSongPosition ( 0 );
}
else
{
2007-02-26 01:46:50 +00:00
StartPlayingSong ( MIN_SECONDS_TO_STEP , MIN_SECONDS_TO_MUSIC );
2006-01-18 20:45:05 +00:00
}
}
2006-11-09 06:10:19 +00:00
bool ScreenGameplay :: AllAreFailing ()
{
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
{
if ( pi -> m_pLifeMeter && ! pi -> m_pLifeMeter -> IsFailing () )
return false ;
}
return true ;
}
2007-05-01 02:25:38 +00:00
void ScreenGameplay :: GetMusicEndTiming ( float & fSecondsToStartFadingOutMusic , float & fSecondsToStartTransitioningOut )
{
float fLastStepSeconds = GAMESTATE -> m_pCurSong -> GetElapsedTimeFromBeat ( GAMESTATE -> m_pCurSong -> m_fLastBeat );
fLastStepSeconds += Player :: GetMaxStepDistanceSeconds ();
float fTransitionLength ;
if ( ! GAMESTATE -> IsCourseMode () || IsLastSong () )
fTransitionLength = OUT_TRANSITION_LENGTH ;
else
fTransitionLength = COURSE_TRANSITION_LENGTH ;
fSecondsToStartTransitioningOut = fLastStepSeconds ;
// Align the end of the music fade to the end of the transition.
float fSecondsToFinishFadingOutMusic = fSecondsToStartTransitioningOut + fTransitionLength ;
if ( fSecondsToFinishFadingOutMusic < GAMESTATE -> m_pCurSong -> m_fMusicLengthSeconds )
fSecondsToStartFadingOutMusic = fSecondsToFinishFadingOutMusic - MUSIC_FADE_OUT_SECONDS ;
else
fSecondsToStartFadingOutMusic = GAMESTATE -> m_pCurSong -> m_fMusicLengthSeconds ; // don't fade
/* Make sure we keep going long enough to register a miss for the last note, and
* never start fading before the last note. */
fSecondsToStartFadingOutMusic = max ( fSecondsToStartFadingOutMusic , fLastStepSeconds );
fSecondsToStartTransitioningOut = max ( fSecondsToStartTransitioningOut , fLastStepSeconds );
/* Make sure the fade finishes before the transition finishes. */
fSecondsToStartTransitioningOut = max ( fSecondsToStartTransitioningOut , fSecondsToStartFadingOutMusic + MUSIC_FADE_OUT_SECONDS - fTransitionLength );
}
2002-05-20 08:59:37 +00:00
void ScreenGameplay :: Update ( float fDeltaTime )
{
2003-03-24 21:26:12 +00:00
if ( GAMESTATE -> m_pCurSong == NULL )
{
/* ScreenDemonstration will move us to the next screen. We just need to
* survive for one update without crashing. We need to call Screen::Update
* to make sure we receive the next-screen message. */
Screen :: Update ( fDeltaTime );
return ;
}
2004-05-21 00:58:48 +00:00
UpdateSongPosition ( fDeltaTime );
2003-04-13 00:44:50 +00:00
if ( m_bZeroDeltaOnNextUpdate )
{
Screen :: Update ( 0 );
m_bZeroDeltaOnNextUpdate = false ;
}
else
2004-10-24 10:20:24 +00:00
{
2003-04-13 00:44:50 +00:00
Screen :: Update ( fDeltaTime );
2004-10-24 10:20:24 +00:00
}
2003-02-10 22:08:10 +00:00
2004-02-16 05:30:31 +00:00
/* This happens if ScreenDemonstration::HandleScreenMessage sets a new screen when
* PREFSMAN->m_bDelayedScreenLoad. */
2003-03-24 21:29:06 +00:00
if ( GAMESTATE -> m_pCurSong == NULL )
return ;
2004-02-16 05:30:31 +00:00
/* This can happen if ScreenDemonstration::HandleScreenMessage sets a new screen when
* !PREFSMAN->m_bDelayedScreenLoad. (The new screen was loaded when we called Screen::Update,
* and the ctor might set a new GAMESTATE->m_pCurSong, so the above check can fail.) */
if ( SCREENMAN -> GetTopScreen () != this )
return ;
2003-02-10 22:08:10 +00:00
2005-03-11 03:54:40 +00:00
/* Update actors when paused, but never move on to another state. */
if ( m_bPaused )
return ;
2002-07-31 19:40:40 +00:00
//LOG->Trace( "m_fOffsetInBeats = %f, m_fBeatsPerSecond = %f, m_Music.GetPositionSeconds = %f", m_fOffsetInBeats, m_fBeatsPerSecond, m_Music.GetPositionSeconds() );
2002-05-20 08:59:37 +00:00
2004-10-24 10:45:30 +00:00
m_AutoKeysounds . Update ( fDeltaTime );
2004-06-08 07:16:28 +00:00
2003-12-07 20:29:42 +00:00
//
// update GameState HealthState
//
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2003-12-07 20:29:42 +00:00
{
2007-02-25 08:23:50 +00:00
HealthState & hs = pi -> GetPlayerState () -> m_HealthState ;
2007-02-25 08:51:41 +00:00
HealthState OldHealthState = hs ;
2007-05-12 23:48:29 +00:00
if ( GAMESTATE -> GetPlayerFailType ( pi -> GetPlayerState ()) != PlayerOptions :: FAIL_OFF &&
2006-11-09 06:26:28 +00:00
pi -> m_pLifeMeter && pi -> m_pLifeMeter -> IsFailing () )
2004-06-08 07:16:28 +00:00
{
2007-02-25 08:23:50 +00:00
hs = HealthState_Dead ;
2004-06-08 07:16:28 +00:00
}
2006-11-09 05:45:10 +00:00
else if ( pi -> m_pLifeMeter && pi -> m_pLifeMeter -> IsHot () )
2003-12-07 20:29:42 +00:00
{
2007-02-25 08:23:50 +00:00
hs = HealthState_Hot ;
2004-05-16 12:34:02 +00:00
}
2007-05-12 23:48:29 +00:00
else if ( GAMESTATE -> GetPlayerFailType ( pi -> GetPlayerState ()) != PlayerOptions :: FAIL_OFF &&
2006-11-09 06:26:28 +00:00
pi -> m_pLifeMeter && pi -> m_pLifeMeter -> IsInDanger () )
2004-05-16 12:34:02 +00:00
{
2007-02-25 08:23:50 +00:00
hs = HealthState_Danger ;
2004-05-16 12:34:02 +00:00
}
else
{
2007-02-25 08:23:50 +00:00
hs = HealthState_Alive ;
2003-12-07 20:29:42 +00:00
}
2007-02-25 08:51:41 +00:00
if ( hs != OldHealthState )
{
Message msg ( "HealthStateChanged" );
msg . SetParam ( "PlayerNumber" , pi -> m_pn );
msg . SetParam ( "HealthState" , hs );
MESSAGEMAN -> Broadcast ( msg );
}
2007-01-16 01:39:04 +00:00
pi -> m_SoundEffectControl . Update ( fDeltaTime );
2003-12-07 20:29:42 +00:00
}
2006-11-30 08:22:30 +00:00
{
2007-06-12 18:33:32 +00:00
float fSpeed = GAMESTATE -> m_SongOptions . GetCurrent (). m_fMusicRate ;
if ( GAMESTATE -> m_SongOptions . GetCurrent (). m_fHaste != 0.0f )
fSpeed *= GetHasteRate ();
2006-11-30 08:22:30 +00:00
RageSoundParams p = m_pSoundMusic -> GetParams ();
2007-06-12 18:33:32 +00:00
if ( fabsf ( p . m_fSpeed - fSpeed ) > 0.01f )
{
p . m_fSpeed = fSpeed ;
m_pSoundMusic -> SetParams ( p );
}
2006-11-30 08:22:30 +00:00
}
2004-06-08 07:16:28 +00:00
2002-05-20 08:59:37 +00:00
switch ( m_DancingState )
{
case STATE_DANCING :
2005-02-16 03:25:45 +00:00
/* Set STATSMAN->m_CurStageStats.bFailed for failed players. In, FAIL_IMMEDIATE, send
2005-05-09 02:58:30 +00:00
* SM_BeginFailed if all players failed, and kill dead Oni players. */
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2004-06-11 20:09:53 +00:00
{
2005-08-23 21:38:51 +00:00
PlayerNumber pn = pi -> GetStepsAndTrailIndex ();
2007-05-12 23:48:29 +00:00
PlayerOptions :: FailType ft = GAMESTATE -> GetPlayerFailType ( pi -> GetPlayerState () );
2006-08-05 02:38:05 +00:00
SongOptions :: LifeType lt = GAMESTATE -> m_SongOptions . GetCurrent (). m_LifeType ;
2005-04-08 00:53:17 +00:00
2007-05-12 23:48:29 +00:00
if ( ft == PlayerOptions :: FAIL_OFF || ft == PlayerOptions :: FAIL_AT_END )
2005-04-05 08:30:57 +00:00
continue ;
2004-06-11 20:09:53 +00:00
2005-04-05 08:30:57 +00:00
// check for individual fail
2005-08-23 21:38:51 +00:00
if ( pi -> m_pLifeMeter == NULL || ! pi -> m_pLifeMeter -> IsFailing () )
2005-04-05 08:30:57 +00:00
continue ; /* isn't failing */
2006-11-14 11:13:21 +00:00
if ( pi -> GetPlayerStageStats () -> m_bFailed )
2005-04-05 08:30:57 +00:00
continue ; /* failed and is already dead */
LOG -> Trace ( "Player %d failed" , ( int ) pn );
2006-11-14 11:13:21 +00:00
pi -> GetPlayerStageStats () -> m_bFailed = true ; // fail
2004-06-11 20:09:53 +00:00
2007-03-07 04:51:38 +00:00
{
Message msg ( "PlayerFailed" );
msg . SetParam ( "PlayerNumber" , pi -> m_pn );
MESSAGEMAN -> Broadcast ( msg );
}
2005-05-09 02:58:30 +00:00
//
// Check for and do Oni die.
//
bool bAllowOniDie = false ;
switch ( lt )
{
case SongOptions :: LIFE_BATTERY :
bAllowOniDie = true ;
break ;
}
2007-05-12 23:48:29 +00:00
if ( bAllowOniDie && ft == PlayerOptions :: FAIL_IMMEDIATE )
2005-04-05 08:30:57 +00:00
{
2006-11-09 08:18:58 +00:00
if ( ! STATSMAN -> m_CurStageStats . AllFailed () ) // if not the last one to fail
2004-06-11 20:09:53 +00:00
{
2005-04-05 08:30:57 +00:00
// kill them!
SOUND -> PlayOnceFromDir ( THEME -> GetPathS ( m_sName , "oni die" ) );
2005-08-23 21:38:51 +00:00
pi -> ShowOniGameOver ();
2006-07-17 00:58:33 +00:00
pi -> m_NoteData . Init (); // remove all notes and scoring
2005-08-23 21:38:51 +00:00
pi -> m_pPlayer -> FadeToFail (); // tell the NoteField to fade to white
2004-06-11 20:09:53 +00:00
}
}
}
2005-04-05 08:30:57 +00:00
bool bAllFailed = true ;
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2005-02-17 21:30:10 +00:00
{
2007-05-12 23:48:29 +00:00
PlayerOptions :: FailType ft = GAMESTATE -> GetPlayerFailType ( pi -> GetPlayerState () );
2005-04-05 08:30:57 +00:00
switch ( ft )
{
2007-05-12 23:48:29 +00:00
case PlayerOptions :: FAIL_IMMEDIATE :
2007-08-24 20:29:01 +00:00
if ( pi -> m_pLifeMeter == NULL || ( pi -> m_pLifeMeter && ! pi -> m_pLifeMeter -> IsFailing ()) )
2005-04-05 08:30:57 +00:00
bAllFailed = false ;
break ;
2007-05-12 23:48:29 +00:00
case PlayerOptions :: FAIL_IMMEDIATE_CONTINUE :
case PlayerOptions :: FAIL_AT_END :
2005-04-05 08:30:57 +00:00
bAllFailed = false ; // wait until the end of the song to fail.
break ;
2007-05-12 23:48:29 +00:00
case PlayerOptions :: FAIL_OFF :
2005-04-05 08:30:57 +00:00
bAllFailed = false ; // never fail.
break ;
default :
ASSERT ( 0 );
}
2005-02-17 21:30:10 +00:00
}
2005-04-05 08:30:57 +00:00
if ( bAllFailed )
2007-05-01 19:43:41 +00:00
{
m_pSoundMusic -> StopPlaying ();
SCREENMAN -> PostMessageToTopScreen ( SM_NotesEnded , 0 );
}
2004-06-11 20:09:53 +00:00
2003-01-24 02:43:07 +00:00
//
2003-03-30 20:54:37 +00:00
// Update living players' alive time
2003-01-24 02:43:07 +00:00
//
2006-09-21 01:58:30 +00:00
// HACK: Don't scale alive time when ussing tab/tilde. Instead of accumulating time from a timer,
// this time should instead be tied to the music position.
float fUnscaledDeltaTime = m_timerGameplaySeconds . GetDeltaTime ();
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2006-11-14 11:13:21 +00:00
if ( ! pi -> GetPlayerStageStats () -> m_bFailed )
pi -> GetPlayerStageStats () -> m_fAliveSeconds += fUnscaledDeltaTime * GAMESTATE -> m_SongOptions . GetCurrent (). m_fMusicRate ;
2003-01-24 02:43:07 +00:00
2003-12-09 10:20:18 +00:00
// update fGameplaySeconds
2006-11-14 11:13:21 +00:00
STATSMAN -> m_CurStageStats . m_fGameplaySeconds += fUnscaledDeltaTime ;
2005-04-23 02:50:26 +00:00
if ( GAMESTATE -> m_fSongBeat >= GAMESTATE -> m_pCurSong -> m_fFirstBeat && GAMESTATE -> m_fSongBeat < GAMESTATE -> m_pCurSong -> m_fLastBeat )
2007-03-18 19:38:11 +00:00
{
2006-11-14 11:13:21 +00:00
STATSMAN -> m_CurStageStats . m_fStepsSeconds += fUnscaledDeltaTime ;
2003-12-09 10:20:18 +00:00
2007-03-18 19:38:11 +00:00
if ( GAMESTATE -> m_SongOptions . GetCurrent (). m_fHaste != 0.0f )
{
float fHasteRate = GetHasteRate ();
2007-04-26 00:56:37 +00:00
GAMESTATE -> m_fAccumulatedHasteSeconds += ( fUnscaledDeltaTime * fHasteRate ) - fUnscaledDeltaTime ;
2007-03-18 19:38:11 +00:00
}
}
2002-07-27 19:29:51 +00:00
//
2002-05-20 08:59:37 +00:00
// Check for end of song
2002-07-27 19:29:51 +00:00
//
2007-05-01 02:25:38 +00:00
{
float fSecondsToStartFadingOutMusic , fSecondsToStartTransitioningOut ;
GetMusicEndTiming ( fSecondsToStartFadingOutMusic , fSecondsToStartTransitioningOut );
2007-05-01 19:43:41 +00:00
bool bAllReallyFailed = STATSMAN -> m_CurStageStats . AllFailed ();
if ( bAllReallyFailed )
fSecondsToStartTransitioningOut += BEGIN_FAILED_DELAY ;
if ( GAMESTATE -> m_fMusicSeconds >= fSecondsToStartTransitioningOut && ! m_NextSong . IsTransitioning () )
this -> PostScreenMessage ( SM_NotesEnded , 0 );
2007-05-01 02:25:38 +00:00
}
2004-03-13 22:41:31 +00:00
2003-11-10 23:25:44 +00:00
//
// update 2d dancing characters
//
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerNumberInfo ( m_vPlayerInfo , pi )
2003-11-10 23:25:44 +00:00
{
2006-02-04 18:37:26 +00:00
DancingCharacters * pCharacter = NULL ;
if ( m_pSongBackground )
pCharacter = m_pSongBackground -> GetDancingCharacters ();
2005-02-07 04:02:38 +00:00
if ( pCharacter != NULL )
2005-02-07 04:12:51 +00:00
{
2005-08-23 21:38:51 +00:00
TapNoteScore tns = pi -> m_pPlayer -> GetLastTapNoteScore ();
2005-02-07 04:12:51 +00:00
2005-04-13 01:11:44 +00:00
ANIM_STATES_2D state = AS2D_MISS ;
switch ( tns )
2005-02-07 04:12:51 +00:00
{
2005-10-09 04:30:59 +00:00
case TNS_W4 :
case TNS_W3 :
2005-04-13 01:11:44 +00:00
state = AS2D_GOOD ;
break ;
2005-10-09 04:30:59 +00:00
case TNS_W2 :
case TNS_W1 :
2005-04-13 01:11:44 +00:00
state = AS2D_GREAT ;
break ;
default :
2005-04-15 11:50:48 +00:00
state = AS2D_MISS ;
break ;
2005-04-13 01:11:44 +00:00
}
2005-02-07 04:12:51 +00:00
2007-02-25 08:23:50 +00:00
if ( state == AS2D_GREAT && pi -> GetPlayerState () -> m_HealthState == HealthState_Hot )
2005-02-07 04:12:51 +00:00
state = AS2D_FEVER ;
2005-08-23 21:38:51 +00:00
pCharacter -> Change2DAnimState ( pi -> m_pn , state );
2005-02-07 04:12:51 +00:00
}
2003-11-10 23:25:44 +00:00
}
2003-07-08 19:56:56 +00:00
//
// Check for enemy death in enemy battle
//
static float fLastSeenEnemyHealth = 1 ;
if ( fLastSeenEnemyHealth != GAMESTATE -> m_fOpponentHealthPercent )
{
fLastSeenEnemyHealth = GAMESTATE -> m_fOpponentHealthPercent ;
if ( GAMESTATE -> m_fOpponentHealthPercent == 0 )
{
2004-02-16 05:29:33 +00:00
// HACK: Load incorrect directory on purpose for now.
PlayAnnouncer ( "gameplay battle damage level3" , 0 );
2003-07-09 02:27:05 +00:00
2003-07-08 19:56:56 +00:00
GAMESTATE -> RemoveAllActiveAttacks ();
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerNumberInfo ( m_vPlayerInfo , pi )
2003-07-08 19:56:56 +00:00
{
2005-08-23 21:38:51 +00:00
if ( ! GAMESTATE -> IsCpuPlayer ( pi -> m_pn ) )
continue ;
2004-05-31 08:58:43 +00:00
SOUND -> PlayOnceFromDir ( THEME -> GetPathS ( m_sName , "oni die" ) );
2006-01-18 07:43:17 +00:00
pi -> ShowOniGameOver ();
2006-07-17 00:58:33 +00:00
pi -> m_NoteData . Init (); // remove all notes and scoring
2006-01-18 07:43:17 +00:00
pi -> m_pPlayer -> FadeToFail (); // tell the NoteField to fade to white
2003-07-08 19:56:56 +00:00
}
}
}
2007-05-01 19:43:41 +00:00
//
// update give up
//
bool bGiveUpTimerFired = ! m_GiveUpTimer . IsZero () && m_GiveUpTimer . Ago () > 2.5f ;
2007-05-30 20:22:57 +00:00
bool bAllHumanHaveBigMissCombo = FAIL_ON_MISS_COMBO . GetValue () != - 1 && STATSMAN -> m_CurStageStats . GetMinimumMissCombo () >= FAIL_ON_MISS_COMBO ;
if ( bGiveUpTimerFired || bAllHumanHaveBigMissCombo )
2007-05-01 19:43:41 +00:00
{
STATSMAN -> m_CurStageStats . m_bGaveUp = true ;
FOREACH_EnabledPlayerNumberInfo ( m_vPlayerInfo , pi )
{
2007-05-30 20:22:57 +00:00
pi -> GetPlayerStageStats () -> m_bFailed |= bAllHumanHaveBigMissCombo ;
2008-05-01 08:41:18 +00:00
pi -> GetPlayerStageStats () -> m_bDisqualified |= bGiveUpTimerFired ; // Don't disqualify if failing for miss combo. The player should still be eligable for a high score on courses.
2007-05-01 19:43:41 +00:00
}
AbortGiveUp ( false );
if ( GIVING_UP_GOES_TO_PREV_SCREEN )
{
BeginBackingOutFromGameplay ();
}
else
{
m_pSoundMusic -> StopPlaying ();
this -> PostScreenMessage ( SM_NotesEnded , 0 );
}
return ;
}
2002-07-27 19:29:51 +00:00
//
2003-03-09 00:55:49 +00:00
// Check to see if it's time to play a ScreenGameplay comment
2002-07-27 19:29:51 +00:00
//
2004-02-16 05:29:33 +00:00
m_fTimeSinceLastDancingComment += fDeltaTime ;
switch ( GAMESTATE -> m_PlayMode )
2002-05-20 08:59:37 +00:00
{
2004-06-11 06:05:35 +00:00
case PLAY_MODE_REGULAR :
2004-02-16 05:29:33 +00:00
case PLAY_MODE_BATTLE :
case PLAY_MODE_RAVE :
if ( GAMESTATE -> OneIsHot () )
PlayAnnouncer ( "gameplay comment hot" , SECONDS_BETWEEN_COMMENTS );
else if ( GAMESTATE -> AllAreInDangerOrWorse () )
PlayAnnouncer ( "gameplay comment danger" , SECONDS_BETWEEN_COMMENTS );
else
PlayAnnouncer ( "gameplay comment good" , SECONDS_BETWEEN_COMMENTS );
break ;
case PLAY_MODE_NONSTOP :
case PLAY_MODE_ONI :
case PLAY_MODE_ENDLESS :
PlayAnnouncer ( "gameplay comment oni" , SECONDS_BETWEEN_COMMENTS );
break ;
default :
ASSERT ( 0 );
2002-05-20 08:59:37 +00:00
}
}
2003-09-06 03:25:45 +00:00
2004-01-12 09:36:01 +00:00
PlayTicks ();
2003-11-20 11:55:45 +00:00
2004-12-03 23:30:50 +00:00
UpdateLights ();
2005-04-24 11:03:02 +00:00
SendCrossedMessages ();
2004-12-03 23:30:50 +00:00
if ( NSMAN -> useSMserver )
{
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerNumberInfo ( m_vPlayerInfo , pi )
if ( pi -> m_pLifeMeter )
NSMAN -> m_playerLife [ pi -> m_pn ] = int ( pi -> m_pLifeMeter -> GetLife () * 10000 );
2004-12-03 23:30:50 +00:00
2005-08-24 20:45:57 +00:00
if ( m_bShowScoreboard )
2005-08-15 02:10:57 +00:00
FOREACH_NSScoreBoardColumn ( cn )
2007-02-12 22:01:50 +00:00
if ( m_bShowScoreboard && NSMAN -> ChangedScoreboard ( cn ) && GAMESTATE -> GetFirstDisabledPlayer () != PLAYER_INVALID )
2005-08-15 02:10:57 +00:00
m_Scoreboard [ cn ]. SetText ( NSMAN -> m_Scoreboard [ cn ] );
2004-12-03 23:30:50 +00:00
}
}
2007-03-18 19:38:11 +00:00
float ScreenGameplay :: GetHasteRate ()
{
2007-04-26 00:56:37 +00:00
if ( GAMESTATE -> m_fMusicSeconds < GAMESTATE -> m_fLastHasteUpdateMusicSeconds || // new song
2007-06-14 01:54:26 +00:00
GAMESTATE -> m_fMusicSeconds > GAMESTATE -> m_fLastHasteUpdateMusicSeconds + 4 )
2007-04-26 00:56:37 +00:00
{
bool bAnyPlayerHitAllNotes = false ;
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
{
if ( ! GAMESTATE -> IsHumanPlayer ( pi -> m_pn ) )
continue ;
PlayerState * pPS = pi -> GetPlayerState ();
if ( pPS -> m_iTapsHitSinceLastHasteUpdate > 0 &&
pPS -> m_iTapsMissedSinceLastHasteUpdate == 0 )
bAnyPlayerHitAllNotes = true ;
pPS -> m_iTapsHitSinceLastHasteUpdate = 0 ;
pPS -> m_iTapsMissedSinceLastHasteUpdate = 0 ;
}
if ( bAnyPlayerHitAllNotes )
2007-06-14 01:54:26 +00:00
GAMESTATE -> m_fHasteRate += 0.1f ;
2007-04-28 23:31:23 +00:00
CLAMP ( GAMESTATE -> m_fHasteRate , - 1.0f , + 1.0f );
2007-04-26 00:56:37 +00:00
GAMESTATE -> m_fLastHasteUpdateMusicSeconds = GAMESTATE -> m_fMusicSeconds ;
}
/* If the life meter is less than half full, push the haste rate down to let
* the player use his accumulated haste time. */
float fMaxLife = 0 ;
2007-03-18 19:38:11 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
{
if ( ! GAMESTATE -> IsHumanPlayer ( pi -> m_pn ) )
continue ;
2007-04-26 00:56:37 +00:00
fMaxLife = max ( fMaxLife , pi -> m_pLifeMeter -> GetLife () );
2007-03-18 19:38:11 +00:00
}
2007-04-26 00:56:37 +00:00
if ( fMaxLife < 0.5f )
GAMESTATE -> m_fHasteRate = SCALE ( fMaxLife , 0.0f , 0.5f , - 1.0f , 0.0f );
2007-03-18 19:38:11 +00:00
float fSpeed = 1.0f ;
2007-04-26 00:56:37 +00:00
if ( GAMESTATE -> m_fHasteRate < 0 )
fSpeed = SCALE ( GAMESTATE -> m_fHasteRate , - 1.0f , 0.0f , 0.5f , 1.0f );
2007-05-27 06:40:37 +00:00
else if ( GAMESTATE -> m_fHasteRate < 0.3f )
fSpeed = SCALE ( GAMESTATE -> m_fHasteRate , 0.0f , 0.3f , 1.0f , 1.2f );
2007-04-26 00:56:37 +00:00
else
2007-05-27 06:40:37 +00:00
fSpeed = SCALE ( GAMESTATE -> m_fHasteRate , 0.3f , 1.0f , 1.2f , 1.5f );
2007-03-18 19:38:11 +00:00
fSpeed *= GAMESTATE -> m_SongOptions . GetCurrent (). m_fHaste ;
2007-04-26 00:56:37 +00:00
if ( GAMESTATE -> m_fAccumulatedHasteSeconds <= 1 )
2007-03-18 19:38:11 +00:00
{
/* Only allow slowing down the song while the players have accumulated
* haste. This prevents dragging on the song by keeping the life meter
* nearly empty. */
float fClamped = max ( 1.0f , fSpeed );
2007-04-26 00:56:37 +00:00
fSpeed = lerp ( GAMESTATE -> m_fAccumulatedHasteSeconds , fClamped , fSpeed );
2007-03-18 19:38:11 +00:00
}
return fSpeed ;
}
2004-12-03 23:30:50 +00:00
void ScreenGameplay :: UpdateLights ()
{
2004-12-03 23:31:35 +00:00
if ( ! LIGHTSMAN -> IsEnabled () )
return ;
2005-06-02 20:06:26 +00:00
if ( m_CabinetLightsNoteData . GetNumTracks () == 0 ) // light data wasn't loaded
return ;
2004-12-03 23:31:35 +00:00
2004-06-28 07:26:00 +00:00
const Style * pStyle = GAMESTATE -> GetCurrentStyle ();
2006-09-26 21:23:30 +00:00
bool bBlinkCabinetLight [ NUM_CabinetLight ];
2006-09-27 04:39:51 +00:00
bool bBlinkGameButton [ NUM_GameController ][ NUM_GameButton ];
2004-04-22 05:25:58 +00:00
ZERO ( bBlinkCabinetLight );
ZERO ( bBlinkGameButton );
2004-03-30 07:44:29 +00:00
bool bCrossedABeat = false ;
2004-01-12 09:36:01 +00:00
{
2005-05-04 20:37:41 +00:00
const float fSongBeat = GAMESTATE -> m_fLightSongBeat ;
2005-04-29 01:34:52 +00:00
const int iSongRow = BeatToNoteRowNotRounded ( fSongBeat );
2004-01-12 09:36:01 +00:00
static int iRowLastCrossed = 0 ;
2004-03-30 07:44:29 +00:00
float fBeatLast = roundf ( NoteRowToBeat ( iRowLastCrossed ));
2005-04-29 01:31:41 +00:00
float fBeatNow = roundf ( NoteRowToBeat ( iSongRow ));
2004-03-30 07:44:29 +00:00
bCrossedABeat = fBeatLast != fBeatNow ;
2004-01-12 09:36:01 +00:00
2004-12-03 23:39:50 +00:00
FOREACH_CabinetLight ( cl )
{
// for each index we crossed since the last update:
2005-04-29 01:31:41 +00:00
FOREACH_NONEMPTY_ROW_IN_TRACK_RANGE ( m_CabinetLightsNoteData , cl , r , iRowLastCrossed + 1 , iSongRow + 1 )
2004-12-03 23:39:50 +00:00
{
2005-04-29 01:35:44 +00:00
if ( m_CabinetLightsNoteData . GetTapNote ( cl , r ). type != TapNote :: empty )
bBlinkCabinetLight [ cl ] = true ;
2004-04-22 05:25:58 +00:00
}
2005-01-23 06:31:41 +00:00
2005-07-22 00:14:24 +00:00
if ( m_CabinetLightsNoteData . IsHoldNoteAtRow ( cl , iSongRow ) )
2005-04-29 01:35:44 +00:00
bBlinkCabinetLight [ cl ] = true ;
2004-12-03 23:33:06 +00:00
}
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerNumberInfo ( m_vPlayerInfo , pi )
2004-12-03 23:33:06 +00:00
{
2006-07-17 00:58:33 +00:00
const NoteData & nd = pi -> m_pPlayer -> GetNoteData ();
for ( int t = 0 ; t < nd . GetNumTracks (); t ++ )
2004-04-22 05:25:58 +00:00
{
2005-04-29 01:35:44 +00:00
bool bBlink = false ;
2004-12-03 23:43:35 +00:00
// for each index we crossed since the last update:
2006-07-17 00:58:33 +00:00
FOREACH_NONEMPTY_ROW_IN_TRACK_RANGE ( nd , t , r , iRowLastCrossed + 1 , iSongRow + 1 )
2004-04-22 05:25:58 +00:00
{
2006-07-17 00:58:33 +00:00
const TapNote & tn = nd . GetTapNote ( t , r );
2006-08-19 19:58:48 +00:00
if ( tn . type != TapNote :: mine )
2005-04-29 01:35:44 +00:00
bBlink = true ;
}
// check if a hold should be active
2006-07-17 00:58:33 +00:00
if ( nd . IsHoldNoteAtRow ( t , iSongRow ) )
2005-04-29 01:35:44 +00:00
bBlink = true ;
if ( bBlink )
{
2006-09-13 00:16:23 +00:00
GameInput gi = pStyle -> StyleInputToGameInput ( t , pi -> m_pn );
2005-04-29 01:35:44 +00:00
bBlinkGameButton [ gi . controller ][ gi . button ] = true ;
2004-04-22 05:25:58 +00:00
}
}
2004-01-12 09:36:01 +00:00
}
2005-04-29 01:31:41 +00:00
iRowLastCrossed = iSongRow ;
2004-01-12 09:36:01 +00:00
}
2005-05-09 04:48:18 +00:00
// Before the first beat of the song, all cabinet lights solid on (except for menu buttons).
bool bOverrideCabinetBlink = ( GAMESTATE -> m_fSongBeat < GAMESTATE -> m_pCurSong -> m_fFirstBeat );
2004-04-20 02:35:30 +00:00
FOREACH_CabinetLight ( cl )
2007-05-08 02:02:44 +00:00
bBlinkCabinetLight [ cl ] |= bOverrideCabinetBlink ;
2004-10-15 14:37:33 +00:00
// Send blink data.
FOREACH_CabinetLight ( cl )
{
if ( bBlinkCabinetLight [ cl ] )
2004-04-22 05:25:58 +00:00
LIGHTSMAN -> BlinkCabinetLight ( cl );
}
2008-04-24 09:34:01 +00:00
FOREACH_ENUM ( GameController , gc )
2004-04-22 05:25:58 +00:00
{
2008-04-24 09:34:01 +00:00
FOREACH_ENUM ( GameButton , gb )
2004-04-22 05:25:58 +00:00
{
if ( bBlinkGameButton [ gc ][ gb ] )
LIGHTSMAN -> BlinkGameButton ( GameInput ( gc , gb ) );
}
2004-04-20 02:35:30 +00:00
}
2002-05-20 08:59:37 +00:00
}
2005-04-24 11:03:02 +00:00
void ScreenGameplay :: SendCrossedMessages ()
{
{
2005-05-01 22:59:00 +00:00
static int iRowLastCrossed = 0 ;
2005-04-24 11:03:02 +00:00
2005-05-01 22:59:00 +00:00
float fPositionSeconds = GAMESTATE -> m_fMusicSeconds ;
2005-04-24 11:15:07 +00:00
float fSongBeat = GAMESTATE -> m_pCurSong -> GetBeatFromElapsedTime ( fPositionSeconds );
int iRowNow = BeatToNoteRowNotRounded ( fSongBeat );
iRowNow = max ( 0 , iRowNow );
2005-05-01 22:59:00 +00:00
for ( int r = iRowLastCrossed + 1 ; r <= iRowNow ; r ++ )
2005-04-24 11:03:02 +00:00
{
2005-05-01 22:59:00 +00:00
if ( GetNoteType ( r ) == NOTE_TYPE_4TH )
2005-08-14 07:29:48 +00:00
MESSAGEMAN -> Broadcast ( Message_BeatCrossed );
2005-04-24 11:03:02 +00:00
}
2005-04-24 11:15:07 +00:00
iRowLastCrossed = iRowNow ;
2005-04-24 11:03:02 +00:00
}
2005-05-01 22:59:00 +00:00
{
const int NUM_MESSAGES_TO_SEND = 4 ;
2006-04-04 21:45:10 +00:00
const float MESSAGE_SPACING_SECONDS = 0.4f ;
2005-05-01 22:59:00 +00:00
PlayerNumber pn = PLAYER_INVALID ;
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerNumberInfo ( m_vPlayerInfo , pi )
2005-05-01 22:59:00 +00:00
{
2007-02-22 07:18:05 +00:00
if ( GAMESTATE -> m_pCurSteps [ pi -> m_pn ] -> GetDifficulty () == Difficulty_Beginner )
2005-05-01 22:59:00 +00:00
{
2005-08-23 21:38:51 +00:00
pn = pi -> m_pn ;
2005-05-01 22:59:00 +00:00
break ;
}
}
if ( pn == PLAYER_INVALID )
return ;
2006-07-17 00:58:33 +00:00
const NoteData & nd = m_vPlayerInfo [ pn ]. m_pPlayer -> GetNoteData ();
2005-05-01 22:59:00 +00:00
static int iRowLastCrossedAll [ NUM_MESSAGES_TO_SEND ] = { 0 , 0 , 0 , 0 };
for ( int i = 0 ; i < NUM_MESSAGES_TO_SEND ; i ++ )
{
float fOffsetFromCurrentSeconds = MESSAGE_SPACING_SECONDS * i ;
float fPositionSeconds = GAMESTATE -> m_fMusicSeconds + fOffsetFromCurrentSeconds ;
float fSongBeat = GAMESTATE -> m_pCurSong -> GetBeatFromElapsedTime ( fPositionSeconds );
int iRowNow = BeatToNoteRowNotRounded ( fSongBeat );
iRowNow = max ( 0 , iRowNow );
int & iRowLastCrossed = iRowLastCrossedAll [ i ];
FOREACH_NONEMPTY_ROW_ALL_TRACKS_RANGE ( nd , r , iRowLastCrossed + 1 , iRowNow + 1 )
{
2005-05-09 12:26:44 +00:00
int iNumTracksWithTapOrHoldHead = 0 ;
for ( int t = 0 ; t < nd . GetNumTracks (); t ++ )
2005-05-01 22:59:00 +00:00
{
2005-05-09 12:26:44 +00:00
if ( nd . GetTapNote ( t , r ). type == TapNote :: empty )
continue ;
iNumTracksWithTapOrHoldHead ++ ;
2005-05-08 04:10:16 +00:00
// Send col-specific crossed
if ( i == 0 )
{
2006-09-30 00:46:21 +00:00
const Style * pStyle = GAMESTATE -> GetCurrentStyle ();
RString sButton = pStyle -> ColToButtonName ( t );
2006-01-22 01:00:06 +00:00
RString sMessageName = "NoteCrossed" + sButton ;
2005-05-08 04:10:16 +00:00
MESSAGEMAN -> Broadcast ( sMessageName );
}
2005-05-09 12:26:44 +00:00
}
if ( iNumTracksWithTapOrHoldHead > 0 )
2006-11-13 22:36:39 +00:00
MESSAGEMAN -> Broadcast ( ( MessageID )( Message_NoteCrossed + i ) );
2005-05-09 12:26:44 +00:00
if ( i == 0 && iNumTracksWithTapOrHoldHead >= 2 )
{
2006-01-22 01:00:06 +00:00
RString sMessageName = "NoteCrossedJump" ;
2005-05-09 12:26:44 +00:00
MESSAGEMAN -> Broadcast ( sMessageName );
2005-05-01 22:59:00 +00:00
}
}
iRowLastCrossed = iRowNow ;
}
}
2005-04-24 11:03:02 +00:00
}
2005-09-12 08:04:47 +00:00
void ScreenGameplay :: BeginBackingOutFromGameplay ()
2005-03-10 02:45:40 +00:00
{
m_DancingState = STATE_OUTRO ;
2005-03-15 08:44:35 +00:00
AbortGiveUp ( false );
2005-03-10 02:45:40 +00:00
m_pSoundMusic -> StopPlaying ();
2007-01-25 00:50:57 +00:00
m_GameplayAssist . StopPlaying (); /* Stop any queued assist ticks. */
2005-03-10 02:45:40 +00:00
this -> ClearMessageQueue ();
2005-06-29 07:57:15 +00:00
// If this is the final stage, don't allow extra stage
2007-04-25 03:50:17 +00:00
if ( GAMESTATE -> GetSmallestNumStagesLeftForAnyHumanPlayer () == 0 )
2005-06-29 07:57:15 +00:00
GAMESTATE -> m_bBackedOutOfFinalStage = true ;
// Disallow backing out of extra stage
2006-08-06 02:37:42 +00:00
if ( GAMESTATE -> IsAnExtraStage () )
2005-06-29 07:57:15 +00:00
SCREENMAN -> PostMessageToTopScreen ( SM_BeginFailed , 0 );
else
2006-02-04 20:14:04 +00:00
m_Cancel . StartTransitioning ( SM_DoPrevScreen );
2005-03-10 02:45:40 +00:00
}
2005-03-15 08:44:35 +00:00
void ScreenGameplay :: AbortGiveUp ( bool bShowText )
2003-09-06 03:25:45 +00:00
{
if ( m_GiveUpTimer . IsZero () )
return ;
m_textDebug . StopTweening ();
2005-03-15 08:44:35 +00:00
if ( bShowText )
m_textDebug . SetText ( GIVE_UP_ABORTED_TEXT );
// otherwise tween out the text that's there
2003-09-06 03:25:45 +00:00
m_textDebug . BeginTweening ( 1 / 2.f );
m_textDebug . SetDiffuse ( RageColor ( 1 , 1 , 1 , 0 ) );
m_GiveUpTimer . SetZero ();
}
2002-05-20 08:59:37 +00:00
2005-09-05 02:26:50 +00:00
void ScreenGameplay :: Input ( const InputEventPlus & input )
2002-05-20 08:59:37 +00:00
{
2002-07-31 19:40:40 +00:00
//LOG->Trace( "ScreenGameplay::Input()" );
2003-01-19 21:57:13 +00:00
2005-03-11 03:54:40 +00:00
if ( m_bPaused )
{
/* If we're paused, only accept MENU_BUTTON_START to unpause. */
2006-09-14 20:31:46 +00:00
if ( GAMESTATE -> IsHumanPlayer ( input . pn ) && input . MenuI == MENU_BUTTON_START && input . type == IET_FIRST_PRESS )
2005-04-21 02:07:02 +00:00
{
2006-09-26 20:59:40 +00:00
if ( m_PauseController == GameController_Invalid || m_PauseController == input . GameI . controller )
2005-04-21 02:07:02 +00:00
this -> PauseGame ( false );
}
2005-03-11 03:54:40 +00:00
return ;
}
2006-09-14 20:31:46 +00:00
if ( m_DancingState != STATE_OUTRO &&
2006-09-14 04:08:58 +00:00
GAMESTATE -> IsHumanPlayer ( input . pn ) &&
2005-03-20 06:14:41 +00:00
! m_Cancel . IsTransitioning () )
2003-01-19 21:57:13 +00:00
{
2006-03-14 05:47:51 +00:00
/*
2006-11-21 06:15:04 +00:00
* Allow bailing out by holding any START button. This gives a way to "give up"
* when a back button isn't available.
2003-11-24 02:03:09 +00:00
*
2006-11-21 06:15:04 +00:00
* If this is also a style button, don't do this; pump center is start.
2006-03-14 05:47:51 +00:00
*/
2005-03-10 02:45:40 +00:00
bool bHoldingGiveUp = false ;
2006-10-07 04:25:28 +00:00
if ( GAMESTATE -> GetCurrentStyle () -> GameInputToColumn ( input . GameI ) == Column_Invalid )
2006-09-13 01:29:33 +00:00
{
2006-09-14 20:31:46 +00:00
bHoldingGiveUp |= ( START_GIVES_UP && input . MenuI == MENU_BUTTON_START );
bHoldingGiveUp |= ( BACK_GIVES_UP && input . MenuI == MENU_BUTTON_BACK );
2006-09-13 01:29:33 +00:00
}
2005-03-10 02:45:40 +00:00
if ( bHoldingGiveUp )
2003-09-06 03:25:45 +00:00
{
/* No PREFSMAN->m_bDelayedEscape; always delayed. */
2005-09-05 02:26:50 +00:00
if ( input . type == IET_RELEASE )
2006-03-14 05:47:51 +00:00
{
2005-03-15 08:44:35 +00:00
AbortGiveUp ( true );
2006-03-14 05:47:51 +00:00
}
2005-09-05 02:26:50 +00:00
else if ( input . type == IET_FIRST_PRESS && m_GiveUpTimer . IsZero () )
2003-09-06 03:25:45 +00:00
{
2006-05-03 23:57:23 +00:00
m_textDebug . SetText ( GIVE_UP_START_TEXT );
2003-09-06 03:25:45 +00:00
m_textDebug . StopTweening ();
m_textDebug . SetDiffuse ( RageColor ( 1 , 1 , 1 , 0 ) );
m_textDebug . BeginTweening ( 1 / 8.f );
m_textDebug . SetDiffuse ( RageColor ( 1 , 1 , 1 , 1 ) );
m_GiveUpTimer . Touch (); /* start the timer */
}
return ;
}
2005-03-10 02:45:40 +00:00
/* Only handle MENU_BUTTON_BACK as a regular BACK button if BACK_GIVES_UP is
* disabled. */
2006-10-27 10:19:08 +00:00
bool bHoldingBack = false ;
if ( GAMESTATE -> GetCurrentStyle () -> GameInputToColumn ( input . GameI ) == Column_Invalid )
{
bHoldingBack |= input . MenuI == MENU_BUTTON_BACK && ! BACK_GIVES_UP ;
}
if ( bHoldingBack )
2003-01-19 21:57:13 +00:00
{
2005-09-05 02:26:50 +00:00
if ( (( ! PREFSMAN -> m_bDelayedBack && input . type == IET_FIRST_PRESS ) ||
2006-09-13 02:59:05 +00:00
( input . DeviceI . device == DEVICE_KEYBOARD && input . type == IET_REPEAT ) ||
2006-09-13 02:44:03 +00:00
( input . DeviceI . device != DEVICE_KEYBOARD && INPUTFILTER -> GetSecsHeld ( input . DeviceI ) >= 1.0f )) )
2005-03-10 02:45:40 +00:00
{
2006-09-14 04:08:58 +00:00
LOG -> Trace ( "Player %i went back" , input . pn + 1 );
2005-09-12 08:04:47 +00:00
BeginBackingOutFromGameplay ();
2005-03-10 02:45:40 +00:00
}
2005-09-05 02:26:50 +00:00
else if ( PREFSMAN -> m_bDelayedBack && input . type == IET_FIRST_PRESS )
2005-03-10 02:45:40 +00:00
{
2006-05-03 23:57:23 +00:00
m_textDebug . SetText ( GIVE_UP_BACK_TEXT );
2005-03-10 02:45:40 +00:00
m_textDebug . StopTweening ();
m_textDebug . SetDiffuse ( RageColor ( 1 , 1 , 1 , 0 ) );
m_textDebug . BeginTweening ( 1 / 8.f );
m_textDebug . SetDiffuse ( RageColor ( 1 , 1 , 1 , 1 ) );
}
2005-09-05 02:26:50 +00:00
else if ( PREFSMAN -> m_bDelayedBack && input . type == IET_RELEASE )
2005-03-10 02:45:40 +00:00
{
m_textDebug . StopTweening ();
m_textDebug . BeginTweening ( 1 / 8.f );
m_textDebug . SetDiffuse ( RageColor ( 1 , 1 , 1 , 0 ) );
}
2004-02-16 01:35:59 +00:00
2004-02-15 02:06:39 +00:00
return ;
}
2003-01-19 21:57:13 +00:00
}
2006-08-14 09:09:24 +00:00
bool bRelease = input . type == IET_RELEASE ;
2006-12-11 12:27:58 +00:00
if ( ! input . GameI . IsValid () )
2006-12-06 07:16:38 +00:00
return ;
2006-12-11 12:27:58 +00:00
const int iCol = GAMESTATE -> GetCurrentStyle () -> GameInputToColumn ( input . GameI );
2006-10-27 10:19:08 +00:00
// Don't pass on any inputs to Player that aren't a press or a release.
switch ( input . type )
{
case IET_FIRST_PRESS :
case IET_RELEASE :
break ;
default :
return ;
}
2005-08-23 21:38:51 +00:00
if ( GAMESTATE -> m_bMultiplayer )
2003-02-27 10:56:37 +00:00
{
2007-08-20 10:45:28 +00:00
if ( input . mp != MultiPlayer_Invalid && GAMESTATE -> IsMultiPlayerEnabled ( input . mp ) && iCol != - 1 )
{
FOREACH ( PlayerInfo , m_vPlayerInfo , pi )
{
if ( input . mp == pi -> m_mp )
pi -> m_pPlayer -> Step ( iCol , - 1 , input . DeviceI . ts , false , bRelease );
}
}
2005-08-23 21:38:51 +00:00
}
else
{
//
// handle a step or battle item activate
//
2006-10-27 10:19:08 +00:00
if ( GAMESTATE -> IsHumanPlayer ( input . pn ) )
2005-08-23 21:38:51 +00:00
{
AbortGiveUp ( true );
2006-11-21 05:02:55 +00:00
if ( GamePreferences :: m_AutoPlay == PC_HUMAN )
2006-06-24 04:19:00 +00:00
{
2006-07-09 20:14:06 +00:00
PlayerInfo & pi = GetPlayerInfoForInput ( input );
2006-10-27 10:19:08 +00:00
ASSERT ( input . GameI . IsValid () );
2007-01-12 23:00:40 +00:00
GameButtonType gbt = GAMESTATE -> m_pCurGame -> GetPerButtonInfo ( input . GameI . button ) -> m_gbt ;
2006-10-27 10:19:08 +00:00
switch ( gbt )
{
2006-10-27 18:09:39 +00:00
case GameButtonType_INVALID :
break ;
2006-10-27 10:19:08 +00:00
case GameButtonType_Step :
2007-01-03 05:40:19 +00:00
if ( iCol != - 1 )
pi . m_pPlayer -> Step ( iCol , - 1 , input . DeviceI . ts , false , bRelease );
2006-10-27 10:19:08 +00:00
break ;
case GameButtonType_Fret :
2007-01-03 05:40:19 +00:00
if ( iCol != - 1 )
pi . m_pPlayer -> Fret ( iCol , - 1 , input . DeviceI . ts , false , bRelease );
2006-10-27 10:19:08 +00:00
break ;
case GameButtonType_Strum :
pi . m_pPlayer -> Strum ( iCol , - 1 , input . DeviceI . ts , false , bRelease );
break ;
}
2006-06-24 04:19:00 +00:00
}
2005-08-23 21:38:51 +00:00
}
2003-02-27 10:56:37 +00:00
}
2002-05-20 08:59:37 +00:00
}
2003-01-11 08:55:21 +00:00
2002-07-27 19:29:51 +00:00
2003-12-23 02:18:27 +00:00
/*
* Saving StageStats that are affected by the note pattern is a little tricky:
*
* Stats are cumulative for course play.
*
* For regular songs, it doesn't matter how we do it; the pattern doesn't change
* during play.
*
* The pattern changes during play in battle and course mode. We want to include these
* changes, so run stats for a song after the song finishes.
*
* If we fail, be sure to include the current song in stats, with the current modifier set.
*
* So:
*
2005-08-23 21:38:51 +00:00
* 1. At the end of a song in any mode, pass or fail, add stats for that song (from m_pPlayer).
2003-12-23 02:18:27 +00:00
* 2. At the end of gameplay in course mode, add stats for any songs that weren't played,
* applying the modifiers the song would have been played with. This doesn't include songs
* that were played but failed; that was done in #1.
*/
2006-07-10 04:32:33 +00:00
void ScreenGameplay :: SaveStats ()
2003-12-15 06:24:59 +00:00
{
2006-07-10 00:02:07 +00:00
float fMusicLen = GAMESTATE -> m_pCurSong -> m_fMusicLengthSeconds ;
2006-07-10 04:32:33 +00:00
2006-01-18 07:43:17 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2003-12-15 06:24:59 +00:00
{
2005-12-24 20:18:56 +00:00
/* Note that adding stats is only meaningful for the counters (eg. RadarCategory_Jumps),
* not for the percentages (RadarCategory_Air). */
2006-07-10 00:02:07 +00:00
RadarValues rv ;
PlayerStageStats & pss = * pi -> GetPlayerStageStats ();
2006-07-17 00:58:33 +00:00
const NoteData & nd = pi -> m_pPlayer -> GetNoteData ();
2004-07-11 07:21:33 +00:00
2006-07-17 00:58:33 +00:00
NoteDataUtil :: CalculateRadarValues ( nd , fMusicLen , rv );
2006-11-14 11:13:21 +00:00
pss . m_radarPossible += rv ;
2004-07-11 07:21:33 +00:00
2006-07-17 00:58:33 +00:00
NoteDataWithScoring :: GetActualRadarValues ( nd , pss , fMusicLen , rv );
2006-11-14 11:13:21 +00:00
pss . m_radarActual += rv ;
2003-12-15 06:24:59 +00:00
}
2006-07-10 04:32:33 +00:00
}
2004-02-16 10:22:18 +00:00
2006-07-10 04:32:33 +00:00
void ScreenGameplay :: SongFinished ()
{
2006-10-26 22:41:40 +00:00
AdjustSync :: HandleSongEnd ();
2006-07-10 04:32:33 +00:00
SaveStats (); // Let subclasses save the stats.
2004-02-16 10:22:18 +00:00
/* Extremely important: if we don't remove attacks before moving on to the next
* screen, they'll still be turned on eventually. */
GAMESTATE -> RemoveAllActiveAttacks ();
2006-01-18 07:43:17 +00:00
FOREACH_VisiblePlayerInfo ( m_vPlayerInfo , pi )
2005-08-23 21:38:51 +00:00
pi -> m_pActiveAttackList -> Refresh ();
2003-12-23 02:18:27 +00:00
}
2003-12-15 06:24:59 +00:00
2004-02-21 21:00:49 +00:00
void ScreenGameplay :: StageFinished ( bool bBackedOut )
2003-12-23 02:18:27 +00:00
{
if ( GAMESTATE -> IsCourseMode () && GAMESTATE -> m_PlayMode != PLAY_MODE_ENDLESS )
{
2004-01-03 04:38:17 +00:00
LOG -> Trace ( "Stage finished at index %i/%i" , GAMESTATE -> GetCourseSongIndex (), ( int ) m_apSongsQueue . size () );
2005-10-02 19:19:14 +00:00
/* +1 to skip the current song; that song has already passed. */
for ( unsigned i = GAMESTATE -> GetCourseSongIndex () + 1 ; i < m_apSongsQueue . size (); ++ i )
2003-12-23 02:18:27 +00:00
{
2005-10-02 19:19:14 +00:00
LOG -> Trace ( "Running stats for %i" , i );
SetupSong ( i );
2006-01-18 07:43:17 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2005-08-23 21:38:51 +00:00
pi -> m_pPlayer -> ApplyWaitingTransforms ();
2005-04-11 07:59:27 +00:00
SongFinished ();
2003-12-23 02:18:27 +00:00
}
}
2003-12-15 06:24:59 +00:00
2007-04-24 01:35:32 +00:00
if ( bBackedOut )
{
GAMESTATE -> CancelStage ();
return ;
}
2007-04-25 04:03:20 +00:00
/* If all players failed, kill. */
if ( STATSMAN -> m_CurStageStats . AllFailed () )
{
FOREACH_HumanPlayer ( p )
GAMESTATE -> m_iPlayerStageTokens [ p ] = 0 ;
}
2007-04-24 01:35:32 +00:00
FOREACH_HumanPlayer ( pn )
STATSMAN -> m_CurStageStats . m_player [ pn ]. CalcAwards ( pn , STATSMAN -> m_CurStageStats . m_bGaveUp , STATSMAN -> m_CurStageStats . m_bUsedAutoplay );
2007-04-25 16:16:53 +00:00
STATSMAN -> m_CurStageStats . CommitScores ( false );
2007-11-13 10:24:42 +00:00
2007-11-13 10:27:28 +00:00
GAMESTATE -> CommitStageStats ();
2007-04-25 16:16:53 +00:00
// save current stage stats
STATSMAN -> m_vPlayedStageStats . push_back ( STATSMAN -> m_CurStageStats );
2007-04-24 01:35:32 +00:00
STATSMAN -> CalcAccumPlayedStageStats ();
GAMESTATE -> FinishStage ();
2003-12-15 06:24:59 +00:00
}
2002-05-20 08:59:37 +00:00
void ScreenGameplay :: HandleScreenMessage ( const ScreenMessage SM )
{
2003-11-14 18:33:12 +00:00
CHECKPOINT_M ( ssprintf ( "HandleScreenMessage(%i)" , SM ) );
2005-04-02 02:45:17 +00:00
if ( SM == SM_DoneFadingIn )
2002-05-20 08:59:37 +00:00
{
2004-04-12 20:11:36 +00:00
SOUND -> PlayOnceFromAnnouncer ( "gameplay ready" );
2003-03-09 00:55:49 +00:00
m_Ready . StartTransitioning ( SM_PlayGo );
2005-03-23 08:48:38 +00:00
}
else if ( SM == SM_PlayGo )
{
2006-08-06 02:37:42 +00:00
if ( GAMESTATE -> IsAnExtraStage () )
2004-04-12 20:11:36 +00:00
SOUND -> PlayOnceFromAnnouncer ( "gameplay here we go extra" );
2007-04-25 03:50:17 +00:00
else if ( GAMESTATE -> GetSmallestNumStagesLeftForAnyHumanPlayer () == 0 )
2004-04-12 20:11:36 +00:00
SOUND -> PlayOnceFromAnnouncer ( "gameplay here we go final" );
2004-02-16 05:29:33 +00:00
else
2004-04-12 20:11:36 +00:00
SOUND -> PlayOnceFromAnnouncer ( "gameplay here we go normal" );
2004-02-16 05:29:33 +00:00
2003-03-09 00:55:49 +00:00
m_Go . StartTransitioning ( SM_None );
2005-10-10 04:39:32 +00:00
GAMESTATE -> m_bGameplayLeadIn . Set ( false );
2003-01-25 07:40:47 +00:00
m_DancingState = STATE_DANCING ; // STATE CHANGE! Now the user is allowed to press Back
2005-03-23 08:48:38 +00:00
}
else if ( SM == SM_NotesEnded ) // received while STATE_DANCING
{
2005-04-24 02:21:25 +00:00
AbortGiveUp ( false ); // don't allow giveup while the next song is loading
2005-03-23 08:48:38 +00:00
/* Do this in LoadNextSong, so we don't tween off old attacks until
2005-04-06 06:12:23 +00:00
* m_NextSong finishes. */
2005-03-23 08:48:38 +00:00
// GAMESTATE->RemoveAllActiveAttacks();
2003-01-25 07:40:47 +00:00
2006-01-18 07:43:17 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2002-07-23 01:41:40 +00:00
{
2006-11-09 07:33:57 +00:00
/* Mark failure. */
2007-05-12 23:48:29 +00:00
if ( GAMESTATE -> GetPlayerFailType ( pi -> GetPlayerState ()) != PlayerOptions :: FAIL_OFF &&
2006-11-09 05:45:10 +00:00
( pi -> m_pLifeMeter && pi -> m_pLifeMeter -> IsFailing ()) )
2006-11-14 11:13:21 +00:00
pi -> GetPlayerStageStats () -> m_bFailed = true ;
2003-11-03 19:42:06 +00:00
2006-11-14 11:13:21 +00:00
if ( ! pi -> GetPlayerStageStats () -> m_bFailed )
pi -> GetPlayerStageStats () -> m_iSongsPassed ++ ;
2005-04-27 06:34:53 +00:00
2006-11-09 07:08:09 +00:00
// set a life record at the point of failure
2006-11-14 11:13:21 +00:00
if ( pi -> GetPlayerStageStats () -> m_bFailed )
pi -> GetPlayerStageStats () -> SetLifeRecordAt ( 0 , STATSMAN -> m_CurStageStats . m_fGameplaySeconds );
2005-03-23 08:48:38 +00:00
}
2003-04-13 00:44:50 +00:00
2005-03-23 08:48:38 +00:00
/* If all players have *really* failed (bFailed, not the life meter or
2005-04-06 06:12:23 +00:00
* bFailedEarlier): */
2005-03-23 08:48:38 +00:00
const bool bAllReallyFailed = STATSMAN -> m_CurStageStats . AllFailed ();
2005-04-09 11:32:10 +00:00
const bool bStopCourseEarly = STOP_COURSE_EARLY ;
const bool bIsLastSong = IsLastSong ();
2005-03-23 02:11:33 +00:00
2006-04-08 01:52:37 +00:00
LOG -> Trace ( "bAllReallyFailed = %d, bStopCourseEarly = %d, bIsLastSong = %d" , bAllReallyFailed , bStopCourseEarly , bIsLastSong );
2005-03-23 08:48:38 +00:00
2005-04-09 11:32:10 +00:00
if ( bStopCourseEarly || bAllReallyFailed || bIsLastSong )
2005-03-23 08:48:38 +00:00
{
2005-04-09 11:32:10 +00:00
// Time to leave from ScreenGameplay
2005-04-10 06:21:59 +00:00
HandleScreenMessage ( SM_LeaveGameplay );
2005-04-09 11:32:10 +00:00
}
else
{
2007-05-01 02:25:38 +00:00
/* Load the next song in the course. */
HandleScreenMessage ( SM_StartLoadingNextSong );
2005-03-23 08:48:38 +00:00
return ;
}
}
2005-04-10 06:21:59 +00:00
else if ( SM == SM_LeaveGameplay )
{
// update dancing characters for win / lose
2006-02-04 18:37:26 +00:00
DancingCharacters * pDancers = NULL ;
if ( m_pSongBackground )
pDancers = m_pSongBackground -> GetDancingCharacters ();
2006-01-18 07:41:44 +00:00
if ( pDancers )
2005-04-10 06:21:59 +00:00
{
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerNumberInfo ( m_vPlayerInfo , pi )
2005-04-10 06:21:59 +00:00
{
/* XXX: In battle modes, switch( GAMESTATE->GetStageResult(p) ). */
2006-11-14 11:13:21 +00:00
if ( pi -> GetPlayerStageStats () -> m_bFailed )
2006-01-18 07:41:44 +00:00
pDancers -> Change2DAnimState ( pi -> m_pn , AS2D_FAIL ); // fail anim
2007-02-25 08:23:50 +00:00
else if ( pi -> m_pLifeMeter && pi -> GetPlayerState () -> m_HealthState == HealthState_Hot )
2006-01-18 07:41:44 +00:00
pDancers -> Change2DAnimState ( pi -> m_pn , AS2D_WINFEVER ); // full life pass anim
2005-04-10 06:21:59 +00:00
else
2006-01-18 07:41:44 +00:00
pDancers -> Change2DAnimState ( pi -> m_pn , AS2D_WIN ); // pass anim
2005-04-10 06:21:59 +00:00
}
}
/* End round. */
if ( m_DancingState == STATE_OUTRO ) // ScreenGameplay already ended
return ; // ignore
m_DancingState = STATE_OUTRO ;
AbortGiveUp ( false );
GAMESTATE -> RemoveAllActiveAttacks ();
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
{
if ( pi -> m_pActiveAttackList )
pi -> m_pActiveAttackList -> Refresh ();
}
2005-04-10 06:21:59 +00:00
LIGHTSMAN -> SetLightsMode ( LIGHTSMODE_ALL_CLEARED );
bool bAllReallyFailed = STATSMAN -> m_CurStageStats . AllFailed ();
if ( bAllReallyFailed )
{
this -> PostScreenMessage ( SM_BeginFailed , 0 );
return ;
}
2005-10-13 22:52:25 +00:00
TweenOffScreen ();
2005-07-06 06:41:57 +00:00
2006-02-04 20:14:04 +00:00
m_Out . StartTransitioning ( SM_DoNextScreen );
2006-01-18 08:38:40 +00:00
2005-04-10 06:21:59 +00:00
// do they deserve an extra stage?
if ( GAMESTATE -> HasEarnedExtraStage () )
SOUND -> PlayOnceFromAnnouncer ( "gameplay extra" );
else
SOUND -> PlayOnceFromAnnouncer ( "gameplay cleared" );
}
2005-03-23 08:48:38 +00:00
else if ( SM == SM_StartLoadingNextSong )
2005-05-08 22:03:41 +00:00
{
2005-03-23 08:48:38 +00:00
/* Next song. */
2005-04-21 11:16:01 +00:00
// give a little life back between stages
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
2005-03-23 08:48:38 +00:00
{
2006-11-09 04:47:33 +00:00
if ( pi -> m_pLifeMeter )
pi -> m_pLifeMeter -> OnSongEnded ();
2005-03-23 08:48:38 +00:00
}
2006-04-29 02:03:08 +00:00
GAMESTATE -> m_bLoadingNextSong = true ;
2005-07-12 21:16:15 +00:00
MESSAGEMAN -> Broadcast ( "BeforeLoadingNextCourseSong" );
2005-03-23 08:48:38 +00:00
m_NextSong . Reset ();
2005-09-03 05:50:13 +00:00
m_NextSong . PlayCommand ( "Start" );
2005-03-23 08:48:38 +00:00
m_NextSong . StartTransitioning ( SM_LoadNextSong );
2006-04-29 02:03:08 +00:00
MESSAGEMAN -> Broadcast ( "ChangeCourseSongIn" );
2005-03-23 08:48:38 +00:00
}
else if ( SM == SM_LoadNextSong )
{
2007-05-01 02:25:38 +00:00
m_pSoundMusic -> Stop ();
2003-12-15 06:24:59 +00:00
SongFinished ();
2006-04-29 02:03:08 +00:00
MESSAGEMAN -> Broadcast ( "ChangeCourseSongOut" );
2004-02-14 00:39:24 +00:00
2006-04-29 02:03:08 +00:00
GAMESTATE -> m_bLoadingNextSong = false ;
2003-01-25 07:40:47 +00:00
LoadNextSong ();
2005-03-19 00:03:53 +00:00
m_NextSong . Reset ();
m_NextSong . PlayCommand ( "Finish" );
m_NextSong . StartTransitioning ( SM_None );
2007-02-26 01:46:50 +00:00
StartPlayingSong ( MIN_SECONDS_TO_STEP_NEXT_SONG , 0 );
2005-03-23 08:48:38 +00:00
}
else if ( SM == SM_PlayToasty )
{
2006-02-28 01:13:44 +00:00
if ( g_bEasterEggs )
2003-03-16 19:11:51 +00:00
if ( ! m_Toasty . IsTransitioning () && ! m_Toasty . IsFinished () ) // don't play if we've already played it once
m_Toasty . StartTransitioning ();
2005-03-23 08:48:38 +00:00
}
else if ( SM >= SM_100Combo && SM <= SM_1000Combo )
{
int iCombo = ( SM - SM_100Combo + 1 ) * 100 ;
PlayAnnouncer ( ssprintf ( "gameplay %d combo" , iCombo ), 2 );
}
else if ( SM == SM_ComboStopped )
{
2004-02-16 05:29:33 +00:00
PlayAnnouncer ( "gameplay combo stopped" , 2 );
2005-03-23 08:48:38 +00:00
}
else if ( SM == SM_ComboContinuing )
{
2004-02-16 05:29:33 +00:00
PlayAnnouncer ( "gameplay combo overflow" , 2 );
2005-03-23 08:48:38 +00:00
}
else if ( SM >= SM_BattleTrickLevel1 && SM <= SM_BattleTrickLevel3 )
{
int iTrickLevel = SM - SM_BattleTrickLevel1 + 1 ;
PlayAnnouncer ( ssprintf ( "gameplay battle trick level%d" , iTrickLevel ), 3 );
2006-02-23 23:50:32 +00:00
if ( SM == SM_BattleTrickLevel1 ) m_soundBattleTrickLevel1 . Play ();
else if ( SM == SM_BattleTrickLevel2 ) m_soundBattleTrickLevel2 . Play ();
else if ( SM == SM_BattleTrickLevel3 ) m_soundBattleTrickLevel3 . Play ();
2005-03-23 08:48:38 +00:00
}
else if ( SM >= SM_BattleDamageLevel1 && SM <= SM_BattleDamageLevel3 )
{
int iDamageLevel = SM - SM_BattleDamageLevel1 + 1 ;
PlayAnnouncer ( ssprintf ( "gameplay battle damage level%d" , iDamageLevel ), 3 );
}
2006-02-04 20:14:04 +00:00
else if ( SM == SM_DoPrevScreen )
2005-03-23 08:48:38 +00:00
{
2003-12-15 06:24:59 +00:00
SongFinished ();
2007-08-20 10:45:28 +00:00
this -> StageFinished ( true );
2003-12-15 06:24:59 +00:00
2006-06-25 18:11:09 +00:00
m_sNextScreen = GetPrevScreen ();
2006-02-06 01:23:25 +00:00
if ( AdjustSync :: IsSyncDataChanged () )
2006-02-04 20:14:04 +00:00
ScreenSaveSync :: PromptSaveSync ( SM_GoToPrevScreen );
else
HandleScreenMessage ( SM_GoToPrevScreen );
2005-03-23 08:48:38 +00:00
}
2006-02-04 20:14:04 +00:00
else if ( SM == SM_DoNextScreen )
2005-03-23 08:48:38 +00:00
{
2005-04-16 05:05:25 +00:00
SongFinished ();
2007-08-20 10:45:28 +00:00
this -> StageFinished ( false );
2006-04-21 00:17:48 +00:00
//SaveReplay();
2006-02-04 20:14:04 +00:00
2006-02-06 01:23:25 +00:00
if ( AdjustSync :: IsSyncDataChanged () )
2006-02-04 20:14:04 +00:00
ScreenSaveSync :: PromptSaveSync ( SM_GoToNextScreen );
else
HandleScreenMessage ( SM_GoToNextScreen );
2005-03-23 08:48:38 +00:00
}
2005-07-04 23:41:33 +00:00
else if ( SM == SM_GainFocus )
{
/* We do this ourself. */
SOUND -> HandleSongTimer ( false );
}
2005-03-23 08:48:38 +00:00
else if ( SM == SM_LoseFocus )
{
2004-02-09 19:56:28 +00:00
/* We might have turned the song timer off. Be sure to turn it back on. */
SOUND -> HandleSongTimer ( true );
2005-03-23 08:48:38 +00:00
}
else if ( SM == SM_BeginFailed )
{
2002-05-20 08:59:37 +00:00
m_DancingState = STATE_OUTRO ;
2005-03-15 08:44:35 +00:00
AbortGiveUp ( false );
2007-01-25 00:50:57 +00:00
m_GameplayAssist . StopPlaying (); /* Stop any queued assist ticks. */
2005-10-13 22:52:25 +00:00
TweenOffScreen ();
2006-02-04 20:14:04 +00:00
m_Failed . StartTransitioning ( SM_DoNextScreen );
2002-05-20 08:59:37 +00:00
2002-08-01 13:42:56 +00:00
// show the survive time if extra stage
2006-08-06 02:37:42 +00:00
if ( GAMESTATE -> IsAnExtraStage () )
2002-08-01 13:42:56 +00:00
{
2007-10-27 01:51:58 +00:00
float fMaxAliveSeconds = 0 ;
2006-01-18 07:43:17 +00:00
FOREACH_EnabledPlayer ( p )
2007-10-27 01:51:58 +00:00
fMaxAliveSeconds = max ( fMaxAliveSeconds , STATSMAN -> m_CurStageStats . m_player [ p ]. m_fAliveSeconds );
m_textSurviveTime . SetText ( "TIME: " + SecondsToMMSSMsMs ( fMaxAliveSeconds ) );
2007-04-08 22:48:25 +00:00
ON_COMMAND ( m_textSurviveTime );
2002-08-01 13:42:56 +00:00
}
2003-08-25 17:15:47 +00:00
2004-02-15 23:10:40 +00:00
if ( GAMESTATE -> IsCourseMode () )
2006-01-18 09:00:09 +00:00
{
2005-03-11 02:38:08 +00:00
if ( GAMESTATE -> GetCourseSongIndex () >= int ( m_apSongsQueue . size () / 2 ) )
2004-04-12 20:11:36 +00:00
SOUND -> PlayOnceFromAnnouncer ( "gameplay oni failed halfway" );
2003-08-25 17:15:47 +00:00
else
2004-04-12 20:11:36 +00:00
SOUND -> PlayOnceFromAnnouncer ( "gameplay oni failed" );
2006-01-18 09:00:09 +00:00
}
2003-08-25 17:15:47 +00:00
else
2006-01-18 09:00:09 +00:00
{
2004-04-12 20:11:36 +00:00
SOUND -> PlayOnceFromAnnouncer ( "gameplay failed" );
2006-01-18 09:00:09 +00:00
}
2005-03-23 08:48:38 +00:00
}
else if ( SM == SM_Pause )
{
2005-03-11 04:12:48 +00:00
/* Ignore SM_Pause when in demonstration. */
if ( GAMESTATE -> m_bDemonstrationOrJukebox )
return ;
2005-03-11 03:54:40 +00:00
if ( ! m_bPaused )
PauseGame ( true );
2002-05-20 08:59:37 +00:00
}
2005-04-16 05:05:25 +00:00
ScreenWithMenuElements :: HandleScreenMessage ( SM );
2002-06-14 22:25:22 +00:00
}
2002-05-20 08:59:37 +00:00
2007-01-16 02:32:27 +00:00
void ScreenGameplay :: HandleMessage ( const Message & msg )
{
if ( msg == "Judgment" )
{
PlayerNumber pn ;
msg . GetParam ( "Player" , pn );
2002-05-20 08:59:37 +00:00
2007-01-16 02:32:27 +00:00
FOREACH_EnabledPlayerNumberInfo ( m_vPlayerInfo , pi )
{
if ( pi -> m_pn != pn )
continue ;
if ( ! pi -> GetPlayerState () -> m_PlayerOptions . GetCurrent (). m_bMuteOnError )
continue ;
2007-04-24 05:53:41 +00:00
RageSoundReader * pSoundReader = m_AutoKeysounds . GetPlayerSound ( pn );
if ( pSoundReader == NULL )
pSoundReader = m_AutoKeysounds . GetSharedSound ();
2007-01-16 02:32:27 +00:00
HoldNoteScore hns ;
msg . GetParam ( "HoldNoteScore" , hns );
TapNoteScore tns ;
msg . GetParam ( "TapNoteScore" , tns );
bool bOn = false ;
if ( hns != HoldNoteScore_Invalid )
bOn = hns != HNS_LetGo ;
else
bOn = tns != TNS_Miss ;
if ( pSoundReader )
pSoundReader -> SetProperty ( "Volume" , bOn ? 1.0f : 0.0f );
}
}
ScreenWithMenuElements :: HandleMessage ( msg );
}
2005-09-10 20:07:13 +00:00
void ScreenGameplay :: Cancel ( ScreenMessage smSendWhenDone )
{
m_pSoundMusic -> Stop ();
ScreenWithMenuElements :: Cancel ( smSendWhenDone );
}
2005-07-12 21:12:12 +00:00
Song * ScreenGameplay :: GetNextCourseSong () const
{
ASSERT ( GAMESTATE -> IsCourseMode () );
int iPlaySongIndex = GAMESTATE -> GetCourseSongIndex () + 1 ;
iPlaySongIndex %= m_apSongsQueue . size ();
return m_apSongsQueue [ iPlaySongIndex ];
}
2007-02-12 00:03:38 +00:00
PlayerInfo * ScreenGameplay :: GetPlayerInfo ( PlayerNumber pn )
{
FOREACH_EnabledPlayerNumberInfo ( m_vPlayerInfo , pi )
{
if ( pi -> m_pn == pn )
return &* pi ;
}
return NULL ;
}
2007-10-26 10:09:43 +00:00
PlayerInfo * ScreenGameplay :: GetDummyPlayerInfo ( int iDummyIndex )
{
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
{
if ( pi -> m_bIsDummy && pi -> m_iDummyIndex == iDummyIndex )
return &* pi ;
}
return NULL ;
}
2006-04-21 00:17:48 +00:00
void ScreenGameplay :: SaveReplay ()
2005-11-22 21:18:45 +00:00
{
FOREACH_HumanPlayer ( pn )
{
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
{
2006-07-17 00:58:33 +00:00
XNode * p = pi -> m_pPlayer -> GetNoteData (). CreateNode ();
2005-12-02 03:46:27 +00:00
//
// Find a file name for the screenshot
//
2006-09-16 03:17:18 +00:00
FILEMAN -> FlushDirCache ( "Save/" );
2005-12-02 03:46:27 +00:00
2006-01-22 01:00:06 +00:00
vector < RString > files ;
2006-09-16 03:12:07 +00:00
GetDirListing ( "Save/replay*" , files , false , false );
2005-12-02 03:46:27 +00:00
sort ( files . begin (), files . end () );
2006-09-16 03:12:07 +00:00
/* Files should be of the form "replay#####.xxx". */
2005-12-02 03:46:27 +00:00
int iIndex = 0 ;
for ( int i = files . size () - 1 ; i >= 0 ; -- i )
{
2006-04-21 00:17:48 +00:00
static Regex re ( "^replay([0-9]{5}) \\ .... $ " ) ;
2006-01-22 01:00:06 +00:00
vector < RString > matches ;
2005-12-02 03:46:27 +00:00
if ( ! re . Compare ( files [ i ], matches ) )
continue ;
ASSERT ( matches . size () == 1 );
iIndex = atoi ( matches [ 0 ] ) + 1 ;
break ;
}
2006-04-21 00:17:48 +00:00
RString sFileName = ssprintf ( "replay%05d.xml" , iIndex );
2005-12-02 03:46:27 +00:00
2006-10-02 05:53:56 +00:00
XmlFileUtil :: SaveToFile ( p , "Save/" + sFileName );
2005-11-22 21:18:45 +00:00
SAFE_DELETE ( p );
return ;
}
}
}
2005-07-12 21:12:12 +00:00
// lua start
#include "LuaBinding.h"
class LunaScreenGameplay : public Luna < ScreenGameplay >
{
public :
static int GetNextCourseSong ( T * p , lua_State * L ) { p -> GetNextCourseSong () -> PushSelf ( L ); return 1 ; }
2006-02-28 21:55:58 +00:00
static int Center1Player ( T * p , lua_State * L ) { lua_pushboolean ( L , p -> Center1Player () ); return 1 ; }
2007-05-29 21:19:38 +00:00
static int GetLifeMeter ( T * p , lua_State * L )
2007-02-12 00:03:38 +00:00
{
PlayerNumber pn = Enum :: Check < PlayerNumber > ( L , 1 );
2007-07-12 11:01:25 +00:00
PlayerInfo * pi = p -> GetPlayerInfo ( pn );
if ( pi == NULL )
return 0 ;
LifeMeter * pLM = pi -> m_pLifeMeter ;
2007-05-29 21:19:38 +00:00
if ( pLM == NULL )
2007-02-12 00:03:38 +00:00
return 0 ;
2007-05-29 21:19:38 +00:00
pLM -> PushSelf ( L );
2007-02-12 00:03:38 +00:00
return 1 ;
}
2007-10-26 10:09:43 +00:00
static int GetDummyPlayerInfo ( T * p , lua_State * L )
{
int iDummyIndex = IArg ( 1 );
PlayerInfo * pi = p -> GetDummyPlayerInfo ( iDummyIndex );
if ( pi == NULL )
return 0 ;
pi -> PushSelf ( L );
return 1 ;
}
2006-09-27 19:47:52 +00:00
LunaScreenGameplay ()
2005-07-12 21:12:12 +00:00
{
2005-09-10 02:47:04 +00:00
ADD_METHOD ( GetNextCourseSong );
2006-02-28 21:55:58 +00:00
ADD_METHOD ( Center1Player );
2007-05-29 21:19:38 +00:00
ADD_METHOD ( GetLifeMeter );
2007-10-26 10:09:43 +00:00
ADD_METHOD ( GetDummyPlayerInfo );
2005-07-12 21:12:12 +00:00
}
};
LUA_REGISTER_DERIVED_CLASS ( ScreenGameplay , ScreenWithMenuElements )
2007-02-12 00:03:38 +00:00
class LunaPlayerInfo : public Luna < PlayerInfo >
{
public :
static int GetLifeMeter ( T * p , lua_State * L ) { p -> m_pLifeMeter -> PushSelf ( L ); return 1 ; }
2007-10-28 23:59:33 +00:00
static int GetStepsQueueWrapped ( T * p , lua_State * L )
2007-10-26 10:09:43 +00:00
{
2007-10-28 23:59:33 +00:00
int iIndex = IArg ( 1 );
iIndex %= p -> m_vpStepsQueue . size ();
Steps * pSteps = p -> m_vpStepsQueue [ iIndex ];
2007-10-26 10:09:43 +00:00
pSteps -> PushSelf ( L );
return 1 ;
}
2007-02-12 00:03:38 +00:00
LunaPlayerInfo ()
{
ADD_METHOD ( GetLifeMeter );
2007-10-28 23:59:33 +00:00
ADD_METHOD ( GetStepsQueueWrapped );
2007-02-12 00:03:38 +00:00
}
};
LUA_REGISTER_CLASS ( PlayerInfo )
2005-07-12 21:12:12 +00:00
// lua end
2005-05-18 07:15:56 +00:00
2004-06-08 05:22:33 +00:00
/*
* (c) 2001-2004 Chris Danford, 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.
*/