Better support for parsing hex values
This commit is contained in:
parent
d2fa68ba18
commit
c16a6d5d23
4 changed files with 10 additions and 10 deletions
|
@ -136,7 +136,7 @@ void KeyValueConfigBase::save() {
|
||||||
|
|
||||||
bool KeyValueConfigBase::getConfigBool(QString key, QString value) {
|
bool KeyValueConfigBase::getConfigBool(QString key, QString value) {
|
||||||
bool ok;
|
bool ok;
|
||||||
int result = value.toInt(&ok);
|
int result = value.toInt(&ok, 0);
|
||||||
if (!ok || (result != 0 && result != 1)) {
|
if (!ok || (result != 0 && result != 1)) {
|
||||||
logWarn(QString("Invalid config value for %1: '%2'. Must be 0 or 1.").arg(key).arg(value));
|
logWarn(QString("Invalid config value for %1: '%2'. Must be 0 or 1.").arg(key).arg(value));
|
||||||
}
|
}
|
||||||
|
|
|
@ -410,7 +410,7 @@ int ParseUtil::gameStringToInt(QString gameString, bool * ok) {
|
||||||
return 1;
|
return 1;
|
||||||
if (QString::compare(gameString, "FALSE", Qt::CaseInsensitive) == 0)
|
if (QString::compare(gameString, "FALSE", Qt::CaseInsensitive) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
return gameString.toInt(ok);
|
return gameString.toInt(ok, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParseUtil::gameStringToBool(QString gameString, bool * ok) {
|
bool ParseUtil::gameStringToBool(QString gameString, bool * ok) {
|
||||||
|
|
|
@ -2070,8 +2070,8 @@ bool Project::readHealLocations() {
|
||||||
HealLocation healLocation;
|
HealLocation healLocation;
|
||||||
if (match.hasMatch()) {
|
if (match.hasMatch()) {
|
||||||
QString mapName = match.captured("map");
|
QString mapName = match.captured("map");
|
||||||
int x = match.captured("x").toInt();
|
int x = match.captured("x").toInt(nullptr, 0);
|
||||||
int y = match.captured("y").toInt();
|
int y = match.captured("y").toInt(nullptr, 0);
|
||||||
healLocation = HealLocation(idName, mapName, this->healLocations.size() + 1, x, y);
|
healLocation = HealLocation(idName, mapName, this->healLocations.size() + 1, x, y);
|
||||||
} else {
|
} else {
|
||||||
// This heal location has data, but is missing from the location table and won't be displayed by Porymap.
|
// 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));
|
QRegularExpression respawnNPCRegex(QString("%1(?<npc>[0-9]+)").arg(initializerPattern));
|
||||||
match = respawnNPCRegex.match(text);
|
match = respawnNPCRegex.match(text);
|
||||||
if (match.hasMatch())
|
if (match.hasMatch())
|
||||||
healLocation.respawnNPC = match.captured("npc").toInt();
|
healLocation.respawnNPC = match.captured("npc").toInt(nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->healLocations.append(healLocation);
|
this->healLocations.append(healLocation);
|
||||||
|
@ -2474,11 +2474,11 @@ bool Project::readEventGraphics() {
|
||||||
QRegularExpressionMatch dimensionMatch = re.match(dimensions_label);
|
QRegularExpressionMatch dimensionMatch = re.match(dimensions_label);
|
||||||
QRegularExpressionMatch oamTablesMatch = re.match(subsprites_label);
|
QRegularExpressionMatch oamTablesMatch = re.match(subsprites_label);
|
||||||
if (oamTablesMatch.hasMatch()) {
|
if (oamTablesMatch.hasMatch()) {
|
||||||
eventGraphics->spriteWidth = oamTablesMatch.captured(1).toInt();
|
eventGraphics->spriteWidth = oamTablesMatch.captured(1).toInt(nullptr, 0);
|
||||||
eventGraphics->spriteHeight = oamTablesMatch.captured(2).toInt();
|
eventGraphics->spriteHeight = oamTablesMatch.captured(2).toInt(nullptr, 0);
|
||||||
} else if (dimensionMatch.hasMatch()) {
|
} else if (dimensionMatch.hasMatch()) {
|
||||||
eventGraphics->spriteWidth = dimensionMatch.captured(1).toInt();
|
eventGraphics->spriteWidth = dimensionMatch.captured(1).toInt(nullptr, 0);
|
||||||
eventGraphics->spriteHeight = dimensionMatch.captured(2).toInt();
|
eventGraphics->spriteHeight = dimensionMatch.captured(2).toInt(nullptr, 0);
|
||||||
} else {
|
} else {
|
||||||
eventGraphics->spriteWidth = eventGraphics->spritesheet.width();
|
eventGraphics->spriteWidth = eventGraphics->spritesheet.width();
|
||||||
eventGraphics->spriteHeight = eventGraphics->spritesheet.height();
|
eventGraphics->spriteHeight = eventGraphics->spritesheet.height();
|
||||||
|
|
|
@ -512,7 +512,7 @@ void TilesetEditor::on_comboBox_metatileBehaviors_currentTextChanged(const QStri
|
||||||
} else {
|
} else {
|
||||||
// Check if user has entered a number value instead
|
// Check if user has entered a number value instead
|
||||||
bool ok;
|
bool ok;
|
||||||
behavior = metatileBehavior.toInt(&ok);
|
behavior = metatileBehavior.toInt(&ok, 0);
|
||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue