add profile switching on STitleMenu

This commit is contained in:
Chris Danford
2005-08-03 03:27:43 +00:00
parent 9dd876559a
commit 843e2a9c91
5 changed files with 110 additions and 3 deletions
+13
View File
@@ -203,6 +203,12 @@ void FadingBanner::LoadFromCourse( const Course* pCourse )
LoadFromCachedBanner( sPath );
}
void FadingBanner::LoadIconFromCharacter( Character* pCharacter )
{
BeforeChange();
m_Banner[m_iIndexLatest].LoadIconFromCharacter( pCharacter );
}
void FadingBanner::LoadRoulette()
{
BeforeChange();
@@ -249,12 +255,19 @@ public:
else { Course *pC = Luna<Course>::check(L,1); p->LoadFromCourse( pC ); }
return 0;
}
static int LoadIconFromCharacter( T* p, lua_State *L )
{
if( lua_isnil(L,1) ) { p->LoadIconFromCharacter( NULL ); }
else { Character *pC = Luna<Character>::check(L,1); p->LoadIconFromCharacter( pC ); }
return 0;
}
static void Register(lua_State *L)
{
ADD_METHOD( ScaleToClipped )
ADD_METHOD( LoadFromSong )
ADD_METHOD( LoadFromCourse )
ADD_METHOD( LoadIconFromCharacter )
Luna<T>::Register( L );
}
};
+1
View File
@@ -23,6 +23,7 @@ public:
void LoadMode();
void LoadFromSongGroup( CString sSongGroup );
void LoadFromCourse( const Course* pCourse );
void LoadIconFromCharacter( Character* pCharacter );
void LoadRoulette();
void LoadRandom();
void LoadFallback();
+87 -3
View File
@@ -14,9 +14,32 @@
#include "RageTextureManager.h"
#include "LightsManager.h"
#include "Game.h"
#include "InputMapper.h"
#include "ProfileManager.h"
#define COIN_MODE_CHANGE_SCREEN THEME->GetMetric (m_sName,"CoinModeChangeScreen")
static void ChangeDefaultLocalProfile( PlayerNumber pn, int iDir )
{
CString sCurrent = PREFSMAN->GetDefaultLocalProfileID(pn);
vector<CString> vsProfileID;
PROFILEMAN->GetLocalProfileIDs( vsProfileID );
if( vsProfileID.empty() )
return;
int iIndex = 0;
vector<CString>::const_iterator iter = find( vsProfileID.begin(), vsProfileID.end(), sCurrent );
if( iter != vsProfileID.end() )
{
iIndex = iter - vsProfileID.begin();
iIndex += iDir;
wrap( iIndex, vsProfileID.size() );
}
sCurrent = vsProfileID[iIndex];
PREFSMAN->GetDefaultLocalProfileID(pn).Set( sCurrent );
}
REGISTER_SCREEN_CLASS( ScreenTitleMenu );
ScreenTitleMenu::ScreenTitleMenu( CString sScreenName ) :
@@ -38,8 +61,12 @@ ScreenTitleMenu::ScreenTitleMenu( CString sScreenName ) :
void ScreenTitleMenu::Init()
{
m_bSelectIsDown = false; // used by LoadHelpText which is called by ScreenWithMenuElements::Init()
ScreenSelectMaster::Init();
m_soundSelectPressed.Load( THEME->GetPathS(m_sName,"select down"), true );
this->SortByDrawOrder();
SOUND->PlayOnceFromAnnouncer( "title menu game name" );
@@ -54,11 +81,11 @@ void ScreenTitleMenu::Input( const DeviceInput& DeviceI, const InputEventType ty
{
LOG->Trace( "ScreenTitleMenu::Input( %d-%d )", DeviceI.device, DeviceI.button ); // debugging gameport joystick problem
if( m_In.IsTransitioning() || m_Cancel.IsTransitioning() ) /* not m_Out */
return;
if( type == IET_FIRST_PRESS )
{
if( m_In.IsTransitioning() || m_Cancel.IsTransitioning() ) /* not m_Out */
return;
//
// detect codes
//
@@ -105,6 +132,37 @@ void ScreenTitleMenu::Input( const DeviceInput& DeviceI, const InputEventType ty
}
}
if( MenuI.IsValid() )
{
LoadHelpText();
PlayerNumber pn = MenuI.player;
bool bSelectIsDown = false;
FOREACH_PlayerNumber( p )
bSelectIsDown |= INPUTMAPPER->IsButtonDown( MenuInput(p, MENU_BUTTON_SELECT) );
if( bSelectIsDown )
{
if( type == IET_FIRST_PRESS )
{
switch( MenuI.button )
{
case MENU_BUTTON_LEFT:
ChangeDefaultLocalProfile( pn, -1 );
MESSAGEMAN->Broadcast( ssprintf("MenuLeftP%d",pn+1) );
break;
case MENU_BUTTON_RIGHT:
ChangeDefaultLocalProfile( pn, +1 );
MESSAGEMAN->Broadcast( ssprintf("MenuRightP%d",pn+1) );
break;
}
}
return;
}
}
ScreenSelectMaster::Input( DeviceI, type, GameI, MenuI, StyleI );
}
@@ -118,6 +176,32 @@ void ScreenTitleMenu::HandleMessage( const CString& sMessage )
}
}
void ScreenTitleMenu::LoadHelpText()
{
ScreenWithMenuElements::LoadHelpText();
bool bSelectIsDown = false;
FOREACH_PlayerNumber( p )
bSelectIsDown |= INPUTMAPPER->IsButtonDown( MenuInput(p, MENU_BUTTON_SELECT) );
if( bSelectIsDown )
LOG->Trace( "bSelectIsDown" );
/* If m_soundSelectPressed isn't loaded yet, wait until it is before we do this. */
if( m_bSelectIsDown != bSelectIsDown && m_soundSelectPressed.IsLoaded() )
{
if( bSelectIsDown )
m_soundSelectPressed.Play();
m_bSelectIsDown = bSelectIsDown;
if( bSelectIsDown )
MESSAGEMAN->Broadcast( "SelectMenuOn" );
else
MESSAGEMAN->Broadcast( "SelectMenuOff" );
}
}
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
+7
View File
@@ -15,6 +15,13 @@ public:
virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
virtual void HandleMessage( const CString& sMessage );
protected:
virtual void LoadHelpText();
RageSound m_soundSelectPressed;
bool m_bSelectIsDown;
};
#endif
+2
View File
@@ -44,6 +44,8 @@ public:
CString ToString() const;
bool IsValid() const;
static void ClearCache();
StepsType GetStepsType() const { return st; }
};
#endif