Files
itgmania212121/stepmania/src/ScreenOptionsMemoryCard.cpp
T

176 lines
5.1 KiB
C++
Raw Normal View History

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"
#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"
2006-01-17 21:23:26 +00:00
#include "OptionRowHandler.h"
2005-11-29 05:56:11 +00:00
2006-01-15 20:46:15 +00:00
REGISTER_SCREEN_CLASS( ScreenOptionsMemoryCard );
2005-11-29 05:56:11 +00:00
void ScreenOptionsMemoryCard::Init()
{
ScreenOptions::Init();
2006-02-01 07:25:25 +00:00
this->SubscribeToMessage( Message_StorageDevicesChanged );
}
void ScreenOptionsMemoryCard::BeginScreen()
{
2006-01-17 21:23:26 +00:00
vector<OptionRowHandler*> vHands;
2006-02-03 07:31:42 +00:00
m_CurrentUsbStorageDevices = MEMCARDMAN->GetStorageDevices();
2006-01-17 21:23:26 +00:00
2006-02-03 07:31:42 +00:00
FOREACH_CONST( UsbStorageDevice, m_CurrentUsbStorageDevices, iter )
2005-11-29 05:56:11 +00:00
{
2005-12-04 09:01:28 +00:00
// TODO: Make these string themable
2006-01-22 01:00:06 +00:00
vector<RString> vs;
2005-12-04 09:01:28 +00:00
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) );
2006-01-17 21:23:26 +00:00
vHands.push_back( OptionRowHandlerUtil::MakeNull() );
OptionRowDefinition &def = vHands.back()->m_Def;
2006-01-22 01:00:06 +00:00
RString sDescription = join(", ", vs);
2006-01-17 21:23:26 +00:00
def.m_sName = sDescription;
def.m_vsChoices.push_back( "" );
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;
def.m_bOneChoiceForAllPlayers = true;
2005-12-04 09:01:28 +00:00
}
2006-02-03 07:31:42 +00:00
if( m_CurrentUsbStorageDevices.empty() )
2005-12-04 09:01:28 +00:00
{
OptionRowDefinition def( "No memory cards detected", true, "" );
2005-11-29 05:56:11 +00:00
}
2006-01-17 21:31:50 +00:00
InitMenu( vHands );
2005-11-29 05:56:11 +00:00
2005-11-29 08:02:54 +00:00
ScreenOptions::BeginScreen();
// select the last chosen memory card (if present)
2006-02-03 07:34:27 +00:00
SelectRowWithMemoryCard( MEMCARDMAN->m_sEditorMemoryCardOsMountPoint.Get() );
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 );
}
2006-01-22 01:00:06 +00:00
void ScreenOptionsMemoryCard::HandleMessage( const RString& 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 05:56:11 +00:00
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];
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
{
2006-02-03 07:31:42 +00:00
const vector<UsbStorageDevice> &v = m_CurrentUsbStorageDevices;
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
}
}
2006-02-03 07:34:27 +00:00
void ScreenOptionsMemoryCard::SelectRowWithMemoryCard( const RString &sOsMountPoint )
{
if( sOsMountPoint.empty() )
return;
const vector<UsbStorageDevice> &v = m_CurrentUsbStorageDevices;
for( unsigned i=0; i<v.size(); i++ )
{
if( v[i].sOsMountDir == sOsMountPoint )
{
this->MoveRowAbsolute( PLAYER_1, i, false );
return;
}
}
}
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];
2006-02-03 07:31:42 +00:00
const vector<UsbStorageDevice> &v = m_CurrentUsbStorageDevices;
2005-12-12 09:59:17 +00:00
if( iCurRow < int(v.size()) ) // a card
2005-11-30 05:33:01 +00:00
{
2006-02-03 07:31:42 +00:00
const vector<UsbStorageDevice> &v = m_CurrentUsbStorageDevices;
2005-11-30 05:33:01 +00:00
const UsbStorageDevice &dev = v[iCurRow];
MEMCARDMAN->m_sEditorMemoryCardOsMountPoint.Set( dev.sOsMountDir );
bool bSuccess = MEMCARDMAN->MountCard( PLAYER_1, dev );
if( bSuccess )
{
SCREENMAN->PlayStartSound();
2005-11-30 05:33:01 +00:00
this->BeginFadingOut();
}
else
{
2006-01-22 01:00:06 +00:00
RString 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.
*/