Added setup system. Changed reader and writer for texture atlas and nine patch to have image and serialized data be in same file. Some refactors occurred as well.
This commit is contained in:
@@ -65,10 +65,11 @@ namespace RecrownedAthenaeum.SpecialTypes
|
||||
/// Creates or obtains a previously created texture of a region.
|
||||
/// </summary>
|
||||
/// <param name="name">Name of region.</param>
|
||||
/// <param name="graphicsDevice">graphics device to be used.</param>
|
||||
/// <param name="graphicsDevice">graphics device to be used. Default is null and will resort to using graphics device from <see cref="Setup"/>'s graphics device manager.</param>
|
||||
/// <returns>The texture from the region.</returns>
|
||||
public Texture2D ObtainRegionAsTexture(string name, GraphicsDevice graphicsDevice)
|
||||
public Texture2D ObtainRegionAsTexture(string name, GraphicsDevice graphicsDevice = null)
|
||||
{
|
||||
if (graphicsDevice == null) graphicsDevice = Setup.graphicsDeviceManager.GraphicsDevice;
|
||||
return dictionaryOfRegions[name].AsTexture2D(graphicsDevice);
|
||||
}
|
||||
|
||||
@@ -174,15 +175,16 @@ namespace RecrownedAthenaeum.SpecialTypes
|
||||
/// <summary>
|
||||
/// Create or obtains a previously created texture of this region.
|
||||
/// </summary>
|
||||
/// <param name="graphicsDevice">The graphics device to use to create the texture.</param>
|
||||
/// <param name="graphicsDevice">The graphics device to use to create the texture. Will use graphics device from <see cref="Setup"/>'s graphics device manager if left to null.</param>
|
||||
/// <returns>The texture of the region.</returns>
|
||||
public Texture2D AsTexture2D(GraphicsDevice graphicsDevice)
|
||||
public Texture2D AsTexture2D(GraphicsDevice graphicsDevice = null)
|
||||
{
|
||||
if (Disposed) throw new ObjectDisposedException(GetType().Name);
|
||||
|
||||
if (regionTexture == null)
|
||||
{
|
||||
Color[] data = new Color[sourceRectangle.Width * sourceRectangle.Height];
|
||||
if (graphicsDevice == null) graphicsDevice = Setup.graphicsDeviceManager.GraphicsDevice;
|
||||
regionTexture = new Texture2D(graphicsDevice, sourceRectangle.Width, sourceRectangle.Height);
|
||||
atlasTexture.GetData(0, sourceRectangle, data, 0, sourceRectangle.Width * sourceRectangle.Height);
|
||||
regionTexture.SetData(data);
|
||||
|
||||
Reference in New Issue
Block a user