pub mod types;

use super::args::{ColorType, Point};
use clap::Args;
use std::io::Write;
use types::Header;
use tool_helper::{Error, Input};

#[derive(Args)]
pub struct Arguments {
    #[clap(flatten)]
    global: super::args::Arguments,

    #[clap(long, value_parser, default_value_t, value_name = Point::POINT_VALUE_NAME)]
    clut_pos: Point,

    #[clap(long, value_parser, default_value_t, value_name = Point::POINT_VALUE_NAME)]
    tex_pos: Point,
}

pub fn convert(args: Arguments, input: Input, output: &mut dyn Write) -> Result<(), Error> {
    let     global_args = args.global;
    let mut header_conv = Header::default();

    match global_args.color_depth {
        ColorType::Full16 => super::convert_full16(&mut header_conv, input, output, args.tex_pos),
        _                 => super::convert_palette_based(&mut header_conv, input, output, args.tex_pos, args.clut_pos, global_args.color_depth, global_args.clut_align, global_args.semi_transparent, global_args.transparent_palette),
    }
}