Don't duplicate the data for common GameButtons.

InputScheme separates the generic, low-level engine data
from the Game*-specific high-level data.  GameButtonType
is a high-level distinction; in fact, it's only needed
for custom GameButtons (eg. DANCE_BUTTON_*), since the
function of generic GameButtons (GAME_BUTTON_*) can simply
be identified by their value--that's why, for example, we
don't have GameButtonType for GAME_BUTTON_COIN.
This commit is contained in:
Glenn Maynard
2007-01-12 22:57:55 +00:00
parent 4d761d588e
commit 369a060afa
7 changed files with 218 additions and 165 deletions
+22
View File
@@ -15,6 +15,28 @@ TapNoteScore Game::MapTapNoteScore( TapNoteScore tns ) const
}
}
static const Game::PerButtonInfo g_CommonButtonInfo[] =
{
{ GameButtonType_INVALID }, // GAME_BUTTON_MENULEFT
{ GameButtonType_INVALID }, // GAME_BUTTON_MENURIGHT
{ GameButtonType_INVALID }, // GAME_BUTTON_MENUUP
{ GameButtonType_INVALID }, // GAME_BUTTON_MENUDOWN
{ GameButtonType_INVALID }, // GAME_BUTTON_START
{ GameButtonType_INVALID }, // GAME_BUTTON_SELECT
{ GameButtonType_INVALID }, // GAME_BUTTON_BACK
{ GameButtonType_INVALID }, // GAME_BUTTON_COIN
{ GameButtonType_INVALID }, // GAME_BUTTON_OPERATOR
};
const Game::PerButtonInfo *Game::GetPerButtonInfo( GameButton gb ) const
{
COMPILE_ASSERT( GAME_BUTTON_NEXT == ARRAYLEN(g_CommonButtonInfo) );
if( gb < GAME_BUTTON_NEXT )
return &g_CommonButtonInfo[gb];
else
return &m_PerButtonInfo[gb-GAME_BUTTON_NEXT];
}
// lua start
#include "LuaBinding.h"
+8
View File
@@ -36,6 +36,14 @@ public:
bool m_bAllowHopos; // allow Hammer-ons and Pull-offs? Only useful for guitar type input.
InputScheme m_InputScheme;
struct PerButtonInfo
{
GameButtonType m_gbt;
};
/* Data for each Game-specific GameButton. This starts at GAME_BUTTON_NEXT. */
PerButtonInfo m_PerButtonInfo[NUM_GameButton];
const PerButtonInfo *GetPerButtonInfo( GameButton gb ) const;
TapNoteScore MapTapNoteScore( TapNoteScore tns ) const;
TapNoteScore m_mapW1To;
TapNoteScore m_mapW2To;
+1 -1
View File
@@ -16,7 +16,7 @@ StringToX( GameController );
RString GameButtonToString( const InputScheme* pInputs, GameButton i )
{
return pInputs->m_GameButtonInfo[i].m_szName;
return pInputs->GetGameButtonName(i);
}
RString GameButtonToLocalizedString( const InputScheme* pInputs, GameButton i )
+160 -160
View File
@@ -127,21 +127,12 @@ static const Game g_Game_Dance =
"dance", // m_szName
NUM_DANCE_BUTTONS, // m_iButtonsPerController
{ // m_szButtonNames
{ "MenuLeft", GameButtonType_INVALID },
{ "MenuRight", GameButtonType_INVALID },
{ "MenuUp", GameButtonType_INVALID },
{ "MenuDown", GameButtonType_INVALID },
{ "Start", GameButtonType_INVALID },
{ "Select", GameButtonType_INVALID },
{ "Back", GameButtonType_INVALID },
{ "Coin", GameButtonType_INVALID },
{ "Operator", GameButtonType_INVALID },
{ "Left", GameButtonType_Step },
{ "Right", GameButtonType_Step },
{ "Up", GameButtonType_Step },
{ "Down", GameButtonType_Step },
{ "UpLeft", GameButtonType_Step },
{ "UpRight", GameButtonType_Step },
"Left",
"Right",
"Up",
"Down",
"UpLeft",
"UpRight",
},
{ // m_SecondaryMenuButton
DANCE_BUTTON_LEFT, // MENU_BUTTON_LEFT
@@ -156,6 +147,14 @@ static const Game g_Game_Dance =
},
g_AutoKeyMappings_Dance
},
{
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
},
TNS_W1, // m_mapW1To
TNS_W2, // m_mapW2To
TNS_W3, // m_mapW3To
@@ -194,20 +193,11 @@ static const Game g_Game_Pump =
"pump", // m_szName
NUM_PUMP_BUTTONS, // m_iButtonsPerController
{ // m_szButtonNames
{ "MenuLeft", GameButtonType_INVALID},
{ "MenuRight", GameButtonType_INVALID },
{ "MenuUp", GameButtonType_INVALID },
{ "MenuDown", GameButtonType_INVALID },
{ "Start", GameButtonType_INVALID },
{ "Select", GameButtonType_INVALID },
{ "Back", GameButtonType_INVALID },
{ "Coin", GameButtonType_INVALID },
{ "Operator", GameButtonType_INVALID },
{ "UpLeft", GameButtonType_Step },
{ "UpRight", GameButtonType_Step },
{ "Center", GameButtonType_Step },
{ "DownLeft", GameButtonType_Step },
{ "DownRight", GameButtonType_Step },
"UpLeft",
"UpRight",
"Center",
"DownLeft",
"DownRight",
},
{ // m_SecondaryMenuButton
PUMP_BUTTON_DOWNLEFT, // MENU_BUTTON_LEFT
@@ -222,6 +212,13 @@ static const Game g_Game_Pump =
},
g_AutoKeyMappings_Pump
},
{
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
},
TNS_W1, // m_mapW1To
TNS_W2, // m_mapW2To
TNS_W3, // m_mapW3To
@@ -250,22 +247,13 @@ static const Game g_Game_Ez2 =
"ez2", // m_szName
NUM_EZ2_BUTTONS, // m_iButtonsPerController
{ // m_szButtonNames
{ "MenuLeft", GameButtonType_INVALID },
{ "MenuRight", GameButtonType_INVALID },
{ "MenuUp", GameButtonType_INVALID },
{ "MenuDown", GameButtonType_INVALID },
{ "Start", GameButtonType_INVALID },
{ "Select", GameButtonType_INVALID },
{ "Back", GameButtonType_INVALID },
{ "Coin", GameButtonType_INVALID },
{ "Operator", GameButtonType_INVALID },
{ "FootUpLeft", GameButtonType_Step },
{ "FootUpRight", GameButtonType_Step },
{ "FootDown", GameButtonType_Step },
{ "HandUpLeft", GameButtonType_Step },
{ "HandUpRight", GameButtonType_Step },
{ "HandLrLeft", GameButtonType_Step },
{ "HandLrRight", GameButtonType_Step },
"FootUpLeft",
"FootUpRight",
"FootDown",
"HandUpLeft",
"HandUpRight",
"HandLrLeft",
"HandLrRight",
},
{ // m_SecondaryMenuButton
EZ2_BUTTON_HANDUPLEFT, // MENU_BUTTON_LEFT
@@ -280,6 +268,15 @@ static const Game g_Game_Ez2 =
},
g_AutoKeyMappings_Ez2
},
{
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
},
TNS_W2, // m_mapW1To
TNS_W2, // m_mapW2To
TNS_W2, // m_mapW3To
@@ -306,20 +303,11 @@ static const Game g_Game_Para =
"para", // m_szName
NUM_PARA_BUTTONS, // m_iButtonsPerController
{ // m_szButtonNames
{ "MenuLeft", GameButtonType_INVALID },
{ "MenuRight", GameButtonType_INVALID },
{ "MenuUp", GameButtonType_INVALID },
{ "MenuDown", GameButtonType_INVALID },
{ "Start", GameButtonType_INVALID },
{ "Select", GameButtonType_INVALID },
{ "Back", GameButtonType_INVALID },
{ "Coin", GameButtonType_INVALID },
{ "Operator", GameButtonType_INVALID },
{ "Left", GameButtonType_Step },
{ "UpLeft", GameButtonType_Step },
{ "Up", GameButtonType_Step },
{ "UpRight", GameButtonType_Step },
{ "Right", GameButtonType_Step },
"Left",
"UpLeft",
"Up",
"UpRight",
"Right",
},
{ // m_SecondaryMenuButton
PARA_BUTTON_LEFT, // MENU_BUTTON_LEFT
@@ -334,6 +322,13 @@ static const Game g_Game_Para =
},
g_AutoKeyMappings_Para
},
{
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
},
TNS_W1, // m_mapW1To
TNS_W2, // m_mapW2To
TNS_W3, // m_mapW3To
@@ -363,23 +358,14 @@ static const Game g_Game_DS3DDX =
"ds3ddx", // m_szName
NUM_DS3DDX_BUTTONS, // m_iButtonsPerController
{ // m_szButtonNames
{ "MenuLeft", GameButtonType_INVALID },
{ "MenuRight", GameButtonType_INVALID },
{ "MenuUp", GameButtonType_INVALID },
{ "MenuDown", GameButtonType_INVALID },
{ "Start", GameButtonType_INVALID },
{ "Select", GameButtonType_INVALID },
{ "Back", GameButtonType_INVALID },
{ "Coin", GameButtonType_INVALID },
{ "Operator", GameButtonType_INVALID },
{ "HandLeft", GameButtonType_Step },
{ "FootDownLeft", GameButtonType_Step },
{ "FootUpLeft", GameButtonType_Step },
{ "HandUp", GameButtonType_Step },
{ "HandDown", GameButtonType_Step },
{ "FootUpRight", GameButtonType_Step },
{ "FootDownRight", GameButtonType_Step },
{ "HandRight", GameButtonType_Step },
"HandLeft",
"FootDownLeft",
"FootUpLeft",
"HandUp",
"HandDown",
"FootUpRight",
"FootDownRight",
"HandRight",
},
{ // m_SecondaryMenuButton
DS3DDX_BUTTON_HANDLEFT, // MENU_BUTTON_LEFT
@@ -394,6 +380,16 @@ static const Game g_Game_DS3DDX =
},
g_AutoKeyMappings_DS3DDX
},
{
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
},
TNS_W1, // m_mapW1To
TNS_W2, // m_mapW2To
TNS_W3, // m_mapW3To
@@ -423,24 +419,15 @@ static const Game g_Game_Beat =
"beat", // m_szName
NUM_BEAT_BUTTONS, // m_iButtonsPerController
{ // m_szButtonNames
{ "MenuLeft", GameButtonType_INVALID },
{ "MenuRight", GameButtonType_INVALID },
{ "MenuUp", GameButtonType_INVALID },
{ "MenuDown", GameButtonType_INVALID },
{ "Start", GameButtonType_INVALID },
{ "Select", GameButtonType_INVALID },
{ "Back", GameButtonType_INVALID },
{ "Coin", GameButtonType_INVALID },
{ "Operator", GameButtonType_INVALID },
{ "Key1", GameButtonType_Step },
{ "Key2", GameButtonType_Step },
{ "Key3", GameButtonType_Step },
{ "Key4", GameButtonType_Step },
{ "Key5", GameButtonType_Step },
{ "Key6", GameButtonType_Step },
{ "Key7", GameButtonType_Step },
{ "Scratch up", GameButtonType_Step },
{ "Scratch down", GameButtonType_Step },
"Key1",
"Key2",
"Key3",
"Key4",
"Key5",
"Key6",
"Key7",
"Scratch up",
"Scratch down",
},
{ // m_SecondaryMenuButton
BEAT_BUTTON_KEY1, // MENU_BUTTON_LEFT
@@ -455,6 +442,17 @@ static const Game g_Game_Beat =
},
g_AutoKeyMappings_Beat
},
{
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
},
TNS_W1, // m_mapW1To
TNS_W2, // m_mapW2To
TNS_W3, // m_mapW3To
@@ -484,19 +482,10 @@ static const Game g_Game_Maniax =
"maniax", // m_szName
NUM_MANIAX_BUTTONS, // m_iButtonsPerController
{ // m_szButtonNames
{ "MenuLeft", GameButtonType_INVALID },
{ "MenuRight", GameButtonType_INVALID },
{ "MenuUp", GameButtonType_INVALID },
{ "MenuDown", GameButtonType_INVALID },
{ "Start", GameButtonType_INVALID },
{ "Select", GameButtonType_INVALID },
{ "Back", GameButtonType_INVALID },
{ "Coin", GameButtonType_INVALID },
{ "Operator", GameButtonType_INVALID },
{ "HandUpLeft", GameButtonType_Step },
{ "HandUpRight", GameButtonType_Step },
{ "HandLrLeft", GameButtonType_Step },
{ "HandLrRight", GameButtonType_Step },
"HandUpLeft",
"HandUpRight",
"HandLrLeft",
"HandLrRight",
},
{ // m_SecondaryMenuButton
MANIAX_BUTTON_HANDUPLEFT, // MENU_BUTTON_LEFT
@@ -511,6 +500,12 @@ static const Game g_Game_Maniax =
},
g_AutoKeyMappings_Maniax
},
{
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
},
TNS_W1, // m_mapW1To
TNS_W2, // m_mapW2To
TNS_W3, // m_mapW3To
@@ -550,24 +545,15 @@ static const Game g_Game_Techno =
"techno", // m_szName
NUM_TECHNO_BUTTONS, // m_iButtonsPerController
{ // m_szButtonNames
{ "MenuLeft", GameButtonType_INVALID },
{ "MenuRight", GameButtonType_INVALID },
{ "MenuUp", GameButtonType_INVALID },
{ "MenuDown", GameButtonType_INVALID },
{ "Start", GameButtonType_INVALID },
{ "Select", GameButtonType_INVALID },
{ "Back", GameButtonType_INVALID },
{ "Coin", GameButtonType_INVALID },
{ "Operator", GameButtonType_INVALID },
{ "Left", GameButtonType_Step },
{ "Right", GameButtonType_Step },
{ "Up", GameButtonType_Step },
{ "Down", GameButtonType_Step },
{ "UpLeft", GameButtonType_Step },
{ "UpRight", GameButtonType_Step },
{ "Center", GameButtonType_Step },
{ "DownLeft", GameButtonType_Step },
{ "DownRight", GameButtonType_Step },
"Left",
"Right",
"Up",
"Down",
"UpLeft",
"UpRight",
"Center",
"DownLeft",
"DownRight",
},
{ // m_SecondaryMenuButton
TECHNO_BUTTON_LEFT, // MENU_BUTTON_LEFT
@@ -582,6 +568,17 @@ static const Game g_Game_Techno =
},
g_AutoKeyMappings_Techno
},
{
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
},
TNS_W1, // m_mapW1To
TNS_W2, // m_mapW2To
TNS_W3, // m_mapW3To
@@ -612,24 +609,15 @@ static const Game g_Game_Popn =
"popn", // m_szName
NUM_POPN_BUTTONS, // m_iButtonsPerController
{ // m_szButtonNames
{ "MenuLeft", GameButtonType_Step },
{ "MenuRight", GameButtonType_Step },
{ "MenuUp", GameButtonType_Step },
{ "MenuDown", GameButtonType_Step },
{ "Start", GameButtonType_Step },
{ "Back", GameButtonType_Step },
{ "Select", GameButtonType_Step },
{ "Coin", GameButtonType_Step },
{ "Operator", GameButtonType_Step },
{ "Left White", GameButtonType_Step },
{ "Left Yellow", GameButtonType_Step },
{ "Left Green", GameButtonType_Step },
{ "Left Blue", GameButtonType_Step },
{ "Red", GameButtonType_Step },
{ "Right Blue", GameButtonType_Step },
{ "Right Green", GameButtonType_Step },
{ "Right Yellow", GameButtonType_Step },
{ "Right White", GameButtonType_Step },
"Left White",
"Left Yellow",
"Left Green",
"Left Blue",
"Red",
"Right Blue",
"Right Green",
"Right Yellow",
"Right White",
},
{ // m_SecondaryMenuButton
POPN_BUTTON_LEFT_BLUE, // MENU_BUTTON_LEFT
@@ -644,6 +632,17 @@ static const Game g_Game_Popn =
},
g_AutoKeyMappings_Popn
},
{
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
},
TNS_W2, // m_mapW1To
TNS_W2, // m_mapW2To
TNS_W3, // m_mapW3To
@@ -673,23 +672,14 @@ static const Game g_Game_Lights =
"lights", // m_szName
NUM_LIGHTS_BUTTONS, // m_iButtonsPerController
{ // m_szButtonNames
{ "MenuLeft", GameButtonType_INVALID },
{ "MenuRight", GameButtonType_INVALID },
{ "MenuUp", GameButtonType_INVALID },
{ "MenuDown", GameButtonType_INVALID },
{ "Start", GameButtonType_INVALID },
{ "Select", GameButtonType_INVALID },
{ "Back", GameButtonType_INVALID },
{ "Coin", GameButtonType_INVALID },
{ "Operator", GameButtonType_INVALID },
{ "MarqueeUpLeft", GameButtonType_Step },
{ "MarqueeUpRight", GameButtonType_Step },
{ "MarqueeLrLeft", GameButtonType_Step },
{ "MarqueeLrRight", GameButtonType_Step },
{ "ButtonsLeft", GameButtonType_Step },
{ "ButtonsRight", GameButtonType_Step },
{ "BassLeft", GameButtonType_Step },
{ "BassRight", GameButtonType_Step },
"MarqueeUpLeft",
"MarqueeUpRight",
"MarqueeLrLeft",
"MarqueeLrRight",
"ButtonsLeft",
"ButtonsRight",
"BassLeft",
"BassRight",
},
{ // m_SecondaryMenuButton
LIGHTS_BUTTON_MARQUEE_UP_LEFT, // MENU_BUTTON_LEFT
@@ -704,6 +694,16 @@ static const Game g_Game_Lights =
},
g_AutoKeyMappings_Lights
},
{
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
{ GameButtonType_Step },
},
TNS_W1, // m_mapW1To
TNS_W2, // m_mapW2To
TNS_W3, // m_mapW3To
+23 -1
View File
@@ -964,7 +964,7 @@ MultiPlayer InputMapper::InputDeviceToMultiPlayer( InputDevice id )
GameButton InputScheme::ButtonNameToIndex( const RString &sButtonName ) const
{
for( int i=0; i<m_iButtonsPerController; i++ )
if( stricmp(m_GameButtonInfo[i].m_szName, sButtonName) == 0 )
if( stricmp(GetGameButtonName(i), sButtonName) == 0 )
return i;
return GameButton_Invalid;
@@ -1032,6 +1032,28 @@ MenuButton InputScheme::GetMenuButtonSecondaryFunction( GameButton gb ) const
return MenuButton_Invalid;
}
static const char *g_szCommonGameButtonNames[] =
{
"MenuLeft",
"MenuRight",
"MenuUp",
"MenuDown",
"Start",
"Select",
"Back",
"Coin",
"Operator",
};
const char *InputScheme::GetGameButtonName( GameButton gb ) const
{
COMPILE_ASSERT( GAME_BUTTON_NEXT == ARRAYLEN(g_szCommonGameButtonNames) );
if( gb < GAME_BUTTON_NEXT )
return g_szCommonGameButtonNames[gb];
else
return m_szGameButtonNames[gb-GAME_BUTTON_NEXT];
}
/*
* (c) 2001-2003 Chris Danford
* All rights reserved.
+3 -2
View File
@@ -41,9 +41,9 @@ public:
struct GameButtonInfo
{
char m_szName[60]; // The name used by the button graphics system. e.g. "left", "right", "middle C", "snare"
GameButtonType m_gbt;
};
GameButtonInfo m_GameButtonInfo[NUM_GameButton];
/* Data for each Game-specific GameButton. This starts at GAME_BUTTON_NEXT. */
const char *m_szGameButtonNames[NUM_GameButton];
GameButton m_SecondaryMenuButton[NUM_MenuButton];
const InputMapping *m_Maps;
@@ -51,6 +51,7 @@ public:
MenuButton GameInputToMenuButton( GameInput GameI ) const;
void MenuButtonToGameInputs( MenuButton MenuI, PlayerNumber pn, GameInput GameIout[4] ) const;
MenuButton GetMenuButtonSecondaryFunction( GameButton gb ) const;
const char *GetGameButtonName( GameButton gb ) const;
};
#define FOREACH_GameButtonInScheme( s, var ) for( GameButton var=(GameButton)0; var<s->m_iButtonsPerController; enum_add<GameButton>( var, +1 ) )
+1 -1
View File
@@ -92,7 +92,7 @@ RString Style::ColToButtonName( int iCol ) const
return pzColumnName;
GameInput GI = StyleInputToGameInput( iCol, PLAYER_1 );
return INPUTMAPPER->GetInputScheme()->m_GameButtonInfo[GI.button].m_szName;
return INPUTMAPPER->GetInputScheme()->GetGameButtonName(GI.button);
}
// Lua bindings