Strip leading digits from new map names

This commit is contained in:
GriffinR 2020-12-05 17:39:02 -05:00 committed by huderlem
parent b854e5e597
commit 8261ad5bea

View file

@ -185,7 +185,9 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
MapLayout *layout; MapLayout *layout;
// If map name is not unique, use default value. Also use only valid characters. // If map name is not unique, use default value. Also use only valid characters.
// After stripping invalid characters, strip any leading digits.
QString newMapName = this->ui->lineEdit_NewMap_Name->text().remove(QRegularExpression("[^a-zA-Z0-9_]+")); QString newMapName = this->ui->lineEdit_NewMap_Name->text().remove(QRegularExpression("[^a-zA-Z0-9_]+"));
newMapName = newMapName.remove(QRegularExpression("^[0-9]*"));
if (project->mapNames->contains(newMapName) || newMapName.isEmpty()) { if (project->mapNames->contains(newMapName) || newMapName.isEmpty()) {
newMapName = project->getNewMapName(); newMapName = project->getNewMapName();
} }