stuff
parent
bd8c217adc
commit
5ccb569b9e
|
@ -8,4 +8,5 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
image = "^0.23"
|
image = "^0.23"
|
||||||
colour = "^0.5"
|
colour = "^0.5"
|
||||||
|
clap = "^2.33"
|
78
src/main.rs
78
src/main.rs
|
@ -1,62 +1,40 @@
|
||||||
extern crate image;
|
extern crate image;
|
||||||
|
extern crate clap;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate colour;
|
extern crate colour;
|
||||||
|
|
||||||
use std::env::{ Args, args };
|
use clap::{App, SubCommand};
|
||||||
use std::process::exit;
|
|
||||||
|
|
||||||
mod reskit;
|
mod reskit;
|
||||||
|
use reskit::utility;
|
||||||
use reskit::tileset;
|
use reskit::tileset;
|
||||||
|
|
||||||
struct ArgumentOption {
|
fn main() {
|
||||||
pub key: String,
|
let matches = App::new( "reskit" )
|
||||||
pub value: String
|
.version( "0.0.1a" )
|
||||||
}
|
.author( "(c) 2021 Ashley N. <ne0ndrag0n@ne0ndrag0n.com>" )
|
||||||
|
.about( "Sega Megadrive resource kit and format converter" )
|
||||||
|
.subcommand(
|
||||||
|
SubCommand::with_name( "tileset" )
|
||||||
|
.about( "Generate a Sega Megadrive VDP tileset + palette from a 15-colour image" )
|
||||||
|
.arg_from_usage( "-i, --input=<FILE> 'Specify input image'" )
|
||||||
|
.arg_from_usage( "-o, --output=<FILE> 'Specify output file'")
|
||||||
|
)
|
||||||
|
.get_matches();
|
||||||
|
|
||||||
fn print_help() {
|
// Get arguments for tileset
|
||||||
println!( "Usage:" );
|
if let Some( matches ) = matches.subcommand_matches( "tileset" ) {
|
||||||
println!( "reskit [plugin] options" );
|
// Get input and output filenames
|
||||||
println!( "" );
|
if let Some( input_filename ) = matches.value_of( "input" ) {
|
||||||
println!( "Available Plugins:" );
|
if let Some( output_filename ) = matches.value_of( "output" ) {
|
||||||
println!( " tileset - Convert 15-colour PNG to Sega Genesis VDP format" );
|
return tileset::generate( input_filename, output_filename );
|
||||||
println!( " Output as .bin containing palette, then tiles");
|
} else {
|
||||||
println!( "" );
|
utility::print_error( "expected: output_filename (-o,--output)" );
|
||||||
println!( "Options:" );
|
}
|
||||||
println!( "--input Specify input file for plugin" );
|
} else {
|
||||||
println!( "--output Specify output file/path for plugin" );
|
utility::print_error( "expected: input filename (-i,--input)" );
|
||||||
}
|
|
||||||
|
|
||||||
fn get_option( arguments: &mut Args ) -> Option< ArgumentOption > {
|
|
||||||
Some( ArgumentOption{ key: arguments.next()?, value: arguments.next()? } )
|
|
||||||
}
|
|
||||||
|
|
||||||
fn load_module( module: String, arguments: Args ) -> i32 {
|
|
||||||
// Discriminate module
|
|
||||||
match module.as_str() {
|
|
||||||
"reskit" => {
|
|
||||||
42
|
|
||||||
},
|
|
||||||
_ => {
|
|
||||||
red!( "fatal: " ); println!( "invalid module: {}", module );
|
|
||||||
2
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
utility::print_error( "no plugin provided (try --help)" );
|
||||||
fn main() {
|
|
||||||
cyan!( "reskit" ); println!( " - Sega Genesis Resource Kit (v0.0.1a)" );
|
|
||||||
println!( "(c) 2021 Ashley N. (ne0ndrag0n)" );
|
|
||||||
|
|
||||||
let mut args = args();
|
|
||||||
args.next(); // Burn arg1
|
|
||||||
|
|
||||||
let mode = match args.next() {
|
|
||||||
Some( mode ) => mode,
|
|
||||||
None => {
|
|
||||||
print_help();
|
|
||||||
exit( 1 );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
exit( load_module( mode, args ) );
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
pub mod tileset;
|
pub mod tileset;
|
||||||
|
pub mod utility;
|
|
@ -1,3 +1,14 @@
|
||||||
pub fn load_tileset() -> i32 {
|
use crate::reskit::utility;
|
||||||
3
|
use image::GenericImageView;
|
||||||
|
|
||||||
|
pub fn generate( image_filename: &str, output_filename: &str ) {
|
||||||
|
let img = image::open( image_filename );
|
||||||
|
if let Ok( img ) = img {
|
||||||
|
// Image must be multiple of 8 in both dimensions
|
||||||
|
let x = img.dimensions().0;
|
||||||
|
let y = img.dimensions().1;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
pub fn print_error( error_msg: &'static str ) {
|
||||||
|
red!( "fatal: " ); println!( "{}", error_msg );
|
||||||
|
}
|
Loading…
Reference in New Issue