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

The following examples show how to use com.badlogic.gdx.utils.JsonValue#isString() . 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: JsonListMapDeserializer.java    From gdx-fireapp with Apache License 2.0 5 votes vote down vote up
private Object processValue(JsonValue jsonData) {
    if (jsonData.isBoolean())
        return jsonData.asBoolean();
    else if (jsonData.isDouble())
        return jsonData.asDouble();
    else if (jsonData.isLong())
        return jsonData.asLong();
    else if (jsonData.isNull())
        return null;
    else if (jsonData.isString())
        return jsonData.asString();
    return null;
}
 
Example 2
Source File: JsonSkinSerializer.java    From beatoraja with GNU General Public License v3.0 5 votes vote down vote up
public T read(Json json, JsonValue jsonValue, Class cls) {
	if (jsonValue.isString() && luaPropertyLoader != null) {
		return luaPropertyLoader.apply(lua, jsonValue.asString());
	} else if (jsonValue.isNumber() && idPropertyLoader != null) {
		return idPropertyLoader.apply(jsonValue.asInt());
	} else {
		return null;
	}
}
 
Example 3
Source File: ModelTools.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
private static void readableInkDialogsInternal(JsonValue v, StringBuilder sbMD, OrderedProperties prop) {
	if (v.isArray() || v.isObject()) {
		if (v.name != null && v.isArray() && v.parent != null && v.parent.parent != null
				&& v.parent.parent.parent != null) {
			if (v.name.contains("-"))
				sbMD.append('\n');
			else if (v.parent.parent.parent.parent == null)
				sbMD.append("\n==== " + v.name + " ====\n");
			else if (v.name.equals("s"))
				sbMD.append("  * ");
			// else
			// sbMD.append("\n-- " + v.name + " --\n");
		}

		for (int i = 0; i < v.size; i++) {
			JsonValue aValue = v.get(i);

			readableInkDialogsInternal(aValue, sbMD, prop);
		}

	} else if (v.isString() && v.asString().charAt(0) == '^') {
		String key = v.asString().substring(1).trim();

		if (key.length() == 0 || key.charAt(0) == '>')
			return;

		int idx = key.indexOf('>');
		String charName = "";

		if (idx != -1) {
			charName = key.substring(0, idx).trim();
			key = key.substring(idx + 1).trim();

			if (key.length() <= 1)
				return;
		}

		key = key.substring(1);

		String value = prop.getProperty(key);

		sbMD.append(charName + (charName.isEmpty() ? "" : ": ") + value + " (" + key + ")\n");
	}
}