From a595ed8d9fbe6ff4a7a6f13c279b5412aeb41ab4 Mon Sep 17 00:00:00 2001 From: LawnCable Date: Fri, 15 Apr 2022 08:37:05 +0200 Subject: layer tiles, draft for object parsing and more --- src/lowlevel/objects.draft.rs | 92 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 src/lowlevel/objects.draft.rs (limited to 'src/lowlevel/objects.draft.rs') diff --git a/src/lowlevel/objects.draft.rs b/src/lowlevel/objects.draft.rs new file mode 100644 index 0000000..9416e27 --- /dev/null +++ b/src/lowlevel/objects.draft.rs @@ -0,0 +1,92 @@ +enum TextHAlign { + Left, + Center, + Right, + Justify, +} + +impl Default for TextHAlign { + fn default() -> Self { + TextHAlign::Left + } +} + +enum TextVAlign { + Top, + Center, + Bottom, +} + +impl Default for TextVAlign { + fn default() -> Self { + TextVAlign::Top + } +} + +enum Object { + Tile { + gid: usize, + }, + Ellipse, + Point, + Polygon { + points: Vec<(i64, i64)>, + }, + Polyline { + points: Vec<(i64, i64)>, + }, + Text { + /// The font family used (defaults to “sans-serif”) + fonfamily: String, + /// The size of the font in pixels (not using points, because other sizes in the TMX format are also using pixels) (defaults to 16) + pixelsize: u32, + + /// Whether word wrapping is enabled (1) or disabled (0). (defaults to 0) + wrap: bool, + + /// Color of the text in #AARRGGBB or #RRGGBB format (defaults to #000000) + color: rgb::RGBA8, + + /// Whether the font is bold (1) or not (0). (defaults to 0) + bold: bool, + /// Whether the font is italic (1) or not (0). (defaults to 0) + italic: bool, + /// Whether a line should be drawn below the text (1) or not (0). (defaults to 0) + underline: bool, + /// Whether a line should be drawn through the text (1) or not (0). (defaults to 0) + strikeout: bool, + /// Whether kerning should be used while rendering the text (1) or not (0). (defaults to 1) + kerning: bool, + + /// Horizontal alignment of the text within the object ( left, center, right or justify, defaults to left) (since Tiled 1.2.1) + halign: TextHAlign, + /// Vertical alignment of the text within the object ( top, center or bottom, defaults to top) + valign: TextVAlign, + }, +} + +struct BaseObject { + object: Object, + /// Unique ID of the object. Each object that is placed on a map gets a unique id. Even if an object was deleted, no object gets the same ID. Can not be changed in Tiled. (since Tiled 0.11) + id: usize, + /// The name of the object. An arbitrary string. (defaults to “”) + name: String, + /// The type of the object. An arbitrary string. (defaults to “”) + r#type: String, + /// The x coordinate of the object in pixels. (defaults to 0) + x: u64, + /// The y coordinate of the object in pixels. (defaults to 0) + y: u64, + /// The width of the object in pixels. (defaults to 0) + width: u64, + /// The height of the object in pixels. (defaults to 0) + height: u64, + /// The rota�on of the object in degrees clockwise around (x, y). (defaults to 0) + rotation: ?, + /// Whether the object is shown (1) or hidden (0). (defaults to 1) + visible: bool, + /// A reference to a template file. (op�onal) + template: Option +} + +// todo ask in tiled discord if representation is ok -- cgit v1.2.3-60-g2f50