Files
itgmania212121/stepmania/src/GameDef.cpp
T

131 lines
4.0 KiB
C++
Raw Normal View History

2003-02-16 04:01:45 +00:00
#include "global.h"
2002-04-16 17:31:00 +00:00
#include "GameDef.h"
2002-05-01 19:14:55 +00:00
#include "RageLog.h"
2002-04-16 17:31:00 +00:00
#include "RageUtil.h"
2002-04-28 20:42:32 +00:00
#include "IniFile.h"
#include "StyleDef.h"
2002-07-27 19:29:51 +00:00
#include "RageException.h"
#include "GameState.h"
#include "InputMapper.h"
#include "PrefsManager.h"
2002-04-28 20:42:32 +00:00
2004-03-30 04:32:27 +00:00
int GameDef::GetNumGameplayButtons()
{
int iIndexOfStart = ButtonNameToIndex( "Start" );
ASSERT( iIndexOfStart != GAME_BUTTON_INVALID );
return iIndexOfStart;
}
2004-01-25 02:27:41 +00:00
GameButton GameDef::ButtonNameToIndex( const CString &sButtonName ) const
2002-12-17 21:14:45 +00:00
{
for( int i=0; i<m_iButtonsPerController; i++ )
if( stricmp(m_szButtonNames[i], sButtonName) == 0 )
return i;
2002-12-17 21:14:45 +00:00
return GAME_BUTTON_INVALID;
}
2002-08-22 23:36:03 +00:00
MenuInput GameDef::GameInputToMenuInput( GameInput GameI ) const
{
PlayerNumber pn;
StyleDef::StyleType type = StyleDef::TWO_PLAYERS_TWO_CREDITS;
2003-01-30 07:18:33 +00:00
if( GAMESTATE->m_CurStyle != STYLE_INVALID )
type = GAMESTATE->GetCurrentStyleDef()->m_StyleType;
switch( type )
{
case StyleDef::ONE_PLAYER_ONE_CREDIT:
case StyleDef::TWO_PLAYERS_TWO_CREDITS:
pn = (PlayerNumber)GameI.controller;
break;
case StyleDef::ONE_PLAYER_TWO_CREDITS:
2002-08-20 21:00:56 +00:00
pn = GAMESTATE->m_MasterPlayerNumber;
break;
default:
2002-09-07 10:43:16 +00:00
ASSERT(0); return MenuInput(); // invalid m_StyleType
};
2002-11-16 08:54:15 +00:00
int i;
for( i=0; i<NUM_MENU_BUTTONS; i++ )
if( m_DedicatedMenuButton[i] == GameI.button )
return MenuInput( pn, (MenuButton)i );
2002-08-20 21:00:56 +00:00
if( !PREFSMAN->m_bOnlyDedicatedMenuButtons )
{
for( i=0; i<NUM_MENU_BUTTONS; i++ )
if( m_SecondaryMenuButton[i] == GameI.button )
return MenuInput( pn, (MenuButton)i );
}
return MenuInput(); // invalid GameInput
}
2002-08-22 23:36:03 +00:00
void GameDef::MenuInputToGameInput( MenuInput MenuI, GameInput GameIout[4] ) const
{
ASSERT( MenuI.IsValid() );
GameIout[0].MakeInvalid(); // initialize
GameIout[1].MakeInvalid();
GameIout[2].MakeInvalid();
GameIout[3].MakeInvalid();
GameController controller[2];
StyleDef::StyleType type = StyleDef::TWO_PLAYERS_TWO_CREDITS;
if( GAMESTATE->m_CurStyle != STYLE_INVALID )
type = GAMESTATE->GetCurrentStyleDef()->m_StyleType;
int iNumSidesUsing = 1;
switch( type )
{
case StyleDef::ONE_PLAYER_ONE_CREDIT:
case StyleDef::TWO_PLAYERS_TWO_CREDITS:
controller[0] = (GameController)MenuI.player;
iNumSidesUsing = 1;
break;
case StyleDef::ONE_PLAYER_TWO_CREDITS:
controller[0] = GAME_CONTROLLER_1;
controller[1] = GAME_CONTROLLER_2;
iNumSidesUsing = 2;
break;
default:
ASSERT(0); // invalid m_StyleType
};
GameButton button[2] = { m_DedicatedMenuButton[MenuI.button], m_SecondaryMenuButton[MenuI.button] };
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];
}
}
}
2004-05-31 22:42:12 +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.
*/