diff --git a/lib/src/maps/elements/entities.rs b/lib/src/maps/elements/entities.rs index 8fb0622..a7e04e4 100644 --- a/lib/src/maps/elements/entities.rs +++ b/lib/src/maps/elements/entities.rs @@ -213,7 +213,7 @@ macro_rules! entities { } entities! { - FallingBlock + FallingBlock, ZipMover, FakeWall, Spring, Refill ( SpikesUp, "spikesUp", [kind, "type", ResolvableString] @@ -234,11 +234,6 @@ entities! { JumpThru, "jumpThru", [texture, "texture", ResolvableString] ), - ( - ZipMover, "zipMover", - [] - (target) - ), ( Wire, "wire", [above, "above", bool] @@ -315,7 +310,6 @@ unit_entities! { Player, "player", GoldenBerry, "goldenBerry", CrumbleBlock, "crumbleBlock", - Refill, "refill", Checkpoint, "checkpoint", WingedGoldenStrawberry, "memorialTextController", FlutterBird, "flutterbird" @@ -389,3 +383,49 @@ impl Entity for Spring { encoder.optional_attribute("playerCanUse", &self.player_can_use); } } + +#[derive(Debug)] +pub struct ZipMover { + pub theme: Option, + pub to: Node, +} + +impl Entity for ZipMover { + const NAME: &'static str = "zipMover"; + + fn from_raw(parser: MapParser) -> Result + where Self: Sized { + Ok(Self { + theme: parser.get_optional_attribute("theme"), + to: parser.parse_element()?, + }) + } + + fn to_raw(&self, encoder: &mut MapEncoder) { + encoder.optional_attribute("theme", &self.theme); + encoder.child(&self.to); + } +} + +#[derive(Debug)] +pub struct Refill { + pub two_dash: Option, + pub one_use: Option, +} + +impl Entity for Refill { + const NAME: &'static str = "refill"; + + fn from_raw(parser: MapParser) -> Result + where Self: Sized { + Ok(Self { + two_dash: parser.get_optional_attribute("twoDash"), + one_use: parser.get_optional_attribute("oneUse"), + }) + } + + fn to_raw(&self, encoder: &mut MapEncoder) { + encoder.optional_attribute("twoDash", &self.two_dash); + encoder.optional_attribute("oneUse", &self.one_use); + } +} diff --git a/lib/src/maps/elements/level.rs b/lib/src/maps/elements/level.rs index 03adec8..013916d 100644 --- a/lib/src/maps/elements/level.rs +++ b/lib/src/maps/elements/level.rs @@ -56,6 +56,7 @@ pub struct Level { pub disable_down_transition: Option, pub whisper: Option, pub delay_alt_music_fade: Option, + pub enforce_dash_number: Option, pub c: Integer, pub entities: Entities, pub solids: Solids, @@ -64,6 +65,8 @@ pub struct Level { pub fg_decals: FGDecals, pub bg_tiles: BGTiles, pub bg_decals: BGDecals, + pub bg: Background, + pub objtiles: ObjTiles, } impl MapElement for Level { @@ -94,6 +97,7 @@ impl MapElement for Level { disable_down_transition: parser.get_optional_attribute("disableDownTransition"), whisper: parser.get_optional_attribute("whisper"), delay_alt_music_fade: parser.get_optional_attribute("delayAltMusicFade"), + enforce_dash_number: parser.get_optional_attribute("enforceDashNumber"), c: parser.get_attribute("c")?, entities: parser.parse_element()?, solids: parser.parse_element()?, @@ -102,6 +106,8 @@ impl MapElement for Level { fg_decals: parser.parse_element()?, bg_tiles: parser.parse_element()?, bg_decals: parser.parse_element()?, + bg: parser.parse_element()?, + objtiles: parser.parse_element()?, }) } @@ -124,7 +130,7 @@ impl MapElement for Level { } encoder.optional_attribute("ambience", &self.ambience); if let Some(progress) = &self.ambience_progress { - encoder.attribute("musicProgress", progress.clone()); + encoder.attribute("ambienceProgress", progress.clone()); } encoder.attribute("underwater", self.underwater); encoder.optional_attribute("space", &self.space); @@ -136,16 +142,19 @@ impl MapElement for Level { if let Some(alt_music_fade) = self.delay_alt_music_fade { encoder.attribute("delayAltMusicFade", alt_music_fade); } + encoder.optional_attribute("enforceDashNumber", &self.enforce_dash_number); encoder.attribute("x", self.x); encoder.attribute("y", self.y); encoder.attribute("c", self.c); - encoder.child(&self.entities); - encoder.child(&self.solids); encoder.child(&self.triggers); - encoder.child(&self.fg_decals); encoder.child(&self.fg_tiles); - encoder.child(&self.bg_decals); + encoder.child(&self.fg_decals); + encoder.child(&self.solids); + encoder.child(&self.entities); encoder.child(&self.bg_tiles); + encoder.child(&self.bg_decals); + encoder.child(&self.bg); + encoder.child(&self.objtiles); } } @@ -182,6 +191,7 @@ pub struct FGTiles { pub offset_y: Float, pub tileset: ResolvableString, pub export_mode: Integer, + pub inner_text: Option, } impl MapElement for FGTiles { @@ -194,6 +204,7 @@ impl MapElement for FGTiles { offset_y: parser.get_attribute("offsetY")?, tileset: parser.get_attribute("tileset")?, export_mode: parser.get_attribute("exportMode")?, + inner_text: parser.get_optional_attribute("innerText"), }) } @@ -202,6 +213,10 @@ impl MapElement for FGTiles { encoder.attribute("offsetY", self.offset_y); encoder.attribute("tileset", self.tileset.clone()); encoder.attribute("exportMode", self.export_mode); + encoder.optional_attribute( + "innerText", + &self.inner_text.as_ref().map(EncodedVar::new_rle_str), + ) } } @@ -376,6 +391,7 @@ impl MapElement for ObjTiles { encoder.attribute("offsetX", self.offset_x); encoder.attribute("offsetY", self.offset_y); encoder.attribute("tileset", self.tileset.clone()); + encoder.attribute("exportMode", self.export_mode); encoder.optional_attribute( "innerText", &self.inner_text.as_ref().map(EncodedVar::new_rle_str), diff --git a/lib/src/maps/elements/style.rs b/lib/src/maps/elements/style.rs index d596408..4270e7b 100644 --- a/lib/src/maps/elements/style.rs +++ b/lib/src/maps/elements/style.rs @@ -72,16 +72,16 @@ impl MapElement for Foregrounds { } fn to_raw(&self, encoder: &mut MapEncoder) { - encoder.children(&self.parallax_elements); - if self.snow_fg { encoder.child(&SnowFG); } + encoder.children(&self.parallax_elements); } } #[derive(Debug, Clone)] pub struct Parallax { + pub blend_mode: Option, pub texture: ResolvableString, pub x: Float, pub y: Float, @@ -89,6 +89,10 @@ pub struct Parallax { pub scroll_y: Float, pub loopx: bool, pub loopy: bool, + pub speed_x: Option, + pub speed_y: Option, + pub color: Option, + pub alpha: Option, } impl MapElement for Parallax { @@ -96,6 +100,7 @@ impl MapElement for Parallax { fn from_raw(parser: MapParser) -> Result { Ok(Self { + blend_mode: parser.get_optional_attribute("blendmode"), texture: parser.get_attribute("texture")?, x: parser.get_attribute("x")?, y: parser.get_attribute("y")?, @@ -103,10 +108,15 @@ impl MapElement for Parallax { scroll_y: parser.get_attribute("scrolly")?, loopx: parser.get_attribute("loopx")?, loopy: parser.get_attribute("loopy")?, + speed_x: parser.get_optional_attribute("speedx"), + speed_y: parser.get_optional_attribute("speedy"), + color: parser.get_optional_attribute("color"), + alpha: parser.get_optional_attribute("alpha"), }) } fn to_raw(&self, encoder: &mut MapEncoder) { + encoder.optional_attribute("blendmode", &self.blend_mode); encoder.attribute("texture", self.texture.clone()); encoder.attribute("x", self.x); encoder.attribute("y", self.y); @@ -114,6 +124,10 @@ impl MapElement for Parallax { encoder.attribute("scrolly", self.scroll_y); encoder.attribute("loopx", self.loopx); encoder.attribute("loopy", self.loopy); + encoder.optional_attribute("speedx", &self.speed_x); + encoder.optional_attribute("speedy", &self.speed_y); + encoder.optional_attribute("color", &self.color); + encoder.optional_attribute("alpha", &self.alpha); } }