From 69473b0cf4e2194794cf6ccb418358a77f2d7551 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 6 Dec 2005 00:34:51 +0000 Subject: [PATCH] allow optionally specifying keys to map --- stepmania/Themes/default/metrics.ini | 1 + stepmania/src/ScreenMapControllers.cpp | 78 +++++++++++++++++--------- stepmania/src/ScreenMapControllers.h | 8 +-- 3 files changed, 53 insertions(+), 34 deletions(-) diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 8b661a9587..a6c19bff3b 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -2516,6 +2516,7 @@ TweenSeconds=0.3 Class=ScreenMapControllers Fallback=ScreenOptionsServiceChild NextScreen=ScreenOptionsService +ButtonsToMap= EvenLineIn=addx,-SCREEN_WIDTH;decelerate,0.5;addx,SCREEN_WIDTH; OddLineIn=addx,SCREEN_WIDTH;decelerate,0.5;addx,-SCREEN_WIDTH; EvenLineOut=stoptweening;accelerate,0.3;addx,-SCREEN_WIDTH; diff --git a/stepmania/src/ScreenMapControllers.cpp b/stepmania/src/ScreenMapControllers.cpp index fadc01555c..ae72c2e192 100644 --- a/stepmania/src/ScreenMapControllers.cpp +++ b/stepmania/src/ScreenMapControllers.cpp @@ -12,6 +12,8 @@ #include "Command.h" #include "InputEventPlus.h" +#define BUTTONS_TO_MAP THEME->GetMetric( m_sName, "ButtonsToMap" ) + static const ThemeMetric EVEN_LINE_IN ("ScreenMapControllers","EvenLineIn"); static const ThemeMetric EVEN_LINE_OUT ("ScreenMapControllers","EvenLineOut"); static const ThemeMetric ODD_LINE_IN ("ScreenMapControllers","OddLineIn"); @@ -30,7 +32,6 @@ static const float BUTTON_COLUMN_X[NUM_SHOWN_GAME_TO_DEVICE_SLOTS*MAX_GAME_CONTR 50, 125, 200, 440, 515, 590 }; - REGISTER_SCREEN_CLASS( ScreenMapControllers ); ScreenMapControllers::ScreenMapControllers( CString sClassName ) : ScreenWithMenuElements( sClassName ) { @@ -41,44 +42,64 @@ void ScreenMapControllers::Init() { ScreenWithMenuElements::Init(); - for( int b=0; bGetCurrentGame()->m_iButtonsPerController; b++ ) + CString sButtons = BUTTONS_TO_MAP; + if( sButtons.empty() ) { - KeyToMap k; - k.m_sName = GAMESTATE->GetCurrentGame()->m_szButtonNames[b]; - k.m_sSecondary = GAMEMAN->GetMenuButtonSecondaryFunction( GAMESTATE->GetCurrentGame(), b ); - k.m_GameButton = (GameButton) b; - m_KeysToMap.push_back( k ); + /* Map all buttons for this game. */ + for( int b=0; bGetCurrentGame()->m_iButtonsPerController; b++ ) + { + KeyToMap k; + k.m_GameButton = (GameButton) b; + m_KeysToMap.push_back( k ); + } + } + else + { + /* Map the specified buttons. */ + vector asBits; + split( sButtons, ",", asBits ); + for( unsigned i=0; iGetCurrentGame(), asBits[i] ); + m_KeysToMap.push_back( k ); + } } for( unsigned b=0; bGetPathF("Common","title") ); - m_textName[b].SetXY( SCREEN_CENTER_X, -6 ); - m_textName[b].SetText( pKey->m_sName ); - ON_COMMAND( m_textName[b] ); - m_Line[b].AddChild( &m_textName[b] ); + BitmapText *pName = new BitmapText; + pName->SetName( "Title" ); + pName->LoadFromFont( THEME->GetPathF("Common","title") ); + pName->SetXY( SCREEN_CENTER_X, -6 ); + pName->SetText( GAMESTATE->GetCurrentGame()->m_szButtonNames[pKey->m_GameButton] ); + ON_COMMAND( pName ); + m_Line[b].AddChild( pName ); - m_textName2[b].SetName( "Secondary" ); - m_textName2[b].LoadFromFont( THEME->GetPathF("Common","title") ); - m_textName2[b].SetXY( SCREEN_CENTER_X, +6 ); - m_textName2[b].SetText( pKey->m_sSecondary ); - ON_COMMAND( m_textName2[b] ); - m_Line[b].AddChild( &m_textName2[b] ); + BitmapText *pSecondary = new BitmapText; + pSecondary->SetName( "Secondary" ); + pSecondary->LoadFromFont( THEME->GetPathF("Common","title") ); + pSecondary->SetXY( SCREEN_CENTER_X, +6 ); + CString sText = GAMEMAN->GetMenuButtonSecondaryFunction( GAMESTATE->GetCurrentGame(), pKey->m_GameButton ); + pSecondary->SetText( sText ); + ON_COMMAND( pSecondary ); + m_Line[b].AddChild( pSecondary ); for( int p=0; pGetPathF("ScreenMapControllers","entry") ); - m_textMappedTo[b][p][s].SetXY( BUTTON_COLUMN_X[p*NUM_SHOWN_GAME_TO_DEVICE_SLOTS+s], 0 ); - ON_COMMAND( m_textMappedTo[b][p][s] ); - m_Line[b].AddChild( &m_textMappedTo[b][p][s] ); + pKey->m_textMappedTo[p][s] = new BitmapText; + pKey->m_textMappedTo[p][s]->SetName( "MappedTo" ); + pKey->m_textMappedTo[p][s]->LoadFromFont( THEME->GetPathF("ScreenMapControllers","entry") ); + pKey->m_textMappedTo[p][s]->SetXY( BUTTON_COLUMN_X[p*NUM_SHOWN_GAME_TO_DEVICE_SLOTS+s], 0 ); + ON_COMMAND( pKey->m_textMappedTo[p][s] ); + m_Line[b].AddChild( pKey->m_textMappedTo[p][s] ); } } + m_Line[b].DeleteChildrenWhenDone(); m_Line[b].SetY( LINE_START_Y + b*LINE_GAP_Y ); this->AddChild( &m_Line[b] ); @@ -305,16 +326,17 @@ void ScreenMapControllers::TweenOffScreen() void ScreenMapControllers::Refresh() { - for( int p=0; pm_textMappedTo[p][s]; + GameInput cur_gi( p, pKey->m_GameButton ); DeviceInput di; if( INPUTMAPPER->GameToDevice( cur_gi, s, di ) ) pText->SetText( di.toString() ); diff --git a/stepmania/src/ScreenMapControllers.h b/stepmania/src/ScreenMapControllers.h index fc1f164c1b..bac678f9f1 100644 --- a/stepmania/src/ScreenMapControllers.h +++ b/stepmania/src/ScreenMapControllers.h @@ -32,17 +32,13 @@ private: struct KeyToMap { - CString m_sName; - CString m_sSecondary; GameButton m_GameButton; + // owned by m_Line + BitmapText *m_textMappedTo[MAX_GAME_CONTROLLERS][NUM_SHOWN_GAME_TO_DEVICE_SLOTS]; }; vector m_KeysToMap; - BitmapText m_textName[MAX_GAME_BUTTONS]; - BitmapText m_textName2[MAX_GAME_BUTTONS]; - BitmapText m_textMappedTo[MAX_GAME_BUTTONS][MAX_GAME_CONTROLLERS][NUM_SHOWN_GAME_TO_DEVICE_SLOTS]; - ActorFrame m_Line[MAX_GAME_BUTTONS]; };