Example usage for com.badlogic.gdx.utils StringBuilder StringBuilder

List of usage examples for com.badlogic.gdx.utils StringBuilder StringBuilder

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils StringBuilder StringBuilder.

Prototype

public StringBuilder() 

Source Link

Document

Constructs an instance with an initial capacity of 16 .

Usage

From source file:de.longri.cachebox3.develop.tools.skin_editor.validation.Validate_UnusedSvgFiles.java

License:Open Source License

@Override
public void runValidation() {

    FileHandle svgFolder = validationSkin.skinFolder.child("svg");
    FileHandle[] files = svgFolder.list();

    ObjectMap<java.lang.String, ScaledSvg> registed = validationSkin.getAll(ScaledSvg.class);

    Array<String> neadedList = new Array<String>();
    for (ScaledSvg scaledSvg : registed.values()) {
        neadedList.add(scaledSvg.path);//from  ww w.j av  a2  s  .c o m
    }

    Array<String> svgList = new Array<String>();
    for (FileHandle file : files) {
        svgList.add("svg/" + file.name());
    }

    for (String test : neadedList) {
        svgList.removeValue(test, true);
    }

    StringBuilder warnMassageBuilder = new StringBuilder();
    if (svgList.size > 0) {
        warnMassageBuilder.append("Unused *.svg files : \n\n");
        for (String unusedFile : svgList) {
            warnMassageBuilder.append(unusedFile);
            warnMassageBuilder.append("\n");
        }
        warnMsg = warnMassageBuilder.toString();
    }

}

From source file:at.therefactory.jewelthief.ui.Hud.java

License:Open Source License

