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

@ -29,11 +29,12 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
*****************************************************************************/
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) {
@ -270,4 +278,4 @@ namespace Spine {
void Load (AtlasPage page, String path);
void Unload (Object texture);
}
}
}

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

@ -29,8 +29,8 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
*****************************************************************************/
using System;
using System.IO;
using Microsoft.Xna.Framework;
@ -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) {
@ -74,4 +81,4 @@ namespace Spine {
return Texture2D.FromStream(device, input);
}
}
}
}