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

View File

@ -80,7 +80,13 @@ namespace Spine {
} }
#else #else
public SkeletonData ReadSkeletonData (String path) { public SkeletonData ReadSkeletonData (String 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)) { using (StreamReader reader = new StreamReader(path)) {
#endif
SkeletonData skeletonData = ReadSkeletonData(reader); SkeletonData skeletonData = ReadSkeletonData(reader);
skeletonData.name = Path.GetFileNameWithoutExtension(path); skeletonData.name = Path.GetFileNameWithoutExtension(path);
return skeletonData; return skeletonData;

View File

@ -60,7 +60,14 @@ namespace Spine {
} }
#else #else
static public Texture2D LoadTexture (GraphicsDevice device, String path) { static public Texture2D LoadTexture (GraphicsDevice device, String path) {
#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)) { using (Stream input = new FileStream(path, FileMode.Open, FileAccess.Read)) {
#endif
try { try {
return Util.LoadTexture(device, input); return Util.LoadTexture(device, input);
} catch (Exception ex) { } catch (Exception ex) {