Better support for parsing hex values

This commit is contained in:
GriffinR 2022-10-28 12:40:36 -04:00
parent d2fa68ba18
commit c16a6d5d23
4 changed files with 10 additions and 10 deletions

View file

@ -136,7 +136,7 @@ void KeyValueConfigBase::save() {
bool KeyValueConfigBase::getConfigBool(QString key, QString value) {
bool ok;
int result = value.toInt(&ok);
int result = value.toInt(&ok, 0);
if (!ok || (result != 0 && result != 1)) {
logWarn(QString("Invalid config value for %1: '%2'. Must be 0 or 1.").arg(key).arg(value));
}

View file

@ -410,7 +410,7 @@ int ParseUtil::gameStringToInt(QString gameString, bool * ok) {
return 1;
if (QString::compare(gameString, "FALSE", Qt::CaseInsensitive) == 0)
return 0;
return gameString.toInt(ok);
return gameString.toInt(ok, 0);
}
bool ParseUtil::gameStringToBool(QString gameString, bool * ok) {

View file

@ -2070,8 +2070,8 @@ bool Project::readHealLocations() {
HealLocation healLocation;
if (match.hasMatch()) {
QString mapName = match.captured("map");
int x = match.captured("x").toInt();
int y = match.captured("y").toInt();
int x = match.captured("x").toInt(nullptr, 0);
int y = match.captured("y").toInt(nullptr, 0);
healLocation = HealLocation(idName, mapName, this->healLocations.size() + 1, x, y);
} else {
// This heal location has data, but is missing from the location table and won't be displayed by Porymap.
@ -2091,7 +2091,7 @@ bool Project::readHealLocations() {
QRegularExpression respawnNPCRegex(QString("%1(?<npc>[0-9]+)").arg(initializerPattern));
match = respawnNPCRegex.match(text);
if (match.hasMatch())
healLocation.respawnNPC = match.captured("npc").toInt();
healLocation.respawnNPC = match.captured("npc").toInt(nullptr, 0);
}
this->healLocations.append(healLocation);
@ -2474,11 +2474,11 @@ bool Project::readEventGraphics() {
QRegularExpressionMatch dimensionMatch = re.match(dimensions_label);
QRegularExpressionMatch oamTablesMatch = re.match(subsprites_label);
if (oamTablesMatch.hasMatch()) {
eventGraphics->spriteWidth = oamTablesMatch.captured(1).toInt();
eventGraphics->spriteHeight = oamTablesMatch.captured(2).toInt();
eventGraphics->spriteWidth = oamTablesMatch.captured(1).toInt(nullptr, 0);
eventGraphics->spriteHeight = oamTablesMatch.captured(2).toInt(nullptr, 0);
} else if (dimensionMatch.hasMatch()) {
eventGraphics->spriteWidth = dimensionMatch.captured(1).toInt();
eventGraphics->spriteHeight = dimensionMatch.captured(2).toInt();
eventGraphics->spriteWidth = dimensionMatch.captured(1).toInt(nullptr, 0);
eventGraphics->spriteHeight = dimensionMatch.captured(2).toInt(nullptr, 0);
} else {
eventGraphics->spriteWidth = eventGraphics->spritesheet.width();
eventGraphics->spriteHeight = eventGraphics->spritesheet.height();

View file

@ -512,7 +512,7 @@ void TilesetEditor::on_comboBox_metatileBehaviors_currentTextChanged(const QStri
} else {
// Check if user has entered a number value instead
bool ok;
behavior = metatileBehavior.toInt(&ok);
behavior = metatileBehavior.toInt(&ok, 0);
if (!ok) return;
}