Merge pull request #588 from GriffinRichards/preserve-settings
Stop changing settings if their features fail to load
This commit is contained in:
commit
d74affe0b9
8 changed files with 119 additions and 144 deletions
|
@ -7,9 +7,14 @@ and this project somewhat adheres to [Semantic Versioning](https://semver.org/sp
|
||||||
The **"Breaking Changes"** listed below are changes that have been made in the decompilation projects (e.g. pokeemerald), which porymap requires in order to work properly. It also includes changes to the scripting API that may change the behavior of existing porymap scripts. If porymap is used with a project or API script that is not up-to-date with the breaking changes, then porymap will likely break or behave improperly.
|
The **"Breaking Changes"** listed below are changes that have been made in the decompilation projects (e.g. pokeemerald), which porymap requires in order to work properly. It also includes changes to the scripting API that may change the behavior of existing porymap scripts. If porymap is used with a project or API script that is not up-to-date with the breaking changes, then porymap will likely break or behave improperly.
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
### Changed
|
||||||
|
- If Wild Encounters fail to load they are now only disabled for that session, and the settings remain unchanged.
|
||||||
|
- Defaults are used if project constants are missing, rather than failing to open the project or changing settings.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fix the Tileset Editor selectors scrolling to the wrong selection when zoomed
|
- Fix the Tileset Editor selectors scrolling to the wrong selection when zoomed.
|
||||||
- Fix the Tileset Editor selectors getting extra white space when changing tilesets
|
- Fix the Tileset Editor selectors getting extra white space when changing tilesets.
|
||||||
|
- Fix a crash when adding disabled events with the Pencil tool.
|
||||||
|
|
||||||
## [5.3.0] - 2024-01-15
|
## [5.3.0] - 2024-01-15
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -373,7 +373,6 @@ private:
|
||||||
void initShortcuts();
|
void initShortcuts();
|
||||||
void initExtraShortcuts();
|
void initExtraShortcuts();
|
||||||
void setProjectSpecificUI();
|
void setProjectSpecificUI();
|
||||||
void setWildEncountersUIEnabled(bool enabled);
|
|
||||||
void loadUserSettings();
|
void loadUserSettings();
|
||||||
void applyMapListFilter(QString filterText);
|
void applyMapListFilter(QString filterText);
|
||||||
void restoreWindowState();
|
void restoreWindowState();
|
||||||
|
|
|
@ -54,6 +54,7 @@ public:
|
||||||
QMap<int, QString> mapSectionValueToName;
|
QMap<int, QString> mapSectionValueToName;
|
||||||
QMap<QString, EventGraphics*> eventGraphicsMap;
|
QMap<QString, EventGraphics*> eventGraphicsMap;
|
||||||
QMap<QString, int> gfxDefines;
|
QMap<QString, int> gfxDefines;
|
||||||
|
QString defaultSong;
|
||||||
QStringList songNames;
|
QStringList songNames;
|
||||||
QStringList itemNames;
|
QStringList itemNames;
|
||||||
QStringList flagNames;
|
QStringList flagNames;
|
||||||
|
@ -78,6 +79,7 @@ public:
|
||||||
bool usingAsmTilesets;
|
bool usingAsmTilesets;
|
||||||
QString importExportPath;
|
QString importExportPath;
|
||||||
QSet<QString> disabledSettingsNames;
|
QSet<QString> disabledSettingsNames;
|
||||||
|
bool wildEncountersLoaded;
|
||||||
|
|
||||||
void set_root(QString);
|
void set_root(QString);
|
||||||
|
|
||||||
|
@ -162,8 +164,6 @@ public:
|
||||||
void saveTilesetMetatiles(Tileset*);
|
void saveTilesetMetatiles(Tileset*);
|
||||||
void saveTilesetTilesImage(Tileset*);
|
void saveTilesetTilesImage(Tileset*);
|
||||||
void saveTilesetPalettes(Tileset*);
|
void saveTilesetPalettes(Tileset*);
|
||||||
|
|
||||||
QString defaultSong;
|
|
||||||
void appendTilesetLabel(QString label, QString isSecondaryStr);
|
void appendTilesetLabel(QString label, QString isSecondaryStr);
|
||||||
bool readTilesetLabels();
|
bool readTilesetLabels();
|
||||||
bool readTilesetMetatileLabels();
|
bool readTilesetMetatileLabels();
|
||||||
|
@ -253,7 +253,6 @@ signals:
|
||||||
void reloadProject();
|
void reloadProject();
|
||||||
void uncheckMonitorFilesAction();
|
void uncheckMonitorFilesAction();
|
||||||
void mapCacheCleared();
|
void mapCacheCleared();
|
||||||
void disableWildEncountersUI();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROJECT_H
|
#endif // PROJECT_H
|
||||||
|
|
|
@ -233,8 +233,8 @@ bool ObjectEvent::loadFromJson(QJsonObject json, Project *) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectEvent::setDefaultValues(Project *project) {
|
void ObjectEvent::setDefaultValues(Project *project) {
|
||||||
this->setGfx(project->gfxDefines.keys().first());
|
this->setGfx(project->gfxDefines.keys().value(0, "0"));
|
||||||
this->setMovement(project->movementTypes.first());
|
this->setMovement(project->movementTypes.value(0, "0"));
|
||||||
this->setScript("NULL");
|
this->setScript("NULL");
|
||||||
this->setTrainerType(project->trainerTypes.value(0, "0"));
|
this->setTrainerType(project->trainerTypes.value(0, "0"));
|
||||||
this->setFlag("0");
|
this->setFlag("0");
|
||||||
|
@ -404,7 +404,7 @@ bool CloneObjectEvent::loadFromJson(QJsonObject json, Project *project) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloneObjectEvent::setDefaultValues(Project *project) {
|
void CloneObjectEvent::setDefaultValues(Project *project) {
|
||||||
this->setGfx(project->gfxDefines.keys().first());
|
this->setGfx(project->gfxDefines.keys().value(0, "0"));
|
||||||
this->setTargetID(1);
|
this->setTargetID(1);
|
||||||
if (this->getMap()) this->setTargetMap(this->getMap()->name);
|
if (this->getMap()) this->setTargetMap(this->getMap()->name);
|
||||||
}
|
}
|
||||||
|
@ -436,8 +436,8 @@ void CloneObjectEvent::loadPixmap(Project *project) {
|
||||||
this->movement = clonedObject->getMovement();
|
this->movement = clonedObject->getMovement();
|
||||||
} else {
|
} else {
|
||||||
// Invalid object specified, use default graphics data (as would be shown in-game)
|
// Invalid object specified, use default graphics data (as would be shown in-game)
|
||||||
this->gfx = project->gfxDefines.key(0);
|
this->gfx = project->gfxDefines.key(0, "0");
|
||||||
this->movement = project->movementTypes.first();
|
this->movement = project->movementTypes.value(0, "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
EventGraphics *eventGfx = project->eventGraphicsMap.value(gfx, nullptr);
|
EventGraphics *eventGfx = project->eventGraphicsMap.value(gfx, nullptr);
|
||||||
|
@ -596,7 +596,7 @@ bool TriggerEvent::loadFromJson(QJsonObject json, Project *) {
|
||||||
|
|
||||||
void TriggerEvent::setDefaultValues(Project *project) {
|
void TriggerEvent::setDefaultValues(Project *project) {
|
||||||
this->setScriptLabel("NULL");
|
this->setScriptLabel("NULL");
|
||||||
this->setScriptVar(project->varNames.first());
|
this->setScriptVar(project->varNames.value(0, "0"));
|
||||||
this->setScriptVarValue("0");
|
this->setScriptVarValue("0");
|
||||||
this->setElevation(0);
|
this->setElevation(0);
|
||||||
}
|
}
|
||||||
|
@ -665,7 +665,7 @@ bool WeatherTriggerEvent::loadFromJson(QJsonObject json, Project *) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WeatherTriggerEvent::setDefaultValues(Project *project) {
|
void WeatherTriggerEvent::setDefaultValues(Project *project) {
|
||||||
this->setWeather(project->coordEventWeatherNames.first());
|
this->setWeather(project->coordEventWeatherNames.value(0, "0"));
|
||||||
this->setElevation(0);
|
this->setElevation(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,7 +734,7 @@ bool SignEvent::loadFromJson(QJsonObject json, Project *) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SignEvent::setDefaultValues(Project *project) {
|
void SignEvent::setDefaultValues(Project *project) {
|
||||||
this->setFacingDirection(project->bgEventFacingDirections.first());
|
this->setFacingDirection(project->bgEventFacingDirections.value(0, "0"));
|
||||||
this->setScriptLabel("NULL");
|
this->setScriptLabel("NULL");
|
||||||
this->setElevation(0);
|
this->setElevation(0);
|
||||||
}
|
}
|
||||||
|
@ -819,8 +819,8 @@ bool HiddenItemEvent::loadFromJson(QJsonObject json, Project *) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HiddenItemEvent::setDefaultValues(Project *project) {
|
void HiddenItemEvent::setDefaultValues(Project *project) {
|
||||||
this->setItem(project->itemNames.first());
|
this->setItem(project->itemNames.value(0, "0"));
|
||||||
this->setFlag(project->flagNames.first());
|
this->setFlag(project->flagNames.value(0, "0"));
|
||||||
if (projectConfig.getHiddenItemQuantityEnabled()) {
|
if (projectConfig.getHiddenItemQuantityEnabled()) {
|
||||||
this->setQuantity(1);
|
this->setQuantity(1);
|
||||||
}
|
}
|
||||||
|
@ -898,7 +898,7 @@ bool SecretBaseEvent::loadFromJson(QJsonObject json, Project *) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SecretBaseEvent::setDefaultValues(Project *project) {
|
void SecretBaseEvent::setDefaultValues(Project *project) {
|
||||||
this->setBaseID(project->secretBaseIds.first());
|
this->setBaseID(project->secretBaseIds.value(0, "0"));
|
||||||
this->setElevation(0);
|
this->setElevation(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -361,14 +361,12 @@ void MainWindow::markMapEdited() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setWildEncountersUIEnabled(bool enabled) {
|
|
||||||
ui->mainTabBar->setTabEnabled(4, enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the UI using information we've read from the user's project files.
|
// Update the UI using information we've read from the user's project files.
|
||||||
void MainWindow::setProjectSpecificUI()
|
void MainWindow::setProjectSpecificUI()
|
||||||
{
|
{
|
||||||
this->setWildEncountersUIEnabled(userConfig.getEncounterJsonActive());
|
// Wild Encounters tab
|
||||||
|
// TODO: This index should come from an enum
|
||||||
|
ui->mainTabBar->setTabEnabled(4, editor->project->wildEncountersLoaded);
|
||||||
|
|
||||||
bool hasFlags = projectConfig.getMapAllowFlagsEnabled();
|
bool hasFlags = projectConfig.getMapAllowFlagsEnabled();
|
||||||
ui->checkBox_AllowRunning->setVisible(hasFlags);
|
ui->checkBox_AllowRunning->setVisible(hasFlags);
|
||||||
|
@ -500,7 +498,10 @@ bool MainWindow::openProject(const QString &dir, bool initial) {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this->statusBar()->showMessage(QString("Opening %1").arg(projectString));
|
|
||||||
|
const QString openMessage = QString("Opening %1").arg(projectString);
|
||||||
|
this->statusBar()->showMessage(openMessage);
|
||||||
|
logInfo(openMessage);
|
||||||
|
|
||||||
userConfig.setProjectDir(dir);
|
userConfig.setProjectDir(dir);
|
||||||
userConfig.load();
|
userConfig.load();
|
||||||
|
@ -520,7 +521,6 @@ bool MainWindow::openProject(const QString &dir, bool initial) {
|
||||||
editor->project = new Project(this);
|
editor->project = new Project(this);
|
||||||
QObject::connect(editor->project, &Project::reloadProject, this, &MainWindow::on_action_Reload_Project_triggered);
|
QObject::connect(editor->project, &Project::reloadProject, this, &MainWindow::on_action_Reload_Project_triggered);
|
||||||
QObject::connect(editor->project, &Project::mapCacheCleared, this, &MainWindow::onMapCacheCleared);
|
QObject::connect(editor->project, &Project::mapCacheCleared, this, &MainWindow::onMapCacheCleared);
|
||||||
QObject::connect(editor->project, &Project::disableWildEncountersUI, [this]() { this->setWildEncountersUIEnabled(false); });
|
|
||||||
QObject::connect(editor->project, &Project::uncheckMonitorFilesAction, [this]() {
|
QObject::connect(editor->project, &Project::uncheckMonitorFilesAction, [this]() {
|
||||||
porymapConfig.setMonitorFiles(false);
|
porymapConfig.setMonitorFiles(false);
|
||||||
if (this->preferenceEditor)
|
if (this->preferenceEditor)
|
||||||
|
@ -544,10 +544,7 @@ bool MainWindow::openProject(const QString &dir, bool initial) {
|
||||||
}
|
}
|
||||||
|
|
||||||
showWindowTitle();
|
showWindowTitle();
|
||||||
|
this->statusBar()->showMessage(QString("Opened %1").arg(projectString));
|
||||||
const QString successMessage = QString("Opened %1").arg(projectString);
|
|
||||||
this->statusBar()->showMessage(successMessage);
|
|
||||||
logInfo(successMessage);
|
|
||||||
|
|
||||||
porymapConfig.addRecentProject(dir);
|
porymapConfig.addRecentProject(dir);
|
||||||
refreshRecentProjectsMenu();
|
refreshRecentProjectsMenu();
|
||||||
|
@ -575,29 +572,22 @@ bool MainWindow::isProjectOpen() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::setInitialMap() {
|
bool MainWindow::setInitialMap() {
|
||||||
QList<QStringList> names;
|
QStringList names;
|
||||||
if (editor && editor->project)
|
if (editor && editor->project)
|
||||||
names = editor->project->groupedMapNames;
|
names = editor->project->mapNames;
|
||||||
|
|
||||||
|
// Try to set most recently-opened map, if it's still in the list.
|
||||||
QString recentMap = userConfig.getRecentMap();
|
QString recentMap = userConfig.getRecentMap();
|
||||||
if (!recentMap.isEmpty()) {
|
if (!recentMap.isEmpty() && names.contains(recentMap) && setMap(recentMap, true))
|
||||||
// Make sure the recent map is still in the map list
|
return true;
|
||||||
for (int i = 0; i < names.length(); i++) {
|
|
||||||
if (names.value(i).contains(recentMap)) {
|
// Failing that, try loading maps in the map list sequentially.
|
||||||
return setMap(recentMap, true);
|
for (auto name : names) {
|
||||||
}
|
if (name != recentMap && setMap(name, true))
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Failing that, just get the first map in the list.
|
logError("Failed to load any maps.");
|
||||||
for (int i = 0; i < names.length(); i++) {
|
|
||||||
QStringList list = names.value(i);
|
|
||||||
if (list.length()) {
|
|
||||||
return setMap(list.value(0), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logError("Failed to load any map names.");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1767,7 +1757,7 @@ void MainWindow::on_mainTabBar_tabBarClicked(int index)
|
||||||
editor->setEditingConnections();
|
editor->setEditingConnections();
|
||||||
}
|
}
|
||||||
if (index != 4) {
|
if (index != 4) {
|
||||||
if (userConfig.getEncounterJsonActive())
|
if (editor->project && editor->project->wildEncountersLoaded)
|
||||||
editor->saveEncounterTabData();
|
editor->saveEncounterTabData();
|
||||||
}
|
}
|
||||||
if (index != 1) {
|
if (index != 1) {
|
||||||
|
|
162
src/project.cpp
162
src/project.cpp
|
@ -614,7 +614,7 @@ void Project::saveMapGroups() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::saveWildMonData() {
|
void Project::saveWildMonData() {
|
||||||
if (!userConfig.getEncounterJsonActive()) return;
|
if (!this->wildEncountersLoaded) return;
|
||||||
|
|
||||||
QString wildEncountersJsonFilepath = QString("%1/%2").arg(root).arg(projectConfig.getFilePath(ProjectFilePath::json_wild_encounters));
|
QString wildEncountersJsonFilepath = QString("%1/%2").arg(root).arg(projectConfig.getFilePath(ProjectFilePath::json_wild_encounters));
|
||||||
QFile wildEncountersFile(wildEncountersJsonFilepath);
|
QFile wildEncountersFile(wildEncountersJsonFilepath);
|
||||||
|
@ -1602,6 +1602,7 @@ bool Project::readWildMonData() {
|
||||||
wildMonFields.clear();
|
wildMonFields.clear();
|
||||||
wildMonData.clear();
|
wildMonData.clear();
|
||||||
encounterGroupLabels.clear();
|
encounterGroupLabels.clear();
|
||||||
|
this->wildEncountersLoaded = false;
|
||||||
if (!userConfig.getEncounterJsonActive()) {
|
if (!userConfig.getEncounterJsonActive()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1611,10 +1612,7 @@ bool Project::readWildMonData() {
|
||||||
|
|
||||||
OrderedJson::object wildMonObj;
|
OrderedJson::object wildMonObj;
|
||||||
if (!parser.tryParseOrderedJsonFile(&wildMonObj, wildMonJsonFilepath)) {
|
if (!parser.tryParseOrderedJsonFile(&wildMonObj, wildMonJsonFilepath)) {
|
||||||
// Failing to read wild encounters data is not a critical error, just disable the
|
// Failing to read wild encounters data is not a critical error, the encounter editor will just be disabled
|
||||||
// encounter editor and log a warning in case the user intended to have this data.
|
|
||||||
userConfig.setEncounterJsonActive(false);
|
|
||||||
emit disableWildEncountersUI();
|
|
||||||
logWarn(QString("Failed to read wild encounters from %1").arg(wildMonJsonFilepath));
|
logWarn(QString("Failed to read wild encounters from %1").arg(wildMonJsonFilepath));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1702,54 +1700,64 @@ bool Project::readWildMonData() {
|
||||||
setDefaultEncounterRate(i.key(), rate);
|
setDefaultEncounterRate(i.key(), rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->wildEncountersLoaded = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Project::readMapGroups() {
|
bool Project::readMapGroups() {
|
||||||
mapConstantsToMapNames.clear();
|
this->mapConstantsToMapNames.clear();
|
||||||
mapNamesToMapConstants.clear();
|
this->mapNamesToMapConstants.clear();
|
||||||
mapGroups.clear();
|
this->mapGroups.clear();
|
||||||
|
this->groupNames.clear();
|
||||||
|
this->groupedMapNames.clear();
|
||||||
|
this->mapNames.clear();
|
||||||
|
|
||||||
QString mapGroupsFilepath = root + "/" + projectConfig.getFilePath(ProjectFilePath::json_map_groups);
|
const QString filepath = root + "/" + projectConfig.getFilePath(ProjectFilePath::json_map_groups);
|
||||||
fileWatcher.addPath(mapGroupsFilepath);
|
fileWatcher.addPath(filepath);
|
||||||
QJsonDocument mapGroupsDoc;
|
QJsonDocument mapGroupsDoc;
|
||||||
if (!parser.tryParseJsonFile(&mapGroupsDoc, mapGroupsFilepath)) {
|
if (!parser.tryParseJsonFile(&mapGroupsDoc, filepath)) {
|
||||||
logError(QString("Failed to read map groups from %1").arg(mapGroupsFilepath));
|
logError(QString("Failed to read map groups from %1").arg(filepath));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject mapGroupsObj = mapGroupsDoc.object();
|
QJsonObject mapGroupsObj = mapGroupsDoc.object();
|
||||||
QJsonArray mapGroupOrder = mapGroupsObj["group_order"].toArray();
|
QJsonArray mapGroupOrder = mapGroupsObj["group_order"].toArray();
|
||||||
|
|
||||||
QList<QStringList> groupedMaps;
|
|
||||||
QStringList maps;
|
|
||||||
QStringList groups;
|
|
||||||
for (int groupIndex = 0; groupIndex < mapGroupOrder.size(); groupIndex++) {
|
for (int groupIndex = 0; groupIndex < mapGroupOrder.size(); groupIndex++) {
|
||||||
QString groupName = ParseUtil::jsonToQString(mapGroupOrder.at(groupIndex));
|
QString groupName = ParseUtil::jsonToQString(mapGroupOrder.at(groupIndex));
|
||||||
QJsonArray mapNames = mapGroupsObj.value(groupName).toArray();
|
QJsonArray mapNamesJson = mapGroupsObj.value(groupName).toArray();
|
||||||
groupedMaps.append(QStringList());
|
this->groupedMapNames.append(QStringList());
|
||||||
groups.append(groupName);
|
this->groupNames.append(groupName);
|
||||||
for (int j = 0; j < mapNames.size(); j++) {
|
for (int j = 0; j < mapNamesJson.size(); j++) {
|
||||||
QString mapName = ParseUtil::jsonToQString(mapNames.at(j));
|
QString mapName = ParseUtil::jsonToQString(mapNamesJson.at(j));
|
||||||
mapGroups.insert(mapName, groupIndex);
|
if (mapName == DYNAMIC_MAP_NAME) {
|
||||||
groupedMaps[groupIndex].append(mapName);
|
logWarn(QString("Ignoring map with reserved name '%1'.").arg(mapName));
|
||||||
maps.append(mapName);
|
continue;
|
||||||
|
}
|
||||||
|
this->mapGroups.insert(mapName, groupIndex);
|
||||||
|
this->groupedMapNames[groupIndex].append(mapName);
|
||||||
|
this->mapNames.append(mapName);
|
||||||
|
|
||||||
// Build the mapping and reverse mapping between map constants and map names.
|
// Build the mapping and reverse mapping between map constants and map names.
|
||||||
QString mapConstant = Map::mapConstantFromName(mapName);
|
QString mapConstant = Map::mapConstantFromName(mapName);
|
||||||
mapConstantsToMapNames.insert(mapConstant, mapName);
|
this->mapConstantsToMapNames.insert(mapConstant, mapName);
|
||||||
mapNamesToMapConstants.insert(mapName, mapConstant);
|
this->mapNamesToMapConstants.insert(mapName, mapConstant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString defineName = this->getDynamicMapDefineName();
|
if (this->groupNames.isEmpty()) {
|
||||||
mapConstantsToMapNames.insert(defineName, DYNAMIC_MAP_NAME);
|
logError(QString("Failed to find any map groups in %1").arg(filepath));
|
||||||
mapNamesToMapConstants.insert(DYNAMIC_MAP_NAME, defineName);
|
return false;
|
||||||
maps.append(DYNAMIC_MAP_NAME);
|
}
|
||||||
|
if (this->mapNames.isEmpty()) {
|
||||||
|
logError(QString("Failed to find any map names in %1").arg(filepath));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString defineName = this->getDynamicMapDefineName();
|
||||||
|
this->mapConstantsToMapNames.insert(defineName, DYNAMIC_MAP_NAME);
|
||||||
|
this->mapNamesToMapConstants.insert(DYNAMIC_MAP_NAME, defineName);
|
||||||
|
this->mapNames.append(DYNAMIC_MAP_NAME);
|
||||||
|
|
||||||
groupNames = groups;
|
|
||||||
groupedMapNames = groupedMaps;
|
|
||||||
mapNames = maps;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2177,10 +2185,8 @@ bool Project::readItemNames() {
|
||||||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_items);
|
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_items);
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
itemNames = parser.readCDefineNames(filename, prefixes);
|
itemNames = parser.readCDefineNames(filename, prefixes);
|
||||||
if (itemNames.isEmpty()) {
|
if (itemNames.isEmpty())
|
||||||
logError(QString("Failed to read item constants from %1").arg(filename));
|
logWarn(QString("Failed to read item constants from %1").arg(filename));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2189,10 +2195,8 @@ bool Project::readFlagNames() {
|
||||||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_flags);
|
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_flags);
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
flagNames = parser.readCDefineNames(filename, prefixes);
|
flagNames = parser.readCDefineNames(filename, prefixes);
|
||||||
if (flagNames.isEmpty()) {
|
if (flagNames.isEmpty())
|
||||||
logError(QString("Failed to read flag constants from %1").arg(filename));
|
logWarn(QString("Failed to read flag constants from %1").arg(filename));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2201,10 +2205,8 @@ bool Project::readVarNames() {
|
||||||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_vars);
|
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_vars);
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
varNames = parser.readCDefineNames(filename, prefixes);
|
varNames = parser.readCDefineNames(filename, prefixes);
|
||||||
if (varNames.isEmpty()) {
|
if (varNames.isEmpty())
|
||||||
logError(QString("Failed to read var constants from %1").arg(filename));
|
logWarn(QString("Failed to read var constants from %1").arg(filename));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2213,10 +2215,8 @@ bool Project::readMovementTypes() {
|
||||||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_obj_event_movement);
|
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_obj_event_movement);
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
movementTypes = parser.readCDefineNames(filename, prefixes);
|
movementTypes = parser.readCDefineNames(filename, prefixes);
|
||||||
if (movementTypes.isEmpty()) {
|
if (movementTypes.isEmpty())
|
||||||
logError(QString("Failed to read movement type constants from %1").arg(filename));
|
logWarn(QString("Failed to read movement type constants from %1").arg(filename));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2224,10 +2224,8 @@ bool Project::readInitialFacingDirections() {
|
||||||
QString filename = projectConfig.getFilePath(ProjectFilePath::initial_facing_table);
|
QString filename = projectConfig.getFilePath(ProjectFilePath::initial_facing_table);
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
facingDirections = parser.readNamedIndexCArray(filename, projectConfig.getIdentifier(ProjectIdentifier::symbol_facing_directions));
|
facingDirections = parser.readNamedIndexCArray(filename, projectConfig.getIdentifier(ProjectIdentifier::symbol_facing_directions));
|
||||||
if (facingDirections.isEmpty()) {
|
if (facingDirections.isEmpty())
|
||||||
logError(QString("Failed to read initial movement type facing directions from %1").arg(filename));
|
logWarn(QString("Failed to read initial movement type facing directions from %1").arg(filename));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2236,10 +2234,8 @@ bool Project::readMapTypes() {
|
||||||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_map_types);
|
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_map_types);
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
mapTypes = parser.readCDefineNames(filename, prefixes);
|
mapTypes = parser.readCDefineNames(filename, prefixes);
|
||||||
if (mapTypes.isEmpty()) {
|
if (mapTypes.isEmpty())
|
||||||
logError(QString("Failed to read map type constants from %1").arg(filename));
|
logWarn(QString("Failed to read map type constants from %1").arg(filename));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2248,10 +2244,8 @@ bool Project::readMapBattleScenes() {
|
||||||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_map_types);
|
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_map_types);
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
mapBattleScenes = parser.readCDefineNames(filename, prefixes);
|
mapBattleScenes = parser.readCDefineNames(filename, prefixes);
|
||||||
if (mapBattleScenes.isEmpty()) {
|
if (mapBattleScenes.isEmpty())
|
||||||
logError(QString("Failed to read map battle scene constants from %1").arg(filename));
|
logWarn(QString("Failed to read map battle scene constants from %1").arg(filename));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2260,10 +2254,8 @@ bool Project::readWeatherNames() {
|
||||||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_weather);
|
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_weather);
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
weatherNames = parser.readCDefineNames(filename, prefixes);
|
weatherNames = parser.readCDefineNames(filename, prefixes);
|
||||||
if (weatherNames.isEmpty()) {
|
if (weatherNames.isEmpty())
|
||||||
logError(QString("Failed to read weather constants from %1").arg(filename));
|
logWarn(QString("Failed to read weather constants from %1").arg(filename));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2275,10 +2267,8 @@ bool Project::readCoordEventWeatherNames() {
|
||||||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_weather);
|
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_weather);
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
coordEventWeatherNames = parser.readCDefineNames(filename, prefixes);
|
coordEventWeatherNames = parser.readCDefineNames(filename, prefixes);
|
||||||
if (coordEventWeatherNames.isEmpty()) {
|
if (coordEventWeatherNames.isEmpty())
|
||||||
logWarn(QString("Failed to read coord event weather constants from %1. Disabling Weather Trigger events.").arg(filename));
|
logWarn(QString("Failed to read coord event weather constants from %1").arg(filename));
|
||||||
projectConfig.setEventWeatherTriggerEnabled(false);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2290,10 +2280,8 @@ bool Project::readSecretBaseIds() {
|
||||||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_secret_bases);
|
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_secret_bases);
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
secretBaseIds = parser.readCDefineNames(filename, prefixes);
|
secretBaseIds = parser.readCDefineNames(filename, prefixes);
|
||||||
if (secretBaseIds.isEmpty()) {
|
if (secretBaseIds.isEmpty())
|
||||||
logWarn(QString("Failed to read secret base id constants from '%1'. Disabling Secret Base events.").arg(filename));
|
logWarn(QString("Failed to read secret base id constants from '%1'").arg(filename));
|
||||||
projectConfig.setEventSecretBaseEnabled(false);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2302,10 +2290,8 @@ bool Project::readBgEventFacingDirections() {
|
||||||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_event_bg);
|
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_event_bg);
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
bgEventFacingDirections = parser.readCDefineNames(filename, prefixes);
|
bgEventFacingDirections = parser.readCDefineNames(filename, prefixes);
|
||||||
if (bgEventFacingDirections.isEmpty()) {
|
if (bgEventFacingDirections.isEmpty())
|
||||||
logError(QString("Failed to read bg event facing direction constants from %1").arg(filename));
|
logWarn(QString("Failed to read bg event facing direction constants from %1").arg(filename));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2314,10 +2300,8 @@ bool Project::readTrainerTypes() {
|
||||||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_trainer_types);
|
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_trainer_types);
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
trainerTypes = parser.readCDefineNames(filename, prefixes);
|
trainerTypes = parser.readCDefineNames(filename, prefixes);
|
||||||
if (trainerTypes.isEmpty()) {
|
if (trainerTypes.isEmpty())
|
||||||
logError(QString("Failed to read trainer type constants from %1").arg(filename));
|
logWarn(QString("Failed to read trainer type constants from %1").arg(filename));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2351,12 +2335,12 @@ bool Project::readSongNames() {
|
||||||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_songs);
|
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_songs);
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
this->songNames = parser.readCDefineNames(filename, prefixes);
|
this->songNames = parser.readCDefineNames(filename, prefixes);
|
||||||
if (this->songNames.isEmpty()) {
|
if (this->songNames.isEmpty())
|
||||||
logError(QString("Failed to read song names from %1.").arg(filename));
|
logWarn(QString("Failed to read song names from %1.").arg(filename));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this->defaultSong = this->songNames.value(0);
|
|
||||||
// Song names don't have a very useful order (esp. if we include SE_* values), so sort them alphabetically.
|
// Song names don't have a very useful order (esp. if we include SE_* values), so sort them alphabetically.
|
||||||
|
// The default song should be the first in the list, not the first alphabetically, so save that before sorting.
|
||||||
|
this->defaultSong = this->songNames.value(0, "0");
|
||||||
this->songNames.sort();
|
this->songNames.sort();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2366,10 +2350,8 @@ bool Project::readObjEventGfxConstants() {
|
||||||
QString filename = projectConfig.getFilePath(ProjectFilePath::constants_obj_events);
|
QString filename = projectConfig.getFilePath(ProjectFilePath::constants_obj_events);
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
this->gfxDefines = parser.readCDefinesByPrefix(filename, prefixes);
|
this->gfxDefines = parser.readCDefinesByPrefix(filename, prefixes);
|
||||||
if (this->gfxDefines.isEmpty()) {
|
if (this->gfxDefines.isEmpty())
|
||||||
logError(QString("Failed to read object event graphics constants from %1.").arg(filename));
|
logWarn(QString("Failed to read object event graphics constants from %1.").arg(filename));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,8 +141,8 @@ int ScriptUtility::getMainTab() {
|
||||||
void ScriptUtility::setMainTab(int index) {
|
void ScriptUtility::setMainTab(int index) {
|
||||||
if (!window || !window->ui || !window->ui->mainTabBar || index < 0 || index >= window->ui->mainTabBar->count())
|
if (!window || !window->ui || !window->ui->mainTabBar || index < 0 || index >= window->ui->mainTabBar->count())
|
||||||
return;
|
return;
|
||||||
// Can't select Wild Encounters tab if it's disabled
|
// Can't select tab if it's disabled
|
||||||
if (index == 4 && !userConfig.getEncounterJsonActive())
|
if (!window->ui->mainTabBar->isTabEnabled(index))
|
||||||
return;
|
return;
|
||||||
window->on_mainTabBar_tabBarClicked(index);
|
window->on_mainTabBar_tabBarClicked(index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ void NewMapPopup::init() {
|
||||||
ui->comboBox_NewMap_Group->addItems(project->groupNames);
|
ui->comboBox_NewMap_Group->addItems(project->groupNames);
|
||||||
ui->comboBox_NewMap_Song->addItems(project->songNames);
|
ui->comboBox_NewMap_Song->addItems(project->songNames);
|
||||||
ui->comboBox_NewMap_Type->addItems(project->mapTypes);
|
ui->comboBox_NewMap_Type->addItems(project->mapTypes);
|
||||||
ui->comboBox_NewMap_Location->addItems(project->mapSectionValueToName.values());
|
ui->comboBox_NewMap_Location->addItems(project->mapSectionNameToValue.keys());
|
||||||
|
|
||||||
// Set spin box limits
|
// Set spin box limits
|
||||||
ui->spinBox_NewMap_Width->setMinimum(1);
|
ui->spinBox_NewMap_Width->setMinimum(1);
|
||||||
|
@ -173,8 +173,8 @@ void NewMapPopup::setDefaultSettings(Project *project) {
|
||||||
settings.borderHeight = DEFAULT_BORDER_HEIGHT;
|
settings.borderHeight = DEFAULT_BORDER_HEIGHT;
|
||||||
settings.primaryTilesetLabel = project->getDefaultPrimaryTilesetLabel();
|
settings.primaryTilesetLabel = project->getDefaultPrimaryTilesetLabel();
|
||||||
settings.secondaryTilesetLabel = project->getDefaultSecondaryTilesetLabel();
|
settings.secondaryTilesetLabel = project->getDefaultSecondaryTilesetLabel();
|
||||||
settings.type = project->mapTypes.at(0);
|
settings.type = project->mapTypes.value(0, "0");
|
||||||
settings.location = project->mapSectionValueToName.values().at(0);
|
settings.location = project->mapSectionNameToValue.keys().value(0, "0");
|
||||||
settings.song = project->defaultSong;
|
settings.song = project->defaultSong;
|
||||||
settings.canFlyTo = false;
|
settings.canFlyTo = false;
|
||||||
settings.showLocationName = true;
|
settings.showLocationName = true;
|
||||||
|
@ -258,9 +258,9 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
|
||||||
newMap->location = this->ui->comboBox_NewMap_Location->currentText();
|
newMap->location = this->ui->comboBox_NewMap_Location->currentText();
|
||||||
newMap->song = this->ui->comboBox_NewMap_Song->currentText();
|
newMap->song = this->ui->comboBox_NewMap_Song->currentText();
|
||||||
newMap->requiresFlash = false;
|
newMap->requiresFlash = false;
|
||||||
newMap->weather = this->project->weatherNames.value(0);
|
newMap->weather = this->project->weatherNames.value(0, "0");
|
||||||
newMap->show_location = this->ui->checkBox_NewMap_Show_Location->isChecked();
|
newMap->show_location = this->ui->checkBox_NewMap_Show_Location->isChecked();
|
||||||
newMap->battle_scene = this->project->mapBattleScenes.value(0);
|
newMap->battle_scene = this->project->mapBattleScenes.value(0, "0");
|
||||||
|
|
||||||
if (this->existingLayout) {
|
if (this->existingLayout) {
|
||||||
layout = this->project->mapLayouts.value(this->layoutId);
|
layout = this->project->mapLayouts.value(this->layoutId);
|
||||||
|
|
Loading…
Reference in a new issue