2003-12-15 08:34:06 +00:00
|
|
|
#ifndef MemoryCardManager_H
|
|
|
|
|
#define MemoryCardManager_H
|
|
|
|
|
|
2003-12-19 04:52:07 +00:00
|
|
|
#include "GameConstantsAndTypes.h" // for MemoryCardState
|
2003-12-15 08:34:06 +00:00
|
|
|
#include "PlayerNumber.h"
|
2003-12-18 04:24:25 +00:00
|
|
|
#include "RageSound.h"
|
2003-12-18 07:46:21 +00:00
|
|
|
#include "arch/MemoryCard/MemoryCardDriver.h"
|
2005-10-27 17:37:59 +00:00
|
|
|
#include "Preference.h"
|
2003-12-17 10:20:53 +00:00
|
|
|
|
2004-03-14 01:40:24 +00:00
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
extern const RString MEM_CARD_MOUNT_POINT[NUM_PLAYERS];
|
2004-03-14 01:40:24 +00:00
|
|
|
|
2003-12-15 08:34:06 +00:00
|
|
|
class MemoryCardManager
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
MemoryCardManager();
|
|
|
|
|
~MemoryCardManager();
|
|
|
|
|
|
2005-11-29 23:13:43 +00:00
|
|
|
void Update( float fDelta );
|
2003-12-17 10:20:53 +00:00
|
|
|
|
2005-02-06 05:08:46 +00:00
|
|
|
MemoryCardState GetCardState( PlayerNumber pn ) const { return m_State[pn]; }
|
2006-03-12 23:53:31 +00:00
|
|
|
RString GetCardError( PlayerNumber pn ) const { return m_sError[pn]; }
|
2003-12-17 10:20:53 +00:00
|
|
|
|
2005-01-27 19:42:34 +00:00
|
|
|
void LockCards(); // prevent removing or changing of memory cards
|
|
|
|
|
void UnlockCards();
|
2005-05-22 01:44:37 +00:00
|
|
|
bool MountCard( PlayerNumber pn, int iTimeout = 10 );
|
2005-11-30 05:33:01 +00:00
|
|
|
bool MountCard( PlayerNumber pn, const UsbStorageDevice &d );
|
2004-10-03 05:27:52 +00:00
|
|
|
void UnmountCard( PlayerNumber pn );
|
2005-02-06 08:48:55 +00:00
|
|
|
|
2005-11-30 05:33:01 +00:00
|
|
|
bool IsMounted( PlayerNumber pn ) const { return m_bMounted[pn]; }
|
|
|
|
|
|
2005-02-06 08:48:55 +00:00
|
|
|
/* When paused, no changes in memory card state will be noticed until unpaused. */
|
2005-09-29 02:36:10 +00:00
|
|
|
void PauseMountingThread( int iTimeout = 20 );
|
2005-02-06 08:48:55 +00:00
|
|
|
void UnPauseMountingThread();
|
2003-12-19 08:17:44 +00:00
|
|
|
|
2005-02-06 08:48:55 +00:00
|
|
|
bool GetCardsLocked() const { return m_bCardsLocked; }
|
2005-02-06 05:08:46 +00:00
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
bool PathIsMemCard( RString sDir ) const;
|
2004-10-09 09:57:12 +00:00
|
|
|
|
|
|
|
|
bool IsNameAvailable( PlayerNumber pn ) const;
|
2006-03-12 23:53:31 +00:00
|
|
|
RString GetName( PlayerNumber pn ) const;
|
2004-03-23 22:33:14 +00:00
|
|
|
|
2005-11-27 01:50:10 +00:00
|
|
|
const vector<UsbStorageDevice> &GetStorageDevices() { return m_vStorageDevices; }
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
static Preference1D<RString> m_sMemoryCardOsMountPoint;
|
2006-03-13 11:47:41 +00:00
|
|
|
static Preference1D<int> m_iMemoryCardUsbBus;
|
|
|
|
|
static Preference1D<int> m_iMemoryCardUsbPort;
|
|
|
|
|
static Preference1D<int> m_iMemoryCardUsbLevel;
|
2005-10-27 17:37:59 +00:00
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
static Preference<RString> m_sEditorMemoryCardOsMountPoint;
|
2005-11-29 08:02:54 +00:00
|
|
|
|
2006-03-12 07:02:50 +00:00
|
|
|
// Lua
|
|
|
|
|
void PushSelf( lua_State *L );
|
|
|
|
|
|
2003-12-17 10:20:53 +00:00
|
|
|
protected:
|
2006-03-26 04:51:47 +00:00
|
|
|
void UpdateAssignments();
|
2005-02-06 05:08:46 +00:00
|
|
|
void CheckStateChanges();
|
2003-12-18 07:46:21 +00:00
|
|
|
|
|
|
|
|
vector<UsbStorageDevice> m_vStorageDevices; // all currently connected
|
|
|
|
|
|
2003-12-17 10:20:53 +00:00
|
|
|
bool m_bCardsLocked;
|
2005-01-27 22:57:18 +00:00
|
|
|
bool m_bMounted[NUM_PLAYERS]; // card is currently mounted
|
2005-02-06 05:08:46 +00:00
|
|
|
|
|
|
|
|
UsbStorageDevice m_Device[NUM_PLAYERS]; // device in the memory card slot, blank if none
|
|
|
|
|
UsbStorageDevice m_FinalDevice[NUM_PLAYERS]; // device in the memory card slot when we finalized, blank if none
|
|
|
|
|
|
|
|
|
|
MemoryCardState m_State[NUM_PLAYERS];
|
2006-01-22 01:00:06 +00:00
|
|
|
RString m_sError[NUM_PLAYERS]; // if MemoryCardState_Error
|
2005-02-06 05:08:46 +00:00
|
|
|
|
2003-12-19 04:52:07 +00:00
|
|
|
RageSound m_soundReady;
|
|
|
|
|
RageSound m_soundError;
|
|
|
|
|
RageSound m_soundTooLate;
|
2003-12-18 04:24:25 +00:00
|
|
|
RageSound m_soundDisconnect;
|
2003-12-15 08:34:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern MemoryCardManager* MEMCARDMAN; // global and accessable from anywhere in our program
|
|
|
|
|
|
|
|
|
|
#endif
|
2004-06-08 01:24:17 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* (c) 2003-2004 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.
|
|
|
|
|
*/
|