Soften launch requirements, fix some potential crashes

This commit is contained in:
GriffinR 2024-01-19 11:59:04 -05:00
parent 3505251ad2
commit 3ebc7a93d4
6 changed files with 106 additions and 140 deletions

View file

@ -8,11 +8,13 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
## [Unreleased] ## [Unreleased]
### Changed ### Changed
- If settings-specific features like Wild Encounters fail to load they are now only disabled for that session - 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

View file

@ -78,8 +78,6 @@ public:
bool usingAsmTilesets; bool usingAsmTilesets;
QString importExportPath; QString importExportPath;
QSet<QString> disabledSettingsNames; QSet<QString> disabledSettingsNames;
bool weatherEventConstantsLoaded;
bool secretBaseConstantsLoaded;
bool wildEncountersLoaded; bool wildEncountersLoaded;
void set_root(QString); void set_root(QString);
@ -165,8 +163,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();

View file

@ -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);
} }

View file

@ -376,8 +376,8 @@ void MainWindow::setProjectSpecificUI()
ui->label_AllowBiking->setVisible(hasFlags); ui->label_AllowBiking->setVisible(hasFlags);
ui->label_AllowEscaping->setVisible(hasFlags); ui->label_AllowEscaping->setVisible(hasFlags);
ui->newEventToolButton->newWeatherTriggerAction->setVisible(editor->project->weatherEventConstantsLoaded); ui->newEventToolButton->newWeatherTriggerAction->setVisible(projectConfig.getEventWeatherTriggerEnabled());
ui->newEventToolButton->newSecretBaseAction->setVisible(editor->project->secretBaseConstantsLoaded); ui->newEventToolButton->newSecretBaseAction->setVisible(projectConfig.getEventSecretBaseEnabled());
ui->newEventToolButton->newCloneObjectAction->setVisible(projectConfig.getEventCloneObjectEnabled()); ui->newEventToolButton->newCloneObjectAction->setVisible(projectConfig.getEventCloneObjectEnabled());
bool floorNumEnabled = projectConfig.getFloorNumberEnabled(); bool floorNumEnabled = projectConfig.getFloorNumberEnabled();
@ -498,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();
@ -541,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();
@ -572,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;
} }

View file

@ -1705,50 +1705,59 @@ bool Project::readWildMonData() {
} }
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;
} }
@ -2176,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;
} }
@ -2188,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;
} }
@ -2200,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;
} }
@ -2212,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;
} }
@ -2223,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;
} }
@ -2235,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;
} }
@ -2247,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;
} }
@ -2259,15 +2254,12 @@ 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;
} }
bool Project::readCoordEventWeatherNames() { bool Project::readCoordEventWeatherNames() {
this->weatherEventConstantsLoaded = false;
if (!projectConfig.getEventWeatherTriggerEnabled()) if (!projectConfig.getEventWeatherTriggerEnabled())
return true; return true;
@ -2275,17 +2267,12 @@ 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));
return true;
}
this->weatherEventConstantsLoaded = true;
return true; return true;
} }
bool Project::readSecretBaseIds() { bool Project::readSecretBaseIds() {
this->secretBaseConstantsLoaded = false;
if (!projectConfig.getEventSecretBaseEnabled()) if (!projectConfig.getEventSecretBaseEnabled())
return true; return true;
@ -2293,12 +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));
return true;
}
this->secretBaseConstantsLoaded = true;
return true; return true;
} }
@ -2307,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;
} }
@ -2319,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;
} }
@ -2356,11 +2335,9 @@ 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.
this->songNames.sort(); this->songNames.sort();
return true; return true;
@ -2371,10 +2348,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;
} }

View file

@ -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,9 +173,9 @@ 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->songNames.value(0, "0");
settings.canFlyTo = false; settings.canFlyTo = false;
settings.showLocationName = true; settings.showLocationName = true;
settings.allowRunning = false; settings.allowRunning = false;
@ -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);