Start of transition to OTK
This commit is contained in:
parent
c04f2f1b78
commit
9387611b19
@ -3,7 +3,6 @@
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MonoGame.Framework.Content.Pipeline.Portable" Version="3.7.1.189" PrivateAssets="All"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\RecrownedAthenaeum\RecrownedAthenaeum.csproj" PrivateAssets="All"/>
|
||||
|
@ -1,16 +0,0 @@
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using RecrownedAthenaeum.SpecialTypes;
|
||||
|
||||
namespace RecrownedAthenaeum.ContentReaders
|
||||
{
|
||||
class NinePatchDataReader : ContentTypeReader<NinePatch>
|
||||
{
|
||||
protected override NinePatch Read(ContentReader input, NinePatch existingInstance)
|
||||
{
|
||||
Texture2D texture = input.ContentManager.Load<Texture2D>(input.ReadString());
|
||||
NinePatch ninePatch = new NinePatch(texture, input.ReadInt32(), input.ReadInt32(), input.ReadInt32(), input.ReadInt32());
|
||||
return ninePatch;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using RecrownedAthenaeum.Data;
|
||||
using RecrownedAthenaeum.SpecialTypes;
|
||||
using System.IO;
|
||||
|
||||
namespace RecrownedAthenaeum.ContentReaders
|
||||
{
|
||||
class TextureAtlasDataReader : ContentTypeReader<TextureAtlas>
|
||||
{
|
||||
protected override TextureAtlas Read(ContentReader input, TextureAtlas existingInstance)
|
||||
{
|
||||
TextureAtlasData atlasData = ReadTextureAtlasData(input);
|
||||
Texture2D atlasTexture = input.ContentManager.Load<Texture2D>(atlasData.textureName);
|
||||
|
||||
TextureAtlas atlas = new TextureAtlas(atlasTexture, GenerateAtlasRegionsFromData(atlasData, atlasTexture));
|
||||
|
||||
return atlas;
|
||||
}
|
||||
|
||||
public TextureAtlasData ReadTextureAtlasData(BinaryReader reader)
|
||||
{
|
||||
string textureName = reader.ReadString();
|
||||
TextureAtlasData.AtlasRegionData[] regions = new TextureAtlasData.AtlasRegionData[reader.ReadInt32()];
|
||||
for (int i = 0; i < regions.Length; i++)
|
||||
{
|
||||
regions[i] = new TextureAtlasData.AtlasRegionData();
|
||||
regions[i].name = reader.ReadString();
|
||||
regions[i].bounds = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());
|
||||
if (reader.ReadBoolean())
|
||||
{
|
||||
regions[i].ninePatchData = new NinePatchData(null, reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());
|
||||
}
|
||||
}
|
||||
|
||||
TextureAtlasData atlasData = new TextureAtlasData(textureName, regions);
|
||||
|
||||
return atlasData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates region given <see cref="TextureAtlasData"/>.
|
||||
/// </summary>
|
||||
/// <param name="textureAtlasData">The data to generate the regions from.</param>
|
||||
/// <param name="atlasTexture">The texture containing the atlas.</param>
|
||||
/// <returns>An array of regions.</returns>
|
||||
public TextureAtlas.Region[] GenerateAtlasRegionsFromData(TextureAtlasData textureAtlasData, Texture2D atlasTexture)
|
||||
{
|
||||
TextureAtlas.Region[] regions = new TextureAtlas.Region[textureAtlasData.regions.Length];
|
||||
for (int regionID = 0; regionID < regions.Length; regionID++)
|
||||
{
|
||||
TextureAtlasData.AtlasRegionData regionData = textureAtlasData.regions[regionID];
|
||||
NinePatch nPatch = null;
|
||||
if (regionData.ninePatchData != null)
|
||||
{
|
||||
NinePatchData nPatchData = regionData.ninePatchData;
|
||||
nPatch = new NinePatch(atlasTexture, nPatchData.left, nPatchData.right, nPatchData.bottom, nPatchData.bottom, regionData.bounds);
|
||||
}
|
||||
regions[regionID] = new TextureAtlas.Region(regionData.name, regionData.bounds, nPatch, atlasTexture);
|
||||
}
|
||||
|
||||
return regions;
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ namespace RecrownedAthenaeum.ContentSystem
|
||||
/// <summary>
|
||||
/// Wrapper for the content manager that helps with controlling it by adding automated multithreaded content loading.
|
||||
/// </summary>
|
||||
public class ContentManagerController
|
||||
public class AssetManager
|
||||
{
|
||||
Thread thread;
|
||||
readonly ContentManager contentManager;
|
||||
@ -40,7 +40,7 @@ namespace RecrownedAthenaeum.ContentSystem
|
||||
/// Wraps the <see cref="ContentManager"/>.
|
||||
/// </summary>
|
||||
/// <param name="contentManager">The manager to wrap.</param>
|
||||
public ContentManagerController(ContentManager contentManager)
|
||||
public AssetManager()
|
||||
{
|
||||
this.contentManager = contentManager;
|
||||
assets = new Dictionary<string, Object>();
|
||||
|
@ -1,7 +1,7 @@
|
||||
namespace RecrownedAthenaeum.ContentSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// Modifies the given path based on a name. Used to simplify long paths for the <see cref="ContentManagerController"/>
|
||||
/// Modifies the given path based on a name. Used to simplify long paths for the <see cref="AssetManager"/>
|
||||
/// </summary>
|
||||
public interface IContentPathResolver
|
||||
{
|
||||
|
@ -4,6 +4,6 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3"/>
|
||||
<PackageReference Include="MonoGame.Framework.Portable" Version="3.6.0.1625" PrivateAssets="All"/>
|
||||
<PackageReference Include="OpenTK" Version="3.1.0"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -15,7 +15,7 @@ namespace RecrownedAthenaeum.UI.BookSystem
|
||||
/// </summary>
|
||||
public class Book : IInputListener
|
||||
{
|
||||
readonly ContentManagerController assets;
|
||||
readonly AssetManager assets;
|
||||
readonly ISkin skin;
|
||||
Page targetPage;
|
||||
int width, height;
|
||||
@ -31,10 +31,10 @@ namespace RecrownedAthenaeum.UI.BookSystem
|
||||
/// <summary>
|
||||
/// Creates a book.
|
||||
/// </summary>
|
||||
/// <param name="assets"><see cref="ContentManagerController"/> that holds the assets that are to be used in the pages for this book during initialization.</param>
|
||||
/// <param name="assets"><see cref="AssetManager"/> that holds the assets that are to be used in the pages for this book during initialization.</param>
|
||||
/// <param name="skin">The skin that will be passed to pages during their initialization.</param>
|
||||
/// <param name="camera">Camera to move to change pages.</param>
|
||||
public Book(ContentManagerController assets, ISkin skin, Camera2D camera)
|
||||
public Book(AssetManager assets, ISkin skin, Camera2D camera)
|
||||
{
|
||||
this.assets = assets;
|
||||
this.skin = skin;
|
||||
|
@ -49,7 +49,7 @@ namespace RecrownedAthenaeum.UI.BookSystem
|
||||
/// <param name="assets">The assets to be used during initialization passed by the book this page belongs to.</param>
|
||||
/// <param name="skin">The skin the book containing this page is given that can be used by this page.</param>
|
||||
/// <param name="basicScissor">The scissor box to use for cropping.</param>
|
||||
protected internal virtual void Initialize(ContentManagerController assets, ISkin skin, BasicScissor basicScissor)
|
||||
protected internal virtual void Initialize(AssetManager assets, ISkin skin, BasicScissor basicScissor)
|
||||
{
|
||||
this.basicScissor = basicScissor;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user