Jypeli  9
The simple game programming library
XnaSerialization.cs
Siirry tämän tiedoston dokumentaatioon.
1 using System;
2 using System.IO;
3 
4 #if WINRT
5 using Windows.Storage.Streams;
6 #endif
7 
8 namespace Jypeli
9 {
10  public partial class FileManager
11  {
12  public LoadState BeginLoadContent( string assetName )
13  {
14  if ( Game.Instance == null )
15  throw new InvalidOperationException( "Content can not be loaded here, because the game has not been initialized." );
16 
17  StorageFile contentFile = Game.Instance.Content.Load<StorageFile>( assetName );
18  return new LoadState( contentFile, assetName );
19  }
20 
21  public T LoadContent<T>( T obj, string assetName )
22  {
23  if ( Game.Instance == null )
24  throw new InvalidOperationException( "Content can not be loaded here, because the game has not been initialized." );
25 
26  byte[] contentData = Game.Instance.Content.Load<byte[]>( assetName );
27  MemoryStream contentStream = new MemoryStream( contentData );
28  StorageFile contentFile = new StorageFile( assetName, contentStream );
29 
30  LoadState state = BeginLoad( contentFile, assetName );
31  T result = state.Load<T>( obj, "default" );
32  state.EndLoad();
33  return result;
34  }
35  }
36 }
Jypeli.StorageFile
Tiedosto.
Definition: StorageFile.cs:17
Jypeli.LoadState
Definition: LoadState.cs:9
Jypeli
Definition: Automobile.cs:5
Jypeli.FileManager.BeginLoad
LoadState BeginLoad(string fileName)
Definition: Serialization.cs:8
Jypeli.Game.Instance
static Game Instance
Käynnissä olevan pelin pääolio.
Definition: Game.cs:90
Jypeli.LoadState.EndLoad
void EndLoad()
Definition: LoadState.cs:31
System
Definition: CFFauxAttributes.cs:29
Jypeli.LoadState.Load
object Load(object obj, Type type, string name)
Definition: LoadState.cs:90
Jypeli.Game
Definition: Content.cs:46
Jypeli.FileManager.BeginLoadContent
LoadState BeginLoadContent(string assetName)
Definition: XnaSerialization.cs:12
Jypeli.FileManager.LoadContent< T >
T LoadContent< T >(T obj, string assetName)
Definition: XnaSerialization.cs:21