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.
|
||||
|
||||
## [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
|
||||
- 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 scrolling to the wrong selection when zoomed.
|
||||
- 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
|
||||
### Added
|
||||
|
|
|
@ -373,7 +373,6 @@ private:
|
|||
void initShortcuts();
|
||||
void initExtraShortcuts();
|
||||
void setProjectSpecificUI();
|
||||
void setWildEncountersUIEnabled(bool enabled);
|
||||
void loadUserSettings();
|
||||
void applyMapListFilter(QString filterText);
|
||||
void restoreWindowState();
|
||||
|
|
|
@ -54,6 +54,7 @@ public:
|
|||
QMap<int, QString> mapSectionValueToName;
|
||||
QMap<QString, EventGraphics*> eventGraphicsMap;
|
||||
QMap<QString, int> gfxDefines;
|
||||
QString defaultSong;
|
||||
QStringList songNames;
|
||||
QStringList itemNames;
|
||||
QStringList flagNames;
|
||||
|
@ -78,6 +79,7 @@ public:
|
|||
bool usingAsmTilesets;
|
||||
QString importExportPath;
|
||||
QSet<QString> disabledSettingsNames;
|
||||
bool wildEncountersLoaded;
|
||||
|
||||
void set_root(QString);
|
||||
|
||||
|
@ -162,8 +164,6 @@ public:
|
|||
void saveTilesetMetatiles(Tileset*);
|
||||
void saveTilesetTilesImage(Tileset*);
|
||||
void saveTilesetPalettes(Tileset*);
|
||||
|
||||
QString defaultSong;
|
||||
void appendTilesetLabel(QString label, QString isSecondaryStr);
|
||||
bool readTilesetLabels();
|
||||
bool readTilesetMetatileLabels();
|
||||
|
@ -253,7 +253,6 @@ signals:
|
|||
void reloadProject();
|
||||
void uncheckMonitorFilesAction();
|
||||
void mapCacheCleared();
|
||||
void disableWildEncountersUI();
|
||||
};
|
||||
|
||||
#endif // PROJECT_H
|
||||
|
|
|
@ -233,8 +233,8 @@ bool ObjectEvent::loadFromJson(QJsonObject json, Project *) {
|
|||
}
|
||||
|
||||
void ObjectEvent::setDefaultValues(Project *project) {
|
||||
this->setGfx(project->gfxDefines.keys().first());
|
||||
this->setMovement(project->movementTypes.first());
|
||||
this->setGfx(project->gfxDefines.keys().value(0, "0"));
|
||||
this->setMovement(project->movementTypes.value(0, "0"));
|
||||
this->setScript("NULL");
|
||||
this->setTrainerType(project->trainerTypes.value(0, "0"));
|
||||
this->setFlag("0");
|
||||
|
@ -404,7 +404,7 @@ bool CloneObjectEvent::loadFromJson(QJsonObject json, Project *project) {
|
|||
}
|
||||
|
||||
void CloneObjectEvent::setDefaultValues(Project *project) {
|
||||
this->setGfx(project->gfxDefines.keys().first());
|
||||
this->setGfx(project->gfxDefines.keys().value(0, "0"));
|
||||
this->setTargetID(1);
|
||||
if (this->getMap()) this->setTargetMap(this->getMap()->name);
|
||||
}
|
||||
|
@ -436,8 +436,8 @@ void CloneObjectEvent::loadPixmap(Project *project) {
|
|||
this->movement = clonedObject->getMovement();
|
||||
} else {
|
||||
// Invalid object specified, use default graphics data (as would be shown in-game)
|
||||
this->gfx = project->gfxDefines.key(0);
|
||||
this->movement = project->movementTypes.first();
|
||||
this->gfx = project->gfxDefines.key(0, "0");
|
||||
this->movement = project->movementTypes.value(0, "0");
|
||||
}
|
||||
|
||||
EventGraphics *eventGfx = project->eventGraphicsMap.value(gfx, nullptr);
|
||||
|
@ -596,7 +596,7 @@ bool TriggerEvent::loadFromJson(QJsonObject json, Project *) {
|
|||
|
||||
void TriggerEvent::setDefaultValues(Project *project) {
|
||||
this->setScriptLabel("NULL");
|
||||
this->setScriptVar(project->varNames.first());
|
||||
this->setScriptVar(project->varNames.value(0, "0"));
|
||||
this->setScriptVarValue("0");
|
||||
this->setElevation(0);
|
||||
}
|
||||
|
@ -665,7 +665,7 @@ bool WeatherTriggerEvent::loadFromJson(QJsonObject json, Project *) {
|
|||
}
|
||||
|
||||
void WeatherTriggerEvent::setDefaultValues(Project *project) {
|
||||
this->setWeather(project->coordEventWeatherNames.first());
|
||||
this->setWeather(project->coordEventWeatherNames.value(0, "0"));
|
||||
this->setElevation(0);
|
||||
}
|
||||
|
||||
|
@ -734,7 +734,7 @@ bool SignEvent::loadFromJson(QJsonObject json, Project *) {
|
|||
}
|
||||
|
||||
void SignEvent::setDefaultValues(Project *project) {
|
||||
this->setFacingDirection(project->bgEventFacingDirections.first());
|
||||
this->setFacingDirection(project->bgEventFacingDirections.value(0, "0"));
|
||||
this->setScriptLabel("NULL");
|
||||
this->setElevation(0);
|
||||
}
|
||||
|
@ -819,8 +819,8 @@ bool HiddenItemEvent::loadFromJson(QJsonObject json, Project *) {
|
|||
}
|
||||
|
||||
void HiddenItemEvent::setDefaultValues(Project *project) {
|
||||
this->setItem(project->itemNames.first());
|
||||
this->setFlag(project->flagNames.first());
|
||||
this->setItem(project->itemNames.value(0, "0"));
|
||||
this->setFlag(project->flagNames.value(0, "0"));
|
||||
if (projectConfig.getHiddenItemQuantityEnabled()) {
|
||||
this->setQuantity(1);
|
||||
}
|
||||
|
@ -898,7 +898,7 @@ bool SecretBaseEvent::loadFromJson(QJsonObject json, Project *) {
|
|||
}
|
||||
|
||||
void SecretBaseEvent::setDefaultValues(Project *project) {
|
||||
this->setBaseID(project->secretBaseIds.first());
|
||||
this->setBaseID(project->secretBaseIds.value(0, "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.
|
||||
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();
|
||||
ui->checkBox_AllowRunning->setVisible(hasFlags);
|
||||
|
@ -500,7 +498,10 @@ bool MainWindow::openProject(const QString &dir, bool initial) {
|
|||
}
|
||||
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.load();
|
||||
|
@ -520,7 +521,6 @@ bool MainWindow::openProject(const QString &dir, bool initial) {
|
|||
editor->project = new Project(this);
|
||||
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::disableWildEncountersUI, [this]() { this->setWildEncountersUIEnabled(false); });
|
||||
QObject::connect(editor->project, &Project::uncheckMonitorFilesAction, [this]() {
|
||||
porymapConfig.setMonitorFiles(false);
|
||||
if (this->preferenceEditor)
|
||||
|
@ -544,10 +544,7 @@ bool MainWindow::openProject(const QString &dir, bool initial) {
|
|||
}
|
||||
|
||||
showWindowTitle();
|
||||
|
||||
const QString successMessage = QString("Opened %1").arg(projectString);
|
||||
this->statusBar()->showMessage(successMessage);
|
||||
logInfo(successMessage);
|
||||
this->statusBar()->showMessage(QString("Opened %1").arg(projectString));
|
||||
|
||||
porymapConfig.addRecentProject(dir);
|
||||
refreshRecentProjectsMenu();
|
||||
|
@ -575,29 +572,22 @@ bool MainWindow::isProjectOpen() {
|
|||
}
|
||||
|
||||
bool MainWindow::setInitialMap() {
|
||||
QList<QStringList> names;
|
||||
QStringList names;
|
||||
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();
|
||||
if (!recentMap.isEmpty()) {
|
||||
// Make sure the recent map is still in the map list
|
||||
for (int i = 0; i < names.length(); i++) {
|
||||
if (names.value(i).contains(recentMap)) {
|
||||
return setMap(recentMap, true);
|
||||
}
|
||||
}
|
||||
if (!recentMap.isEmpty() && names.contains(recentMap) && setMap(recentMap, true))
|
||||
return true;
|
||||
|
||||
// Failing that, try loading maps in the map list sequentially.
|
||||
for (auto name : names) {
|
||||
if (name != recentMap && setMap(name, true))
|
||||
return true;
|
||||
}
|
||||
|
||||
// Failing that, just get the first map in the list.
|
||||
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.");
|
||||
logError("Failed to load any maps.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1767,7 +1757,7 @@ void MainWindow::on_mainTabBar_tabBarClicked(int index)
|
|||
editor->setEditingConnections();
|
||||
}
|
||||
if (index != 4) {
|
||||
if (userConfig.getEncounterJsonActive())
|
||||
if (editor->project && editor->project->wildEncountersLoaded)
|
||||
editor->saveEncounterTabData();
|
||||
}
|
||||
if (index != 1) {
|
||||
|
|
160
src/project.cpp
160
src/project.cpp
|
@ -614,7 +614,7 @@ void Project::saveMapGroups() {
|
|||
}
|
||||
|
||||
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));
|
||||
QFile wildEncountersFile(wildEncountersJsonFilepath);
|
||||
|
@ -1602,6 +1602,7 @@ bool Project::readWildMonData() {
|
|||
wildMonFields.clear();
|
||||
wildMonData.clear();
|
||||
encounterGroupLabels.clear();
|
||||
this->wildEncountersLoaded = false;
|
||||
if (!userConfig.getEncounterJsonActive()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1611,10 +1612,7 @@ bool Project::readWildMonData() {
|
|||
|
||||
OrderedJson::object wildMonObj;
|
||||
if (!parser.tryParseOrderedJsonFile(&wildMonObj, wildMonJsonFilepath)) {
|
||||
// Failing to read wild encounters data is not a critical error, just disable the
|
||||
// encounter editor and log a warning in case the user intended to have this data.
|
||||
userConfig.setEncounterJsonActive(false);
|
||||
emit disableWildEncountersUI();
|
||||
// Failing to read wild encounters data is not a critical error, the encounter editor will just be disabled
|
||||
logWarn(QString("Failed to read wild encounters from %1").arg(wildMonJsonFilepath));
|
||||
return true;
|
||||
}
|
||||
|
@ -1702,54 +1700,64 @@ bool Project::readWildMonData() {
|
|||
setDefaultEncounterRate(i.key(), rate);
|
||||
}
|
||||
|
||||
this->wildEncountersLoaded = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Project::readMapGroups() {
|
||||
mapConstantsToMapNames.clear();
|
||||
mapNamesToMapConstants.clear();
|
||||
mapGroups.clear();
|
||||
this->mapConstantsToMapNames.clear();
|
||||
this->mapNamesToMapConstants.clear();
|
||||
this->mapGroups.clear();
|
||||
this->groupNames.clear();
|
||||
this->groupedMapNames.clear();
|
||||
this->mapNames.clear();
|
||||
|
||||
QString mapGroupsFilepath = root + "/" + projectConfig.getFilePath(ProjectFilePath::json_map_groups);
|
||||
fileWatcher.addPath(mapGroupsFilepath);
|
||||
const QString filepath = root + "/" + projectConfig.getFilePath(ProjectFilePath::json_map_groups);
|
||||
fileWatcher.addPath(filepath);
|
||||
QJsonDocument mapGroupsDoc;
|
||||
if (!parser.tryParseJsonFile(&mapGroupsDoc, mapGroupsFilepath)) {
|
||||
logError(QString("Failed to read map groups from %1").arg(mapGroupsFilepath));
|
||||
if (!parser.tryParseJsonFile(&mapGroupsDoc, filepath)) {
|
||||
logError(QString("Failed to read map groups from %1").arg(filepath));
|
||||
return false;
|
||||
}
|
||||
|
||||
QJsonObject mapGroupsObj = mapGroupsDoc.object();
|
||||
QJsonArray mapGroupOrder = mapGroupsObj["group_order"].toArray();
|
||||
|
||||
QList<QStringList> groupedMaps;
|
||||
QStringList maps;
|
||||
QStringList groups;
|
||||
for (int groupIndex = 0; groupIndex < mapGroupOrder.size(); groupIndex++) {
|
||||
QString groupName = ParseUtil::jsonToQString(mapGroupOrder.at(groupIndex));
|
||||
QJsonArray mapNames = mapGroupsObj.value(groupName).toArray();
|
||||
groupedMaps.append(QStringList());
|
||||
groups.append(groupName);
|
||||
for (int j = 0; j < mapNames.size(); j++) {
|
||||
QString mapName = ParseUtil::jsonToQString(mapNames.at(j));
|
||||
mapGroups.insert(mapName, groupIndex);
|
||||
groupedMaps[groupIndex].append(mapName);
|
||||
maps.append(mapName);
|
||||
QJsonArray mapNamesJson = mapGroupsObj.value(groupName).toArray();
|
||||
this->groupedMapNames.append(QStringList());
|
||||
this->groupNames.append(groupName);
|
||||
for (int j = 0; j < mapNamesJson.size(); j++) {
|
||||
QString mapName = ParseUtil::jsonToQString(mapNamesJson.at(j));
|
||||
if (mapName == DYNAMIC_MAP_NAME) {
|
||||
logWarn(QString("Ignoring map with reserved name '%1'.").arg(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.
|
||||
QString mapConstant = Map::mapConstantFromName(mapName);
|
||||
mapConstantsToMapNames.insert(mapConstant, mapName);
|
||||
mapNamesToMapConstants.insert(mapName, mapConstant);
|
||||
this->mapConstantsToMapNames.insert(mapConstant, mapName);
|
||||
this->mapNamesToMapConstants.insert(mapName, mapConstant);
|
||||
}
|
||||
}
|
||||
|
||||
if (this->groupNames.isEmpty()) {
|
||||
logError(QString("Failed to find any map groups in %1").arg(filepath));
|
||||
return false;
|
||||
}
|
||||
if (this->mapNames.isEmpty()) {
|
||||
logError(QString("Failed to find any map names in %1").arg(filepath));
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString defineName = this->getDynamicMapDefineName();
|
||||
mapConstantsToMapNames.insert(defineName, DYNAMIC_MAP_NAME);
|
||||
mapNamesToMapConstants.insert(DYNAMIC_MAP_NAME, defineName);
|
||||
maps.append(DYNAMIC_MAP_NAME);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -2177,10 +2185,8 @@ bool Project::readItemNames() {
|
|||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_items);
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
itemNames = parser.readCDefineNames(filename, prefixes);
|
||||
if (itemNames.isEmpty()) {
|
||||
logError(QString("Failed to read item constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
if (itemNames.isEmpty())
|
||||
logWarn(QString("Failed to read item constants from %1").arg(filename));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2189,10 +2195,8 @@ bool Project::readFlagNames() {
|
|||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_flags);
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
flagNames = parser.readCDefineNames(filename, prefixes);
|
||||
if (flagNames.isEmpty()) {
|
||||
logError(QString("Failed to read flag constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
if (flagNames.isEmpty())
|
||||
logWarn(QString("Failed to read flag constants from %1").arg(filename));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2201,10 +2205,8 @@ bool Project::readVarNames() {
|
|||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_vars);
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
varNames = parser.readCDefineNames(filename, prefixes);
|
||||
if (varNames.isEmpty()) {
|
||||
logError(QString("Failed to read var constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
if (varNames.isEmpty())
|
||||
logWarn(QString("Failed to read var constants from %1").arg(filename));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2213,10 +2215,8 @@ bool Project::readMovementTypes() {
|
|||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_obj_event_movement);
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
movementTypes = parser.readCDefineNames(filename, prefixes);
|
||||
if (movementTypes.isEmpty()) {
|
||||
logError(QString("Failed to read movement type constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
if (movementTypes.isEmpty())
|
||||
logWarn(QString("Failed to read movement type constants from %1").arg(filename));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2224,10 +2224,8 @@ bool Project::readInitialFacingDirections() {
|
|||
QString filename = projectConfig.getFilePath(ProjectFilePath::initial_facing_table);
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
facingDirections = parser.readNamedIndexCArray(filename, projectConfig.getIdentifier(ProjectIdentifier::symbol_facing_directions));
|
||||
if (facingDirections.isEmpty()) {
|
||||
logError(QString("Failed to read initial movement type facing directions from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
if (facingDirections.isEmpty())
|
||||
logWarn(QString("Failed to read initial movement type facing directions from %1").arg(filename));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2236,10 +2234,8 @@ bool Project::readMapTypes() {
|
|||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_map_types);
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
mapTypes = parser.readCDefineNames(filename, prefixes);
|
||||
if (mapTypes.isEmpty()) {
|
||||
logError(QString("Failed to read map type constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
if (mapTypes.isEmpty())
|
||||
logWarn(QString("Failed to read map type constants from %1").arg(filename));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2248,10 +2244,8 @@ bool Project::readMapBattleScenes() {
|
|||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_map_types);
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
mapBattleScenes = parser.readCDefineNames(filename, prefixes);
|
||||
if (mapBattleScenes.isEmpty()) {
|
||||
logError(QString("Failed to read map battle scene constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
if (mapBattleScenes.isEmpty())
|
||||
logWarn(QString("Failed to read map battle scene constants from %1").arg(filename));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2260,10 +2254,8 @@ bool Project::readWeatherNames() {
|
|||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_weather);
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
weatherNames = parser.readCDefineNames(filename, prefixes);
|
||||
if (weatherNames.isEmpty()) {
|
||||
logError(QString("Failed to read weather constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
if (weatherNames.isEmpty())
|
||||
logWarn(QString("Failed to read weather constants from %1").arg(filename));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2275,10 +2267,8 @@ bool Project::readCoordEventWeatherNames() {
|
|||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_weather);
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
coordEventWeatherNames = parser.readCDefineNames(filename, prefixes);
|
||||
if (coordEventWeatherNames.isEmpty()) {
|
||||
logWarn(QString("Failed to read coord event weather constants from %1. Disabling Weather Trigger events.").arg(filename));
|
||||
projectConfig.setEventWeatherTriggerEnabled(false);
|
||||
}
|
||||
if (coordEventWeatherNames.isEmpty())
|
||||
logWarn(QString("Failed to read coord event weather constants from %1").arg(filename));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2290,10 +2280,8 @@ bool Project::readSecretBaseIds() {
|
|||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_secret_bases);
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
secretBaseIds = parser.readCDefineNames(filename, prefixes);
|
||||
if (secretBaseIds.isEmpty()) {
|
||||
logWarn(QString("Failed to read secret base id constants from '%1'. Disabling Secret Base events.").arg(filename));
|
||||
projectConfig.setEventSecretBaseEnabled(false);
|
||||
}
|
||||
if (secretBaseIds.isEmpty())
|
||||
logWarn(QString("Failed to read secret base id constants from '%1'").arg(filename));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2302,10 +2290,8 @@ bool Project::readBgEventFacingDirections() {
|
|||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_event_bg);
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
bgEventFacingDirections = parser.readCDefineNames(filename, prefixes);
|
||||
if (bgEventFacingDirections.isEmpty()) {
|
||||
logError(QString("Failed to read bg event facing direction constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
if (bgEventFacingDirections.isEmpty())
|
||||
logWarn(QString("Failed to read bg event facing direction constants from %1").arg(filename));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2314,10 +2300,8 @@ bool Project::readTrainerTypes() {
|
|||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_trainer_types);
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
trainerTypes = parser.readCDefineNames(filename, prefixes);
|
||||
if (trainerTypes.isEmpty()) {
|
||||
logError(QString("Failed to read trainer type constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
if (trainerTypes.isEmpty())
|
||||
logWarn(QString("Failed to read trainer type constants from %1").arg(filename));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2351,12 +2335,12 @@ bool Project::readSongNames() {
|
|||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_songs);
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
this->songNames = parser.readCDefineNames(filename, prefixes);
|
||||
if (this->songNames.isEmpty()) {
|
||||
logError(QString("Failed to read song names from %1.").arg(filename));
|
||||
return false;
|
||||
}
|
||||
this->defaultSong = this->songNames.value(0);
|
||||
if (this->songNames.isEmpty())
|
||||
logWarn(QString("Failed to read song names from %1.").arg(filename));
|
||||
|
||||
// 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();
|
||||
return true;
|
||||
}
|
||||
|
@ -2366,10 +2350,8 @@ bool Project::readObjEventGfxConstants() {
|
|||
QString filename = projectConfig.getFilePath(ProjectFilePath::constants_obj_events);
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
this->gfxDefines = parser.readCDefinesByPrefix(filename, prefixes);
|
||||
if (this->gfxDefines.isEmpty()) {
|
||||
logError(QString("Failed to read object event graphics constants from %1.").arg(filename));
|
||||
return false;
|
||||
}
|
||||
if (this->gfxDefines.isEmpty())
|
||||
logWarn(QString("Failed to read object event graphics constants from %1.").arg(filename));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -141,8 +141,8 @@ int ScriptUtility::getMainTab() {
|
|||
void ScriptUtility::setMainTab(int index) {
|
||||
if (!window || !window->ui || !window->ui->mainTabBar || index < 0 || index >= window->ui->mainTabBar->count())
|
||||
return;
|
||||
// Can't select Wild Encounters tab if it's disabled
|
||||
if (index == 4 && !userConfig.getEncounterJsonActive())
|
||||
// Can't select tab if it's disabled
|
||||
if (!window->ui->mainTabBar->isTabEnabled(index))
|
||||
return;
|
||||
window->on_mainTabBar_tabBarClicked(index);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ void NewMapPopup::init() {
|
|||
ui->comboBox_NewMap_Group->addItems(project->groupNames);
|
||||
ui->comboBox_NewMap_Song->addItems(project->songNames);
|
||||
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
|
||||
ui->spinBox_NewMap_Width->setMinimum(1);
|
||||
|
@ -173,8 +173,8 @@ void NewMapPopup::setDefaultSettings(Project *project) {
|
|||
settings.borderHeight = DEFAULT_BORDER_HEIGHT;
|
||||
settings.primaryTilesetLabel = project->getDefaultPrimaryTilesetLabel();
|
||||
settings.secondaryTilesetLabel = project->getDefaultSecondaryTilesetLabel();
|
||||
settings.type = project->mapTypes.at(0);
|
||||
settings.location = project->mapSectionValueToName.values().at(0);
|
||||
settings.type = project->mapTypes.value(0, "0");
|
||||
settings.location = project->mapSectionNameToValue.keys().value(0, "0");
|
||||
settings.song = project->defaultSong;
|
||||
settings.canFlyTo = false;
|
||||
settings.showLocationName = true;
|
||||
|
@ -258,9 +258,9 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
|
|||
newMap->location = this->ui->comboBox_NewMap_Location->currentText();
|
||||
newMap->song = this->ui->comboBox_NewMap_Song->currentText();
|
||||
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->battle_scene = this->project->mapBattleScenes.value(0);
|
||||
newMap->battle_scene = this->project->mapBattleScenes.value(0, "0");
|
||||
|
||||
if (this->existingLayout) {
|
||||
layout = this->project->mapLayouts.value(this->layoutId);
|
||||
|
|
Loading…
Reference in a new issue