From 1ca5c9a4b7b57982b6255896385a8b45d3451b51 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 13 Sep 2006 00:46:21 +0000 Subject: [PATCH] reduce StyleInput to an int --- stepmania/src/GameManager.cpp | 2 +- stepmania/src/ScreenEdit.cpp | 12 ++++++------ stepmania/src/ScreenGameplay.cpp | 12 ++++++------ stepmania/src/ScreenNameEntry.cpp | 8 ++++---- stepmania/src/Style.cpp | 17 +++++++---------- stepmania/src/StyleInput.h | 13 ++----------- 6 files changed, 26 insertions(+), 38 deletions(-) diff --git a/stepmania/src/GameManager.cpp b/stepmania/src/GameManager.cpp index 2dde92a578..fa490f9c3c 100644 --- a/stepmania/src/GameManager.cpp +++ b/stepmania/src/GameManager.cpp @@ -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; } } diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 69e4f58eb8..45169ade5e 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -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 &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)) ); } } diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 6a866a6451..0ca2638d5f 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -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 ); } } } diff --git a/stepmania/src/ScreenNameEntry.cpp b/stepmania/src/ScreenNameEntry.cpp index 45894bdc70..c5b5e60065 100644 --- a/stepmania/src/ScreenNameEntry.cpp +++ b/stepmania/src/ScreenNameEntry.cpp @@ -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; } } diff --git a/stepmania/src/Style.cpp b/stepmania/src/Style.cpp index 6fa1d8138d..b0d083be42 100644 --- a/stepmania/src/Style.cpp +++ b/stepmania/src/Style.cpp @@ -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; } diff --git a/stepmania/src/StyleInput.h b/stepmania/src/StyleInput.h index 2ca632258e..d0504fcd0b 100644 --- a/stepmania/src/StyleInput.h +++ b/stepmania/src/StyleInput.h @@ -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