Move default prefab prompt to when the user selects the prefab tab, rather than app startup

This commit is contained in:
Marcus Huderle 2022-10-09 14:36:12 -05:00
parent 2fc4b6b53b
commit fc2f91023f
3 changed files with 5 additions and 3 deletions

View file

@ -23,7 +23,7 @@ public:
void initPrefabUI(MetatileSelector *selector, QWidget *prefabWidget, QLabel *emptyPrefabLabel, Map *map);
void addPrefab(MetatileSelection selection, Map *map, QString name);
void updatePrefabUi(Map *map);
void handlePrefabImport();
void tryImportDefaultPrefabs(Map *map);
private:
MetatileSelector *selector;

View file

@ -1697,6 +1697,7 @@ void MainWindow::on_mapViewTab_tabBarClicked(int index)
editor->setEditingCollision();
} else if (index == 2) {
editor->setEditingMap();
prefab.tryImportDefaultPrefabs(this->editor->map);
}
editor->setCursorRectVisible(false);
}

View file

@ -159,7 +159,6 @@ void Prefab::initPrefabUI(MetatileSelector *selector, QWidget *prefabWidget, QLa
this->selector = selector;
this->prefabWidget = prefabWidget;
this->emptyPrefabLabel = emptyPrefabLabel;
this->handlePrefabImport();
this->loadPrefabs();
this->updatePrefabUi(map);
}
@ -270,7 +269,7 @@ void Prefab::addPrefab(MetatileSelection selection, Map *map, QString name) {
this->updatePrefabUi(map);
}
void Prefab::handlePrefabImport() {
void Prefab::tryImportDefaultPrefabs(Map *map) {
BaseGameVersion version = projectConfig.getBaseGameVersion();
// Ensure we have default prefabs for the project's game version.
if (version != BaseGameVersion::pokeruby && version != BaseGameVersion::pokeemerald && version != BaseGameVersion::pokefirered)
@ -330,6 +329,8 @@ void Prefab::handlePrefabImport() {
prefabsFile.write(content.toUtf8());
prefabsFile.close();
this->loadPrefabs();
this->updatePrefabUi(map);
}
projectConfig.setPrefabImportPrompted(true);