add ScreenJoinMultiplayer
This commit is contained in:
@@ -35,6 +35,7 @@ ScreenNetSelectMusic.cpp ScreenNetSelectMusic.h ScreenNetSelectBase.cpp ScreenNe
|
|||||||
ScreenEz2SelectMusic.cpp ScreenEz2SelectMusic.h ScreenEz2SelectPlayer.cpp ScreenEz2SelectPlayer.h \
|
ScreenEz2SelectMusic.cpp ScreenEz2SelectMusic.h ScreenEz2SelectPlayer.cpp ScreenEz2SelectPlayer.h \
|
||||||
ScreenGameplay.cpp ScreenGameplay.h ScreenHowToPlay.cpp ScreenHowToPlay.h \
|
ScreenGameplay.cpp ScreenGameplay.h ScreenHowToPlay.cpp ScreenHowToPlay.h \
|
||||||
ScreenInstructions.cpp ScreenInstructions.h \
|
ScreenInstructions.cpp ScreenInstructions.h \
|
||||||
|
ScreenJoinMultiplayer.cpp ScreenJoinMultiplayer.h \
|
||||||
ScreenJukebox.cpp ScreenJukebox.h \
|
ScreenJukebox.cpp ScreenJukebox.h \
|
||||||
ScreenMapControllers.cpp ScreenMapControllers.h \
|
ScreenMapControllers.cpp ScreenMapControllers.h \
|
||||||
ScreenMessage.cpp ScreenMessage.h ScreenMiniMenu.cpp ScreenMiniMenu.h ScreenMusicScroll.cpp ScreenMusicScroll.h \
|
ScreenMessage.cpp ScreenMessage.h ScreenMiniMenu.cpp ScreenMiniMenu.h ScreenMusicScroll.cpp ScreenMusicScroll.h \
|
||||||
|
|||||||
@@ -0,0 +1,248 @@
|
|||||||
|
/*
|
||||||
|
* Join players in perparation for ScreenGameplayMultiplayer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "global.h"
|
||||||
|
#include "ScreenJoinMultiplayer.h"
|
||||||
|
#include "RageInput.h"
|
||||||
|
class Style;
|
||||||
|
#include "GameManager.h"
|
||||||
|
#include "GameState.h"
|
||||||
|
#include "InputMapper.h"
|
||||||
|
#include "GameSoundManager.h"
|
||||||
|
#include "GameCommand.h"
|
||||||
|
|
||||||
|
enum MultiPlayerStatus
|
||||||
|
{
|
||||||
|
MultiPlayerStatus_Joined,
|
||||||
|
MultiPlayerStatus_NotJoined,
|
||||||
|
MultiPlayerStatus_Unplugged,
|
||||||
|
MultiPlayerStatus_MissingMultitap,
|
||||||
|
NUM_MultiPlayerStatus,
|
||||||
|
MultiPlayerStatus_Invalid
|
||||||
|
};
|
||||||
|
|
||||||
|
static const CString MultiPlayerStatusNames[] = {
|
||||||
|
"Joined",
|
||||||
|
"NotJoined",
|
||||||
|
"Unplugged",
|
||||||
|
"MissingMultitap",
|
||||||
|
};
|
||||||
|
XToString( MultiPlayerStatus, NUM_MultiPlayerStatus );
|
||||||
|
|
||||||
|
static bool IsConnected( MultiPlayerStatus s )
|
||||||
|
{
|
||||||
|
return s == MultiPlayerStatus_Joined || s == MultiPlayerStatus_NotJoined;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static MultiPlayerStatus g_MultiPlayerStatus[NUM_MultiPlayer];
|
||||||
|
|
||||||
|
REGISTER_SCREEN_CLASS( ScreenJoinMultiplayer );
|
||||||
|
ScreenJoinMultiplayer::ScreenJoinMultiplayer( CString sClassName ) : ScreenWithMenuElements( sClassName )
|
||||||
|
{
|
||||||
|
FOREACH_MultiPlayer( p )
|
||||||
|
g_MultiPlayerStatus[p] = MultiPlayerStatus_Invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenJoinMultiplayer::Init()
|
||||||
|
{
|
||||||
|
ScreenWithMenuElements::Init();
|
||||||
|
|
||||||
|
// Set Style to the first style (should be a one player style)
|
||||||
|
vector<const Style*> v;
|
||||||
|
GAMEMAN->GetStylesForGame( GAMESTATE->m_pCurGame, v, false );
|
||||||
|
GAMESTATE->m_pCurStyle.Set( v[0] );
|
||||||
|
|
||||||
|
FOREACH_MultiPlayer( p )
|
||||||
|
{
|
||||||
|
GameCommand gc;
|
||||||
|
gc.m_iIndex = p;
|
||||||
|
|
||||||
|
Lua *L = LUA->Get();
|
||||||
|
gc.PushSelf( L );
|
||||||
|
lua_setglobal( L, "ThisGameCommand" );
|
||||||
|
LUA->Release( L );
|
||||||
|
|
||||||
|
m_sprPlayer[p].Load( THEME->GetPathG(m_sName, "player") );
|
||||||
|
this->AddChild( m_sprPlayer[p] );
|
||||||
|
|
||||||
|
LUA->UnsetGlobal( "ThisGameCommand" );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_exprOnCommandFunction.SetFromExpression( THEME->GetMetric(m_sName,"TranformFunction") );
|
||||||
|
|
||||||
|
FOREACH_MultiPlayer( p )
|
||||||
|
{
|
||||||
|
PositionItem( m_sprPlayer[p], p, NUM_MultiPlayer );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_soundPlugIn.Load( THEME->GetPathS(m_sName,"PlugIn") );
|
||||||
|
m_soundUnplug.Load( THEME->GetPathS(m_sName,"Unplug") );
|
||||||
|
m_soundJoin.Load( THEME->GetPathS(m_sName,"Join") );
|
||||||
|
m_soundUnjoin.Load( THEME->GetPathS(m_sName,"Unjoin") );
|
||||||
|
|
||||||
|
UpdatePlayerStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenJoinMultiplayer::PositionItem( Actor *pActor, int iItemIndex, int iNumItems )
|
||||||
|
{
|
||||||
|
Lua *L = LUA->Get();
|
||||||
|
m_exprOnCommandFunction.PushSelf( L );
|
||||||
|
ASSERT( !lua_isnil(L, -1) );
|
||||||
|
pActor->PushSelf( L );
|
||||||
|
LuaHelpers::Push( iItemIndex, L );
|
||||||
|
LuaHelpers::Push( iNumItems, L );
|
||||||
|
lua_call( L, 3, 0 ); // 3 args, 0 results
|
||||||
|
LUA->Release(L);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenJoinMultiplayer::HandleScreenMessage( const ScreenMessage SM )
|
||||||
|
{
|
||||||
|
ScreenWithMenuElements::HandleScreenMessage( SM );
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenJoinMultiplayer::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
|
||||||
|
{
|
||||||
|
if( this->IsTransitioning() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Translate input and sent to the appropriate player. Assume that all
|
||||||
|
// joystick devices are mapped the same as the master player.
|
||||||
|
if( DeviceI.device >= DEVICE_JOY1 &&
|
||||||
|
DeviceI.device < DEVICE_JOY1 + NUM_MultiPlayer )
|
||||||
|
{
|
||||||
|
DeviceInput di = DeviceI;
|
||||||
|
di.device = DEVICE_JOY1;
|
||||||
|
GameInput gi;
|
||||||
|
INPUTMAPPER->DeviceToGame( di, gi );
|
||||||
|
|
||||||
|
if( GameI.IsValid() )
|
||||||
|
{
|
||||||
|
MenuInput mi;
|
||||||
|
INPUTMAPPER->GameToMenu( gi, mi );
|
||||||
|
|
||||||
|
MultiPlayer p = (MultiPlayer)(DeviceI.device - DEVICE_JOY1);
|
||||||
|
|
||||||
|
ASSERT( p>=0 && p<NUM_MultiPlayer );
|
||||||
|
|
||||||
|
MultiPlayerStatus old = g_MultiPlayerStatus[p];
|
||||||
|
|
||||||
|
switch( mi.button )
|
||||||
|
{
|
||||||
|
case MENU_BUTTON_UP:
|
||||||
|
if( old == MultiPlayerStatus_NotJoined )
|
||||||
|
{
|
||||||
|
m_soundJoin.Play();
|
||||||
|
g_MultiPlayerStatus[p] = MultiPlayerStatus_Joined;
|
||||||
|
m_sprPlayer[p]->PlayCommand( MultiPlayerStatusToString(g_MultiPlayerStatus[p]) );
|
||||||
|
}
|
||||||
|
return; // input handled
|
||||||
|
case MENU_BUTTON_DOWN:
|
||||||
|
if( old == MultiPlayerStatus_Joined )
|
||||||
|
{
|
||||||
|
m_soundUnjoin.Play();
|
||||||
|
g_MultiPlayerStatus[p] = MultiPlayerStatus_NotJoined;
|
||||||
|
m_sprPlayer[p]->PlayCommand( MultiPlayerStatusToString(g_MultiPlayerStatus[p]) );
|
||||||
|
}
|
||||||
|
return; // input handled
|
||||||
|
case MENU_BUTTON_BACK:
|
||||||
|
MenuBack( GAMESTATE->m_MasterPlayerNumber );
|
||||||
|
return; // input handled
|
||||||
|
case MENU_BUTTON_START:
|
||||||
|
MenuStart( GAMESTATE->m_MasterPlayerNumber );
|
||||||
|
return; // input handled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ScreenWithMenuElements::Input( DeviceI, type, GameI, MenuI, StyleI );
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenJoinMultiplayer::Update( float fDeltaTime )
|
||||||
|
{
|
||||||
|
ScreenWithMenuElements::Update(fDeltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenJoinMultiplayer::DrawPrimitives()
|
||||||
|
{
|
||||||
|
ScreenWithMenuElements::DrawPrimitives();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenJoinMultiplayer::UpdatePlayerStatus()
|
||||||
|
{
|
||||||
|
FOREACH_MultiPlayer( p )
|
||||||
|
{
|
||||||
|
InputDevice id = (InputDevice)p;
|
||||||
|
|
||||||
|
MultiPlayerStatus old = g_MultiPlayerStatus[p];
|
||||||
|
bool bWasConnected = IsConnected( old );
|
||||||
|
|
||||||
|
MultiPlayerStatus s = MultiPlayerStatus_Invalid;
|
||||||
|
switch( INPUTMAN->GetInputDeviceState(id) )
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
ASSERT(0);
|
||||||
|
case InputDeviceState_Connected:
|
||||||
|
s = MultiPlayerStatus_NotJoined;
|
||||||
|
break;
|
||||||
|
case InputDeviceState_INVALID:
|
||||||
|
case InputDeviceState_Disconnected:
|
||||||
|
s = MultiPlayerStatus_Unplugged;
|
||||||
|
break;
|
||||||
|
case InputDeviceState_MissingMultitap:
|
||||||
|
s = MultiPlayerStatus_MissingMultitap;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( old != s )
|
||||||
|
{
|
||||||
|
m_sprPlayer[p]->PlayCommand( MultiPlayerStatusToString(s) );
|
||||||
|
g_MultiPlayerStatus[p] = s;
|
||||||
|
|
||||||
|
bool bIsConnected = IsConnected( s );
|
||||||
|
|
||||||
|
if( !bWasConnected && bIsConnected )
|
||||||
|
m_soundPlugIn.Play();
|
||||||
|
else if( bWasConnected && !bIsConnected )
|
||||||
|
m_soundUnplug.Play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenJoinMultiplayer::MenuBack( PlayerNumber pn )
|
||||||
|
{
|
||||||
|
SOUND->StopMusic();
|
||||||
|
Cancel( SM_GoToPrevScreen );
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenJoinMultiplayer::MenuStart( PlayerNumber pn )
|
||||||
|
{
|
||||||
|
this->StartTransitioning( SM_BeginFadingOut );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (c) 2005 Chris Danford
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
#ifndef ScreenJoinMultiplayer_H
|
||||||
|
#define ScreenJoinMultiplayer_H
|
||||||
|
|
||||||
|
#include "ScreenWithMenuElements.h"
|
||||||
|
|
||||||
|
class ScreenJoinMultiplayer : public ScreenWithMenuElements
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ScreenJoinMultiplayer( CString sName );
|
||||||
|
virtual void Init();
|
||||||
|
|
||||||
|
virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
|
||||||
|
virtual void HandleScreenMessage( const ScreenMessage SM );
|
||||||
|
virtual void Update(float f);
|
||||||
|
virtual void DrawPrimitives();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void UpdatePlayerStatus();
|
||||||
|
void PositionItem( Actor *pActor, int iItemIndex, int iNumItems );
|
||||||
|
|
||||||
|
virtual void MenuBack( PlayerNumber pn );
|
||||||
|
virtual void MenuStart( PlayerNumber pn );
|
||||||
|
|
||||||
|
AutoActor m_sprPlayer[NUM_MultiPlayer];
|
||||||
|
|
||||||
|
LuaExpression m_exprOnCommandFunction; // params: self,itemIndex,numItems
|
||||||
|
|
||||||
|
RageSound m_soundPlugIn;
|
||||||
|
RageSound m_soundUnplug;
|
||||||
|
RageSound m_soundJoin;
|
||||||
|
RageSound m_soundUnjoin;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (c) 2005 Chris Danford
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
@@ -369,6 +369,12 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\
|
|||||||
<File
|
<File
|
||||||
RelativePath="ScreenInstructions.h">
|
RelativePath="ScreenInstructions.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\ScreenJoinMultiplayer.cpp">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\ScreenJoinMultiplayer.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="ScreenJukebox.cpp">
|
RelativePath="ScreenJukebox.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ IntDir=.\../Debug6
|
|||||||
TargetDir=\cvs\stepmania\Program
|
TargetDir=\cvs\stepmania\Program
|
||||||
TargetName=StepMania-debug
|
TargetName=StepMania-debug
|
||||||
SOURCE="$(InputPath)"
|
SOURCE="$(InputPath)"
|
||||||
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||||
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
|
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
|
||||||
# End Special Build Tool
|
# End Special Build Tool
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ IntDir=.\../Release6
|
|||||||
TargetDir=\cvs\stepmania\Program
|
TargetDir=\cvs\stepmania\Program
|
||||||
TargetName=StepMania
|
TargetName=StepMania
|
||||||
SOURCE="$(InputPath)"
|
SOURCE="$(InputPath)"
|
||||||
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||||
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
|
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
|
||||||
# End Special Build Tool
|
# End Special Build Tool
|
||||||
|
|
||||||
@@ -2656,6 +2656,14 @@ SOURCE=.\ScreenInstructions.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\ScreenJoinMultiplayer.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\ScreenJoinMultiplayer.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\ScreenJukebox.cpp
|
SOURCE=.\ScreenJukebox.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|||||||
@@ -349,6 +349,12 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\
|
|||||||
<File
|
<File
|
||||||
RelativePath="ScreenInstructions.h">
|
RelativePath="ScreenInstructions.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="ScreenJoinMultiplayer.cpp">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="ScreenJoinMultiplayer.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="ScreenJukebox.cpp">
|
RelativePath="ScreenJukebox.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
|||||||
Reference in New Issue
Block a user