mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 00:31:34 +11:00
Fix all the clippy lints
This commit is contained in:
parent
62e0c346c5
commit
5234c7181e
|
@ -2,7 +2,7 @@ use std::env;
|
||||||
|
|
||||||
use agb_image_converter::{convert_image, ImageConverterConfig, TileSize};
|
use agb_image_converter::{convert_image, ImageConverterConfig, TileSize};
|
||||||
|
|
||||||
fn main() -> () {
|
fn main() {
|
||||||
let args: Vec<_> = env::args().collect();
|
let args: Vec<_> = env::args().collect();
|
||||||
|
|
||||||
let file_path = &args[1];
|
let file_path = &args[1];
|
||||||
|
@ -12,6 +12,5 @@ fn main() -> () {
|
||||||
tile_size: TileSize::Tile8,
|
tile_size: TileSize::Tile8,
|
||||||
input_image: file_path.into(),
|
input_image: file_path.into(),
|
||||||
output_file: output_path.into(),
|
output_file: output_path.into(),
|
||||||
output_name: "HELLO".to_owned(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ impl Colour {
|
||||||
Colour { r, g, b }
|
Colour { r, g, b }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_rgb15(&self) -> u16 {
|
pub fn to_rgb15(self) -> u16 {
|
||||||
let (r, g, b) = (self.r as u16, self.g as u16, self.b as u16);
|
let (r, g, b) = (self.r as u16, self.g as u16, self.b as u16);
|
||||||
((r >> 3) & 31) | (((g >> 3) & 31) << 5) | (((b >> 3) & 31) << 10)
|
((r >> 3) & 31) | (((g >> 3) & 31) << 5) | (((b >> 3) & 31) << 10)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ pub enum TileSize {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TileSize {
|
impl TileSize {
|
||||||
fn to_size(&self) -> usize {
|
fn to_size(self) -> usize {
|
||||||
match &self {
|
match self {
|
||||||
TileSize::Tile8 => 8,
|
TileSize::Tile8 => 8,
|
||||||
TileSize::Tile16 => 16,
|
TileSize::Tile16 => 16,
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ impl Palette16Optimiser {
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect::<HashSet<Palette16>>();
|
.collect::<HashSet<Palette16>>();
|
||||||
|
|
||||||
while unsatisfied_palettes.len() > 0 {
|
while !unsatisfied_palettes.is_empty() {
|
||||||
let palette = self.find_maximal_palette_for(&unsatisfied_palettes, transparent_colour);
|
let palette = self.find_maximal_palette_for(&unsatisfied_palettes, transparent_colour);
|
||||||
|
|
||||||
for test_palette in unsatisfied_palettes.clone() {
|
for test_palette in unsatisfied_palettes.clone() {
|
||||||
|
@ -130,8 +130,8 @@ impl Palette16Optimiser {
|
||||||
}
|
}
|
||||||
|
|
||||||
Palette16OptimisationResults {
|
Palette16OptimisationResults {
|
||||||
assignments,
|
|
||||||
optimised_palettes,
|
optimised_palettes,
|
||||||
|
assignments,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,9 @@ pub(crate) fn generate_code(
|
||||||
image: &Image,
|
image: &Image,
|
||||||
tile_size: TileSize,
|
tile_size: TileSize,
|
||||||
) -> io::Result<()> {
|
) -> io::Result<()> {
|
||||||
write!(
|
writeln!(
|
||||||
output,
|
output,
|
||||||
"pub const PALETTE_DATA: &'static [crate::display::palette16::Palette16] = &[\n",
|
"pub const PALETTE_DATA: &'static [crate::display::palette16::Palette16] = &[",
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
for palette in &results.optimised_palettes {
|
for palette in &results.optimised_palettes {
|
||||||
|
@ -27,12 +27,13 @@ pub(crate) fn generate_code(
|
||||||
write!(output, "0x00000000, ")?;
|
write!(output, "0x00000000, ")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(output, "]),\n")?;
|
writeln!(output, "]),")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(output, "];\n\n")?;
|
writeln!(output, "];")?;
|
||||||
|
writeln!(output)?;
|
||||||
|
|
||||||
write!(output, "pub const TILE_DATA: &'static [u32] = &[\n",)?;
|
writeln!(output, "pub const TILE_DATA: &'static [u32] = &[",)?;
|
||||||
|
|
||||||
let tile_size = tile_size.to_size();
|
let tile_size = tile_size.to_size();
|
||||||
|
|
||||||
|
@ -43,9 +44,9 @@ pub(crate) fn generate_code(
|
||||||
for x in 0..tiles_x {
|
for x in 0..tiles_x {
|
||||||
let palette_index = results.assignments[y * tiles_x + x];
|
let palette_index = results.assignments[y * tiles_x + x];
|
||||||
let palette = &results.optimised_palettes[palette_index];
|
let palette = &results.optimised_palettes[palette_index];
|
||||||
write!(
|
writeln!(
|
||||||
output,
|
output,
|
||||||
" /* {}, {} (palette index {}) */\n",
|
" /* {}, {} (palette index {}) */",
|
||||||
x, y, palette_index
|
x, y, palette_index
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
@ -68,11 +69,12 @@ pub(crate) fn generate_code(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(output, "\n")?;
|
writeln!(output)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(output, "];\n\n")?;
|
writeln!(output, "];")?;
|
||||||
|
writeln!(output)?;
|
||||||
|
|
||||||
write!(output, "pub const PALETTE_ASSIGNMENT: &'static [u8] = &[")?;
|
write!(output, "pub const PALETTE_ASSIGNMENT: &'static [u8] = &[")?;
|
||||||
|
|
||||||
|
@ -83,7 +85,7 @@ pub(crate) fn generate_code(
|
||||||
write!(output, "{}, ", assignment)?;
|
write!(output, "{}, ", assignment)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(output, "\n];\n")?;
|
writeln!(output, "\n];")?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue