コード例 #1
0
ファイル: StorageHandler.cs プロジェクト: Zikomo/Leximo
        public StorageHandler()
        {
            EasyStorageSettings.SetSupportedLanguages(EasyStorage.Language.English);
            HighScores = new HighScores();
            Settings = new Settings();

            #if WINDOWS
            saveDevice = new PCSaveDevice("Leximo");
            useStorage = true;
            GetHighScoresFromDevice();
            //sharedSaveDevice = saveDevice;
            #else
            // add the GamerServicesComponent

            // create and add our SaveDevice
            sharedSaveDevice = new SharedSaveDevice("Leximo");
            //Components.Add(sharedSaveDevice);

            // hook an event for when the device is selected
            sharedSaveDevice.DeviceSelected += (s, e) => GetHighScoresFromDevice();

            // 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
            sharedSaveDevice.DeviceSelectorCanceled += new EventHandler<SaveDeviceEventArgs>(sharedSaveDevice_DeviceSelectorCanceled);//(s, e) => e.Response = SaveDeviceEventResponse.Prompt;
            sharedSaveDevice.DeviceDisconnected += new EventHandler<SaveDeviceEventArgs>(sharedSaveDevice_DeviceDisconnected); //(s, e) => e.Response = SaveDeviceEventResponse.Prompt;

            // prompt for a device on the next Update

            // make sure we hold on to the device
            saveDevice = sharedSaveDevice;
            #endif
        }
コード例 #2
0
        private void PromptMe()
        {
            // we can set our supported languages explicitly or we can allow the
            // game to support all the languages. the first language given will
            // be the default if the current language is not one of the supported
            // languages. this only affects the text found in message boxes shown
            // by EasyStorage and does not have any affect on the rest of the game.
            EasyStorageSettings.SetSupportedLanguages(Language.French, Language.Spanish);

            // on Windows Phone we use a save device that uses IsolatedStorage
            // on Windows and Xbox 360, we use a save device that gets a
            //shared StorageDevice to handle our file IO.
            #if WINDOWS_PHONE
            saveDevice = new IsolatedStorageSaveDevice();
            Global.SaveDevice = saveDevice;

            // we use the tap gesture for input on the phone
            TouchPanel.EnabledGestures = GestureType.Tap;
            #else
            // create and add our SaveDevice
            SharedSaveDevice sharedSaveDevice = new SharedSaveDevice();
            ScreenManager.Game.Components.Add(sharedSaveDevice);

            // make sure we hold on to the device
            saveDevice = sharedSaveDevice;

            // 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
            sharedSaveDevice.DeviceSelectorCanceled +=
                (s, e) => e.Response = SaveDeviceEventResponse.Force;
            sharedSaveDevice.DeviceDisconnected +=
                (s, e) => e.Response = SaveDeviceEventResponse.Force;

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

            sharedSaveDevice.DeviceSelected += (s, e) =>
            {
                //Save our save device to the global counterpart, so we can access it
                //anywhere we want to save/load
                GameSettings.SaveDevice = (SaveDevice)s;

                //Once they select a storage device, we can load the main menu.
                //You'll notice I hard coded PlayerIndex.One here. You'll need to
                //change that if you plan on releasing your game. I linked to an
                //example on how to do that but here's the link if you need it.
                //http://blog.nickgravelyn.com/2009/03/basic-handling-of-multiple-controllers/
                ScreenManager.AddScreen(new MainMenuScreen(), PlayerIndex.One);
            };
            #endif

            #if XBOX
            // add the GamerServicesComponent
            ScreenManager.Game.Components.Add(
                new Microsoft.Xna.Framework.GamerServices.GamerServicesComponent(ScreenManager.Game));
            #endif
        }
