com.badlogic.gdx.tools.texturepacker.TexturePacker Java Examples

The following examples show how to use com.badlogic.gdx.tools.texturepacker.TexturePacker. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DesktopLauncher.java    From skin-composer with MIT License 6 votes vote down vote up
@Override
public void packFontImages(Array<FileHandle> files, FileHandle saveFile) {
    var settings = new TexturePacker.Settings();
    settings.pot = false;
    settings.duplicatePadding = true;
    settings.filterMin = Texture.TextureFilter.Linear;
    settings.filterMag = Texture.TextureFilter.Linear;
    settings.ignoreBlankImages = false;
    settings.useIndexes = false;
    settings.limitMemory = false;
    settings.maxWidth = 2048;
    settings.maxHeight = 2048;
    settings.flattenPaths = true;
    settings.silent = true;
    var texturePacker = new TexturePacker(settings);

    for (FileHandle file : files) {
        if (file.exists()) {
            texturePacker.addImage(file.file());
        }
    }

    texturePacker.pack(saveFile.parent().file(), saveFile.nameWithoutExtension());
}
 
Example #2
Source File: DesktopLauncher.java    From FruitCatcher with Apache License 2.0 6 votes vote down vote up
public static void main (String[] arg) {
       // Create two run configurations
       // 1. For texture packing. Pass 'texturepacker' as argument and use desktop/src
       //    as working directory
       // 2. For playing game with android/assets as working directory
       if (arg.length == 1 && arg[0].equals("texturepacker")) {
           String outdir = "assets";
           TexturePacker.Settings settings = new TexturePacker.Settings();
           settings.maxWidth = 1024;
           settings.maxHeight = 1024;
           TexturePacker.process(settings, "images", outdir, "game");
           TexturePacker.process(settings, "text-images", outdir, "text_images");
           TexturePacker.process(settings, "text-images-de", outdir, "text_images_de");
       }
       else {
           LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
           config.title = "FruitCatcher";
           config.width = 800;
           config.height = 480;
           new LwjglApplication(new FruitCatcherGame(null, "en"), config);
       }
}
 
Example #3
Source File: ScaleFactorJsonSerializer.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@Override
public ScaleFactorModel read(Json json, JsonValue jsonData, Class type) {
    String suffix = "";
    float factor = 1f;
    TexturePacker.Resampling resampling = TexturePacker.Resampling.bicubic;

    JsonValue.JsonIterator iterator = jsonData.iterator();
    while (iterator.hasNext()) {
        JsonValue value = iterator.next();
        switch (value.name) {
            case "suffix":
                suffix = value.asString();
                break;
            case "factor":
                factor = value.asFloat();
                break;
            case "resampling":
                resampling = TexturePacker.Resampling.valueOf(value.asString());
                break;
        }
    }
    return new ScaleFactorModel(suffix, factor, resampling);
}
 
Example #4
Source File: GlobalActions.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@LmlAction("copySettingsToAllPacks") public void copySettingsToAllPacks() {
    PackModel selectedPack = getSelectedPack();
    if (selectedPack == null) return;

    TexturePacker.Settings generalSettings = selectedPack.getSettings();
    Array<PackModel> packs = getProject().getPacks();
    for (PackModel pack : packs) {
        if (pack == selectedPack) continue;

        pack.setSettings(generalSettings);
    }

    eventDispatcher.postEvent(new ShowToastEvent()
            .message(getString("toastCopyAllSettings"))
            .duration(ShowToastEvent.DURATION_SHORT));
}
 
Example #5
Source File: WelcomeScreen.java    From gdx-skineditor with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param projectName
 */
public void createProject(String projectName) {

	FileHandle projectFolder = Gdx.files.local("projects").child(projectName);
	if (projectFolder.exists() == true) {
		game.showNotice("Error", "Project name already in use!", stage);
		return;
	}

	projectFolder.mkdirs();
	projectFolder.child("assets").mkdirs();
	projectFolder.child("backups").mkdirs();
	game.skin.save(projectFolder.child("uiskin.json"));

	// Copy assets
	FileHandle assetsFolder = Gdx.files.local("resources/raw");
	assetsFolder.copyTo(projectFolder.child("assets"));
	// Rebuild from raw resources
	TexturePacker.Settings settings = new TexturePacker.Settings();
	settings.combineSubdirectories = true;
	TexturePacker.process(settings, "projects/" + projectName +"/assets/", "projects/" + projectName, "uiskin");

	game.showNotice("Operation completed", "New project successfully created.", stage);
	
	refreshProjects();
}
 
