MCPcopy Create free account
hub / github.com/MaaXYZ/MaaFramework / parse_swipe

Method parse_swipe

source/MaaFramework/Resource/PipelineParser.cpp:1248–1302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1246}
1247
1248bool PipelineParser::parse_swipe(const json::value& input, Action::SwipeParam& output, const Action::SwipeParam& default_value)
1249{
1250 if (!parse_action_target(input, "begin", output.begin, default_value.begin)) {
1251 LogError << "failed to parse_action_target begin" << VAR(input);
1252 return false;
1253 }
1254
1255 if (!parse_action_target_obj_or_list(input, "end", output.end, default_value.end)) {
1256 LogError << "failed to parse_action_target end" << VAR(input);
1257 return false;
1258 }
1259
1260 if (!parse_action_target_offset_or_list(input, "end_offset", output.end_offset, default_value.end_offset)) {
1261 LogError << "failed to parse_action_target end" << VAR(input);
1262 return false;
1263 }
1264 // if (output.begin.type == Action::Target::Type::Self
1265 // && output.end.type == Action::Target::Type::Self) {
1266 // LogError << "not set swipe begin or end";
1267 // return false;
1268 // }
1269
1270 if (!get_and_check_value_or_array(input, "duration", output.duration, default_value.duration)) {
1271 LogError << "failed to get_and_check_value duration" << VAR(input);
1272 return false;
1273 }
1274
1275 if (!get_and_check_value_or_array(input, "end_hold", output.end_hold, default_value.end_hold)) {
1276 LogError << "failed to get_and_check_value end_hold" << VAR(input);
1277 return false;
1278 }
1279
1280 if (!get_and_check_value(input, "only_hover", output.only_hover, default_value.only_hover)) {
1281 LogError << "failed to get_and_check_value only_hover" << VAR(input);
1282 return false;
1283 }
1284
1285 // only for multi swipe
1286 if (!get_and_check_value(input, "starting", output.starting, default_value.starting)) {
1287 LogError << "failed to get_and_check_value starting" << VAR(input);
1288 return false;
1289 }
1290
1291 if (!get_and_check_value(input, "contact", output.contact, default_value.contact)) {
1292 LogError << "failed to get_and_check_value contact" << VAR(input);
1293 return false;
1294 }
1295
1296 if (!get_and_check_value(input, "pressure", output.pressure, default_value.pressure)) {
1297 LogError << "failed to get_and_check_value pressure" << VAR(input);
1298 return false;
1299 }
1300
1301 return true;
1302}
1303
1304bool PipelineParser::parse_multi_swipe(
1305 const json::value& input,

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected