preferences now use object as type for serialization and no longer uses marker interface.
This commit is contained in:
parent
151480eaee
commit
87823b26d6
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace RecrownedAthenaeum.Pipeline.NinePatch
|
||||
{
|
||||
class NinePatchTemplate
|
||||
class NinePatchFile
|
||||
{
|
||||
public string name;
|
||||
public string bounds;
|
||||
|
@ -11,13 +11,13 @@ using System.Xml.Serialization;
|
||||
|
||||
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
||||
{
|
||||
internal class TextureAtlasImporter : ContentImporter<TextureAtlasTemplate>
|
||||
internal class TextureAtlasImporter : ContentImporter<TextureAtlasFile>
|
||||
{
|
||||
public override TextureAtlasTemplate Import(string filename, ContentImporterContext context)
|
||||
public override TextureAtlasFile Import(string filename, ContentImporterContext context)
|
||||
{
|
||||
StreamReader stream = new StreamReader(filename);
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(TextureAtlasTemplate));
|
||||
TextureAtlasTemplate atlas = (TextureAtlasTemplate)serializer.Deserialize(stream);
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(TextureAtlasFile));
|
||||
TextureAtlasFile atlas = (TextureAtlasFile)serializer.Deserialize(stream);
|
||||
context.AddDependency(atlas.textureName);
|
||||
stream.Dispose();
|
||||
return atlas;
|
||||
|
@ -10,10 +10,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
||||
{
|
||||
class TextureAtlasProcessor : ContentProcessor<TextureAtlasTemplate, TextureAtlasTemplate>
|
||||
class TextureAtlasProcessor : ContentProcessor<TextureAtlasFile, TextureAtlasFile>
|
||||
{
|
||||
|
||||
public override TextureAtlasTemplate Process(TextureAtlasTemplate input, ContentProcessorContext context)
|
||||
public override TextureAtlasFile Process(TextureAtlasFile input, ContentProcessorContext context)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ using System.Xml.Serialization;
|
||||
|
||||
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
||||
{
|
||||
public class TextureAtlasTemplate
|
||||
public class TextureAtlasFile
|
||||
{
|
||||
public string textureName;
|
||||
public TextureAtlasRegion[] regions;
|
||||
|
@ -8,14 +8,14 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
||||
{
|
||||
class TextureAtlasWriter : ContentTypeWriter<TextureAtlasTemplate>
|
||||
class TextureAtlasWriter : ContentTypeWriter<TextureAtlasFile>
|
||||
{
|
||||
public override string GetRuntimeReader(TargetPlatform targetPlatform)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void Write(ContentWriter output, TextureAtlasTemplate value)
|
||||
protected override void Write(ContentWriter output, TextureAtlasFile value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -35,13 +35,20 @@ namespace RecrownedAthenaeum.DataTypes
|
||||
return dictionaryOfRegions[name].AsTexture2D(graphicsDevice, texture);
|
||||
}
|
||||
|
||||
public struct TextureAtlasRegion : IComparable<TextureAtlasRegion>, IDisposable
|
||||
public class TextureAtlasRegion : IComparable<TextureAtlasRegion>, IDisposable
|
||||
{
|
||||
public string name;
|
||||
Rectangle sourceRectangle;
|
||||
NinePatch ninepatch;
|
||||
public readonly string name;
|
||||
readonly Rectangle sourceRectangle;
|
||||
readonly NinePatch ninepatch;
|
||||
Texture2D regionTexture;
|
||||
|
||||
public TextureAtlasRegion(string name, Rectangle source, NinePatch ninePatch)
|
||||
{
|
||||
this.name = name;
|
||||
this.sourceRectangle = source;
|
||||
this.ninepatch = ninePatch;
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch batch, Rectangle destination, Texture2D fromTexture, Color color, float rotation, Vector2 origin)
|
||||
{
|
||||
batch.Draw(fromTexture, destination, sourceRectangle, color, rotation, origin, SpriteEffects.None, 0f);
|
||||
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace RecrownedAthenaeum.Persistence
|
||||
{
|
||||
public interface Preferences
|
||||
{
|
||||
}
|
||||
}
|
@ -8,15 +8,15 @@ namespace RecrownedAthenaeum.Persistence
|
||||
{
|
||||
public class PreferencesManager
|
||||
{
|
||||
private readonly Dictionary<Type, Preferences> preferenceList;
|
||||
private readonly Dictionary<Type, object> preferenceList;
|
||||
string savePath;
|
||||
XmlSerializer xmlSerializer;
|
||||
|
||||
public PreferencesManager(string savePath, params Preferences[] preferences)
|
||||
public PreferencesManager(string savePath, params object[] preferences)
|
||||
{
|
||||
this.savePath = savePath;
|
||||
Directory.CreateDirectory(savePath);
|
||||
preferenceList = new Dictionary<Type, Preferences>();
|
||||
preferenceList = new Dictionary<Type, object>();
|
||||
Debug.WriteLine("Preference manager setting up...");
|
||||
Type[] preferenceTypes = new Type[preferences.Length];
|
||||
for (int prefID = 0; prefID < preferences.Length; prefID++)
|
||||
@ -26,10 +26,10 @@ namespace RecrownedAthenaeum.Persistence
|
||||
Debug.WriteLine(preferences[prefID] + " added to list of preferences");
|
||||
}
|
||||
|
||||
xmlSerializer = new XmlSerializer(typeof(Preferences), preferenceTypes);
|
||||
xmlSerializer = new XmlSerializer(typeof(object), preferenceTypes);
|
||||
}
|
||||
|
||||
public T GetPreferences<T>() where T : Preferences
|
||||
public T GetPreferences<T>()
|
||||
{
|
||||
return (T)preferenceList[typeof(T)];
|
||||
}
|
||||
@ -49,7 +49,7 @@ namespace RecrownedAthenaeum.Persistence
|
||||
|
||||
public void Save()
|
||||
{
|
||||
foreach (KeyValuePair<Type, Preferences> prefs in preferenceList)
|
||||
foreach (KeyValuePair<Type, object> prefs in preferenceList)
|
||||
{
|
||||
SaveSpecific(prefs.Key);
|
||||
}
|
||||
@ -61,7 +61,7 @@ namespace RecrownedAthenaeum.Persistence
|
||||
if (File.Exists(path))
|
||||
{
|
||||
Stream stream = new FileStream(path, FileMode.Open);
|
||||
preferenceList[preference] = (Preferences)xmlSerializer.Deserialize(stream);
|
||||
preferenceList[preference] = xmlSerializer.Deserialize(stream);
|
||||
stream.Close();
|
||||
return true;
|
||||
}
|
||||
|
@ -64,7 +64,6 @@
|
||||
<Compile Include="obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs" />
|
||||
<Compile Include="obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs" />
|
||||
<Compile Include="ParticleSystem\Particle.cs" />
|
||||
<Compile Include="Persistence\Preferences.cs" />
|
||||
<Compile Include="Persistence\PreferencesManager.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ScreenSystem\ITransition.cs" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user