diff --git a/forms/newmappopup.ui b/forms/newmappopup.ui
index b9595ec8..3b759041 100644
--- a/forms/newmappopup.ui
+++ b/forms/newmappopup.ui
@@ -7,7 +7,7 @@
0
0
410
- 508
+ 621
@@ -87,14 +87,14 @@
- -
+
-
Map Height
- -
+
-
<html><head/><body><p>Height (in blocks) of the new map.</p></body></html>
@@ -104,14 +104,14 @@
- -
+
-
Border Width
- -
+
-
<html><head/><body><p>Width (in blocks) of the new map's border.</p></body></html>
@@ -121,14 +121,14 @@
- -
+
-
Border Height
- -
+
-
<html><head/><body><p>Height (in blocks) of the new map's border.</p></body></html>
@@ -138,14 +138,14 @@
- -
+
-
Primary Tileset
- -
+
-
<html><head/><body><p>The primary tileset for the new map.</p></body></html>
@@ -155,14 +155,14 @@
- -
+
-
Secondary Tileset
- -
+
-
<html><head/><body><p>The secondary tileset for the new map.</p></body></html>
@@ -172,14 +172,14 @@
- -
+
-
Type
- -
+
-
<html><head/><body><p>The map type is a general attribute, which is used for many different things. For example. it determines whether biking or running is allowed.</p></body></html>
@@ -189,14 +189,14 @@
- -
+
-
Location
- -
+
-
<html><head/><body><p>The section of the region map which the map is grouped under. This also determines the name of the map that is displayed when the player enters it.</p></body></html>
@@ -206,14 +206,14 @@
- -
+
-
Can Fly To
- -
+
-
<html><head/><body><p>Whether to add a heal location to the new map.</p></body></html>
@@ -223,56 +223,56 @@
- -
+
-
Allow Running
- -
-
-
- Allow Biking
-
-
-
- -
-
-
- Allow Escape Rope
-
-
-
- -
+
-
- -
+
-
+
+
+ Allow Biking
+
+
+
+ -
- -
+
-
+
+
+ Allow Escape Rope
+
+
+
+ -
- -
+
-
Floor Number
- -
+
-
<html><head/><body><p>Floor number to be used for maps with elevators.</p></body></html>
@@ -285,13 +285,60 @@
- -
+
-
Accept
+ -
+
+
+ true
+
+
+ false
+
+
+
+ 0
+ 0
+
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Raised
+
+
+
-
+
+
+ false
+
+
+ !
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+
+
+
diff --git a/include/ui/newmappopup.h b/include/ui/newmappopup.h
index 21a688ed..c573b16e 100644
--- a/include/ui/newmappopup.h
+++ b/include/ui/newmappopup.h
@@ -23,6 +23,7 @@ public:
QString layoutId;
void init(int, int, QString, QString);
void useLayout(QString);
+ void connectSignals();
signals:
void applied();
@@ -31,6 +32,7 @@ private:
Ui::NewMapPopup *ui;
Project *project;
void setDefaultValues(int, QString);
+ bool checkNewMapDimensions();
private slots:
void on_pushButton_NewMap_Accept_clicked();
diff --git a/src/ui/newmappopup.cpp b/src/ui/newmappopup.cpp
index b877eac9..e4369a5b 100644
--- a/src/ui/newmappopup.cpp
+++ b/src/ui/newmappopup.cpp
@@ -38,6 +38,34 @@ void NewMapPopup::init(int type, int group, QString sec, QString layoutId) {
setDefaultValues(group, QString());
break;
}
+ connectSignals();
+}
+
+bool NewMapPopup::checkNewMapDimensions() {
+ int numMetatiles = project->getMapDataSize(ui->spinBox_NewMap_Width->value(), ui->spinBox_NewMap_Height->value());
+ int maxMetatiles = project->getMaxMapDataSize();
+
+ if (numMetatiles > maxMetatiles) {
+ ui->frame_NewMap_Warning->setVisible(true);
+ ui->label_NewMap_WarningMessage->setText("WARNING: The specified map dimensions are too large.");
+ return false;
+ }
+ else {
+ ui->frame_NewMap_Warning->setVisible(false);
+ ui->label_NewMap_WarningMessage->clear();
+ return true;
+ }
+};
+
+void NewMapPopup::connectSignals() {
+ ui->spinBox_NewMap_Width->setMinimum(1);
+ ui->spinBox_NewMap_Height->setMinimum(1);
+ ui->spinBox_NewMap_Width->setMaximum(project->getMaxMapWidth());
+ ui->spinBox_NewMap_Height->setMaximum(project->getMaxMapHeight());
+
+ //ui->icon_NewMap_WarningIcon->setPixmap();
+ connect(ui->spinBox_NewMap_Width, QOverload::of(&QSpinBox::valueChanged), [=](int){checkNewMapDimensions();});
+ connect(ui->spinBox_NewMap_Height, QOverload::of(&QSpinBox::valueChanged), [=](int){checkNewMapDimensions();});
}
void NewMapPopup::useLayout(QString layoutId) {
@@ -138,6 +166,10 @@ void NewMapPopup::on_lineEdit_NewMap_Name_textChanged(const QString &text) {
}
void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
+ if (!checkNewMapDimensions()) {
+ // ignore when map dimensions are invalid
+ return;
+ }
Map *newMap = new Map;
MapLayout *layout;