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"
2002-05-20 08:59:37 +00:00
# include "GameManager.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"
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"
# include "DifficultyIcon.h"
# include "DifficultyMeter.h"
2005-08-26 17:39:53 +00:00
# include "PlayerScoreList.h"
2005-09-05 02:26:50 +00:00
# include "InputEventPlus.h"
2005-11-22 21:18:45 +00:00
# include "XmlFile.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")
# define EVAL_ON_FAIL THEME->GetMetricB(m_sName,"ShowEvaluationOnFail")
# define SHOW_SCORE_IN_RAVE THEME->GetMetricB(m_sName,"ShowScoreInRave")
# define SONG_POSITION_METER_WIDTH THEME->GetMetricF(m_sName,"SongPositionMeterWidth")
2005-08-23 21:38:51 +00:00
# define PLAYER_X( sName, styleType ) THEME->GetMetricF(m_sName,ssprintf("Player%s%sX",sName.c_str(),StyleTypeToString(styleType).c_str()))
2005-04-09 11:32:10 +00:00
# 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 " ) ;
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
2005-03-28 08:01:36 +00:00
AutoScreenMessage ( SM_GoToScreenAfterBack )
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
2005-05-19 01:26:41 +00:00
static Preference < float > g_fNetStartOffset ( " NetworkStartOffset " , - 3.0 ) ;
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 ;
m_mp = MultiPlayer_INVALID ;
m_bIsDummy = false ;
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 ;
m_pDifficultyIcon = NULL ;
m_pDifficultyMeter = NULL ;
}
2005-08-23 23:48:23 +00:00
void PlayerInfo : : Load ( PlayerNumber pn , MultiPlayer mp , bool bShowNoteField )
2005-08-23 21:38:51 +00:00
{
m_pn = pn ;
m_mp = mp ;
m_bIsDummy = false ;
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 :
if ( GAMESTATE - > m_SongOptions . m_LifeType = = SongOptions : : LIFE_TIME )
m_pPrimaryScoreDisplay = new ScoreDisplayLifeTime ;
else
m_pPrimaryScoreDisplay = new ScoreDisplayOni ;
break ;
default :
ASSERT ( 0 ) ;
}
2005-08-23 21:38:51 +00:00
}
2005-08-26 17:39:53 +00:00
if ( m_pPrimaryScoreDisplay )
m_pPrimaryScoreDisplay - > Init ( GetPlayerState ( ) , GetPlayerStageStats ( ) ) ;
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 )
{
m_pSecondaryScoreDisplay - > Init ( GetPlayerState ( ) , GetPlayerStageStats ( ) ) ;
}
2006-01-18 07:43:17 +00:00
switch ( PREFSMAN - > m_ScoringType )
2005-08-23 21:38:51 +00:00
{
default : ASSERT ( 0 ) ;
2005-10-08 04:50:28 +00:00
case PrefsManager : : SCORING_NEW :
case PrefsManager : : SCORING_OLD :
2005-10-08 02:10:32 +00:00
m_pPrimaryScoreKeeper = new ScoreKeeperNormal (
2005-08-23 21:38:51 +00:00
GetPlayerState ( ) ,
GetPlayerStageStats ( ) ) ;
break ;
}
switch ( GAMESTATE - > m_PlayMode )
{
case PLAY_MODE_RAVE :
m_pSecondaryScoreKeeper = new ScoreKeeperRave (
GetPlayerState ( ) ,
GetPlayerStageStats ( ) ) ;
break ;
}
2005-09-03 05:49:30 +00:00
switch ( GAMESTATE - > m_PlayMode )
{
case PLAY_MODE_BATTLE :
case PLAY_MODE_RAVE :
break ;
}
2005-08-23 21:38:51 +00:00
m_ptextPlayerOptions = NULL ;
m_pActiveAttackList = NULL ;
2005-08-26 17:39:53 +00:00
m_pPlayer = new Player ( bShowNoteField , true ) ;
2005-08-23 21:38:51 +00:00
m_pInventory = NULL ;
m_pDifficultyIcon = NULL ;
m_pDifficultyMeter = NULL ;
if ( IsMultiPlayer ( ) )
{
2005-08-26 17:39:53 +00:00
GetPlayerState ( ) - > m_CurrentPlayerOptions = GAMESTATE - > m_pPlayerState [ PLAYER_1 ] - > m_CurrentPlayerOptions ;
GetPlayerState ( ) - > m_PlayerOptions = GAMESTATE - > m_pPlayerState [ PLAYER_1 ] - > m_PlayerOptions ;
2005-11-02 20:02:47 +00:00
GetPlayerState ( ) - > m_StagePlayerOptions = GAMESTATE - > m_pPlayerState [ PLAYER_1 ] - > m_StagePlayerOptions ;
2005-08-26 17:39:53 +00:00
GetPlayerState ( ) - > m_StoredPlayerOptions = GAMESTATE - > m_pPlayerState [ PLAYER_1 ] - > m_StoredPlayerOptions ;
2005-08-23 21:38:51 +00:00
}
}
2005-08-23 23:48:23 +00:00
void PlayerInfo : : LoadDummyP1 ( )
2005-08-23 21:38:51 +00:00
{
m_pn = PLAYER_1 ;
m_bIsDummy = true ;
// don't init any of the scoring objects
2005-08-26 17:39:53 +00:00
m_pPlayer = new Player ( true , false ) ;
2005-08-23 21:38:51 +00:00
m_PlayerStateDummy = * GAMESTATE - > m_pPlayerState [ PLAYER_1 ] ;
m_PlayerStateDummy . m_PlayerController = PC_AUTOPLAY ;
}
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 ) ;
SAFE_DELETE ( m_pDifficultyIcon ) ;
SAFE_DELETE ( m_pDifficultyMeter ) ;
}
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
{
if ( m_bIsDummy )
return & m_PlayerStageStatsDummy ;
return IsMultiPlayer ( ) ?
& STATSMAN - > m_CurStageStats . m_multiPlayer [ GetPlayerStateAndStageStatsIndex ( ) ] :
& STATSMAN - > m_CurStageStats . m_player [ GetPlayerStateAndStageStatsIndex ( ) ] ;
}
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 ) ;
if ( m_mp ! = MultiPlayer_INVALID )
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
{
iter + + ;
for ( ; iter ! = v . end ( ) ; iter + + )
{
if ( ! iter - > IsEnabled ( ) )
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
{
iter + + ;
for ( ; iter ! = v . end ( ) ; iter + + )
{
if ( iter - > m_bIsDummy )
continue ;
if ( ! iter - > IsEnabled ( ) )
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
{
iter + + ;
for ( ; iter ! = v . end ( ) ; iter + + )
{
if ( iter - > m_bIsDummy )
continue ;
if ( ! iter - > IsEnabled ( ) )
continue ;
if ( iter - > m_mp ! = MultiPlayer_INVALID )
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
{
iter + + ;
for ( ; iter ! = v . end ( ) ; iter + + )
{
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
{
iter + + ;
for ( ; iter ! = v . end ( ) ; iter + + )
{
if ( ! iter - > m_pPlayer - > HasNoteField ( ) )
continue ;
return iter ;
}
return iter ;
}
2006-01-15 19:49:02 +00:00
ScreenGameplay : : ScreenGameplay ( )
2002-05-20 08:59:37 +00:00
{
2005-08-26 17:39:53 +00:00
m_pPlayerScoreList = NULL ;
2004-02-18 02:31:43 +00:00
}
2002-05-20 08:59:37 +00:00
2004-02-18 02:31:43 +00:00
void ScreenGameplay : : Init ( )
{
2006-01-15 19:48:11 +00:00
PLAYER_TYPE . Load ( m_sName , " PlayerType " ) ;
GIVE_UP_TEXT . Load ( m_sName , " GiveUpText " ) ;
GIVE_UP_ABORTED_TEXT . Load ( m_sName , " GiveUpAbortedText " ) ;
MUSIC_FADE_OUT_SECONDS . Load ( m_sName , " MusicFadeOutSeconds " ) ;
START_GIVES_UP . Load ( m_sName , " StartGivesUp " ) ;
BACK_GIVES_UP . Load ( m_sName , " BackGivesUp " ) ;
GIVING_UP_GOES_TO_PREV_SCREEN . Load ( m_sName , " GivingUpGoesToPrevScreen " ) ;
GIVING_UP_GOES_TO_NEXT_SCREEN . Load ( m_sName , " GivingUpGoesToNextScreen " ) ;
FAIL_AFTER_30_MISSES . Load ( m_sName , " FailAfter30Misses " ) ;
USE_FORCED_MODIFIERS_IN_BEGINNER . Load ( m_sName , " UseForcedModifiersInBeginner " ) ;
FORCED_MODIFIERS_IN_BEGINNER . Load ( m_sName , " ForcedModifiersInBeginner " ) ;
2005-08-23 21:38:51 +00:00
this - > FillPlayerInfo ( m_vPlayerInfo ) ;
ASSERT_M ( ! m_vPlayerInfo . empty ( ) , " m_vPlayerInfo must be filled by FillPlayerInfo " ) ;
2005-04-01 12:35:49 +00:00
ScreenWithMenuElements : : Init ( ) ;
2005-01-03 22:44:19 +00:00
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
2005-01-03 23:20:11 +00:00
if ( GAMESTATE - > m_bDemonstrationOrJukebox )
2004-03-23 06:11:10 +00:00
LIGHTSMAN - > SetLightsMode ( LIGHTSMODE_DEMONSTRATION ) ;
2003-11-16 04:45:12 +00:00
else
2004-03-30 04:44:09 +00:00
LIGHTSMAN - > SetLightsMode ( LIGHTSMODE_GAMEPLAY ) ;
2003-11-16 04:45:12 +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
2003-02-24 03:26:33 +00:00
/* Save selected options before we change them. */
GAMESTATE - > StoreSelectedOptions ( ) ;
2004-03-30 03:55:54 +00:00
/* Save settings to the profile now. Don't do this on extra stages, since the
* user doesn't have full control; saving would force profiles to DIFFICULTY_HARD
* and save over their default modifiers every time someone got an extra stage.
* Do this before course modifiers are set up. */
if ( ! GAMESTATE - > IsExtraStage ( ) & & ! GAMESTATE - > IsExtraStage2 ( ) )
{
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
2002-08-02 09:31:06 +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 )
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 ) ;
2002-07-23 01:41:40 +00:00
2005-02-16 03:25:45 +00:00
STATSMAN - > m_CurStageStats . playMode = GAMESTATE - > m_PlayMode ;
STATSMAN - > m_CurStageStats . pStyle = GAMESTATE - > m_pCurStyle ;
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
2003-09-06 01:35:29 +00:00
if ( GAMESTATE - > IsExtraStage ( ) )
2005-02-16 03:25:45 +00:00
STATSMAN - > m_CurStageStats . StageType = StageStats : : STAGE_EXTRA ;
2003-09-06 01:35:29 +00:00
else if ( GAMESTATE - > IsExtraStage2 ( ) )
2005-02-16 03:25:45 +00:00
STATSMAN - > m_CurStageStats . StageType = StageStats : : STAGE_EXTRA2 ;
2003-09-06 01:35:29 +00:00
else
2005-02-16 03:25:45 +00:00
STATSMAN - > m_CurStageStats . StageType = StageStats : : STAGE_NORMAL ;
2003-09-06 01:35:29 +00:00
2002-06-14 22:25:22 +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-02-27 10:56:37 +00:00
2005-03-11 02:52:40 +00:00
m_SongBackground . SetName ( " SongBackground " ) ;
2005-03-11 02:12:21 +00:00
m_SongBackground . SetDrawOrder ( DRAW_ORDER_BEFORE_EVERYTHING ) ;
2005-03-11 02:52:40 +00:00
ON_COMMAND ( m_SongBackground ) ;
2005-03-11 02:12:21 +00:00
this - > AddChild ( & m_SongBackground ) ;
2004-01-07 00:13:32 +00:00
2005-03-11 02:52:40 +00:00
m_SongForeground . SetName ( " SongForeground " ) ;
m_SongForeground . SetDrawOrder ( DRAW_ORDER_OVERLAY + 1 ) ; // on top of the overlay, but under transitions
2005-09-10 03:46:32 +00:00
ON_COMMAND ( m_SongForeground ) ;
2005-03-11 02:52:40 +00:00
this - > AddChild ( & m_SongForeground ) ;
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-20 08:59:37 +00:00
{
2005-08-23 21:38:51 +00:00
pi - > m_pPlayer - > SetName ( ssprintf ( " Player%s " , pi - > GetName ( ) . c_str ( ) ) ) ;
// 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.
2005-08-26 17:39:53 +00:00
float fPlayerX = PLAYER_X ( pi - > GetName ( ) , GAMESTATE - > GetCurrentStyle ( ) - > m_StyleType ) ;
2005-08-23 21:38:51 +00:00
2005-08-26 17:39:53 +00:00
/* Perhaps this should be handled better by defining a new
* StyleType for ONE_PLAYER_ONE_CREDIT_AND_ONE_COMPUTER,
2006-01-27 07:09:43 +00:00
* but for now just ignore Center1Player when it's Battle or Rave
2005-08-26 17:39:53 +00:00
* Mode. This doesn't begin to address two-player solo (6 arrows) */
2006-01-27 07:09:43 +00:00
if ( PREFSMAN - > m_bCenter1Player & &
2005-08-26 17:39:53 +00:00
GAMESTATE - > m_PlayMode ! = PLAY_MODE_BATTLE & &
GAMESTATE - > m_PlayMode ! = PLAY_MODE_RAVE & &
GAMESTATE - > GetCurrentStyle ( ) - > m_StyleType = = ONE_PLAYER_ONE_SIDE )
fPlayerX = SCREEN_CENTER_X ;
pi - > m_pPlayer - > SetXY ( fPlayerX , SCREEN_CENTER_Y ) ;
2005-08-23 21:38:51 +00:00
this - > AddChild ( pi - > m_pPlayer ) ;
}
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
{
if ( pi - > m_pPlayer - > HasNoteField ( ) )
{
pi - > m_sprOniGameOver . Load ( THEME - > GetPathG ( m_sName , " oni gameover " ) ) ;
pi - > m_sprOniGameOver - > SetName ( ssprintf ( " OniGameOver%s " , pi - > GetName ( ) . c_str ( ) ) ) ;
SET_XY_AND_ON_COMMAND ( pi - > m_sprOniGameOver ) ;
this - > AddChild ( pi - > m_sprOniGameOver ) ;
}
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
2004-05-02 03:01:27 +00:00
m_SongFinished . SetDrawOrder ( DRAW_ORDER_TRANSITIONS - 1 ) ;
2005-09-10 05:56:09 +00:00
m_SongFinished . Load ( THEME - > GetPathB ( m_sName , " song finished " ) ) ;
2004-03-06 10:07:17 +00:00
this - > AddChild ( & m_SongFinished ) ;
2002-06-14 22:25:22 +00:00
2005-02-06 03:32:53 +00:00
bool bBattery = GAMESTATE - > m_SongOptions . m_LifeType = = SongOptions : : LIFE_BATTERY ;
2003-11-19 12:33:52 +00:00
//
// Add LifeFrame
//
2005-02-06 03:32:53 +00:00
m_sprLifeFrame . Load ( THEME - > GetPathG ( m_sName , bBattery ? " oni life frame " : " life frame " ) ) ;
2005-05-06 10:48:32 +00:00
m_sprLifeFrame - > SetName ( " LifeFrame " ) ;
2003-04-13 21:17:14 +00:00
SET_XY ( m_sprLifeFrame ) ;
2005-05-06 10:48:32 +00:00
this - > AddChild ( m_sprLifeFrame ) ;
2002-10-18 19:01:32 +00:00
2003-07-08 19:56:56 +00:00
//
2003-11-19 12:33:52 +00:00
// Add score frame
//
2005-02-06 03:32:53 +00:00
m_sprScoreFrame . Load ( THEME - > GetPathG ( m_sName , bBattery ? " oni score frame " : " score frame " ) ) ;
2004-05-31 08:58:43 +00:00
m_sprScoreFrame . SetName ( " ScoreFrame " ) ;
2003-11-19 12:33:52 +00:00
SET_XY ( m_sprScoreFrame ) ;
this - > AddChild ( & m_sprScoreFrame ) ;
//
// 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 " ) ;
2003-07-08 19:56:56 +00:00
SET_XY ( * m_pCombinedLifeMeter ) ;
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 )
2003-06-30 18:08:27 +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
2005-10-27 21:55:24 +00:00
pi - > m_pLifeMeter = LifeMeter : : MakeLifeMeter ( GAMESTATE - > m_SongOptions . 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 ( ) ) ) ;
SET_XY ( pi - > m_pLifeMeter ) ;
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:
2005-08-24 20:44:15 +00:00
if ( NSMAN - > useSMserver & & ! GAMESTATE - > PlayerUsingBothSides ( ) )
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 ) ) ;
SET_XY ( m_Scoreboard [ col ] ) ;
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-07-23 01:41:40 +00:00
2004-07-25 06:29:50 +00:00
m_MaxCombo . LoadFromFont ( THEME - > GetPathF ( m_sName , " max combo " ) ) ;
2003-04-13 21:17:14 +00:00
m_MaxCombo . SetName ( " MaxCombo " ) ;
SET_XY ( m_MaxCombo ) ;
2005-08-23 21:38:51 +00:00
m_MaxCombo . SetText ( ssprintf ( " %d " , m_vPlayerInfo [ 0 ] . GetPlayerStageStats ( ) - > iMaxCombo ) ) ; // TODO: Make this work for both players
2002-11-07 19:42:39 +00:00
this - > AddChild ( & m_MaxCombo ) ;
2005-08-26 17:39:53 +00:00
if ( GAMESTATE - > m_bMultiplayer )
{
vector < const PlayerState * > vpPlayerState ;
vector < const PlayerStageStats * > vpPlayerStageStats ;
FOREACH_EnabledMultiPlayer ( p )
{
vpPlayerState . push_back ( m_vPlayerInfo [ p ] . GetPlayerState ( ) ) ;
vpPlayerStageStats . push_back ( m_vPlayerInfo [ p ] . GetPlayerStageStats ( ) ) ;
}
m_pPlayerScoreList = new PlayerScoreList ;
m_pPlayerScoreList - > Init ( vpPlayerState , vpPlayerStageStats ) ;
m_pPlayerScoreList - > SetName ( " PlayerScoreList " ) ;
SET_XY ( m_pPlayerScoreList ) ;
this - > AddChild ( m_pPlayerScoreList ) ;
}
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 ( ) ) ) ;
SET_XY ( pi - > m_pPrimaryScoreDisplay ) ;
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 ( ) ) ) ;
SET_XY ( pi - > m_pSecondaryScoreDisplay ) ;
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-05-07 09:58:23 +00:00
m_sprCourseSongNumber . SetName ( " CourseSongNumber " ) ;
SET_XY ( m_sprCourseSongNumber ) ;
2005-08-23 21:38:51 +00:00
if ( GAMESTATE - > IsCourseMode ( ) )
this - > AddChild ( & m_sprCourseSongNumber ) ;
2004-01-23 06:20:28 +00:00
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerNumberInfo ( m_vPlayerInfo , pi )
2003-11-29 11:16:36 +00:00
{
2005-08-23 21:38:51 +00:00
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 ( ) ) ) ;
SET_XY ( pi - > m_ptextCourseSongNumber ) ;
pi - > m_ptextCourseSongNumber - > SetText ( " " ) ;
pi - > m_ptextCourseSongNumber - > SetDiffuse ( RageColor ( 0 , 0.5f , 1 , 1 ) ) ; // light blue
this - > AddChild ( pi - > m_ptextCourseSongNumber ) ;
}
2003-12-18 23:19:02 +00:00
2005-08-23 21:38:51 +00:00
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 ( ) ) ) ;
SET_XY ( pi - > m_ptextStepsDescription ) ;
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 ( ) ) ) ;
SET_XY ( pi - > m_ptextPlayerOptions ) ;
this - > AddChild ( pi - > m_ptextPlayerOptions ) ;
2002-06-14 22:25:22 +00:00
2006-01-18 20:35:55 +00:00
//
// Difficulty icon and meter
//
2005-08-23 21:38:51 +00:00
ASSERT ( pi - > m_pDifficultyIcon = = NULL ) ;
pi - > m_pDifficultyIcon = new DifficultyIcon ;
2006-01-07 04:11:29 +00:00
pi - > m_pDifficultyIcon - > Load ( THEME - > GetPathG ( m_sName , ssprintf ( " difficulty icons %dx%d " , NUM_PLAYERS , NUM_Difficulty ) ) ) ;
2003-02-28 20:50:28 +00:00
/* Position it in LoadNextSong. */
2005-08-23 21:38:51 +00:00
this - > AddChild ( pi - > m_pDifficultyIcon ) ;
2004-05-31 06:04:30 +00:00
2005-08-23 21:38:51 +00:00
ASSERT ( pi - > m_pDifficultyMeter = = NULL ) ;
pi - > m_pDifficultyMeter = new DifficultyMeter ;
pi - > m_pDifficultyMeter - > Load ( m_sName + ssprintf ( " DifficultyMeter%s " , pi - > GetName ( ) . c_str ( ) ) ) ;
2004-05-31 06:04:30 +00:00
/* Position it in LoadNextSong. */
2005-08-23 21:38:51 +00:00
this - > AddChild ( pi - > m_pDifficultyMeter ) ;
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 " ) ;
SET_XY ( m_textSongOptions ) ;
m_textSongOptions . SetText ( GAMESTATE - > m_SongOptions . GetString ( ) ) ;
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 ( ) ) ) ;
SET_XY ( pi - > m_pActiveAttackList ) ;
this - > AddChild ( pi - > m_pActiveAttackList ) ;
}
2002-06-14 22:25:22 +00:00
2004-12-01 20:42:15 +00:00
if ( PREFSMAN - > m_bShowLyrics )
this - > AddChild ( & m_LyricDisplay ) ;
2002-08-23 20:18:29 +00:00
2003-01-11 08:55:21 +00:00
2003-11-17 03:34:13 +00:00
m_BPMDisplay . SetName ( " BPMDisplay " ) ;
2003-11-14 18:31:28 +00:00
m_BPMDisplay . Load ( ) ;
2003-04-13 21:17:14 +00:00
SET_XY ( m_BPMDisplay ) ;
2003-03-09 00:55:49 +00:00
this - > AddChild ( & m_BPMDisplay ) ;
2004-12-18 08:15:19 +00:00
m_fLastBPS = 0 ;
2003-03-09 00:55:49 +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 ) ;
2002-05-20 08:59:37 +00:00
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 ) ;
2002-05-20 08:59:37 +00:00
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 ) ;
2002-07-27 19:29:51 +00:00
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 " ) ;
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 ) ;
2006-01-18 20:33:17 +00:00
m_soundAssistTick . Load ( THEME - > GetPathS ( m_sName , " assist tick " ) , true ) ;
2003-03-09 00:55:49 +00:00
2003-03-30 20:18:46 +00:00
if ( GAMESTATE - > IsExtraStage ( ) | | GAMESTATE - > IsExtraStage2 ( ) ) // 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 " ) ;
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-01-18 20:33:17 +00:00
m_SongBackground . Init ( ) ;
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
{
pi - > m_pPlayer - > Init (
2005-03-18 03:17:52 +00:00
PLAYER_TYPE ,
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 ( ) ;
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 ( ) ) ;
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 ( ) ;
this - > SortByDrawOrder ( ) ;
2003-09-06 03:25:45 +00:00
m_GiveUpTimer . SetZero ( ) ;
2002-05-20 08:59:37 +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 )
{
2005-01-31 04:41:25 +00:00
ASSERT ( e - > pSteps ) ;
2005-08-23 21:38:51 +00:00
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 )
{
pi - > GetPlayerState ( ) - > m_StagePlayerOptions . FromString ( " clearall, " + CommonMetrics : : DEFAULT_MODIFIERS . GetValue ( ) , true ) ;
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-11-02 20:02:47 +00:00
if ( pSteps - > GetDifficulty ( ) = = DIFFICULTY_BEGINNER & & ( bool ) USE_FORCED_MODIFIERS_IN_BEGINNER )
{
pi - > GetPlayerState ( ) - > m_StagePlayerOptions . FromString ( FORCED_MODIFIERS_IN_BEGINNER , true ) ;
pi - > GetPlayerState ( ) - > RebuildPlayerOptionsFromActiveAttacks ( ) ;
}
2005-01-03 23:29:40 +00:00
}
}
2005-04-20 06:13:06 +00:00
// Fill StageStats
STATSMAN - > m_CurStageStats . vpPossibleSongs = m_apSongsQueue ;
2005-08-23 21:38:51 +00:00
FOREACH ( PlayerInfo , m_vPlayerInfo , pi )
{
if ( pi - > GetPlayerStageStats ( ) )
pi - > GetPlayerStageStats ( ) - > vpPossibleSteps = pi - > m_vpStepsQueue ;
}
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
SAFE_DELETE ( m_pPlayerScoreList ) ;
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
2004-01-12 09:36:01 +00:00
m_soundAssistTick . StopPlaying ( ) ; /* Stop any queued assist ticks. */
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
{
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
}
2002-06-24 22:04:31 +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 ;
GAMESTATE - > m_pCurSteps [ pi - > GetStepsAndTrailIndex ( ) ] . Set ( pi - > m_vpStepsQueue [ iSongIndex ] ) ;
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 ;
2005-08-23 21:38:51 +00:00
GAMESTATE - > m_pCurSteps [ pi - > GetStepsAndTrailIndex ( ) ] - > GetNoteData ( originalNoteData ) ;
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 ) ;
2004-10-24 10:45:30 +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 21:39:00 +00:00
/* Update attack bOn flags. */
pi - > GetPlayerState ( ) - > Update ( 0 ) ;
2006-01-12 19:24:13 +00:00
}
2005-04-11 07:59:27 +00:00
// load player
{
NoteData nd = ndTransformed ;
NoteDataUtil : : RemoveAllTapsOfType ( nd , TapNote : : autoKeysound ) ;
2005-08-23 21:38:51 +00:00
pi - > m_pPlayer - > Load ( nd ) ;
2005-04-11 07:59:27 +00:00
}
2004-10-24 10:45:30 +00:00
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
}
2004-07-23 04:45:48 +00:00
2003-12-23 02:18:27 +00:00
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 ) ;
2005-05-20 08:57:59 +00:00
GAMESTATE - > m_SongOptions . FromString ( a . sModifiers ) ;
2005-04-11 07:59:27 +00:00
}
2005-03-12 05:04:24 +00:00
2005-04-11 07:59:27 +00:00
/* Update attack bOn flags. */
2006-01-18 22:20:21 +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. */
2005-08-23 21:38:51 +00:00
pi - > GetPlayerState ( ) - > m_CurrentPlayerOptions = pi - > GetPlayerState ( ) - > m_PlayerOptions ;
2005-04-11 07:59:27 +00:00
}
2003-12-23 02:18:27 +00:00
}
2005-05-06 10:48:32 +00:00
void ScreenGameplay : : LoadCourseSongNumber ( int iSongNumber )
2004-02-14 00:39:24 +00:00
{
if ( ! GAMESTATE - > IsCourseMode ( ) )
return ;
2006-01-22 01:00:06 +00:00
const RString path = THEME - > GetPathG ( m_sName , ssprintf ( " course song %i " , iSongNumber + 1 ) , true ) ;
2005-05-07 09:58:23 +00:00
if ( path ! = " " )
m_sprCourseSongNumber . Load ( path ) ;
else
m_sprCourseSongNumber . UnloadTexture ( ) ;
SCREENMAN - > ZeroNextUpdate ( ) ;
2004-02-14 00:39:24 +00:00
}
2005-09-09 21:49:29 +00:00
void ScreenGameplay : : ReloadCurrentSong ( )
{
FOREACH_EnabledPlayerInfoNotDummy ( m_vPlayerInfo , pi )
pi - > GetPlayerStageStats ( ) - > iSongsPlayed - - ;
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
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfoNotDummy ( m_vPlayerInfo , pi )
2004-04-18 18:42:42 +00:00
{
2005-08-23 21:38:51 +00:00
pi - > GetPlayerStageStats ( ) - > iSongsPlayed + + ;
if ( pi - > m_ptextCourseSongNumber )
2005-10-02 19:58:40 +00:00
pi - > m_ptextCourseSongNumber - > SetText ( ssprintf ( " %d " , pi - > GetPlayerStageStats ( ) - > 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
// super hack
if ( GAMESTATE - > m_bMultiplayer )
STATSMAN - > m_CurStageStats . m_player [ GAMESTATE - > m_MasterPlayerNumber ] . iSongsPlayed + + ;
2005-02-25 04:18:28 +00:00
LoadCourseSongNumber ( GAMESTATE - > GetCourseSongIndex ( ) ) ;
2003-12-18 23:19:02 +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 ] ) ;
2005-04-20 06:13:06 +00:00
STATSMAN - > m_CurStageStats . 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();
2005-11-02 20:02:47 +00:00
GAMESTATE - > RestoreStageOptions ( ) ;
2002-06-14 22:25:22 +00:00
2004-08-25 08:56:58 +00:00
/* If we're in battery mode, force FailImmediate. We assume in PlayerMinus::Step that
* failed players can't step. */
if ( GAMESTATE - > m_SongOptions . m_LifeType = = SongOptions : : LIFE_BATTERY )
GAMESTATE - > m_SongOptions . m_FailType = SongOptions : : FAIL_IMMEDIATE ;
2003-02-17 19:52:16 +00:00
m_textSongOptions . SetText ( GAMESTATE - > m_SongOptions . GetString ( ) ) ;
2002-07-28 20:28:37 +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 ( ) ] ;
pi - > GetPlayerStageStats ( ) - > vpPlayedSteps . push_back ( pSteps ) ;
2003-03-26 23:08:05 +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-01-31 09:53:48 +00:00
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 ) ;
}
2003-03-26 23:08:05 +00:00
2005-08-23 21:38:51 +00:00
if ( pi - > m_ptextPlayerOptions )
pi - > m_ptextPlayerOptions - > SetText ( pi - > GetPlayerState ( ) - > m_PlayerOptions . GetString ( ) ) ;
if ( pi - > m_pActiveAttackList )
pi - > m_pActiveAttackList - > Refresh ( ) ;
2003-01-10 02:22:07 +00:00
2004-06-06 21:30:47 +00:00
// reset oni game over graphic
2005-08-23 21:38:51 +00:00
SET_XY_AND_ON_COMMAND ( pi - > m_sprOniGameOver ) ;
2002-08-01 21:55:40 +00:00
2005-08-23 21:38:51 +00:00
if ( GAMESTATE - > m_SongOptions . m_LifeType = = SongOptions : : LIFE_BATTERY & & pi - > GetPlayerStageStats ( ) - > bFailed ) // already failed
pi - > ShowOniGameOver ( ) ;
2002-08-01 21:55:40 +00:00
2005-04-05 08:30:57 +00:00
if ( GAMESTATE - > m_SongOptions . m_LifeType = = SongOptions : : LIFE_BAR & &
GAMESTATE - > m_PlayMode = = PLAY_MODE_REGULAR & &
! GAMESTATE - > IsEventMode ( ) & &
! GAMESTATE - > m_bDemonstrationOrJukebox )
2004-06-06 21:30:47 +00:00
{
2005-08-23 21:38:51 +00:00
if ( pi - > m_pLifeMeter )
pi - > m_pLifeMeter - > UpdateNonstopLifebar (
GAMESTATE - > GetStageIndex ( ) ,
PREFSMAN - > m_iSongsPerPlay ,
PREFSMAN - > m_iProgressiveStageLifebar ) ;
2004-06-06 21:30:47 +00:00
}
if ( GAMESTATE - > m_SongOptions . m_LifeType = = SongOptions : : LIFE_BAR & & GAMESTATE - > m_PlayMode = = PLAY_MODE_NONSTOP )
{
2005-08-23 21:38:51 +00:00
if ( pi - > m_pLifeMeter )
pi - > m_pLifeMeter - > UpdateNonstopLifebar (
GAMESTATE - > GetCourseSongIndex ( ) ,
GAMESTATE - > m_pCurCourse - > GetEstimatedNumStages ( ) ,
PREFSMAN - > m_iProgressiveNonstopLifebar ) ;
2004-06-06 21:30:47 +00:00
}
2002-08-01 21:55:40 +00:00
2005-08-23 21:38:51 +00:00
if ( pi - > m_pDifficultyIcon )
pi - > m_pDifficultyIcon - > SetFromSteps ( pi - > GetStepsAndTrailIndex ( ) , pSteps ) ;
2004-06-01 05:45:34 +00:00
2005-08-23 21:38:51 +00:00
if ( pi - > m_pDifficultyMeter )
{
pi - > m_pDifficultyMeter - > SetName ( m_sName + ssprintf ( " DifficultyMeter%s " , pi - > GetName ( ) . c_str ( ) ) ) ;
pi - > m_pDifficultyMeter - > SetFromSteps ( pSteps ) ;
}
2002-06-14 22:25:22 +00:00
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 )
pi - > m_pPrimaryScoreKeeper - > OnNextSong ( GAMESTATE - > GetCourseSongIndex ( ) , pSteps , & pi - > m_pPlayer - > m_NoteData ) ;
if ( pi - > m_pSecondaryScoreKeeper )
pi - > m_pSecondaryScoreKeeper - > OnNextSong ( GAMESTATE - > GetCourseSongIndex ( ) , pSteps , & pi - > m_pPlayer - > m_NoteData ) ;
2003-07-21 19:07:10 +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
{
pi - > GetPlayerState ( ) - > m_PlayerController = PREFSMAN - > m_AutoPlay ;
}
}
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
{
2005-08-23 21:38:51 +00:00
if ( pi - > GetPlayerState ( ) - > m_PlayerOptions . m_fScrolls [ PlayerOptions : : SCROLL_REVERSE ] = = 1 )
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
{
2005-08-23 21:38:51 +00:00
bool bReverse = pi - > GetPlayerState ( ) - > m_PlayerOptions . m_fScrolls [ PlayerOptions : : SCROLL_REVERSE ] = = 1 ;
if ( pi - > m_pDifficultyIcon )
{
pi - > m_pDifficultyIcon - > SetName ( ssprintf ( " Difficulty%s%s " , pi - > GetName ( ) . c_str ( ) , bReverse ? " Reverse " : " " ) ) ;
SET_XY ( pi - > m_pDifficultyIcon ) ;
}
2004-05-31 06:04:30 +00:00
2005-08-23 21:38:51 +00:00
if ( pi - > m_pDifficultyMeter )
{
pi - > m_pDifficultyMeter - > SetName ( ssprintf ( " DifficultyMeter%s%s " , pi - > GetName ( ) . c_str ( ) , bReverse ? " Reverse " : " " ) ) ;
SET_XY ( pi - > m_pDifficultyMeter ) ;
}
2003-02-28 20:50:28 +00:00
}
2003-04-13 00:44:50 +00:00
2003-03-19 22:48:43 +00:00
/* XXX: We want to put the lyrics out of the way, but it's likely that one
* player is in reverse and the other isn't. What to do? */
2005-08-23 21:38:51 +00:00
m_LyricDisplay . SetName ( ssprintf ( " Lyrics%s " , bAllReverse ? " Reverse " : ( bAtLeastOneReverse ? " OneReverse " : " " ) ) ) ;
2003-04-13 21:17:14 +00:00
SET_XY ( m_LyricDisplay ) ;
2003-03-19 22:48:43 +00:00
2005-09-10 05:56:09 +00:00
m_SongFinished . Reset ( ) ;
2004-03-06 10:07:17 +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-20 09:19:46 +00:00
{
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerNumberInfo ( m_vPlayerInfo , pi )
2004-04-18 18:42:42 +00:00
{
2005-08-23 21:38:51 +00:00
Steps * pSteps = GAMESTATE - > m_pCurSteps [ pi - > GetStepsAndTrailIndex ( ) ] ;
if ( pSteps - > GetDifficulty ( ) = = DIFFICULTY_BEGINNER )
m_BeginnerHelper . AddPlayer ( pi - > GetStepsAndTrailIndex ( ) , & pi - > m_pPlayer - > m_NoteData ) ;
2004-04-18 18:42:42 +00:00
}
2003-12-02 19:11:51 +00:00
}
2003-08-27 13:36:22 +00:00
2005-03-11 02:12:21 +00:00
m_SongBackground . Unload ( ) ;
2005-03-11 02:06:39 +00:00
if ( ! PREFSMAN - > m_bShowBeginnerHelper | | ! m_BeginnerHelper . Initialize ( 2 ) )
2003-08-20 09:19:46 +00:00
{
2005-03-11 02:06:39 +00:00
m_BeginnerHelper . SetHidden ( true ) ;
/* BeginnerHelper disabled, or failed to load. */
2005-03-11 02:12:21 +00:00
m_SongBackground . 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. */
2005-03-11 02:12:21 +00:00
m_SongBackground . SetBrightness ( INITIAL_BACKGROUND_BRIGHTNESS ) ;
m_SongBackground . 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
{
2005-03-11 02:06:39 +00:00
m_BeginnerHelper . SetHidden ( false ) ;
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
{
2005-08-23 21:38:51 +00:00
if ( ! pi - > GetPlayerStageStats ( ) - > 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
2005-03-11 02:52:40 +00:00
m_SongForeground . 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
2005-03-11 02:12:21 +00:00
/* m_soundMusic and m_SongBackground 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 ( ) ;
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 ) ;
2005-05-04 08:20:12 +00:00
const Steps * pSteps = GAMESTATE - > m_pCurSong - > GetClosestNotes ( 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 ) ;
Difficulty d1 = DIFFICULTY_INVALID ;
if ( asDifficulties . size ( ) > 0 )
d1 = StringToDifficulty ( asDifficulties [ 0 ] ) ;
pSteps = GAMESTATE - > m_pCurSong - > GetClosestNotes ( GAMESTATE - > GetCurrentStyle ( ) - > m_StepsType , d1 ) ;
// 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 ] ) ;
const Steps * pSteps2 = GAMESTATE - > m_pCurSong - > GetClosestNotes ( GAMESTATE - > GetCurrentStyle ( ) - > m_StepsType , d2 ) ;
if ( pSteps ! = NULL & & pSteps2 ! = NULL & & pSteps ! = pSteps2 )
{
NoteData TapNoteData2 ;
pSteps2 - > GetNoteData ( TapNoteData2 ) ;
NoteDataUtil : : LoadTransformedLightsFromTwo ( TapNoteData1 , TapNoteData2 , m_CabinetLightsNoteData ) ;
return ;
}
/* fall through */
}
NoteDataUtil : : LoadTransformedLights ( TapNoteData1 , m_CabinetLightsNoteData , GameManager : : StepsTypeToNumTracks ( STEPS_TYPE_LIGHTS_CABINET ) ) ;
2005-05-04 06:48:34 +00:00
}
2003-01-25 08:32:57 +00:00
float ScreenGameplay : : StartPlayingSong ( float MinTimeToNotes , float MinTimeToMusic )
2003-01-25 07:40:47 +00:00
{
2003-01-25 08:32:57 +00:00
ASSERT ( MinTimeToNotes > = 0 ) ;
ASSERT ( MinTimeToMusic > = 0 ) ;
2003-01-25 07:40:47 +00:00
/* XXX: We want the first beat *in use*, so we don't delay needlessly. */
2002-09-10 08:21:55 +00:00
const float fFirstBeat = GAMESTATE - > m_pCurSong - > m_fFirstBeat ;
const float fFirstSecond = GAMESTATE - > m_pCurSong - > GetElapsedTimeFromBeat ( fFirstBeat ) ;
2003-01-25 08:32:57 +00:00
float fStartSecond = fFirstSecond - MinTimeToNotes ;
2002-12-29 23:31:29 +00:00
2003-01-25 08:32:57 +00:00
fStartSecond = min ( fStartSecond , - MinTimeToMusic ) ;
2004-02-28 02:09:46 +00:00
RageSoundParams p ;
2005-09-23 00:12:32 +00:00
p . m_bAccurateSync = true ;
2004-02-28 02:09:46 +00:00
p . SetPlaybackRate ( GAMESTATE - > m_SongOptions . m_fMusicRate ) ;
p . StopMode = RageSoundParams : : M_CONTINUE ;
p . m_StartSecond = fStartSecond ;
2005-02-24 21:44:08 +00:00
ASSERT ( ! m_pSoundMusic - > IsPlaying ( ) ) ;
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 */
2003-01-25 07:40:47 +00:00
/* Return the amount of time until the first beat. */
2003-01-25 08:10:35 +00:00
return fFirstSecond - fStartSecond ;
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
{
2004-01-12 09:36:01 +00:00
if ( ! GAMESTATE - > m_SongOptions . m_bAssistTick )
return ;
/* Sound cards have a latency between when a sample is Play()ed and when the sound
* will start coming out the speaker. Compensate for this by boosting fPositionSeconds
* ahead. This is just to make sure that we request the sound early enough for it to
* come out on time; the actual precise timing is handled by SetStartTime. */
2002-10-12 00:32:47 +00:00
float fPositionSeconds = GAMESTATE - > m_fMusicSeconds ;
2005-10-27 05:16:19 +00:00
fPositionSeconds + = SOUND - > GetPlayLatency ( ) + ( float ) CommonMetrics : : TICK_EARLY_SECONDS + 0.250f ;
2004-01-12 09:36:01 +00:00
const float fSongBeat = GAMESTATE - > m_pCurSong - > GetBeatFromElapsedTime ( fPositionSeconds ) ;
2002-10-12 00:32:47 +00:00
2004-01-12 09:36:01 +00:00
const int iSongRow = max ( 0 , BeatToNoteRowNotRounded ( fSongBeat ) ) ;
2004-04-04 04:12:26 +00:00
static int iRowLastCrossed = - 1 ;
if ( iSongRow < iRowLastCrossed )
iRowLastCrossed = - 1 ;
2002-10-12 00:32:47 +00:00
2004-01-12 09:36:01 +00:00
int iTickRow = - 1 ;
2004-12-03 23:50:20 +00:00
// for each index we crossed since the last update:
2005-08-23 21:38:51 +00:00
Player & player = * m_vPlayerInfo [ 0 ] . m_pPlayer ;
FOREACH_NONEMPTY_ROW_ALL_TRACKS_RANGE ( player . m_NoteData , r , iRowLastCrossed + 1 , iSongRow + 1 )
if ( player . m_NoteData . IsThereATapOrHoldHeadAtRow ( r ) )
2004-01-12 09:36:01 +00:00
iTickRow = r ;
2002-10-12 00:32:47 +00:00
2004-01-12 09:36:01 +00:00
iRowLastCrossed = iSongRow ;
2002-10-12 00:32:47 +00:00
2004-01-12 09:36:01 +00:00
if ( iTickRow ! = - 1 )
{
const float fTickBeat = NoteRowToBeat ( iTickRow ) ;
const float fTickSecond = GAMESTATE - > m_pCurSong - > m_Timing . GetElapsedTimeFromBeat ( fTickBeat ) ;
float fSecondsUntil = fTickSecond - GAMESTATE - > m_fMusicSeconds ;
2004-01-20 03:10:55 +00:00
fSecondsUntil / = GAMESTATE - > m_SongOptions . m_fMusicRate ; /* 2x music rate means the time until the tick is halved */
2004-01-12 09:36:01 +00:00
2004-02-28 02:09:46 +00:00
RageSoundParams p ;
2005-10-27 05:16:19 +00:00
p . m_StartTime = GAMESTATE - > m_LastBeatUpdate + ( fSecondsUntil - ( float ) CommonMetrics : : TICK_EARLY_SECONDS ) ;
2004-02-28 02:09:46 +00:00
m_soundAssistTick . Play ( & p ) ;
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
if ( m_pCombinedLifeMeter )
m_pCombinedLifeMeter - > OnTaunt ( ) ;
}
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 ( )
2002-05-20 08:59:37 +00:00
{
2006-01-18 20:45:05 +00:00
ScreenWithMenuElements : : BeginScreen ( ) ;
2003-03-24 21:26:12 +00:00
if ( GAMESTATE - > m_pCurSong = = NULL )
return ;
2006-01-18 20:45:05 +00:00
SOUND - > PlayOnceFromAnnouncer ( " gameplay intro " ) ; // crowd cheer
//
// Get the transitions rolling
//
if ( GAMESTATE - > m_bDemonstrationOrJukebox )
{
StartPlayingSong ( 0 , 0 ) ; // *kick* (no transitions)
}
else if ( NSMAN - > useSMserver )
2003-03-12 01:26:44 +00:00
{
2006-01-18 20:45:05 +00:00
//If we're using networking, we must not have any
//delay. If we do this can cause inconsistancy
//on different computers and differet themes
2003-03-16 07:30:50 +00:00
2006-01-18 20:45:05 +00:00
StartPlayingSong ( 0 , 0 ) ;
m_pSoundMusic - > Stop ( ) ;
2005-01-25 05:11:18 +00:00
2006-01-18 20:45:05 +00:00
float startOffset = g_fNetStartOffset ;
2005-01-25 05:11:18 +00:00
2006-01-18 20:45:05 +00:00
NSMAN - > StartRequest ( 1 ) ;
2005-01-26 06:48:01 +00:00
2006-01-18 20:45:05 +00:00
RageSoundParams p ;
p . m_bAccurateSync = true ;
p . SetPlaybackRate ( 1.0 ) ; //Force 1.0 playback speed
p . StopMode = RageSoundParams : : M_CONTINUE ;
p . m_StartSecond = startOffset ;
m_pSoundMusic - > Play ( & p ) ;
2005-01-25 05:11:18 +00:00
2006-01-18 20:45:05 +00:00
UpdateSongPosition ( 0 ) ;
}
else
{
float fMinTimeToMusic = m_In . GetLengthSeconds ( ) ; // start of m_Ready
float fMinTimeToNotes = fMinTimeToMusic + m_Ready . GetLengthSeconds ( ) + m_Go . GetLengthSeconds ( ) + 2 ; // end of Go
/*
* Tell the music to start, but don't actually make any noise for
* at least 2.5 (or 1.5) seconds. (This is so we scroll on screen smoothly.)
*
* This is only a minimum: the music might be started later, to meet
* the minimum-time-to-notes value. If you're writing song data,
* and you want to make sure we get ideal timing here, make sure there's
* a bit of space at the beginning of the music with no steps.
*/
2005-01-25 05:11:18 +00:00
2006-01-18 20:45:05 +00:00
/*float delay =*/ StartPlayingSong ( fMinTimeToNotes , fMinTimeToMusic ) ;
2003-03-12 01:26:44 +00:00
}
2006-01-18 20:45:05 +00:00
}
2003-03-12 01:26:44 +00:00
2006-01-18 20:45:05 +00:00
void ScreenGameplay : : Update ( float fDeltaTime )
{
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 ;
}
2003-03-12 01:26:44 +00:00
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 ;
2005-02-28 08:43:49 +00:00
if ( GAMESTATE - > m_MasterPlayerNumber ! = PLAYER_INVALID & & ! m_MaxCombo . GetHidden ( ) )
2005-02-16 03:25:45 +00:00
m_MaxCombo . SetText ( ssprintf ( " %d " , STATSMAN - > m_CurStageStats . m_player [ GAMESTATE - > m_MasterPlayerNumber ] . iMaxCombo ) ) ; /* MAKE THIS WORK FOR BOTH PLAYERS! */
2003-02-10 22:08:10 +00:00
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
{
2005-08-23 21:38:51 +00:00
PlayerNumber pn = pi - > GetStepsAndTrailIndex ( ) ;
2004-06-10 19:38:38 +00:00
if (
2005-08-23 21:38:51 +00:00
( pi - > m_pLifeMeter & & pi - > m_pLifeMeter - > IsFailing ( ) ) | |
( m_pCombinedLifeMeter & & m_pCombinedLifeMeter - > IsFailing ( pn ) ) )
2003-12-07 20:29:42 +00:00
{
2005-08-23 21:38:51 +00:00
pi - > GetPlayerState ( ) - > m_HealthState = PlayerState : : DEAD ;
2004-05-16 12:34:02 +00:00
}
2004-06-08 07:16:28 +00:00
else if (
2005-08-23 21:38:51 +00:00
( pi - > m_pLifeMeter & & pi - > m_pLifeMeter - > IsHot ( ) ) | |
( m_pCombinedLifeMeter & & m_pCombinedLifeMeter - > IsHot ( pn ) ) )
2004-05-16 12:34:02 +00:00
{
2005-08-23 21:38:51 +00:00
pi - > GetPlayerState ( ) - > m_HealthState = PlayerState : : HOT ;
2004-05-16 12:34:02 +00:00
}
else if (
2005-08-23 21:38:51 +00:00
( pi - > m_pLifeMeter & & pi - > m_pLifeMeter - > IsInDanger ( ) ) | |
( m_pCombinedLifeMeter & & m_pCombinedLifeMeter - > IsInDanger ( pn ) ) )
2004-05-16 12:34:02 +00:00
{
2005-08-23 21:38:51 +00:00
pi - > GetPlayerState ( ) - > m_HealthState = PlayerState : : DANGER ;
2004-05-16 12:34:02 +00:00
}
else
{
2005-08-23 21:38:51 +00:00
pi - > GetPlayerState ( ) - > m_HealthState = PlayerState : : ALIVE ;
2003-12-07 20:29:42 +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 ( ) ;
SongOptions : : FailType ft = GAMESTATE - > GetPlayerFailType ( pi - > GetPlayerState ( ) ) ;
2005-04-08 00:53:17 +00:00
SongOptions : : LifeType lt = GAMESTATE - > m_SongOptions . m_LifeType ;
2005-04-05 08:30:57 +00:00
if ( ft = = SongOptions : : FAIL_OFF )
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 */
2005-08-23 21:38:51 +00:00
if ( m_pCombinedLifeMeter & & ! m_pCombinedLifeMeter - > IsFailing ( pn ) )
continue ; /* isn't failing */
if ( pi - > GetPlayerStageStats ( ) - > bFailed )
2005-04-05 08:30:57 +00:00
continue ; /* failed and is already dead */
/* If recovery is enabled, only set fail if both are failing.
* There's no way to recover mid-song in battery mode. */
2005-04-08 00:53:17 +00:00
if ( lt ! = SongOptions : : LIFE_BATTERY & &
2005-04-05 08:30:57 +00:00
PREFSMAN - > m_bTwoPlayerRecovery & & ! GAMESTATE - > AllAreDead ( ) )
continue ;
2004-06-11 20:09:53 +00:00
2005-04-05 08:30:57 +00:00
LOG - > Trace ( " Player %d failed " , ( int ) pn ) ;
2005-08-23 21:38:51 +00:00
pi - > GetPlayerStageStats ( ) - > bFailed = true ; // fail
2004-06-11 20:09:53 +00:00
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 ;
}
if ( bAllowOniDie & & ft = = SongOptions : : FAIL_IMMEDIATE )
2005-04-05 08:30:57 +00:00
{
if ( ! STATSMAN - > m_CurStageStats . AllFailedEarlier ( ) ) // 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 ( ) ;
pi - > m_pPlayer - > m_NoteData . Init ( ) ; // remove all notes and scoring
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 )
2004-07-31 19:14:53 +00:00
{
2005-08-23 21:38:51 +00:00
SongOptions : : FailType ft = GAMESTATE - > GetPlayerFailType ( pi - > GetPlayerState ( ) ) ;
2005-04-05 08:30:57 +00:00
switch ( ft )
{
case SongOptions : : FAIL_IMMEDIATE :
2005-08-23 21:38:51 +00:00
if ( pi - > GetPlayerState ( ) - > m_HealthState < PlayerState : : DEAD )
2005-04-05 08:30:57 +00:00
bAllFailed = false ;
break ;
case SongOptions : : FAIL_END_OF_SONG :
bAllFailed = false ; // wait until the end of the song to fail.
break ;
case SongOptions : : FAIL_OFF :
bAllFailed = false ; // never fail.
break ;
default :
ASSERT ( 0 ) ;
}
2004-07-31 19:14:53 +00:00
}
2005-04-05 08:30:57 +00:00
if ( bAllFailed )
2004-08-01 00:35:14 +00:00
SCREENMAN - > PostMessageToTopScreen ( SM_BeginFailed , 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
//
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
if ( ! pi - > GetPlayerStageStats ( ) - > bFailed )
pi - > GetPlayerStageStats ( ) - > fAliveSeconds + = fDeltaTime * GAMESTATE - > m_SongOptions . m_fMusicRate ;
2003-01-24 02:43:07 +00:00
2003-12-09 10:20:18 +00:00
// update fGameplaySeconds
2005-02-16 03:25:45 +00:00
STATSMAN - > m_CurStageStats . fGameplaySeconds + = fDeltaTime ;
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 )
STATSMAN - > m_CurStageStats . fStepsSeconds + = fDeltaTime ;
2003-12-09 10:20:18 +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
//
2004-03-03 08:03:47 +00:00
float fSecondsToStop = GAMESTATE - > m_pCurSong - > GetElapsedTimeFromBeat ( GAMESTATE - > m_pCurSong - > m_fLastBeat ) ;
2004-03-13 22:41:31 +00:00
/* Make sure we keep going long enough to register a miss for the last note. */
2005-08-23 21:38:51 +00:00
Player & player = * m_vPlayerInfo [ 0 ] . m_pPlayer ;
fSecondsToStop + = player . GetMaxStepDistanceSeconds ( ) ;
2004-03-13 22:41:31 +00:00
2005-03-19 00:03:53 +00:00
if ( GAMESTATE - > m_fMusicSeconds > fSecondsToStop & & ! m_SongFinished . IsTransitioning ( ) & & ! m_NextSong . IsTransitioning ( ) )
2004-03-06 10:07:17 +00:00
m_SongFinished . StartTransitioning ( SM_NotesEnded ) ;
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
{
2005-03-11 02:12:21 +00:00
DancingCharacters * pCharacter = m_SongBackground . 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-08-23 21:38:51 +00:00
if ( state = = AS2D_GREAT & & pi - > m_pLifeMeter & & pi - > m_pLifeMeter - > GetLife ( ) = = 1.0f ) // full life
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 ( ) ;
pi - > m_pPlayer - > m_NoteData . Init ( ) ; // remove all notes and scoring
pi - > m_pPlayer - > FadeToFail ( ) ; // tell the NoteField to fade to white
2003-07-08 19:56:56 +00:00
}
}
}
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
2003-12-25 05:53:30 +00:00
//
2005-04-27 06:34:53 +00:00
// update give up
2003-12-25 05:53:30 +00:00
//
2005-04-27 06:34:53 +00:00
bool bGiveUpTimerFired = ! m_GiveUpTimer . IsZero ( ) & & m_GiveUpTimer . Ago ( ) > 2.5f ;
2005-05-09 15:14:19 +00:00
if ( bGiveUpTimerFired | | ( FAIL_AFTER_30_MISSES & & GAMESTATE - > AllHumanHaveComboOf30OrMoreMisses ( ) ) )
2003-09-06 03:25:45 +00:00
{
2005-05-09 10:12:03 +00:00
// Give up
2005-10-01 00:18:13 +00:00
STATSMAN - > m_CurStageStats . bGaveUp = true ;
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerNumberInfo ( m_vPlayerInfo , pi )
2005-05-09 15:14:19 +00:00
{
2005-08-23 21:38:51 +00:00
pi - > GetPlayerStageStats ( ) - > bFailed | = GAMESTATE - > AllHumanHaveComboOf30OrMoreMisses ( ) ;
2005-05-09 15:14:19 +00:00
}
2005-05-09 10:12:03 +00:00
2003-09-06 03:25:45 +00:00
m_GiveUpTimer . SetZero ( ) ;
2005-03-10 02:45:40 +00:00
2005-04-27 06:34:53 +00:00
if ( GIVING_UP_GOES_TO_PREV_SCREEN )
2003-09-06 03:25:45 +00:00
{
2005-09-12 08:04:47 +00:00
BeginBackingOutFromGameplay ( ) ;
2003-09-06 03:25:45 +00:00
2005-03-11 04:53:45 +00:00
}
2005-04-10 06:21:59 +00:00
else if ( GIVING_UP_GOES_TO_NEXT_SCREEN )
{
HandleScreenMessage ( SM_LeaveGameplay ) ;
return ;
}
2005-03-11 04:53:45 +00:00
else
{
2005-04-27 06:34:53 +00:00
this - > PostScreenMessage ( SM_NotesEnded , 0 ) ;
2005-03-10 02:45:40 +00:00
}
2005-04-27 06:34:53 +00:00
return ;
2003-09-06 03:25:45 +00:00
}
2004-12-18 08:15:19 +00:00
//
// update bpm display
//
2005-02-28 08:43:49 +00:00
if ( m_fLastBPS ! = GAMESTATE - > m_fCurBPS & & ! m_BPMDisplay . GetHidden ( ) )
2004-12-18 08:15:19 +00:00
{
m_fLastBPS = GAMESTATE - > m_fCurBPS ;
2005-03-17 17:53:10 +00:00
m_BPMDisplay . SetConstantBpm ( GAMESTATE - > m_fCurBPS * 60.0f ) ;
2004-12-18 08:15:19 +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 )
2005-08-24 20:45:57 +00:00
if ( m_bShowScoreboard & & NSMAN - > ChangedScoreboard ( cn ) )
2005-08-15 02:10:57 +00:00
m_Scoreboard [ cn ] . SetText ( NSMAN - > m_Scoreboard [ cn ] ) ;
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 ( ) ;
2004-04-22 05:25:58 +00:00
bool bBlinkCabinetLight [ NUM_CABINET_LIGHTS ] ;
bool bBlinkGameButton [ MAX_GAME_CONTROLLERS ] [ MAX_GAME_BUTTONS ] ;
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
{
2005-08-23 21:38:51 +00:00
for ( int t = 0 ; t < pi - > m_pPlayer - > m_NoteData . 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:
2005-08-23 21:38:51 +00:00
FOREACH_NONEMPTY_ROW_IN_TRACK_RANGE ( pi - > m_pPlayer - > m_NoteData , t , r , iRowLastCrossed + 1 , iSongRow + 1 )
2004-04-22 05:25:58 +00:00
{
2005-08-23 21:38:51 +00:00
TapNote tn = pi - > m_pPlayer - > m_NoteData . GetTapNote ( t , r ) ;
2005-04-29 01:35:44 +00:00
if ( tn . type ! = TapNote : : empty & & tn . type ! = TapNote : : mine )
bBlink = true ;
2004-04-22 05:25:58 +00:00
}
2004-01-12 09:36:01 +00:00
2005-04-29 01:35:44 +00:00
// check if a hold should be active
2005-08-23 21:38:51 +00:00
if ( pi - > m_pPlayer - > m_NoteData . IsHoldNoteAtRow ( t , iSongRow ) )
2005-04-29 01:35:44 +00:00
bBlink = true ;
if ( bBlink )
2004-04-22 05:25:58 +00:00
{
2005-08-23 21:38:51 +00:00
StyleInput si ( pi - > m_pn , t ) ;
2004-06-28 07:26:00 +00:00
GameInput gi = pStyle - > StyleInputToGameInput ( si ) ;
2005-04-29 01:35:44 +00:00
bBlinkGameButton [ gi . controller ] [ gi . button ] = true ;
2004-04-22 05:25:58 +00:00
}
}
}
2005-04-29 01:35:44 +00:00
iRowLastCrossed = iSongRow ;
}
2004-04-22 05:25:58 +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-10-15 14:37:33 +00:00
FOREACH_CabinetLight ( cl )
{
switch ( cl )
{
case LIGHT_BUTTONS_LEFT :
case LIGHT_BUTTONS_RIGHT :
// don't blink
break ;
default :
bBlinkCabinetLight [ cl ] | = bOverrideCabinetBlink ;
break ;
}
}
2004-03-30 07:44:29 +00:00
2004-10-15 14:37:33 +00:00
// Send blink data.
2004-04-20 02:35:30 +00:00
FOREACH_CabinetLight ( cl )
{
2004-10-15 14:37:33 +00:00
if ( bBlinkCabinetLight [ cl ] )
2004-04-22 05:25:58 +00:00
LIGHTSMAN - > BlinkCabinetLight ( cl ) ;
}
FOREACH_GameController ( gc )
{
FOREACH_GameButton ( gb )
{
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 ) ;
2005-04-24 11:03:02 +00:00
2005-04-24 11:15:07 +00:00
int iRowNow = BeatToNoteRowNotRounded ( fSongBeat ) ;
iRowNow = max ( 0 , iRowNow ) ;
2005-04-24 11:03:02 +00:00
2005-05-01 22:59:00 +00:00
for ( int r = iRowLastCrossed + 1 ; r < = iRowNow ; r + + )
{
if ( GetNoteType ( r ) = = NOTE_TYPE_4TH )
2005-08-14 07:29:48 +00:00
MESSAGEMAN - > Broadcast ( Message_BeatCrossed ) ;
2005-05-01 22:59:00 +00:00
}
iRowLastCrossed = iRowNow ;
}
{
const int NUM_MESSAGES_TO_SEND = 4 ;
const float MESSAGE_SPACING_SECONDS = 0.5f ;
PlayerNumber pn = PLAYER_INVALID ;
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerNumberInfo ( m_vPlayerInfo , pi )
2005-04-24 11:15:07 +00:00
{
2005-08-23 21:38:51 +00:00
if ( GAMESTATE - > m_pCurSteps [ pi - > m_pn ] - > GetDifficulty ( ) = = DIFFICULTY_BEGINNER )
2005-04-24 11:03:02 +00:00
{
2005-08-23 21:38:51 +00:00
pn = pi - > m_pn ;
2005-04-24 11:15:07 +00:00
break ;
2005-04-24 11:03:02 +00:00
}
}
2005-05-01 22:59:00 +00:00
if ( pn = = PLAYER_INVALID )
return ;
2005-04-24 11:15:07 +00:00
2005-08-23 21:38:51 +00:00
NoteData & nd = m_vPlayerInfo [ pn ] . m_pPlayer - > m_NoteData ;
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 )
{
2005-05-09 12:26:44 +00:00
StyleInput si ( pn , t ) ;
2005-05-08 04:10:16 +00:00
const Game * pGame = GAMESTATE - > GetCurrentGame ( ) ;
2006-01-22 01:00:06 +00:00
RString sButton = pGame - > ColToButtonName ( t ) ;
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 )
2005-08-14 07:29:48 +00:00
MESSAGEMAN - > Broadcast ( ( Message ) ( 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 ( ) ;
m_soundAssistTick . StopPlaying ( ) ; /* Stop any queued assist ticks. */
this - > ClearMessageQueue ( ) ;
2005-06-29 07:57:15 +00:00
// If this is the final stage, don't allow extra stage
if ( GAMESTATE - > IsFinalStage ( ) )
GAMESTATE - > m_bBackedOutOfFinalStage = true ;
// Disallow backing out of extra stage
if ( GAMESTATE - > IsExtraStage ( ) | | GAMESTATE - > IsExtraStage2 ( ) )
SCREENMAN - > PostMessageToTopScreen ( SM_BeginFailed , 0 ) ;
else
m_Cancel . StartTransitioning ( SM_GoToScreenAfterBack ) ;
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-09-05 02:26:50 +00:00
if ( input . type = = IET_LEVEL_CHANGED )
2004-09-09 22:21:50 +00:00
return ;
2005-03-11 03:54:40 +00:00
if ( m_bPaused )
{
/* If we're paused, only accept MENU_BUTTON_START to unpause. */
2005-09-05 02:26:50 +00:00
if ( input . MenuI . IsValid ( ) & & GAMESTATE - > IsHumanPlayer ( input . MenuI . player ) & & input . MenuI . button = = MENU_BUTTON_START & & input . type = = IET_FIRST_PRESS )
2005-04-21 02:07:02 +00:00
{
2005-09-05 02:26:50 +00:00
if ( m_PauseController = = GAME_CONTROLLER_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 ;
}
2005-09-05 02:26:50 +00:00
if ( input . MenuI . IsValid ( ) & &
2003-01-19 21:57:13 +00:00
m_DancingState ! = STATE_OUTRO & &
2006-01-10 20:53:40 +00:00
GAMESTATE - > IsHumanPlayer ( input . MenuI . player ) & &
( ! GAMESTATE - > m_bMultiplayer | | input . mp = = MultiPlayer_1 ) & &
2005-03-20 06:14:41 +00:00
! m_Cancel . IsTransitioning ( ) )
2003-01-19 21:57:13 +00:00
{
2003-11-24 02:03:09 +00:00
/* Allow bailing out by holding the START button of all active players. This
* gives a way to "give up" when a back button isn't available. Doing this is
* treated as failing the song, unlike BACK, since it's always available.
*
* However, if this is also a style button, don't do this. (pump center = start) */
2005-03-10 02:45:40 +00:00
bool bHoldingGiveUp = false ;
2005-09-05 02:26:50 +00:00
bHoldingGiveUp | = ( START_GIVES_UP & & input . MenuI . button = = MENU_BUTTON_START & & ! input . StyleI . IsValid ( ) ) ;
bHoldingGiveUp | = ( BACK_GIVES_UP & & input . MenuI . button = = MENU_BUTTON_BACK & & ! input . StyleI . IsValid ( ) ) ;
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 )
2005-03-15 08:44:35 +00:00
AbortGiveUp ( true ) ;
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
{
2005-03-12 00:04:27 +00:00
m_textDebug . SetText ( GIVE_UP_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. */
2005-09-05 02:26:50 +00:00
if ( input . MenuI . button = = MENU_BUTTON_BACK & & ! BACK_GIVES_UP )
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 ) | |
( input . DeviceI . device = = DEVICE_KEYBOARD & & ( input . type = = IET_SLOW_REPEAT | | input . type = = IET_FAST_REPEAT ) ) | |
( input . DeviceI . device ! = DEVICE_KEYBOARD & & input . type = = IET_FAST_REPEAT ) ) )
2005-03-10 02:45:40 +00:00
{
2005-09-05 02:26:50 +00:00
LOG - > Trace ( " Player %i went back " , input . MenuI . player + 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
{
m_textDebug . SetText ( " Continue holding BACK to quit " ) ;
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-15 02:06:39 +00:00
return ;
}
2003-01-19 21:57:13 +00:00
}
2004-12-22 07:31:27 +00:00
/* Nothing below cares about releases. */
2005-09-05 02:26:50 +00:00
if ( input . type = = IET_RELEASE )
2005-08-23 21:38:51 +00:00
return ;
2002-05-20 08:59:37 +00:00
2002-06-24 22:04:31 +00:00
2005-08-23 21:38:51 +00:00
if ( GAMESTATE - > m_bMultiplayer )
2003-02-27 10:56:37 +00:00
{
2006-01-10 18:23:20 +00:00
if ( input . mp ! = MultiPlayer_INVALID & &
input . StyleI . IsValid ( ) & &
GAMESTATE - > IsMultiPlayerEnabled ( input . mp ) )
2005-08-23 21:38:51 +00:00
{
2006-01-10 18:23:20 +00:00
m_vPlayerInfo [ input . mp ] . m_pPlayer - > Step ( input . StyleI . col , input . DeviceI . ts ) ;
2005-08-23 21:38:51 +00:00
}
}
else
{
//
// handle a step or battle item activate
//
2005-09-05 02:26:50 +00:00
if ( input . type = = IET_FIRST_PRESS & &
input . StyleI . IsValid ( ) & &
GAMESTATE - > IsHumanPlayer ( input . StyleI . player ) )
2005-08-23 21:38:51 +00:00
{
AbortGiveUp ( true ) ;
if ( PREFSMAN - > m_AutoPlay = = PC_HUMAN )
2005-09-05 02:26:50 +00:00
m_vPlayerInfo [ input . StyleI . player ] . m_pPlayer - > Step ( input . StyleI . col , input . DeviceI . ts ) ;
2005-08-23 21:38:51 +00:00
}
2003-02-27 10:56:37 +00:00
}
2002-07-27 19:29:51 +00:00
}
2002-07-28 20:28:37 +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.
*/
2003-12-15 06:24:59 +00:00
void ScreenGameplay : : SongFinished ( )
{
// save any statistics
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). */
2004-07-11 07:21:33 +00:00
RadarValues v ;
2005-08-23 21:38:51 +00:00
NoteDataUtil : : CalculateRadarValues ( pi - > m_pPlayer - > m_NoteData , GAMESTATE - > m_pCurSong - > m_fMusicLengthSeconds , v ) ;
pi - > GetPlayerStageStats ( ) - > radarPossible + = v ;
2004-07-11 07:21:33 +00:00
2005-08-23 21:38:51 +00:00
NoteDataWithScoring : : GetActualRadarValues ( pi - > m_pPlayer - > m_NoteData , pi - > m_pn , GAMESTATE - > m_pCurSong - > m_fMusicLengthSeconds , v ) ;
pi - > GetPlayerStageStats ( ) - > radarActual + = v ;
2003-12-15 06:24:59 +00:00
}
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
// save current stage stats
2004-02-21 21:00:49 +00:00
if ( ! bBackedOut )
2005-02-16 03:25:45 +00:00
STATSMAN - > m_vPlayedStageStats . push_back ( STATSMAN - > m_CurStageStats ) ;
2004-01-23 02:04:34 +00:00
/* Reset options. */
2005-11-02 20:02:47 +00:00
GAMESTATE - > RestoreStageOptions ( ) ;
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 )
{
2004-02-16 05:29:33 +00:00
if ( GAMESTATE - > IsExtraStage ( ) | | GAMESTATE - > IsExtraStage2 ( ) )
2004-04-12 20:11:36 +00:00
SOUND - > PlayOnceFromAnnouncer ( " gameplay here we go extra " ) ;
2004-02-16 05:29:33 +00:00
else if ( GAMESTATE - > IsFinalStage ( ) )
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
{
2005-03-23 08:48:38 +00:00
/* If either player's passmark is enabled, check it. */
2005-08-23 21:38:51 +00:00
if ( pi - > GetPlayerState ( ) - > m_PlayerOptions . m_fPassmark > 0 & &
pi - > m_pLifeMeter & &
pi - > m_pLifeMeter - > GetLife ( ) < pi - > GetPlayerState ( ) - > m_PlayerOptions . m_fPassmark )
2003-02-24 02:45:01 +00:00
{
2005-03-23 08:48:38 +00:00
LOG - > Trace ( " Player %i failed: life %f is under %f " ,
2005-08-23 21:38:51 +00:00
pi - > GetPlayerStateAndStageStatsIndex ( ) + 1 , pi - > m_pLifeMeter - > GetLife ( ) , pi - > GetPlayerState ( ) - > m_PlayerOptions . m_fPassmark ) ;
pi - > GetPlayerStageStats ( ) - > bFailed = true ;
2005-03-23 08:48:38 +00:00
}
2003-11-03 19:42:06 +00:00
2005-03-23 08:48:38 +00:00
/* Mark failure. This hasn't been done yet if m_bTwoPlayerRecovery is set. */
2005-08-23 21:38:51 +00:00
if ( GAMESTATE - > GetPlayerFailType ( pi - > GetPlayerState ( ) ) ! = SongOptions : : FAIL_OFF & &
( pi - > m_pLifeMeter & & pi - > m_pLifeMeter - > IsFailing ( ) ) | |
( m_pCombinedLifeMeter & & m_pCombinedLifeMeter - > IsFailing ( pi - > GetStepsAndTrailIndex ( ) ) ) )
pi - > GetPlayerStageStats ( ) - > bFailed = true ;
2003-12-15 06:24:59 +00:00
2005-08-23 21:38:51 +00:00
if ( ! pi - > GetPlayerStageStats ( ) - > bFailed )
pi - > GetPlayerStageStats ( ) - > iSongsPassed + + ;
2005-04-27 06:34:53 +00:00
// set a life record at the point of failue
2005-08-23 21:38:51 +00:00
if ( pi - > GetPlayerStageStats ( ) - > bFailed )
pi - > GetPlayerStageStats ( ) - > SetLifeRecordAt ( 0 , STATSMAN - > m_CurStageStats . fGameplaySeconds ) ;
2005-03-23 08:48:38 +00:00
}
2002-07-27 19:29:51 +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 ( ) ;
2003-11-01 06:23:59 +00:00
2005-04-09 11:32:10 +00:00
LOG - > Trace ( " bAllReallyFailed = %d, bStopCourseEarly = %d, bIsLastSong = %d " , bAllReallyFailed , bStopCourseEarly , bIsLastSong ) ;
2005-03-23 02:11:33 +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 ) ;
}
else
{
/* Load the next song in the course. First, fade out and stop the music. */
float fFadeLengthSeconds = MUSIC_FADE_OUT_SECONDS ;
RageSoundParams p = m_pSoundMusic - > GetParams ( ) ;
p . m_FadeLength = fFadeLengthSeconds ;
2005-06-15 02:01:09 +00:00
p . m_LengthSeconds = GAMESTATE - > m_fMusicSeconds + fFadeLengthSeconds ;
2005-04-10 06:21:59 +00:00
m_pSoundMusic - > SetParams ( p ) ;
SCREENMAN - > PostMessageToTopScreen ( SM_StartLoadingNextSong , fFadeLengthSeconds ) ;
return ;
}
}
else if ( SM = = SM_LeaveGameplay )
{
// update dancing characters for win / lose
2006-01-18 07:41:44 +00:00
DancingCharacters * pDancers = m_SongBackground . GetDancingCharacters ( ) ;
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-06 06:12:23 +00:00
{
2005-04-10 06:21:59 +00:00
/* XXX: In battle modes, switch( GAMESTATE->GetStageResult(p) ). */
2005-08-23 21:38:51 +00:00
if ( pi - > GetPlayerStageStats ( ) - > bFailed )
2006-01-18 07:41:44 +00:00
pDancers - > Change2DAnimState ( pi - > m_pn , AS2D_FAIL ) ; // fail anim
2005-08-23 21:38:51 +00:00
else if ( pi - > m_pLifeMeter & & pi - > m_pLifeMeter - > GetLife ( ) = = 1.0f ) // full life
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-06 06:12:23 +00:00
}
2005-04-10 06:21:59 +00:00
}
2003-11-10 23:25:44 +00:00
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 ) ;
2003-04-14 22:12:54 +00:00
2005-04-10 06:21:59 +00:00
GAMESTATE - > RemoveAllActiveAttacks ( ) ;
2005-08-23 21:38:51 +00:00
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
{
if ( pi - > m_pActiveAttackList )
pi - > m_pActiveAttackList - > Refresh ( ) ;
}
2003-11-03 19:42:06 +00:00
2005-04-10 06:21:59 +00:00
LIGHTSMAN - > SetLightsMode ( LIGHTSMODE_ALL_CLEARED ) ;
2003-11-16 04:45:12 +00:00
2005-04-10 06:21:59 +00:00
bool bAllReallyFailed = STATSMAN - > m_CurStageStats . AllFailed ( ) ;
2003-11-16 04:45:12 +00:00
2005-04-10 06:21:59 +00:00
if ( bAllReallyFailed )
{
this - > PostScreenMessage ( SM_BeginFailed , 0 ) ;
return ;
}
2003-11-03 19:42:06 +00:00
2005-10-13 22:52:25 +00:00
TweenOffScreen ( ) ;
2005-07-06 06:41:57 +00:00
2006-01-18 08:43:40 +00:00
m_Out . StartTransitioning ( SM_GoToNextScreen ) ;
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
m_pSoundMusic - > Stop ( ) ;
2003-11-10 23:25:44 +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 02:11:33 +00:00
{
2005-08-23 21:38:51 +00:00
if ( ! pi - > GetPlayerStageStats ( ) - > bFailed )
2005-03-23 02:11:33 +00:00
{
2005-08-23 21:38:51 +00:00
if ( pi - > m_pLifeMeter )
pi - > m_pLifeMeter - > OnSongEnded ( ) ;
if ( pi - > m_pPrimaryScoreDisplay )
pi - > m_pPrimaryScoreDisplay - > OnSongEnded ( ) ;
if ( pi - > m_pSecondaryScoreDisplay )
pi - > m_pSecondaryScoreDisplay - > OnSongEnded ( ) ;
2005-03-23 02:11:33 +00:00
}
}
2005-04-21 11:16:01 +00:00
if ( m_pCombinedLifeMeter )
m_pCombinedLifeMeter - > OnSongEnded ( ) ;
2002-05-20 08:59:37 +00:00
2005-03-23 08:48:38 +00:00
int iPlaySongIndex = GAMESTATE - > GetCourseSongIndex ( ) + 1 ;
iPlaySongIndex % = m_apSongsQueue . size ( ) ;
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 ) ;
LoadCourseSongNumber ( GAMESTATE - > GetCourseSongIndex ( ) + 1 ) ;
2005-05-07 09:58:23 +00:00
COMMAND ( m_sprCourseSongNumber , " ChangeIn " ) ;
2005-03-23 08:48:38 +00:00
}
else if ( SM = = SM_LoadNextSong )
{
2003-12-15 06:24:59 +00:00
SongFinished ( ) ;
2005-05-07 09:58:23 +00:00
COMMAND ( m_sprCourseSongNumber , " ChangeOut " ) ;
2004-02-14 00:39:24 +00:00
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 ) ;
2003-02-05 20:50:12 +00:00
/* We're fading in, so don't hit any notes for a few seconds; they'll be
* obscured by the fade. */
2005-03-19 00:03:53 +00:00
StartPlayingSong ( m_NextSong . GetLengthSeconds ( ) + 2 , 0 ) ;
2005-03-23 08:48:38 +00:00
}
else if ( SM = = SM_PlayToasty )
{
2003-01-11 08:55:21 +00:00
if ( PREFSMAN - > m_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 ) ;
switch ( SM )
{
case SM_BattleTrickLevel1 : m_soundBattleTrickLevel1 . Play ( ) ; break ;
case SM_BattleTrickLevel2 : m_soundBattleTrickLevel2 . Play ( ) ; break ;
case SM_BattleTrickLevel3 : m_soundBattleTrickLevel3 . Play ( ) ; break ;
default : ASSERT ( 0 ) ;
}
}
else if ( SM > = SM_BattleDamageLevel1 & & SM < = SM_BattleDamageLevel3 )
{
int iDamageLevel = SM - SM_BattleDamageLevel1 + 1 ;
PlayAnnouncer ( ssprintf ( " gameplay battle damage level%d " , iDamageLevel ) , 3 ) ;
}
else if ( SM = = SM_GoToScreenAfterBack )
{
2003-12-15 06:24:59 +00:00
SongFinished ( ) ;
2004-02-21 21:00:49 +00:00
StageFinished ( true ) ;
2003-12-15 06:24:59 +00:00
2004-01-23 02:04:34 +00:00
GAMESTATE - > CancelStage ( ) ;
2005-04-16 05:05:25 +00:00
HandleScreenMessage ( SM_GoToPrevScreen ) ;
2005-03-23 08:48:38 +00:00
}
else if ( SM = = SM_GoToNextScreen )
{
2005-04-16 05:05:25 +00:00
SongFinished ( ) ;
StageFinished ( false ) ;
2005-11-22 21:18:45 +00:00
//SaveRecordedResults();
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 ) ;
2004-10-25 03:47:22 +00:00
m_pSoundMusic - > StopPlaying ( ) ;
2004-01-12 09:36:01 +00:00
m_soundAssistTick . StopPlaying ( ) ; /* Stop any queued assist ticks. */
2005-10-13 22:52:25 +00:00
TweenOffScreen ( ) ;
2005-01-30 03:08:42 +00:00
m_Failed . StartTransitioning ( SM_GoToNextScreen ) ;
2002-05-20 08:59:37 +00:00
2002-08-01 13:42:56 +00:00
// show the survive time if extra stage
if ( GAMESTATE - > IsExtraStage ( ) | | GAMESTATE - > IsExtraStage2 ( ) )
{
2003-01-24 02:43:07 +00:00
float fMaxSurviveSeconds = 0 ;
2006-01-18 07:43:17 +00:00
FOREACH_EnabledPlayer ( p )
fMaxSurviveSeconds = max ( fMaxSurviveSeconds , STATSMAN - > m_CurStageStats . m_player [ p ] . fAliveSeconds ) ;
2004-02-22 19:51:46 +00:00
m_textSurviveTime . SetText ( " TIME: " + SecondsToMMSSMsMs ( fMaxSurviveSeconds ) ) ;
2003-08-07 10:15:16 +00:00
SET_XY_AND_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
2005-09-10 20:07:13 +00:00
void ScreenGameplay : : Cancel ( ScreenMessage smSendWhenDone )
{
m_pSoundMusic - > Stop ( ) ;
ScreenWithMenuElements : : Cancel ( smSendWhenDone ) ;
}
2005-10-14 03:11:50 +00:00
void ScreenGameplay : : TweenOnScreen ( )
2002-06-14 22:25:22 +00:00
{
2003-04-13 21:17:14 +00:00
ON_COMMAND ( m_sprLifeFrame ) ;
2005-05-07 09:58:23 +00:00
ON_COMMAND ( m_sprCourseSongNumber ) ;
2003-04-13 21:17:14 +00:00
ON_COMMAND ( m_textSongOptions ) ;
ON_COMMAND ( m_sprScoreFrame ) ;
2004-07-18 17:16:57 +00:00
ON_COMMAND ( m_BPMDisplay ) ;
ON_COMMAND ( m_MaxCombo ) ;
2005-08-26 17:39:53 +00:00
ON_COMMAND ( m_pPlayerScoreList ) ;
2004-07-18 17:16:57 +00:00
2003-06-30 18:08:27 +00:00
if ( m_pCombinedLifeMeter )
ON_COMMAND ( * m_pCombinedLifeMeter ) ;
2005-08-23 21:38:51 +00:00
FOREACH ( PlayerInfo , m_vPlayerInfo , pi )
2002-08-28 22:42:40 +00:00
{
2005-08-23 21:38:51 +00:00
if ( pi - > m_pLifeMeter )
ON_COMMAND ( pi - > m_pLifeMeter ) ;
}
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
{
ON_COMMAND ( pi - > m_ptextCourseSongNumber ) ;
ON_COMMAND ( pi - > m_ptextStepsDescription ) ;
if ( pi - > m_pPrimaryScoreDisplay )
ON_COMMAND ( pi - > m_pPrimaryScoreDisplay ) ;
if ( pi - > m_pSecondaryScoreDisplay )
ON_COMMAND ( pi - > m_pSecondaryScoreDisplay ) ;
ON_COMMAND ( pi - > m_ptextPlayerOptions ) ;
ON_COMMAND ( pi - > m_pActiveAttackList ) ;
ON_COMMAND ( pi - > m_pDifficultyIcon ) ;
ON_COMMAND ( pi - > m_pDifficultyMeter ) ;
if ( pi - > m_pPlayer - > HasNoteField ( ) )
ON_COMMAND ( pi - > m_pPlayer ) ;
2002-08-28 22:42:40 +00:00
}
2004-08-13 08:24:11 +00:00
2005-08-24 20:45:57 +00:00
if ( m_bShowScoreboard )
2004-08-13 08:40:53 +00:00
FOREACH_NSScoreBoardColumn ( sc )
ON_COMMAND ( m_Scoreboard [ sc ] ) ;
2005-10-14 03:11:50 +00:00
ScreenWithMenuElements : : TweenOnScreen ( ) ;
2002-05-20 08:59:37 +00:00
}
2002-06-14 22:25:22 +00:00
2005-10-13 22:52:25 +00:00
void ScreenGameplay : : TweenOffScreen ( )
2002-06-14 22:25:22 +00:00
{
2005-04-02 02:45:17 +00:00
ScreenWithMenuElements : : TweenOffScreen ( ) ;
2003-04-13 21:17:14 +00:00
OFF_COMMAND ( m_sprLifeFrame ) ;
2005-05-07 09:58:23 +00:00
OFF_COMMAND ( m_sprCourseSongNumber ) ;
2003-04-13 21:17:14 +00:00
OFF_COMMAND ( m_textSongOptions ) ;
OFF_COMMAND ( m_sprScoreFrame ) ;
2004-07-18 17:16:57 +00:00
OFF_COMMAND ( m_BPMDisplay ) ;
OFF_COMMAND ( m_MaxCombo ) ;
2005-08-26 17:39:53 +00:00
OFF_COMMAND ( m_pPlayerScoreList ) ;
2004-07-18 17:16:57 +00:00
2003-06-30 18:08:27 +00:00
if ( m_pCombinedLifeMeter )
OFF_COMMAND ( * m_pCombinedLifeMeter ) ;
2005-08-23 21:38:51 +00:00
FOREACH ( PlayerInfo , m_vPlayerInfo , pi )
2003-04-13 21:17:14 +00:00
{
2005-08-23 21:38:51 +00:00
if ( pi - > m_pLifeMeter )
OFF_COMMAND ( pi - > m_pLifeMeter ) ;
}
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
{
OFF_COMMAND ( pi - > m_ptextCourseSongNumber ) ;
OFF_COMMAND ( pi - > m_ptextStepsDescription ) ;
if ( pi - > m_pPrimaryScoreDisplay )
OFF_COMMAND ( pi - > m_pPrimaryScoreDisplay ) ;
if ( pi - > m_pSecondaryScoreDisplay )
OFF_COMMAND ( pi - > m_pSecondaryScoreDisplay ) ;
OFF_COMMAND ( pi - > m_ptextPlayerOptions ) ;
OFF_COMMAND ( pi - > m_pActiveAttackList ) ;
OFF_COMMAND ( pi - > m_pDifficultyIcon ) ;
OFF_COMMAND ( pi - > m_pDifficultyMeter ) ;
if ( pi - > m_pPlayer - > HasNoteField ( ) )
OFF_COMMAND ( pi - > m_pPlayer ) ;
2003-04-13 21:17:14 +00:00
}
2003-04-18 04:00:24 +00:00
2005-08-24 20:45:57 +00:00
if ( m_bShowScoreboard )
2004-08-13 08:40:53 +00:00
FOREACH_NSScoreBoardColumn ( sc )
OFF_COMMAND ( m_Scoreboard [ sc ] ) ;
2004-08-13 08:24:11 +00:00
2003-06-13 02:54:58 +00:00
m_textDebug . StopTweening ( ) ;
m_textDebug . BeginTweening ( 1 / 8.f ) ;
m_textDebug . SetDiffuse ( RageColor ( 1 , 1 , 1 , 0 ) ) ;
2002-06-14 22:25:22 +00:00
}
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 ] ;
}
2005-11-22 21:18:45 +00:00
void ScreenGameplay : : SaveRecordedResults ( )
{
FOREACH_HumanPlayer ( pn )
{
FOREACH_EnabledPlayerInfo ( m_vPlayerInfo , pi )
{
XNode * p = pi - > m_pPlayer - > m_NoteData . CreateNode ( ) ;
DISP_OPT opt ;
2005-12-02 03:46:27 +00:00
//
// Find a file name for the screenshot
//
FlushDirCache ( ) ;
2006-01-22 01:00:06 +00:00
vector < RString > files ;
2005-12-02 03:46:27 +00:00
GetDirListing ( " Save/recording* " , files , false , false ) ;
sort ( files . begin ( ) , files . end ( ) ) ;
/* Files should be of the form "recording######.xxx". */
int iIndex = 0 ;
for ( int i = files . size ( ) - 1 ; i > = 0 ; - - i )
{
static Regex re ( " ^recording([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-01-22 01:00:06 +00:00
RString sFileName = ssprintf ( " recording%05d.xml " , iIndex ) ;
2005-12-02 03:46:27 +00:00
p - > SaveToFile ( " Save/ " + sFileName , opt ) ;
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 :
LunaScreenGameplay ( ) { LUA - > Register ( Register ) ; }
static int GetNextCourseSong ( T * p , lua_State * L ) { p - > GetNextCourseSong ( ) - > PushSelf ( L ) ; return 1 ; }
static void Register ( Lua * L )
{
2005-09-10 02:47:04 +00:00
ADD_METHOD ( GetNextCourseSong ) ;
2005-07-12 21:12:12 +00:00
Luna < T > : : Register ( L ) ;
}
} ;
LUA_REGISTER_DERIVED_CLASS ( ScreenGameplay , ScreenWithMenuElements )
// 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.
*/