Java Code Examples for com.badlogic.gdx.utils.JsonValue#getBoolean()

The following examples show how to use com.badlogic.gdx.utils.JsonValue#getBoolean() . These examples are extracted from open source projects. 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 Project: skin-composer   File: StyleProperty.java    License: MIT License 6 votes vote down vote up
@Override
public void read(Json json, JsonValue jsonValue) {
    try {
        name = jsonValue.getString("name");
        optional = jsonValue.getBoolean("optional");
        if (jsonValue.get("value").isNumber()) {
            type = Float.TYPE;
            value = Double.parseDouble(jsonValue.getString("value"));
        } else {
            type = ClassReflection.forName(jsonValue.getString("type"));
            if (jsonValue.get("value").isNull()) {
                value = null;
            } else {
                value = jsonValue.getString("value");
            }
        }
    } catch (ReflectionException ex) {
        Gdx.app.error(getClass().toString(), "Error reading from serialized object" , ex);
        DialogFactory.showDialogErrorStatic("Read Error...","Error reading from serialized object.\n\nOpen log?");
    }
}
 
Example 2
Source Project: talos   File: RandomRangeModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void read (Json json, JsonValue jsonData) {
    super.read(json, jsonData);
    min = jsonData.getFloat("min", 0);
    max = jsonData.getFloat("max", 0);
    distributed = jsonData.getBoolean("distributed", false);
}
 
Example 3
Source Project: talos   File: EmConfigModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void read (Json json, JsonValue jsonData) {
    super.read(json, jsonData);
    getUserValue().additive = jsonData.getBoolean("additive");
    getUserValue().attached = jsonData.getBoolean("attached");
    getUserValue().continuous = jsonData.getBoolean("continuous");
    getUserValue().aligned = jsonData.getBoolean("aligned");
}
 
Example 4
Source Project: talos   File: BoundEffect.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void read(Json json, JsonValue jsonData) {
    String effectName = jsonData.getString("effectName");
    String effectPath = parent.getWorkspace().getPath(effectName + ".p");
    FileHandle effectHandle = TalosMain.Instance().ProjectController().findFile(effectPath);
    this.name = effectName;

    if(effectHandle == null || !effectHandle.exists()) {
       throw new GdxRuntimeException("Particle effect not found");
    }

    parent.getWorkspace().registerTalosAssets(effectHandle);

    //TODO: refactor this
    ParticleEffectDescriptor descriptor = new ParticleEffectDescriptor();
    descriptor.setAssetProvider(TalosMain.Instance().TalosProject().getProjectAssetProvider());
    descriptor.load(effectHandle);
    parent.getWorkspace().getVfxLibrary().put(name, descriptor);

    // track this file
    TalosMain.Instance().FileTracker().trackFile(effectHandle, parent.getWorkspace().bvb.particleTracker);

    this.particleEffectDescriptor = descriptor;

    positionAttachment = json.readValue(AttachmentPoint.class, jsonData.get("positionAttachment"));
    JsonValue valueAttachmentsJson = jsonData.get("valueAttachments");
    for(JsonValue valueAttachmentJson: valueAttachmentsJson) {
        AttachmentPoint point = json.readValue(AttachmentPoint.class, valueAttachmentJson);
        valueAttachments.add(point);
    }

    setStartEvent(jsonData.getString("startEvent", ""));
    setCompleteEvent(jsonData.getString("completeEvent", ""));

    isBehind = jsonData.getBoolean("isBehind");

    setForever(startEvent.equals("") && completeEvent.equals(""));
}
 
Example 5
Source Project: gdx-gamesvcs   File: GameJoltClient.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Helper method when just interested if GameJolt request was successful
 */
protected boolean parseSuccessFromResponse(String json) {
    JsonValue response = null;
    boolean success;
    try {
        response = new JsonReader().parse(json).get("response");
        success = response != null && response.getBoolean("success");
    } catch (Throwable t) {
        Gdx.app.error(GAMESERVICE_ID, "Cannot parse GameJolt response: " + json, t);
        success = false;
    }
    return success;
}
 
