Add identifier config settings

This commit is contained in:
GriffinR
2023-12-18 02:19:12 -05:00
parent bfb827b736
commit 6d995cee9b
20 changed files with 439 additions and 213 deletions

View File

@@ -29,11 +29,12 @@ void Map::setName(QString mapName) {
constantName = mapConstantFromName(mapName);
}
QString Map::mapConstantFromName(QString mapName) {
QString Map::mapConstantFromName(QString mapName, bool includePrefix) {
// Transform map names of the form 'GraniteCave_B1F` into map constants like 'MAP_GRANITE_CAVE_B1F'.
static const QRegularExpression caseChange("([a-z])([A-Z])");
QString nameWithUnderscores = mapName.replace(caseChange, "\\1_\\2");
QString withMapAndUppercase = "MAP_" + nameWithUnderscores.toUpper();
const QString prefix = includePrefix ? projectConfig.getIdentifier(ProjectIdentifier::define_map_prefix) : "";
QString withMapAndUppercase = prefix + nameWithUnderscores.toUpper();
static const QRegularExpression underscores("_+");
QString constantName = withMapAndUppercase.replace(underscores, "_");