Example #6
Source File: MainScreen.java    From gdx-skineditor with Apache License 2.0 6 votes vote down vote up
/**
 * 
 */
public void refreshResources() {
	
	TexturePacker.Settings settings = new TexturePacker.Settings();
	settings.combineSubdirectories = true;
	settings.maxWidth = 2048;
	settings.maxHeight = 2048;
	TexturePacker.process(settings, "projects/" + currentProject +"/assets/", "projects/" + currentProject, "uiskin");
	

	// Load project skin
	if (game.skinProject != null) {
		game.skinProject.dispose();
	}
	
	game.skinProject = new Skin();
	game.skinProject.addRegions(new TextureAtlas(Gdx.files.local("projects/" + currentProject +"/uiskin.atlas")));
	game.skinProject.load(Gdx.files.local("projects/" + currentProject +"/uiskin.json"));

	
}
 
Example #7
Source File: PackDialogController.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
private Array<PackProcessingNode> prepareProcessingNodes(ProjectModel project, Array<PackModel> packs) {
    Array<PackProcessingNode> result = new Array<>();
    for (PackModel pack : packs) {
        for (ScaleFactorModel scaleFactor : pack.getScaleFactors()) {
            PackModel newPack = new PackModel(pack);
            newPack.setScaleFactors(Array.with(scaleFactor));
            TexturePacker.Settings settings = newPack.getSettings();
            settings.scaleSuffix[0] = "";
            settings.scale[0] = scaleFactor.getFactor();
            settings.scaleResampling[0] = scaleFactor.getResampling();

            PackProcessingNode processingNode = new PackProcessingNode(project, newPack);
            processingNode.setOrigPack(pack);

            result.add(processingNode);
        }
    }
    return result;
}
 
Example #8
Source File: PackingProcessor.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
private void performPacking(PackModel packModel, PageFileWriter pageFileWriter) throws Exception {
    Array<ImageEntry> imageEntries = collectImageFiles(packModel);
    if (imageEntries.size == 0) {
        throw new IllegalStateException("No images to pack");
    }

    deleteOldFiles(packModel);
    String filename = obtainFilename(packModel);

    TexturePacker packer = new TexturePacker(packModel.getSettings(), pageFileWriter);
    for (ImageEntry image : imageEntries) {
        if (image.ninePatch) {
            packer.addImage(image.fileHandle.file(), image.name, image.splits, image.pads);
        } else {
            packer.addImage(image.fileHandle.file(), image.name);
        }
    }
    packer.pack(new File(packModel.getOutputDir()), filename);
}
 
Example #9
Source File: MainController.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@LmlAction("onSettingsCboChanged") void onSettingsCboChanged(VisSelectBox selectBox) {
        if (!viewShown) return;

        PackModel pack = getSelectedPack();
        if (pack == null) return;

        TexturePacker.Settings settings = pack.getSettings();
        Object value = selectBox.getSelected();
        switch (selectBox.getName()) {
            case "cboEncodingFormat": settings.format = (Pixmap.Format) value; break;
            case "cboMinFilter": settings.filterMin = (Texture.TextureFilter) value; break;
            case "cboMagFilter": settings.filterMag = (Texture.TextureFilter) value; break;
            case "cboWrapX": settings.wrapX = (Texture.TextureWrap) value; break;
            case "cboWrapY": settings.wrapY = (Texture.TextureWrap) value; break;
//            case "cboOutputFormat": settings.outputFormat = (String) value; break;
        }
    }
 
Example #10
Source File: MainController.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@LmlAction("onSettingsIntSeekBarChanged") void onSettingsIntSeekBarChanged(SeekBar seekBar) {
    PackModel pack = getSelectedPack();
    if (pack == null) return;

    TexturePacker.Settings settings = pack.getSettings();
    IntSeekBarModel model = (IntSeekBarModel) seekBar.getModel();
    switch (seekBar.getName()) {
        case "skbMinPageWidth": settings.minWidth = model.getValue(); break;
        case "skbMinPageHeight": settings.minHeight = model.getValue(); break;
        case "skbMaxPageWidth": settings.maxWidth = model.getValue(); break;
        case "skbMaxPageHeight": settings.maxHeight = model.getValue(); break;
        case "skbAlphaThreshold": settings.alphaThreshold = model.getValue(); break;
        case "skbPaddingX": settings.paddingX = model.getValue(); break;
        case "skbPaddingY": settings.paddingY = model.getValue(); break;
    }
}
 
