diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui
index 36f07e34..386c790e 100644
--- a/forms/mainwindow.ui
+++ b/forms/mainwindow.ui
@@ -2710,14 +2710,8 @@
-
- 0
+ -1
-
-
- Land Mons
-
-
-
diff --git a/include/core/wildmoninfo.h b/include/core/wildmoninfo.h
index de24cbcc..3845a52a 100644
--- a/include/core/wildmoninfo.h
+++ b/include/core/wildmoninfo.h
@@ -16,16 +16,22 @@ struct WildMonInfo {
QVector wildPokemon;
};
+// for extensibility, make a QVector
+// or QMap
struct WildPokemonHeader {
WildMonInfo landMons;
WildMonInfo waterMons;
WildMonInfo rockSmashMons;
WildMonInfo fishingMons;
+
+ QMap wildMons;
};
class Project;
QWidget *newSpeciesTableEntry(Project *project, WildPokemon mon, int index);
void createSpeciesTableRow(Project *, QTableWidget *, WildPokemon, int);
void clearTabWidget(QLayout *tab);
+void clearTable(QTableWidget *table);
+void populateWildMonTabWidget(QTabWidget *tabWidget, QVector fields);
#endif // GUARD_WILDMONINFO_H
diff --git a/include/editor.h b/include/editor.h
index 002c9302..21647f9e 100644
--- a/include/editor.h
+++ b/include/editor.h
@@ -56,6 +56,7 @@ public:
void displayMapConnections();
void displayMapBorder();
void displayMapGrid();
+ void displayWildMonTables();
void setEditingMap();
void setEditingCollision();
diff --git a/include/project.h b/include/project.h
index 83bc89db..e7b455a7 100644
--- a/include/project.h
+++ b/include/project.h
@@ -89,6 +89,7 @@ public:
// when saving, preserve the extra fields for gBattlePyramidWildMonHeaders, gBattlePikeWildMonHeaders
void readSpeciesIconPaths();
QMap speciesToIconPath;
+ QVector wildMonFields;
QMap getTopLevelMapFields();
bool loadMapData(Map*);
diff --git a/src/core/wildmoninfo.cpp b/src/core/wildmoninfo.cpp
index 509e01bd..d900f61e 100644
--- a/src/core/wildmoninfo.cpp
+++ b/src/core/wildmoninfo.cpp
@@ -18,6 +18,11 @@ void clearTabWidget(QLayout *tab) {
if (item) tab->removeItem(item);
}
+void clearTable(QTableWidget *table) {
+ //
+ if (table) table->clear();
+}
+
void createSpeciesTableRow(Project *project, QTableWidget *table, WildPokemon mon, int index) {
//
@@ -70,57 +75,64 @@ void createSpeciesTableRow(Project *project, QTableWidget *table, WildPokemon mo
table->setCellWidget(index - 1, 4, percentLabel);
}
-
-//
-QWidget *newSpeciesTableEntry(Project *project, WildPokemon mon, int index) {
-
- QMap landPercentages = QMap({
- {1, "20"}, {2, "20"},
- {3, "10"}, {4, "10"}, {5, "10"}, {6, "10"},
- {7, "5"}, {8, "5"},
- {9, "4"}, {10, "4"},
- {11, "1"}, {12, "1"}
- });
-
+// tabWidget_WildMons
+void populateWildMonTabWidget(QTabWidget *tabWidget, QVector fields) {
//
- QHBoxLayout *speciesHBox = new QHBoxLayout;
- QTableWidgetItem *monItem = new QTableWidgetItem();
-
- QPixmap monIcon = QPixmap(project->speciesToIconPath.value(mon.species)).copy(0, 0, 32, 32);
-
- QLabel *monNum = new QLabel(QString("%1.").arg(QString::number(index)));
-
- QLabel *monLabel = new QLabel();
- monLabel->setPixmap(monIcon);
-
- QComboBox *monSelector = new QComboBox;
- monSelector->addItems(project->speciesToIconPath.keys());
- monSelector->setCurrentText(mon.species);
- monSelector->setEditable(true);
-
- QObject::connect(monSelector, &QComboBox::currentTextChanged, [=](QString newSpecies){
- QPixmap monIcon = QPixmap(project->speciesToIconPath.value(newSpecies)).copy(0, 0, 32, 32);
- monLabel->setPixmap(monIcon);
+ QPushButton *newTabButton = new QPushButton("New Field");
+ QObject::connect(newTabButton, &QPushButton::clicked, [=](){
+ qDebug() << "new field pressed";
});
+ tabWidget->setCornerWidget(newTabButton);
- QSpinBox *minLevel = new QSpinBox;
- QSpinBox *maxLevel = new QSpinBox;
- minLevel->setMinimum(1);
- minLevel->setMaximum(100);
- maxLevel->setMinimum(1);
- maxLevel->setMaximum(100);
- minLevel->setValue(mon.minLevel);
- maxLevel->setValue(mon.maxLevel);
-
- // percentage
- QLabel *percentLabel = new QLabel(landPercentages[index]);
-
- speciesHBox->addWidget(monNum);
- speciesHBox->addWidget(monLabel);
- speciesHBox->addWidget(monSelector);
- speciesHBox->addWidget(minLevel);
- speciesHBox->addWidget(maxLevel);
- speciesHBox->addWidget(percentLabel);
-
- return (QWidget *)speciesHBox;
+ // change this to for each entry in header
+ //if (true) {//header.landMons.active) {
+ for (QString field : fields) {
+ //
+ tabWidget->addTab(new QTableWidget(), field);
+ }
}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/editor.cpp b/src/editor.cpp
index c7bf03b8..fede786f 100644
--- a/src/editor.cpp
+++ b/src/editor.cpp
@@ -151,6 +151,10 @@ void Editor::setEditingConnections() {
}
void Editor::setEditingWildMons() {
+ // nothing for now
+}
+
+void Editor::displayWildMonTables() {
// clear the current layout
//
// move to loadMap? no because loadMap calls this anyways if it's open
@@ -161,39 +165,61 @@ void Editor::setEditingWildMons() {
//QFrame *landMonFrame = ui->frame_LandMonInfo;
- QLayout *landMonTab = ui->tab_LandMons->layout();
+ //QTabWidget *tabWidgetWildMons = ui->tabWidget_WildMons;
- QTableWidget *landMonTable = new QTableWidget;//ui->tableWidget_RockSmashMonInfo;
+ //QLayout *landMonTab = ui->tabWidget_WildMons->widget(0)->layout();//new QGridLayout(ui->tabWidget_WildMons->findChild("land_mons"));
+ //ui->tabWidget_WildMons->widget(0)->layout();
+ //findChild("land_mons")->layout();
+ //tabWidgetWildMons->widget(0)->layout();
+ //ui->tab_LandMons->layout();
+
+ //if (!landMonTab) qDebug() << "landMonTab is nullptr!";
+
+ //return;
+
+ //QTableWidget *landMonTable = static_cast(ui->tabWidget_WildMons->widget(0));//landMonTab->findChild();//ui->tabWidget_WildMons->findChild("land_mons");
+ //new QTableWidget;//ui->tableWidget_RockSmashMonInfo;
+
+ //return;
- clearTabWidget(landMonTab);
+ //clearTabWidget(landMonTab);
+ //clearTable(landMonTable);
//QGridLayout *gridLayout = new QGridLayout(landMonFrame);
- landMonTab->addWidget(landMonTable);
+ //landMonTab->addWidget(landMonTable);
//if (!landMonTable)
//for (auto mon : project->wildMonData.value(map->constantName))
WildPokemonHeader header = project->wildMonData.value(map->constantName);
- if (header.landMons.active) { // else,
- int i = 1;
+ //QString field = "land_mons";
- landMonTable->setRowCount(header.landMons.wildPokemon.size());
- landMonTable->setColumnCount(5);// + 1 for last column stretch
+ int tabIndex = 0;
+ for (QString field : project->wildMonFields) {
+ QTableWidget *speciesTable = static_cast(ui->tabWidget_WildMons->widget(tabIndex));
+ clearTable(speciesTable);
+ if (header.wildMons[field].active) {//header.landMons.active) { // else,
+ int i = 1;
- QStringList landMonTableHeaders;
- landMonTableHeaders << "Index" << "Species" << "Min Level" << "Max Level" << "Catch Percentage";
- landMonTable->setHorizontalHeaderLabels(landMonTableHeaders);
- landMonTable->verticalHeader()->hide();
- landMonTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
- landMonTable->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
+ speciesTable->setRowCount(header.wildMons[field].wildPokemon.size());
+ speciesTable->setColumnCount(5);// + 1 for last column stretch
- landMonTable->setShowGrid(false);
+ QStringList landMonTableHeaders;
+ landMonTableHeaders << "Index" << "Species" << "Min Level" << "Max Level" << "Catch Percentage";
+ speciesTable->setHorizontalHeaderLabels(landMonTableHeaders);
+ speciesTable->verticalHeader()->hide();
+ speciesTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
+ speciesTable->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
- for (WildPokemon mon : header.landMons.wildPokemon) {
- createSpeciesTableRow(project, landMonTable, mon, i);
- i++;
+ speciesTable->setShowGrid(false);
+
+ for (WildPokemon mon : header.wildMons[field].wildPokemon) {
+ createSpeciesTableRow(project, speciesTable, mon, i);
+ i++;
+ }
}
+ tabIndex++;
}
}
@@ -652,6 +678,7 @@ void Editor::displayMap() {
displayMapConnections();
displayMapBorder();
displayMapGrid();
+ displayWildMonTables();
this->playerViewRect->setZValue(1000);
this->cursorMapTileRect->setZValue(1001);
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 5cca1e11..a9570074 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -261,11 +261,13 @@ bool MainWindow::openProject(QString dir) {
setWindowTitle(editor->project->getProjectTitle());
loadDataStructures();
populateMapList();
+ populateWildMonTabWidget(ui->tabWidget_WildMons, editor->project->wildMonFields);
success = setMap(getDefaultMap(), true);
} else {
setWindowTitle(editor->project->getProjectTitle());
loadDataStructures();
populateMapList();
+ populateWildMonTabWidget(ui->tabWidget_WildMons, editor->project->wildMonFields);
}
if (success) {
@@ -1086,7 +1088,7 @@ void MainWindow::on_tabWidget_currentChanged(int index)
} else if (index == 3) {
editor->setEditingConnections();
} else if (index == 4) {
- editor->setEditingWildMons();
+ //editor->setEditingWildMons();
}
}
diff --git a/src/project.cpp b/src/project.cpp
index 7ce40962..575c8c5f 100644
--- a/src/project.cpp
+++ b/src/project.cpp
@@ -1320,6 +1320,11 @@ void Project::readWildMonData() {
QJsonObject subObject = subObjectRef.toObject();
if (!subObject["for_maps"].toBool()) continue;
+ // fill wildMonFields
+ for (auto field : subObject["fields"].toArray()) {
+ wildMonFields.append(field.toString());
+ }
+
//qDebug() << subObject["label"].toString();
QJsonArray encounters = subObject["encounters"].toArray();
for (QJsonValue encounter : encounters) {
@@ -1330,6 +1335,22 @@ void Project::readWildMonData() {
WildPokemonHeader header;
+ for (QString field : wildMonFields) {
+ //
+ if (encounter[field] != QJsonValue::Undefined) {
+ header.wildMons[field].active = true;
+ header.wildMons[field].encounterRate = encounter[field]["encounter_rate"].toInt();
+ for (QJsonValue mon : encounter[field]["mons"].toArray()) {
+ header.wildMons[field].wildPokemon.append({
+ mon["min_level"].toInt(),
+ mon["max_level"].toInt(),
+ mon["species"].toString()
+ });
+ }
+ }
+ }
+
+ /*
// land_mons, water_mons, rock_smash_mons, fishing_mons
if (encounter["land_mons"] != QJsonValue::Undefined) {
header.landMons.active = true;
@@ -1375,6 +1396,7 @@ void Project::readWildMonData() {
});
}
}
+ */
wildMonData.insert(mapConstant, header);
}