figure out secondary button names dynamically
This commit is contained in:
@@ -2862,6 +2862,66 @@ const Style* GameManager::GameAndStringToStyle( const Game *game, CString sStyle
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
CString GameManager::GetSecondaryMenuButtonName( const Game *pGame, GameButton gb ) const
|
||||
{
|
||||
/*
|
||||
* Each GameButton can be used in gameplay (if any gameplay style maps to
|
||||
* it) and/or map to a menu button (if m_DedicatedMenuButton or m_SecondaryMenuButton
|
||||
* map to it).
|
||||
*
|
||||
* If a button is only used in gameplay, return ""; the primary description is
|
||||
* sufficient.
|
||||
*
|
||||
* If a button is only used in menus, return "(dedicated)" if any other button
|
||||
* maps to the same MenuButton; otherwise return "".
|
||||
*
|
||||
* If a button is used in both gameplay and menus, return szSecondaryNames[] for
|
||||
* the MenuButton.
|
||||
*/
|
||||
vector<const Style*> aStyles;
|
||||
this->GetStylesForGame( pGame, aStyles );
|
||||
bool bUsedInGameplay = false;
|
||||
for( unsigned i = 0; i < aStyles.size(); ++i )
|
||||
{
|
||||
const Style *pStyle = aStyles[i];
|
||||
FOREACH_GameController(gc)
|
||||
{
|
||||
const StyleInput si = pStyle->GameInputToStyleInput( GameInput(gc,gb) );
|
||||
if( si.IsValid() )
|
||||
bUsedInGameplay = true;
|
||||
}
|
||||
}
|
||||
|
||||
static const char *szSecondaryNames[NUM_MENU_BUTTONS] =
|
||||
{
|
||||
"(MenuLeft)",
|
||||
"(MenuRight)",
|
||||
"(MenuUp)",
|
||||
"(MenuDown)",
|
||||
"(MenuStart)",
|
||||
"(MenuBack)",
|
||||
"(Coin)",
|
||||
"(Operator)"
|
||||
};
|
||||
|
||||
FOREACH_MenuButton(m)
|
||||
{
|
||||
if( !bUsedInGameplay && pGame->m_DedicatedMenuButton[m] == gb )
|
||||
{
|
||||
if( pGame->m_SecondaryMenuButton[m] == pGame->m_DedicatedMenuButton[m] ||
|
||||
pGame->m_SecondaryMenuButton[m] == GAME_BUTTON_INVALID )
|
||||
return "";
|
||||
else
|
||||
return "(dedicated)";
|
||||
}
|
||||
else if( bUsedInGameplay && pGame->m_SecondaryMenuButton[m] == gb )
|
||||
return szSecondaryNames[m];
|
||||
}
|
||||
|
||||
return ""; // only used in gameplay
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2001-2004 Chris Danford, Glenn Maynard
|
||||
* All rights reserved.
|
||||
|
||||
@@ -7,6 +7,7 @@ class Style;
|
||||
class Game;
|
||||
|
||||
#include "GameConstantsAndTypes.h"
|
||||
#include "GameInput.h"
|
||||
|
||||
class GameManager
|
||||
{
|
||||
@@ -34,6 +35,7 @@ public:
|
||||
static const Game* StringToGameType( CString sGameType );
|
||||
const Style* GameAndStringToStyle( const Game* pGame, CString sStyle );
|
||||
static CString StyleToThemedString( const Style* s );
|
||||
CString GetSecondaryMenuButtonName( const Game *pGame, GameButton gb ) const;
|
||||
};
|
||||
|
||||
extern GameManager* GAMEMAN; // global and accessable from anywhere in our program
|
||||
|
||||
@@ -49,7 +49,7 @@ ScreenMapControllers::ScreenMapControllers( CString sClassName ) : ScreenWithMen
|
||||
for( int b=0; b<GAMESTATE->GetCurrentGame()->m_iButtonsPerController; b++ )
|
||||
{
|
||||
CString sName = GAMESTATE->GetCurrentGame()->m_szButtonNames[b];
|
||||
CString sSecondary = GAMESTATE->GetCurrentGame()->m_szSecondaryFunction[b];
|
||||
CString sSecondary = GAMEMAN->GetSecondaryMenuButtonName( GAMESTATE->GetCurrentGame(), b );
|
||||
|
||||
m_textName[b].LoadFromFont( THEME->GetPathToF("Common title") );
|
||||
m_textName[b].SetXY( SCREEN_CENTER_X, -6 );
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "ThemeManager.h"
|
||||
#include "Game.h"
|
||||
#include "ScreenDimensions.h"
|
||||
#include "GameManager.h"
|
||||
|
||||
|
||||
REGISTER_SCREEN_CLASS( ScreenTestInput );
|
||||
@@ -58,7 +59,7 @@ void ScreenTestInput::Update( float fDeltaTime )
|
||||
if( INPUTMAPPER->DeviceToGame(di,gi) )
|
||||
{
|
||||
CString sName = GAMESTATE->GetCurrentGame()->m_szButtonNames[gi.button];
|
||||
CString sSecondary = GAMESTATE->GetCurrentGame()->m_szSecondaryFunction[gi.button];
|
||||
CString sSecondary = GAMEMAN->GetSecondaryMenuButtonName( GAMESTATE->GetCurrentGame(), gi.button );
|
||||
|
||||
sTemp += ssprintf(" (Controller %d %s) %s", gi.controller+1, sName.c_str(), sSecondary.c_str() );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user