porymap/src/core/maplayout.cpp

35 lines
976 B
C++
Raw Normal View History

#include "maplayout.h"
2019-02-01 17:43:25 +00:00
#include <QRegularExpression>
QString MapLayout::layoutConstantFromName(QString mapName) {
// Transform map names of the form 'GraniteCave_B1F` into layout constants like 'LAYOUT_GRANITE_CAVE_B1F'.
static const QRegularExpression caseChange("([a-z])([A-Z])");
QString nameWithUnderscores = mapName.replace(caseChange, "\\1_\\2");
2019-02-01 17:43:25 +00:00
QString withMapAndUppercase = "LAYOUT_" + nameWithUnderscores.toUpper();
static const QRegularExpression underscores("_+");
QString constantName = withMapAndUppercase.replace(underscores, "_");
2019-02-01 17:43:25 +00:00
// Handle special cases.
// SSTidal should be SS_TIDAL, rather than SSTIDAL
constantName = constantName.replace("SSTIDAL", "SS_TIDAL");
return constantName;
}
int MapLayout::getWidth() {
2022-10-16 07:49:42 +01:00
return width;
}
int MapLayout::getHeight() {
2022-10-16 07:49:42 +01:00
return height;
}
int MapLayout::getBorderWidth() {
2022-10-16 07:49:42 +01:00
return border_width;
}
int MapLayout::getBorderHeight() {
2022-10-16 07:49:42 +01:00
return border_height;
}