comfy_ldtk/quicktype.rs
1// Version: 1.4.1
2// Example code that deserializes and serializes the model.
3// extern crate serde;
4// #[macro_use]
5// extern crate serde_derive;
6// extern crate serde_json;
7//
8// use generated_module::LdtkJson;
9//
10// fn main() {
11// let json = r#"{"answer": 42}"#;
12// let model: LdtkJson = serde_json::from_str(&json).unwrap();
13// }
14
15use serde::{Deserialize, Serialize};
16use std::collections::HashMap;
17
18/// This file is a JSON schema of files created by LDtk level editor <https://ldtk.io>.
19///
20/// This is the root of any Project JSON file. It contains: - the project settings, - an
21/// array of levels, - a group of definitions (that can probably be safely ignored for most
22/// users).
23#[derive(Debug, Clone, Serialize, Deserialize)]
24#[serde(rename_all = "camelCase")]
25pub struct LdtkJson {
26 /// This object is not actually used by LDtk. It ONLY exists to force explicit references to
27 /// all types, to make sure QuickType finds them and integrate all of them. Otherwise,
28 /// Quicktype will drop types that are not explicitely used.
29 #[serde(rename = "__FORCED_REFS")]
30 pub forced_refs: Option<ForcedRefs>,
31
32 /// LDtk application build identifier.<br/> This is only used to identify the LDtk version
33 /// that generated this particular project file, which can be useful for specific bug fixing.
34 /// Note that the build identifier is just the date of the release, so it's not unique to
35 /// each user (one single global ID per LDtk public release), and as a result, completely
36 /// anonymous.
37 pub app_build_id: f64,
38
39 /// Number of backup files to keep, if the `backupOnSave` is TRUE
40 pub backup_limit: i64,
41
42 /// If TRUE, an extra copy of the project will be created in a sub folder, when saving.
43 pub backup_on_save: bool,
44
45 /// Target relative path to store backup files
46 pub backup_rel_path: Option<String>,
47
48 /// Project background color
49 pub bg_color: String,
50
51 /// An array of command lines that can be ran manually by the user
52 pub custom_commands: Vec<LdtkCustomCommand>,
53
54 /// Default height for new entities
55 pub default_entity_height: i64,
56
57 /// Default width for new entities
58 pub default_entity_width: i64,
59
60 /// Default grid size for new layers
61 pub default_grid_size: i64,
62
63 /// Default background color of levels
64 pub default_level_bg_color: String,
65
66 /// **WARNING**: this field will move to the `worlds` array after the "multi-worlds" update.
67 /// It will then be `null`. You can enable the Multi-worlds advanced project option to enable
68 /// the change immediately.<br/><br/> Default new level height
69 pub default_level_height: Option<i64>,
70
71 /// **WARNING**: this field will move to the `worlds` array after the "multi-worlds" update.
72 /// It will then be `null`. You can enable the Multi-worlds advanced project option to enable
73 /// the change immediately.<br/><br/> Default new level width
74 pub default_level_width: Option<i64>,
75
76 /// Default X pivot (0 to 1) for new entities
77 pub default_pivot_x: f64,
78
79 /// Default Y pivot (0 to 1) for new entities
80 pub default_pivot_y: f64,
81
82 /// A structure containing all the definitions of this project
83 pub defs: Definitions,
84
85 /// If the project isn't in MultiWorlds mode, this is the IID of the internal "dummy" World.
86 pub dummy_world_iid: String,
87
88 /// If TRUE, the exported PNGs will include the level background (color or image).
89 pub export_level_bg: bool,
90
91 /// **WARNING**: this deprecated value is no longer exported since version 0.9.3 Replaced
92 /// by: `imageExportMode`
93 pub export_png: Option<bool>,
94
95 /// If TRUE, a Tiled compatible file will also be generated along with the LDtk JSON file
96 /// (default is FALSE)
97 pub export_tiled: bool,
98
99 /// If TRUE, one file will be saved for the project (incl. all its definitions) and one file
100 /// in a sub-folder for each level.
101 pub external_levels: bool,
102
103 /// An array containing various advanced flags (ie. options or other states). Possible
104 /// values: `DiscardPreCsvIntGrid`, `ExportPreCsvIntGridFormat`, `IgnoreBackupSuggest`,
105 /// `PrependIndexToLevelFileNames`, `MultiWorlds`, `UseMultilinesType`
106 pub flags: Vec<Flag>,
107
108 /// Naming convention for Identifiers (first-letter uppercase, full uppercase etc.) Possible
109 /// values: `Capitalize`, `Uppercase`, `Lowercase`, `Free`
110 pub identifier_style: IdentifierStyle,
111
112 /// Unique project identifier
113 pub iid: String,
114
115 /// "Image export" option when saving project. Possible values: `None`, `OneImagePerLayer`,
116 /// `OneImagePerLevel`, `LayersAndLevels`
117 pub image_export_mode: ImageExportMode,
118
119 /// File format version
120 pub json_version: String,
121
122 /// The default naming convention for level identifiers.
123 pub level_name_pattern: String,
124
125 /// All levels. The order of this array is only relevant in `LinearHorizontal` and
126 /// `linearVertical` world layouts (see `worldLayout` value).<br/> Otherwise, you should
127 /// refer to the `worldX`,`worldY` coordinates of each Level.
128 pub levels: Vec<Level>,
129
130 /// If TRUE, the Json is partially minified (no indentation, nor line breaks, default is
131 /// FALSE)
132 pub minify_json: bool,
133
134 /// Next Unique integer ID available
135 pub next_uid: i64,
136
137 /// File naming pattern for exported PNGs
138 pub png_file_pattern: Option<String>,
139
140 /// If TRUE, a very simplified will be generated on saving, for quicker & easier engine
141 /// integration.
142 pub simplified_export: bool,
143
144 /// All instances of entities that have their `exportToToc` flag enabled are listed in this
145 /// array.
146 pub toc: Vec<LdtkTableOfContentEntry>,
147
148 /// This optional description is used by LDtk Samples to show up some informations and
149 /// instructions.
150 pub tutorial_desc: Option<String>,
151
152 /// **WARNING**: this field will move to the `worlds` array after the "multi-worlds" update.
153 /// It will then be `null`. You can enable the Multi-worlds advanced project option to enable
154 /// the change immediately.<br/><br/> Height of the world grid in pixels.
155 pub world_grid_height: Option<i64>,
156
157 /// **WARNING**: this field will move to the `worlds` array after the "multi-worlds" update.
158 /// It will then be `null`. You can enable the Multi-worlds advanced project option to enable
159 /// the change immediately.<br/><br/> Width of the world grid in pixels.
160 pub world_grid_width: Option<i64>,
161
162 /// **WARNING**: this field will move to the `worlds` array after the "multi-worlds" update.
163 /// It will then be `null`. You can enable the Multi-worlds advanced project option to enable
164 /// the change immediately.<br/><br/> An enum that describes how levels are organized in
165 /// this project (ie. linearly or in a 2D space). Possible values: <`null`>, `Free`,
166 /// `GridVania`, `LinearHorizontal`, `LinearVertical`
167 pub world_layout: Option<WorldLayout>,
168
169 /// This array will be empty, unless you enable the Multi-Worlds in the project advanced
170 /// settings.<br/><br/> - in current version, a LDtk project file can only contain a single
171 /// world with multiple levels in it. In this case, levels and world layout related settings
172 /// are stored in the root of the JSON.<br/> - with "Multi-worlds" enabled, there will be a
173 /// `worlds` array in root, each world containing levels and layout settings. Basically, it's
174 /// pretty much only about moving the `levels` array to the `worlds` array, along with world
175 /// layout related values (eg. `worldGridWidth` etc).<br/><br/>If you want to start
176 /// supporting this future update easily, please refer to this documentation:
177 /// <https://github.com/deepnight/ldtk/issues/231>
178 pub worlds: Vec<World>,
179}
180
181#[derive(Debug, Clone, Serialize, Deserialize)]
182pub struct LdtkCustomCommand {
183 pub command: String,
184
185 /// Possible values: `Manual`, `AfterLoad`, `BeforeSave`, `AfterSave`
186 pub when: When,
187}
188
189/// Possible values: `Manual`, `AfterLoad`, `BeforeSave`, `AfterSave`
190#[derive(Debug, Clone, Serialize, Deserialize)]
191pub enum When {
192 #[serde(rename = "AfterLoad")]
193 AfterLoad,
194
195 #[serde(rename = "AfterSave")]
196 AfterSave,
197
198 #[serde(rename = "BeforeSave")]
199 BeforeSave,
200
201 Manual,
202}
203
204/// If you're writing your own LDtk importer, you should probably just ignore *most* stuff in
205/// the `defs` section, as it contains data that are mostly important to the editor. To keep
206/// you away from the `defs` section and avoid some unnecessary JSON parsing, important data
207/// from definitions is often duplicated in fields prefixed with a double underscore (eg.
208/// `__identifier` or `__type`). The 2 only definition types you might need here are
209/// **Tilesets** and **Enums**.
210///
211/// A structure containing all the definitions of this project
212#[derive(Debug, Clone, Serialize, Deserialize)]
213#[serde(rename_all = "camelCase")]
214pub struct Definitions {
215 /// All entities definitions, including their custom fields
216 pub entities: Vec<EntityDefinition>,
217
218 /// All internal enums
219 pub enums: Vec<EnumDefinition>,
220
221 /// Note: external enums are exactly the same as `enums`, except they have a `relPath` to
222 /// point to an external source file.
223 pub external_enums: Vec<EnumDefinition>,
224
225 /// All layer definitions
226 pub layers: Vec<LayerDefinition>,
227
228 /// All custom fields available to all levels.
229 pub level_fields: Vec<FieldDefinition>,
230
231 /// All tilesets
232 pub tilesets: Vec<TilesetDefinition>,
233}
234
235#[derive(Debug, Clone, Serialize, Deserialize)]
236#[serde(rename_all = "camelCase")]
237pub struct EntityDefinition {
238 /// Base entity color
239 pub color: String,
240
241 /// User defined documentation for this element to provide help/tips to level designers.
242 pub doc: Option<String>,
243
244 /// If enabled, all instances of this entity will be listed in the project "Table of content"
245 /// object.
246 pub export_to_toc: bool,
247
248 /// Array of field definitions
249 pub field_defs: Vec<FieldDefinition>,
250
251 pub fill_opacity: f64,
252
253 /// Pixel height
254 pub height: i64,
255
256 pub hollow: bool,
257
258 /// User defined unique identifier
259 pub identifier: String,
260
261 /// Only applies to entities resizable on both X/Y. If TRUE, the entity instance width/height
262 /// will keep the same aspect ratio as the definition.
263 pub keep_aspect_ratio: bool,
264
265 /// Possible values: `DiscardOldOnes`, `PreventAdding`, `MoveLastOne`
266 pub limit_behavior: LimitBehavior,
267
268 /// If TRUE, the maxCount is a "per world" limit, if FALSE, it's a "per level". Possible
269 /// values: `PerLayer`, `PerLevel`, `PerWorld`
270 pub limit_scope: LimitScope,
271
272 pub line_opacity: f64,
273
274 /// Max instances count
275 pub max_count: i64,
276
277 /// Max pixel height (only applies if the entity is resizable on Y)
278 pub max_height: Option<i64>,
279
280 /// Max pixel width (only applies if the entity is resizable on X)
281 pub max_width: Option<i64>,
282
283 /// Min pixel height (only applies if the entity is resizable on Y)
284 pub min_height: Option<i64>,
285
286 /// Min pixel width (only applies if the entity is resizable on X)
287 pub min_width: Option<i64>,
288
289 /// An array of 4 dimensions for the up/right/down/left borders (in this order) when using
290 /// 9-slice mode for `tileRenderMode`.<br/> If the tileRenderMode is not NineSlice, then
291 /// this array is empty.<br/> See: <https://en.wikipedia.org/wiki/9-slice_scaling>
292 pub nine_slice_borders: Vec<i64>,
293
294 /// Pivot X coordinate (from 0 to 1.0)
295 pub pivot_x: f64,
296
297 /// Pivot Y coordinate (from 0 to 1.0)
298 pub pivot_y: f64,
299
300 /// Possible values: `Rectangle`, `Ellipse`, `Tile`, `Cross`
301 pub render_mode: RenderMode,
302
303 /// If TRUE, the entity instances will be resizable horizontally
304 pub resizable_x: bool,
305
306 /// If TRUE, the entity instances will be resizable vertically
307 pub resizable_y: bool,
308
309 /// Display entity name in editor
310 pub show_name: bool,
311
312 /// An array of strings that classifies this entity
313 pub tags: Vec<String>,
314
315 /// **WARNING**: this deprecated value is no longer exported since version 1.2.0 Replaced
316 /// by: `tileRect`
317 pub tile_id: Option<i64>,
318
319 pub tile_opacity: f64,
320
321 /// An object representing a rectangle from an existing Tileset
322 pub tile_rect: Option<TilesetRectangle>,
323
324 /// An enum describing how the the Entity tile is rendered inside the Entity bounds. Possible
325 /// values: `Cover`, `FitInside`, `Repeat`, `Stretch`, `FullSizeCropped`,
326 /// `FullSizeUncropped`, `NineSlice`
327 pub tile_render_mode: TileRenderMode,
328
329 /// Tileset ID used for optional tile display
330 pub tileset_id: Option<i64>,
331
332 /// Unique Int identifier
333 pub uid: i64,
334
335 /// This tile overrides the one defined in `tileRect` in the UI
336 pub ui_tile_rect: Option<TilesetRectangle>,
337
338 /// Pixel width
339 pub width: i64,
340}
341
342/// This section is mostly only intended for the LDtk editor app itself. You can safely
343/// ignore it.
344#[derive(Debug, Clone, Serialize, Deserialize)]
345#[serde(rename_all = "camelCase")]
346pub struct FieldDefinition {
347 /// Human readable value type. Possible values: `Int, Float, String, Bool, Color,
348 /// ExternEnum.XXX, LocalEnum.XXX, Point, FilePath`.<br/> If the field is an array, this
349 /// field will look like `Array<...>` (eg. `Array<Int>`, `Array<Point>` etc.)<br/> NOTE: if
350 /// you enable the advanced option **Use Multilines type**, you will have "*Multilines*"
351 /// instead of "*String*" when relevant.
352 #[serde(rename = "__type")]
353 pub field_definition_type: String,
354
355 /// Optional list of accepted file extensions for FilePath value type. Includes the dot:
356 /// `.ext`
357 pub accept_file_types: Option<Vec<String>>,
358
359 /// Possible values: `Any`, `OnlySame`, `OnlyTags`, `OnlySpecificEntity`
360 pub allowed_refs: AllowedRefs,
361
362 pub allowed_refs_entity_uid: Option<i64>,
363
364 pub allowed_ref_tags: Vec<String>,
365
366 pub allow_out_of_level_ref: bool,
367
368 /// Array max length
369 pub array_max_length: Option<i64>,
370
371 /// Array min length
372 pub array_min_length: Option<i64>,
373
374 pub auto_chain_ref: bool,
375
376 /// TRUE if the value can be null. For arrays, TRUE means it can contain null values
377 /// (exception: array of Points can't have null values).
378 pub can_be_null: bool,
379
380 /// Default value if selected value is null or invalid.
381 pub default_override: Option<serde_json::Value>,
382
383 /// User defined documentation for this field to provide help/tips to level designers about
384 /// accepted values.
385 pub doc: Option<String>,
386
387 pub editor_always_show: bool,
388
389 pub editor_cut_long_values: bool,
390
391 pub editor_display_color: Option<String>,
392
393 /// Possible values: `Hidden`, `ValueOnly`, `NameAndValue`, `EntityTile`, `LevelTile`,
394 /// `Points`, `PointStar`, `PointPath`, `PointPathLoop`, `RadiusPx`, `RadiusGrid`,
395 /// `ArrayCountWithLabel`, `ArrayCountNoLabel`, `RefLinkBetweenPivots`,
396 /// `RefLinkBetweenCenters`
397 pub editor_display_mode: EditorDisplayMode,
398
399 /// Possible values: `Above`, `Center`, `Beneath`
400 pub editor_display_pos: EditorDisplayPos,
401
402 pub editor_display_scale: f64,
403
404 /// Possible values: `ZigZag`, `StraightArrow`, `CurvedArrow`, `ArrowsLine`, `DashedLine`
405 pub editor_link_style: EditorLinkStyle,
406
407 pub editor_show_in_world: bool,
408
409 pub editor_text_prefix: Option<String>,
410
411 pub editor_text_suffix: Option<String>,
412
413 /// User defined unique identifier
414 pub identifier: String,
415
416 /// TRUE if the value is an array of multiple values
417 pub is_array: bool,
418
419 /// Max limit for value, if applicable
420 pub max: Option<f64>,
421
422 /// Min limit for value, if applicable
423 pub min: Option<f64>,
424
425 /// Optional regular expression that needs to be matched to accept values. Expected format:
426 /// `/some_reg_ex/g`, with optional "i" flag.
427 pub regex: Option<String>,
428
429 pub symmetrical_ref: bool,
430
431 /// Possible values: <`null`>, `LangPython`, `LangRuby`, `LangJS`, `LangLua`, `LangC`,
432 /// `LangHaxe`, `LangMarkdown`, `LangJson`, `LangXml`, `LangLog`
433 pub text_language_mode: Option<TextLanguageMode>,
434
435 /// UID of the tileset used for a Tile
436 pub tileset_uid: Option<i64>,
437
438 /// Internal enum representing the possible field types. Possible values: F_Int, F_Float,
439 /// F_String, F_Text, F_Bool, F_Color, F_Enum(...), F_Point, F_Path, F_EntityRef, F_Tile
440 #[serde(rename = "type")]
441 pub purple_type: String,
442
443 /// Unique Int identifier
444 pub uid: i64,
445
446 /// If TRUE, the color associated with this field will override the Entity or Level default
447 /// color in the editor UI. For Enum fields, this would be the color associated to their
448 /// values.
449 pub use_for_smart_color: bool,
450}
451
452/// Possible values: `Any`, `OnlySame`, `OnlyTags`, `OnlySpecificEntity`
453#[derive(Debug, Clone, Serialize, Deserialize)]
454pub enum AllowedRefs {
455 Any,
456
457 #[serde(rename = "OnlySame")]
458 OnlySame,
459
460 #[serde(rename = "OnlySpecificEntity")]
461 OnlySpecificEntity,
462
463 #[serde(rename = "OnlyTags")]
464 OnlyTags,
465}
466
467/// Possible values: `Hidden`, `ValueOnly`, `NameAndValue`, `EntityTile`, `LevelTile`,
468/// `Points`, `PointStar`, `PointPath`, `PointPathLoop`, `RadiusPx`, `RadiusGrid`,
469/// `ArrayCountWithLabel`, `ArrayCountNoLabel`, `RefLinkBetweenPivots`,
470/// `RefLinkBetweenCenters`
471#[derive(Debug, Clone, Serialize, Deserialize)]
472pub enum EditorDisplayMode {
473 #[serde(rename = "ArrayCountNoLabel")]
474 ArrayCountNoLabel,
475
476 #[serde(rename = "ArrayCountWithLabel")]
477 ArrayCountWithLabel,
478
479 #[serde(rename = "EntityTile")]
480 EntityTile,
481
482 Hidden,
483
484 #[serde(rename = "LevelTile")]
485 LevelTile,
486
487 #[serde(rename = "NameAndValue")]
488 NameAndValue,
489
490 #[serde(rename = "PointPath")]
491 PointPath,
492
493 #[serde(rename = "PointPathLoop")]
494 PointPathLoop,
495
496 #[serde(rename = "PointStar")]
497 PointStar,
498
499 Points,
500
501 #[serde(rename = "RadiusGrid")]
502 RadiusGrid,
503
504 #[serde(rename = "RadiusPx")]
505 RadiusPx,
506
507 #[serde(rename = "RefLinkBetweenCenters")]
508 RefLinkBetweenCenters,
509
510 #[serde(rename = "RefLinkBetweenPivots")]
511 RefLinkBetweenPivots,
512
513 #[serde(rename = "ValueOnly")]
514 ValueOnly,
515}
516
517/// Possible values: `Above`, `Center`, `Beneath`
518#[derive(Debug, Clone, Serialize, Deserialize)]
519pub enum EditorDisplayPos {
520 Above,
521
522 Beneath,
523
524 Center,
525}
526
527/// Possible values: `ZigZag`, `StraightArrow`, `CurvedArrow`, `ArrowsLine`, `DashedLine`
528#[derive(Debug, Clone, Serialize, Deserialize)]
529pub enum EditorLinkStyle {
530 #[serde(rename = "ArrowsLine")]
531 ArrowsLine,
532
533 #[serde(rename = "CurvedArrow")]
534 CurvedArrow,
535
536 #[serde(rename = "DashedLine")]
537 DashedLine,
538
539 #[serde(rename = "StraightArrow")]
540 StraightArrow,
541
542 #[serde(rename = "ZigZag")]
543 ZigZag,
544}
545
546#[derive(Debug, Clone, Serialize, Deserialize)]
547pub enum TextLanguageMode {
548 #[serde(rename = "LangC")]
549 LangC,
550
551 #[serde(rename = "LangHaxe")]
552 LangHaxe,
553
554 #[serde(rename = "LangJS")]
555 LangJs,
556
557 #[serde(rename = "LangJson")]
558 LangJson,
559
560 #[serde(rename = "LangLog")]
561 LangLog,
562
563 #[serde(rename = "LangLua")]
564 LangLua,
565
566 #[serde(rename = "LangMarkdown")]
567 LangMarkdown,
568
569 #[serde(rename = "LangPython")]
570 LangPython,
571
572 #[serde(rename = "LangRuby")]
573 LangRuby,
574
575 #[serde(rename = "LangXml")]
576 LangXml,
577}
578
579/// Possible values: `DiscardOldOnes`, `PreventAdding`, `MoveLastOne`
580#[derive(Debug, Clone, Serialize, Deserialize)]
581pub enum LimitBehavior {
582 #[serde(rename = "DiscardOldOnes")]
583 DiscardOldOnes,
584
585 #[serde(rename = "MoveLastOne")]
586 MoveLastOne,
587
588 #[serde(rename = "PreventAdding")]
589 PreventAdding,
590}
591
592/// If TRUE, the maxCount is a "per world" limit, if FALSE, it's a "per level". Possible
593/// values: `PerLayer`, `PerLevel`, `PerWorld`
594#[derive(Debug, Clone, Serialize, Deserialize)]
595pub enum LimitScope {
596 #[serde(rename = "PerLayer")]
597 PerLayer,
598
599 #[serde(rename = "PerLevel")]
600 PerLevel,
601
602 #[serde(rename = "PerWorld")]
603 PerWorld,
604}
605
606/// Possible values: `Rectangle`, `Ellipse`, `Tile`, `Cross`
607#[derive(Debug, Clone, Serialize, Deserialize)]
608pub enum RenderMode {
609 Cross,
610
611 Ellipse,
612
613 Rectangle,
614
615 Tile,
616}
617
618/// This object represents a custom sub rectangle in a Tileset image.
619#[derive(Debug, Clone, Serialize, Deserialize)]
620#[serde(rename_all = "camelCase")]
621pub struct TilesetRectangle {
622 /// Height in pixels
623 pub h: i64,
624
625 /// UID of the tileset
626 pub tileset_uid: i64,
627
628 /// Width in pixels
629 pub w: i64,
630
631 /// X pixels coordinate of the top-left corner in the Tileset image
632 pub x: i64,
633
634 /// Y pixels coordinate of the top-left corner in the Tileset image
635 pub y: i64,
636}
637
638/// An enum describing how the the Entity tile is rendered inside the Entity bounds. Possible
639/// values: `Cover`, `FitInside`, `Repeat`, `Stretch`, `FullSizeCropped`,
640/// `FullSizeUncropped`, `NineSlice`
641#[derive(Debug, Clone, Serialize, Deserialize)]
642pub enum TileRenderMode {
643 Cover,
644
645 #[serde(rename = "FitInside")]
646 FitInside,
647
648 #[serde(rename = "FullSizeCropped")]
649 FullSizeCropped,
650
651 #[serde(rename = "FullSizeUncropped")]
652 FullSizeUncropped,
653
654 #[serde(rename = "NineSlice")]
655 NineSlice,
656
657 Repeat,
658
659 Stretch,
660}
661
662#[derive(Debug, Clone, Serialize, Deserialize)]
663#[serde(rename_all = "camelCase")]
664pub struct EnumDefinition {
665 pub external_file_checksum: Option<String>,
666
667 /// Relative path to the external file providing this Enum
668 pub external_rel_path: Option<String>,
669
670 /// Tileset UID if provided
671 pub icon_tileset_uid: Option<i64>,
672
673 /// User defined unique identifier
674 pub identifier: String,
675
676 /// An array of user-defined tags to organize the Enums
677 pub tags: Vec<String>,
678
679 /// Unique Int identifier
680 pub uid: i64,
681
682 /// All possible enum values, with their optional Tile infos.
683 pub values: Vec<EnumValueDefinition>,
684}
685
686#[derive(Debug, Clone, Serialize, Deserialize)]
687#[serde(rename_all = "camelCase")]
688pub struct EnumValueDefinition {
689 /// **WARNING**: this deprecated value is no longer exported since version 1.4.0 Replaced
690 /// by: `tileRect`
691 #[serde(rename = "__tileSrcRect")]
692 pub tile_src_rect: Option<Vec<i64>>,
693
694 /// Optional color
695 pub color: i64,
696
697 /// Enum value
698 pub id: String,
699
700 /// **WARNING**: this deprecated value is no longer exported since version 1.4.0 Replaced
701 /// by: `tileRect`
702 pub tile_id: Option<i64>,
703
704 /// Optional tileset rectangle to represents this value
705 pub tile_rect: Option<TilesetRectangle>,
706}
707
708#[derive(Debug, Clone, Serialize, Deserialize)]
709#[serde(rename_all = "camelCase")]
710pub struct LayerDefinition {
711 /// Type of the layer (*IntGrid, Entities, Tiles or AutoLayer*)
712 #[serde(rename = "__type")]
713 pub layer_definition_type: String,
714
715 /// Contains all the auto-layer rule definitions.
716 pub auto_rule_groups: Vec<AutoLayerRuleGroup>,
717
718 pub auto_source_layer_def_uid: Option<i64>,
719
720 /// **WARNING**: this deprecated value is no longer exported since version 1.2.0 Replaced
721 /// by: `tilesetDefUid`
722 pub auto_tileset_def_uid: Option<i64>,
723
724 /// Allow editor selections when the layer is not currently active.
725 pub can_select_when_inactive: bool,
726
727 /// Opacity of the layer (0 to 1.0)
728 pub display_opacity: f64,
729
730 /// User defined documentation for this element to provide help/tips to level designers.
731 pub doc: Option<String>,
732
733 /// An array of tags to forbid some Entities in this layer
734 pub excluded_tags: Vec<String>,
735
736 /// Width and height of the grid in pixels
737 pub grid_size: i64,
738
739 /// Height of the optional "guide" grid in pixels
740 pub guide_grid_hei: i64,
741
742 /// Width of the optional "guide" grid in pixels
743 pub guide_grid_wid: i64,
744
745 pub hide_fields_when_inactive: bool,
746
747 /// Hide the layer from the list on the side of the editor view.
748 pub hide_in_list: bool,
749
750 /// User defined unique identifier
751 pub identifier: String,
752
753 /// Alpha of this layer when it is not the active one.
754 pub inactive_opacity: f64,
755
756 /// An array that defines extra optional info for each IntGrid value.<br/> WARNING: the
757 /// array order is not related to actual IntGrid values! As user can re-order IntGrid values
758 /// freely, you may value "2" before value "1" in this array.
759 pub int_grid_values: Vec<IntGridValueDefinition>,
760
761 /// Group informations for IntGrid values
762 pub int_grid_values_groups: Vec<IntGridValueGroupDefinition>,
763
764 /// Parallax horizontal factor (from -1 to 1, defaults to 0) which affects the scrolling
765 /// speed of this layer, creating a fake 3D (parallax) effect.
766 pub parallax_factor_x: f64,
767
768 /// Parallax vertical factor (from -1 to 1, defaults to 0) which affects the scrolling speed
769 /// of this layer, creating a fake 3D (parallax) effect.
770 pub parallax_factor_y: f64,
771
772 /// If true (default), a layer with a parallax factor will also be scaled up/down accordingly.
773 pub parallax_scaling: bool,
774
775 /// X offset of the layer, in pixels (IMPORTANT: this should be added to the `LayerInstance`
776 /// optional offset)
777 pub px_offset_x: i64,
778
779 /// Y offset of the layer, in pixels (IMPORTANT: this should be added to the `LayerInstance`
780 /// optional offset)
781 pub px_offset_y: i64,
782
783 /// If TRUE, the content of this layer will be used when rendering levels in a simplified way
784 /// for the world view
785 pub render_in_world_view: bool,
786
787 /// An array of tags to filter Entities that can be added to this layer
788 pub required_tags: Vec<String>,
789
790 /// If the tiles are smaller or larger than the layer grid, the pivot value will be used to
791 /// position the tile relatively its grid cell.
792 pub tile_pivot_x: f64,
793
794 /// If the tiles are smaller or larger than the layer grid, the pivot value will be used to
795 /// position the tile relatively its grid cell.
796 pub tile_pivot_y: f64,
797
798 /// Reference to the default Tileset UID being used by this layer definition.<br/>
799 /// **WARNING**: some layer *instances* might use a different tileset. So most of the time,
800 /// you should probably use the `__tilesetDefUid` value found in layer instances.<br/> Note:
801 /// since version 1.0.0, the old `autoTilesetDefUid` was removed and merged into this value.
802 pub tileset_def_uid: Option<i64>,
803
804 /// Type of the layer as Haxe Enum Possible values: `IntGrid`, `Entities`, `Tiles`,
805 /// `AutoLayer`
806 #[serde(rename = "type")]
807 pub purple_type: Type,
808
809 /// User defined color for the UI
810 pub ui_color: Option<String>,
811
812 /// Unique Int identifier
813 pub uid: i64,
814}
815
816#[derive(Debug, Clone, Serialize, Deserialize)]
817#[serde(rename_all = "camelCase")]
818pub struct AutoLayerRuleGroup {
819 pub active: bool,
820
821 /// *This field was removed in 1.0.0 and should no longer be used.*
822 pub collapsed: Option<bool>,
823
824 pub color: Option<String>,
825
826 pub icon: Option<TilesetRectangle>,
827
828 pub is_optional: bool,
829
830 pub name: String,
831
832 pub rules: Vec<AutoLayerRuleDefinition>,
833
834 pub uid: i64,
835
836 pub uses_wizard: bool,
837}
838
839/// This complex section isn't meant to be used by game devs at all, as these rules are
840/// completely resolved internally by the editor before any saving. You should just ignore
841/// this part.
842#[derive(Debug, Clone, Serialize, Deserialize)]
843#[serde(rename_all = "camelCase")]
844pub struct AutoLayerRuleDefinition {
845 /// If FALSE, the rule effect isn't applied, and no tiles are generated.
846 pub active: bool,
847
848 pub alpha: f64,
849
850 /// When TRUE, the rule will prevent other rules to be applied in the same cell if it matches
851 /// (TRUE by default).
852 pub break_on_match: bool,
853
854 /// Chances for this rule to be applied (0 to 1)
855 pub chance: f64,
856
857 /// Checker mode Possible values: `None`, `Horizontal`, `Vertical`
858 pub checker: Checker,
859
860 /// If TRUE, allow rule to be matched by flipping its pattern horizontally
861 pub flip_x: bool,
862
863 /// If TRUE, allow rule to be matched by flipping its pattern vertically
864 pub flip_y: bool,
865
866 /// Default IntGrid value when checking cells outside of level bounds
867 pub out_of_bounds_value: Option<i64>,
868
869 /// Rule pattern (size x size)
870 pub pattern: Vec<i64>,
871
872 /// If TRUE, enable Perlin filtering to only apply rule on specific random area
873 pub perlin_active: bool,
874
875 pub perlin_octaves: f64,
876
877 pub perlin_scale: f64,
878
879 pub perlin_seed: f64,
880
881 /// X pivot of a tile stamp (0-1)
882 pub pivot_x: f64,
883
884 /// Y pivot of a tile stamp (0-1)
885 pub pivot_y: f64,
886
887 /// Pattern width & height. Should only be 1,3,5 or 7.
888 pub size: i64,
889
890 /// Array of all the tile IDs. They are used randomly or as stamps, based on `tileMode` value.
891 pub tile_ids: Vec<i64>,
892
893 /// Defines how tileIds array is used Possible values: `Single`, `Stamp`
894 pub tile_mode: TileMode,
895
896 /// Max random offset for X tile pos
897 pub tile_random_x_max: i64,
898
899 /// Min random offset for X tile pos
900 pub tile_random_x_min: i64,
901
902 /// Max random offset for Y tile pos
903 pub tile_random_y_max: i64,
904
905 /// Min random offset for Y tile pos
906 pub tile_random_y_min: i64,
907
908 /// Tile X offset
909 pub tile_x_offset: i64,
910
911 /// Tile Y offset
912 pub tile_y_offset: i64,
913
914 /// Unique Int identifier
915 pub uid: i64,
916
917 /// X cell coord modulo
918 pub x_modulo: i64,
919
920 /// X cell start offset
921 pub x_offset: i64,
922
923 /// Y cell coord modulo
924 pub y_modulo: i64,
925
926 /// Y cell start offset
927 pub y_offset: i64,
928}
929
930/// Checker mode Possible values: `None`, `Horizontal`, `Vertical`
931#[derive(Debug, Clone, Serialize, Deserialize)]
932pub enum Checker {
933 Horizontal,
934
935 None,
936
937 Vertical,
938}
939
940/// Defines how tileIds array is used Possible values: `Single`, `Stamp`
941#[derive(Debug, Clone, Serialize, Deserialize)]
942pub enum TileMode {
943 Single,
944
945 Stamp,
946}
947
948/// IntGrid value definition
949#[derive(Debug, Clone, Serialize, Deserialize)]
950#[serde(rename_all = "camelCase")]
951pub struct IntGridValueDefinition {
952 pub color: String,
953
954 /// Parent group identifier (0 if none)
955 pub group_uid: i64,
956
957 /// User defined unique identifier
958 pub identifier: Option<String>,
959
960 pub tile: Option<TilesetRectangle>,
961
962 /// The IntGrid value itself
963 pub value: i64,
964}
965
966/// IntGrid value group definition
967#[derive(Debug, Clone, Serialize, Deserialize)]
968pub struct IntGridValueGroupDefinition {
969 /// User defined color
970 pub color: Option<String>,
971
972 /// User defined string identifier
973 pub identifier: Option<String>,
974
975 /// Group unique ID
976 pub uid: i64,
977}
978
979/// Type of the layer as Haxe Enum Possible values: `IntGrid`, `Entities`, `Tiles`,
980/// `AutoLayer`
981#[derive(Debug, Clone, Serialize, Deserialize)]
982pub enum Type {
983 #[serde(rename = "AutoLayer")]
984 AutoLayer,
985
986 Entities,
987
988 #[serde(rename = "IntGrid")]
989 IntGrid,
990
991 Tiles,
992}
993
994/// The `Tileset` definition is the most important part among project definitions. It
995/// contains some extra informations about each integrated tileset. If you only had to parse
996/// one definition section, that would be the one.
997#[derive(Debug, Clone, Serialize, Deserialize)]
998#[serde(rename_all = "camelCase")]
999pub struct TilesetDefinition {
1000 /// Grid-based height
1001 #[serde(rename = "__cHei")]
1002 pub c_hei: i64,
1003
1004 /// Grid-based width
1005 #[serde(rename = "__cWid")]
1006 pub c_wid: i64,
1007
1008 /// The following data is used internally for various optimizations. It's always synced with
1009 /// source image changes.
1010 pub cached_pixel_data: Option<HashMap<String, Option<serde_json::Value>>>,
1011
1012 /// An array of custom tile metadata
1013 pub custom_data: Vec<TileCustomMetadata>,
1014
1015 /// If this value is set, then it means that this atlas uses an internal LDtk atlas image
1016 /// instead of a loaded one. Possible values: <`null`>, `LdtkIcons`
1017 pub embed_atlas: Option<EmbedAtlas>,
1018
1019 /// Tileset tags using Enum values specified by `tagsSourceEnumId`. This array contains 1
1020 /// element per Enum value, which contains an array of all Tile IDs that are tagged with it.
1021 pub enum_tags: Vec<EnumTagValue>,
1022
1023 /// User defined unique identifier
1024 pub identifier: String,
1025
1026 /// Distance in pixels from image borders
1027 pub padding: i64,
1028
1029 /// Image height in pixels
1030 pub px_hei: i64,
1031
1032 /// Image width in pixels
1033 pub px_wid: i64,
1034
1035 /// Path to the source file, relative to the current project JSON file<br/> It can be null
1036 /// if no image was provided, or when using an embed atlas.
1037 pub rel_path: Option<String>,
1038
1039 /// Array of group of tiles selections, only meant to be used in the editor
1040 pub saved_selections: Vec<HashMap<String, Option<serde_json::Value>>>,
1041
1042 /// Space in pixels between all tiles
1043 pub spacing: i64,
1044
1045 /// An array of user-defined tags to organize the Tilesets
1046 pub tags: Vec<String>,
1047
1048 /// Optional Enum definition UID used for this tileset meta-data
1049 pub tags_source_enum_uid: Option<i64>,
1050
1051 pub tile_grid_size: i64,
1052
1053 /// Unique Intidentifier
1054 pub uid: i64,
1055}
1056
1057/// In a tileset definition, user defined meta-data of a tile.
1058#[derive(Debug, Clone, Serialize, Deserialize)]
1059#[serde(rename_all = "camelCase")]
1060pub struct TileCustomMetadata {
1061 pub data: String,
1062
1063 pub tile_id: i64,
1064}
1065
1066#[derive(Debug, Clone, Serialize, Deserialize)]
1067pub enum EmbedAtlas {
1068 #[serde(rename = "LdtkIcons")]
1069 LdtkIcons,
1070}
1071
1072/// In a tileset definition, enum based tag infos
1073#[derive(Debug, Clone, Serialize, Deserialize)]
1074#[serde(rename_all = "camelCase")]
1075pub struct EnumTagValue {
1076 pub enum_value_id: String,
1077
1078 pub tile_ids: Vec<i64>,
1079}
1080
1081#[derive(Debug, Clone, Serialize, Deserialize)]
1082pub enum Flag {
1083 #[serde(rename = "DiscardPreCsvIntGrid")]
1084 DiscardPreCsvIntGrid,
1085
1086 #[serde(rename = "ExportPreCsvIntGridFormat")]
1087 ExportPreCsvIntGridFormat,
1088
1089 #[serde(rename = "IgnoreBackupSuggest")]
1090 IgnoreBackupSuggest,
1091
1092 #[serde(rename = "MultiWorlds")]
1093 MultiWorlds,
1094
1095 #[serde(rename = "PrependIndexToLevelFileNames")]
1096 PrependIndexToLevelFileNames,
1097
1098 #[serde(rename = "UseMultilinesType")]
1099 UseMultilinesType,
1100}
1101
1102/// This object is not actually used by LDtk. It ONLY exists to force explicit references to
1103/// all types, to make sure QuickType finds them and integrate all of them. Otherwise,
1104/// Quicktype will drop types that are not explicitely used.
1105#[derive(Debug, Clone, Serialize, Deserialize)]
1106#[serde(rename_all = "PascalCase")]
1107pub struct ForcedRefs {
1108 pub auto_layer_rule_group: Option<AutoLayerRuleGroup>,
1109
1110 pub auto_rule_def: Option<AutoLayerRuleDefinition>,
1111
1112 pub custom_command: Option<LdtkCustomCommand>,
1113
1114 pub definitions: Option<Definitions>,
1115
1116 pub entity_def: Option<EntityDefinition>,
1117
1118 pub entity_instance: Option<EntityInstance>,
1119
1120 pub entity_reference_infos: Option<ReferenceToAnEntityInstance>,
1121
1122 pub enum_def: Option<EnumDefinition>,
1123
1124 pub enum_def_values: Option<EnumValueDefinition>,
1125
1126 pub enum_tag_value: Option<EnumTagValue>,
1127
1128 pub field_def: Option<FieldDefinition>,
1129
1130 pub field_instance: Option<FieldInstance>,
1131
1132 pub grid_point: Option<GridPoint>,
1133
1134 pub int_grid_value_def: Option<IntGridValueDefinition>,
1135
1136 pub int_grid_value_group_def: Option<IntGridValueGroupDefinition>,
1137
1138 pub int_grid_value_instance: Option<IntGridValueInstance>,
1139
1140 pub layer_def: Option<LayerDefinition>,
1141
1142 pub layer_instance: Option<LayerInstance>,
1143
1144 pub level: Option<Level>,
1145
1146 pub level_bg_pos_infos: Option<LevelBackgroundPosition>,
1147
1148 pub neighbour_level: Option<NeighbourLevel>,
1149
1150 pub table_of_content_entry: Option<LdtkTableOfContentEntry>,
1151
1152 pub tile: Option<TileInstance>,
1153
1154 pub tile_custom_metadata: Option<TileCustomMetadata>,
1155
1156 pub tileset_def: Option<TilesetDefinition>,
1157
1158 pub tileset_rect: Option<TilesetRectangle>,
1159
1160 pub world: Option<World>,
1161}
1162
1163#[derive(Debug, Clone, Serialize, Deserialize)]
1164#[serde(rename_all = "camelCase")]
1165pub struct EntityInstance {
1166 /// Grid-based coordinates (`[x,y]` format)
1167 #[serde(rename = "__grid")]
1168 pub grid: Vec<i64>,
1169
1170 /// Entity definition identifier
1171 #[serde(rename = "__identifier")]
1172 pub identifier: String,
1173
1174 /// Pivot coordinates (`[x,y]` format, values are from 0 to 1) of the Entity
1175 #[serde(rename = "__pivot")]
1176 pub pivot: Vec<f64>,
1177
1178 /// The entity "smart" color, guessed from either Entity definition, or one its field
1179 /// instances.
1180 #[serde(rename = "__smartColor")]
1181 pub smart_color: String,
1182
1183 /// Array of tags defined in this Entity definition
1184 #[serde(rename = "__tags")]
1185 pub tags: Vec<String>,
1186
1187 /// Optional TilesetRect used to display this entity (it could either be the default Entity
1188 /// tile, or some tile provided by a field value, like an Enum).
1189 #[serde(rename = "__tile")]
1190 pub tile: Option<TilesetRectangle>,
1191
1192 /// X world coordinate in pixels
1193 #[serde(rename = "__worldX")]
1194 pub world_x: i64,
1195
1196 /// Y world coordinate in pixels
1197 #[serde(rename = "__worldY")]
1198 pub world_y: i64,
1199
1200 /// Reference of the **Entity definition** UID
1201 pub def_uid: i64,
1202
1203 /// An array of all custom fields and their values.
1204 pub field_instances: Vec<FieldInstance>,
1205
1206 /// Entity height in pixels. For non-resizable entities, it will be the same as Entity
1207 /// definition.
1208 pub height: i64,
1209
1210 /// Unique instance identifier
1211 pub iid: String,
1212
1213 /// Pixel coordinates (`[x,y]` format) in current level coordinate space. Don't forget
1214 /// optional layer offsets, if they exist!
1215 pub px: Vec<i64>,
1216
1217 /// Entity width in pixels. For non-resizable entities, it will be the same as Entity
1218 /// definition.
1219 pub width: i64,
1220}
1221
1222#[derive(Debug, Clone, Serialize, Deserialize)]
1223#[serde(rename_all = "camelCase")]
1224pub struct FieldInstance {
1225 /// Field definition identifier
1226 #[serde(rename = "__identifier")]
1227 pub identifier: String,
1228
1229 /// Optional TilesetRect used to display this field (this can be the field own Tile, or some
1230 /// other Tile guessed from the value, like an Enum).
1231 #[serde(rename = "__tile")]
1232 pub tile: Option<TilesetRectangle>,
1233
1234 /// Type of the field, such as `Int`, `Float`, `String`, `Enum(my_enum_name)`, `Bool`,
1235 /// etc.<br/> NOTE: if you enable the advanced option **Use Multilines type**, you will have
1236 /// "*Multilines*" instead of "*String*" when relevant.
1237 #[serde(rename = "__type")]
1238 pub field_instance_type: String,
1239
1240 /// Actual value of the field instance. The value type varies, depending on `__type`:<br/>
1241 /// - For **classic types** (ie. Integer, Float, Boolean, String, Text and FilePath), you
1242 /// just get the actual value with the expected type.<br/> - For **Color**, the value is an
1243 /// hexadecimal string using "#rrggbb" format.<br/> - For **Enum**, the value is a String
1244 /// representing the selected enum value.<br/> - For **Point**, the value is a
1245 /// [GridPoint](#ldtk-GridPoint) object.<br/> - For **Tile**, the value is a
1246 /// [TilesetRect](#ldtk-TilesetRect) object.<br/> - For **EntityRef**, the value is an
1247 /// [EntityReferenceInfos](#ldtk-EntityReferenceInfos) object.<br/><br/> If the field is an
1248 /// array, then this `__value` will also be a JSON array.
1249 #[serde(rename = "__value")]
1250 pub value: Option<serde_json::Value>,
1251
1252 /// Reference of the **Field definition** UID
1253 pub def_uid: i64,
1254
1255 /// Editor internal raw values
1256 pub real_editor_values: Vec<Option<serde_json::Value>>,
1257}
1258
1259/// This object describes the "location" of an Entity instance in the project worlds.
1260#[derive(Debug, Clone, Serialize, Deserialize)]
1261#[serde(rename_all = "camelCase")]
1262pub struct ReferenceToAnEntityInstance {
1263 /// IID of the refered EntityInstance
1264 pub entity_iid: String,
1265
1266 /// IID of the LayerInstance containing the refered EntityInstance
1267 pub layer_iid: String,
1268
1269 /// IID of the Level containing the refered EntityInstance
1270 pub level_iid: String,
1271
1272 /// IID of the World containing the refered EntityInstance
1273 pub world_iid: String,
1274}
1275
1276/// This object is just a grid-based coordinate used in Field values.
1277#[derive(Debug, Clone, Serialize, Deserialize)]
1278pub struct GridPoint {
1279 /// X grid-based coordinate
1280 pub cx: i64,
1281
1282 /// Y grid-based coordinate
1283 pub cy: i64,
1284}
1285
1286/// IntGrid value instance
1287#[derive(Debug, Clone, Serialize, Deserialize)]
1288#[serde(rename_all = "camelCase")]
1289pub struct IntGridValueInstance {
1290 /// Coordinate ID in the layer grid
1291 pub coord_id: i64,
1292
1293 /// IntGrid value
1294 pub v: i64,
1295}
1296
1297#[derive(Debug, Clone, Serialize, Deserialize)]
1298#[serde(rename_all = "camelCase")]
1299pub struct LayerInstance {
1300 /// Grid-based height
1301 #[serde(rename = "__cHei")]
1302 pub c_hei: i64,
1303
1304 /// Grid-based width
1305 #[serde(rename = "__cWid")]
1306 pub c_wid: i64,
1307
1308 /// Grid size
1309 #[serde(rename = "__gridSize")]
1310 pub grid_size: i64,
1311
1312 /// Layer definition identifier
1313 #[serde(rename = "__identifier")]
1314 pub identifier: String,
1315
1316 /// Layer opacity as Float [0-1]
1317 #[serde(rename = "__opacity")]
1318 pub opacity: f64,
1319
1320 /// Total layer X pixel offset, including both instance and definition offsets.
1321 #[serde(rename = "__pxTotalOffsetX")]
1322 pub px_total_offset_x: i64,
1323
1324 /// Total layer Y pixel offset, including both instance and definition offsets.
1325 #[serde(rename = "__pxTotalOffsetY")]
1326 pub px_total_offset_y: i64,
1327
1328 /// The definition UID of corresponding Tileset, if any.
1329 #[serde(rename = "__tilesetDefUid")]
1330 pub tileset_def_uid: Option<i64>,
1331
1332 /// The relative path to corresponding Tileset, if any.
1333 #[serde(rename = "__tilesetRelPath")]
1334 pub tileset_rel_path: Option<String>,
1335
1336 /// Layer type (possible values: IntGrid, Entities, Tiles or AutoLayer)
1337 #[serde(rename = "__type")]
1338 pub layer_instance_type: String,
1339
1340 /// An array containing all tiles generated by Auto-layer rules. The array is already sorted
1341 /// in display order (ie. 1st tile is beneath 2nd, which is beneath 3rd etc.).<br/><br/>
1342 /// Note: if multiple tiles are stacked in the same cell as the result of different rules,
1343 /// all tiles behind opaque ones will be discarded.
1344 pub auto_layer_tiles: Vec<TileInstance>,
1345
1346 pub entity_instances: Vec<EntityInstance>,
1347
1348 pub grid_tiles: Vec<TileInstance>,
1349
1350 /// Unique layer instance identifier
1351 pub iid: String,
1352
1353 /// **WARNING**: this deprecated value is no longer exported since version 1.0.0 Replaced
1354 /// by: `intGridCsv`
1355 pub int_grid: Option<Vec<IntGridValueInstance>>,
1356
1357 /// A list of all values in the IntGrid layer, stored in CSV format (Comma Separated
1358 /// Values).<br/> Order is from left to right, and top to bottom (ie. first row from left to
1359 /// right, followed by second row, etc).<br/> `0` means "empty cell" and IntGrid values
1360 /// start at 1.<br/> The array size is `__cWid` x `__cHei` cells.
1361 pub int_grid_csv: Vec<i64>,
1362
1363 /// Reference the Layer definition UID
1364 pub layer_def_uid: i64,
1365
1366 /// Reference to the UID of the level containing this layer instance
1367 pub level_id: i64,
1368
1369 /// An Array containing the UIDs of optional rules that were enabled in this specific layer
1370 /// instance.
1371 pub optional_rules: Vec<i64>,
1372
1373 /// This layer can use another tileset by overriding the tileset UID here.
1374 pub override_tileset_uid: Option<i64>,
1375
1376 /// X offset in pixels to render this layer, usually 0 (IMPORTANT: this should be added to
1377 /// the `LayerDef` optional offset, so you should probably prefer using `__pxTotalOffsetX`
1378 /// which contains the total offset value)
1379 pub px_offset_x: i64,
1380
1381 /// Y offset in pixels to render this layer, usually 0 (IMPORTANT: this should be added to
1382 /// the `LayerDef` optional offset, so you should probably prefer using `__pxTotalOffsetX`
1383 /// which contains the total offset value)
1384 pub px_offset_y: i64,
1385
1386 /// Random seed used for Auto-Layers rendering
1387 pub seed: i64,
1388
1389 /// Layer instance visibility
1390 pub visible: bool,
1391}
1392
1393/// This structure represents a single tile from a given Tileset.
1394#[derive(Debug, Clone, Serialize, Deserialize)]
1395pub struct TileInstance {
1396 /// Alpha/opacity of the tile (0-1, defaults to 1)
1397 pub a: f64,
1398
1399 /// Internal data used by the editor.<br/> For auto-layer tiles: `[ruleId, coordId]`.<br/>
1400 /// For tile-layer tiles: `[coordId]`.
1401 pub d: Vec<i64>,
1402
1403 /// "Flip bits", a 2-bits integer to represent the mirror transformations of the tile.<br/>
1404 /// - Bit 0 = X flip<br/> - Bit 1 = Y flip<br/> Examples: f=0 (no flip), f=1 (X flip
1405 /// only), f=2 (Y flip only), f=3 (both flips)
1406 pub f: i64,
1407
1408 /// Pixel coordinates of the tile in the **layer** (`[x,y]` format). Don't forget optional
1409 /// layer offsets, if they exist!
1410 pub px: Vec<i64>,
1411
1412 /// Pixel coordinates of the tile in the **tileset** (`[x,y]` format)
1413 pub src: Vec<i64>,
1414
1415 /// The *Tile ID* in the corresponding tileset.
1416 pub t: i64,
1417}
1418
1419/// This section contains all the level data. It can be found in 2 distinct forms, depending
1420/// on Project current settings: - If "*Separate level files*" is **disabled** (default):
1421/// full level data is *embedded* inside the main Project JSON file, - If "*Separate level
1422/// files*" is **enabled**: level data is stored in *separate* standalone `.ldtkl` files (one
1423/// per level). In this case, the main Project JSON file will still contain most level data,
1424/// except heavy sections, like the `layerInstances` array (which will be null). The
1425/// `externalRelPath` string points to the `ldtkl` file. A `ldtkl` file is just a JSON file
1426/// containing exactly what is described below.
1427#[derive(Debug, Clone, Serialize, Deserialize)]
1428#[serde(rename_all = "camelCase")]
1429pub struct Level {
1430 /// Background color of the level (same as `bgColor`, except the default value is
1431 /// automatically used here if its value is `null`)
1432 #[serde(rename = "__bgColor")]
1433 pub bg_color: String,
1434
1435 /// Position informations of the background image, if there is one.
1436 #[serde(rename = "__bgPos")]
1437 pub bg_pos: Option<LevelBackgroundPosition>,
1438
1439 /// An array listing all other levels touching this one on the world map. Since 1.4.0, this
1440 /// includes levels that overlap in the same world layer, or in nearby world layers.<br/>
1441 /// Only relevant for world layouts where level spatial positioning is manual (ie. GridVania,
1442 /// Free). For Horizontal and Vertical layouts, this array is always empty.
1443 #[serde(rename = "__neighbours")]
1444 pub neighbours: Vec<NeighbourLevel>,
1445
1446 /// The "guessed" color for this level in the editor, decided using either the background
1447 /// color or an existing custom field.
1448 #[serde(rename = "__smartColor")]
1449 pub smart_color: String,
1450
1451 /// Background color of the level. If `null`, the project `defaultLevelBgColor` should be
1452 /// used.
1453 #[serde(rename = "bgColor")]
1454 pub level_bg_color: Option<String>,
1455
1456 /// Background image X pivot (0-1)
1457 pub bg_pivot_x: f64,
1458
1459 /// Background image Y pivot (0-1)
1460 pub bg_pivot_y: f64,
1461
1462 /// An enum defining the way the background image (if any) is positioned on the level. See
1463 /// `__bgPos` for resulting position info. Possible values: <`null`>, `Unscaled`,
1464 /// `Contain`, `Cover`, `CoverDirty`, `Repeat`
1465 #[serde(rename = "bgPos")]
1466 pub level_bg_pos: Option<BgPos>,
1467
1468 /// The *optional* relative path to the level background image.
1469 pub bg_rel_path: Option<String>,
1470
1471 /// This value is not null if the project option "*Save levels separately*" is enabled. In
1472 /// this case, this **relative** path points to the level Json file.
1473 pub external_rel_path: Option<String>,
1474
1475 /// An array containing this level custom field values.
1476 pub field_instances: Vec<FieldInstance>,
1477
1478 /// User defined unique identifier
1479 pub identifier: String,
1480
1481 /// Unique instance identifier
1482 pub iid: String,
1483
1484 /// An array containing all Layer instances. **IMPORTANT**: if the project option "*Save
1485 /// levels separately*" is enabled, this field will be `null`.<br/> This array is **sorted
1486 /// in display order**: the 1st layer is the top-most and the last is behind.
1487 pub layer_instances: Option<Vec<LayerInstance>>,
1488
1489 /// Height of the level in pixels
1490 pub px_hei: i64,
1491
1492 /// Width of the level in pixels
1493 pub px_wid: i64,
1494
1495 /// Unique Int identifier
1496 pub uid: i64,
1497
1498 /// If TRUE, the level identifier will always automatically use the naming pattern as defined
1499 /// in `Project.levelNamePattern`. Becomes FALSE if the identifier is manually modified by
1500 /// user.
1501 pub use_auto_identifier: bool,
1502
1503 /// Index that represents the "depth" of the level in the world. Default is 0, greater means
1504 /// "above", lower means "below".<br/> This value is mostly used for display only and is
1505 /// intended to make stacking of levels easier to manage.
1506 pub world_depth: i64,
1507
1508 /// World X coordinate in pixels.<br/> Only relevant for world layouts where level spatial
1509 /// positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, the
1510 /// value is always -1 here.
1511 pub world_x: i64,
1512
1513 /// World Y coordinate in pixels.<br/> Only relevant for world layouts where level spatial
1514 /// positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, the
1515 /// value is always -1 here.
1516 pub world_y: i64,
1517}
1518
1519/// Level background image position info
1520#[derive(Debug, Clone, Serialize, Deserialize)]
1521#[serde(rename_all = "camelCase")]
1522pub struct LevelBackgroundPosition {
1523 /// An array of 4 float values describing the cropped sub-rectangle of the displayed
1524 /// background image. This cropping happens when original is larger than the level bounds.
1525 /// Array format: `[ cropX, cropY, cropWidth, cropHeight ]`
1526 pub crop_rect: Vec<f64>,
1527
1528 /// An array containing the `[scaleX,scaleY]` values of the **cropped** background image,
1529 /// depending on `bgPos` option.
1530 pub scale: Vec<f64>,
1531
1532 /// An array containing the `[x,y]` pixel coordinates of the top-left corner of the
1533 /// **cropped** background image, depending on `bgPos` option.
1534 pub top_left_px: Vec<i64>,
1535}
1536
1537#[derive(Debug, Clone, Serialize, Deserialize)]
1538pub enum BgPos {
1539 Contain,
1540
1541 Cover,
1542
1543 #[serde(rename = "CoverDirty")]
1544 CoverDirty,
1545
1546 Repeat,
1547
1548 Unscaled,
1549}
1550
1551/// Nearby level info
1552#[derive(Debug, Clone, Serialize, Deserialize)]
1553#[serde(rename_all = "camelCase")]
1554pub struct NeighbourLevel {
1555 /// A single lowercase character tipping on the level location (`n`orth, `s`outh, `w`est,
1556 /// `e`ast).<br/> Since 1.4.0, this character value can also be `<` (neighbour depth is
1557 /// lower), `>` (neighbour depth is greater) or `o` (levels overlap and share the same world
1558 /// depth).
1559 pub dir: String,
1560
1561 /// Neighbour Instance Identifier
1562 pub level_iid: String,
1563
1564 /// **WARNING**: this deprecated value is no longer exported since version 1.2.0 Replaced
1565 /// by: `levelIid`
1566 pub level_uid: Option<i64>,
1567}
1568
1569#[derive(Debug, Clone, Serialize, Deserialize)]
1570pub struct LdtkTableOfContentEntry {
1571 pub identifier: String,
1572
1573 pub instances: Vec<ReferenceToAnEntityInstance>,
1574}
1575
1576/// **IMPORTANT**: this type is available as a preview. You can rely on it to update your
1577/// importers, for when it will be officially available. A World contains multiple levels,
1578/// and it has its own layout settings.
1579#[derive(Debug, Clone, Serialize, Deserialize)]
1580#[serde(rename_all = "camelCase")]
1581pub struct World {
1582 /// Default new level height
1583 pub default_level_height: i64,
1584
1585 /// Default new level width
1586 pub default_level_width: i64,
1587
1588 /// User defined unique identifier
1589 pub identifier: String,
1590
1591 /// Unique instance identifer
1592 pub iid: String,
1593
1594 /// All levels from this world. The order of this array is only relevant in
1595 /// `LinearHorizontal` and `linearVertical` world layouts (see `worldLayout` value).
1596 /// Otherwise, you should refer to the `worldX`,`worldY` coordinates of each Level.
1597 pub levels: Vec<Level>,
1598
1599 /// Height of the world grid in pixels.
1600 pub world_grid_height: i64,
1601
1602 /// Width of the world grid in pixels.
1603 pub world_grid_width: i64,
1604
1605 /// An enum that describes how levels are organized in this project (ie. linearly or in a 2D
1606 /// space). Possible values: `Free`, `GridVania`, `LinearHorizontal`, `LinearVertical`, `null`
1607 pub world_layout: Option<WorldLayout>,
1608}
1609
1610#[derive(Debug, Clone, Serialize, Deserialize)]
1611pub enum WorldLayout {
1612 Free,
1613
1614 #[serde(rename = "GridVania")]
1615 GridVania,
1616
1617 #[serde(rename = "LinearHorizontal")]
1618 LinearHorizontal,
1619
1620 #[serde(rename = "LinearVertical")]
1621 LinearVertical,
1622}
1623
1624/// Naming convention for Identifiers (first-letter uppercase, full uppercase etc.) Possible
1625/// values: `Capitalize`, `Uppercase`, `Lowercase`, `Free`
1626#[derive(Debug, Clone, Serialize, Deserialize)]
1627pub enum IdentifierStyle {
1628 Capitalize,
1629
1630 Free,
1631
1632 Lowercase,
1633
1634 Uppercase,
1635}
1636
1637/// "Image export" option when saving project. Possible values: `None`, `OneImagePerLayer`,
1638/// `OneImagePerLevel`, `LayersAndLevels`
1639#[derive(Debug, Clone, Serialize, Deserialize)]
1640pub enum ImageExportMode {
1641 #[serde(rename = "LayersAndLevels")]
1642 LayersAndLevels,
1643
1644 None,
1645
1646 #[serde(rename = "OneImagePerLayer")]
1647 OneImagePerLayer,
1648
1649 #[serde(rename = "OneImagePerLevel")]
1650 OneImagePerLevel,
1651}