Example usage for com.badlogic.gdx.backends.lwjgl LwjglFiles LwjglFiles

List of usage examples for com.badlogic.gdx.backends.lwjgl LwjglFiles LwjglFiles

Introduction

In this page you can find the example usage for com.badlogic.gdx.backends.lwjgl LwjglFiles LwjglFiles.

Prototype

LwjglFiles

Source Link

Usage

From source file:Generator.java

License:Open Source License

private static void renamePrefixes(String path, String prefix, String newPrefix) {
    Files files = new LwjglFiles();
    for (FileHandle fileHandle : files.local(path).list()) {
        if (fileHandle.name().startsWith(prefix)) {
            String newName = newPrefix + fileHandle.name().substring(prefix.length());
            println(fileHandle.name() + " -> " + newName);
            fileHandle.sibling(newName).write(fileHandle.read(), false);
            fileHandle.delete();/*from www . ja va2s.  c  o  m*/
        }
    }
}

From source file:es.eucm.ead.buildtools.GenerateBindings.java

License:Open Source License

public static void generateBindingsFile(String schemaFolder, String schemaPackage,
        String schemaBindingsLocation) {
    Files files = new LwjglFiles();
    String bindings = "[\n  ";
    bindings += addBindings(files.internal(schemaFolder + schemaPackage), schemaFolder);
    int lastComma = bindings.lastIndexOf(',');
    if (lastComma > 0) {
        bindings = bindings.substring(0, lastComma);
    }// ww  w .  j  ava 2 s . co  m
    bindings += "\n]";
    new FileHandle(files.internal(schemaBindingsLocation).file()).writeString(bindings, false);
}

From source file:es.eucm.ead.buildtools.GenerateFieldClasses.java

License:Open Source License

public static void main(String[] args) {
    System.out.println("Generating Field classes ...");
    System.out.println();//from   w w w  . jav  a2  s .  com
    Files files = new LwjglFiles();
    Json json = new Json();
    FileHandle dir = files.internal(REPOCOMPONENTS_MAIN_PATH);
    // Generate fields classes for all repo classes
    buildCodeForAllClasses(files, json, dir, SCHEMAX_REPO_PACKAGE, EDITOR_SCHEMA_DESTFOLDER);
}

From source file:es.eucm.ead.buildtools.GenerateSkin.java

License:Open Source License

public static void main(String[] args) {
    Files files = new LwjglFiles();

    Settings settings = new Settings();

    FileHandle rawRoot = files.internal(RAW_LOCATION);
    FileHandle skinsRoot = new FileHandle(files.internal(SKINS_LOCATION).file());

    for (FileHandle folder : rawRoot.list()) {
        if (folder.isDirectory()) {
            FileHandle skinFolder = skinsRoot.child(folder.name());
            skinFolder.mkdirs();//from w w w  .  j a v a  2 s  .c  o  m
            TexturePacker.process(settings, folder.child("images").file().getAbsolutePath(),
                    skinFolder.file().getAbsolutePath(), "skin");
            folder.child("fonts").copyTo(skinFolder);
            folder.child("skin.json").copyTo(skinFolder);
        }
    }
}

From source file:es.eucm.ead.maven.GenerateSkinMojo.java

License:Open Source License

public void execute() throws MojoExecutionException {

    if (!sourceDir.exists()) {
        throw new MojoExecutionException("[generate-skins] Source directory does not exists: " + sourceDir);
    }/*from w  ww  .j  ava2s  . co m*/

    if (!outputDir.exists()) {
        if (!outputDir.mkdir()) {
            throw new MojoExecutionException("[generate-skins] Cannot create output directory: " + outputDir);
        }
    }

    Settings settings = new Settings();
    settings.limitMemory = false;

    LwjglFiles files = new LwjglFiles();
    LwjglNativesLoader.load();
    FileHandle rawRoot = files.absolute(sourceDir.getAbsolutePath());
    FileHandle skinsRoot = new FileHandle(files.internal(outputDir.getAbsolutePath()).file());

    getLog().info("[generate-skins] Removing old skins (if any)");
    for (FileHandle folder : skinsRoot.list()) {
        folder.deleteDirectory();
    }

    Array<FileHandle> tempFolders = new Array<FileHandle>();
    for (FileHandle skinRaw : rawRoot.list()) {
        if (skinRaw.isDirectory()) {
            FileHandle skinFolder = skinsRoot.child(skinRaw.name());

            if (!skinFolder.exists()) {

                if (skinRaw.child("common").exists()) {
                    generateMultipleSkins(skinRaw, skinsRoot);
                } else {
                    getLog().info("[generate-skins] Generating: " + skinRaw.name());
                    skinFolder.mkdirs();
                    FileHandle imagesFolder = skinRaw.child("images");

                    FileHandle fonts = skinRaw.child("ttf2fnt");
                    if (fonts.exists()) {
                        FileHandle config = fonts.child("fonts.config");
                        // fonts.config defines which .ttf will be
                        // transformed
                        // to what .fnt and with what size.
                        if (!config.exists()) {
                            fonts.copyTo(skinFolder);
                        } else {
                            String[] lines = config.readString().split("\n");
                            for (String line : lines) {
                                String[] props = line.split(" ");
                                String ttfFontName = props[0];
                                String fontSize = props[1];
                                fontSize = fontSize.replace("\r", "");

                                FileHandle child = fonts.child(ttfFontName);
                                if (child.exists()) {
                                    String fontName = child.nameWithoutExtension() + "-" + fontSize;
                                    FileHandle dstFolder = imagesFolder.child(fontName);
                                    dstFolder.mkdirs();
                                    dstFolder.child("pack.json").writeString(defaultPack, false);
                                    tempFolders.add(dstFolder);
                                    generateFiles(fontName, child, Integer.valueOf(fontSize), dstFolder);
                                    dstFolder.child(fontName + ".fnt").copyTo(skinFolder);
                                }
                            }
                        }
                    }
                    fonts = skinRaw.child("fonts");
                    if (fonts.exists()) {
                        fonts.copyTo(skinFolder);
                    }

                    TexturePacker.process(settings, imagesFolder.file().getAbsolutePath(),
                            skinFolder.file().getAbsolutePath(), "skin");

                    skinRaw.child("skin.json").copyTo(skinFolder);

                    for (FileHandle tempFolder : tempFolders) {
                        tempFolder.deleteDirectory();
                    }
                }
            } else {
                getLog().info("[generate-skins] skin already exists, skipping: " + skinRaw.name());
            }
        }
    }

}

From source file:ludoserver.core.Core.java

public Core() throws IOException, InterruptedException {
    // haxXx/*from   w  w  w .  j av a 2 s . co  m*/
    LwjglNativesLoader.load();
    Gdx.files = new LwjglFiles();

    server = new GameServer();
    server.bind(Network.port);
    server.start();

    Network.register(server);

    int N = 48;
    long taskTime = 0;
    long sleepTime = 1000 / N;
    while (true) {
        taskTime = System.currentTimeMillis();
        server.process();
        taskTime = System.currentTimeMillis() - taskTime;
        if (sleepTime - taskTime > 0) {
            Thread.sleep(sleepTime - taskTime);
        }
    }
}