| 37 | }; |
| 38 | |
| 39 | s32 parse_frames(Array<SpriteFrame> &sprite_frames, const JsonArray &frames, CompileOptions &opts) |
| 40 | { |
| 41 | CE_UNUSED(opts); |
| 42 | |
| 43 | for (u32 ii = 0; ii < array::size(frames); ++ii) { |
| 44 | TempAllocator512 ta; |
| 45 | JsonObject obj(ta); |
| 46 | RETURN_IF_ERROR(sjson::parse(obj, frames[ii])); |
| 47 | |
| 48 | SpriteFrame sf; |
| 49 | sf.name = RETURN_IF_ERROR(sjson::parse_string_id(obj["name"])); |
| 50 | sf.region = RETURN_IF_ERROR(sjson::parse_vector4(obj["region"])); |
| 51 | sf.pivot = RETURN_IF_ERROR(sjson::parse_vector2(obj["pivot"])); |
| 52 | |
| 53 | if (json_object::has(obj, "index")) { |
| 54 | sf.index = RETURN_IF_ERROR(sjson::parse_int(obj["index"])); |
| 55 | } else { |
| 56 | sf.index = ii; |
| 57 | } |
| 58 | |
| 59 | array::push_back(sprite_frames, sf); |
| 60 | } |
| 61 | |
| 62 | std::sort(array::begin(sprite_frames) |
| 63 | , array::end(sprite_frames) |
| 64 | , [](const SpriteFrame &frame_a, const SpriteFrame &frame_b) { |
| 65 | return frame_a.index < frame_b.index; |
| 66 | }); |
| 67 | |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | s32 compile(CompileOptions &opts) |
| 72 | { |
no test coverage detected