mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 17:41:33 +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,
|
tile_size: TileSize,
|
||||||
input_image: PathBuf,
|
input_image: PathBuf,
|
||||||
output_file: PathBuf,
|
output_file: PathBuf,
|
||||||
|
|
||||||
|
#[builder(default, setter(strip_option))]
|
||||||
|
crate_prefix: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn convert_image(settings: ImageConverterConfig) {
|
pub fn convert_image(settings: ImageConverterConfig) {
|
||||||
|
@ -56,6 +59,7 @@ pub fn convert_image(settings: ImageConverterConfig) {
|
||||||
&optimisation_results,
|
&optimisation_results,
|
||||||
&image,
|
&image,
|
||||||
settings.tile_size,
|
settings.tile_size,
|
||||||
|
settings.crate_prefix.unwrap_or("agb".to_owned()),
|
||||||
)
|
)
|
||||||
.expect("Failed to write data");
|
.expect("Failed to write data");
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,14 +10,20 @@ pub(crate) fn generate_code(
|
||||||
results: &Palette16OptimisationResults,
|
results: &Palette16OptimisationResults,
|
||||||
image: &Image,
|
image: &Image,
|
||||||
tile_size: TileSize,
|
tile_size: TileSize,
|
||||||
|
crate_prefix: String,
|
||||||
) -> io::Result<()> {
|
) -> io::Result<()> {
|
||||||
writeln!(
|
writeln!(
|
||||||
output,
|
output,
|
||||||
"pub const PALETTE_DATA: &[crate::display::palette16::Palette16] = &[",
|
"pub const PALETTE_DATA: &[{}::display::palette16::Palette16] = &[",
|
||||||
|
crate_prefix,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
for palette in &results.optimised_palettes {
|
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() {
|
for colour in palette.clone() {
|
||||||
write!(output, "0x{:08x}, ", colour.to_rgb15())?;
|
write!(output, "0x{:08x}, ", colour.to_rgb15())?;
|
||||||
|
|
Loading…
Reference in a new issue