beginnings of late join

This commit is contained in:
Chris Danford
2007-03-04 08:52:06 +00:00
parent 7d872d9710
commit cf80f30e3b
7 changed files with 43 additions and 9 deletions
+1
View File
@@ -3909,6 +3909,7 @@ AreStagePlayerModsForced=AreStagePlayerModsForced
AreStageSongModsForced=AreStageSongModsForced
GradeTierForExtra1="Grade_Tier03"
GradeTierForExtra2="Grade_Tier03"
AllowLateJoin=false
[ScreenMiniMenuContext]
Fallback="ScreenMiniMenu"
+22 -4
View File
@@ -35,6 +35,8 @@
#include "Style.h"
#include "ThemeManager.h"
#include "UnlockManager.h"
#include "ScreenManager.h"
#include "Screen.h"
#include <ctime>
#include <set>
@@ -76,6 +78,7 @@ struct GameStateImpl
};
static GameStateImpl *g_pImpl = NULL;
ThemeMetric<bool> ALLOW_LATE_JOIN("GameState","AllowLateJoin");
ThemeMetric<bool> USE_NAME_BLACKLIST("GameState","UseNameBlacklist");
ThemeMetric<RString> DEFAULT_SORT ("GameState","DefaultSort");
@@ -317,9 +320,6 @@ void GameState::Reset()
void GameState::JoinPlayer( PlayerNumber pn )
{
m_bSideIsJoined[pn] = true;
Message msg( MessageIDToString(Message_PlayerJoined) );
msg.SetParam( "Player", pn );
MESSAGEMAN->Broadcast( msg );
if( m_MasterPlayerNumber == PLAYER_INVALID )
m_MasterPlayerNumber = pn;
@@ -327,6 +327,17 @@ void GameState::JoinPlayer( PlayerNumber pn )
// if first player to join, set start time
if( GetNumSidesJoined() == 1 )
BeginGame();
// Set the current style to something appropriate for the new number of joined players.
if( ALLOW_LATE_JOIN && GAMESTATE->m_pCurStyle != NULL )
{
const Style *pStyle = GAMEMAN->GetFirstCompatibleStyle( m_pCurGame, GetNumSidesJoined(), m_pCurStyle->m_StepsType );
GAMESTATE->m_pCurStyle.Set( pStyle );
}
Message msg( MessageIDToString(Message_PlayerJoined) );
msg.SetParam( "Player", pn );
MESSAGEMAN->Broadcast( msg );
}
/* Handle an input that can join a player. Return true if the player joined. */
@@ -906,7 +917,14 @@ RString GameState::GetPlayerDisplayName( PlayerNumber pn ) const
bool GameState::PlayersCanJoin() const
{
return GetNumSidesJoined() == 0 || GetCurrentStyle() == NULL; // selecting a style finalizes the players
bool b = GetNumSidesJoined() == 0 || GetCurrentStyle() == NULL; // selecting a style finalizes the players
if( ALLOW_LATE_JOIN.IsLoaded() && ALLOW_LATE_JOIN )
{
Screen *pScreen = SCREENMAN->GetTopScreen();
if( pScreen )
b |= pScreen->AllowLateJoin();
}
return b;
}
int GameState::GetNumSidesJoined() const
+1
View File
@@ -55,6 +55,7 @@ public:
virtual ScreenType GetScreenType() const { return ALLOW_OPERATOR_MENU_BUTTON ? game_menu : system_menu; }
bool AllowOperatorMenuButton() const { return ALLOW_OPERATOR_MENU_BUTTON; }
virtual bool AllowLateJoin() const { return false; }
//
// Lua
+1 -1
View File
@@ -134,7 +134,7 @@ void ScreenSelect::Input( const InputEventPlus &input )
{
// LOG->Trace( "ScreenSelect::Input()" );
/* Reset the demonstration timer when a key is pressed. */
/* Reset the announcer timers when a key is pressed. */
m_timerIdleComment.GetDeltaTime();
m_timerIdleTimeout.GetDeltaTime();
+1
View File
@@ -38,6 +38,7 @@ public:
virtual void TweenOffScreen();
virtual void HandleScreenMessage( const ScreenMessage SM );
virtual bool AllowLateJoin() const { return true; }
protected:
enum Page { PAGE_1, PAGE_2, NUM_PAGES }; // on PAGE_2, cursors are locked together
+16 -4
View File
@@ -147,7 +147,7 @@ void ScreenSelectMusic::Init()
COMMAND( m_sprCDTitleBack, "Back" );
this->AddChild( &m_sprCDTitleBack );
FOREACH_HumanPlayer( p )
FOREACH_ENUM( PlayerNumber, p )
{
m_sprHighScoreFrame[p].SetName( ssprintf("ScoreFrameP%d",p+1) );
m_sprHighScoreFrame[p].Load( THEME->GetPathG(m_sName,ssprintf("score frame p%d",p+1)) );
@@ -287,6 +287,18 @@ void ScreenSelectMusic::Input( const InputEventPlus &input )
{
// LOG->Trace( "ScreenSelectMusic::Input()" );
if( input.MenuI == MENU_BUTTON_START && input.type == IET_FIRST_PRESS && GAMESTATE->JoinInput(input.pn) )
{
int iSel = 0;
m_iSelection[input.pn] = iSel;
SwitchToPreferredDifficulty();
return; // don't handle this press again below
}
// temp Chris debug
if( input.DeviceI.device == DEVICE_KEYBOARD && input.DeviceI.button == KEY_F8 )
{
@@ -432,7 +444,7 @@ void ScreenSelectMusic::Input( const InputEventPlus &input )
bool bLeftIsDown = false;
bool bRightIsDown = false;
FOREACH_EnabledPlayer( p )
FOREACH_HumanPlayer( p )
{
bLeftIsDown |= INPUTMAPPER->IsBeingPressed( m_GameButtonPreviousSong, p );
bRightIsDown |= INPUTMAPPER->IsBeingPressed( m_GameButtonNextSong, p );
@@ -540,7 +552,7 @@ bool ScreenSelectMusic::DetectCodes( const InputEventPlus &input )
void ScreenSelectMusic::UpdateSelectButton()
{
bool bSelectIsDown = false;
FOREACH_EnabledPlayer( pn )
FOREACH_HumanPlayer( pn )
bSelectIsDown |= INPUTMAPPER->IsBeingPressed( MENU_BUTTON_SELECT, pn );
if( !SELECT_MENU_AVAILABLE )
bSelectIsDown = false;
@@ -590,7 +602,7 @@ void ScreenSelectMusic::ChangeDifficulty( PlayerNumber pn, int dir )
}
vector<PlayerNumber> vpns;
FOREACH_HumanPlayer( p )
FOREACH_ENUM( PlayerNumber, p )
{
if( pn == p || GAMESTATE->DifficultiesLocked() )
{
+1
View File
@@ -27,6 +27,7 @@ public:
virtual void Update( float fDeltaTime );
virtual void Input( const InputEventPlus &input );
virtual void HandleScreenMessage( const ScreenMessage SM );
virtual bool AllowLateJoin() const { return true; }
virtual void MenuStart( const InputEventPlus &input );
virtual void MenuBack( const InputEventPlus &input );