//-----------------------------------------------------------------------------
// LoadingScreen.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
using System;
using System.Threading;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
namespace AlienGameSample
{
///
/// This just loads all content we're going to use on a background thread. It doesn't
/// draw anything because it's supposed to be invoked in front of the background screen and right
/// before the main menu (i.e. noone will notice). This saves us from spinning up the drive later
/// and stalling between menu and gameplay.
///
class LoadingScreen : GameScreen
{
private Thread backgroundThread;
///
/// The constructor is private: loading screens should
/// be activated via the static Load method instead.
///
public LoadingScreen()
{
TransitionOnTime = TimeSpan.FromSeconds(0.0);
TransitionOffTime = TimeSpan.FromSeconds(0.0);
}
public override void LoadContent()
{
// Create the thread here (instead of the ctor), so we can guarantee that loading content will work
if (backgroundThread == null)
{
backgroundThread = new Thread(BackgroundLoadContent);
backgroundThread.Start();
}
base.LoadContent();
}
void BackgroundLoadContent()
{
// First thing we need to do is get a valid storage device for loading and saving
// high scores. Since this is a background thread, we can block on it; rendering the guide
// for Xbox 360 will happen on the main thread.
StorageDevice device = StorageDevice.ShowStorageDeviceGuide();
ScreenManager.Game.Services.AddService(typeof(StorageDevice), device);
/*ScreenManager.Game.Content.Load