Search in sources :

Example 66 with Array

use of com.badlogic.gdx.utils.Array in project gdx-skineditor by cobolfoo.

the class MainScreen method saveToSkin.

/**
	 * Save everything to skin
	 */
public void saveToSkin() {
    FileHandle projectFolder = Gdx.files.local("projects").child(currentProject);
    FileHandle[] items = projectFolder.child("backups").list();
    Array<String> sortedItems = new Array<String>();
    for (FileHandle item : items) {
        sortedItems.add(item.name());
    }
    sortedItems.sort();
    // Keep only last ten files
    int count = 0;
    for (String item : sortedItems) {
        if (count++ > 8) {
            // Remove file 
            projectFolder.child("backups").child(item).delete();
        }
    }
    FileHandle projectFile = projectFolder.child("uiskin.json");
    FileHandle backupFile = projectFolder.child("backups").child("uiskin_" + (TimeUtils.millis() / 1000) + ".json");
    projectFile.copyTo(backupFile);
    game.skinProject.save(projectFile);
}
Also used : Array(com.badlogic.gdx.utils.Array) FileHandle(com.badlogic.gdx.files.FileHandle)

Example 67 with Array

use of com.badlogic.gdx.utils.Array in project gdx-skineditor by cobolfoo.

the class WelcomeScreen method refreshProjects.

/**
	 * 
	 */
public void refreshProjects() {
    Array<String> items = new Array<String>();
    FileHandle[] projects = Gdx.files.local("projects").list();
    for (FileHandle project : projects) {
        if (project.child("uiskin.json").exists() == true) {
            items.add(project.name());
        }
    }
    items.sort();
    listProjects.setItems(items);
}
Also used : Array(com.badlogic.gdx.utils.Array) FileHandle(com.badlogic.gdx.files.FileHandle)

Aggregations

Array (com.badlogic.gdx.utils.Array)67 FileHandle (com.badlogic.gdx.files.FileHandle)18 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)16 AssetDescriptor (com.badlogic.gdx.assets.AssetDescriptor)9 Texture (com.badlogic.gdx.graphics.Texture)8 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)7 IntArray (com.badlogic.gdx.utils.IntArray)7 Element (com.badlogic.gdx.utils.XmlReader.Element)7 IOException (java.io.IOException)7 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)5 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)5 JsonValue (com.badlogic.gdx.utils.JsonValue)5 ObjectMap (com.badlogic.gdx.utils.ObjectMap)5 Color (com.badlogic.gdx.graphics.Color)4 ModelMaterial (com.badlogic.gdx.graphics.g3d.model.data.ModelMaterial)4 Page (com.badlogic.gdx.tools.texturepacker.TexturePacker.Page)4 Rect (com.badlogic.gdx.tools.texturepacker.TexturePacker.Rect)4 Json (com.badlogic.gdx.utils.Json)4 TextureParameter (com.badlogic.gdx.assets.loaders.TextureLoader.TextureParameter)3 GwtFileHandle (com.badlogic.gdx.backends.gwt.GwtFileHandle)3