use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Project {
#[serde(rename = "__FORCED_REFS")]
pub forced_refs: Option<ForcedRefs>,
pub app_build_id: f64,
pub backup_limit: i64,
pub backup_on_save: bool,
pub backup_rel_path: Option<String>,
pub bg_color: String,
pub custom_commands: Vec<LdtkCustomCommand>,
pub default_entity_height: i64,
pub default_entity_width: i64,
pub default_grid_size: i64,
pub default_level_bg_color: String,
pub default_level_height: Option<i64>,
pub default_level_width: Option<i64>,
pub default_pivot_x: f64,
pub default_pivot_y: f64,
pub defs: Definitions,
pub dummy_world_iid: String,
pub export_level_bg: bool,
pub export_png: Option<bool>,
pub export_tiled: bool,
pub external_levels: bool,
pub flags: Vec<Flag>,
pub identifier_style: IdentifierStyle,
pub iid: String,
pub image_export_mode: ImageExportMode,
pub json_version: String,
pub level_name_pattern: String,
pub levels: Vec<Level>,
pub minify_json: bool,
pub next_uid: i64,
pub png_file_pattern: Option<String>,
pub simplified_export: bool,
pub toc: Vec<LdtkTableOfContentEntry>,
pub tutorial_desc: Option<String>,
pub world_grid_height: Option<i64>,
pub world_grid_width: Option<i64>,
pub world_layout: Option<WorldLayout>,
pub worlds: Vec<World>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LdtkCustomCommand {
pub command: String,
pub when: When,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum When {
#[serde(rename = "AfterLoad")]
AfterLoad,
#[serde(rename = "AfterSave")]
AfterSave,
#[serde(rename = "BeforeSave")]
BeforeSave,
Manual,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Definitions {
pub entities: Vec<EntityDefinition>,
pub enums: Vec<EnumDefinition>,
pub external_enums: Vec<EnumDefinition>,
pub layers: Vec<LayerDefinition>,
pub level_fields: Vec<FieldDefinition>,
pub tilesets: Vec<TilesetDefinition>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EntityDefinition {
pub color: String,
pub doc: Option<String>,
pub export_to_toc: bool,
pub field_defs: Vec<FieldDefinition>,
pub fill_opacity: f64,
pub height: i64,
pub hollow: bool,
pub identifier: String,
pub keep_aspect_ratio: bool,
pub limit_behavior: LimitBehavior,
pub limit_scope: LimitScope,
pub line_opacity: f64,
pub max_count: i64,
pub max_height: Option<i64>,
pub max_width: Option<i64>,
pub min_height: Option<i64>,
pub min_width: Option<i64>,
pub nine_slice_borders: Vec<i64>,
pub pivot_x: f64,
pub pivot_y: f64,
pub render_mode: RenderMode,
pub resizable_x: bool,
pub resizable_y: bool,
pub show_name: bool,
pub tags: Vec<String>,
pub tile_id: Option<i64>,
pub tile_opacity: f64,
pub tile_rect: Option<TilesetRectangle>,
pub tile_render_mode: TileRenderMode,
pub tileset_id: Option<i64>,
pub uid: i64,
pub ui_tile_rect: Option<TilesetRectangle>,
pub width: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FieldDefinition {
#[serde(rename = "__type")]
pub field_definition_type: String,
pub accept_file_types: Option<Vec<String>>,
pub allowed_refs: AllowedRefs,
pub allowed_refs_entity_uid: Option<i64>,
pub allowed_ref_tags: Vec<String>,
pub allow_out_of_level_ref: bool,
pub array_max_length: Option<i64>,
pub array_min_length: Option<i64>,
pub auto_chain_ref: bool,
pub can_be_null: bool,
pub default_override: Option<serde_json::Value>,
pub doc: Option<String>,
pub editor_always_show: bool,
pub editor_cut_long_values: bool,
pub editor_display_color: Option<String>,
pub editor_display_mode: EditorDisplayMode,
pub editor_display_pos: EditorDisplayPos,
pub editor_display_scale: f64,
pub editor_link_style: EditorLinkStyle,
pub editor_show_in_world: bool,
pub editor_text_prefix: Option<String>,
pub editor_text_suffix: Option<String>,
pub identifier: String,
pub is_array: bool,
pub max: Option<f64>,
pub min: Option<f64>,
pub regex: Option<String>,
pub symmetrical_ref: bool,
pub text_language_mode: Option<TextLanguageMode>,
pub tileset_uid: Option<i64>,
#[serde(rename = "type")]
pub purple_type: String,
pub uid: i64,
pub use_for_smart_color: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum AllowedRefs {
Any,
#[serde(rename = "OnlySame")]
OnlySame,
#[serde(rename = "OnlySpecificEntity")]
OnlySpecificEntity,
#[serde(rename = "OnlyTags")]
OnlyTags,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum EditorDisplayMode {
#[serde(rename = "ArrayCountNoLabel")]
ArrayCountNoLabel,
#[serde(rename = "ArrayCountWithLabel")]
ArrayCountWithLabel,
#[serde(rename = "EntityTile")]
EntityTile,
Hidden,
#[serde(rename = "LevelTile")]
LevelTile,
#[serde(rename = "NameAndValue")]
NameAndValue,
#[serde(rename = "PointPath")]
PointPath,
#[serde(rename = "PointPathLoop")]
PointPathLoop,
#[serde(rename = "PointStar")]
PointStar,
Points,
#[serde(rename = "RadiusGrid")]
RadiusGrid,
#[serde(rename = "RadiusPx")]
RadiusPx,
#[serde(rename = "RefLinkBetweenCenters")]
RefLinkBetweenCenters,
#[serde(rename = "RefLinkBetweenPivots")]
RefLinkBetweenPivots,
#[serde(rename = "ValueOnly")]
ValueOnly,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum EditorDisplayPos {
Above,
Beneath,
Center,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum EditorLinkStyle {
#[serde(rename = "ArrowsLine")]
ArrowsLine,
#[serde(rename = "CurvedArrow")]
CurvedArrow,
#[serde(rename = "DashedLine")]
DashedLine,
#[serde(rename = "StraightArrow")]
StraightArrow,
#[serde(rename = "ZigZag")]
ZigZag,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum TextLanguageMode {
#[serde(rename = "LangC")]
LangC,
#[serde(rename = "LangHaxe")]
LangHaxe,
#[serde(rename = "LangJS")]
LangJs,
#[serde(rename = "LangJson")]
LangJson,
#[serde(rename = "LangLog")]
LangLog,
#[serde(rename = "LangLua")]
LangLua,
#[serde(rename = "LangMarkdown")]
LangMarkdown,
#[serde(rename = "LangPython")]
LangPython,
#[serde(rename = "LangRuby")]
LangRuby,
#[serde(rename = "LangXml")]
LangXml,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum LimitBehavior {
#[serde(rename = "DiscardOldOnes")]
DiscardOldOnes,
#[serde(rename = "MoveLastOne")]
MoveLastOne,
#[serde(rename = "PreventAdding")]
PreventAdding,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum LimitScope {
#[serde(rename = "PerLayer")]
PerLayer,
#[serde(rename = "PerLevel")]
PerLevel,
#[serde(rename = "PerWorld")]
PerWorld,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum RenderMode {
Cross,
Ellipse,
Rectangle,
Tile,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TilesetRectangle {
pub h: i64,
pub tileset_uid: i64,
pub w: i64,
pub x: i64,
pub y: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum TileRenderMode {
Cover,
#[serde(rename = "FitInside")]
FitInside,
#[serde(rename = "FullSizeCropped")]
FullSizeCropped,
#[serde(rename = "FullSizeUncropped")]
FullSizeUncropped,
#[serde(rename = "NineSlice")]
NineSlice,
Repeat,
Stretch,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EnumDefinition {
pub external_file_checksum: Option<String>,
pub external_rel_path: Option<String>,
pub icon_tileset_uid: Option<i64>,
pub identifier: String,
pub tags: Vec<String>,
pub uid: i64,
pub values: Vec<EnumValueDefinition>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EnumValueDefinition {
#[serde(rename = "__tileSrcRect")]
pub tile_src_rect: Option<Vec<i64>>,
pub color: i64,
pub id: String,
pub tile_id: Option<i64>,
pub tile_rect: Option<TilesetRectangle>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LayerDefinition {
#[serde(rename = "__type")]
pub layer_definition_type: String,
pub auto_rule_groups: Vec<AutoLayerRuleGroup>,
pub auto_source_layer_def_uid: Option<i64>,
pub auto_tileset_def_uid: Option<i64>,
pub can_select_when_inactive: bool,
pub display_opacity: f64,
pub doc: Option<String>,
pub excluded_tags: Vec<String>,
pub grid_size: i64,
pub guide_grid_hei: i64,
pub guide_grid_wid: i64,
pub hide_fields_when_inactive: bool,
pub hide_in_list: bool,
pub identifier: String,
pub inactive_opacity: f64,
pub int_grid_values: Vec<IntGridValueDefinition>,
pub int_grid_values_groups: Vec<IntGridValueGroupDefinition>,
pub parallax_factor_x: f64,
pub parallax_factor_y: f64,
pub parallax_scaling: bool,
pub px_offset_x: i64,
pub px_offset_y: i64,
pub render_in_world_view: bool,
pub required_tags: Vec<String>,
pub tile_pivot_x: f64,
pub tile_pivot_y: f64,
pub tileset_def_uid: Option<i64>,
#[serde(rename = "type")]
pub purple_type: Type,
pub ui_color: Option<String>,
pub uid: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AutoLayerRuleGroup {
pub active: bool,
pub collapsed: Option<bool>,
pub color: Option<String>,
pub icon: Option<TilesetRectangle>,
pub is_optional: bool,
pub name: String,
pub rules: Vec<AutoLayerRuleDefinition>,
pub uid: i64,
pub uses_wizard: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AutoLayerRuleDefinition {
pub active: bool,
pub alpha: f64,
pub break_on_match: bool,
pub chance: f64,
pub checker: Checker,
pub flip_x: bool,
pub flip_y: bool,
pub out_of_bounds_value: Option<i64>,
pub pattern: Vec<i64>,
pub perlin_active: bool,
pub perlin_octaves: f64,
pub perlin_scale: f64,
pub perlin_seed: f64,
pub pivot_x: f64,
pub pivot_y: f64,
pub size: i64,
pub tile_ids: Vec<i64>,
pub tile_mode: TileMode,
pub tile_random_x_max: i64,
pub tile_random_x_min: i64,
pub tile_random_y_max: i64,
pub tile_random_y_min: i64,
pub tile_x_offset: i64,
pub tile_y_offset: i64,
pub uid: i64,
pub x_modulo: i64,
pub x_offset: i64,
pub y_modulo: i64,
pub y_offset: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Checker {
Horizontal,
None,
Vertical,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum TileMode {
Single,
Stamp,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct IntGridValueDefinition {
pub color: String,
pub group_uid: i64,
pub identifier: Option<String>,
pub tile: Option<TilesetRectangle>,
pub value: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IntGridValueGroupDefinition {
pub color: Option<String>,
pub identifier: Option<String>,
pub uid: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "AutoLayer")]
AutoLayer,
Entities,
#[serde(rename = "IntGrid")]
IntGrid,
Tiles,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TilesetDefinition {
#[serde(rename = "__cHei")]
pub c_hei: i64,
#[serde(rename = "__cWid")]
pub c_wid: i64,
pub cached_pixel_data: Option<HashMap<String, Option<serde_json::Value>>>,
pub custom_data: Vec<TileCustomMetadata>,
pub embed_atlas: Option<EmbedAtlas>,
pub enum_tags: Vec<EnumTagValue>,
pub identifier: String,
pub padding: i64,
pub px_hei: i64,
pub px_wid: i64,
pub rel_path: Option<String>,
pub saved_selections: Vec<HashMap<String, Option<serde_json::Value>>>,
pub spacing: i64,
pub tags: Vec<String>,
pub tags_source_enum_uid: Option<i64>,
pub tile_grid_size: i64,
pub uid: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TileCustomMetadata {
pub data: String,
pub tile_id: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum EmbedAtlas {
#[serde(rename = "LdtkIcons")]
LdtkIcons,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EnumTagValue {
pub enum_value_id: String,
pub tile_ids: Vec<i64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Flag {
#[serde(rename = "DiscardPreCsvIntGrid")]
DiscardPreCsvIntGrid,
#[serde(rename = "ExportPreCsvIntGridFormat")]
ExportPreCsvIntGridFormat,
#[serde(rename = "IgnoreBackupSuggest")]
IgnoreBackupSuggest,
#[serde(rename = "MultiWorlds")]
MultiWorlds,
#[serde(rename = "PrependIndexToLevelFileNames")]
PrependIndexToLevelFileNames,
#[serde(rename = "UseMultilinesType")]
UseMultilinesType,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct ForcedRefs {
pub auto_layer_rule_group: Option<AutoLayerRuleGroup>,
pub auto_rule_def: Option<AutoLayerRuleDefinition>,
pub custom_command: Option<LdtkCustomCommand>,
pub definitions: Option<Definitions>,
pub entity_def: Option<EntityDefinition>,
pub entity_instance: Option<EntityInstance>,
pub entity_reference_infos: Option<ReferenceToAnEntityInstance>,
pub enum_def: Option<EnumDefinition>,
pub enum_def_values: Option<EnumValueDefinition>,
pub enum_tag_value: Option<EnumTagValue>,
pub field_def: Option<FieldDefinition>,
pub field_instance: Option<FieldInstance>,
pub grid_point: Option<GridPoint>,
pub int_grid_value_def: Option<IntGridValueDefinition>,
pub int_grid_value_group_def: Option<IntGridValueGroupDefinition>,
pub int_grid_value_instance: Option<IntGridValueInstance>,
pub layer_def: Option<LayerDefinition>,
pub layer_instance: Option<LayerInstance>,
pub level: Option<Level>,
pub level_bg_pos_infos: Option<LevelBackgroundPosition>,
pub neighbour_level: Option<NeighbourLevel>,
pub table_of_content_entry: Option<LdtkTableOfContentEntry>,
pub tile: Option<TileInstance>,
pub tile_custom_metadata: Option<TileCustomMetadata>,
pub tileset_def: Option<TilesetDefinition>,
pub tileset_rect: Option<TilesetRectangle>,
pub world: Option<World>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EntityInstance {
#[serde(rename = "__grid")]
pub grid: Vec<i64>,
#[serde(rename = "__identifier")]
pub identifier: String,
#[serde(rename = "__pivot")]
pub pivot: Vec<f64>,
#[serde(rename = "__smartColor")]
pub smart_color: String,
#[serde(rename = "__tags")]
pub tags: Vec<String>,
#[serde(rename = "__tile")]
pub tile: Option<TilesetRectangle>,
#[serde(rename = "__worldX")]
pub world_x: i64,
#[serde(rename = "__worldY")]
pub world_y: i64,
pub def_uid: i64,
pub field_instances: Vec<FieldInstance>,
pub height: i64,
pub iid: String,
pub px: Vec<i64>,
pub width: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FieldInstance {
#[serde(rename = "__identifier")]
pub identifier: String,
#[serde(rename = "__tile")]
pub tile: Option<TilesetRectangle>,
#[serde(rename = "__type")]
pub field_instance_type: String,
#[serde(rename = "__value")]
pub value: Option<serde_json::Value>,
pub def_uid: i64,
pub real_editor_values: Vec<Option<serde_json::Value>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ReferenceToAnEntityInstance {
pub entity_iid: String,
pub layer_iid: String,
pub level_iid: String,
pub world_iid: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GridPoint {
pub cx: i64,
pub cy: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct IntGridValueInstance {
pub coord_id: i64,
pub v: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LayerInstance {
#[serde(rename = "__cHei")]
pub c_hei: i64,
#[serde(rename = "__cWid")]
pub c_wid: i64,
#[serde(rename = "__gridSize")]
pub grid_size: i64,
#[serde(rename = "__identifier")]
pub identifier: String,
#[serde(rename = "__opacity")]
pub opacity: f64,
#[serde(rename = "__pxTotalOffsetX")]
pub px_total_offset_x: i64,
#[serde(rename = "__pxTotalOffsetY")]
pub px_total_offset_y: i64,
#[serde(rename = "__tilesetDefUid")]
pub tileset_def_uid: Option<i64>,
#[serde(rename = "__tilesetRelPath")]
pub tileset_rel_path: Option<String>,
#[serde(rename = "__type")]
pub layer_instance_type: String,
pub auto_layer_tiles: Vec<TileInstance>,
pub entity_instances: Vec<EntityInstance>,
pub grid_tiles: Vec<TileInstance>,
pub iid: String,
pub int_grid: Option<Vec<IntGridValueInstance>>,
pub int_grid_csv: Vec<i64>,
pub layer_def_uid: i64,
pub level_id: i64,
pub optional_rules: Vec<i64>,
pub override_tileset_uid: Option<i64>,
pub px_offset_x: i64,
pub px_offset_y: i64,
pub seed: i64,
pub visible: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TileInstance {
pub a: f64,
pub d: Vec<i64>,
pub f: i64,
pub px: Vec<i64>,
pub src: Vec<i64>,
pub t: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Level {
#[serde(rename = "__bgColor")]
pub bg_color: String,
#[serde(rename = "__bgPos")]
pub bg_pos: Option<LevelBackgroundPosition>,
#[serde(rename = "__neighbours")]
pub neighbours: Vec<NeighbourLevel>,
#[serde(rename = "__smartColor")]
pub smart_color: String,
#[serde(rename = "bgColor")]
pub level_bg_color: Option<String>,
pub bg_pivot_x: f64,
pub bg_pivot_y: f64,
#[serde(rename = "bgPos")]
pub level_bg_pos: Option<BgPos>,
pub bg_rel_path: Option<String>,
pub external_rel_path: Option<String>,
pub field_instances: Vec<FieldInstance>,
pub identifier: String,
pub iid: String,
pub layer_instances: Option<Vec<LayerInstance>>,
pub px_hei: i64,
pub px_wid: i64,
pub uid: i64,
pub use_auto_identifier: bool,
pub world_depth: i64,
pub world_x: i64,
pub world_y: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LevelBackgroundPosition {
pub crop_rect: Vec<f64>,
pub scale: Vec<f64>,
pub top_left_px: Vec<i64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum BgPos {
Contain,
Cover,
#[serde(rename = "CoverDirty")]
CoverDirty,
Repeat,
Unscaled,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NeighbourLevel {
pub dir: String,
pub level_iid: String,
pub level_uid: Option<i64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LdtkTableOfContentEntry {
pub identifier: String,
pub instances: Vec<ReferenceToAnEntityInstance>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct World {
pub default_level_height: i64,
pub default_level_width: i64,
pub identifier: String,
pub iid: String,
pub levels: Vec<Level>,
pub world_grid_height: i64,
pub world_grid_width: i64,
pub world_layout: Option<WorldLayout>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum WorldLayout {
Free,
#[serde(rename = "GridVania")]
GridVania,
#[serde(rename = "LinearHorizontal")]
LinearHorizontal,
#[serde(rename = "LinearVertical")]
LinearVertical,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum IdentifierStyle {
Capitalize,
Free,
Lowercase,
Uppercase,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ImageExportMode {
#[serde(rename = "LayersAndLevels")]
LayersAndLevels,
None,
#[serde(rename = "OneImagePerLayer")]
OneImagePerLayer,
#[serde(rename = "OneImagePerLevel")]
OneImagePerLevel,
}