mirror of
https://github.com/huderlem/porymap.git
synced 2026-04-24 23:07:52 -05:00
Add setting for default map size
This commit is contained in:
parent
900ff0afd9
commit
c630581453
|
|
@ -369,7 +369,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>559</width>
|
||||
<height>560</height>
|
||||
<height>622</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_16">
|
||||
|
|
@ -379,37 +379,6 @@
|
|||
<string>Map Data Defaults</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="1" colspan="3">
|
||||
<widget class="QWidget" name="widget_CustomSizeBorderMetatiles" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="NoScrollSpinBox" name="spinBox_FillMetatile">
|
||||
<property name="toolTip">
|
||||
<string>The default metatile value that will be used to fill new maps</string>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string>0x</string>
|
||||
</property>
|
||||
<property name="displayIntegerBase">
|
||||
<number>16</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_Elevation">
|
||||
<property name="text">
|
||||
|
|
@ -417,6 +386,44 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_MapWidth">
|
||||
<property name="text">
|
||||
<string>Width</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="NoScrollSpinBox" name="spinBox_Elevation">
|
||||
<property name="toolTip">
|
||||
<string>The default elevation that will be used to fill new maps</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkBox_CreateTextFile">
|
||||
<property name="toolTip">
|
||||
<string>Whether a separate text.inc or text.pory file will be created for new maps, alongside the scripts file</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Create separate text file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="NoScrollSpinBox" name="spinBox_MapWidth">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="NoScrollSpinBox" name="spinBox_MapHeight">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_FillMetatile">
|
||||
<property name="text">
|
||||
|
|
@ -424,13 +431,10 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkBox_CreateTextFile">
|
||||
<property name="toolTip">
|
||||
<string>Whether a separate text.inc or text.pory file will be created for new maps, alongside the scripts file</string>
|
||||
</property>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_Collision">
|
||||
<property name="text">
|
||||
<string>Create separate text file</string>
|
||||
<string>Collision</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -441,6 +445,20 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="UIntHexSpinBox" name="spinBox_FillMetatile">
|
||||
<property name="toolTip">
|
||||
<string>The default metatile value that will be used to fill new maps</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="NoScrollSpinBox" name="spinBox_Collision">
|
||||
<property name="toolTip">
|
||||
<string>The default collision that will be used to fill new maps</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="3">
|
||||
<widget class="QStackedWidget" name="stackedWidget_BorderMetatiles">
|
||||
<widget class="QWidget" name="page_CustomBorderSize">
|
||||
|
|
@ -481,79 +499,59 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="NoScrollSpinBox" name="spinBox_BorderMetatile1">
|
||||
<widget class="UIntHexSpinBox" name="spinBox_BorderMetatile1">
|
||||
<property name="toolTip">
|
||||
<string>The default metatile value that will be used for the top-left border metatile on new maps.</string>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string>0x</string>
|
||||
</property>
|
||||
<property name="displayIntegerBase">
|
||||
<number>16</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="NoScrollSpinBox" name="spinBox_BorderMetatile2">
|
||||
<widget class="UIntHexSpinBox" name="spinBox_BorderMetatile2">
|
||||
<property name="toolTip">
|
||||
<string>The default metatile value that will be used for the top-right border metatile on new maps.</string>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string>0x</string>
|
||||
</property>
|
||||
<property name="displayIntegerBase">
|
||||
<number>16</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="NoScrollSpinBox" name="spinBox_BorderMetatile3">
|
||||
<widget class="UIntHexSpinBox" name="spinBox_BorderMetatile3">
|
||||
<property name="toolTip">
|
||||
<string>The default metatile value that will be used for the bottom-left border metatile on new maps.</string>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string>0x</string>
|
||||
</property>
|
||||
<property name="displayIntegerBase">
|
||||
<number>16</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="NoScrollSpinBox" name="spinBox_BorderMetatile4">
|
||||
<widget class="UIntHexSpinBox" name="spinBox_BorderMetatile4">
|
||||
<property name="toolTip">
|
||||
<string>The default metatile value that will be used for the bottom-right border metatile on new maps.</string>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string>0x</string>
|
||||
</property>
|
||||
<property name="displayIntegerBase">
|
||||
<number>16</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="NoScrollSpinBox" name="spinBox_Elevation">
|
||||
<property name="toolTip">
|
||||
<string>The default elevation that will be used to fill new maps</string>
|
||||
</property>
|
||||
<item row="1" column="1" colspan="3">
|
||||
<widget class="QWidget" name="widget_CustomSizeBorderMetatiles" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_Collision">
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_MapHeight">
|
||||
<property name="text">
|
||||
<string>Collision</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="NoScrollSpinBox" name="spinBox_Collision">
|
||||
<property name="toolTip">
|
||||
<string>The default collision that will be used to fill new maps</string>
|
||||
<string>Height</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -1084,7 +1082,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>559</width>
|
||||
<height>788</height>
|
||||
<height>840</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
|
|
|
|||
|
|
@ -319,6 +319,7 @@ public:
|
|||
this->defaultMetatileId = 1;
|
||||
this->defaultElevation = 3;
|
||||
this->defaultCollision = 0;
|
||||
this->defaultMapSize = QSize(20,20);
|
||||
this->defaultPrimaryTileset = "gTileset_General";
|
||||
this->prefabFilepath = QString();
|
||||
this->prefabImportPrompted = false;
|
||||
|
|
@ -383,6 +384,7 @@ public:
|
|||
uint16_t defaultMetatileId;
|
||||
uint16_t defaultElevation;
|
||||
uint16_t defaultCollision;
|
||||
QSize defaultMapSize;
|
||||
QList<uint16_t> newMapBorderMetatileIds;
|
||||
QString defaultPrimaryTileset;
|
||||
QString defaultSecondaryTileset;
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ public:
|
|||
int getMaxMapHeight() const;
|
||||
bool mapDimensionsValid(int width, int height) const;
|
||||
bool calculateDefaultMapSize();
|
||||
int getDefaultMapDimension() const { return this->defaultMapDimension; }
|
||||
QSize getDefaultMapSize() const { return this->defaultMapSize; }
|
||||
QSize getMapSizeAddition() const { return this->mapSizeAddition; }
|
||||
|
||||
int getMaxEvents(Event::Group group) const;
|
||||
|
|
@ -306,9 +306,9 @@ private:
|
|||
QString findSpeciesIconPath(const QStringList &names) const;
|
||||
|
||||
int maxObjectEvents;
|
||||
QSize mapSizeAddition;
|
||||
int maxMapDataSize;
|
||||
int defaultMapDimension;
|
||||
QSize defaultMapSize;
|
||||
QSize mapSizeAddition;
|
||||
|
||||
// TODO: These really shouldn't be static, they're specific to a single project.
|
||||
// We're making an assumption here that we only have one project open at a single time
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ int KeyValueConfigBase::getConfigInteger(QString key, QString value, int min, in
|
|||
int result = value.toInt(&ok, 0);
|
||||
if (!ok) {
|
||||
logWarn(QString("Invalid config value for %1: '%2'. Must be an integer.").arg(key).arg(value));
|
||||
return defaultValue;
|
||||
result = defaultValue;
|
||||
}
|
||||
return qMin(max, qMax(min, result));
|
||||
}
|
||||
|
|
@ -275,7 +275,7 @@ uint32_t KeyValueConfigBase::getConfigUint32(QString key, QString value, uint32_
|
|||
uint32_t result = value.toUInt(&ok, 0);
|
||||
if (!ok) {
|
||||
logWarn(QString("Invalid config value for %1: '%2'. Must be an integer.").arg(key).arg(value));
|
||||
return defaultValue;
|
||||
result = defaultValue;
|
||||
}
|
||||
return qMin(max, qMax(min, result));
|
||||
}
|
||||
|
|
@ -739,6 +739,10 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
|
|||
this->defaultElevation = getConfigUint32(key, value, 0, Block::maxValue);
|
||||
} else if (key == "default_collision") {
|
||||
this->defaultCollision = getConfigUint32(key, value, 0, Block::maxValue);
|
||||
} else if (key == "default_map_width") {
|
||||
this->defaultMapSize.setWidth(getConfigInteger(key, value, 1));
|
||||
} else if (key == "default_map_height") {
|
||||
this->defaultMapSize.setHeight(getConfigInteger(key, value, 1));
|
||||
} else if (key == "new_map_border_metatiles") {
|
||||
this->newMapBorderMetatileIds.clear();
|
||||
QList<QString> metatileIds = value.split(",");
|
||||
|
|
@ -890,6 +894,8 @@ QMap<QString, QString> ProjectConfig::getKeyValueMap() {
|
|||
map.insert("default_metatile", Metatile::getMetatileIdString(this->defaultMetatileId));
|
||||
map.insert("default_elevation", QString::number(this->defaultElevation));
|
||||
map.insert("default_collision", QString::number(this->defaultCollision));
|
||||
map.insert("default_map_width", QString::number(this->defaultMapSize.width()));
|
||||
map.insert("default_map_height", QString::number(this->defaultMapSize.height()));
|
||||
map.insert("new_map_border_metatiles", Metatile::getMetatileIdStrings(this->newMapBorderMetatileIds));
|
||||
map.insert("default_primary_tileset", this->defaultPrimaryTileset);
|
||||
map.insert("default_secondary_tileset", this->defaultSecondaryTileset);
|
||||
|
|
|
|||
|
|
@ -1990,8 +1990,8 @@ void Project::initNewMapSettings() {
|
|||
this->newMapSettings.layout.folderName = this->newMapSettings.name;
|
||||
this->newMapSettings.layout.name = QString();
|
||||
this->newMapSettings.layout.id = Layout::layoutConstantFromName(this->newMapSettings.name);
|
||||
this->newMapSettings.layout.width = getDefaultMapDimension();
|
||||
this->newMapSettings.layout.height = getDefaultMapDimension();
|
||||
this->newMapSettings.layout.width = this->defaultMapSize.width();
|
||||
this->newMapSettings.layout.height = this->defaultMapSize.height();
|
||||
this->newMapSettings.layout.borderWidth = DEFAULT_BORDER_WIDTH;
|
||||
this->newMapSettings.layout.borderHeight = DEFAULT_BORDER_HEIGHT;
|
||||
this->newMapSettings.layout.primaryTilesetLabel = getDefaultPrimaryTilesetLabel();
|
||||
|
|
@ -2013,8 +2013,8 @@ void Project::initNewMapSettings() {
|
|||
void Project::initNewLayoutSettings() {
|
||||
this->newLayoutSettings.name = QString();
|
||||
this->newLayoutSettings.id = Layout::layoutConstantFromName(this->newLayoutSettings.name);
|
||||
this->newLayoutSettings.width = getDefaultMapDimension();
|
||||
this->newLayoutSettings.height = getDefaultMapDimension();
|
||||
this->newLayoutSettings.width = this->defaultMapSize.width();
|
||||
this->newLayoutSettings.height = this->defaultMapSize.height();
|
||||
this->newLayoutSettings.borderWidth = DEFAULT_BORDER_WIDTH;
|
||||
this->newLayoutSettings.borderHeight = DEFAULT_BORDER_HEIGHT;
|
||||
this->newLayoutSettings.primaryTilesetLabel = getDefaultPrimaryTilesetLabel();
|
||||
|
|
@ -2154,16 +2154,23 @@ bool Project::readFieldmapProperties() {
|
|||
this->mapSizeAddition = QSize(w, h);
|
||||
|
||||
this->maxMapDataSize = 10240; // Default value of MAX_MAP_DATA_SIZE
|
||||
this->defaultMapDimension = 20; // Arbitrary default of 20x20.
|
||||
this->defaultMapSize = projectConfig.defaultMapSize;
|
||||
auto it = defines.find(maxMapSizeName);
|
||||
if (it != defines.end()) {
|
||||
int min = getMapDataSize(1, 1);
|
||||
if (it.value() >= min) {
|
||||
this->maxMapDataSize = it.value();
|
||||
if (getMapDataSize(this->defaultMapDimension, this->defaultMapDimension) > this->maxMapDataSize) {
|
||||
if (getMapDataSize(this->defaultMapSize.width(), this->defaultMapSize.height()) > this->maxMapDataSize) {
|
||||
// The specified map size is too small to use the default map dimensions.
|
||||
// Calculate the largest square map size that we can use instead.
|
||||
this->defaultMapDimension = qFloor((qSqrt(4 * this->maxMapDataSize + 1) - (w + h)) / 2);
|
||||
int dimension = qFloor((qSqrt(4 * this->maxMapDataSize + 1) - (w + h)) / 2);
|
||||
logWarn(QString("Value for '%1' (%2) is too small to support the default %3x%4 map. Default changed to %5x%5.")
|
||||
.arg(maxMapSizeName)
|
||||
.arg(it.value())
|
||||
.arg(this->defaultMapSize.width())
|
||||
.arg(this->defaultMapSize.height())
|
||||
.arg(dimension));
|
||||
this->defaultMapSize = QSize(dimension, dimension);
|
||||
}
|
||||
} else {
|
||||
logWarn(QString("Value for '%1' (%2) is too small to support a 1x1 map. Must be at least %3. Using default (%4) instead.")
|
||||
|
|
|
|||
|
|
@ -136,6 +136,8 @@ void ProjectSettingsEditor::initUi() {
|
|||
ui->spinBox_UnusedTileCovered->setMaximum(Tile::maxValue);
|
||||
ui->spinBox_UnusedTileSplit->setMaximum(Tile::maxValue);
|
||||
ui->spinBox_MaxEvents->setMaximum(INT_MAX);
|
||||
ui->spinBox_MapWidth->setMaximum(INT_MAX);
|
||||
ui->spinBox_MapHeight->setMaximum(INT_MAX);
|
||||
|
||||
// The values for some of the settings we provide in this window can be determined using constants in the user's projects.
|
||||
// If the user has these constants we disable these settings in the UI -- they can modify them using their constants.
|
||||
|
|
@ -455,6 +457,8 @@ void ProjectSettingsEditor::refresh() {
|
|||
ui->spinBox_Elevation->setValue(projectConfig.defaultElevation);
|
||||
ui->spinBox_Collision->setValue(projectConfig.defaultCollision);
|
||||
ui->spinBox_FillMetatile->setValue(projectConfig.defaultMetatileId);
|
||||
ui->spinBox_MapWidth->setValue(projectConfig.defaultMapSize.width());
|
||||
ui->spinBox_MapHeight->setValue(projectConfig.defaultMapSize.height());
|
||||
ui->spinBox_MaxElevation->setValue(projectConfig.collisionSheetHeight - 1);
|
||||
ui->spinBox_MaxCollision->setValue(projectConfig.collisionSheetWidth - 1);
|
||||
ui->spinBox_BehaviorMask->setValue(projectConfig.metatileBehaviorMask & ui->spinBox_BehaviorMask->maximum());
|
||||
|
|
@ -530,6 +534,7 @@ void ProjectSettingsEditor::save() {
|
|||
projectConfig.defaultElevation = ui->spinBox_Elevation->value();
|
||||
projectConfig.defaultCollision = ui->spinBox_Collision->value();
|
||||
projectConfig.defaultMetatileId = ui->spinBox_FillMetatile->value();
|
||||
projectConfig.defaultMapSize = QSize(ui->spinBox_MapWidth->value(), ui->spinBox_MapHeight->value());
|
||||
projectConfig.collisionSheetHeight = ui->spinBox_MaxElevation->value() + 1;
|
||||
projectConfig.collisionSheetWidth = ui->spinBox_MaxCollision->value() + 1;
|
||||
projectConfig.metatileBehaviorMask = ui->spinBox_BehaviorMask->value();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user