Example 6
Source Project: skin-composer   File: CustomClass.java    License: MIT License 5 votes vote down vote up
@Override
public void read(Json json, JsonValue jsonData) {
    fullyQualifiedName = jsonData.getString("fullyQualifiedName");
    displayName = jsonData.getString("displayName");
    styles = json.readValue("styles", Array.class, CustomStyle.class, jsonData);
    for (CustomStyle style : styles) {
        style.setParentClass(this);
    }
    templateStyle = json.readValue("templateStyle", CustomStyle.class, jsonData);
    templateStyle.setParentClass(this);
    declareAfterUIclasses = jsonData.getBoolean("declareAfterUIclasses", false);
}
 
Example 7
Source Project: skin-composer   File: CustomStyle.java    License: MIT License 5 votes vote down vote up
@Override
public void read(Json json, JsonValue jsonData) {
    name = jsonData.getString("name");
    properties = json.readValue("properties", Array.class, CustomProperty.class, jsonData);
    for (CustomProperty property : properties) {
        property.setParentStyle(this);
    }
    deletable = jsonData.getBoolean("deletable");
}
 
Example 8
Source Project: skin-composer   File: FreeTypeFontData.java    License: MIT License 5 votes vote down vote up
@Override
public void read(Json json, JsonValue jsonData) {
    name = jsonData.getString("name");
    file = jsonData.has("file") ? Gdx.files.absolute(jsonData.getString("file")) : null;
    previewTTF = jsonData.getString("previewTTF");
    useCustomSerializer = jsonData.getBoolean("useCustomSerializer", false);
    size = jsonData.getInt("size", 16);
    mono = jsonData.getBoolean("mono");
    hinting = jsonData.getString("hinting", "AutoMedium");
    color = jsonData.getString("color");
    gamma = jsonData.getFloat("gamma", 1.8f);
    renderCount = jsonData.getInt("renderCount", 2);
    borderWidth = jsonData.getFloat("borderWidth", 0);
    borderColor = jsonData.getString("borderColor");
    borderStraight = jsonData.getBoolean("borderStraight", false);
    borderGamma = jsonData.getFloat("borderGamma", 1.8f);
    shadowOffsetX = jsonData.getInt("shadowOffsetX", 0);
    shadowOffsetY = jsonData.getInt("shadowOffsetY", 0);
    shadowColor = jsonData.getString("shadowColor");
    spaceX = jsonData.getInt("spaceX");
    spaceY = jsonData.getInt("spaceY");
    characters = jsonData.getString("characters", "");
    kerning = jsonData.getBoolean("kerning", true);
    flip = jsonData.getBoolean("flip", false);
    genMipMaps = jsonData.getBoolean("genMipMaps", false);
    minFilter = jsonData.getString("minFilter", "Nearest");
    magFilter = jsonData.getString("magFilter", "Nearest");
    incremental = jsonData.getBoolean("incremental");
}
 
Example 9
@Override
public InputFile read(Json json, JsonValue jsonData, Class clazz) {
    String path = jsonData.getString("path");
    InputFile.Type type = InputFile.Type.valueOf(jsonData.getString("type"));
    String dirFilePrefix = jsonData.getString("dirFilePrefix", null);
    String regionName = jsonData.getString("regionName", null);
    boolean recursive = jsonData.getBoolean("recursive", false);
    boolean flattenPaths = jsonData.getBoolean("flattenPaths", false);

    FileHandle fileHandle;
    if (new File(path).isAbsolute()) {
        fileHandle = Gdx.files.absolute(path);
    } else {
        fileHandle = Gdx.files.absolute(new File(root, path).getAbsolutePath());
    }

    InputFile inputFile = new InputFile(fileHandle, type);
    inputFile.setDirFilePrefix(dirFilePrefix);
    inputFile.setRegionName(regionName);
    inputFile.setRecursive(recursive);
    inputFile.setFlattenPaths(flattenPaths);

    // Ninepatch
    JsonValue ninepatch = jsonData.get("ninepatch");
    if (ninepatch != null) {
        InputFile.NinePatchProps npp = inputFile.getNinePatchProps();
        int[] splits = ninepatch.get("splits").asIntArray();
        int[] pads = ninepatch.get("pads").asIntArray();
        npp.left = splits[0];
        npp.right = splits[1];
        npp.top = splits[2];
        npp.bottom = splits[3];
        npp.padLeft = pads[0];
        npp.padRight = pads[1];
        npp.padTop = pads[2];
        npp.padBottom = pads[3];
        inputFile.setProgrammaticNinePatch(true);
    }

    return inputFile;
}