mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-09 14:13:43 +00:00
lottie/slot: Support overriding plural sids
Previously, slot overriding only works in single sid, the others are ignored. This patch enables slot overriding for all sids within a single slot.
This commit is contained in:
parent
946d934827
commit
7f2cd1090c
3 changed files with 19 additions and 16 deletions
|
@ -305,21 +305,22 @@ bool LottieLoader::override(const char* slot)
|
|||
|
||||
//parsing slot json
|
||||
LottieParser parser(temp, dirName);
|
||||
auto sid = parser.sid();
|
||||
if (!sid) {
|
||||
free(temp);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret = false;
|
||||
auto idx = 0;
|
||||
auto success = true;
|
||||
while (auto sid = parser.sid(idx == 0)) {
|
||||
for (auto s = comp->slots.begin(); s < comp->slots.end(); ++s) {
|
||||
if (strcmp((*s)->sid, sid)) continue;
|
||||
ret = parser.parse(*s);
|
||||
if (!parser.parse(*s)) success = false;
|
||||
break;
|
||||
}
|
||||
++idx;
|
||||
}
|
||||
|
||||
if (idx < 1) success = false;
|
||||
|
||||
free(temp);
|
||||
return ret;
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1238,11 +1238,13 @@ void LottieParser::postProcess(Array<LottieGlyph*>& glyphes)
|
|||
/* External Class Implementation */
|
||||
/************************************************************************/
|
||||
|
||||
const char* LottieParser::sid()
|
||||
const char* LottieParser::sid(bool first)
|
||||
{
|
||||
if (first) {
|
||||
//verify json
|
||||
if (!parseNext()) return nullptr;
|
||||
enterObject();
|
||||
}
|
||||
return nextObjectKey();
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
|
||||
bool parse();
|
||||
bool parse(LottieSlot* slot);
|
||||
const char* sid();
|
||||
const char* sid(bool first = false);
|
||||
|
||||
LottieComposition* comp = nullptr;
|
||||
const char* dirName = nullptr; //base resource directory
|
||||
|
|
Loading…
Add table
Reference in a new issue