Files
itgmania212121/stepmania/src/Game.cpp
T

154 lines
4.2 KiB
C++
Raw Normal View History

2004-07-25 18:40:03 +00:00
#include "global.h"
#include "Game.h"
#include "RageLog.h"
#include "RageUtil.h"
#include "Style.h"
#include "GameState.h"
#include "PrefsManager.h"
int Game::GetNumGameplayButtons() const
{
int iIndexOfStart = ButtonNameToIndex( "Start" );
2006-09-27 04:44:15 +00:00
ASSERT( iIndexOfStart != GameButton_Invalid );
2004-07-25 18:40:03 +00:00
return iIndexOfStart;
}
2006-01-22 01:00:06 +00:00
GameButton Game::ButtonNameToIndex( const RString &sButtonName ) const
2004-07-25 18:40:03 +00:00
{
for( int i=0; i<m_iButtonsPerController; i++ )
if( stricmp(m_szButtonNames[i], sButtonName) == 0 )
return i;
2006-09-27 04:44:15 +00:00
return GameButton_Invalid;
2004-07-25 18:40:03 +00:00
}
MenuButton Game::GameInputToMenuButton( GameInput GameI ) const
2004-07-25 18:40:03 +00:00
{
2004-12-06 05:17:56 +00:00
FOREACH_MenuButton(i)
2004-07-25 18:40:03 +00:00
if( m_DedicatedMenuButton[i] == GameI.button )
return i;
2004-07-25 18:40:03 +00:00
if( !PREFSMAN->m_bOnlyDedicatedMenuButtons )
{
2004-12-06 05:17:56 +00:00
FOREACH_MenuButton(i)
2004-07-25 18:40:03 +00:00
if( m_SecondaryMenuButton[i] == GameI.button )
return i;
2004-07-25 18:40:03 +00:00
}
return MenuButton_INVALID; // invalid GameInput
2004-07-25 18:40:03 +00:00
}
void Game::MenuButtonToGameInputs( MenuButton MenuI, PlayerNumber pn, GameInput GameIout[4] ) const
2004-07-25 18:40:03 +00:00
{
ASSERT( MenuI != MenuButton_INVALID );
2004-07-25 18:40:03 +00:00
GameIout[0].MakeInvalid(); // initialize
GameIout[1].MakeInvalid();
GameIout[2].MakeInvalid();
GameIout[3].MakeInvalid();
GameController controller[2];
StyleType type = TWO_PLAYERS_TWO_SIDES;
2004-07-25 18:40:03 +00:00
if( GAMESTATE->GetCurrentStyle() )
type = GAMESTATE->GetCurrentStyle()->m_StyleType;
int iNumSidesUsing = 1;
switch( type )
{
case ONE_PLAYER_ONE_SIDE:
case TWO_PLAYERS_TWO_SIDES:
controller[0] = (GameController)pn;
2004-07-25 18:40:03 +00:00
iNumSidesUsing = 1;
break;
case ONE_PLAYER_TWO_SIDES:
2006-06-24 00:09:50 +00:00
case TWO_PLAYERS_SHARED_SIDES:
2004-07-25 18:40:03 +00:00
controller[0] = GAME_CONTROLLER_1;
controller[1] = GAME_CONTROLLER_2;
iNumSidesUsing = 2;
break;
default:
ASSERT(0); // invalid m_StyleType
};
2006-09-14 20:45:51 +00:00
GameButton button[2] = { m_DedicatedMenuButton[MenuI], m_SecondaryMenuButton[MenuI] };
2004-07-25 18:40:03 +00:00
int iNumButtonsUsing = PREFSMAN->m_bOnlyDedicatedMenuButtons ? 1 : 2;
for( int i=0; i<iNumSidesUsing; i++ )
{
for( int j=0; j<iNumButtonsUsing; j++ )
{
GameIout[i*2+j].controller = controller[i];
GameIout[i*2+j].button = button[j];
}
}
}
2006-09-13 09:16:57 +00:00
RString Game::ColToButtonName( int iCol ) const
{
2005-05-08 04:03:08 +00:00
const Style *pStyle = GAMESTATE->GetCurrentStyle();
2006-09-13 09:16:57 +00:00
const char *pzColumnName = pStyle->m_ColumnInfo[PLAYER_1][iCol].pzName;
if( pzColumnName != NULL )
return pzColumnName;
2006-09-13 09:16:57 +00:00
GameInput GI = pStyle->StyleInputToGameInput( iCol, PLAYER_1 );
return m_szButtonNames[GI.button];
}
2005-02-07 06:05:42 +00:00
TapNoteScore Game::MapTapNoteScore( TapNoteScore tns ) const
{
switch( tns )
{
case TNS_W1: return m_mapW1To;
case TNS_W2: return m_mapW2To;
case TNS_W3: return m_mapW3To;
case TNS_W4: return m_mapW4To;
case TNS_W5: return m_mapW5To;
2005-02-07 06:05:42 +00:00
default: return tns;
}
}
2005-06-25 03:30:20 +00:00
// lua start
#include "LuaBinding.h"
class LunaGame: public Luna<Game>
{
public:
static int GetName( T* p, lua_State *L ) { lua_pushstring( L, p->m_szName ); return 1; }
2006-09-27 19:53:05 +00:00
LunaGame()
{
LUA->Register( Register );
ADD_METHOD( GetName );
2005-06-25 03:30:20 +00:00
}
};
LUA_REGISTER_CLASS( Game )
// lua end
2004-07-25 18:40:03 +00:00
/*
* (c) 2001-2002 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.
*/