2003-09-08 03:26:58 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
Class: ScreenProfileOptions
|
|
|
|
|
|
|
|
|
|
Desc: See header.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001-2003 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Chris Danford
|
|
|
|
|
Chris POmez
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ScreenProfileOptions.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "ProfileManager.h"
|
|
|
|
|
#include "RageSounds.h"
|
|
|
|
|
#include "ThemeManager.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "ScreenManager.h"
|
2003-11-01 19:36:52 +00:00
|
|
|
#include "ScreenTextEntry.h"
|
|
|
|
|
#include "ScreenPrompt.h"
|
2003-09-08 03:26:58 +00:00
|
|
|
|
|
|
|
|
|
2003-09-30 11:32:06 +00:00
|
|
|
enum {
|
2003-09-08 03:26:58 +00:00
|
|
|
PO_PLAYER1,
|
|
|
|
|
PO_PLAYER2,
|
|
|
|
|
PO_CREATE_NEW,
|
|
|
|
|
PO_DELETE_,
|
2003-09-08 07:21:41 +00:00
|
|
|
PO_RENAME_,
|
2003-09-30 05:25:47 +00:00
|
|
|
NUM_PROFILE_OPTIONS_LINES
|
2003-09-08 03:26:58 +00:00
|
|
|
};
|
|
|
|
|
|
2003-09-30 05:25:47 +00:00
|
|
|
OptionRow g_ProfileOptionsLines[NUM_PROFILE_OPTIONS_LINES] = {
|
2003-09-08 03:26:58 +00:00
|
|
|
OptionRow( "Player1\nProfile", true ),
|
|
|
|
|
OptionRow( "Player2\nProfile", true ),
|
|
|
|
|
OptionRow( "Create\nNew", true, "PRESS START" ),
|
|
|
|
|
OptionRow( "Delete", true ),
|
2003-09-08 07:21:41 +00:00
|
|
|
OptionRow( "Rename", true ),
|
2003-09-08 03:26:58 +00:00
|
|
|
};
|
|
|
|
|
|
2003-11-01 19:36:52 +00:00
|
|
|
const ScreenMessage SM_DoneCreating = ScreenMessage(SM_User+1);
|
|
|
|
|
const ScreenMessage SM_DoneRenaming = ScreenMessage(SM_User+2);
|
|
|
|
|
const ScreenMessage SM_DoneDeleting = ScreenMessage(SM_User+3);
|
|
|
|
|
|
2003-09-27 22:30:51 +00:00
|
|
|
ScreenProfileOptions::ScreenProfileOptions( CString sClassName ) : ScreenOptions( sClassName )
|
2003-09-08 03:26:58 +00:00
|
|
|
{
|
|
|
|
|
LOG->Trace( "ScreenProfileOptions::ScreenProfileOptions()" );
|
|
|
|
|
|
|
|
|
|
g_ProfileOptionsLines[PO_PLAYER1].choices.clear();
|
2003-09-08 07:21:41 +00:00
|
|
|
g_ProfileOptionsLines[PO_PLAYER1].choices.push_back( "-NONE-" );
|
2003-11-01 19:36:52 +00:00
|
|
|
PROFILEMAN->GetMachineProfileNames( g_ProfileOptionsLines[PO_PLAYER1].choices );
|
2003-09-08 03:26:58 +00:00
|
|
|
|
|
|
|
|
g_ProfileOptionsLines[PO_PLAYER2].choices.clear();
|
2003-09-08 07:21:41 +00:00
|
|
|
g_ProfileOptionsLines[PO_PLAYER2].choices.push_back( "-NONE-" );
|
2003-11-01 19:36:52 +00:00
|
|
|
PROFILEMAN->GetMachineProfileNames( g_ProfileOptionsLines[PO_PLAYER2].choices );
|
2003-09-08 03:26:58 +00:00
|
|
|
|
|
|
|
|
g_ProfileOptionsLines[PO_DELETE_].choices.clear();
|
2003-09-08 07:21:41 +00:00
|
|
|
g_ProfileOptionsLines[PO_DELETE_].choices.push_back( "-NONE-" );
|
2003-11-01 19:36:52 +00:00
|
|
|
PROFILEMAN->GetMachineProfileNames( g_ProfileOptionsLines[PO_DELETE_].choices );
|
2003-09-08 07:21:41 +00:00
|
|
|
|
|
|
|
|
g_ProfileOptionsLines[PO_RENAME_].choices.clear();
|
|
|
|
|
g_ProfileOptionsLines[PO_RENAME_].choices.push_back( "-NONE-" );
|
2003-11-01 19:36:52 +00:00
|
|
|
PROFILEMAN->GetMachineProfileNames( g_ProfileOptionsLines[PO_RENAME_].choices );
|
2003-09-08 03:26:58 +00:00
|
|
|
|
|
|
|
|
Init(
|
|
|
|
|
INPUTMODE_TOGETHER,
|
|
|
|
|
g_ProfileOptionsLines,
|
2003-09-30 05:25:47 +00:00
|
|
|
NUM_PROFILE_OPTIONS_LINES,
|
2003-09-08 03:26:58 +00:00
|
|
|
true );
|
|
|
|
|
m_Menu.m_MenuTimer.Disable();
|
|
|
|
|
|
|
|
|
|
SOUND->PlayMusic( THEME->GetPathToS("ScreenMachineOptions music") );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenProfileOptions::ImportOptions()
|
|
|
|
|
{
|
2003-09-08 07:21:41 +00:00
|
|
|
vector<CString> vsProfiles;
|
2003-11-01 19:36:52 +00:00
|
|
|
PROFILEMAN->GetMachineProfileIDs( vsProfiles );
|
2003-09-08 07:21:41 +00:00
|
|
|
|
2003-09-08 03:26:58 +00:00
|
|
|
CStringArray::iterator iter;
|
|
|
|
|
|
|
|
|
|
iter = find(
|
2003-09-08 07:21:41 +00:00
|
|
|
vsProfiles.begin(),
|
|
|
|
|
vsProfiles.end(),
|
2003-09-08 03:26:58 +00:00
|
|
|
PREFSMAN->m_sDefaultProfile[PLAYER_1] );
|
2003-09-08 07:21:41 +00:00
|
|
|
if( iter != vsProfiles.end() )
|
|
|
|
|
m_iSelectedOption[0][PO_PLAYER1] = iter - vsProfiles.begin() + 1;
|
2003-09-08 03:26:58 +00:00
|
|
|
|
|
|
|
|
iter = find(
|
2003-09-08 07:21:41 +00:00
|
|
|
vsProfiles.begin(),
|
|
|
|
|
vsProfiles.end(),
|
2003-11-01 19:36:52 +00:00
|
|
|
PREFSMAN->m_sDefaultProfile[PLAYER_2] );
|
2003-09-08 07:21:41 +00:00
|
|
|
if( iter != vsProfiles.end() )
|
|
|
|
|
m_iSelectedOption[0][PO_PLAYER2] = iter - vsProfiles.begin() + 1;
|
2003-09-08 03:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenProfileOptions::ExportOptions()
|
|
|
|
|
{
|
2003-09-08 07:21:41 +00:00
|
|
|
vector<CString> vsProfiles;
|
2003-11-01 19:36:52 +00:00
|
|
|
PROFILEMAN->GetMachineProfileIDs( vsProfiles );
|
2003-09-08 07:21:41 +00:00
|
|
|
|
|
|
|
|
if( m_iSelectedOption[0][PO_PLAYER1] > 0 )
|
|
|
|
|
PREFSMAN->m_sDefaultProfile[PLAYER_1] = vsProfiles[m_iSelectedOption[0][PO_PLAYER1]-1];
|
|
|
|
|
else
|
|
|
|
|
PREFSMAN->m_sDefaultProfile[PLAYER_1] = "";
|
|
|
|
|
|
|
|
|
|
if( m_iSelectedOption[0][PO_PLAYER2] > 0 )
|
|
|
|
|
PREFSMAN->m_sDefaultProfile[PLAYER_2] = vsProfiles[m_iSelectedOption[0][PO_PLAYER2]-1];
|
|
|
|
|
else
|
|
|
|
|
PREFSMAN->m_sDefaultProfile[PLAYER_2] = "";
|
2003-09-08 03:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenProfileOptions::GoToPrevState()
|
|
|
|
|
{
|
|
|
|
|
SCREENMAN->SetNewScreen( "ScreenOptionsMenu" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenProfileOptions::GoToNextState()
|
|
|
|
|
{
|
|
|
|
|
PREFSMAN->SaveGlobalPrefsToDisk();
|
|
|
|
|
GoToPrevState();
|
|
|
|
|
}
|
2003-09-08 07:21:41 +00:00
|
|
|
|
2003-11-01 19:36:52 +00:00
|
|
|
void ScreenProfileOptions::HandleScreenMessage( const ScreenMessage SM )
|
2003-09-08 07:21:41 +00:00
|
|
|
{
|
2003-11-01 19:36:52 +00:00
|
|
|
CString sProfileID = GetSelectedProfileID();
|
|
|
|
|
CString sName = GetSelectedProfileName();
|
2003-09-08 07:21:41 +00:00
|
|
|
|
2003-11-01 19:36:52 +00:00
|
|
|
switch( SM )
|
2003-09-08 07:21:41 +00:00
|
|
|
{
|
2003-11-01 19:36:52 +00:00
|
|
|
case SM_DoneCreating:
|
|
|
|
|
if( !ScreenTextEntry::s_bCancelledLast )
|
2003-09-08 07:21:41 +00:00
|
|
|
{
|
2003-11-01 19:36:52 +00:00
|
|
|
CString sNewProfileID = ScreenTextEntry::s_sLastAnswer;
|
|
|
|
|
bool bResult = PROFILEMAN->CreateMachineProfile( sNewProfileID );
|
|
|
|
|
if( bResult )
|
|
|
|
|
SCREENMAN->SetNewScreen( "ScreenProfileOptions" ); // reload
|
2003-09-08 07:21:41 +00:00
|
|
|
else
|
2003-11-01 19:36:52 +00:00
|
|
|
SCREENMAN->Prompt( SM_None, ssprintf("Error creating profile '%s'.", sNewProfileID.c_str()) );
|
2003-09-08 07:21:41 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2003-11-01 19:36:52 +00:00
|
|
|
case SM_DoneRenaming:
|
|
|
|
|
if( !ScreenTextEntry::s_bCancelledLast )
|
2003-09-08 07:21:41 +00:00
|
|
|
{
|
2003-11-01 19:36:52 +00:00
|
|
|
CString sNewName = ScreenTextEntry::s_sLastAnswer;
|
|
|
|
|
bool bResult = PROFILEMAN->RenameMachineProfile( sProfileID, sNewName );
|
|
|
|
|
if( bResult )
|
|
|
|
|
SCREENMAN->SetNewScreen( "ScreenProfileOptions" ); // reload
|
2003-09-08 07:21:41 +00:00
|
|
|
else
|
2003-11-01 19:36:52 +00:00
|
|
|
SCREENMAN->Prompt( SM_None, ssprintf("Error renaming profile %s '%s'\nto '%s'.", sProfileID.c_str(), sName.c_str(), sNewName.c_str()) );
|
2003-09-08 07:21:41 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2003-11-01 19:36:52 +00:00
|
|
|
case SM_DoneDeleting:
|
|
|
|
|
if( ScreenPrompt::s_bLastAnswer )
|
|
|
|
|
{
|
|
|
|
|
bool bResult = PROFILEMAN->DeleteMachineProfile( sProfileID );
|
|
|
|
|
if( bResult )
|
|
|
|
|
SCREENMAN->SetNewScreen( "ScreenProfileOptions" ); // reload
|
|
|
|
|
else
|
|
|
|
|
SCREENMAN->Prompt( SM_None, ssprintf("Error deleting profile %s '%s'.", sName.c_str(), sProfileID.c_str()) );
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ScreenOptions::HandleScreenMessage( SM );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ScreenProfileOptions::MenuStart( PlayerNumber pn )
|
|
|
|
|
{
|
|
|
|
|
CString sProfileID = GetSelectedProfileID();
|
|
|
|
|
CString sName = GetSelectedProfileName();
|
|
|
|
|
|
|
|
|
|
switch( GetCurrentRow() )
|
|
|
|
|
{
|
|
|
|
|
case PO_CREATE_NEW:
|
|
|
|
|
SCREENMAN->TextEntry( SM_DoneCreating, "Enter a profile name", "", NULL );
|
|
|
|
|
break;
|
|
|
|
|
case PO_DELETE_:
|
|
|
|
|
if( sProfileID=="" )
|
|
|
|
|
SOUND->PlayOnce( THEME->GetPathToS("common invalid") );
|
|
|
|
|
else
|
|
|
|
|
SCREENMAN->Prompt( SM_DoneDeleting, ssprintf("Delete profile %s '%s'?",sProfileID.c_str(),sName.c_str()), true );
|
|
|
|
|
break;
|
|
|
|
|
case PO_RENAME_:
|
|
|
|
|
if( sProfileID=="" )
|
|
|
|
|
SOUND->PlayOnce( THEME->GetPathToS("common invalid") );
|
|
|
|
|
else
|
|
|
|
|
SCREENMAN->TextEntry( SM_DoneRenaming, ssprintf("Rename profile %s '%s'",sProfileID.c_str(),sName.c_str()), sName, NULL );
|
|
|
|
|
break;
|
2003-09-08 07:21:41 +00:00
|
|
|
default:
|
|
|
|
|
ScreenOptions::MenuStart( pn );
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-11-01 19:36:52 +00:00
|
|
|
|
|
|
|
|
CString ScreenProfileOptions::GetSelectedProfileID()
|
|
|
|
|
{
|
|
|
|
|
vector<CString> vsProfiles;
|
|
|
|
|
PROFILEMAN->GetMachineProfileIDs( vsProfiles );
|
|
|
|
|
|
|
|
|
|
if( m_iSelectedOption[0][m_iCurrentRow[0]]==0 )
|
|
|
|
|
return "";
|
|
|
|
|
else
|
|
|
|
|
return vsProfiles[m_iSelectedOption[0][m_iCurrentRow[0]]-1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CString ScreenProfileOptions::GetSelectedProfileName()
|
|
|
|
|
{
|
|
|
|
|
if( m_iSelectedOption[0][m_iCurrentRow[0]]==0 )
|
|
|
|
|
return "";
|
|
|
|
|
else
|
|
|
|
|
return g_ProfileOptionsLines[PO_PLAYER1].choices[ m_iSelectedOption[0][m_iCurrentRow[0]] ];
|
|
|
|
|
}
|
|
|
|
|
|