Example #11
Source File: MainController.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@LmlAction("onSettingsCbChecked") void onSettingsCbChecked(VisCheckBox checkBox) {
    PackModel pack = getSelectedPack();
    if (pack == null) return;

    TexturePacker.Settings settings = pack.getSettings();
    switch (checkBox.getName()) {
        case "cbUseFastAlgorithm": settings.fast = checkBox.isChecked(); break;
        case "cbEdgePadding": settings.edgePadding = checkBox.isChecked(); break;
        case "cbStripWhitespaceX": settings.stripWhitespaceX = checkBox.isChecked(); break;
        case "cbStripWhitespaceY": settings.stripWhitespaceY = checkBox.isChecked(); break;
        case "cbAllowRotation": settings.rotation = checkBox.isChecked(); break;
        case "cbBleeding": settings.bleed = checkBox.isChecked(); break;
        case "cbDuplicatePadding": settings.duplicatePadding = checkBox.isChecked(); break;
        case "cbForcePot": settings.pot = checkBox.isChecked(); break;
        case "cbForceMof": settings.multipleOfFour = checkBox.isChecked(); break;
        case "cbUseAliases": settings.alias = checkBox.isChecked(); break;
        case "cbIgnoreBlankImages": settings.ignoreBlankImages = checkBox.isChecked(); break;
        case "cbDebug": settings.debug = checkBox.isChecked(); break;
        case "cbUseIndices": settings.useIndexes = checkBox.isChecked(); break;
        case "cbPremultiplyAlpha": settings.premultiplyAlpha = checkBox.isChecked(); break;
        case "cbGrid": settings.grid = checkBox.isChecked(); break;
        case "cbSquare": settings.square = checkBox.isChecked(); break;
        case "cbLimitMemory": settings.limitMemory = checkBox.isChecked(); break;
    }
}
 
Example #12
Source File: DesktopLauncher.java    From skin-composer with MIT License 6 votes vote down vote up
@Override
public void texturePack(Array<FileHandle> handles, FileHandle localFile, FileHandle targetFile, FileHandle settingsFile) {
    var json = new Json();
    var settings = json.fromJson(TexturePacker.Settings.class, settingsFile);
    
    var p = new TexturePacker(settings);
    for (var handle : handles) {
        if (handle.exists()) {
            p.addImage(handle.file());
        } else {
            if (localFile != null) {
                var localHandle = localFile.sibling(localFile.nameWithoutExtension() + "_data/" + handle.name());
                if (localHandle.exists()) {
                    p.addImage(localHandle.file());
                } else {
                    Gdx.app.error(getClass().getName(), "File does not exist error while creating texture atlas: " + handle.path());
                }
            } else {
                Gdx.app.error(getClass().getName(), "File does not exist error while creating texture atlas: " + handle.path());
            }
        }
    }
    p.pack(targetFile.parent().file(), targetFile.nameWithoutExtension());
}
 
Example #13
Source File: SkinEditorGame.java    From gdx-skineditor with Apache License 2.0 5 votes vote down vote up
@Override
public void create() {
	
	opt = new OptionalChecker();
	
	fm = new SystemFonts();
	fm.refreshFonts();
	
	// Create projects folder if not already here
	FileHandle dirProjects = new FileHandle("projects");
	
	if (dirProjects.isDirectory() == false) {
		dirProjects.mkdirs();
	}
	
	// Rebuild from raw resources, kind of overkill, might disable it for production
	TexturePacker.Settings settings = new TexturePacker.Settings();
	settings.combineSubdirectories = true;
	TexturePacker.process(settings, "resources/raw/", ".", "resources/uiskin");

	batch = new SpriteBatch();
	skin = new Skin();
	atlas = new TextureAtlas(Gdx.files.internal("resources/uiskin.atlas"));
	
	
	skin.addRegions(new TextureAtlas(Gdx.files.local("resources/uiskin.atlas")));
	skin.load(Gdx.files.local("resources/uiskin.json"));
	
	screenMain = new MainScreen(this);
	screenWelcome = new WelcomeScreen(this);
	setScreen(screenWelcome);
	
}
 
