mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-12 20:05:55 -05:00
Add search feature to wild pokemon tab
This commit is contained in:
@@ -221,6 +221,7 @@ enum ProjectIdentifier {
|
||||
define_map_section_prefix,
|
||||
define_map_section_empty,
|
||||
define_species_prefix,
|
||||
define_species_empty,
|
||||
regex_behaviors,
|
||||
regex_obj_event_gfx,
|
||||
regex_items,
|
||||
|
||||
@@ -5,10 +5,14 @@
|
||||
#include <QtWidgets>
|
||||
#include "orderedmap.h"
|
||||
|
||||
struct WildPokemon {
|
||||
int minLevel = 5;
|
||||
int maxLevel = 5;
|
||||
QString species = "SPECIES_NONE"; // TODO: Use define_species_prefix
|
||||
class WildPokemon {
|
||||
public:
|
||||
WildPokemon();
|
||||
WildPokemon(int minLevel, int maxLevel, const QString &species);
|
||||
|
||||
int minLevel;
|
||||
int maxLevel;
|
||||
QString species;
|
||||
};
|
||||
|
||||
struct WildMonInfo {
|
||||
@@ -30,7 +34,8 @@ struct EncounterField {
|
||||
typedef QVector<EncounterField> EncounterFields;
|
||||
|
||||
void setDefaultEncounterRate(QString fieldName, int rate);
|
||||
WildMonInfo getDefaultMonInfo(EncounterField field);
|
||||
WildMonInfo getDefaultMonInfo(const EncounterField &field);
|
||||
QVector<double> getWildEncounterPercentages(const EncounterField &field);
|
||||
void combineEncounters(WildMonInfo &to, WildMonInfo from);
|
||||
|
||||
#endif // GUARD_WILDMONINFO_H
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "gridsettings.h"
|
||||
#include "customscriptseditor.h"
|
||||
#include "wildmonchart.h"
|
||||
#include "wildmonsearch.h"
|
||||
#include "updatepromoter.h"
|
||||
#include "aboutporymap.h"
|
||||
#include "mapheaderform.h"
|
||||
@@ -282,6 +283,7 @@ private slots:
|
||||
void on_pushButton_DeleteWildMonGroup_clicked();
|
||||
void on_pushButton_SummaryChart_clicked();
|
||||
void on_pushButton_ConfigureEncountersJSON_clicked();
|
||||
void on_toolButton_WildMonSearch_clicked();
|
||||
void on_pushButton_CreatePrefab_clicked();
|
||||
void on_spinBox_SelectedElevation_valueChanged(int elevation);
|
||||
void on_spinBox_SelectedCollision_valueChanged(int collision);
|
||||
@@ -294,6 +296,7 @@ private slots:
|
||||
void reloadScriptEngine();
|
||||
void on_actionShow_Grid_triggered();
|
||||
void on_actionGrid_Settings_triggered();
|
||||
void openWildMonTable(const QString &mapName, const QString &groupName, const QString &fieldName);
|
||||
|
||||
public:
|
||||
Ui::MainWindow *ui;
|
||||
@@ -321,6 +324,7 @@ private:
|
||||
QPointer<NetworkAccessManager> networkAccessManager = nullptr;
|
||||
QPointer<AboutPorymap> aboutWindow = nullptr;
|
||||
QPointer<WildMonChart> wildMonChart = nullptr;
|
||||
QPointer<WildMonSearch> wildMonSearch = nullptr;
|
||||
|
||||
QAction *undoAction = nullptr;
|
||||
QAction *redoAction = nullptr;
|
||||
|
||||
@@ -152,6 +152,7 @@ public:
|
||||
QVector<poryjson::Json::object> extraEncounterGroups;
|
||||
|
||||
bool readSpeciesIconPaths();
|
||||
QPixmap getSpeciesIcon(const QString &species) const;
|
||||
QMap<QString, QString> speciesToIconPath;
|
||||
|
||||
void addNewMapsec(const QString &idName);
|
||||
@@ -238,6 +239,7 @@ public:
|
||||
static QString getEmptyMapDefineName();
|
||||
static QString getDynamicMapDefineName();
|
||||
static QString getDynamicMapName();
|
||||
static QString getEmptySpeciesName();
|
||||
static int getNumTilesPrimary();
|
||||
static int getNumTilesTotal();
|
||||
static int getNumMetatilesPrimary();
|
||||
|
||||
@@ -14,7 +14,7 @@ class EncounterTableModel : public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EncounterTableModel(WildMonInfo monInfo, EncounterFields allFields, int fieldIndex, QObject *parent = nullptr);
|
||||
EncounterTableModel(const WildMonInfo &monInfo, const EncounterField &field, QObject *parent = nullptr);
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
@@ -28,22 +28,17 @@ public:
|
||||
Slot, Group, Species, MinLevel, MaxLevel, EncounterChance, SlotRatio, EncounterRate, Count
|
||||
};
|
||||
|
||||
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);
|
||||
WildMonInfo encounterData() const { return m_monInfo; }
|
||||
EncounterField encounterField() const { return m_encounterField; }
|
||||
QList<double> percentages() const { return m_slotPercentages; }
|
||||
|
||||
private:
|
||||
WildMonInfo monInfo;
|
||||
EncounterFields encounterFields;
|
||||
int fieldIndex;
|
||||
|
||||
int numRows = 0;
|
||||
int numCols = 0;
|
||||
|
||||
QVector<int> slotRatios;
|
||||
QList<QString> groupNames;
|
||||
QList<double> slotPercentages;
|
||||
int m_numRows = 0;
|
||||
int m_numCols = 0;
|
||||
WildMonInfo m_monInfo;
|
||||
EncounterField m_encounterField;
|
||||
QMap<int,QString> m_groupNames;
|
||||
QList<double> m_slotPercentages;
|
||||
|
||||
signals:
|
||||
void edited();
|
||||
|
||||
@@ -27,6 +27,8 @@ public:
|
||||
void copy(int index);
|
||||
void paste(int index);
|
||||
|
||||
void setCurrentField(const QString &fieldName);
|
||||
|
||||
public slots:
|
||||
void setTabActive(int index, bool active = true);
|
||||
void deactivateTab(int tabIndex);
|
||||
@@ -38,6 +40,7 @@ private:
|
||||
QVector<bool> activeTabs;
|
||||
QVector<QPushButton *> addDeleteTabButtons;
|
||||
QVector<QPushButton *> copyTabButtons;
|
||||
QMap<QString,int> fieldNameToIndex;
|
||||
|
||||
Editor *editor;
|
||||
};
|
||||
|
||||
47
include/ui/wildmonsearch.h
Normal file
47
include/ui/wildmonsearch.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef WILDMONSEARCH_H
|
||||
#define WILDMONSEARCH_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class Project;
|
||||
|
||||
namespace Ui {
|
||||
class WildMonSearch;
|
||||
}
|
||||
|
||||
class WildMonSearch : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WildMonSearch(Project *project, QWidget *parent = nullptr);
|
||||
~WildMonSearch();
|
||||
|
||||
void refresh();
|
||||
|
||||
signals:
|
||||
void openWildMonTableRequested(const QString &mapName, const QString &groupName, const QString &fieldName);
|
||||
|
||||
private:
|
||||
struct RowData {
|
||||
QString mapName;
|
||||
QString groupName;
|
||||
QString fieldName;
|
||||
QString levelRange;
|
||||
QString chance;
|
||||
};
|
||||
|
||||
Ui::WildMonSearch *ui;
|
||||
Project *const project;
|
||||
QMap<QString,QMap<int,QString>> percentageStrings;
|
||||
QMap<QString,QList<RowData>> resultsCache;
|
||||
|
||||
void addTableEntry(const RowData &rowData);
|
||||
QList<RowData> search(const QString &species) const;
|
||||
void updatePercentageStrings();
|
||||
void updateResults(const QString &species);
|
||||
void cellDoubleClicked(int row, int column);
|
||||
|
||||
};
|
||||
|
||||
#endif // WILDMONSEARCH_H
|
||||
Reference in New Issue
Block a user