fix map dimension checks in new map window
This commit is contained in:
parent
c0ad1216d2
commit
482d3cd8fb
3 changed files with 120 additions and 39 deletions
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>410</width>
|
||||
<height>508</height>
|
||||
<height>621</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -87,14 +87,14 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_NewMap_Height">
|
||||
<property name="text">
|
||||
<string>Map Height</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_NewMap_Height">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Height (in blocks) of the new map.</p></body></html></string>
|
||||
|
@ -104,14 +104,14 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_NewMap_BorderWidth">
|
||||
<property name="text">
|
||||
<string>Border Width</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_NewMap_BorderWidth">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Width (in blocks) of the new map's border.</p></body></html></string>
|
||||
|
@ -121,14 +121,14 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_NewMap_BorderHeight">
|
||||
<property name="text">
|
||||
<string>Border Height</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="6" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_NewMap_BorderHeight">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Height (in blocks) of the new map's border.</p></body></html></string>
|
||||
|
@ -138,14 +138,14 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_NewMap_Primary_Tileset">
|
||||
<property name="text">
|
||||
<string>Primary Tileset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="7" column="1">
|
||||
<widget class="NoScrollComboBox" name="comboBox_NewMap_Primary_Tileset">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The primary tileset for the new map.</p></body></html></string>
|
||||
|
@ -155,14 +155,14 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_NewMap_Secondary_Tileset">
|
||||
<property name="text">
|
||||
<string>Secondary Tileset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="8" column="1">
|
||||
<widget class="NoScrollComboBox" name="comboBox_NewMap_Secondary_Tileset">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The secondary tileset for the new map.</p></body></html></string>
|
||||
|
@ -172,14 +172,14 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_NewMap_Type">
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<item row="9" column="1">
|
||||
<widget class="NoScrollComboBox" name="comboBox_NewMap_Type">
|
||||
<property name="toolTip">
|
||||
<string><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></string>
|
||||
|
@ -189,14 +189,14 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label_NewMap_Location">
|
||||
<property name="text">
|
||||
<string>Location</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<item row="10" column="1">
|
||||
<widget class="NoScrollComboBox" name="comboBox_NewMap_Location">
|
||||
<property name="toolTip">
|
||||
<string><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></string>
|
||||
|
@ -206,14 +206,14 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="label_NewMap_Flyable">
|
||||
<property name="text">
|
||||
<string>Can Fly To</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<item row="11" column="1">
|
||||
<widget class="QCheckBox" name="checkBox_NewMap_Flyable">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Whether to add a heal location to the new map.</p></body></html></string>
|
||||
|
@ -223,56 +223,56 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<item row="12" column="0">
|
||||
<widget class="QLabel" name="label_NewMap_Allow_Running">
|
||||
<property name="text">
|
||||
<string>Allow Running</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<widget class="QLabel" name="label_NewMap_Allow_Biking">
|
||||
<property name="text">
|
||||
<string>Allow Biking</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0">
|
||||
<widget class="QLabel" name="label_NewMap_Allow_Escape_Rope">
|
||||
<property name="text">
|
||||
<string>Allow Escape Rope</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<item row="12" column="1">
|
||||
<widget class="QCheckBox" name="checkBox_NewMap_Allow_Running">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="1">
|
||||
<item row="13" column="0">
|
||||
<widget class="QLabel" name="label_NewMap_Allow_Biking">
|
||||
<property name="text">
|
||||
<string>Allow Biking</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="1">
|
||||
<widget class="QCheckBox" name="checkBox_NewMap_Allow_Biking">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="1">
|
||||
<item row="14" column="0">
|
||||
<widget class="QLabel" name="label_NewMap_Allow_Escape_Rope">
|
||||
<property name="text">
|
||||
<string>Allow Escape Rope</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="1">
|
||||
<widget class="QCheckBox" name="checkBox_NewMap_Allow_Escape_Rope">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="0">
|
||||
<item row="15" column="0">
|
||||
<widget class="QLabel" name="label_NewMap_Floor_Number">
|
||||
<property name="text">
|
||||
<string>Floor Number</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="1">
|
||||
<item row="15" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_NewMap_Floor_Number">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Floor number to be used for maps with elevators.</p></body></html></string>
|
||||
|
@ -285,13 +285,60 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="pushButton_NewMap_Accept">
|
||||
<property name="text">
|
||||
<string>Accept</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QFrame" name="frame_NewMap_Warning">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_NewMap_WarningMessage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
|
@ -300,7 +347,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>410</width>
|
||||
<height>21</height>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<int>::of(&QSpinBox::valueChanged), [=](int){checkNewMapDimensions();});
|
||||
connect(ui->spinBox_NewMap_Height, QOverload<int>::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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue