Move warp behavior warning setting to porymap.cfg

This commit is contained in:
GriffinR 2023-12-19 12:57:45 -05:00
parent 59f365b16d
commit 2cdbd029b6
4 changed files with 22 additions and 21 deletions

View file

@ -69,6 +69,7 @@ public:
this->textEditorGotoLine = "";
this->paletteEditorBitDepth = 24;
this->projectSettingsTab = 0;
this->warpBehaviorWarningDisabled = false;
}
void setRecentProject(QString project);
void setReopenOnLaunch(bool enabled);
@ -94,6 +95,7 @@ public:
void setTextEditorGotoLine(const QString &command);
void setPaletteEditorBitDepth(int bitDepth);
void setProjectSettingsTab(int tab);
void setWarpBehaviorWarningDisabled(bool disabled);
QString getRecentProject();
bool getReopenOnLaunch();
MapSortOrder getMapSortOrder();
@ -118,6 +120,7 @@ public:
QString getTextEditorGotoLine();
int getPaletteEditorBitDepth();
int getProjectSettingsTab();
bool getWarpBehaviorWarningDisabled();
protected:
virtual QString getConfigFilepath() override;
virtual void parseConfigKeyValue(QString key, QString value) override;
@ -160,6 +163,7 @@ private:
QString textEditorGotoLine;
int paletteEditorBitDepth;
int projectSettingsTab;
bool warpBehaviorWarningDisabled;
};
extern PorymapConfig porymapConfig;
@ -304,7 +308,6 @@ public:
this->blockCollisionMask = 0x0C00;
this->blockElevationMask = 0xF000;
this->warpBehaviors = defaultWarpBehaviors;
this->warpBehaviorWarningDisabled = false;
this->identifiers.clear();
this->readKeys.clear();
}
@ -404,8 +407,6 @@ public:
int getCollisionSheetHeight();
void setWarpBehaviors(const QStringList &behaviors);
QStringList getWarpBehaviors();
void setWarpBehaviorWarningDisabled(bool disabled);
bool getWarpBehaviorWarningDisabled();
protected:
virtual QString getConfigFilepath() override;
@ -457,7 +458,6 @@ private:
int collisionSheetWidth;
int collisionSheetHeight;
QStringList warpBehaviors;
bool warpBehaviorWarningDisabled;
};
extern ProjectConfig projectConfig;

View file

@ -371,6 +371,8 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
}
} else if (key == "project_settings_tab") {
this->projectSettingsTab = getConfigInteger(key, value, 0);
} else if (key == "warp_behavior_warning_disabled") {
this->warpBehaviorWarningDisabled = getConfigBool(key, value);
} else {
logWarn(QString("Invalid config key found in config file %1: '%2'").arg(this->getConfigFilepath()).arg(key));
}
@ -410,6 +412,7 @@ QMap<QString, QString> PorymapConfig::getKeyValueMap() {
map.insert("text_editor_goto_line", this->textEditorGotoLine);
map.insert("palette_editor_bit_depth", QString::number(this->paletteEditorBitDepth));
map.insert("project_settings_tab", QString::number(this->projectSettingsTab));
map.insert("warp_behavior_warning_disabled", QString::number(this->warpBehaviorWarningDisabled));
return map;
}
@ -687,6 +690,15 @@ int PorymapConfig::getProjectSettingsTab() {
return this->projectSettingsTab;
}
void PorymapConfig::setWarpBehaviorWarningDisabled(bool disabled) {
this->warpBehaviorWarningDisabled = disabled;
this->save();
}
bool PorymapConfig::getWarpBehaviorWarningDisabled() {
return this->warpBehaviorWarningDisabled;
}
const QStringList ProjectConfig::versionStrings = {
"pokeruby",
"pokefirered",
@ -843,8 +855,6 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
value.remove(" ");
this->warpBehaviors = value.split(",", Qt::SkipEmptyParts);
this->warpBehaviors.removeDuplicates();
} else if (key == "warp_behavior_warning_disabled") {
this->warpBehaviorWarningDisabled = getConfigBool(key, value);
} else {
logWarn(QString("Invalid config key found in config file %1: '%2'").arg(this->getConfigFilepath()).arg(key));
}
@ -926,14 +936,12 @@ QMap<QString, QString> ProjectConfig::getKeyValueMap() {
if (!path.isEmpty()) map.insert("pokemon_icon_path/" + i.key(), path);
}
for (auto i = this->identifiers.cbegin(), end = this->identifiers.cend(); i != end; i++) {
// TODO: Test to ensure empties aren't output in config
map.insert("ident/"+defaultIdentifiers.value(i.key()).first, i.value());
}
map.insert("collision_sheet_path", this->collisionSheetPath);
map.insert("collision_sheet_width", QString::number(this->collisionSheetWidth));
map.insert("collision_sheet_height", QString::number(this->collisionSheetHeight));
map.insert("warp_behaviors", this->warpBehaviors.join(","));
map.insert("warp_behavior_warning_disabled", QString::number(this->warpBehaviorWarningDisabled));
return map;
}
@ -1396,15 +1404,6 @@ QStringList ProjectConfig::getWarpBehaviors() {
return this->warpBehaviors;
}
void ProjectConfig::setWarpBehaviorWarningDisabled(bool disabled) {
this->warpBehaviorWarningDisabled = disabled;
this->save();
}
bool ProjectConfig::getWarpBehaviorWarningDisabled() {
return this->warpBehaviorWarningDisabled;
}
UserConfig userConfig;