コード例 #3
0
        public DataController()
        {
            SharedDatas = new Dictionary<string, SharedData>();

#if WINDOWS_PHONE
            SaveDevice = new IsolatedStorageSaveDevice();
#else
            Everyone = new SharedSaveDevice();
            Everyone.DeviceSelectorCanceled += (s, e) => e.Response = SaveDeviceEventResponse.Force;
            Everyone.DeviceDisconnected += (s, e) => e.Response = SaveDeviceEventResponse.Force;

            Everyone.PromptForDevice();
#endif
        }
コード例 #4
0
ファイル: Game1.cs プロジェクト: NotYours180/EasyStorage
		public Game1()
		{
			new GraphicsDeviceManager(this);
			Content.RootDirectory = "Content";

			// we can set our supported languages explicitly or we can allow the
			// game to support all the languages. the first language given will
			// be the default if the current language is not one of the supported
			// languages. this only affects the text found in message boxes shown
			// by EasyStorage and does not have any affect on the rest of the game.
			EasyStorageSettings.SetSupportedLanguages(Language.French, Language.Spanish);

			// on PC we use a save that saves to the user's "Saved Games" folder instead
			// of using the Xna.Storage APIs

			// on Xbox, we use a save device that gets a shared StorageDevice to
			// handle our file IO.
#if WINDOWS
			saveDevice = new PCSaveDevice("EasyStorageTestGame");
			TestDevice();
#else
			// add the GamerServicesComponent
			Components.Add(new GamerServicesComponent(this));

			// create and add our SaveDevice
			SharedSaveDevice sharedSaveDevice = new SharedSaveDevice();
			Components.Add(sharedSaveDevice);

			// hook an event for when the device is selected to run our test
			sharedSaveDevice.DeviceSelected += (s, e) => TestDevice();
			
			// 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
			sharedSaveDevice.DeviceSelectorCanceled += (s, e) => e.Response = SaveDeviceEventResponse.Force;
			sharedSaveDevice.DeviceDisconnected += (s, e) => e.Response = SaveDeviceEventResponse.Force;

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

			// make sure we hold on to the device
			saveDevice = sharedSaveDevice;
#endif
		}
コード例 #5
0
ファイル: Game1.cs プロジェクト: NotYours180/EasyStorage
		protected override void Initialize()
		{
			// we can set our supported languages explicitly or we can allow the
			// game to support all the languages. the first language given will
			// be the default if the current language is not one of the supported
			// languages. this only affects the text found in message boxes shown
			// by EasyStorage and does not have any affect on the rest of the game.
			EasyStorageSettings.SetSupportedLanguages(Language.French, Language.Spanish);

			// on Windows Phone we use a save device that uses IsolatedStorage
			// on Windows and Xbox 360, we use a save device that gets a shared StorageDevice to handle our file IO.
#if WINDOWS_PHONE
			saveDevice = new IsolatedStorageSaveDevice();
#else
			// create and add our SaveDevice
			SharedSaveDevice sharedSaveDevice = new SharedSaveDevice();
			Components.Add(sharedSaveDevice);

			// make sure we hold on to the device
			saveDevice = sharedSaveDevice;

			// 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
			sharedSaveDevice.DeviceSelectorCanceled += (s, e) => e.Response = SaveDeviceEventResponse.Force;
			sharedSaveDevice.DeviceDisconnected += (s, e) => e.Response = SaveDeviceEventResponse.Force;

			// prompt for a device on the first Update we can
			sharedSaveDevice.PromptForDevice();
#endif

			// we use the tap gesture for input on the phone
			TouchPanel.EnabledGestures = GestureType.Tap;

#if XBOX
			// add the GamerServicesComponent
			Components.Add(new Microsoft.Xna.Framework.GamerServices.GamerServicesComponent(this));
#endif

			// hook an event so we can see that it does fire
			saveDevice.SaveCompleted += new SaveCompletedEventHandler(saveDevice_SaveCompleted);

			base.Initialize();
		}