Example #14
Source File: KtxFileTypeProcessor.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@Override
public void saveToFile(TexturePacker.Settings settings, BufferedImage image, File file) throws IOException {
    FileHandle tmpPngFile = new FileHandle(File.createTempFile(file.getName(), null));
    FileHandle output = new FileHandle(file);

    super.saveToFile(settings, image, tmpPngFile.file());

    KtxEtc1Processor.process(tmpPngFile, output, alphaChannel);
    tmpPngFile.delete();

    if (zipping) {
        FileUtils.packGzip(output);
    }
}
 
Example #15
Source File: KtxFileTypeProcessor.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@Override
public void saveToFile(TexturePacker.Settings settings, BufferedImage image, File file) throws IOException {
    FileHandle tmpPngFile = new FileHandle(File.createTempFile(file.getName(), null));
    FileHandle output = new FileHandle(file);

    super.saveToFile(settings, image, tmpPngFile.file());

    KtxEtc2Processor.process(tmpPngFile, output, pixelFormat);
    tmpPngFile.delete();

    if (zipping) {
        FileUtils.packGzip(output);
    }
}
 
Example #16
Source File: PackingProcessor.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
private static void deleteOldFiles(PackModel packModel) throws Exception {
    String filename = obtainFilename(packModel);

    TexturePacker.Settings settings = packModel.getSettings();
    String atlasExtension = settings.atlasExtension == null ? "" : settings.atlasExtension;
    atlasExtension = Pattern.quote(atlasExtension);

    for (int i = 0, n = settings.scale.length; i < n; i++) {
        FileProcessor deleteProcessor = new FileProcessor() {
            protected void processFile (Entry inputFile) throws Exception {
                Files.delete(inputFile.inputFile.toPath());
            }
        };
        deleteProcessor.setRecursive(false);

        String scaledPackFileName = settings.getScaledPackFileName(filename, i);
        File packFile = new File(scaledPackFileName);

        String prefix = filename;
        int dotIndex = prefix.lastIndexOf('.');
        if (dotIndex != -1) prefix = prefix.substring(0, dotIndex);
        deleteProcessor.addInputRegex("(?i)" + prefix + "\\d*\\.(png|jpg|jpeg|ktx|zktx)");
        deleteProcessor.addInputRegex("(?i)" + prefix + atlasExtension);

        File outputRoot = new File(packModel.getOutputDir());
        String dir = packFile.getParent();
        if (dir == null)
            deleteProcessor.process(outputRoot, null);
        else if (new File(outputRoot + "/" + dir).exists()) //
            deleteProcessor.process(outputRoot + "/" + dir, null);
    }
}
 
Example #17
Source File: TexturePackerApp.java    From ninja-rabbit with GNU General Public License v2.0 5 votes vote down vote up
public static void main(final String[] args) {
	Settings settings = new Settings();
	settings.edgePadding = true;
	settings.paddingX = 2;
	settings.paddingY = 2;
	settings.pot = false;
	settings.maxHeight = 2048;
	settings.maxWidth = 2048;
	TexturePacker.process(settings, "C:\\Users\\Nicolás\\Desktop\\tiles",
			"C:\\Users\\Nicolás\\Desktop\\tiles.pack",
			"tiles.pack");
}
 
Example #18
Source File: PngFileTypeController.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(Stage stage) {
    ignoreViewChangeEvents = true;
    cboEncoding.setItems(TexturePacker.availableEncodings);
    cboCompression.setItems(WidgetData.PngCompression.values());
    ignoreViewChangeEvents = false;
}
 
Example #19
Source File: Generator.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) {
        TexturePacker.Settings settings = new TexturePacker.Settings();
        settings.combineSubdirectories = true;
        TexturePacker.process(settings, "generator/gfx", "android/assets", "gfx");
        TexturePacker.process(settings, "generator/world-map", "android/assets", "world-map");
//        renamePrefixes("generator/gfx/ui/level-icon", "ui-level-icon-", "");
    }
 
