fix save for region map layout new format
This commit is contained in:
parent
614242f1fe
commit
2fa2fc52e8
1 changed files with 23 additions and 8 deletions
|
@ -268,14 +268,14 @@ bool RegionMap::loadLayout(poryjson::Json layoutJson) {
|
||||||
this->layout_array_label = label;
|
this->layout_array_label = label;
|
||||||
|
|
||||||
QRegularExpression rowRe("{(?<row>[A-Z0-9_, ]+)}");
|
QRegularExpression rowRe("{(?<row>[A-Z0-9_, ]+)}");
|
||||||
QRegularExpressionMatchIterator j = rowRe.globalMatch(text);
|
QRegularExpressionMatchIterator k = rowRe.globalMatch(text);
|
||||||
|
|
||||||
this->layout_layers.append("main");
|
this->layout_layers.append("main");
|
||||||
QList<LayoutSquare> layout;
|
QList<LayoutSquare> layout;
|
||||||
|
|
||||||
int y = 0;
|
int y = 0;
|
||||||
while (j.hasNext()) {
|
while (k.hasNext()) {
|
||||||
QRegularExpressionMatch n = j.next();
|
QRegularExpressionMatch n = k.next();
|
||||||
QString row = n.captured("row");
|
QString row = n.captured("row");
|
||||||
QStringList rowSections = row.split(',');
|
QStringList rowSections = row.split(',');
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
@ -357,7 +357,7 @@ poryjson::Json::object RegionMap::config() {
|
||||||
layoutObject["height"] = this->layout_height;
|
layoutObject["height"] = this->layout_height;
|
||||||
layoutObject["offset_left"] = this->offset_left;
|
layoutObject["offset_left"] = this->offset_left;
|
||||||
layoutObject["offset_top"] = this->offset_top;
|
layoutObject["offset_top"] = this->offset_top;
|
||||||
QMap<LayoutFormat, QString> layoutFormatMap = { {LayoutFormat::Binary, "binary"}, {LayoutFormat::CArray, "C array"} };
|
static QMap<LayoutFormat, QString> layoutFormatMap = { {LayoutFormat::Binary, "binary"}, {LayoutFormat::CArray, "C array"} };
|
||||||
layoutObject["format"] = layoutFormatMap[this->layout_format];
|
layoutObject["format"] = layoutFormatMap[this->layout_format];
|
||||||
layoutObject["path"] = this->layout_path;
|
layoutObject["path"] = this->layout_path;
|
||||||
config["layout"] = layoutObject;
|
config["layout"] = layoutObject;
|
||||||
|
@ -405,11 +405,26 @@ void RegionMap::saveLayout() {
|
||||||
}
|
}
|
||||||
text += " = {\n";
|
text += " = {\n";
|
||||||
if (this->layout_layers.size() == 1) {
|
if (this->layout_layers.size() == 1) {
|
||||||
for (LayoutSquare s : this->getLayout("main")) {
|
if (this->layout_constants.count() == 1) {
|
||||||
text += " " + s.map_section + ",\n";
|
for (LayoutSquare s : this->getLayout("main")) {
|
||||||
|
text += " " + s.map_section + ",\n";
|
||||||
|
}
|
||||||
|
text.chop(2);
|
||||||
|
text += "\n";
|
||||||
|
} else if (this->layout_constants.count() == 2) {
|
||||||
|
for (int row = 0; row < this->layout_height; row++) {
|
||||||
|
text += " {";
|
||||||
|
for (int col = 0; col < this->layout_width; col++) {
|
||||||
|
int i = col + row * this->layout_width;
|
||||||
|
text += this->layouts["main"][i].map_section + ", ";
|
||||||
|
}
|
||||||
|
text.chop(2);
|
||||||
|
text += "},-\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logError(QString("Failed to save region map layout for %1").arg(this->layout_array_label));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
text.chop(2);
|
|
||||||
text += "\n";
|
|
||||||
} else {
|
} else {
|
||||||
// multi layered
|
// multi layered
|
||||||
for (auto layoutName : this->layout_layers) {
|
for (auto layoutName : this->layout_layers) {
|
||||||
|
|
Loading…
Reference in a new issue