Files
MonoGame.Extended/Source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectContent.cs
T
Dylan Wilson e962cec448 A mix between Tiled and GUI stuff (#553)
* mostly restored the tiled importer unit tests

* code cleanup

* code cleanup

* almost got tiled maps serialization independent of the content pipeline

* refactored the tiled map content importer so that tiled maps can be loaded at runtime

* code cleanup

* removed nuspec files

* experimenting with an XML based GUI markup parser

* a few more markup parser features

* finally got a working open file dialog

* experimenting with markup bindings

* attached properties

* working on the gui stuff again

* working on a better textbox

* multiline textboxing

* new text box is really coming along

* removed the content explorer experiment

* restored the old gui demo back to the way it was before (for now)
2018-10-09 22:18:48 +10:00

74 lines
2.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Xml.Serialization;
namespace MonoGame.Extended.Tiled.Serialization
{
// This content class is going to be a lot more complex than the others we use.
// Objects can reference a template file which has starting values for the
// object. The value in the object file overrides any value specified in the
// template. All values have to be able to store a null value so we know if the
// XML parser actually found a value for the property and not just a default
// value. Default values are used when the object and any templates don't
// specify a value.
public class TiledMapObjectContent
{
// TODO: HACK These shouldn't be public
public uint? _globalIdentifier;
public int? _identifier;
public float? _height;
public float? _rotation;
public bool? _visible;
public float? _width;
public float? _x;
public float? _y;
[XmlAttribute(DataType = "int", AttributeName = "id")]
public int Identifier { get => _identifier ?? 0; set => _identifier = value; }
[XmlAttribute(DataType = "string", AttributeName = "name")]
public string Name { get; set; }
[XmlAttribute(DataType = "string", AttributeName = "type")]
public string Type { get; set; }
[XmlAttribute(DataType = "float", AttributeName = "x")]
public float X { get => _x ?? 0; set => _x = value; }
[XmlAttribute(DataType = "float", AttributeName = "y")]
public float Y { get => _y ?? 0; set => _y = value; }
[XmlAttribute(DataType = "float", AttributeName = "width")]
public float Width { get => _width ?? 0; set => _width = value; }
[XmlAttribute(DataType = "float", AttributeName = "height")]
public float Height { get => _height ?? 0; set => _height = value; }
[XmlAttribute(DataType = "float", AttributeName = "rotation")]
public float Rotation { get => _rotation ?? 0; set => _rotation = value; }
[XmlAttribute(DataType = "boolean", AttributeName = "visible")]
public bool Visible { get => _visible ?? true; set => _visible = value; }
[XmlArray("properties")]
[XmlArrayItem("property")]
public List<TiledMapPropertyContent> Properties { get; set; }
[XmlAttribute(DataType = "unsignedInt", AttributeName = "gid")]
public uint GlobalIdentifier { get => _globalIdentifier??0; set => _globalIdentifier = value; }
[XmlElement(ElementName = "ellipse")]
public TiledMapEllipseContent Ellipse { get; set; }
[XmlElement(ElementName = "polygon")]
public TiledMapPolygonContent Polygon { get; set; }
[XmlElement(ElementName = "polyline")]
public TiledMapPolylineContent Polyline { get; set; }
[XmlAttribute(DataType = "string", AttributeName = "template")]
public string TemplateSource { get; set; }
}
}