AxiosEngine-old 

AxiosEngine-old Commit Details


Date:2012-05-12 17:45:00 (12 years 7 months ago)
Author:Natalie Adams
Branch:default
Commit:746146cbe176
Parents: ffcca9881813
Message:Adding a cache for loading in textures

Splitting the code for Gleed2D into seperate files
Changes:
Maxios/Axios_settings.cs (1 diff)
Maxios/Engine/Glee2D/CircleItem.cs (1 diff)
Maxios/Engine/Glee2D/Item.cs (1 diff)
Maxios/Engine/Glee2D/Level.cs (3 diffs)
Maxios/Engine/Glee2D/PathItem.cs (1 diff)
Maxios/Engine/Glee2D/RectangleItem.cs (1 diff)
Maxios/Engine/Glee2D/TextureItem.cs (2 diffs)

File differences

axios/Axios_settings.cs
6969
7070
7171
72
72
73
74
7375
7476
7577
* - Adding SplitFlat extension for Texture2D
* - Removing uneeded Game Screen checking code
* - Adding SplitFlat extension with offsets for Texture2D
* - Adding support for Glee2D
* - Adding support for Gleed2D
* - Splitting the code for Gleed2D into seperate files
* - Adding a cache for loading in textures for Gleed2D
*
*/
axios/Engine/Glee2D/CircleItem.cs
2323
2424
2525
26
26
2727
28
28
2929
3030
3131
{
}
public override void load(ContentManager cm, World world)
public override void load(ContentManager cm, World world, ref Dictionary<string, Texture2D> cache)
{
base.load(cm, world);
base.load(cm, world, ref cache);
_body = BodyFactory.CreateCircle(world, Radius, 1f);
_body.Position = Position;
axios/Engine/Glee2D/Item.cs
4949
5050
5151
52
52
5353
5454
5555
/// Called by Level.FromFile(filename) on each Item after the deserialization process.
/// Should be overriden and can be used to load anything needed by the Item (e.g. a texture).
/// </summary>
public virtual void load(ContentManager cm, World world)
public virtual void load(ContentManager cm, World world, ref Dictionary<string, Texture2D> cache)
{
}
axios/Engine/Glee2D/Level.cs
3838
3939
4040
41
42
4143
4244
4345
4446
4547
4648
49
4750
4851
4952
......
5255
5356
5457
58
5559
5660
57
61
5862
5963
6064
......
6670
6771
6872
69
73
7074
7175
7276
/// </summary>
public SerializableDictionary CustomProperties;
private Dictionary<string, Texture2D> _texturecache;
public Level()
{
Visible = true;
Layers = new List<Layer>();
CustomProperties = new SerializableDictionary();
_texturecache = new Dictionary<string, Texture2D>();
}
public Level(World world)
Layers = new List<Layer>();
CustomProperties = new SerializableDictionary();
_world = world;
_texturecache = new Dictionary<string, Texture2D>();
}
public static Level FromFile(string filename, ContentManager cm, World world)
public static Level FromFile(string filename, ContentManager cm, World world, ref Dictionary<string, Texture2D> cache)
{
FileStream stream = System.IO.File.Open(filename, FileMode.Open);
XmlSerializer serializer = new XmlSerializer(typeof(Level));
foreach (Item item in layer.Items)
{
item.CustomProperties.RestoreItemAssociations(level);
item.load(cm, world);
item.load(cm, world, ref cache);
}
}
axios/Engine/Glee2D/PathItem.cs
2626
2727
2828
29
29
3030
31
31
3232
3333
3434
{
}
public override void load(ContentManager cm, World world)
public override void load(ContentManager cm, World world, ref Dictionary<string, Texture2D> cache)
{
base.load(cm, world);
base.load(cm, world, ref cache);
Vertices v = new Vertices(WorldPoints.Length);
foreach (Vector2 vec in WorldPoints)
axios/Engine/Glee2D/RectangleItem.cs
2424
2525
2626
27
27
2828
29
29
3030
3131
3232
{
}
public override void load(ContentManager cm, World world)
public override void load(ContentManager cm, World world, ref Dictionary<string, Texture2D> cache)
{
base.load(cm, world);
base.load(cm, world, ref cache);
_body = BodyFactory.CreateRectangle(world, Width, Height, 1f);
_body.Position = Position;
axios/Engine/Glee2D/TextureItem.cs
7777
7878
7979
80
80
8181
8282
8383
......
8585
8686
8787
88
88
89
90
91
92
93
8994
9095
9196
/// You must provide your own implementation. However, you can rely on all public fields being
/// filled by the level deserialization process.
/// </summary>
public override void load(ContentManager cm, World world)
public override void load(ContentManager cm, World world, ref Dictionary<string, Texture2D> cache)
{
//throw new NotImplementedException();
//for example:
//this.texture = Texture2D.FromFile(<GraphicsDevice>, texture_filename);
//or by using the Content Pipeline:
this.texture = cm.Load<Texture2D>(asset_name);
if (!cache.ContainsKey(asset_name))
{
cache[asset_name] = cm.Load<Texture2D>(asset_name);
}
this.texture = cache[asset_name];
//this.texture = cm.Load<Texture2D>(asset_name);
}

Archive Download the corresponding diff file

Page rendered in 0.70638s using 14 queries.