00001 #ifndef MemoryCardManager_H 00002 #define MemoryCardManager_H 00003 00004 #include "GameConstantsAndTypes.h" // for MemoryCardState 00005 #include "PlayerNumber.h" 00006 #include "RageSound.h" 00007 #include "arch/MemoryCard/MemoryCardDriver.h" 00008 00009 00010 const CString MEM_CARD_MOUNT_POINT[NUM_PLAYERS] = 00011 { 00012 /* @ is importast; see RageFileManager LoadedDriver::GetPath */ 00013 "@mc1/", 00014 "@mc2/", 00015 }; 00016 00017 class MemoryCardManager 00018 { 00019 public: 00020 MemoryCardManager(); 00021 ~MemoryCardManager(); 00022 00023 void Update( float fDelta ); 00024 00025 MemoryCardState GetCardState( PlayerNumber pn ); 00026 00027 // CString GetOsMountDir( PlayerNumber pn ); // only valid when state = ready 00028 00029 void LockCards( bool bLock ); // prevent removing or changing of memory cards 00030 void TryMountAllCards(); 00031 void MountAllUsedCards(); 00032 void UnmountAllUsedCards(); 00033 void MountCard( PlayerNumber pn ); 00034 void UnmountCard( PlayerNumber pn ); 00035 00036 void PauseMountingThread(); // call this before mouting, reading, or writing to memory card 00037 void UnPauseMountingThread(); // call this when done mouting, reading, or writing to memory card 00038 00039 void FlushAndReset(); // force all files to be flushed to mounted memory cards 00040 00041 bool PathIsMemCard( CString sDir ) const; 00042 00043 bool IsNameAvailable( PlayerNumber pn ) const; 00044 CString GetName( PlayerNumber pn ) const; 00045 00046 protected: 00047 void UpdateUnassignedCards(); // do our best to assign a Device to each player 00048 00049 MemoryCardDriver *m_pDriver; 00050 00051 vector<UsbStorageDevice> m_vStorageDevices; // all currently connected 00052 00053 bool m_bCardsLocked; 00054 bool m_bTooLate[NUM_PLAYERS]; // card was inserted after lock 00055 UsbStorageDevice m_Device[NUM_PLAYERS]; // device in the memory card slot, NULL if none 00056 00057 RageSound m_soundReady; 00058 RageSound m_soundError; 00059 RageSound m_soundTooLate; 00060 RageSound m_soundDisconnect; 00061 }; 00062 00063 extern MemoryCardManager* MEMCARDMAN; // global and accessable from anywhere in our program 00064 00065 #endif 00066 00067 /* 00068 * (c) 2003-2004 Chris Danford 00069 * All rights reserved. 00070 * 00071 * Permission is hereby granted, free of charge, to any person obtaining a 00072 * copy of this software and associated documentation files (the 00073 * "Software"), to deal in the Software without restriction, including 00074 * without limitation the rights to use, copy, modify, merge, publish, 00075 * distribute, and/or sell copies of the Software, and to permit persons to 00076 * whom the Software is furnished to do so, provided that the above 00077 * copyright notice(s) and this permission notice appear in all copies of 00078 * the Software and that both the above copyright notice(s) and this 00079 * permission notice appear in supporting documentation. 00080 * 00081 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00082 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00083 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00084 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00085 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00086 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00087 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00088 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00089 * PERFORMANCE OF THIS SOFTWARE. 00090 */