From 44cd83de92ac909cff44f512fed1a88b5050a249 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Sun, 22 Nov 2015 17:52:25 -0500 Subject: [PATCH] contrib/inkscape_tools: add option to generate icons with different names MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- contrib/inkscape_tools/src/svg_to_icons.nit | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/contrib/inkscape_tools/src/svg_to_icons.nit b/contrib/inkscape_tools/src/svg_to_icons.nit index 301772b..917c197 100644 --- a/contrib/inkscape_tools/src/svg_to_icons.nit +++ b/contrib/inkscape_tools/src/svg_to_icons.nit @@ -20,8 +20,7 @@ module svg_to_icons import opts redef class Int - fun android_path: String do return "drawable-{resolution_name}/icon.png" - + # Android name for this resolution fun resolution_name: String do if self == 36 then return "ldpi" @@ -37,11 +36,12 @@ end var opt_out = new OptionString("Where to output PNG files", "--out", "-o") var opt_id = new OptionString("Extract only object with given ID", "--id", "-i") var opt_android = new OptionBool("Generate in the file structure for Android", "--android", "-a") +var opt_android_name = new OptionString("Name of the resource for Android", "--name", "-n") var opt_large = new OptionBool("Generate large icons (512 and 1024 px)", "--large", "-l") var opt_help = new OptionBool("Print this help message", "--help", "-h") var opt_context = new OptionContext -opt_context.add_option(opt_out, opt_id, opt_android, opt_large, opt_help) +opt_context.add_option(opt_out, opt_id, opt_android, opt_android_name, opt_large, opt_help) opt_context.parse(args) var rest = opt_context.rest @@ -83,10 +83,12 @@ else if opt_large.value then resolutions = [512, 1024] else abort +var android_res_name = opt_android_name.value or else "icon" + for wh in resolutions do var png_path if opt_android.value then - png_path = "{out_path}/{wh.android_path}" + png_path = out_path / "drawable-" + wh.resolution_name / android_res_name + ".png" var dir = png_path.dirname if not dir.file_exists then dir.mkdir else -- 1.7.9.5