Files
itgmania212121/stepmania/src/GameDef.cpp
T

110 lines
2.8 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
/*
-----------------------------------------------------------------------------
Class: GameDef
Desc: See header.
2002-05-19 01:59:48 +00:00
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
2002-04-16 17:31:00 +00:00
Chris Danford
-----------------------------------------------------------------------------
*/
#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
2002-12-17 21:14:45 +00:00
GameButton GameDef::ButtonNameToIndex( const CString &sButtonName )
{
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];
}
}
}