コード例 #6
0
        public void Initialize(Game game)
        {
            // create the save device
            SharedSaveDevice sharedSaveDevice = new SharedSaveDevice();
            game.Components.Add(sharedSaveDevice);
            saveDevice = sharedSaveDevice;

            // create event handlers that force the user to choose a new device
            // if they cancel the device selector, or it they disconnect the storage
            // device after selecting it
            sharedSaveDevice.DeviceSelectorCanceled += (s, e) => e.Response = SaveDeviceEventResponse.Nothing;
            sharedSaveDevice.DeviceDisconnected += (s, e) => e.Response = SaveDeviceEventResponse.Prompt;

            // prompt for a device on the first update we can
            sharedSaveDevice.PromptForDevice();

            #if XBOX
            game.Components.Add(new GamerServicesComponent(game));
            #endif

            saveDevice.SaveCompleted += new SaveCompletedEventHandler(saveDevice_SaveCompleted);
            saveDevice.LoadCompleted += new LoadCompletedEventHandler(saveDevice_LoadCompleted);
        }
        public override void LoadContent(ContentManager _content)
        {
            base.LoadContent(_content);
            TransitionOnTime = TimeSpan.FromSeconds(0f);
            TransitionOffTime = TimeSpan.FromSeconds(0f);
            LevelDataManager.UItextures.TryGetValue("Title", out menuTitleGraphic);
            isMenuTitleGraphic = true;
            menuTitleGraphicScale = 1.0f;

            textLength = ScreenManager.font.MeasureString(text) * textscale;

            video = LevelDataManager.tempContent.Load<Video>(@"Video\pw_intro2");
            player = new VideoPlayer();
            player.Play(video);

            // we can set our supported languages explicitly or we can allow the
            // game to support all the languages. the first language given will
            // be the default if the current language is not one of the supported
            // languages. this only affects the text found in message boxes shown
            // by EasyStorage and does not have any affect on the rest of the game.
            EasyStorageSettings.SetSupportedLanguages(Language.English, Language.French, Language.Spanish, Language.German, Language.Italian, Language.Japanese);
            // on Windows and Xbox 360, we use a save device that gets a
            //shared StorageDevice to handle our file IO.

            // create and add our SaveDevice
            sharedSaveDevice = new SharedSaveDevice();
            ScreenManager.Game.Components.Add(sharedSaveDevice);
            // make sure we hold on to the device
            saveDevice = sharedSaveDevice;
            LevelDataManager.SaveDevice = saveDevice;
            // 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
            sharedSaveDevice.DeviceSelectorCanceled +=
                (s, e) => e.Response = SaveDeviceEventResponse.Force;
            sharedSaveDevice.DeviceDisconnected +=
                (s, e) => e.Response = SaveDeviceEventResponse.Force;

            #if XBOX
            // add the GamerServicesComponent
            ScreenManager.Game.Components.Add(
                new Microsoft.Xna.Framework.GamerServices.GamerServicesComponent(ScreenManager.Game));
            #endif

            sharedSaveDevice.DeviceSelected += (s, e) =>
            {
                LoadOptions();
                LevelDataManager.ReadSaveGameData();
                isPrompt = true;
            };
        }
コード例 #8
0
        /// <summary>
        /// Initialize required components for saving game.
        /// This method is not called at the same moment if you're on PC or Xbox
        /// </summary>
        public void InitSaveDevice()
        {
            #if XBOX
            EasyStorageSettings.SetSupportedLanguages(Language.French, Language.Spanish, Language.English, Language.German, Language.Japanese, Language.Italian);

            SharedSaveDevice sharedSaveDevice = new SharedSaveDevice();
            Components.Add(sharedSaveDevice);

            TGPAContext.Instance.SaveDevice = sharedSaveDevice;

            sharedSaveDevice.DeviceSelectorCanceled += (s, e) => e.Response = SaveDeviceEventResponse.Force;
            sharedSaveDevice.DeviceDisconnected += (s, e) => e.Response = SaveDeviceEventResponse.Force;
            sharedSaveDevice.DeviceSelected += new EventHandler<EventArgs>(DeviceSelectedEventResponse);

            sharedSaveDevice.PromptForDevice();
            #else
            context.Saver.Load();
            #endif
        }