Automatically disable encounters if JSON is missing
This commit is contained in:
parent
b20df82358
commit
096a66067d
4 changed files with 15 additions and 5 deletions
|
@ -418,6 +418,7 @@ private:
|
||||||
void initShortcuts();
|
void initShortcuts();
|
||||||
void initExtraShortcuts();
|
void initExtraShortcuts();
|
||||||
void setProjectSpecificUIVisibility();
|
void setProjectSpecificUIVisibility();
|
||||||
|
void setWildEncountersUIEnabled(bool enabled);
|
||||||
void loadUserSettings();
|
void loadUserSettings();
|
||||||
void applyMapListFilter(QString filterText);
|
void applyMapListFilter(QString filterText);
|
||||||
void restoreWindowState();
|
void restoreWindowState();
|
||||||
|
|
|
@ -244,6 +244,7 @@ signals:
|
||||||
void reloadProject();
|
void reloadProject();
|
||||||
void uncheckMonitorFilesAction();
|
void uncheckMonitorFilesAction();
|
||||||
void mapCacheCleared();
|
void mapCacheCleared();
|
||||||
|
void disableWildEncountersUI();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROJECT_H
|
#endif // PROJECT_H
|
||||||
|
|
|
@ -349,12 +349,15 @@ void MainWindow::markMapEdited() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::setWildEncountersUIEnabled(bool enabled) {
|
||||||
|
ui->actionUse_Encounter_Json->setChecked(enabled);
|
||||||
|
ui->mainTabBar->setTabEnabled(4, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::setProjectSpecificUIVisibility()
|
void MainWindow::setProjectSpecificUIVisibility()
|
||||||
{
|
{
|
||||||
ui->actionUse_Encounter_Json->setChecked(projectConfig.getEncounterJsonActive());
|
|
||||||
ui->actionUse_Poryscript->setChecked(projectConfig.getUsePoryScript());
|
ui->actionUse_Poryscript->setChecked(projectConfig.getUsePoryScript());
|
||||||
|
this->setWildEncountersUIEnabled(projectConfig.getEncounterJsonActive());
|
||||||
ui->mainTabBar->setTabEnabled(4, projectConfig.getEncounterJsonActive());
|
|
||||||
|
|
||||||
switch (projectConfig.getBaseGameVersion())
|
switch (projectConfig.getBaseGameVersion())
|
||||||
{
|
{
|
||||||
|
@ -515,6 +518,7 @@ bool MainWindow::openProject(QString dir) {
|
||||||
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]() { ui->actionMonitor_Project_Files->setChecked(false); });
|
QObject::connect(editor->project, &Project::uncheckMonitorFilesAction, [this]() { ui->actionMonitor_Project_Files->setChecked(false); });
|
||||||
on_actionMonitor_Project_Files_triggered(porymapConfig.getMonitorFiles());
|
on_actionMonitor_Project_Files_triggered(porymapConfig.getMonitorFiles());
|
||||||
editor->project->set_root(dir);
|
editor->project->set_root(dir);
|
||||||
|
|
|
@ -1723,8 +1723,12 @@ bool Project::readWildMonData() {
|
||||||
|
|
||||||
OrderedJson::object wildMonObj;
|
OrderedJson::object wildMonObj;
|
||||||
if (!parser.tryParseOrderedJsonFile(&wildMonObj, wildMonJsonFilepath)) {
|
if (!parser.tryParseOrderedJsonFile(&wildMonObj, wildMonJsonFilepath)) {
|
||||||
logError(QString("Failed to read wild encounters from %1").arg(wildMonJsonFilepath));
|
// Failing to read wild encounters data is not a critical error, just disable the
|
||||||
return false;
|
// encounter editor and log a warning in case the user intended to have this data.
|
||||||
|
projectConfig.setEncounterJsonActive(false);
|
||||||
|
emit disableWildEncountersUI();
|
||||||
|
logWarn(QString("Failed to read wild encounters from %1").arg(wildMonJsonFilepath));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (OrderedJson subObjectRef : wildMonObj["wild_encounter_groups"].array_items()) {
|
for (OrderedJson subObjectRef : wildMonObj["wild_encounter_groups"].array_items()) {
|
||||||
|
|
Loading…
Reference in a new issue