Skip to content

Instantly share code, notes, and snippets.

@CartBlanche
Created July 15, 2011 23:51
Show Gist options
  • Save CartBlanche/1085798 to your computer and use it in GitHub Desktop.
Save CartBlanche/1085798 to your computer and use it in GitHub Desktop.
Default Pths
protected virtual void LoadContent()
{
var model = UIDevice.CurrentDevice.Model;
string suffix = "";
if ( model.ToLower().Contains("iphone") )
{
suffix = "~iphone";
}
else if ( model.ToLower().Contains("ipad") )
{
suffix = "~ipad";
}
string DefaultPath = string.Format("Default{0}.png", suffix);
bool filefound = false;
if (File.Exists(DefaultPath))
{
filefound = true;
}
else if (File.Exists("Default.png"))
{
DefaultPath = "Default.png";
filefound = true;
}
if (filefound)
{
// Store the RootDir for later
string backup = Content.RootDirectory;
try
{
// Clear the RootDirectory for this operation
Content.RootDirectory = string.Empty;
spriteBatch = new SpriteBatch(GraphicsDevice);
splashScreen = Content.Load<Texture2D>(DefaultPath);
}
finally
{
// Reset RootDir
Content.RootDirectory = backup;
}
}
else
{
spriteBatch = null;
splashScreen = null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment