fix broken basic usage

This commit is contained in:
Chris Danford
2006-04-04 21:55:46 +00:00
parent 0183226c72
commit fd5fc24083
+42 -22
View File
@@ -92,10 +92,13 @@ void ScreenOptionsManageProfiles::BeginScreen()
if( SHOW_CREATE_NEW ) if( SHOW_CREATE_NEW )
{ {
OptionRowHandler *pHand = OptionRowHandlerUtil::Make( ParseCommands("gamecommand;screen,ScreenOptionsEditProfile;name,Create New") ); OptionRowHandler *pHand = OptionRowHandlerUtil::Make( ParseCommands(ssprintf("gamecommand;screen,%s;name,dummy",m_sName.c_str())) );
pHand->m_Def.m_layoutType = LAYOUT_SHOW_ALL_IN_ROW; OptionRowDefinition &def = pHand->m_Def;
pHand->m_Def.m_bAllowThemeTitle = true; def.m_layoutType = LAYOUT_SHOW_ALL_IN_ROW;
pHand->m_Def.m_bAllowThemeItems = false; def.m_bAllowThemeTitle = true;
def.m_bAllowThemeItems = false;
def.m_sName = "Create New Profile";
def.m_sExplanationName = "Create New Profile";
OptionRowHandlers.push_back( pHand ); OptionRowHandlers.push_back( pHand );
// FIXME // FIXME
@@ -109,12 +112,21 @@ void ScreenOptionsManageProfiles::BeginScreen()
Profile *pProfile = PROFILEMAN->GetLocalProfile( *s ); Profile *pProfile = PROFILEMAN->GetLocalProfile( *s );
ASSERT( pProfile ); ASSERT( pProfile );
RString sCommand = ssprintf( "gamecommand;screen,ScreenOptionsEditProfile;profileid,%s;name,%s", s->c_str(), pProfile->m_sDisplayName.c_str() ); RString sCommand = ssprintf( "gamecommand;screen,ScreenOptionsEditProfile;profileid,%s;name,dummy", s->c_str() );
OptionRowHandler *pHand = OptionRowHandlerUtil::Make( ParseCommands(sCommand) ); OptionRowHandler *pHand = OptionRowHandlerUtil::Make( ParseCommands(sCommand) );
pHand->m_Def.m_layoutType = LAYOUT_SHOW_ALL_IN_ROW; OptionRowDefinition &def = pHand->m_Def;
pHand->m_Def.m_bAllowThemeTitle = false; def.m_layoutType = LAYOUT_SHOW_ALL_IN_ROW;
pHand->m_Def.m_bAllowThemeItems = false; def.m_bAllowThemeTitle = false;
pHand->m_Def.m_sName = pProfile->m_sDisplayName; def.m_bAllowThemeItems = false;
def.m_sName = pProfile->m_sDisplayName;
def.m_sExplanationName = "Select Profile";
PlayerNumber pn = PLAYER_INVALID;
FOREACH_PlayerNumber( p )
if( *s == ProfileManager::m_sDefaultLocalProfileID[p].Get() )
pn = p;
if( pn != PLAYER_INVALID )
def.m_vsChoices.push_back( PlayerNumberToLocalizedString(pn) );
OptionRowHandlers.push_back( pHand ); OptionRowHandlers.push_back( pHand );
// FIXME // FIXME
@@ -123,12 +135,15 @@ void ScreenOptionsManageProfiles::BeginScreen()
ScreenOptions::InitMenu( OptionRowHandlers ); ScreenOptions::InitMenu( OptionRowHandlers );
// Save sEditLocalProfileID before calling ScreenOptions::BeginScreen, because it will get clobbered.
RString sEditLocalProfileID = GAMESTATE->m_sEditLocalProfileID;
ScreenOptions::BeginScreen(); ScreenOptions::BeginScreen();
// select the last chosen profile // select the last chosen profile
if( !GAMESTATE->m_sEditLocalProfileID.Get().empty() ) if( !sEditLocalProfileID.empty() )
{ {
vector<RString>::const_iterator iter = find( m_vsLocalProfileID.begin(), m_vsLocalProfileID.end(), GAMESTATE->m_sEditLocalProfileID.Get() ); vector<RString>::const_iterator iter = find( m_vsLocalProfileID.begin(), m_vsLocalProfileID.end(), sEditLocalProfileID );
if( iter != m_vsLocalProfileID.end() ) if( iter != m_vsLocalProfileID.end() )
{ {
int iIndex = iter - m_vsLocalProfileID.begin(); int iIndex = iter - m_vsLocalProfileID.begin();
@@ -173,7 +188,7 @@ void ScreenOptionsManageProfiles::HandleScreenMessage( const ScreenMessage SM )
PROFILEMAN->CreateLocalProfile( ScreenTextEntry::s_sLastAnswer, sProfileID ); PROFILEMAN->CreateLocalProfile( ScreenTextEntry::s_sLastAnswer, sProfileID );
GAMESTATE->m_sEditLocalProfileID.Set( sProfileID ); GAMESTATE->m_sEditLocalProfileID.Set( sProfileID );
this->HandleScreenMessage( SM_GoToNextScreen ); SCREENMAN->SetNewScreen( this->m_sName ); // reload
} }
} }
else if( SM == SM_BackFromRename ) else if( SM == SM_BackFromRename )
@@ -228,17 +243,14 @@ void ScreenOptionsManageProfiles::HandleScreenMessage( const ScreenMessage SM )
case ProfileAction_SetDefaultP1: case ProfileAction_SetDefaultP1:
case ProfileAction_SetDefaultP2: case ProfileAction_SetDefaultP2:
{ {
PlayerNumber pn = (PlayerNumber)(ScreenMiniMenu::s_iLastRowCode - ProfileAction_SetDefaultP1); FOREACH_PlayerNumber( p )
PlayerNumber pnOpposite = OPPOSITE_PLAYER[ pn ]; if( ProfileManager::m_sDefaultLocalProfileID[p].Get() == GetLocalProfileIDWithFocus() )
ProfileManager::m_sDefaultLocalProfileID[p].Set("");
PlayerNumber pn = (PlayerNumber)(ScreenMiniMenu::s_iLastRowCode - ProfileAction_SetDefaultP1);
ProfileManager::m_sDefaultLocalProfileID[pn].Set( GetLocalProfileIDWithFocus() ); ProfileManager::m_sDefaultLocalProfileID[pn].Set( GetLocalProfileIDWithFocus() );
if( ProfileManager::m_sDefaultLocalProfileID[pn].Get() == ProfileManager::m_sDefaultLocalProfileID[pnOpposite].Get() )
{ SCREENMAN->SetNewScreen( this->m_sName ); // reload
int iIndex = GetLocalProfileIndexWithFocus();
iIndex++;
wrap( iIndex, m_vsLocalProfileID.size() );
ProfileManager::m_sDefaultLocalProfileID[pnOpposite].Set( m_vsLocalProfileID[iIndex] );
}
} }
break; break;
case ProfileAction_Edit: case ProfileAction_Edit:
@@ -275,6 +287,14 @@ void ScreenOptionsManageProfiles::HandleScreenMessage( const ScreenMessage SM )
} }
} }
} }
else if( SM == SM_LoseFocus )
{
this->PlayCommand( "ScreenLoseFocus" );
}
else if( SM == SM_GainFocus )
{
this->PlayCommand( "ScreenGainFocus" );
}
ScreenOptions::HandleScreenMessage( SM ); ScreenOptions::HandleScreenMessage( SM );
} }
@@ -335,7 +355,7 @@ void ScreenOptionsManageProfiles::ProcessMenuStart( const InputEventPlus &input
} }
else else
{ {
ADD_ACTION( ProfileAction_Edit ); //ADD_ACTION( ProfileAction_Edit );
ADD_ACTION( ProfileAction_Rename ); ADD_ACTION( ProfileAction_Rename );
ADD_ACTION( ProfileAction_Delete ); ADD_ACTION( ProfileAction_Delete );
} }