Example #20
Source File: ImageUtils.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
public static void createAtlas(String inDir, String outdir, String name, float scale, int maxWidth, int maxHeight,
		TextureFilter filterMin, TextureFilter filterMag, String outputFormat, boolean stripWhiteSpace)
		throws IOException {
	Settings settings = new Settings();

	settings.pot = false;
	settings.paddingX = 2;
	settings.paddingY = 2;
	settings.duplicatePadding = false;
	settings.edgePadding = true;
	settings.rotation = false;
	settings.minWidth = 16;
	settings.minWidth = 16;
	settings.stripWhitespaceX = stripWhiteSpace;
	settings.stripWhitespaceY = stripWhiteSpace;
	settings.alphaThreshold = 0;

	settings.filterMin = filterMin;
	settings.filterMag = filterMag;
	settings.wrapX = Texture.TextureWrap.ClampToEdge;
	settings.wrapY = Texture.TextureWrap.ClampToEdge;
	settings.format = Format.RGBA8888;
	settings.alias = true;
	settings.outputFormat = outputFormat;
	settings.jpegQuality = 0.9f;
	settings.ignoreBlankImages = true;
	settings.fast = false;
	settings.debug = false;

	settings.maxWidth = maxWidth;
	settings.maxHeight = maxHeight;

	EditorLogger.debug("ATLAS MAXWIDTH: " + settings.maxWidth);

	File inTmpDir = new File(inDir);

	// Resize images to create atlas for different resolutions
	if (scale != 1.0f) {
		inTmpDir = DesktopUtils.createTempDirectory();

		ImageUtils.scaleDirFiles(new File(inDir), inTmpDir, scale);
	}

	TexturePacker.process(settings, inTmpDir.getAbsolutePath(), outdir,
			name.endsWith(".atlas") ? name : name + ".atlas");

	if (scale != 1.0f) {
		DesktopUtils.removeDir(inTmpDir.getAbsolutePath());
	}
}
 
Example #21
Source File: TextureRegionTestTextures.java    From mini2Dx with Apache License 2.0 4 votes vote down vote up
public static void main(String [] args) {
	TexturePacker.process("../uats/texture-pack", "../uats/src/main/resources", TextureRegionUAT.TEXTURE_PACK);
}
 
Example #22
Source File: TextureSetup.java    From SIFTrain with MIT License 4 votes vote down vote up
public static void main(String[] args) {
    TexturePacker.Settings config = new TexturePacker.Settings();
    config.maxWidth = 512;
    config.maxHeight = 512;
    TexturePacker.process(config, "images/", "textures/", "textures.pack");
}
 
Example #23
Source File: ProjectSerializer.java    From gdx-texture-packer-gui with Apache License 2.0 4 votes vote down vote up
private String serializePack(PackModel pack, FileHandle root) {
        StringBuilder sb = new StringBuilder();

        String filename = pack.getFilename();

        sb.append("name=").append(pack.getName()).append("\n");
        sb.append("filename=").append(filename).append("\n");
        sb.append("output=").append(PathUtils.relativize(pack.getOutputDir(), root.file().getPath())).append("\n");

        sb.append("\n");

        TexturePacker.Settings settings = pack.getSettings();
        sb.append("alias=").append(settings.alias).append("\n");
        sb.append("alphaThreshold=").append(settings.alphaThreshold).append("\n");
        sb.append("debug=").append(settings.debug).append("\n");
        sb.append("duplicatePadding=").append(settings.duplicatePadding).append("\n");
        sb.append("edgePadding=").append(settings.edgePadding).append("\n");
        sb.append("fast=").append(settings.fast).append("\n");
        sb.append("filterMag=").append(settings.filterMag).append("\n");
        sb.append("filterMin=").append(settings.filterMin).append("\n");
//        sb.append("format=").append(settings.format).append("\n");
        sb.append("ignoreBlankImages=").append(settings.ignoreBlankImages).append("\n");
//        sb.append("jpegQuality=").append(settings.jpegQuality).append("\n");
        sb.append("maxHeight=").append(settings.maxHeight).append("\n");
        sb.append("maxWidth=").append(settings.maxWidth).append("\n");
        sb.append("minHeight=").append(settings.minHeight).append("\n");
        sb.append("minWidth=").append(settings.minWidth).append("\n");
//        sb.append("outputFormat=").append(settings.outputFormat).append("\n");
        sb.append("paddingX=").append(settings.paddingX).append("\n");
        sb.append("paddingY=").append(settings.paddingY).append("\n");
        sb.append("pot=").append(settings.pot).append("\n");
        sb.append("mof=").append(settings.multipleOfFour).append("\n");
        sb.append("rotation=").append(settings.rotation).append("\n");
        sb.append("stripWhitespaceX=").append(settings.stripWhitespaceX).append("\n");
        sb.append("stripWhitespaceY=").append(settings.stripWhitespaceY).append("\n");
        sb.append("wrapX=").append(settings.wrapX).append("\n");
        sb.append("wrapY=").append(settings.wrapY).append("\n");
        sb.append("premultiplyAlpha=").append(settings.premultiplyAlpha).append("\n");
        sb.append("grid=").append(settings.grid).append("\n");
        sb.append("square=").append(settings.square).append("\n");
        sb.append("bleed=").append(settings.bleed).append("\n");
        sb.append("limitMemory=").append(settings.limitMemory).append("\n");
        sb.append("useIndexes=").append(settings.useIndexes).append("\n");

        sb.append("\n");

        sb.append("scaleFactors=").append(json.toJson(pack.getScaleFactors())).append("\n");

        inputFileSerializer.setRoot(root.file());
        sb.append("inputFiles=").append(json.toJson(pack.getInputFiles())).append("\n");

        return sb.toString();
    }
 