View file

@ -1990,7 +1990,7 @@ void Editor::redrawObject(DraggablePixmapItem *item) {
// Warp events display a warning if they're not positioned on a metatile with a warp behavior.
void Editor::updateWarpEventWarning(Event *event) {
if (projectConfig.getWarpBehaviorWarningDisabled())
if (porymapConfig.getWarpBehaviorWarningDisabled())
return;
if (!project || !map || !event || event->getEventType() != Event::Type::Warp)
return;
@ -2011,7 +2011,7 @@ void Editor::updateWarpEventWarning(Event *event) {
// events when the Events tab is opened. This does not cover the case where metatiles are painted while
// still on the Events tab, such as by Undo/Redo or the scripting API.
void Editor::updateWarpEventWarnings() {
if (projectConfig.getWarpBehaviorWarningDisabled())
if (porymapConfig.getWarpBehaviorWarningDisabled())
return;
if (selected_events) {
for (auto selection : *selected_events)

View file

@ -8,6 +8,8 @@
/*
Editor for the settings in a user's porymap.project.cfg file (and 'use_encounter_json' in porymap.user.cfg).
Disabling the warp behavior warning is actually part of porymap.cfg, but it's on this window because the
related settings are here (and project-specific).
*/
const int ProjectSettingsEditor::eventsTab = 3;
@ -437,7 +439,7 @@ void ProjectSettingsEditor::refresh() {
ui->checkBox_EnableCustomBorderSize->setChecked(projectConfig.getUseCustomBorderSize());
ui->checkBox_OutputCallback->setChecked(projectConfig.getTilesetsHaveCallback());
ui->checkBox_OutputIsCompressed->setChecked(projectConfig.getTilesetsHaveIsCompressed());
ui->checkBox_DisableWarning->setChecked(projectConfig.getWarpBehaviorWarningDisabled());
ui->checkBox_DisableWarning->setChecked(porymapConfig.getWarpBehaviorWarningDisabled());
// Set spin box values
ui->spinBox_Elevation->setValue(projectConfig.getDefaultElevation());
@ -504,7 +506,7 @@ void ProjectSettingsEditor::save() {
projectConfig.setUseCustomBorderSize(ui->checkBox_EnableCustomBorderSize->isChecked());
projectConfig.setTilesetsHaveCallback(ui->checkBox_OutputCallback->isChecked());
projectConfig.setTilesetsHaveIsCompressed(ui->checkBox_OutputIsCompressed->isChecked());
projectConfig.setWarpBehaviorWarningDisabled(ui->checkBox_DisableWarning->isChecked());
porymapConfig.setWarpBehaviorWarningDisabled(ui->checkBox_DisableWarning->isChecked());
// Save spin box settings
projectConfig.setDefaultElevation(ui->spinBox_Elevation->value());