Project

Struct Project 

Source
pub struct Project {
Show 30 fields pub forced_refs: Option<ForcedRefs>, pub app_build_id: f64, pub backup_limit: i64, pub backup_on_save: bool, pub bg_color: String, 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 export_png: Option<bool>, pub export_tiled: bool, pub external_levels: bool, pub flags: Vec<Flag>, pub identifier_style: IdentifierStyle, 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 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>,
}
Expand description

This file is a JSON schema of files created by LDtk level editor (https://ldtk.io).

This is the root of any Project JSON file. It contains: - the project settings, - an array of levels, - a group of definitions (that can probably be safely ignored for most users).

Fields§

§forced_refs: Option<ForcedRefs>

This object is not actually used by LDtk. It ONLY exists to force explicit references to all types, to make sure QuickType finds them and integrate all of them. Otherwise, Quicktype will drop types that are not explicitely used.

§app_build_id: f64

LDtk application build identifier.
This is only used to identify the LDtk version that generated this particular project file, which can be useful for specific bug fixing. Note that the build identifier is just the date of the release, so it’s not unique to each user (one single global ID per LDtk public release), and as a result, completely anonymous.

§backup_limit: i64

Number of backup files to keep, if the backupOnSave is TRUE

§backup_on_save: bool

If TRUE, an extra copy of the project will be created in a sub folder, when saving.

§bg_color: String

Project background color

§default_grid_size: i64

Default grid size for new layers

§default_level_bg_color: String

Default background color of levels

§default_level_height: Option<i64>

WARNING: this field will move to the worlds array after the “multi-worlds” update. It will then be null. You can enable the Multi-worlds advanced project option to enable the change immediately.

Default new level height

§default_level_width: Option<i64>

WARNING: this field will move to the worlds array after the “multi-worlds” update. It will then be null. You can enable the Multi-worlds advanced project option to enable the change immediately.

Default new level width

§default_pivot_x: f64

Default X pivot (0 to 1) for new entities

§default_pivot_y: f64

Default Y pivot (0 to 1) for new entities

§defs: Definitions

A structure containing all the definitions of this project

§export_png: Option<bool>

WARNING: this deprecated value is no longer exported since version 0.9.3 Replaced by: imageExportMode

§export_tiled: bool

If TRUE, a Tiled compatible file will also be generated along with the LDtk JSON file (default is FALSE)

§external_levels: bool

If TRUE, one file will be saved for the project (incl. all its definitions) and one file in a sub-folder for each level.

§flags: Vec<Flag>

An array containing various advanced flags (ie. options or other states). Possible values: DiscardPreCsvIntGrid, ExportPreCsvIntGridFormat, IgnoreBackupSuggest, PrependIndexToLevelFileNames, MultiWorlds, UseMultilinesType

§identifier_style: IdentifierStyle

Naming convention for Identifiers (first-letter uppercase, full uppercase etc.) Possible values: Capitalize, Uppercase, Lowercase, Free

§image_export_mode: ImageExportMode

“Image export” option when saving project. Possible values: None, OneImagePerLayer, OneImagePerLevel, LayersAndLevels

§json_version: String

File format version

§level_name_pattern: String

The default naming convention for level identifiers.

§levels: Vec<Level>

All levels. The order of this array is only relevant in LinearHorizontal and linearVertical world layouts (see worldLayout value).
Otherwise, you should refer to the worldX,worldY coordinates of each Level.

§minify_json: bool

If TRUE, the Json is partially minified (no indentation, nor line breaks, default is FALSE)

§next_uid: i64

Next Unique integer ID available

§png_file_pattern: Option<String>

File naming pattern for exported PNGs

§simplified_export: bool

If TRUE, a very simplified will be generated on saving, for quicker & easier engine integration.

§tutorial_desc: Option<String>

This optional description is used by LDtk Samples to show up some informations and instructions.

§world_grid_height: Option<i64>

WARNING: this field will move to the worlds array after the “multi-worlds” update. It will then be null. You can enable the Multi-worlds advanced project option to enable the change immediately.

Height of the world grid in pixels.

§world_grid_width: Option<i64>

WARNING: this field will move to the worlds array after the “multi-worlds” update. It will then be null. You can enable the Multi-worlds advanced project option to enable the change immediately.

Width of the world grid in pixels.

§world_layout: Option<WorldLayout>

WARNING: this field will move to the worlds array after the “multi-worlds” update. It will then be null. You can enable the Multi-worlds advanced project option to enable the change immediately.

An enum that describes how levels are organized in this project (ie. linearly or in a 2D space). Possible values: <null>, Free, GridVania, LinearHorizontal, LinearVertical

§worlds: Vec<World>

This array is not used yet in current LDtk version (so, for now, it’s always empty).

In a later update, it will be possible to have multiple Worlds in a single project, each containing multiple Levels.

What will change when “Multiple worlds” support will be added to LDtk:

- in current version, a LDtk project file can only contain a single world with multiple levels in it. In this case, levels and world layout related settings are stored in the root of the JSON.
- after the “Multiple worlds” update, there will be a worlds array in root, each world containing levels and layout settings. Basically, it’s pretty much only about moving the levels array to the worlds array, along with world layout related values (eg. worldGridWidth etc).

If you want to start supporting this future update easily, please refer to this documentation: https://github.com/deepnight/ldtk/issues/231

Implementations§

Source§

impl Project

Source

pub fn new<P: AsRef<Path>>(f: P) -> Self

Source

pub fn load_project<P: AsRef<Path>>(f: P) -> Self

Source

pub fn clear_levels(&mut self)

Source

pub fn load_external_levels<P: AsRef<Path>>(&mut self, f: P)

Source

pub fn get_level(&self, uid: i64) -> Option<&Level>

Trait Implementations§

Source§

impl<'de> Deserialize<'de> for Project

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Project

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,