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

The following examples show how to use com.badlogic.gdx.utils.JsonValue#isArray() . 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: JsonSkinSerializer.java    From beatoraja with GNU General Public License v3.0 5 votes vote down vote up
protected boolean testOption(JsonValue ops) {
	if (ops == null) {
		return true;
	} else if (ops.isNumber()) {
		return testNumber(ops.asInt());
	} else if (ops.isArray()) {
		boolean enabled = true;
		for (int j = 0; j < ops.size; j++) {
			JsonValue ops2 = ops.get(j);
			if (ops2.isNumber()) {
				enabled = testNumber(ops2.asInt());
			} else if (ops2.isArray()) {
				boolean enabled_sub = false;
				for (int k = 0; k < ops2.size; k++) {
					JsonValue ops3 = ops2.get(k);
					if (ops3.isNumber() && testNumber(ops3.asInt())) {
						enabled_sub = true;
						break;
					}
				}
				enabled = enabled_sub;
			} else {
				enabled = false;
			}
			if (!enabled)
				break;
		}
		return enabled;
	} else {
		return false;
	}
}
 
Example 2
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");
	}
}
 
Example 3
Source File: BlenderShapeKeys.java    From gdx-gltf with Apache License 2.0 3 votes vote down vote up
/** Blender store shape key names in mesh extras.
 * <pre>
 *  "meshes" : [
         {
           "name" : "Plane",
           "extras" : {
               "targetNames" : [
                   "Water",
                   "Mountains"
               ]
           },
           "primitives" : ...,
           "weights" : [0.6, 0.3]
         }
       ]
 */
public static Array<String> parse(GLTFMesh glMesh) {
	if(glMesh.extras == null) return null;
	JsonValue targetNames = glMesh.extras.value.get("targetNames");
	if(targetNames != null && targetNames.isArray()){
		return new Array<String>(targetNames.asStringArray());
	}
	return null;
}