Fixed file loading for XNA on Windows Phone 7.

This commit is contained in:
Liquidoodle 2013-10-10 18:02:50 +01:00
parent f3be613429
commit b51a110c54
3 changed files with 31 additions and 10 deletions

View File

@ -34,6 +34,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
#if WINDOWS_STOREAPP
using System.Threading.Tasks;
@ -64,7 +65,14 @@ namespace Spine {
}
#else
public Atlas (String path, TextureLoader textureLoader) {
using (StreamReader reader = new StreamReader(path)) {
#if WINDOWS_PHONE
Stream stream = Microsoft.Xna.Framework.TitleContainer.OpenStream(path);
using (StreamReader reader = new StreamReader(stream))
{
#else
using (StreamReader reader = new StreamReader(path)) {
#endif
try {
Load(reader, Path.GetDirectoryName(path), textureLoader);
} catch (Exception ex) {

View File

@ -80,8 +80,14 @@ namespace Spine {
}
#else
public SkeletonData ReadSkeletonData (String path) {
using (StreamReader reader = new StreamReader(path)) {
SkeletonData skeletonData = ReadSkeletonData(reader);
#if WINDOWS_PHONE
Stream stream = Microsoft.Xna.Framework.TitleContainer.OpenStream(path);
using (StreamReader reader = new StreamReader(stream))
{
#else
using (StreamReader reader = new StreamReader(path)) {
#endif
SkeletonData skeletonData = ReadSkeletonData(reader);
skeletonData.name = Path.GetFileNameWithoutExtension(path);
return skeletonData;
}

View File

@ -60,7 +60,14 @@ namespace Spine {
}
#else
static public Texture2D LoadTexture (GraphicsDevice device, String path) {
using (Stream input = new FileStream(path, FileMode.Open, FileAccess.Read)) {
#if WINDOWS_PHONE
Stream stream = Microsoft.Xna.Framework.TitleContainer.OpenStream(path);
using (Stream input = stream)
{
#else
using (Stream input = new FileStream(path, FileMode.Open, FileAccess.Read)) {
#endif
try {
return Util.LoadTexture(device, input);
} catch (Exception ex) {