Skip to content

Commit 54c0d50

Browse files
committed
Scratch3Reader: Load mutations
1 parent 6f51dde commit 54c0d50

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/internal/scratch3reader.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,32 @@ bool Scratch3Reader::load()
118118
block->addField(field);
119119
}
120120

121+
// mutation
122+
if (blockInfo.contains("mutation")) {
123+
auto mutation = blockInfo["mutation"];
124+
if (mutation.contains("hasnext"))
125+
block->setMutationHasNext(jsonToValue(mutation["hasnext"]).toBool());
126+
BlockPrototype *prototype = block->mutationPrototype();
127+
if (mutation.contains("proccode"))
128+
prototype->setProcCode(mutation["proccode"].get<std::string>());
129+
if (mutation.contains("argumentids")) {
130+
std::vector<std::string> argIDs;
131+
auto argIDsJson = json::parse(mutation["argumentids"].get<std::string>());
132+
for (auto arg : argIDsJson)
133+
argIDs.push_back(arg.get<std::string>());
134+
prototype->setArgumentIds(argIDs);
135+
}
136+
if (mutation.contains("argumentnames")) {
137+
std::vector<std::string> argNames;
138+
auto argNamesJson = json::parse(mutation["argumentnames"].get<std::string>());
139+
for (auto arg : argNamesJson)
140+
argNames.push_back(arg.get<std::string>());
141+
prototype->setArgumentNames(argNames);
142+
}
143+
if (mutation.contains("warp"))
144+
prototype->setWarp(jsonToValue(mutation["warp"]).toBool());
145+
}
146+
121147
// shadow
122148
block->setShadow(blockInfo["shadow"]);
123149

0 commit comments

Comments
 (0)