Add config options to remove unnecessary tileset fields
This commit is contained in:
parent
374da65b7f
commit
487cc8d367
3 changed files with 42 additions and 7 deletions
|
@ -205,12 +205,15 @@ public:
|
|||
this->enableEventCloneObject = false;
|
||||
this->enableFloorNumber = false;
|
||||
this->createMapTextFile = false;
|
||||
this->usePoryScript = false;
|
||||
this->enableTripleLayerMetatiles = false;
|
||||
this->newMapMetatileId = 1;
|
||||
this->newMapElevation = 3;
|
||||
this->newMapBorderMetatileIds = DEFAULT_BORDER_RSE;
|
||||
this->prefabFilepath = QString();
|
||||
this->prefabImportPrompted = false;
|
||||
this->tilesetsHaveCallback = true;
|
||||
this->tilesetsHaveIsCompressed = true;
|
||||
this->filePaths.clear();
|
||||
this->readKeys.clear();
|
||||
}
|
||||
|
@ -255,6 +258,10 @@ public:
|
|||
QString getPrefabFilepath(bool setIfEmpty);
|
||||
void setPrefabImportPrompted(bool prompted);
|
||||
bool getPrefabImportPrompted();
|
||||
void setTilesetsHaveCallback(bool has);
|
||||
bool getTilesetsHaveCallback();
|
||||
void setTilesetsHaveIsCompressed(bool has);
|
||||
bool getTilesetsHaveIsCompressed();
|
||||
protected:
|
||||
virtual QString getConfigFilepath() override;
|
||||
virtual void parseConfigKeyValue(QString key, QString value) override;
|
||||
|
@ -282,6 +289,8 @@ private:
|
|||
QStringList readKeys;
|
||||
QString prefabFilepath;
|
||||
bool prefabImportPrompted;
|
||||
bool tilesetsHaveCallback;
|
||||
bool tilesetsHaveIsCompressed;
|
||||
};
|
||||
|
||||
extern ProjectConfig projectConfig;
|
||||
|
|
|
@ -571,6 +571,10 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
|
|||
this->prefabFilepath = value;
|
||||
} else if (key == "prefabs_import_prompted") {
|
||||
this->prefabImportPrompted = getConfigBool(key, value);
|
||||
} else if (key == "tilesets_have_callback") {
|
||||
this->tilesetsHaveCallback = getConfigBool(key, value);
|
||||
} else if (key == "tilesets_have_is_compressed") {
|
||||
this->tilesetsHaveIsCompressed = getConfigBool(key, value);
|
||||
} else {
|
||||
logWarn(QString("Invalid config key found in config file %1: '%2'").arg(this->getConfigFilepath()).arg(key));
|
||||
}
|
||||
|
@ -617,6 +621,8 @@ QMap<QString, QString> ProjectConfig::getKeyValueMap() {
|
|||
for (auto it = this->filePaths.constKeyValueBegin(); it != this->filePaths.constKeyValueEnd(); ++it) {
|
||||
map.insert("path/"+defaultPaths[(*it).first].first, (*it).second);
|
||||
}
|
||||
map.insert("tilesets_have_callback", QString::number(this->tilesetsHaveCallback));
|
||||
map.insert("tilesets_have_is_compressed", QString::number(this->tilesetsHaveIsCompressed));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
@ -656,10 +662,6 @@ void ProjectConfig::onNewConfigFileCreated() {
|
|||
this->enableEventCloneObject = isPokefirered;
|
||||
this->enableFloorNumber = isPokefirered;
|
||||
this->createMapTextFile = (this->baseGameVersion != BaseGameVersion::pokeemerald);
|
||||
this->usePoryScript = false;
|
||||
this->enableTripleLayerMetatiles = false;
|
||||
this->newMapMetatileId = 1;
|
||||
this->newMapElevation = 3;
|
||||
this->newMapBorderMetatileIds = isPokefirered ? DEFAULT_BORDER_FRLG : DEFAULT_BORDER_RSE;
|
||||
}
|
||||
|
||||
|
@ -854,6 +856,24 @@ bool ProjectConfig::getPrefabImportPrompted() {
|
|||
return this->prefabImportPrompted;
|
||||
}
|
||||
|
||||
void ProjectConfig::setTilesetsHaveCallback(bool has) {
|
||||
this->tilesetsHaveCallback = has;
|
||||
this->save();
|
||||
}
|
||||
|
||||
bool ProjectConfig::getTilesetsHaveCallback() {
|
||||
return this->tilesetsHaveCallback;
|
||||
}
|
||||
|
||||
void ProjectConfig::setTilesetsHaveIsCompressed(bool has) {
|
||||
this->tilesetsHaveIsCompressed = has;
|
||||
this->save();
|
||||
}
|
||||
|
||||
bool ProjectConfig::getTilesetsHaveIsCompressed() {
|
||||
return this->tilesetsHaveIsCompressed;
|
||||
}
|
||||
|
||||
|
||||
UserConfig userConfig;
|
||||
|
||||
|
|
|
@ -136,6 +136,7 @@ bool Tileset::appendToHeaders(QString root, QString friendlyName, bool usingAsm)
|
|||
}
|
||||
QString dataString = "\n";
|
||||
if (usingAsm) {
|
||||
// Append to asm file
|
||||
dataString.append("\t.align 2\n");
|
||||
dataString.append(QString("%1::\n").arg(this->name));
|
||||
dataString.append("\t.byte TRUE @ is compressed\n");
|
||||
|
@ -152,14 +153,15 @@ bool Tileset::appendToHeaders(QString root, QString friendlyName, bool usingAsm)
|
|||
dataString.append("\t.4byte NULL @ animation callback\n");
|
||||
}
|
||||
} else {
|
||||
// Append to C file
|
||||
dataString.append(QString("const struct Tileset %1 =\n{\n").arg(this->name));
|
||||
dataString.append(" .isCompressed = TRUE,\n");
|
||||
if (projectConfig.getTilesetsHaveIsCompressed()) dataString.append(" .isCompressed = TRUE,\n");
|
||||
dataString.append(QString(" .isSecondary = %1,\n").arg(this->is_secondary));
|
||||
dataString.append(QString(" .tiles = gTilesetTiles_%1,\n").arg(friendlyName));
|
||||
dataString.append(QString(" .palettes = gTilesetPalettes_%1,\n").arg(friendlyName));
|
||||
dataString.append(QString(" .metatiles = gMetatiles_%1,\n").arg(friendlyName));
|
||||
dataString.append(QString(" .metatileAttributes = gMetatileAttributes_%1,\n").arg(friendlyName));
|
||||
dataString.append(" .callback = NULL,\n");
|
||||
if (projectConfig.getTilesetsHaveCallback()) dataString.append(" .callback = NULL,\n");
|
||||
dataString.append("};\n");
|
||||
}
|
||||
file.write(dataString.toUtf8());
|
||||
|
@ -183,6 +185,7 @@ bool Tileset::appendToGraphics(QString root, QString friendlyName, bool usingAsm
|
|||
|
||||
QString dataString = "\n";
|
||||
if (usingAsm) {
|
||||
// Append to asm file
|
||||
dataString.append("\t.align 2\n");
|
||||
dataString.append(QString("gTilesetPalettes_%1::\n").arg(friendlyName));
|
||||
for (int i = 0; i < Project::getNumPalettesTotal(); i++)
|
||||
|
@ -191,6 +194,7 @@ bool Tileset::appendToGraphics(QString root, QString friendlyName, bool usingAsm
|
|||
dataString.append(QString("gTilesetTiles_%1::\n").arg(friendlyName));
|
||||
dataString.append(QString("\t.incbin \"%1\"\n").arg(tilesPath));
|
||||
} else {
|
||||
// Append to C file
|
||||
dataString.append(QString("const u16 gTilesetPalettes_%1[][16] =\n{\n").arg(friendlyName));
|
||||
for (int i = 0; i < Project::getNumPalettesTotal(); i++)
|
||||
dataString.append(QString(" INCBIN_U16(\"%1%2.gbapal\"),\n").arg(palettesPath).arg(i, 2, 10, QLatin1Char('0')));
|
||||
|
@ -218,6 +222,7 @@ bool Tileset::appendToMetatiles(QString root, QString friendlyName, bool usingAs
|
|||
|
||||
QString dataString = "\n";
|
||||
if (usingAsm) {
|
||||
// Append to asm file
|
||||
dataString.append("\t.align 1\n");
|
||||
dataString.append(QString("gMetatiles_%1::\n").arg(friendlyName));
|
||||
dataString.append(QString("\t.incbin \"%1\"\n").arg(metatilesPath));
|
||||
|
@ -225,6 +230,7 @@ bool Tileset::appendToMetatiles(QString root, QString friendlyName, bool usingAs
|
|||
dataString.append(QString("gMetatileAttributes_%1::\n").arg(friendlyName));
|
||||
dataString.append(QString("\t.incbin \"%1\"\n").arg(metatileAttrsPath));
|
||||
} else {
|
||||
// Append to C file
|
||||
dataString.append(QString("const u16 gMetatiles_%1[] = INCBIN_U16(\"%2\");\n").arg(friendlyName, metatilesPath));
|
||||
QString attrSize = (projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered) ? "32" : "16";
|
||||
dataString.append(QString("const u%1 gMetatileAttributes_%2[] = INCBIN_U%1(\"%3\");\n").arg(attrSize, friendlyName, metatileAttrsPath));
|
||||
|
@ -236,7 +242,7 @@ bool Tileset::appendToMetatiles(QString root, QString friendlyName, bool usingAs
|
|||
}
|
||||
|
||||
// The path where Porymap expects a Tileset's graphics assets to be stored (but not necessarily where they actually are)
|
||||
// Example: for gTileset_DepartmentStore, returns "data/tilesets/secondary/department_store/"
|
||||
// Example: for gTileset_DepartmentStore, returns "data/tilesets/secondary/department_store"
|
||||
QString Tileset::getExpectedDir()
|
||||
{
|
||||
return Tileset::getExpectedDir(this->name, ParseUtil::gameStringToBool(this->is_secondary));
|
||||
|
|
Loading…
Reference in a new issue