2005-11-29 05:56:11 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
#include "ScreenOptionsMemoryCard.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "arch/MemoryCard/MemoryCardDriver.h"
|
|
|
|
|
#include "MemoryCardManager.h"
|
2005-11-29 08:02:54 +00:00
|
|
|
#include "GameState.h"
|
2005-11-29 23:15:11 +00:00
|
|
|
#include "ScreenManager.h"
|
2005-11-30 05:33:01 +00:00
|
|
|
#include "ScreenPrompt.h"
|
2005-12-22 03:10:04 +00:00
|
|
|
#include "LocalizedString.h"
|
2005-11-29 05:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
REGISTER_SCREEN_CLASS( ScreenOptionsMemoryCard );
|
|
|
|
|
ScreenOptionsMemoryCard::ScreenOptionsMemoryCard( CString sClassName ) : ScreenOptions( sClassName )
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenOptionsMemoryCard::Init()
|
|
|
|
|
{
|
|
|
|
|
ScreenOptions::Init();
|
|
|
|
|
|
|
|
|
|
FOREACH_CONST( UsbStorageDevice, MEMCARDMAN->GetStorageDevices(), iter )
|
|
|
|
|
{
|
2005-12-04 09:01:28 +00:00
|
|
|
// TODO: Make these string themable
|
|
|
|
|
|
|
|
|
|
vector<CString> vs;
|
|
|
|
|
if( iter->sOsMountDir.empty() )
|
|
|
|
|
vs.push_back( "(no mount dir)" );
|
|
|
|
|
else
|
|
|
|
|
vs.push_back( iter->sOsMountDir );
|
|
|
|
|
if( iter->sVolumeLabel.empty() )
|
|
|
|
|
vs.push_back( "(no label)" );
|
|
|
|
|
else
|
|
|
|
|
vs.push_back( iter->sVolumeLabel );
|
|
|
|
|
if( iter->iVolumeSizeMB == 0 )
|
|
|
|
|
vs.push_back( "size ???" );
|
|
|
|
|
else
|
|
|
|
|
vs.push_back( ssprintf("%dMB",iter->iVolumeSizeMB) );
|
|
|
|
|
|
|
|
|
|
CString sDescription = join(", ", vs);
|
2005-11-29 23:15:11 +00:00
|
|
|
OptionRowDefinition def( sDescription, true, "" );
|
2005-12-04 09:01:28 +00:00
|
|
|
def.m_sExplanationName = "Memory Card";
|
2005-12-03 08:19:38 +00:00
|
|
|
def.m_bAllowThemeTitle = false;
|
2005-12-06 12:38:38 +00:00
|
|
|
def.m_bOneChoiceForAllPlayers = true;
|
2005-12-04 09:01:28 +00:00
|
|
|
m_vDefs.push_back( def );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( MEMCARDMAN->GetStorageDevices().empty() )
|
|
|
|
|
{
|
|
|
|
|
OptionRowDefinition def( "No memory cards detected", true, "" );
|
2005-11-29 05:56:11 +00:00
|
|
|
m_vDefs.push_back( def );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vector<OptionRowHandler*> vHands( m_vDefs.size(), NULL );
|
|
|
|
|
|
|
|
|
|
InitMenu( m_vDefs, vHands );
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-29 08:02:54 +00:00
|
|
|
void ScreenOptionsMemoryCard::BeginScreen()
|
|
|
|
|
{
|
|
|
|
|
ScreenOptions::BeginScreen();
|
|
|
|
|
|
|
|
|
|
// select the last chosen memory card (if present)
|
|
|
|
|
if( !MEMCARDMAN->m_sEditorMemoryCardOsMountPoint.Get().empty() )
|
|
|
|
|
{
|
2005-12-04 09:01:28 +00:00
|
|
|
const vector<UsbStorageDevice> &v = MEMCARDMAN->GetStorageDevices();
|
2005-11-29 08:02:54 +00:00
|
|
|
for( unsigned i=0; i<v.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
if( v[i].sOsMountDir == MEMCARDMAN->m_sEditorMemoryCardOsMountPoint.Get() )
|
|
|
|
|
{
|
|
|
|
|
this->MoveRowAbsolute( PLAYER_1, i, false );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-12-04 09:01:28 +00:00
|
|
|
|
|
|
|
|
this->SubscribeToMessage( Message_StorageDevicesChanged );
|
2005-11-29 08:02:54 +00:00
|
|
|
}
|
|
|
|
|
|
2005-11-29 05:56:11 +00:00
|
|
|
void ScreenOptionsMemoryCard::HandleScreenMessage( const ScreenMessage SM )
|
|
|
|
|
{
|
|
|
|
|
ScreenOptions::HandleScreenMessage( SM );
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-29 23:15:11 +00:00
|
|
|
void ScreenOptionsMemoryCard::HandleMessage( const CString& sMessage )
|
|
|
|
|
{
|
|
|
|
|
if( sMessage == MessageToString(Message_StorageDevicesChanged) )
|
|
|
|
|
{
|
2005-12-04 09:01:28 +00:00
|
|
|
if( !m_Out.IsTransitioning() )
|
|
|
|
|
SCREENMAN->SetNewScreen( this->m_sName ); // reload
|
2005-11-29 23:15:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-11-29 05:56:11 +00:00
|
|
|
|
|
|
|
|
void ScreenOptionsMemoryCard::MenuStart( const InputEventPlus &input )
|
|
|
|
|
{
|
|
|
|
|
ScreenOptions::MenuStart( input );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenOptionsMemoryCard::ImportOptions( int iRow, const vector<PlayerNumber> &vpns )
|
|
|
|
|
{
|
2005-11-29 08:02:54 +00:00
|
|
|
|
2005-11-29 05:56:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenOptionsMemoryCard::ExportOptions( int iRow, const vector<PlayerNumber> &vpns )
|
|
|
|
|
{
|
|
|
|
|
OptionRow &row = *m_pRows[iRow];
|
2005-12-06 12:38:38 +00:00
|
|
|
if( row.GetRowType() == OptionRow::RowType_Exit )
|
2005-11-29 05:56:11 +00:00
|
|
|
return;
|
2005-11-29 08:02:54 +00:00
|
|
|
|
|
|
|
|
PlayerNumber pn = GAMESTATE->m_MasterPlayerNumber;
|
|
|
|
|
if( m_iCurrentRow[pn] == iRow )
|
2005-11-29 05:56:11 +00:00
|
|
|
{
|
2005-12-04 09:01:28 +00:00
|
|
|
const vector<UsbStorageDevice> &v = MEMCARDMAN->GetStorageDevices();
|
2005-12-12 09:59:17 +00:00
|
|
|
if( iRow < int(v.size()) )
|
2005-12-04 09:01:28 +00:00
|
|
|
{
|
|
|
|
|
const UsbStorageDevice &dev = v[iRow];
|
|
|
|
|
MEMCARDMAN->m_sEditorMemoryCardOsMountPoint.Set( dev.sOsMountDir );
|
|
|
|
|
}
|
2005-11-29 05:56:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-21 09:56:16 +00:00
|
|
|
static LocalizedString ERROR_MOUNTING_CARD ("ScreenOptionsMemoryCard", "Error mounting card: %s" );
|
2005-11-30 05:33:01 +00:00
|
|
|
void ScreenOptionsMemoryCard::ProcessMenuStart( const InputEventPlus &input )
|
|
|
|
|
{
|
|
|
|
|
int iCurRow = m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber];
|
|
|
|
|
|
2005-12-04 09:01:28 +00:00
|
|
|
const vector<UsbStorageDevice> &v = MEMCARDMAN->GetStorageDevices();
|
2005-12-12 09:59:17 +00:00
|
|
|
if( iCurRow < int(v.size()) ) // a card
|
2005-11-30 05:33:01 +00:00
|
|
|
{
|
|
|
|
|
const vector<UsbStorageDevice> v = MEMCARDMAN->GetStorageDevices();
|
|
|
|
|
const UsbStorageDevice &dev = v[iCurRow];
|
|
|
|
|
MEMCARDMAN->m_sEditorMemoryCardOsMountPoint.Set( dev.sOsMountDir );
|
|
|
|
|
bool bSuccess = MEMCARDMAN->MountCard( PLAYER_1, dev );
|
|
|
|
|
if( bSuccess )
|
|
|
|
|
{
|
|
|
|
|
this->BeginFadingOut();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-12-21 09:56:16 +00:00
|
|
|
CString s = ssprintf(ERROR_MOUNTING_CARD.GetValue(), MEMCARDMAN->GetCardError(PLAYER_1).c_str() );
|
2005-11-30 05:33:01 +00:00
|
|
|
ScreenPrompt::Prompt( SM_None, s );
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-12-04 09:01:28 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SCREENMAN->PlayInvalidSound();
|
|
|
|
|
}
|
2005-11-30 05:33:01 +00:00
|
|
|
}
|
|
|
|
|
|
2005-11-29 05:56:11 +00:00
|
|
|
/*
|
|
|
|
|
* (c) 2005 Chris Danford
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|