Example #24
Source File: ScaleFactorModel.java    From gdx-texture-packer-gui with Apache License 2.0 4 votes vote down vote up
public TexturePacker.Resampling getResampling() {
    return resampling;
}
 
Example #25
Source File: ScaleFactorModel.java    From gdx-texture-packer-gui with Apache License 2.0 4 votes vote down vote up
public ScaleFactorModel(String suffix, float factor, TexturePacker.Resampling resampling) {
    this.suffix = suffix;
    this.factor = factor;
    this.resampling = resampling;
}
 
Example #26
Source File: PackModel.java    From gdx-texture-packer-gui with Apache License 2.0 4 votes vote down vote up
public PackModel() {
    scaleFactors.add(new ScaleFactorModel("", 1f, TexturePacker.Resampling.bicubic));
}
 
Example #27
Source File: MainController.java    From gdx-texture-packer-gui with Apache License 2.0 4 votes vote down vote up
private void updateViewsFromPack(PackModel pack) {
    if (actorsPacks.packListAdapter.getSelected() != pack) {
        actorsPacks.packListAdapter.getSelectionManager().deselectAll();
        if (pack != null) {
            actorsPacks.packListAdapter.getSelectionManager().select(pack);
        }
    }

    // Update pack list item
    PackListAdapter.ViewHolder viewHolder = actorsPacks.packListAdapter.getViewHolder(pack);
    if (viewHolder != null) {
        viewHolder.updateViewData();
    }

    if (pack != null) {
        actorsPacks.edtOutputDir.setText(pack.getOutputDir());
        actorsPacks.edtFileName.setText(pack.getFilename());
        actorsPacks.edtFileName.setMessageText(pack.getName() + ".atlas");
    } else {
        actorsPacks.edtOutputDir.setText(null);
        actorsPacks.edtFileName.setText(null);
    }

    if (pack != null) {
        TexturePacker.Settings settings = pack.getSettings();

        actorsPackSettings.cbUseFastAlgorithm.setChecked(settings.fast);
        actorsPackSettings.cbEdgePadding.setChecked(settings.edgePadding);
        actorsPackSettings.cbStripWhitespaceX.setChecked(settings.stripWhitespaceX);
        actorsPackSettings.cbStripWhitespaceY.setChecked(settings.stripWhitespaceY);
        actorsPackSettings.cbAllowRotation.setChecked(settings.rotation);
        actorsPackSettings.cbBleeding.setChecked(settings.bleed);
        actorsPackSettings.cbDuplicatePadding.setChecked(settings.duplicatePadding);
        actorsPackSettings.cbForcePot.setChecked(settings.pot);
        actorsPackSettings.cbForceMof.setChecked(settings.multipleOfFour);
        actorsPackSettings.cbUseAliases.setChecked(settings.alias);
        actorsPackSettings.cbIgnoreBlankImages.setChecked(settings.ignoreBlankImages);
        actorsPackSettings.cbDebug.setChecked(settings.debug);
        actorsPackSettings.cbUseIndices.setChecked(settings.useIndexes);
        actorsPackSettings.cbPremultiplyAlpha.setChecked(settings.premultiplyAlpha);
        actorsPackSettings.cbGrid.setChecked(settings.grid);
        actorsPackSettings.cbSquare.setChecked(settings.square);
        actorsPackSettings.cbLimitMemory.setChecked(settings.limitMemory);

        ((IntSeekBarModel) actorsPackSettings.skbMinPageWidth.getModel()).setValue(settings.minWidth, false);
        ((IntSeekBarModel) actorsPackSettings.skbMinPageHeight.getModel()).setValue(settings.minHeight, false);
        ((IntSeekBarModel) actorsPackSettings.skbMaxPageWidth.getModel()).setValue(settings.maxWidth, false);
        ((IntSeekBarModel) actorsPackSettings.skbMaxPageHeight.getModel()).setValue(settings.maxHeight, false);
        ((IntSeekBarModel) actorsPackSettings.skbAlphaThreshold.getModel()).setValue(settings.alphaThreshold, false);
        ((IntSeekBarModel) actorsPackSettings.skbPaddingX.getModel()).setValue(settings.paddingX, false);
        ((IntSeekBarModel) actorsPackSettings.skbPaddingY.getModel()).setValue(settings.paddingY, false);

        actorsPackSettings.cboMinFilter.setSelected(settings.filterMin);
        actorsPackSettings.cboMagFilter.setSelected(settings.filterMag);
        actorsPackSettings.cboWrapX.setSelected(settings.wrapX);
        actorsPackSettings.cboWrapY.setSelected(settings.wrapY);

        // Scale factors
        {
            StringBuilder sb = new StringBuilder();
            Array<ScaleFactorModel> scaleFactors = pack.getScaleFactors();
            for (int i = 0; i < scaleFactors.size; i++) {
                ScaleFactorModel scaleFactor = scaleFactors.get(i);
                sb.append(String.format(Locale.US, "%.2f", scaleFactor.getFactor()));
                if (i < scaleFactors.size-1) { sb.append(", "); }
            }
            actorsPackSettings.eetbScaleFactors.setText(sb.toString());
        }
    }

    // Update pane lockers
    for (Actor locker : packPaneLockers) {
        locker.setVisible(pack == null);
    }
}
 
