Treat tileset lists separately
This commit is contained in:
parent
c9d244bf9b
commit
35da77ca94
5 changed files with 25 additions and 24 deletions
|
@ -108,7 +108,8 @@ public:
|
|||
QMap<QString, Tileset*> tilesetCache;
|
||||
Tileset* loadTileset(QString, Tileset *tileset = nullptr);
|
||||
Tileset* getTileset(QString, bool forceLoad = false);
|
||||
QMap<QString, QStringList> tilesetLabels;
|
||||
QStringList primaryTilesetLabels;
|
||||
QStringList secondaryTilesetLabels;
|
||||
QStringList tilesetLabelsOrdered;
|
||||
|
||||
Blockdata readBlockdata(QString);
|
||||
|
|
|
@ -961,9 +961,9 @@ bool MainWindow::loadProjectCombos() {
|
|||
ui->comboBox_Location->clear();
|
||||
ui->comboBox_Location->addItems(project->mapSectionValueToName.values());
|
||||
ui->comboBox_PrimaryTileset->clear();
|
||||
ui->comboBox_PrimaryTileset->addItems(project->tilesetLabels.value("primary"));
|
||||
ui->comboBox_PrimaryTileset->addItems(project->primaryTilesetLabels);
|
||||
ui->comboBox_SecondaryTileset->clear();
|
||||
ui->comboBox_SecondaryTileset->addItems(project->tilesetLabels.value("secondary"));
|
||||
ui->comboBox_SecondaryTileset->addItems(project->secondaryTilesetLabels);
|
||||
ui->comboBox_Weather->clear();
|
||||
ui->comboBox_Weather->addItems(project->weatherNames);
|
||||
ui->comboBox_BattleScene->clear();
|
||||
|
@ -1266,8 +1266,7 @@ void MainWindow::on_actionNew_Tileset_triggered() {
|
|||
msgBox.exec();
|
||||
return;
|
||||
}
|
||||
if (editor->project->tilesetLabels.value("primary").contains(createTilesetDialog->fullSymbolName)
|
||||
|| editor->project->tilesetLabels.value("secondary").contains(createTilesetDialog->fullSymbolName)) {
|
||||
if (editor->project->tilesetLabelsOrdered.contains(createTilesetDialog->fullSymbolName)) {
|
||||
logError(QString("Could not create tileset \"%1\", the symbol \"%2\" already exists.").arg(createTilesetDialog->friendlyName, createTilesetDialog->fullSymbolName));
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setText("Failed to add new tileset.");
|
||||
|
@ -2547,7 +2546,7 @@ void MainWindow::on_comboBox_EmergeMap_currentTextChanged(const QString &mapName
|
|||
|
||||
void MainWindow::on_comboBox_PrimaryTileset_currentTextChanged(const QString &tilesetLabel)
|
||||
{
|
||||
if (editor->project->tilesetLabels["primary"].contains(tilesetLabel) && editor->map) {
|
||||
if (editor->project->primaryTilesetLabels.contains(tilesetLabel) && editor->map) {
|
||||
editor->updatePrimaryTileset(tilesetLabel);
|
||||
redrawMapScene();
|
||||
on_horizontalSlider_MetatileZoom_valueChanged(ui->horizontalSlider_MetatileZoom->value());
|
||||
|
@ -2559,7 +2558,7 @@ void MainWindow::on_comboBox_PrimaryTileset_currentTextChanged(const QString &ti
|
|||
|
||||
void MainWindow::on_comboBox_SecondaryTileset_currentTextChanged(const QString &tilesetLabel)
|
||||
{
|
||||
if (editor->project->tilesetLabels["secondary"].contains(tilesetLabel) && editor->map) {
|
||||
if (editor->project->secondaryTilesetLabels.contains(tilesetLabel) && editor->map) {
|
||||
editor->updateSecondaryTileset(tilesetLabel);
|
||||
redrawMapScene();
|
||||
on_horizontalSlider_MetatileZoom_valueChanged(ui->horizontalSlider_MetatileZoom->value());
|
||||
|
|
|
@ -601,8 +601,8 @@ void Project::setNewMapLayout(Map* map) {
|
|||
layout->border_height = DEFAULT_BORDER_HEIGHT;
|
||||
layout->border_path = QString("%2%1/border.bin").arg(map->name).arg(projectConfig.getFilePath(ProjectFilePath::data_layouts_folders));
|
||||
layout->blockdata_path = QString("%2%1/map.bin").arg(map->name).arg(projectConfig.getFilePath(ProjectFilePath::data_layouts_folders));
|
||||
layout->tileset_primary_label = tilesetLabels["primary"].value(0, "gTileset_General");
|
||||
layout->tileset_secondary_label = tilesetLabels["secondary"].value(0, projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered ? "gTileset_PalletTown" : "gTileset_Petalburg");
|
||||
layout->tileset_primary_label = this->primaryTilesetLabels.value(0, "gTileset_General");
|
||||
layout->tileset_secondary_label = this->secondaryTilesetLabels.value(0, projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered ? "gTileset_PalletTown" : "gTileset_Petalburg");
|
||||
map->layout = layout;
|
||||
map->layoutId = layout->id;
|
||||
|
||||
|
@ -1046,7 +1046,7 @@ void Project::saveTilesetPalettes(Tileset *tileset) {
|
|||
bool Project::loadLayoutTilesets(MapLayout *layout) {
|
||||
layout->tileset_primary = getTileset(layout->tileset_primary_label);
|
||||
if (!layout->tileset_primary) {
|
||||
QString defaultTileset = tilesetLabels["primary"].value(0, "gTileset_General");
|
||||
QString defaultTileset = primaryTilesetLabels.value(0, "gTileset_General");
|
||||
logWarn(QString("Map layout %1 has invalid primary tileset '%2'. Using default '%3'").arg(layout->id).arg(layout->tileset_primary_label).arg(defaultTileset));
|
||||
layout->tileset_primary_label = defaultTileset;
|
||||
layout->tileset_primary = getTileset(layout->tileset_primary_label);
|
||||
|
@ -1058,7 +1058,7 @@ bool Project::loadLayoutTilesets(MapLayout *layout) {
|
|||
|
||||
layout->tileset_secondary = getTileset(layout->tileset_secondary_label);
|
||||
if (!layout->tileset_secondary) {
|
||||
QString defaultTileset = tilesetLabels["secondary"].value(0, projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered ? "gTileset_PalletTown" : "gTileset_Petalburg");
|
||||
QString defaultTileset = secondaryTilesetLabels.value(0, projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered ? "gTileset_PalletTown" : "gTileset_Petalburg");
|
||||
logWarn(QString("Map layout %1 has invalid secondary tileset '%2'. Using default '%3'").arg(layout->id).arg(layout->tileset_secondary_label).arg(defaultTileset));
|
||||
layout->tileset_secondary_label = defaultTileset;
|
||||
layout->tileset_secondary = getTileset(layout->tileset_secondary_label);
|
||||
|
@ -1851,8 +1851,10 @@ Project::DataQualifiers Project::getDataQualifiers(QString text, QString label)
|
|||
}
|
||||
|
||||
void Project::insertTilesetLabel(QString label, bool isSecondary) {
|
||||
QString category = isSecondary ? "secondary" : "primary";
|
||||
this->tilesetLabels[category].append(label);
|
||||
if (isSecondary)
|
||||
this->primaryTilesetLabels.append(label);
|
||||
else
|
||||
this->secondaryTilesetLabels.append(label);
|
||||
this->tilesetLabelsOrdered.append(label);
|
||||
}
|
||||
|
||||
|
@ -1869,9 +1871,8 @@ void Project::insertTilesetLabel(QString label, QString isSecondaryStr) {
|
|||
bool Project::readTilesetLabels() {
|
||||
QStringList primaryTilesets;
|
||||
QStringList secondaryTilesets;
|
||||
this->tilesetLabels.clear();
|
||||
this->tilesetLabels.insert("primary", primaryTilesets);
|
||||
this->tilesetLabels.insert("secondary", secondaryTilesets);
|
||||
this->primaryTilesetLabels.clear();
|
||||
this->secondaryTilesetLabels.clear();
|
||||
this->tilesetLabelsOrdered.clear();
|
||||
|
||||
QString filename = projectConfig.getFilePath(ProjectFilePath::tilesets_headers);
|
||||
|
@ -1903,11 +1904,11 @@ bool Project::readTilesetLabels() {
|
|||
}
|
||||
|
||||
bool success = true;
|
||||
if (this->tilesetLabels["secondary"].isEmpty()) {
|
||||
if (this->secondaryTilesetLabels.isEmpty()) {
|
||||
logError(QString("Failed to find any secondary tilesets in %1").arg(filename));
|
||||
success = false;
|
||||
}
|
||||
if (this->tilesetLabels["primary"].isEmpty()) {
|
||||
if (this->primaryTilesetLabels.isEmpty()) {
|
||||
logError(QString("Failed to find any primary tilesets in %1").arg(filename));
|
||||
success = false;
|
||||
}
|
||||
|
|
|
@ -226,13 +226,13 @@ QList<QString> ScriptUtility::getTilesetNames() {
|
|||
QList<QString> ScriptUtility::getPrimaryTilesetNames() {
|
||||
if (!window || !window->editor || !window->editor->project)
|
||||
return QList<QString>();
|
||||
return window->editor->project->tilesetLabels["primary"];
|
||||
return window->editor->project->primaryTilesetLabels;
|
||||
}
|
||||
|
||||
QList<QString> ScriptUtility::getSecondaryTilesetNames() {
|
||||
if (!window || !window->editor || !window->editor->project)
|
||||
return QList<QString>();
|
||||
return window->editor->project->tilesetLabels["secondary"];
|
||||
return window->editor->project->secondaryTilesetLabels;
|
||||
}
|
||||
|
||||
QList<QString> ScriptUtility::getMetatileBehaviorNames() {
|
||||
|
|
|
@ -108,8 +108,8 @@ void NewMapPopup::useLayout(QString layoutId) {
|
|||
void NewMapPopup::setDefaultValues(int groupNum, QString mapSec) {
|
||||
ui->lineEdit_NewMap_Name->setText(project->getNewMapName());
|
||||
|
||||
ui->comboBox_NewMap_Primary_Tileset->addItems(project->tilesetLabels.value("primary"));
|
||||
ui->comboBox_NewMap_Secondary_Tileset->addItems(project->tilesetLabels.value("secondary"));
|
||||
ui->comboBox_NewMap_Primary_Tileset->addItems(project->primaryTilesetLabels);
|
||||
ui->comboBox_NewMap_Secondary_Tileset->addItems(project->secondaryTilesetLabels);
|
||||
|
||||
ui->comboBox_NewMap_Group->addItems(project->groupNames);
|
||||
ui->comboBox_NewMap_Group->setCurrentText(project->groupNames.at(groupNum));
|
||||
|
@ -147,8 +147,8 @@ void NewMapPopup::setDefaultValues(int groupNum, QString mapSec) {
|
|||
void NewMapPopup::setDefaultValuesImportMap(MapLayout *mapLayout) {
|
||||
ui->lineEdit_NewMap_Name->setText(project->getNewMapName());
|
||||
|
||||
ui->comboBox_NewMap_Primary_Tileset->addItems(project->tilesetLabels.value("primary"));
|
||||
ui->comboBox_NewMap_Secondary_Tileset->addItems(project->tilesetLabels.value("secondary"));
|
||||
ui->comboBox_NewMap_Primary_Tileset->addItems(project->primaryTilesetLabels);
|
||||
ui->comboBox_NewMap_Secondary_Tileset->addItems(project->secondaryTilesetLabels);
|
||||
|
||||
ui->comboBox_NewMap_Group->addItems(project->groupNames);
|
||||
ui->comboBox_NewMap_Group->setCurrentText(project->groupNames.at(0));
|
||||
|
|
Loading…
Reference in a new issue