public static L2DExpressionMotion loadJson(char[] buf) { L2DExpressionMotion motion = new L2DExpressionMotion(); Value value2 = Json.parseFromBytes(buf); motion.setFadeIn(value2.get("fade_in").toInt(0x3e8)); motion.setFadeOut(value2.get("fade_out").toInt(0x3e8)); if (value2.getMap(null).ContainsKey("params")) { Value value3 = value2.get("params"); int count = value3.getVector(null).Count; motion.paramList = new List<L2DExpressionParam>(count); for (int i = 0; i < count; i++) { Value value4 = value3.get(i); string str = value4.get("id").toString(); float num3 = value4.get("val").toFloat(); int num4 = 1; string str2 = !value4.getMap(null).ContainsKey("calc") ? "add" : value4.get("calc").toString(); if (str2.Equals("add")) { num4 = 1; } else if (str2.Equals("mult")) { num4 = 2; } else if (str2.Equals("set")) { num4 = 0; } else { num4 = 1; } if (num4 == 1) { float num5 = value4.getMap(null).ContainsKey("def") ? value4.get("def").toFloat() : 0f; num3 -= num5; } else if (num4 == 2) { float num6 = value4.getMap(null).ContainsKey("def") ? value4.get("def").toFloat(0f) : 1f; if (num6 == 0f) { num6 = 1f; } num3 /= num6; } L2DExpressionParam item = new L2DExpressionParam(); item.id = str; item.type = num4; item.value = num3; motion.paramList.Add(item); } } return motion; }
/* * JSONの解析結果からExpressionを生成する * @param v */ static private L2DExpressionMotion loadJsonV09(Value defaultExpr, Value expr) { L2DExpressionMotion ret = new L2DExpressionMotion(); ret.setFadeIn(expr.get("FADE_IN").toInt(1000)); ret.setFadeOut(expr.get("FADE_OUT").toInt(1000)); // --- IDリストを生成 Value defaultParams = defaultExpr.get("PARAMS"); Value parameters = expr.get("PARAMS"); List <string> paramID = parameters.keySet(); List <string> idList = new List <string>(); foreach (string id in paramID) { idList.Add(id); } // --------- 値を設定 --------- for (int i = idList.Count - 1; i >= 0; --i) { string id = idList[i]; float defaultV = defaultParams.get(id).toFloat(0); float v = parameters.get(id).toFloat(0.0f); float values = (v - defaultV); // ret.addParam(id, value,L2DExpressionMotion.TYPE_ADD); L2DExpressionParam param = new L2DExpressionParam(); param.id = id; param.type = L2DExpressionMotion.TYPE_ADD; param.value = values; ret.paramList.Add(param); } return(ret); }
/* * JSONファイルから読み込み。 * 仕様についてはマニュアル参照。JSONスキーマの形式の仕様がある。 * @param buf * @return */ public static L2DExpressionMotion loadJson(char[] buf) { L2DExpressionMotion ret = new L2DExpressionMotion(); Value json = Json.parseFromBytes(buf); ret.setFadeIn(json.get("fade_in").toInt(1000));// フェードイン ret.setFadeOut(json.get("fade_out").toInt(1000));// フェードアウト if (!json.getMap(null).ContainsKey("params")) return ret; // パラメータ一覧 Value parameters = json.get("params"); int paramNum = parameters.getVector(null).Count; ret.paramList = new List<L2DExpressionParam>(paramNum); for (int i = 0; i < paramNum; i++) { Value param = parameters.get(i); string paramID = param.get("id").toString();// パラメータID float value = param.get("val").toFloat();// 値 // 計算方法の設定 int calcTypeInt = TYPE_ADD; string calc = param.getMap(null).ContainsKey("calc") ? (param.get("calc").toString()) : "add"; if (calc.Equals("add")) { calcTypeInt = TYPE_ADD; } else if (calc.Equals("mult")) { calcTypeInt = TYPE_MULT; } else if (calc.Equals("set")) { calcTypeInt = TYPE_SET; } else { // その他 仕様にない値を設定したときは加算モードにすることで復旧 calcTypeInt = TYPE_ADD; } // 計算方法 加算 if (calcTypeInt == TYPE_ADD) { float defaultValue = (!param.getMap(null).ContainsKey("def")) ? 0 : param.get("def").toFloat(); value = value - defaultValue; } // 計算方法 乗算 else if (calcTypeInt == TYPE_MULT) { float defaultValue = (!param.getMap(null).ContainsKey("def")) ? 1 : param.get("def").toFloat(0); if (defaultValue == 0) defaultValue = 1;// 0(不正値)を指定した場合は1(標準)にする value = value / defaultValue; } // 設定オブジェクトを作成してリストに追加する L2DExpressionParam item = new L2DExpressionParam(); item.id = paramID; item.type = calcTypeInt; item.value = value; ret.paramList.Add(item); } return ret; }
/* * JSONの解析結果からExpressionを生成する * @param v */ private static L2DExpressionMotion loadJsonV09(Value defaultExpr, Value expr) { L2DExpressionMotion ret = new L2DExpressionMotion(); ret.setFadeIn(expr.get("FADE_IN").toInt(1000)); ret.setFadeOut(expr.get("FADE_OUT").toInt(1000)); // --- IDリストを生成 Value defaultParams = defaultExpr.get("PARAMS"); Value parameters = expr.get("PARAMS"); List<string> paramID = parameters.keySet(); List<string> idList = new List<string>(); foreach (string id in paramID) { idList.Add(id); } // --------- 値を設定 --------- for (int i = idList.Count - 1; i >= 0; --i) { string id = idList[i]; float defaultV = defaultParams.get(id).toFloat(0); float v = parameters.get(id).toFloat(0.0f); float values = (v - defaultV); // ret.addParam(id, value,L2DExpressionMotion.TYPE_ADD); L2DExpressionParam param = new L2DExpressionParam(); param.id = id; param.type = L2DExpressionMotion.TYPE_ADD; param.value = values; ret.paramList.Add(param); } return ret; }
public static L2DExpressionMotion loadJson(char[] buf) { L2DExpressionMotion ret = new L2DExpressionMotion(); Value json = Json.parseFromBytes(buf); ret.setFadeIn(json.get("fade_in").toInt(1000)); ret.setFadeOut(json.get("fade_out").toInt(1000)); if (!json.getMap(null).ContainsKey("params")) return ret; Value parameters = json.get("params"); int paramNum = parameters.getVector(null).Count; ret.paramList = new List<L2DExpressionParam>(paramNum); for (int i = 0; i < paramNum; i++) { Value param = parameters.get(i); string paramID = param.get("id").toString(); float value = param.get("val").toFloat(); int calcTypeInt = TYPE_ADD; string calc = param.getMap(null).ContainsKey("calc") ? (param.get("calc").toString()) : "add"; if (calc.Equals("add")) { calcTypeInt = TYPE_ADD; } else if (calc.Equals("mult")) { calcTypeInt = TYPE_MULT; } else if (calc.Equals("set")) { calcTypeInt = TYPE_SET; } else { calcTypeInt = TYPE_ADD; } if (calcTypeInt == TYPE_ADD) { float defaultValue = (!param.getMap(null).ContainsKey("def")) ? 0 : param.get("def").toFloat(); value = value - defaultValue; } else if (calcTypeInt == TYPE_MULT) { float defaultValue = (!param.getMap(null).ContainsKey("def")) ? 1 : param.get("def").toFloat(0); if (defaultValue == 0) defaultValue = 1; value = value / defaultValue; } L2DExpressionParam item = new L2DExpressionParam(); item.id = paramID; item.type = calcTypeInt; item.value = value; ret.paramList.Add(item); } return ret; }
private static L2DExpressionMotion loadJsonV09(Value defaultExpr, Value expr) { L2DExpressionMotion motion = new L2DExpressionMotion(); motion.setFadeIn(expr.get("FADE_IN").toInt(0x3e8)); motion.setFadeOut(expr.get("FADE_OUT").toInt(0x3e8)); Value value2 = defaultExpr.get("PARAMS"); Value value3 = expr.get("PARAMS"); List<string> list = value3.keySet(); List<string> list2 = new List<string>(); foreach (string str in list) { list2.Add(str); } for (int i = list2.Count - 1; i >= 0; i--) { string key = list2[i]; float num2 = value2.get(key).toFloat(0f); float num4 = value3.get(key).toFloat(0f) - num2; L2DExpressionParam item = new L2DExpressionParam(); item.id = key; item.type = 1; item.value = num4; motion.paramList.Add(item); } return motion; }
/* * JSONファイルから読み込み。 * 仕様についてはマニュアル参照。JSONスキーマの形式の仕様がある。 * @param buf * @return */ public static L2DExpressionMotion loadJson(char[] buf) { L2DExpressionMotion ret = new L2DExpressionMotion(); Value json = Json.parseFromBytes(buf); ret.setFadeIn(json.get("fade_in").toInt(1000)); // フェードイン ret.setFadeOut(json.get("fade_out").toInt(1000)); // フェードアウト if (!json.getMap(null).ContainsKey("params")) { return(ret); } // パラメータ一覧 Value parameters = json.get("params"); int paramNum = parameters.getVector(null).Count; ret.paramList = new List <L2DExpressionParam>(paramNum); for (int i = 0; i < paramNum; i++) { Value param = parameters.get(i); string paramID = param.get("id").toString(); // パラメータID float value = param.get("val").toFloat(); // 値 // 計算方法の設定 int calcTypeInt = TYPE_ADD; string calc = param.getMap(null).ContainsKey("calc") ? (param.get("calc").toString()) : "add"; if (calc.Equals("add")) { calcTypeInt = TYPE_ADD; } else if (calc.Equals("mult")) { calcTypeInt = TYPE_MULT; } else if (calc.Equals("set")) { calcTypeInt = TYPE_SET; } else { // その他 仕様にない値を設定したときは加算モードにすることで復旧 calcTypeInt = TYPE_ADD; } // 計算方法 加算 if (calcTypeInt == TYPE_ADD) { float defaultValue = (!param.getMap(null).ContainsKey("def")) ? 0 : param.get("def").toFloat(); value = value - defaultValue; } // 計算方法 乗算 else if (calcTypeInt == TYPE_MULT) { float defaultValue = (!param.getMap(null).ContainsKey("def")) ? 1 : param.get("def").toFloat(0); if (defaultValue == 0) { defaultValue = 1; // 0(不正値)を指定した場合は1(標準)にする } value = value / defaultValue; } // 設定オブジェクトを作成してリストに追加する L2DExpressionParam item = new L2DExpressionParam(); item.id = paramID; item.type = calcTypeInt; item.value = value; ret.paramList.Add(item); } return(ret); }
public static L2DExpressionMotion loadJson(char[] buf) { L2DExpressionMotion ret = new L2DExpressionMotion(); Value json = Json.parseFromBytes(buf); ret.setFadeIn(json.get("fade_in").toInt(1000)); ret.setFadeOut(json.get("fade_out").toInt(1000)); if (!json.getMap(null).ContainsKey("params")) { return(ret); } Value parameters = json.get("params"); int paramNum = parameters.getVector(null).Count; ret.paramList = new List <L2DExpressionParam>(paramNum); for (int i = 0; i < paramNum; i++) { Value param = parameters.get(i); string paramID = param.get("id").toString(); float value = param.get("val").toFloat(); int calcTypeInt = TYPE_ADD; string calc = param.getMap(null).ContainsKey("calc") ? (param.get("calc").toString()) : "add"; if (calc.Equals("add")) { calcTypeInt = TYPE_ADD; } else if (calc.Equals("mult")) { calcTypeInt = TYPE_MULT; } else if (calc.Equals("set")) { calcTypeInt = TYPE_SET; } else { calcTypeInt = TYPE_ADD; } if (calcTypeInt == TYPE_ADD) { float defaultValue = (!param.getMap(null).ContainsKey("def")) ? 0 : param.get("def").toFloat(); value = value - defaultValue; } else if (calcTypeInt == TYPE_MULT) { float defaultValue = (!param.getMap(null).ContainsKey("def")) ? 1 : param.get("def").toFloat(0); if (defaultValue == 0) { defaultValue = 1; } value = value / defaultValue; } L2DExpressionParam item = new L2DExpressionParam(); item.id = paramID; item.type = calcTypeInt; item.value = value; ret.paramList.Add(item); } return(ret); }