2002-04-16 17:31:00 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
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"
|
2002-07-31 19:40:40 +00:00
|
|
|
#include "GameState.h"
|
|
|
|
|
#include "InputMapper.h"
|
|
|
|
|
#include "PrefsManager.h"
|
2002-04-28 20:42:32 +00:00
|
|
|
|
2002-08-25 06:42:26 +00:00
|
|
|
|
2002-07-31 19:40:40 +00:00
|
|
|
|
2002-08-22 23:36:03 +00:00
|
|
|
MenuInput GameDef::GameInputToMenuInput( GameInput GameI ) const
|
2002-07-31 19:40:40 +00:00
|
|
|
{
|
|
|
|
|
PlayerNumber pn;
|
|
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
StyleDef::StyleType type = StyleDef::TWO_PLAYERS_TWO_CREDITS;
|
2002-07-31 19:40:40 +00:00
|
|
|
if( GAMESTATE->m_CurStyle != STYLE_NONE )
|
|
|
|
|
type = GAMESTATE->GetCurrentStyleDef()->m_StyleType;
|
|
|
|
|
switch( type )
|
|
|
|
|
{
|
2002-08-13 23:26:46 +00:00
|
|
|
case StyleDef::ONE_PLAYER_ONE_CREDIT:
|
|
|
|
|
case StyleDef::TWO_PLAYERS_TWO_CREDITS:
|
2002-07-31 19:40:40 +00:00
|
|
|
pn = (PlayerNumber)GameI.controller;
|
|
|
|
|
break;
|
2002-08-13 23:26:46 +00:00
|
|
|
case StyleDef::ONE_PLAYER_TWO_CREDITS:
|
2002-08-20 21:00:56 +00:00
|
|
|
pn = GAMESTATE->m_MasterPlayerNumber;
|
2002-07-31 19:40:40 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
2002-09-07 10:43:16 +00:00
|
|
|
ASSERT(0); return MenuInput(); // invalid m_StyleType
|
2002-07-31 19:40:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for( int 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 );
|
|
|
|
|
}
|
2002-07-31 19:40:40 +00:00
|
|
|
|
|
|
|
|
return MenuInput(); // invalid GameInput
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-22 23:36:03 +00:00
|
|
|
void GameDef::MenuInputToGameInput( MenuInput MenuI, GameInput GameIout[4] ) const
|
2002-07-31 19:40:40 +00:00
|
|
|
{
|
|
|
|
|
ASSERT( MenuI.IsValid() );
|
|
|
|
|
|
|
|
|
|
GameIout[0].MakeInvalid(); // initialize
|
|
|
|
|
GameIout[1].MakeInvalid();
|
|
|
|
|
GameIout[2].MakeInvalid();
|
|
|
|
|
GameIout[3].MakeInvalid();
|
|
|
|
|
|
|
|
|
|
GameController controller[2];
|
|
|
|
|
int iNumSidesUsing = 1;
|
|
|
|
|
switch( GAMESTATE->GetCurrentStyleDef()->m_StyleType )
|
|
|
|
|
{
|
2002-08-13 23:26:46 +00:00
|
|
|
case StyleDef::ONE_PLAYER_ONE_CREDIT:
|
|
|
|
|
case StyleDef::TWO_PLAYERS_TWO_CREDITS:
|
2002-07-31 19:40:40 +00:00
|
|
|
controller[0] = (GameController)MenuI.player;
|
|
|
|
|
iNumSidesUsing = 1;
|
|
|
|
|
break;
|
2002-08-13 23:26:46 +00:00
|
|
|
case StyleDef::ONE_PLAYER_TWO_CREDITS:
|
2002-07-31 19:40:40 +00:00
|
|
|
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++ )
|
2002-08-01 20:30:40 +00:00
|
|
|
{
|
|
|
|
|
GameIout[i*2+j].controller = controller[i];
|
|
|
|
|
GameIout[i*2+j].button = button[j];
|
|
|
|
|
}
|
2002-07-31 19:40:40 +00:00
|
|
|
}
|
|
|
|
|
}
|