Пример #1
0
		/// <summary>
		/// Initialize the FileManager
		/// </summary>
		public override void Initialize()
		{
			base.Initialize();
			
#if !SILVERLIGHT
			_sharedDevice = new SharedStorageDevice();
			_playerDevice = new PlayerStorageDevice(PlayerIndex.One);
#endif
            _isolatedDevice = new IsolatedStorageStorageDevice();
			_titleDevice = new TitleStorageDevice();

			// hook two event handlers to force the user to choose a new device if they cancel the
			// device selector or if they disconnect the storage device after selecting it

#if !SILVERLIGHT
			_sharedDevice.DeviceSelectorCanceled += (s, e) => e.Response = StorageDeviceEventResponse.Force;
			_sharedDevice.DeviceDisconnected += (s, e) => e.Response = StorageDeviceEventResponse.Force;
			_playerDevice.DeviceDisconnected += (s, e) => e.Response = StorageDeviceEventResponse.Force;
			_playerDevice.DeviceSelectorCanceled += (s, e) => e.Response = StorageDeviceEventResponse.Force; 

			// prompt for a device on the first Update we can
			_sharedDevice.PromptForDevice();
			_playerDevice.PromptForDevice();

			// hook an event so we can see that it does fire
			_sharedDevice.SaveCompleted += SharedSaveCompleted;
			_sharedDevice.LoadCompleted += SharedLoadCompleted;
			_sharedDevice.DeleteCompleted += SharedDeleteCompleted;
			_sharedDevice.FileExistsCompleted += SharedFileExistsCompleted;
			_sharedDevice.GetFilesCompleted += SharedGetFilesCompleted;
#endif

			_isolatedDevice.SaveCompleted += IsolatedSaveCompleted;
			_isolatedDevice.LoadCompleted += IsolatedLoadCompleted;
			_isolatedDevice.DeleteCompleted += IsolatedDeleteCompleted;
			_isolatedDevice.FileExistsCompleted += IsolatedFileExistsCompleted;
			_isolatedDevice.GetFilesCompleted += IsolatedGetFilesCompleted;

#if !SILVERLIGHT
			_playerDevice.SaveCompleted += PlayerSaveCompleted;
			_playerDevice.LoadCompleted += PlayerLoadCompleted;
			_playerDevice.DeleteCompleted += PlayerDeleteCompleted;
			_playerDevice.FileExistsCompleted += PlayerFileExistsCompleted;
			_playerDevice.GetFilesCompleted += PlayerGetFilesCompleted;

			this.Game.Components.Add(_sharedDevice);
			this.Game.Components.Add(_playerDevice);           
            _sharedDevice.Update(null);
            _playerDevice.Update(null);
#endif
        }
Пример #2
0
        /// <summary>
        /// Initialize the FileManager
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

#if !SILVERLIGHT
            _sharedDevice = new SharedStorageDevice();
            _playerDevice = new PlayerStorageDevice(PlayerIndex.One);
#endif
            _isolatedDevice = new IsolatedStorageStorageDevice();
            _titleDevice    = new TitleStorageDevice();

            // hook two event handlers to force the user to choose a new device if they cancel the
            // device selector or if they disconnect the storage device after selecting it

#if !SILVERLIGHT
            _sharedDevice.DeviceSelectorCanceled += (s, e) => e.Response = StorageDeviceEventResponse.Force;
            _sharedDevice.DeviceDisconnected     += (s, e) => e.Response = StorageDeviceEventResponse.Force;
            _playerDevice.DeviceDisconnected     += (s, e) => e.Response = StorageDeviceEventResponse.Force;
            _playerDevice.DeviceSelectorCanceled += (s, e) => e.Response = StorageDeviceEventResponse.Force;

            // prompt for a device on the first Update we can
            _sharedDevice.PromptForDevice();
            _playerDevice.PromptForDevice();

            // hook an event so we can see that it does fire
            _sharedDevice.SaveCompleted       += SharedSaveCompleted;
            _sharedDevice.LoadCompleted       += SharedLoadCompleted;
            _sharedDevice.DeleteCompleted     += SharedDeleteCompleted;
            _sharedDevice.FileExistsCompleted += SharedFileExistsCompleted;
            _sharedDevice.GetFilesCompleted   += SharedGetFilesCompleted;
#endif

            _isolatedDevice.SaveCompleted       += IsolatedSaveCompleted;
            _isolatedDevice.LoadCompleted       += IsolatedLoadCompleted;
            _isolatedDevice.DeleteCompleted     += IsolatedDeleteCompleted;
            _isolatedDevice.FileExistsCompleted += IsolatedFileExistsCompleted;
            _isolatedDevice.GetFilesCompleted   += IsolatedGetFilesCompleted;

#if !SILVERLIGHT
            _playerDevice.SaveCompleted       += PlayerSaveCompleted;
            _playerDevice.LoadCompleted       += PlayerLoadCompleted;
            _playerDevice.DeleteCompleted     += PlayerDeleteCompleted;
            _playerDevice.FileExistsCompleted += PlayerFileExistsCompleted;
            _playerDevice.GetFilesCompleted   += PlayerGetFilesCompleted;

            this.Game.Components.Add(_sharedDevice);
            this.Game.Components.Add(_playerDevice);
            _sharedDevice.Update(null);
            _playerDevice.Update(null);
#endif
        }