public Hud(Game game) {
    this.game = game;
    this.stringBuilder = new StringBuilder();
    bundle = JewelThief.getInstance().getBundle();
    font = JewelThief.getInstance().getFont();
    rectangleHud = new Rectangle((WINDOW_WIDTH - game.getSpriteBackground().getWidth()) / 2,
            game.getSpriteBackground().getHeight() + game.getSpriteBackground().getY(), WINDOW_WIDTH, 31);
    jewelsToDisplay = new Jewel[levels.length];
    for (int i = 0; i < jewelsToDisplay.length; i++) {
        try {//  w w  w .  j a  v  a2  s .c o m
            jewelsToDisplay[i] = levels[i].getJewelClass().newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
    buttonShowMenu = new GrayButton("x", rectangleHud.getX() + rectangleHud.getWidth() - 31,
            rectangleHud.getY(), rectangleHud.getHeight(), rectangleHud.getHeight());
    buttonShowMenu.setBorderSize((short) 2);
}

From source file:com.trgk.touchwave.menuscene.StatsScene.java

License:Open Source License

public String encodePlaytime(float playTime) {
    StringBuilder builder = new StringBuilder();

    // ?// www. j a v  a 2s  . c  o m
    if (playTime >= 86400) {
        int days = (int) Math.floor(playTime / 86400f);
        builder.append(String.format(Locale.KOREAN, "%d? ", days));
        playTime -= days * 86400;
    }

    // 
    if (playTime >= 3600) {
        int hours = (int) Math.floor(playTime / 3600);
        builder.append(String.format(Locale.KOREAN, "%d ", hours));
        playTime -= hours * 3600;
    }

    // 
    if (playTime >= 60) {
        int minutes = (int) Math.floor(playTime / 60);
        builder.append(String.format(Locale.KOREAN, "%d ", minutes));
        playTime -= minutes * 60;
    }

    builder.append(String.format(Locale.KOREAN, "%d", (int) Math.floor(playTime)));
    return builder.toString();
}

From source file:de.cubicvoxel.openspacebox.realmdesigner.util.LogWindow.java

License:Open Source License

public void clear() {
    stringBuilder = new StringBuilder();
}

From source file:de.longri.cachebox3.develop.tools.skin_editor.validation.Validate_Abstract_Icons.java

License:Open Source License

@Override
public void runValidation() {

    errorMsg = "";
    warnMsg = "";

    try {//from   w ww  . j  a  v a  2 s.co  m
        Field[] fields = ClassReflection.getFields(tClass);
        Object instance = validationSkin.get(tClass);

        for (Field field : fields) {
            Object object = field.get(instance);

            if (object instanceof Integer) {
                continue;
            }

            if (object != null) {
                TextureRegionDrawable trd = (TextureRegionDrawable) object;
                String svgName = trd.getName();

                ScaledSvg scaledSvg = validationSkin.get(svgName, ScaledSvg.class);
                if (scaledSvg.path.toLowerCase().contains("missingicon")) {
                    isMissingIconList.add(field.getName());
                }

                checkSize(object, field.getName());

            } else {
                isNullList.add(field.getName());
            }

        }
    } catch (Exception e) {
        e.printStackTrace();
        errorMsg = "Error with validation task";
    }

    if (isNullList.size > 0) {
        StringBuilder sb = new StringBuilder();
        sb.append("Some Icons are NULL:\n\n");
        for (String name : isNullList) {
            sb.append(name);
            sb.append("\n");
        }

        errorMsg += sb.toString();
    }

    if (isMissingIconList.size > 0) {
        StringBuilder sb = new StringBuilder();
        sb.append("Some Icons are dummy Icon (\"missingIcon\") :\n\n");
        for (String name : isMissingIconList) {
            sb.append(name);
            sb.append("\n");
        }
        warnMsg = sb.toString();
    }

    if (wrongBitmapsSize.length > 0) {
        warnMsg += "\n\nWrong Sizes:\n\n" + wrongBitmapsSize.toString();
    }
}

From source file:net.dermetfan.gdx.maps.MapUtils.java

License:Apache License

/** @param map the map to represent
 *  @param indent the indentation size (indent is {@code '\t'})
 *  @return a human-readable hierarchy of the given map and its descendants */
public static String readableHierarchy(Map map, int indent) {
    StringBuilder hierarchy = new StringBuilder();
    for (int i = 0; i < indent; i++)
        hierarchy.append('\t');
    hierarchy.append(ClassReflection.getSimpleName(map.getClass())).append('\n');
    hierarchy.append(readableHierarchy(map.getProperties(), indent + 1));
    if (map instanceof TiledMap)
        hierarchy.append(readableHierarchy(((TiledMap) map).getTileSets(), indent + 1));
    hierarchy.append(readableHierarchy(map.getLayers(), indent + 1));
    return hierarchy.toString();
}

From source file:net.dermetfan.gdx.maps.MapUtils.java

License:Apache License

/** @see #readableHierarchy(com.badlogic.gdx.maps.Map, int) */
public static String readableHierarchy(TiledMapTileSets sets, int indent) {
    StringBuilder hierarchy = new StringBuilder();
    for (TiledMapTileSet set : sets)
        hierarchy.append(readableHierarchy(set, indent));
    return hierarchy.toString();
}

From source file:net.dermetfan.gdx.maps.MapUtils.java

License:Apache License

/** @see #readableHierarchy(com.badlogic.gdx.maps.Map, int) */
public static String readableHierarchy(TiledMapTileSet set, int indent) {
    StringBuilder hierarchy = new StringBuilder();
    for (int i = 0; i < indent; i++)
        hierarchy.append('\t');
    hierarchy.append(ClassReflection.getSimpleName(set.getClass())).append(' ').append(set.getName())
            .append(" (").append(set.size()).append(" tiles)\n");
    hierarchy.append(readableHierarchy(set.getProperties(), indent + 1));
    for (TiledMapTile tile : set)
        hierarchy.append(readableHierarchy(tile, indent + 1));
    return hierarchy.toString();
}

From source file:net.dermetfan.gdx.maps.MapUtils.java

License:Apache License

/** @see #readableHierarchy(com.badlogic.gdx.maps.Map, int) */
public static String readableHierarchy(TiledMapTile tile, int indent) {
    StringBuilder hierarchy = new StringBuilder();
    for (int i = 0; i < indent; i++)
        hierarchy.append('\t');
    hierarchy.append(ClassReflection.getSimpleName(tile.getClass())).append(" (ID: ").append(tile.getId())
            .append(", offset: ").append(tile.getOffsetX()).append('x').append(tile.getOffsetY())
            .append(", BlendMode: ").append(tile.getBlendMode()).append(")\n");
    hierarchy.append(readableHierarchy(tile.getProperties(), indent + 1));
    return hierarchy.toString();
}

From source file:edu.franklin.practicum.f15.strategygame.StrategyGame.java

public boolean verifyLicense() {
    boolean result = false;
    // TODO: Load Information from license.json file
    FileHandle fh = Gdx.files.internal("config/license.json");
    String configString = fh.readString();
    JsonValue root = new JsonReader().parse(configString);
    String license = root.getString("licenseKey", "");
    String uniqueID = root.getString("uniqueId", "");

    String params = "response=verify&license=LICENSE&id=UNIQUE_ID";

    if (license.length() <= 0) {
        Logger.logMsg("failed to get licenseKey from license.JSON");
        return false;
    }//from   ww  w  .  j  a v  a 2  s .  c  o  m

    if (uniqueID.length() <= 0) {
        Logger.logMsg("failed to get uniqueID from license.JSON");
        return false;
    }

    params = params.replaceFirst("LICENSE", license);
    params = params.replaceFirst("UNIQUE_ID", uniqueID);

    try {

        String licenseServerURL = "http://f15slic.franklinpracticum.com/api/license_response.php";
        URL url = new URL(licenseServerURL + "?" + params);
        byte[] postData = params.getBytes(java.nio.charset.StandardCharsets.UTF_8);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setDoOutput(true);
        conn.setInstanceFollowRedirects(false);
        conn.setRequestMethod("POST");
        conn.setRequestProperty("charset", "utf-8");
        conn.setUseCaches(false);
        DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
        wr.write(postData);
        BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        StringBuilder sb = new StringBuilder();
        String response;
        String s;
        while ((s = br.readLine()) != null) {
            sb.append(s);
        }
        response = sb.toString();
        if (response.contains("<valid_key>true")) {
            result = true;
            Logger.logMsg("license key is valid");
        } else {
            Logger.logMsg("license key is invalid");
        }
        conn.disconnect();
    } catch (Exception exc) {
        Logger.logMsg("exception occurred validating license: " + exc.toString());
    }

    return result;
}