working on fixing up extra loads when entering play mode in the editor

This commit is contained in:
Glenn Maynard
2005-01-15 01:28:29 +00:00
parent 36445d1e1b
commit 3a9b2f7f4b
8 changed files with 70 additions and 46 deletions
+9
View File
@@ -609,6 +609,15 @@ float GameSoundManager::GetPlayLatency() const
return SOUNDMAN->GetPlayLatency();
}
void GameSoundManager::SetPlayerBalance( PlayerNumber pn, RageSoundParams &params )
{
/* If two players are active, play sounds on each players' side. */
if( GAMESTATE->GetNumPlayersEnabled() == 2 )
params.m_Balance = (pn == PLAYER_1)? -1.0f:1.0f;
else
params.m_Balance = 0;
}
/*
* Copyright (c) 2003-2004 Glenn Maynard
* All rights reserved.
+5
View File
@@ -3,8 +3,11 @@
#ifndef RAGE_SOUNDS_H
#define RAGE_SOUNDS_H
#include "PlayerNumber.h"
class TimingData;
class RageSound;
struct RageSoundParams;
class GameSoundManager
{
public:
@@ -26,6 +29,8 @@ public:
float GetPlayLatency() const;
void HandleSongTimer( bool on=true );
float GetFrameTimingAdjustment( float fDeltaTime );
static void SetPlayerBalance( PlayerNumber pn, RageSoundParams &params );
};
extern GameSoundManager *SOUND;
+41 -33
View File
@@ -32,6 +32,7 @@
#include "ThemeMetric.h"
#include "PlayerState.h"
#include "GameplayMessages.h"
#include "GameSoundManager.h"
ThemeMetric<float> GRAY_ARROWS_Y_STANDARD ("Player","ReceptorArrowsYStandard");
ThemeMetric<float> GRAY_ARROWS_Y_REVERSE ("Player","ReceptorArrowsYReverse");
@@ -94,9 +95,9 @@ Player::~Player()
delete m_pNoteField;
}
void Player::Load(
/* Init() does the expensive stuff: load sounds and note skins. Load() just loads a NoteData. */
void Player::Init(
PlayerState* pPlayerState,
const NoteData& noteData,
PlayerStageStats* pPlayerStageStats,
LifeMeter* pLM,
CombinedLifeMeter* pCombinedLM,
@@ -106,8 +107,6 @@ void Player::Load(
ScoreKeeper* pPrimaryScoreKeeper,
ScoreKeeper* pSecondaryScoreKeeper )
{
m_iDCState = AS2D_IDLE;
m_pPlayerState = pPlayerState;
m_pPlayerStageStats = pPlayerStageStats;
m_pLifeMeter = pLM;
@@ -117,11 +116,44 @@ void Player::Load(
m_pInventory = pInventory;
m_pPrimaryScoreKeeper = pPrimaryScoreKeeper;
m_pSecondaryScoreKeeper = pSecondaryScoreKeeper;
m_soundMine.Load( THEME->GetPathToS("Player mine"), true );
/* Attacks can be launched in course modes and in battle modes. They both come
* here to play, but allow loading a different sound for different modes. */
switch( GAMESTATE->m_PlayMode )
{
case PLAY_MODE_RAVE:
case PLAY_MODE_BATTLE:
m_soundAttackLaunch.Load( THEME->GetPathToS("Player battle attack launch"), true );
m_soundAttackEnding.Load( THEME->GetPathToS("Player battle attack ending"), true );
break;
default:
m_soundAttackLaunch.Load( THEME->GetPathToS("Player course attack launch"), true );
m_soundAttackEnding.Load( THEME->GetPathToS("Player course attack ending"), true );
break;
}
// TODO: Remove use of PlayerNumber.
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
RageSoundParams p;
GameSoundManager::SetPlayerBalance( pn, p );
m_soundMine.SetParams( p );
m_soundAttackLaunch.SetParams( p );
m_soundAttackEnding.SetParams( p );
}
void Player::Load( const NoteData& noteData )
{
m_iDCState = AS2D_IDLE;
m_iRowLastCrossed = BeatToNoteRowNotRounded( GAMESTATE->m_fSongBeat ) - 1; // why this?
m_iMineRowLastCrossed = BeatToNoteRowNotRounded( GAMESTATE->m_fSongBeat ) - 1; // why this?
// TODO: Remove use of PlayerNumber.
PlayerNumber pn = pPlayerState->m_PlayerNumber;
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
GAMESTATE->ResetNoteSkinsForPlayer( pn );
@@ -228,40 +260,16 @@ void Player::Load(
// Need to set Y positions of all these elements in Update since
// they change depending on PlayerOptions.
RageSoundParams p;
m_soundMine.Load( THEME->GetPathToS("Player mine"), true );
/* Attacks can be launched in course modes and in battle modes. They both come
* here to play, but allow loading a different sound for different modes. */
switch( GAMESTATE->m_PlayMode )
{
case PLAY_MODE_RAVE:
case PLAY_MODE_BATTLE:
m_soundAttackLaunch.Load( THEME->GetPathToS("Player battle attack launch"), true );
m_soundAttackEnding.Load( THEME->GetPathToS("Player battle attack ending"), true );
break;
default:
m_soundAttackLaunch.Load( THEME->GetPathToS("Player course attack launch"), true );
m_soundAttackEnding.Load( THEME->GetPathToS("Player course attack ending"), true );
break;
}
if( GAMESTATE->GetNumPlayersEnabled() == 2 )
{
/* Two players are active. Play sounds on this player's side. */
p.m_Balance = (pn == PLAYER_1)? -1.0f:1.0f;
}
m_soundMine.SetParams( p );
m_soundAttackLaunch.SetParams( p );
m_soundAttackEnding.SetParams( p );
//
// Load keysounds
//
Song* pSong = GAMESTATE->m_pCurSong;
const Song* pSong = GAMESTATE->m_pCurSong;
CString sSongDir = pSong->GetSongDir();
m_vKeysounds.clear();
m_vKeysounds.resize( pSong->m_vsKeysoundFile.size() );
RageSoundParams p;
GameSoundManager::SetPlayerBalance( pn, p );
for( unsigned i=0; i<m_vKeysounds.size(); i++ )
{
CString sKeysoundFilePath = sSongDir + pSong->m_vsKeysoundFile[i];
+2 -2
View File
@@ -33,9 +33,8 @@ public:
virtual void Update( float fDeltaTime );
virtual void DrawPrimitives();
void Load(
void Init(
PlayerState* pPlayerState,
const NoteData& noteData,
PlayerStageStats* pPlayerStageStats,
LifeMeter* pLM,
CombinedLifeMeter* pCombinedLM,
@@ -44,6 +43,7 @@ public:
Inventory* pInventory,
ScoreKeeper* pPrimaryScoreKeeper,
ScoreKeeper* pSecondaryScoreKeeper );
void Load( const NoteData& noteData );
void CrossedRow( int iNoteRow );
void CrossedMineRow( int iNoteRow );
void Step( int col, RageTimer tm );
+5 -3
View File
@@ -552,9 +552,8 @@ ScreenEdit::ScreenEdit( CString sName ) : Screen( sName )
/* XXX: Do we actually have to send real note data here, and to m_NoteFieldRecord?
* (We load again on play/record.) */
m_Player.Load(
m_Player.Init(
GAMESTATE->m_pPlayerState[PLAYER_1],
noteData,
NULL,
NULL,
NULL,
@@ -563,6 +562,7 @@ ScreenEdit::ScreenEdit( CString sName ) : Screen( sName )
NULL,
NULL,
NULL );
m_Player.Load( noteData );
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerController = PC_HUMAN;
m_Player.SetXY( PLAYER_X, PLAYER_Y );
@@ -2177,9 +2177,11 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers )
float fSeconds = m_pSong->m_Timing.GetElapsedTimeFromBeat( m_NoteFieldEdit.m_fBeginMarker - 4 );
GAMESTATE->UpdateSongPosition( fSeconds, m_pSong->m_Timing );
/* If we're in course display mode, set that up. */
SetupCourseAttacks();
m_Player.Load( GAMESTATE->m_pPlayerState[PLAYER_1], m_NoteFieldEdit, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL );
m_Player.Init( GAMESTATE->m_pPlayerState[PLAYER_1], NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL );
m_Player.Load( m_NoteFieldEdit );
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerController = PREFSMAN->m_bAutoPlay?PC_AUTOPLAY:PC_HUMAN;
m_rectRecordBack.StopTweening();
+2 -2
View File
@@ -831,9 +831,8 @@ void ScreenGameplay::SetupSong( PlayerNumber p, int iSongIndex )
{
NoteData nd = ndTransformed;
NoteDataUtil::RemoveAllTapsOfType( nd, TapNote::autoKeysound );
m_Player[p].Load(
m_Player[p].Init(
GAMESTATE->m_pPlayerState[p],
nd,
&g_CurStageStats.m_player[p],
m_pLifeMeter[p],
m_pCombinedLifeMeter,
@@ -842,6 +841,7 @@ void ScreenGameplay::SetupSong( PlayerNumber p, int iSongIndex )
m_pInventory[p],
m_pPrimaryScoreKeeper[p],
m_pSecondaryScoreKeeper[p] );
m_Player[p].Load( nd );
}
// load auto keysounds
+4 -4
View File
@@ -308,9 +308,8 @@ void ScreenGameplayMultiplayer::SetupSong( MultiPlayer p, int iSongIndex )
{
NoteData nd = ndTransformed;
NoteDataUtil::RemoveAllTapsOfType( nd, TapNote::autoKeysound );
m_AutoPlayer.Load(
m_AutoPlayer.Init(
GAMESTATE->m_pPlayerState[ GAMESTATE->m_MasterPlayerNumber ],
nd,
NULL,
NULL,
NULL,
@@ -319,10 +318,10 @@ void ScreenGameplayMultiplayer::SetupSong( MultiPlayer p, int iSongIndex )
NULL,
NULL,
NULL );
m_AutoPlayer.Load( nd );
m_HumanPlayer[p].Load(
m_HumanPlayer[p].Init(
&m_PlayerState[p],
nd,
&m_PlayerStageStats[p],
NULL,
NULL,
@@ -331,6 +330,7 @@ void ScreenGameplayMultiplayer::SetupSong( MultiPlayer p, int iSongIndex )
NULL,
m_pPrimaryScoreKeeper[p],
NULL );
m_HumanPlayer[p].Load( nd );
}
// load auto keysounds
+2 -2
View File
@@ -151,9 +151,8 @@ ScreenHowToPlay::ScreenHowToPlay( CString sName ) : ScreenAttract( sName )
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerController = PC_AUTOPLAY;
m_pPlayer = new Player;
m_pPlayer->Load(
m_pPlayer->Init(
GAMESTATE->m_pPlayerState[PLAYER_1],
m_NoteData,
NULL,
m_pLifeMeterBar,
NULL,
@@ -162,6 +161,7 @@ ScreenHowToPlay::ScreenHowToPlay( CString sName ) : ScreenAttract( sName )
NULL,
NULL,
NULL );
m_pPlayer->Load( m_NoteData );
m_pPlayer->SetName( "Player" );
this->AddChild( m_pPlayer );
SET_XY_AND_ON_COMMAND( m_pPlayer );