MCPcopy Create free account
hub / github.com/crownengine/crown / parse_frames

Function parse_frames

src/resource/sprite_resource.cpp:39–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 1

compileFunction · 0.85

Calls 10

parse_string_idFunction · 0.85
parse_vector4Function · 0.85
parse_vector2Function · 0.85
parseFunction · 0.70
sizeFunction · 0.50
hasFunction · 0.50
parse_intFunction · 0.50
sortFunction · 0.50
beginFunction · 0.50
endFunction · 0.50

Tested by

no test coverage detected