pub struct Wrapper { /* private fields */ }Expand description
A wrapper around Lunar Magic’s command line functionality.
Up to date as of Lunar Magic 3.40.
Implementations§
Source§impl Wrapper
impl Wrapper
Sourcepub fn new<P: Into<PathBuf>>(path: P) -> Self
pub fn new<P: Into<PathBuf>>(path: P) -> Self
Returns a new Wrapper.
Note that there doesn’t necessarily have to be a Lunar Magic executable at the passed path at time of creation. It only needs to exist once you try to actually use the wrapper to perform operations.
§Examples
use lunar_magic_wrapper::Wrapper;
let lm_wrapper = Wrapper::new("C:/programs/LunarMagic/lunar_magic.exe");Sourcepub fn export_gfx<P: AsRef<Path>>(&self, rom_path: P) -> ResultL
pub fn export_gfx<P: AsRef<Path>>(&self, rom_path: P) -> ResultL
Exports Graphics from the passed ROM and returns Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.export_gfx("C:/hacks/my_project/my_hack.smc");Sourcepub fn export_exgfx<P: AsRef<Path>>(&self, rom_path: P) -> ResultL
pub fn export_exgfx<P: AsRef<Path>>(&self, rom_path: P) -> ResultL
Exports ExGraphics from the passed ROM and returns Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.export_exgfx("C:/hacks/my_project/my_hack.smc");Sourcepub fn import_gfx<P: AsRef<Path>>(&self, rom_path: P) -> ResultL
pub fn import_gfx<P: AsRef<Path>>(&self, rom_path: P) -> ResultL
Imports Graphics into the passed ROM and returns Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.import_gfx("C:/hacks/my_project/my_hack.smc");Sourcepub fn import_exgfx<P: AsRef<Path>>(&self, rom_path: P) -> ResultL
pub fn import_exgfx<P: AsRef<Path>>(&self, rom_path: P) -> ResultL
Imports ExGraphics into the passed ROM and returns Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.import_exgfx("C:/hacks/my_project/my_hack.smc");Sourcepub fn import_all_graphics<P: AsRef<Path>>(&self, rom_path: P) -> ResultL
pub fn import_all_graphics<P: AsRef<Path>>(&self, rom_path: P) -> ResultL
Imports all graphics into the passed ROM and returns Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.import_all_graphics("C:/hacks/my_project/my_hack.smc");Sourcepub fn export_level<P, M>(
&self,
rom_path: P,
mwl_path: M,
level_number: u16,
) -> ResultL
pub fn export_level<P, M>( &self, rom_path: P, mwl_path: M, level_number: u16, ) -> ResultL
Exports the specified level number as an MWL at the specified location from the passed ROM and returns Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.export_level(
"C:/hacks/my_project/my_hack.smc",
"C:/hacks/my_project/levels/level 105.mwl",
105
);Sourcepub fn import_level<P, M>(
&self,
rom_path: P,
mwl_path: M,
level_number: Option<u16>,
) -> ResultL
pub fn import_level<P, M>( &self, rom_path: P, mwl_path: M, level_number: Option<u16>, ) -> ResultL
Imports the specified MWL file as the (optionally) specified level number into the passed ROM and returns Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
Without specifying a level number:
let output = lm_wrapper.import_level(
"C:/hacks/my_project/my_hack.smc",
"C:/hacks/my_project/levels/level 105.mwl",
None
);With specifying a level number:
let output = lm_wrapper.import_level(
"C:/hacks/my_project/my_hack.smc",
"C:/hacks/my_project/levels/level 105.mwl",
Some(107)
);Sourcepub fn import_map16<P, M>(
&self,
rom_path: P,
map16_path: M,
level_number: u16,
location: Option<(u32, u32)>,
) -> ResultL
pub fn import_map16<P, M>( &self, rom_path: P, map16_path: M, level_number: u16, location: Option<(u32, u32)>, ) -> ResultL
Imports the specified map16 file into the passed ROM at the (optionally) specified X, Y map16 location using the tileset of the specified level and returns Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
Without a location:
let output = lm_wrapper.import_map16(
"C:/hacks/my_project/my_hack.smc",
"C:/hacks/my_project/resources/tiles.map16",
105,
None
);With a location:
let output = lm_wrapper.import_map16(
"C:/hacks/my_project/my_hack.smc",
"C:/hacks/my_project/resources/tiles.map16",
105,
Some((0x02, 0x40))
);Sourcepub fn import_custom_palette<P: AsRef<Path>, Q: AsRef<Path>>(
&self,
rom_path: P,
palette_path: Q,
level_number: u16,
) -> ResultL
pub fn import_custom_palette<P: AsRef<Path>, Q: AsRef<Path>>( &self, rom_path: P, palette_path: Q, level_number: u16, ) -> ResultL
Imports the passed custom palette file into the specified level in the passed ROM and returns Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.import_custom_palette(
"C:/hacks/my_project/my_hack.smc",
"C:/hacks/my_project/resources/my_palette.pal",
105
);Exports shared palette from the passed ROM to the specified output path and returns Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.export_shared_palette(
"C:/hacks/my_project/my_hack.smc",
"C:/hacks/my_project/resources/shared.pal"
);Imports passed shared palette into the passed ROM and returns Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.import_shared_palette(
"C:/hacks/my_project/my_hack.smc",
"C:/hacks/my_project/resources/shared.pal"
);Sourcepub fn export_all_map16<P, M>(&self, rom_path: P, map16_path: M) -> ResultL
pub fn export_all_map16<P, M>(&self, rom_path: P, map16_path: M) -> ResultL
Exports all map16 data from the passed ROM to the specified output path and returns Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.export_all_map16(
"C:/hacks/my_project/my_hack.smc",
"C:/hacks/my_project/resources/all.map16"
);Sourcepub fn import_all_map16<P, M>(&self, rom_path: P, map16_path: M) -> ResultL
pub fn import_all_map16<P, M>(&self, rom_path: P, map16_path: M) -> ResultL
Imports the passed all map16 file into the passed ROM and returns Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.import_all_map16(
"C:/hacks/my_project/my_hack.smc",
"C:/hacks/my_project/resources/all.map16"
);Sourcepub fn export_mult_levels<P: AsRef<Path>, M: AsRef<Path>>(
&self,
rom_path: P,
mwl_path: M,
flags: Option<LevelExportFlag>,
) -> ResultL
pub fn export_mult_levels<P: AsRef<Path>, M: AsRef<Path>>( &self, rom_path: P, mwl_path: M, flags: Option<LevelExportFlag>, ) -> ResultL
Exports multiple levels from the passed ROM to the specified location using the (optionally) specified flags and returns Lunar Magic’s text output or a WrapperErr if something went wrong.
Flags can be specified using the LevelExportFlag enum. Note that if flags are omitted, Lunar Magic will use its default settings for them.
§Examples
Without flags:
// MWL files will be prefixed with "level ", i.e. "level 105.mwl", etc.
// and be contained in `C:/hacks/my_project/resources/levels`
let output = lm_wrapper.export_mult_levels(
"C:/hacks/my_project/my_hack.smc",
"C:/hacks/my_project/resources/levels/level ",
None
);With flags:
// MWL files will be prefixed with "level ", i.e. "level 105.mwl", etc.
// and be contained in `C:/hacks/my_project/resources/levels`
let output = lm_wrapper.export_mult_levels(
"C:/hacks/my_project/my_hack.smc",
"C:/hacks/my_project/resources/levels/level ",
Some(LevelExportFlag::None)
);Sourcepub fn import_mult_levels<P: AsRef<Path>, L: AsRef<Path>>(
&self,
rom_path: P,
level_directory: L,
flags: Option<LevelImportFlag>,
) -> ResultL
pub fn import_mult_levels<P: AsRef<Path>, L: AsRef<Path>>( &self, rom_path: P, level_directory: L, flags: Option<LevelImportFlag>, ) -> ResultL
Imports multiple levels into the passed ROM from the specified location using the (optionally) specified flags and returns Lunar Magic’s text output or a WrapperErr if something went wrong.
Flags can be specified using the LevelImportFlag enum. Note that if flags are omitted, Lunar Magic will use its default settings for them.
§Examples
Without flags:
let output = lm_wrapper.import_mult_levels(
"C:/hacks/my_project/my_hack.smc",
"C:/hacks/my_project/resources/levels",
None
);With flags:
let output = lm_wrapper.import_mult_levels(
"C:/hacks/my_project/my_hack.smc",
"C:/hacks/my_project/resources/levels",
Some(LevelImportFlag::None)
);Sourcepub fn expand_rom<P: AsRef<Path>>(
&self,
rom_path: P,
rom_size: RomSize,
) -> ResultL
pub fn expand_rom<P: AsRef<Path>>( &self, rom_path: P, rom_size: RomSize, ) -> ResultL
Expands the passed ROM to the specified size and returns Lunar Magic’s text output or an WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.expand_rom(
"C:/hacks/my_project/my_hack.smc",
RomSize::_4mb
);Sourcepub fn change_compression<P: AsRef<Path>>(
&self,
rom_path: P,
compression_format: CompressionFormat,
) -> ResultL
pub fn change_compression<P: AsRef<Path>>( &self, rom_path: P, compression_format: CompressionFormat, ) -> ResultL
Changes the compression of the passed ROM to the specified format and returns Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.change_compression(
"C:/hacks/my_project/my_hack.smc",
CompressionFormat::LcLz2Speed
);Sourcepub fn transfer_level_global_exanim<D, S>(
&self,
dest_rom_path: D,
src_rom_path: S,
) -> ResultL
pub fn transfer_level_global_exanim<D, S>( &self, dest_rom_path: D, src_rom_path: S, ) -> ResultL
Transfers level global ExAnimation data from source ROM to destination ROM and return Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.transfer_level_global_exanim(
"C:/hacks/my_project/destination.smc",
"C:/hacks/my_project/source.smc"
);Sourcepub fn transfer_overworld<D, S>(
&self,
dest_rom_path: D,
src_rom_path: S,
) -> ResultL
pub fn transfer_overworld<D, S>( &self, dest_rom_path: D, src_rom_path: S, ) -> ResultL
Transfers overworld data from source ROM to destination ROM and return Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.transfer_overworld(
"C:/hacks/my_project/destination.smc",
"C:/hacks/my_project/source.smc"
);Sourcepub fn transfer_title_screen<D, S>(
&self,
dest_rom_path: D,
src_rom_path: S,
) -> ResultL
pub fn transfer_title_screen<D, S>( &self, dest_rom_path: D, src_rom_path: S, ) -> ResultL
Transfers title screen data from source ROM to destination ROM and return Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.transfer_title_screen(
"C:/hacks/my_project/destination.smc",
"C:/hacks/my_project/source.smc"
);Sourcepub fn transfer_credits<D, S>(
&self,
dest_rom_path: D,
src_rom_path: S,
) -> ResultL
pub fn transfer_credits<D, S>( &self, dest_rom_path: D, src_rom_path: S, ) -> ResultL
Transfers credit data from source ROM to destination ROM and return Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.transfer_credits(
"C:/hacks/my_project/destination.smc",
"C:/hacks/my_project/source.smc"
);Sourcepub fn export_title_moves<D, S>(
&self,
rom_path: D,
title_moves_path: S,
) -> ResultL
pub fn export_title_moves<D, S>( &self, rom_path: D, title_moves_path: S, ) -> ResultL
Exports title screen movement data from the passed ROM to the specified location and returns Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.export_title_moves(
"C:/hacks/my_project/my_hack.smc",
"C:/hacks/my_project/resources/title_screen_movement.zst"
);Sourcepub fn import_title_moves<P, T>(
&self,
rom_path: P,
title_moves_path: T,
) -> ResultL
pub fn import_title_moves<P, T>( &self, rom_path: P, title_moves_path: T, ) -> ResultL
Imports title screen movement data into the passed ROM from the specified location and returns Lunar Magic’s text output or a WrapperErr if something went wrong.
§Examples
let output = lm_wrapper.import_title_moves(
"C:/hacks/my_project/my_hack.smc",
"C:/hacks/my_project/resources/title_screen_movement.zst"
);