reduce StyleInput to an int

This commit is contained in:
Glenn Maynard
2006-09-13 00:46:21 +00:00
parent 6a80311172
commit 1ca5c9a4b7
6 changed files with 26 additions and 38 deletions
+1 -1
View File
@@ -2864,7 +2864,7 @@ MenuButton GameManager::GetMenuButtonSecondaryFunction( const Game *pGame, GameB
FOREACH_GameController(gc)
{
const StyleInput si = pStyle->GameInputToStyleInput( GameInput(gc,gb) );
if( si.IsValid() )
if( si != StyleInput_INVALID )
bUsedInGameplay = true;
}
}
+6 -6
View File
@@ -1921,7 +1921,7 @@ void ScreenEdit::InputRecord( const InputEventPlus &input, EditButton EditB )
if( input.MenuI.player != PLAYER_1 )
return; // ignore
const int iCol = input.StyleI.col;
const int iCol = input.StyleI;
switch( input.type )
{
@@ -2077,17 +2077,17 @@ void ScreenEdit::InputPlay( const InputEventPlus &input, EditButton EditB )
return;
}
if( PREFSMAN->m_AutoPlay != PC_HUMAN )
if( PREFSMAN->m_AutoPlay != PC_HUMAN || input.StyleI == -1 )
return;
switch( input.MenuI.player )
{
case PLAYER_1:
m_Player->Step( input.StyleI.col, -1, input.DeviceI.ts, false, input.type == IET_RELEASE );
m_Player->Step( input.StyleI, -1, input.DeviceI.ts, false, input.type == IET_RELEASE );
break;
case PLAYER_2:
if( GAMESTATE->GetCurrentStyle()->m_StyleType == TWO_PLAYERS_SHARED_SIDES )
m_Player->Step( input.StyleI.col, -1, input.DeviceI.ts, false, input.type == IET_RELEASE );
m_Player->Step( input.StyleI, -1, input.DeviceI.ts, false, input.type == IET_RELEASE );
}
}
@@ -3647,9 +3647,9 @@ static RString GetDeviceButtonsLocalized( const vector<EditButton> &veb, const M
DeviceInput diPress = editmap.button[*eb][s];
DeviceInput diHold = editmap.hold[*eb][s];
if( diPress.IsValid() )
vsPress.push_back( INPUTMAN->GetLocalizedInputString(diPress) );
vsPress.push_back( Capitalize(INPUTMAN->GetLocalizedInputString(diPress)) );
if( diHold.IsValid() )
vsHold.push_back( INPUTMAN->GetLocalizedInputString(diHold) );
vsHold.push_back( Capitalize(INPUTMAN->GetLocalizedInputString(diHold)) );
}
}
+6 -6
View File
@@ -2086,8 +2086,8 @@ void ScreenGameplay::Input( const InputEventPlus &input )
* However, if this is also a style button, don't do this. (pump center = start)
*/
bool bHoldingGiveUp = false;
bHoldingGiveUp |= ( START_GIVES_UP && input.MenuI.button == MENU_BUTTON_START && !input.StyleI.IsValid() );
bHoldingGiveUp |= ( BACK_GIVES_UP && input.MenuI.button == MENU_BUTTON_BACK && !input.StyleI.IsValid() );
bHoldingGiveUp |= ( START_GIVES_UP && input.MenuI.button == MENU_BUTTON_START && input.StyleI == StyleInput_INVALID );
bHoldingGiveUp |= ( BACK_GIVES_UP && input.MenuI.button == MENU_BUTTON_BACK && input.StyleI == StyleInput_INVALID );
if( bHoldingGiveUp )
{
@@ -2147,10 +2147,10 @@ void ScreenGameplay::Input( const InputEventPlus &input )
{
if( input.mp != MultiPlayer_INVALID &&
input.type==IET_FIRST_PRESS &&
input.StyleI.IsValid() &&
input.StyleI != StyleInput_INVALID &&
GAMESTATE->IsMultiPlayerEnabled(input.mp) )
{
m_vPlayerInfo[input.mp].m_pPlayer->Step( input.StyleI.col, -1, input.DeviceI.ts, false, bRelease );
m_vPlayerInfo[input.mp].m_pPlayer->Step( input.StyleI, -1, input.DeviceI.ts, false, bRelease );
}
}
else
@@ -2159,7 +2159,7 @@ void ScreenGameplay::Input( const InputEventPlus &input )
// handle a step or battle item activate
//
if( input.type==IET_FIRST_PRESS &&
input.StyleI.IsValid() &&
input.StyleI != StyleInput_INVALID &&
GAMESTATE->IsHumanPlayer( input.MenuI.player ) )
{
AbortGiveUp( true );
@@ -2167,7 +2167,7 @@ void ScreenGameplay::Input( const InputEventPlus &input )
if( PREFSMAN->m_AutoPlay == PC_HUMAN )
{
PlayerInfo& pi = GetPlayerInfoForInput( input );
pi.m_pPlayer->Step( input.StyleI.col, -1, input.DeviceI.ts, false, bRelease );
pi.m_pPlayer->Step( input.StyleI, -1, input.DeviceI.ts, false, bRelease );
}
}
}
+4 -4
View File
@@ -345,15 +345,15 @@ void ScreenNameEntry::Input( const InputEventPlus &input )
if( input.type != IET_FIRST_PRESS )
return; // ignore
if( input.StyleI.IsValid() && m_bStillEnteringName[input.MenuI.player])
if( input.StyleI != StyleInput_INVALID && m_bStillEnteringName[input.MenuI.player])
{
int iStringIndex = m_ColToStringIndex[input.MenuI.player][input.StyleI.col];
int iStringIndex = m_ColToStringIndex[input.MenuI.player][input.StyleI];
if( iStringIndex != -1 )
{
m_ReceptorArrowRow[input.MenuI.player].Step( input.StyleI.col, TNS_W1 );
m_ReceptorArrowRow[input.MenuI.player].Step( input.StyleI, TNS_W1 );
m_soundStep.Play();
char c = NAME_CHARS[GetClosestCharIndex(m_fFakeBeat)];
m_textSelectedChars[input.MenuI.player][input.StyleI.col].SetText( ssprintf("%c",c) );
m_textSelectedChars[input.MenuI.player][input.StyleI].SetText( ssprintf("%c",c) );
m_sSelectedName[input.MenuI.player][iStringIndex] = c;
}
}
+7 -10
View File
@@ -40,8 +40,8 @@ void Style::GetTransformedNoteDataForStyle( PlayerNumber pn, const NoteData& ori
GameInput Style::StyleInputToGameInput( const StyleInput& StyleI, PlayerNumber pn ) const
{
ASSERT_M( pn < NUM_PLAYERS && StyleI.col < MAX_COLS_PER_PLAYER,
ssprintf("P%i C%i", pn, StyleI.col) );
ASSERT_M( pn < NUM_PLAYERS && StyleI < MAX_COLS_PER_PLAYER,
ssprintf("P%i C%i", pn, StyleI) );
bool bUsingOneSide = m_StyleType != ONE_PLAYER_TWO_SIDES && m_StyleType != TWO_PLAYERS_SHARED_SIDES;
FOREACH_GameController(gc)
@@ -50,26 +50,23 @@ GameInput Style::StyleInputToGameInput( const StyleInput& StyleI, PlayerNumber p
continue;
for( int i = 0; i < m_pGame->m_iButtonsPerController && m_iInputColumn[gc][i] != END_MAPPING; ++i )
if( m_iInputColumn[gc][i] == StyleI.col )
if( m_iInputColumn[gc][i] == StyleI )
return GameInput( gc, i );
}
FAIL_M( ssprintf("Unknown StyleInput %i,%i", pn, StyleI.col) );
FAIL_M( ssprintf("Unknown StyleInput %i,%i", pn, StyleI) );
};
StyleInput Style::GameInputToStyleInput( const GameInput &GameI ) const
{
StyleInput SI;
if( m_iInputColumn[GameI.controller][GameI.button] == NO_MAPPING )
return SI; // Return invalid.
return StyleInput_INVALID;
for( int i = 0; i <= GameI.button; ++i )
if( m_iInputColumn[GameI.controller][i] == END_MAPPING )
return SI; // Return invalid.
SI = StyleInput( m_iInputColumn[GameI.controller][GameI.button] );
return StyleInput_INVALID;
StyleInput SI = (StyleInput) m_iInputColumn[GameI.controller][GameI.button];
return SI;
}
+2 -11
View File
@@ -3,17 +3,8 @@
#ifndef STYLE_INPUT_H
#define STYLE_INPUT_H
struct StyleInput
{
int col;
StyleInput() { MakeInvalid(); };
StyleInput( int c ) { col = c; }
bool operator==( const StyleInput &other ) { return col == other.col; }
bool IsValid() const { return col != -1; }
void MakeInvalid() { col = -1; }
};
typedef int StyleInput;
static const int StyleInput_INVALID = -1;
#endif