mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-13 04:15:45 -05:00
Add search feature to wild pokemon tab
This commit is contained in:
@@ -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