Example #28
Source File: JpegFileTypeController.java    From gdx-texture-packer-gui with Apache License 2.0 4 votes vote down vote up
@Override
public void onViewCreated(Stage stage) {
    ignoreViewChangeEvents = true;
    cboEncoding.setItems(TexturePacker.availableEncodings);
    ignoreViewChangeEvents = false;
}
 
Example #29
Source File: NinePatchEditorDialog.java    From gdx-skineditor with Apache License 2.0 2 votes vote down vote up
public void refreshPreview() {

		Gdx.app.log("NinePatchEditorDialog","refresh preview.");

		Pixmap pixmapImage = new Pixmap(Gdx.files.internal(textSourceImage.getText()));
		
		Pixmap pixmap = new Pixmap((int) (pixmapImage.getWidth()+2), (int) (pixmapImage.getHeight()+2), Pixmap.Format.RGBA8888);
		pixmap.drawPixmap(pixmapImage,1,1);

		pixmap.setColor(Color.BLACK);
		
		// Range left
		int h = pixmapImage.getHeight()+1;
		pixmap.drawLine(0, (int) (h * rangeLeft.rangeStart),0, (int) (h * rangeLeft.rangeStop));
		

		// Range top
		int w = pixmapImage.getWidth()+1;
		pixmap.drawLine((int) (w * rangeTop.rangeStart), 0,(int) (w * rangeTop.rangeStop), 0);

		// Range right
		h = pixmapImage.getHeight()+1;
		pixmap.drawLine(pixmapImage.getWidth()+1, (int) (h * rangeRight.rangeStart),pixmapImage.getWidth()+1, (int) (h * rangeRight.rangeStop));

		// Range bottom
		w = pixmapImage.getWidth()+1;
		pixmap.drawLine((int) (w * rangeBottom.rangeStart), pixmap.getHeight()-1,(int) (w * rangeBottom.rangeStop), pixmap.getHeight()-1);
		
		
		PixmapIO.writePNG(tmpFile, pixmap);
		
		pixmapImage.dispose();
		pixmap.dispose();

		FileHandle fh = new FileHandle(System.getProperty("java.io.tmpdir")).child("skin_ninepatch");
		TexturePacker.Settings settings = new TexturePacker.Settings();
		TexturePacker.process(settings, fh.path(), fh.path(), "pack");

		TextureAtlas ta = new TextureAtlas(fh.child("pack.atlas"));
		NinePatch np = ta.createPatch("button");
		NinePatchDrawable drawable = new NinePatchDrawable(np);
		reviewTablePreview();	
		buttonPreview1.getStyle().up = drawable;
		

	}