mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 00:31:34 +11:00
Pass through a crate prefix
This commit is contained in:
parent
c6b1c4b824
commit
4516c8dfc0
|
@ -35,6 +35,9 @@ pub struct ImageConverterConfig {
|
|||
tile_size: TileSize,
|
||||
input_image: PathBuf,
|
||||
output_file: PathBuf,
|
||||
|
||||
#[builder(default, setter(strip_option))]
|
||||
crate_prefix: Option<String>,
|
||||
}
|
||||
|
||||
pub fn convert_image(settings: ImageConverterConfig) {
|
||||
|
@ -56,6 +59,7 @@ pub fn convert_image(settings: ImageConverterConfig) {
|
|||
&optimisation_results,
|
||||
&image,
|
||||
settings.tile_size,
|
||||
settings.crate_prefix.unwrap_or("agb".to_owned()),
|
||||
)
|
||||
.expect("Failed to write data");
|
||||
}
|
||||
|
|
|
@ -10,14 +10,20 @@ pub(crate) fn generate_code(
|
|||
results: &Palette16OptimisationResults,
|
||||
image: &Image,
|
||||
tile_size: TileSize,
|
||||
crate_prefix: String,
|
||||
) -> io::Result<()> {
|
||||
writeln!(
|
||||
output,
|
||||
"pub const PALETTE_DATA: &[crate::display::palette16::Palette16] = &[",
|
||||
"pub const PALETTE_DATA: &[{}::display::palette16::Palette16] = &[",
|
||||
crate_prefix,
|
||||
)?;
|
||||
|
||||
for palette in &results.optimised_palettes {
|
||||
write!(output, " crate::display::palette16::Palette16::new([")?;
|
||||
write!(
|
||||
output,
|
||||
" {}::display::palette16::Palette16::new([",
|
||||
crate_prefix
|
||||
)?;
|
||||
|
||||
for colour in palette.clone() {
|
||||
write!(output, "0x{:08x}, ", colour.to_rgb15())?;
|
||||
|
|
Loading…
Reference in a new issue