Multiple Storage Containers

Mar 6, 2010 at 6:53 AM

Hey!

First off: Awesome library, dude. This really helps, but I'm still trying to figure it out piece by piece. One thing I want to try is to have multiple storage containers for different things (Player save data, Custom ship data, etc), but when I create a new storage device, it keeps prompting the Storage Device selector. Is there a way I can share a storage device (HDD, for instance) between SaveDevices, or would my best bet be to just save everything in one container?

- Keith

Coordinator
Mar 6, 2010 at 1:20 PM

Each save device is set up to have its own StorageDevice under the hood. Generally you are fine putting everything in one container, so I would just use the one SaveDevice since that's going to be easier. Otherwise you could add a new constructor to the SaveDevice that takes another SaveDevice and a container name and then copies that StorageDevice over. That would let you have two SaveDevice objects for the same StorageDevice but with different StorageContainers.

Hope that makes sense. :)

 

Nick

Mar 7, 2010 at 3:02 AM

OK! Works out fine! I took your advice in the single container (I figured having multiple containers was a bit ridiculous). Thanks for he speedy reply, you are officially the man. Much success in your endeavors!

Mar 7, 2010 at 11:57 PM

I guess I have a similar question. I need a SharedSaveDevice for global settings for all players and I need a PlayerSaveDevice for each player's progress. Would you recommend the same solution for this scenario? Is there a way to make a PromptForDevice() call that returns to two SaveDevices? Or would it be that bad to ask twice to select a storage container?

Thanks for the library and support.

Coordinator
Mar 8, 2010 at 12:42 AM

There's no way to get two StorageDevices without asking twice. I don't think it's bad to ask for two storage devices. 

Mar 8, 2010 at 7:59 AM
Edited Mar 8, 2010 at 10:23 AM

Alright, so I've made a new constructor:

SaveDevice(string containerName, SaveDevice device)

I copied what was in the old constructor and added storageDevice =  device.storageDevice

I create a PlayerSaveDevice the usual way and add a method to create the SharedSaveDevice to its DeviceSelcted event.

Is this all I need to do? Its not working for me. The data saved to the shared device is not shared, but unique to each player.  Does the containerName of the SharedSaveDevice need to be different then the name of the PlayerSaveDevice? I tried it similar and different and neither way helped me. Got any suggestions?

 

EDIT: I just realized that DeviceSelected was never getting called, so I added another public method to SaveDevice:


public
virtual void CheckForStorageDevice() { if (storageDevice != null && storageDevice.IsConnected) { if (DeviceSelected != null) DeviceSelected(this, null); } }

After I call the constructor to the SharedSaveDevice I add my DeviceSelected eventHandlers then call CheckForStorageDevice(), but this still didn't fix my problem.

 

EDIT2: I've noticed that the storageDevicein a SharedSaveDevice has a playerIndex of 255. I don't know of any way I can change the PlayerSaveDevice's storageDevice's playerIndex.

 

And now I've done enough research to realize that what I'm trying to do is impossible.

Coordinator
Mar 8, 2010 at 10:47 AM

A StorageDevice, as you may have discovered, is either shared or player specific. You could use the same StorageDevice for multiple SaveDevices as long as you didn't want to change that property (i.e. you could share the same StorageDevice with three different PlayerSaveDevice instances to use different containers). But to get a StorageDevice of a different kind, you need to ask the user for it.