Wrapper

Struct Wrapper 

Source
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

Source

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");
Source

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");
Source

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");
Source

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");
Source

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");
Source

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");
Source

pub fn export_level<P, M>( &self, rom_path: P, mwl_path: M, level_number: u16, ) -> ResultL
where P: AsRef<Path>, M: AsRef<Path>,

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
);
Source

pub fn import_level<P, M>( &self, rom_path: P, mwl_path: M, level_number: Option<u16>, ) -> ResultL
where P: AsRef<Path>, M: AsRef<Path>,

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)
);
Source

pub fn import_map16<P, M>( &self, rom_path: P, map16_path: M, level_number: u16, location: Option<(u32, u32)>, ) -> ResultL
where P: AsRef<Path>, M: AsRef<Path>,

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))
);
Source

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
);
Source

pub fn export_shared_palette<P, Q>( &self, rom_path: P, palette_path: Q, ) -> ResultL
where P: AsRef<Path>, Q: AsRef<Path>,

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"
);
Source

pub fn import_shared_palette<P, Q>( &self, rom_path: P, palette_path: Q, ) -> ResultL
where P: AsRef<Path>, Q: AsRef<Path>,

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"
);
Source

pub fn export_all_map16<P, M>(&self, rom_path: P, map16_path: M) -> ResultL
where P: AsRef<Path>, M: AsRef<Path>,

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"
);
Source

pub fn import_all_map16<P, M>(&self, rom_path: P, map16_path: M) -> ResultL
where P: AsRef<Path>, M: AsRef<Path>,

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"
);
Source

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)
);
Source

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)
);
Source

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
);
Source

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
);
Source

pub fn transfer_level_global_exanim<D, S>( &self, dest_rom_path: D, src_rom_path: S, ) -> ResultL
where D: AsRef<Path>, S: AsRef<Path>,

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"
);
Source

pub fn transfer_overworld<D, S>( &self, dest_rom_path: D, src_rom_path: S, ) -> ResultL
where D: AsRef<Path>, S: AsRef<Path>,

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"
);
Source

pub fn transfer_title_screen<D, S>( &self, dest_rom_path: D, src_rom_path: S, ) -> ResultL
where D: AsRef<Path>, S: AsRef<Path>,

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"
);
Source

pub fn transfer_credits<D, S>( &self, dest_rom_path: D, src_rom_path: S, ) -> ResultL
where D: AsRef<Path>, S: AsRef<Path>,

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"
);
Source

pub fn export_title_moves<D, S>( &self, rom_path: D, title_moves_path: S, ) -> ResultL
where D: AsRef<Path>, S: AsRef<Path>,

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"
);
Source

pub fn import_title_moves<P, T>( &self, rom_path: P, title_moves_path: T, ) -> ResultL
where P: AsRef<Path>, T: AsRef<Path>,

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"
);

Trait Implementations§

Source§

impl Debug for Wrapper

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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.