Save summary chart settings in config
This commit is contained in:
parent
6f74909a3c
commit
2ec9012c07
4 changed files with 45 additions and 3 deletions
|
@ -72,6 +72,7 @@ public:
|
||||||
this->monitorFiles = true;
|
this->monitorFiles = true;
|
||||||
this->tilesetCheckerboardFill = true;
|
this->tilesetCheckerboardFill = true;
|
||||||
this->theme = "default";
|
this->theme = "default";
|
||||||
|
this->wildMonChartTheme = "";
|
||||||
this->textEditorOpenFolder = "";
|
this->textEditorOpenFolder = "";
|
||||||
this->textEditorGotoLine = "";
|
this->textEditorGotoLine = "";
|
||||||
this->paletteEditorBitDepth = 24;
|
this->paletteEditorBitDepth = 24;
|
||||||
|
@ -117,6 +118,7 @@ public:
|
||||||
bool monitorFiles;
|
bool monitorFiles;
|
||||||
bool tilesetCheckerboardFill;
|
bool tilesetCheckerboardFill;
|
||||||
QString theme;
|
QString theme;
|
||||||
|
QString wildMonChartTheme;
|
||||||
QString textEditorOpenFolder;
|
QString textEditorOpenFolder;
|
||||||
QString textEditorGotoLine;
|
QString textEditorGotoLine;
|
||||||
int paletteEditorBitDepth;
|
int paletteEditorBitDepth;
|
||||||
|
@ -126,6 +128,7 @@ public:
|
||||||
QDateTime lastUpdateCheckTime;
|
QDateTime lastUpdateCheckTime;
|
||||||
QVersionNumber lastUpdateCheckVersion;
|
QVersionNumber lastUpdateCheckVersion;
|
||||||
QMap<QUrl, QDateTime> rateLimitTimes;
|
QMap<QUrl, QDateTime> rateLimitTimes;
|
||||||
|
QByteArray wildMonChartGeometry;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QString getConfigFilepath() override;
|
virtual QString getConfigFilepath() override;
|
||||||
|
|
|
@ -17,6 +17,8 @@ public:
|
||||||
explicit WildMonChart(QWidget *parent, const EncounterTableModel *table);
|
explicit WildMonChart(QWidget *parent, const EncounterTableModel *table);
|
||||||
~WildMonChart();
|
~WildMonChart();
|
||||||
|
|
||||||
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setTable(const EncounterTableModel *table);
|
void setTable(const EncounterTableModel *table);
|
||||||
void createCharts();
|
void createCharts();
|
||||||
|
|
|
@ -354,6 +354,8 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
|
||||||
this->customScriptsEditorGeometry = bytesFromString(value);
|
this->customScriptsEditorGeometry = bytesFromString(value);
|
||||||
} else if (key == "custom_scripts_editor_state") {
|
} else if (key == "custom_scripts_editor_state") {
|
||||||
this->customScriptsEditorState = bytesFromString(value);
|
this->customScriptsEditorState = bytesFromString(value);
|
||||||
|
} else if (key == "wild_mon_chart_geometry") {
|
||||||
|
this->wildMonChartGeometry = bytesFromString(value);
|
||||||
} else if (key == "metatiles_zoom") {
|
} else if (key == "metatiles_zoom") {
|
||||||
this->metatilesZoom = getConfigInteger(key, value, 10, 100, 30);
|
this->metatilesZoom = getConfigInteger(key, value, 10, 100, 30);
|
||||||
} else if (key == "collision_zoom") {
|
} else if (key == "collision_zoom") {
|
||||||
|
@ -380,6 +382,8 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
|
||||||
this->tilesetCheckerboardFill = getConfigBool(key, value);
|
this->tilesetCheckerboardFill = getConfigBool(key, value);
|
||||||
} else if (key == "theme") {
|
} else if (key == "theme") {
|
||||||
this->theme = value;
|
this->theme = value;
|
||||||
|
} else if (key == "wild_mon_chart_theme") {
|
||||||
|
this->wildMonChartTheme = value;
|
||||||
} else if (key == "text_editor_open_directory") {
|
} else if (key == "text_editor_open_directory") {
|
||||||
this->textEditorOpenFolder = value;
|
this->textEditorOpenFolder = value;
|
||||||
} else if (key == "text_editor_goto_line") {
|
} else if (key == "text_editor_goto_line") {
|
||||||
|
@ -439,6 +443,7 @@ QMap<QString, QString> PorymapConfig::getKeyValueMap() {
|
||||||
map.insert("project_settings_editor_state", stringFromByteArray(this->projectSettingsEditorState));
|
map.insert("project_settings_editor_state", stringFromByteArray(this->projectSettingsEditorState));
|
||||||
map.insert("custom_scripts_editor_geometry", stringFromByteArray(this->customScriptsEditorGeometry));
|
map.insert("custom_scripts_editor_geometry", stringFromByteArray(this->customScriptsEditorGeometry));
|
||||||
map.insert("custom_scripts_editor_state", stringFromByteArray(this->customScriptsEditorState));
|
map.insert("custom_scripts_editor_state", stringFromByteArray(this->customScriptsEditorState));
|
||||||
|
map.insert("wild_mon_chart_geometry", stringFromByteArray(this->wildMonChartGeometry));
|
||||||
map.insert("collision_opacity", QString::number(this->collisionOpacity));
|
map.insert("collision_opacity", QString::number(this->collisionOpacity));
|
||||||
map.insert("collision_zoom", QString::number(this->collisionZoom));
|
map.insert("collision_zoom", QString::number(this->collisionZoom));
|
||||||
map.insert("metatiles_zoom", QString::number(this->metatilesZoom));
|
map.insert("metatiles_zoom", QString::number(this->metatilesZoom));
|
||||||
|
@ -453,6 +458,7 @@ QMap<QString, QString> PorymapConfig::getKeyValueMap() {
|
||||||
map.insert("monitor_files", this->monitorFiles ? "1" : "0");
|
map.insert("monitor_files", this->monitorFiles ? "1" : "0");
|
||||||
map.insert("tileset_checkerboard_fill", this->tilesetCheckerboardFill ? "1" : "0");
|
map.insert("tileset_checkerboard_fill", this->tilesetCheckerboardFill ? "1" : "0");
|
||||||
map.insert("theme", this->theme);
|
map.insert("theme", this->theme);
|
||||||
|
map.insert("wild_mon_chart_theme", this->wildMonChartTheme);
|
||||||
map.insert("text_editor_open_directory", this->textEditorOpenFolder);
|
map.insert("text_editor_open_directory", this->textEditorOpenFolder);
|
||||||
map.insert("text_editor_goto_line", this->textEditorGotoLine);
|
map.insert("text_editor_goto_line", this->textEditorGotoLine);
|
||||||
map.insert("palette_editor_bit_depth", QString::number(this->paletteEditorBitDepth));
|
map.insert("palette_editor_bit_depth", QString::number(this->paletteEditorBitDepth));
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
// TODO: Draw species icons below legend icons?
|
// TODO: Draw species icons below legend icons?
|
||||||
// TODO: Save window size, theme selection in config
|
|
||||||
// TODO: Help button that explains the charts
|
// TODO: Help button that explains the charts
|
||||||
|
|
||||||
static const QString baseWindowTitle = QString("Wild Pokémon Summary Charts");
|
static const QString baseWindowTitle = QString("Wild Pokémon Summary Charts");
|
||||||
|
@ -39,6 +38,18 @@ WildMonChart::WildMonChart(QWidget *parent, const EncounterTableModel *table) :
|
||||||
ui->comboBox_Theme->addItem(i.first, i.second);
|
ui->comboBox_Theme->addItem(i.first, i.second);
|
||||||
connect(ui->comboBox_Theme, &QComboBox::currentTextChanged, this, &WildMonChart::updateTheme);
|
connect(ui->comboBox_Theme, &QComboBox::currentTextChanged, this, &WildMonChart::updateTheme);
|
||||||
|
|
||||||
|
// User's theme choice is saved in the config
|
||||||
|
int configThemeIndex = ui->comboBox_Theme->findText(porymapConfig.wildMonChartTheme);
|
||||||
|
if (configThemeIndex >= 0) {
|
||||||
|
const QSignalBlocker blocker(ui->comboBox_Theme);
|
||||||
|
ui->comboBox_Theme->setCurrentIndex(configThemeIndex);
|
||||||
|
} else {
|
||||||
|
porymapConfig.wildMonChartTheme = ui->comboBox_Theme->currentText();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Re-enable once finished
|
||||||
|
//restoreGeometry(porymapConfig.wildMonChartGeometry);
|
||||||
|
|
||||||
setTable(table);
|
setTable(table);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -238,7 +249,8 @@ void WildMonChart::createSpeciesDistributionChart() {
|
||||||
|
|
||||||
applySpeciesColors(series);
|
applySpeciesColors(series);
|
||||||
|
|
||||||
// TODO: Delete old chart
|
if (ui->chartView_SpeciesDistribution->chart())
|
||||||
|
ui->chartView_SpeciesDistribution->chart()->deleteLater();
|
||||||
ui->chartView_SpeciesDistribution->setChart(chart);
|
ui->chartView_SpeciesDistribution->setChart(chart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,6 +277,17 @@ QBarSet* WildMonChart::createLevelDistributionBarSet(const QString &species, con
|
||||||
QToolTip::showText(QCursor::pos(), text);
|
QToolTip::showText(QCursor::pos(), text);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Clicking on a bar set in the stacked chart opens its individual chart
|
||||||
|
if (!individual) {
|
||||||
|
connect(set, &QBarSet::clicked, [this, species](int) {
|
||||||
|
const QSignalBlocker blocker1(ui->groupBox_Species);
|
||||||
|
const QSignalBlocker blocker2(ui->comboBox_Species);
|
||||||
|
ui->groupBox_Species->setChecked(true);
|
||||||
|
ui->comboBox_Species->setCurrentText(species);
|
||||||
|
createLevelDistributionChart();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,7 +359,9 @@ void WildMonChart::createLevelDistributionChart() {
|
||||||
applySpeciesColors(series);
|
applySpeciesColors(series);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Cache old chart
|
// TODO: Cache old charts?
|
||||||
|
if (ui->chartView_LevelDistribution->chart())
|
||||||
|
ui->chartView_LevelDistribution->chart()->deleteLater();
|
||||||
ui->chartView_LevelDistribution->setChart(chart);
|
ui->chartView_LevelDistribution->setChart(chart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,6 +371,7 @@ QChart::ChartTheme WildMonChart::currentTheme() const {
|
||||||
|
|
||||||
void WildMonChart::updateTheme() {
|
void WildMonChart::updateTheme() {
|
||||||
auto theme = currentTheme();
|
auto theme = currentTheme();
|
||||||
|
porymapConfig.wildMonChartTheme = ui->comboBox_Theme->currentText();
|
||||||
|
|
||||||
// In order to keep the color of each species in the legend consistent across
|
// In order to keep the color of each species in the legend consistent across
|
||||||
// charts we save species->color mappings. The legend colors are overwritten
|
// charts we save species->color mappings. The legend colors are overwritten
|
||||||
|
@ -381,3 +407,8 @@ void WildMonChart::stopChartAnimation() {
|
||||||
if (ui->chartView_SpeciesDistribution->chart())
|
if (ui->chartView_SpeciesDistribution->chart())
|
||||||
ui->chartView_SpeciesDistribution->chart()->setAnimationOptions(QChart::NoAnimation);
|
ui->chartView_SpeciesDistribution->chart()->setAnimationOptions(QChart::NoAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WildMonChart::closeEvent(QCloseEvent *event) {
|
||||||
|
porymapConfig.wildMonChartGeometry = saveGeometry();
|
||||||
|
QWidget::closeEvent(event);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue