mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-20 07:36:31 -05:00
Merge pull request #605 from GriffinRichards/encounter-graph
Add encounter charts
This commit is contained in:
@@ -77,6 +77,7 @@ public:
|
||||
this->monitorFiles = true;
|
||||
this->tilesetCheckerboardFill = true;
|
||||
this->theme = "default";
|
||||
this->wildMonChartTheme = "";
|
||||
this->textEditorOpenFolder = "";
|
||||
this->textEditorGotoLine = "";
|
||||
this->paletteEditorBitDepth = 24;
|
||||
@@ -127,6 +128,7 @@ public:
|
||||
bool monitorFiles;
|
||||
bool tilesetCheckerboardFill;
|
||||
QString theme;
|
||||
QString wildMonChartTheme;
|
||||
QString textEditorOpenFolder;
|
||||
QString textEditorGotoLine;
|
||||
int paletteEditorBitDepth;
|
||||
@@ -136,6 +138,7 @@ public:
|
||||
QDateTime lastUpdateCheckTime;
|
||||
QVersionNumber lastUpdateCheckVersion;
|
||||
QMap<QUrl, QDateTime> rateLimitTimes;
|
||||
QByteArray wildMonChartGeometry;
|
||||
|
||||
protected:
|
||||
virtual QString getConfigFilepath() override;
|
||||
@@ -191,6 +194,7 @@ enum ProjectIdentifier {
|
||||
define_obj_event_count,
|
||||
define_min_level,
|
||||
define_max_level,
|
||||
define_max_encounter_rate,
|
||||
define_tiles_primary,
|
||||
define_tiles_total,
|
||||
define_metatiles_primary,
|
||||
@@ -215,6 +219,7 @@ enum ProjectIdentifier {
|
||||
define_map_section_prefix,
|
||||
define_map_section_empty,
|
||||
define_map_section_count,
|
||||
define_species_prefix,
|
||||
regex_behaviors,
|
||||
regex_obj_event_gfx,
|
||||
regex_items,
|
||||
@@ -229,7 +234,6 @@ enum ProjectIdentifier {
|
||||
regex_sign_facing_directions,
|
||||
regex_trainer_types,
|
||||
regex_music,
|
||||
regex_species,
|
||||
};
|
||||
|
||||
enum ProjectFilePath {
|
||||
@@ -278,6 +282,7 @@ enum ProjectFilePath {
|
||||
global_fieldmap,
|
||||
fieldmap,
|
||||
initial_facing_table,
|
||||
wild_encounter,
|
||||
pokemon_icon_table,
|
||||
pokemon_gfx,
|
||||
};
|
||||
|
||||
@@ -22,9 +22,9 @@ struct WildPokemonHeader {
|
||||
};
|
||||
|
||||
struct EncounterField {
|
||||
QString name;
|
||||
QString name; // Ex: "fishing_mons"
|
||||
QVector<int> encounterRates;
|
||||
tsl::ordered_map<QString, QVector<int>> groups;
|
||||
tsl::ordered_map<QString, QVector<int>> groups; // Ex: "good_rod", {2, 3, 4}
|
||||
};
|
||||
|
||||
typedef QVector<EncounterField> EncounterFields;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "movablerect.h"
|
||||
#include "cursortilerect.h"
|
||||
#include "mapruler.h"
|
||||
#include "encountertablemodel.h"
|
||||
|
||||
class DraggablePixmapItem;
|
||||
class MetatilesPixmapItem;
|
||||
@@ -84,6 +85,7 @@ public:
|
||||
void removeSelectedConnection();
|
||||
void addNewWildMonGroup(QWidget *window);
|
||||
void deleteWildMonGroup();
|
||||
EncounterTableModel* getCurrentWildMonTable();
|
||||
void updateDiveMap(QString mapName);
|
||||
void updateEmergeMap(QString mapName);
|
||||
void setSelectedConnection(MapConnection *connection);
|
||||
@@ -222,7 +224,9 @@ private slots:
|
||||
signals:
|
||||
void objectsChanged();
|
||||
void openConnectedMap(MapConnection*);
|
||||
void wildMonDataChanged();
|
||||
void wildMonTableOpened(EncounterTableModel*);
|
||||
void wildMonTableClosed();
|
||||
void wildMonTableEdited();
|
||||
void warpEventDoubleClicked(QString, int, Event::Group);
|
||||
void currentMetatilesSelectionChanged();
|
||||
void mapRulerStatusChanged(const QString &);
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "preferenceeditor.h"
|
||||
#include "projectsettingseditor.h"
|
||||
#include "customscriptseditor.h"
|
||||
#include "wildmonchart.h"
|
||||
#include "updatepromoter.h"
|
||||
#include "aboutporymap.h"
|
||||
|
||||
@@ -182,7 +183,6 @@ private slots:
|
||||
void onOpenConnectedMap(MapConnection*);
|
||||
void onMapNeedsRedrawing();
|
||||
void onTilesetsSaved(QString, QString);
|
||||
void onWildMonDataChanged();
|
||||
void openNewMapPopupWindow();
|
||||
void onNewMapCreated();
|
||||
void onMapCacheCleared();
|
||||
@@ -290,6 +290,7 @@ private slots:
|
||||
void on_horizontalSlider_CollisionZoom_valueChanged(int value);
|
||||
void on_pushButton_NewWildMonGroup_clicked();
|
||||
void on_pushButton_DeleteWildMonGroup_clicked();
|
||||
void on_pushButton_SummaryChart_clicked();
|
||||
void on_pushButton_ConfigureEncountersJSON_clicked();
|
||||
void on_pushButton_CreatePrefab_clicked();
|
||||
void on_spinBox_SelectedElevation_valueChanged(int elevation);
|
||||
@@ -319,6 +320,7 @@ private:
|
||||
QPointer<UpdatePromoter> updatePromoter = nullptr;
|
||||
QPointer<NetworkAccessManager> networkAccessManager = nullptr;
|
||||
QPointer<AboutPorymap> aboutWindow = nullptr;
|
||||
QPointer<WildMonChart> wildMonChart = nullptr;
|
||||
FilterChildrenProxyModel *mapListProxyModel;
|
||||
QStandardItemModel *mapListModel;
|
||||
QList<QStandardItem*> *mapGroupItemsList;
|
||||
|
||||
@@ -39,7 +39,6 @@ public:
|
||||
QMap<QString, int> mapGroups;
|
||||
QList<QStringList> groupedMapNames;
|
||||
QStringList mapNames;
|
||||
QMap<QString, QVariant> miscConstants;
|
||||
QList<HealLocation> healLocations;
|
||||
QMap<QString, int> healLocationNameToValue;
|
||||
QMap<QString, QString> mapConstantsToMapNames;
|
||||
@@ -79,6 +78,9 @@ public:
|
||||
bool usingAsmTilesets;
|
||||
QString importExportPath;
|
||||
QSet<QString> disabledSettingsNames;
|
||||
int pokemonMinLevel;
|
||||
int pokemonMaxLevel;
|
||||
int maxEncounterRate;
|
||||
bool wildEncountersLoaded;
|
||||
|
||||
void set_root(QString);
|
||||
|
||||
@@ -28,7 +28,9 @@ public:
|
||||
Slot, Group, Species, MinLevel, MaxLevel, EncounterChance, SlotRatio, EncounterRate, Count
|
||||
};
|
||||
|
||||
WildMonInfo encounterData();
|
||||
WildMonInfo encounterData() const { return this->monInfo; }
|
||||
EncounterField encounterField() const { return this->encounterFields.at(this->fieldIndex); }
|
||||
QList<double> percentages() const { return this->slotPercentages; }
|
||||
void resize(int rows, int cols);
|
||||
|
||||
private:
|
||||
|
||||
98
include/ui/wildmonchart.h
Normal file
98
include/ui/wildmonchart.h
Normal file
@@ -0,0 +1,98 @@
|
||||
#ifndef WILDMONCHART_H
|
||||
#define WILDMONCHART_H
|
||||
|
||||
#include "encountertablemodel.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#if __has_include(<QtCharts>)
|
||||
#include <QtCharts>
|
||||
|
||||
namespace Ui {
|
||||
class WildMonChart;
|
||||
}
|
||||
|
||||
class WildMonChart : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WildMonChart(QWidget *parent, const EncounterTableModel *table);
|
||||
~WildMonChart();
|
||||
|
||||
virtual void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
public slots:
|
||||
void setTable(const EncounterTableModel *table);
|
||||
void clearTable();
|
||||
void refresh();
|
||||
|
||||
private:
|
||||
Ui::WildMonChart *ui;
|
||||
const EncounterTableModel *table;
|
||||
|
||||
QStringList groupNames;
|
||||
QStringList groupNamesReversed;
|
||||
QStringList speciesInLegendOrder;
|
||||
QMap<int, QString> tableIndexToGroupName;
|
||||
|
||||
struct LevelRange {
|
||||
int min;
|
||||
int max;
|
||||
};
|
||||
QMap<QString, LevelRange> groupedLevelRanges;
|
||||
|
||||
struct Summary {
|
||||
double speciesFrequency = 0.0;
|
||||
QMap<int, double> levelFrequencies;
|
||||
};
|
||||
typedef QMap<QString, Summary> GroupedData;
|
||||
|
||||
QMap<QString, GroupedData> speciesToGroupedData;
|
||||
QMap<QString, QColor> speciesToColor;
|
||||
|
||||
|
||||
QStringList getSpeciesNamesAlphabetical() const;
|
||||
double getSpeciesFrequency(const QString&, const QString&) const;
|
||||
QMap<int, double> getLevelFrequencies(const QString &, const QString &) const;
|
||||
LevelRange getLevelRange(const QString &, const QString &) const;
|
||||
bool usesGroupLabels() const;
|
||||
|
||||
void clearTableData();
|
||||
void readTable();
|
||||
QChart* createSpeciesDistributionChart();
|
||||
QChart* createLevelDistributionChart();
|
||||
QBarSet* createLevelDistributionBarSet(const QString &, const QString &, bool);
|
||||
void refreshSpeciesDistributionChart();
|
||||
void refreshLevelDistributionChart();
|
||||
|
||||
void saveSpeciesColors(const QList<QBarSet*> &);
|
||||
void applySpeciesColors(const QList<QBarSet*> &);
|
||||
QChart::ChartTheme currentTheme() const;
|
||||
void updateTheme();
|
||||
void limitChartAnimation(QChart*);
|
||||
|
||||
void showHelpDialog();
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
// As of writing our static Qt build for Windows doesn't include the QtCharts module, so we dummy the class out here.
|
||||
// The charts module is additionally excluded from Windows in porymap.pro
|
||||
#define DISABLE_CHARTS_MODULE
|
||||
|
||||
class WildMonChart : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WildMonChart(QWidget *, const EncounterTableModel *) {};
|
||||
~WildMonChart() {};
|
||||
|
||||
public slots:
|
||||
void setTable(const EncounterTableModel *) {};
|
||||
void clearTable() {};
|
||||
void refresh() {};
|
||||
};
|
||||
|
||||
#endif // __has_include(<QtCharts>)
|
||||
|
||||
#endif // WILDMONCHART_H
|
||||
Reference in New Issue
Block a user