Home | History | Annotate | Download | only in tiledmappacker
      1 /*******************************************************************************
      2  * Copyright 2015 See AUTHORS file.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *   http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  ******************************************************************************/
     16 
     17 package com.badlogic.gdx.tiledmappacker;
     18 
     19 import java.io.File;
     20 
     21 /** Processes the maps located in gdx-tests-android: "assets/data/maps/tiled-atlas-src" Creates the directory
     22  * "assets/data/maps/tiled-atlas-processed/deleteMe" which contains processed maps. Run TiledMapPackerTestRender to render the
     23  * maps and, optionally, delete the created folder on exit. */
     24 public class TiledMapPackerTest {
     25 
     26 	// TestTypes "NoArgs" and "BadOption" do not create/process maps.
     27 	public enum TestType {
     28 		NoArgs, DefaultUsage, Verbose, StripUnused, CombineTilesets, UnusedAndCombine, BadOption
     29 	}
     30 
     31 	public static void main (String[] args) throws Exception {
     32 		String path = "../../tests/gdx-tests-android/assets/data/maps/";
     33 		String input = path + "tiled-atlas-src";
     34 		String output = path + "tiled-atlas-processed/deleteMe";
     35 		String verboseOpt = "-v";
     36 		String unused = "--strip-unused";
     37 		String combine = "--combine-tilesets";
     38 		String badOpt = "bad";
     39 
     40 		File outputDir = new File(output);
     41 		if (outputDir.exists()) {
     42 			System.out.println("Please run TiledMapPackerTestRender or delete \"deleteMe\" folder located in");
     43 			System.out.println("gdx-tests-android: assets/data/maps/tiled-atlas-processed/deleteMe");
     44 			return;
     45 		}
     46 
     47 		TestType testType = TestType.DefaultUsage;
     48 
     49 		String[] noArgs = {};
     50 		String[] defaultUsage = {input, output};
     51 		String[] verbose = {input, output, verboseOpt};
     52 		String[] stripUnused = {input, output, unused};
     53 		String[] combineTilesets = {input, output, combine};
     54 		String[] unusedAndCombine = {input, output, unused, combine};
     55 		String[] badOption = {input, output, unused, verboseOpt, combine, badOpt};
     56 
     57 		switch (testType) {
     58 		case NoArgs:
     59 			TiledMapPacker.main(noArgs);
     60 			break;
     61 		case DefaultUsage:
     62 			TiledMapPacker.main(defaultUsage);
     63 			break;
     64 		case Verbose:
     65 			TiledMapPacker.main(verbose);
     66 			break;
     67 		case StripUnused:
     68 			TiledMapPacker.main(stripUnused);
     69 			break;
     70 		case CombineTilesets:
     71 			TiledMapPacker.main(combineTilesets);
     72 			break;
     73 		case UnusedAndCombine:
     74 			TiledMapPacker.main(unusedAndCombine);
     75 			break;
     76 		case BadOption:
     77 			TiledMapPacker.main(badOption);
     78 			break;
     79 		default:
     80 			break;
     81 		}
     82 	}
     83 }
     84