forked from Mirrorlandia_minetest/minetest
Simplify how parseElement splits element string (#9726)
This commit is contained in:
parent
cee3c5e73d
commit
6cc5c7cbb4
@ -2668,24 +2668,12 @@ void GUIFormSpecMenu::parseElement(parserData* data, const std::string &element)
|
|||||||
if (parseVersionDirect(element))
|
if (parseVersionDirect(element))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::vector<std::string> parts = split(element,'[');
|
size_t pos = element.find('[');
|
||||||
|
if (pos == std::string::npos)
|
||||||
// ugly workaround to keep compatibility
|
|
||||||
if (parts.size() > 2) {
|
|
||||||
if (trim(parts[0]) == "image") {
|
|
||||||
for (unsigned int i=2;i< parts.size(); i++) {
|
|
||||||
parts[1] += "[" + parts[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else { return; }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parts.size() < 2) {
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
std::string type = trim(parts[0]);
|
std::string type = trim(element.substr(0, pos));
|
||||||
std::string description = trim(parts[1]);
|
std::string description = element.substr(pos+1);
|
||||||
|
|
||||||
if (type == "container") {
|
if (type == "container") {
|
||||||
parseContainer(data, description);
|
parseContainer(data, description);
|
||||||
|
Loading…
Reference in New Issue
Block a user