add json saving to wild encounter editor
This commit is contained in:
parent
4b0e0b0bff
commit
5a62df9f55
8 changed files with 309 additions and 66 deletions
|
@ -2701,17 +2701,79 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="frame_WildMonInfo">
|
<widget class="QFrame" name="frame_WildMonInfo">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::NoFrame</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Raised</enum>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_12">
|
||||||
<item row="0" column="0">
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget_WildMons">
|
<widget class="QFrame" name="frame_2">
|
||||||
<property name="currentIndex">
|
<property name="frameShape">
|
||||||
<number>-1</number>
|
<enum>QFrame::NoFrame</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_10">
|
||||||
|
<property name="text">
|
||||||
|
<string>Group</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBox_EncounterGroupLabel">
|
||||||
|
<property name="sizeAdjustPolicy">
|
||||||
|
<enum>QComboBox::AdjustToContents</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton_NewWildMonGroup">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>Create a new group for wild pokemon data on this map.</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../resources/images.qrc">
|
||||||
|
<normaloff>:/icons/add.ico</normaloff>:/icons/add.ico</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="flat">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_9">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton_ConfigureEncountersJSON">
|
||||||
|
<property name="text">
|
||||||
|
<string>Configure JSON...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QStackedWidget" name="stackedWidget_WildMons">
|
||||||
|
<widget class="QWidget" name="page"/>
|
||||||
|
<widget class="QWidget" name="page_2"/>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -43,6 +43,8 @@ public:
|
||||||
void redo();
|
void redo();
|
||||||
void closeProject();
|
void closeProject();
|
||||||
bool setMap(QString map_name);
|
bool setMap(QString map_name);
|
||||||
|
void saveUiFields();
|
||||||
|
void saveEncounterTabData();
|
||||||
void displayMap();
|
void displayMap();
|
||||||
void displayMetatileSelector();
|
void displayMetatileSelector();
|
||||||
void displayMapMetatiles();
|
void displayMapMetatiles();
|
||||||
|
@ -71,6 +73,7 @@ public:
|
||||||
void setConnectionMap(QString mapName);
|
void setConnectionMap(QString mapName);
|
||||||
void addNewConnection();
|
void addNewConnection();
|
||||||
void removeCurrentConnection();
|
void removeCurrentConnection();
|
||||||
|
void addNewWildMonGroup();
|
||||||
void updateDiveMap(QString mapName);
|
void updateDiveMap(QString mapName);
|
||||||
void updateEmergeMap(QString mapName);
|
void updateEmergeMap(QString mapName);
|
||||||
void setSelectedConnectionFromMap(QString mapName);
|
void setSelectedConnectionFromMap(QString mapName);
|
||||||
|
@ -78,6 +81,7 @@ public:
|
||||||
void updateSecondaryTileset(QString tilesetLabel, bool forceLoad = false);
|
void updateSecondaryTileset(QString tilesetLabel, bool forceLoad = false);
|
||||||
void toggleBorderVisibility(bool visible);
|
void toggleBorderVisibility(bool visible);
|
||||||
void updateCustomMapHeaderValues(QTableWidget *);
|
void updateCustomMapHeaderValues(QTableWidget *);
|
||||||
|
void configureEncounterJSON();
|
||||||
Tileset *getCurrentMapPrimaryTileset();
|
Tileset *getCurrentMapPrimaryTileset();
|
||||||
|
|
||||||
DraggablePixmapItem *addMapEvent(Event *event);
|
DraggablePixmapItem *addMapEvent(Event *event);
|
||||||
|
|
|
@ -145,6 +145,8 @@ private slots:
|
||||||
void on_pushButton_DeleteCustomHeaderField_clicked();
|
void on_pushButton_DeleteCustomHeaderField_clicked();
|
||||||
void on_tableWidget_CustomHeaderFields_cellChanged(int row, int column);
|
void on_tableWidget_CustomHeaderFields_cellChanged(int row, int column);
|
||||||
void on_horizontalSlider_MetatileZoom_valueChanged(int value);
|
void on_horizontalSlider_MetatileZoom_valueChanged(int value);
|
||||||
|
void on_pushButton_NewWildMonGroup_clicked();
|
||||||
|
void on_pushButton_ConfigureEncountersJSON_clicked();
|
||||||
|
|
||||||
void on_actionRegion_Map_Editor_triggered();
|
void on_actionRegion_Map_Editor_triggered();
|
||||||
|
|
||||||
|
|
|
@ -87,8 +87,8 @@ public:
|
||||||
QString readMapLocation(QString map_name);
|
QString readMapLocation(QString map_name);
|
||||||
|
|
||||||
void readWildMonData();
|
void readWildMonData();
|
||||||
QMap<QString, WildPokemonHeader> wildMonData;// "MAP_CONSTANT": wild_encounter_json
|
QMap<QString, QMap<QString, WildPokemonHeader>> wildMonData;// "MAP_CONSTANT": {base_label: wild_encounter_json
|
||||||
QMap<QString, QString> encounterMapToBaseLabel;
|
QMap<QString, QString> encounterMapToBaseLabel;// delete this?
|
||||||
// when saving, preserve the extra fields for gBattlePyramidWildMonHeaders, gBattlePikeWildMonHeaders
|
// when saving, preserve the extra fields for gBattlePyramidWildMonHeaders, gBattlePikeWildMonHeaders
|
||||||
void readSpeciesIconPaths();
|
void readSpeciesIconPaths();
|
||||||
QMap<QString, QString> speciesToIconPath;
|
QMap<QString, QString> speciesToIconPath;
|
||||||
|
|
|
@ -87,15 +87,19 @@ void createSpeciesTableRow(Project *project, QTableWidget *table, WildPokemon mo
|
||||||
table->setCellWidget(index - 1, 2, minLevelFrame);
|
table->setCellWidget(index - 1, 2, minLevelFrame);
|
||||||
table->setCellWidget(index - 1, 3, maxLevelFrame);
|
table->setCellWidget(index - 1, 3, maxLevelFrame);
|
||||||
table->setCellWidget(index - 1, 4, percentLabel);
|
table->setCellWidget(index - 1, 4, percentLabel);
|
||||||
|
|
||||||
|
// TODO: lock max spinbox to min spinbox
|
||||||
}
|
}
|
||||||
|
|
||||||
void populateWildMonTabWidget(QTabWidget *tabWidget, QVector<QPair<QString, QVector<int>>> fields) {
|
void populateWildMonTabWidget(QTabWidget *tabWidget, QVector<QPair<QString, QVector<int>>> fields) {
|
||||||
QPushButton *newTabButton = new QPushButton("Configure JSON...");
|
//QPushButton *newTabButton = new QPushButton("Configure JSON...");
|
||||||
QObject::connect(newTabButton, &QPushButton::clicked, [=](){
|
//QObject::connect(newTabButton, &QPushButton::clicked, [=](){
|
||||||
// TODO
|
// // TODO
|
||||||
qDebug() << "configure json pressed";
|
// qDebug() << "configure json pressed";
|
||||||
});
|
//});
|
||||||
tabWidget->setCornerWidget(newTabButton);
|
//tabWidget->setCornerWidget(newTabButton);
|
||||||
|
|
||||||
|
// delete everything in the tab widget here? no
|
||||||
|
|
||||||
for (QPair<QString, QVector<int>> field : fields) {
|
for (QPair<QString, QVector<int>> field : fields) {
|
||||||
QTableWidget *table = new QTableWidget;
|
QTableWidget *table = new QTableWidget;
|
||||||
|
|
193
src/editor.cpp
193
src/editor.cpp
|
@ -24,6 +24,7 @@ Editor::Editor(Ui::MainWindow* ui)
|
||||||
|
|
||||||
void Editor::saveProject() {
|
void Editor::saveProject() {
|
||||||
if (project) {
|
if (project) {
|
||||||
|
saveUiFields();
|
||||||
project->saveAllMaps();
|
project->saveAllMaps();
|
||||||
project->saveAllDataStructures();
|
project->saveAllDataStructures();
|
||||||
}
|
}
|
||||||
|
@ -31,11 +32,17 @@ void Editor::saveProject() {
|
||||||
|
|
||||||
void Editor::save() {
|
void Editor::save() {
|
||||||
if (project && map) {
|
if (project && map) {
|
||||||
|
saveUiFields();
|
||||||
project->saveMap(map);
|
project->saveMap(map);
|
||||||
project->saveAllDataStructures();
|
project->saveAllDataStructures();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Editor::saveUiFields() {
|
||||||
|
//
|
||||||
|
saveEncounterTabData();
|
||||||
|
}
|
||||||
|
|
||||||
void Editor::undo() {
|
void Editor::undo() {
|
||||||
if (current_view && map_item->paintingEnabled) {
|
if (current_view && map_item->paintingEnabled) {
|
||||||
map->undo();
|
map->undo();
|
||||||
|
@ -154,60 +161,166 @@ void Editor::setEditingWildMons() {
|
||||||
// nothing for now
|
// nothing for now
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: figure out why this is being called twice
|
||||||
void Editor::displayWildMonTables() {
|
void Editor::displayWildMonTables() {
|
||||||
WildPokemonHeader header = project->wildMonData.value(map->constantName);
|
QStackedWidget *stack = ui->stackedWidget_WildMons;
|
||||||
|
QComboBox *labelCombo = ui->comboBox_EncounterGroupLabel;
|
||||||
|
// TODO: temp. instead do a for loop here
|
||||||
|
//WildPokemonHeader header = project->wildMonData.value(map->constantName).first();
|
||||||
|
|
||||||
int tabIndex = 0;
|
// TODO: return when there is no data for the map
|
||||||
for (QPair<QString, QVector<int>> monField : project->wildMonFields) {
|
while (stack->count()) {
|
||||||
QString field = monField.first;
|
//
|
||||||
QTableWidget *speciesTable = static_cast<QTableWidget *>(ui->tabWidget_WildMons->widget(tabIndex++));
|
QWidget *oldWidget = stack->widget(0);
|
||||||
clearTable(speciesTable);
|
stack->removeWidget(oldWidget);
|
||||||
//speciesTable->horizontalHeader()->hide();
|
delete oldWidget;
|
||||||
|
}
|
||||||
|
|
||||||
if (project->wildMonData.contains(map->constantName) && header.wildMons[field].active) {
|
labelCombo->clear();
|
||||||
int i = 1;
|
|
||||||
|
|
||||||
speciesTable->setRowCount(header.wildMons[field].wildPokemon.size());
|
if (!project->wildMonData.contains(map->constantName)) {
|
||||||
speciesTable->setColumnCount(6);// TODO: stretch last column?
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList landMonTableHeaders;
|
// do I have to disconnect this signal? or set it up only once?
|
||||||
landMonTableHeaders << "Index" << "Species" << "Min Level" << "Max Level" << "Index Percentage" << "Encounter Rate";
|
connect(labelCombo, QOverload<int>::of(&QComboBox::activated), [=](int index){
|
||||||
speciesTable->setHorizontalHeaderLabels(landMonTableHeaders);
|
stack->setCurrentIndex(index);//setCurrentWidget(tabWidget);
|
||||||
speciesTable->horizontalHeader()->show();
|
});
|
||||||
speciesTable->verticalHeader()->hide();
|
labelCombo->addItems(project->wildMonData[map->constantName].keys());
|
||||||
speciesTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
labelCombo->setCurrentText(project->wildMonData[map->constantName].firstKey());
|
||||||
speciesTable->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
|
||||||
|
|
||||||
speciesTable->setShowGrid(false);
|
// TODO: instance of this map, use .value()
|
||||||
|
for (int labelIndex = 0; labelIndex < project->wildMonData[map->constantName].keys().size(); labelIndex++) {
|
||||||
|
|
||||||
// set encounter rate slider
|
QString label = project->wildMonData.value(map->constantName).keys().at(labelIndex);
|
||||||
// don't forget to add number label next to it
|
|
||||||
QFrame *encounterFrame = new QFrame;
|
|
||||||
QHBoxLayout *encounterLayout = new QHBoxLayout;
|
|
||||||
|
|
||||||
QSlider *encounterRate = new QSlider(Qt::Horizontal);
|
WildPokemonHeader header = project->wildMonData.value(map->constantName).value(label);
|
||||||
encounterRate->setMinimum(1);
|
|
||||||
encounterRate->setMaximum(100);
|
|
||||||
|
|
||||||
QLabel *encounterLabel = new QLabel;
|
//QTableWidget *speciesTable = new QTableWidget;
|
||||||
connect(encounterRate, &QSlider::valueChanged, [=](int value){
|
//clearTable(speciesTable);
|
||||||
encounterLabel->setText(QString::number(value));
|
QTabWidget *tabWidget = new QTabWidget;
|
||||||
});
|
stack->insertWidget(labelIndex, tabWidget);
|
||||||
encounterRate->setValue(header.wildMons[field].encounterRate);
|
populateWildMonTabWidget(tabWidget, project->wildMonFields);
|
||||||
|
//stack->setCurrentWidget(tabWidget);
|
||||||
|
|
||||||
encounterLayout->addWidget(encounterLabel);
|
int tabIndex = 0;
|
||||||
encounterLayout->addWidget(encounterRate);
|
for (QPair<QString, QVector<int>> monField : project->wildMonFields) {
|
||||||
|
QString field = monField.first;
|
||||||
|
|
||||||
encounterFrame->setLayout(encounterLayout);
|
// tabWidget_WildMons
|
||||||
|
QTableWidget *speciesTable = static_cast<QTableWidget *>(tabWidget->widget(tabIndex++));//static_cast<QTableWidget *>(ui->tabWidget_WildMons->widget(tabIndex++));
|
||||||
|
clearTable(speciesTable);
|
||||||
|
//speciesTable->horizontalHeader()->hide();
|
||||||
|
|
||||||
speciesTable->setCellWidget(0, 5, encounterFrame);
|
if (project->wildMonData.contains(map->constantName) && header.wildMons[field].active) {
|
||||||
|
int i = 1;
|
||||||
|
|
||||||
for (WildPokemon mon : header.wildMons[field].wildPokemon) {
|
//ui->stackedWidget_WildMons->insertWidget(0, speciesTable);
|
||||||
createSpeciesTableRow(project, speciesTable, mon, i, field);
|
//return;
|
||||||
i++;
|
|
||||||
|
speciesTable->setRowCount(header.wildMons[field].wildPokemon.size());
|
||||||
|
speciesTable->setColumnCount(6);// TODO: stretch last column?
|
||||||
|
|
||||||
|
QStringList landMonTableHeaders;
|
||||||
|
landMonTableHeaders << "Index" << "Species" << "Min Level" << "Max Level" << "Index Percentage" << "Encounter Rate";
|
||||||
|
speciesTable->setHorizontalHeaderLabels(landMonTableHeaders);
|
||||||
|
speciesTable->horizontalHeader()->show();
|
||||||
|
speciesTable->verticalHeader()->hide();
|
||||||
|
speciesTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
|
speciesTable->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
|
|
||||||
|
speciesTable->setShowGrid(false);
|
||||||
|
|
||||||
|
// set encounter rate slider
|
||||||
|
// don't forget to add number label next to it
|
||||||
|
QFrame *encounterFrame = new QFrame;
|
||||||
|
QHBoxLayout *encounterLayout = new QHBoxLayout;
|
||||||
|
|
||||||
|
QSlider *encounterRate = new QSlider(Qt::Horizontal);
|
||||||
|
encounterRate->setMinimum(1);
|
||||||
|
encounterRate->setMaximum(100);
|
||||||
|
|
||||||
|
QLabel *encounterLabel = new QLabel;
|
||||||
|
connect(encounterRate, &QSlider::valueChanged, [=](int value){
|
||||||
|
encounterLabel->setText(QString::number(value));
|
||||||
|
});
|
||||||
|
encounterRate->setValue(header.wildMons[field].encounterRate);
|
||||||
|
|
||||||
|
encounterLayout->addWidget(encounterLabel);
|
||||||
|
encounterLayout->addWidget(encounterRate);
|
||||||
|
|
||||||
|
encounterFrame->setLayout(encounterLayout);
|
||||||
|
|
||||||
|
speciesTable->setCellWidget(0, 5, encounterFrame);
|
||||||
|
|
||||||
|
for (WildPokemon mon : header.wildMons[field].wildPokemon) {
|
||||||
|
createSpeciesTableRow(project, speciesTable, mon, i, field);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// create button to add this field to this map
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
// create button to add this field to this map
|
}
|
||||||
|
stack->setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: move this funciton
|
||||||
|
void Editor::addNewWildMonGroup() {
|
||||||
|
//
|
||||||
|
qDebug() << "new wild encounter group to map" << map->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Editor::configureEncounterJSON() {
|
||||||
|
//
|
||||||
|
qDebug() << "configure wild encounter json";
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: move this?
|
||||||
|
void Editor::saveEncounterTabData() {
|
||||||
|
if (!project->wildMonData.contains(map->constantName)) {
|
||||||
|
qDebug() << "don't save encounters for this map";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
QStackedWidget *stack = ui->stackedWidget_WildMons;
|
||||||
|
QComboBox *labelCombo = ui->comboBox_EncounterGroupLabel;
|
||||||
|
|
||||||
|
// TODO: verify that this exists before accsessing so no seg fault
|
||||||
|
QMap<QString, WildPokemonHeader> &encounterMap = project->wildMonData[map->constantName];
|
||||||
|
|
||||||
|
for (int groupIndex = 0; groupIndex < encounterMap.keys().size(); groupIndex++) {
|
||||||
|
//
|
||||||
|
QTabWidget *tabWidget = static_cast<QTabWidget *>(stack->widget(groupIndex));
|
||||||
|
|
||||||
|
// TODO: verify this exists before so no segfault
|
||||||
|
WildPokemonHeader &encounterHeader = encounterMap[labelCombo->itemText(groupIndex)];
|
||||||
|
|
||||||
|
//qDebug() << encounterHeader.wildMons.keys();
|
||||||
|
|
||||||
|
//for (int tabIndex = 0; tabIndex < tabWidget->count(); tabIndex++) {
|
||||||
|
// QTableWidget *monTable =
|
||||||
|
//}
|
||||||
|
int fieldIndex = 0;
|
||||||
|
for (QPair<QString, QVector<int>> monField : project->wildMonFields) {
|
||||||
|
// project->wildMonData
|
||||||
|
//qDebug() << monField.first << "mons";
|
||||||
|
QTableWidget *monTable = static_cast<QTableWidget *>(tabWidget->widget(fieldIndex++));
|
||||||
|
|
||||||
|
QVector<WildPokemon> newWildMons;
|
||||||
|
|
||||||
|
//for (auto *speciesCombo : monTable->findChildren<QComboBox *>()) {
|
||||||
|
for (int row = 0; row < monTable->rowCount(); row++) {
|
||||||
|
// cellWidget(row, column)
|
||||||
|
WildPokemon newWildMon;
|
||||||
|
newWildMon.species = monTable->cellWidget(row, 1)->findChild<QComboBox *>()->currentText();
|
||||||
|
newWildMon.minLevel = monTable->cellWidget(row, 2)->findChild<QSpinBox *>()->value();//static_cast<QSpinBox *>(monTable->cellWidget(row, 2))->value();
|
||||||
|
newWildMon.maxLevel = monTable->cellWidget(row, 3)->findChild<QSpinBox *>()->value();//static_cast<QSpinBox *>(monTable->cellWidget(row, 3))->value();
|
||||||
|
newWildMons.append(newWildMon);//(speciesCombo->currentText());
|
||||||
|
}
|
||||||
|
encounterHeader.wildMons[monField.first].wildPokemon = newWildMons;
|
||||||
|
encounterHeader.wildMons[monField.first].encounterRate = monTable->findChild<QSlider *>()->value();
|
||||||
|
//fieldIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,13 +261,13 @@ bool MainWindow::openProject(QString dir) {
|
||||||
setWindowTitle(editor->project->getProjectTitle());
|
setWindowTitle(editor->project->getProjectTitle());
|
||||||
loadDataStructures();
|
loadDataStructures();
|
||||||
populateMapList();
|
populateMapList();
|
||||||
populateWildMonTabWidget(ui->tabWidget_WildMons, editor->project->wildMonFields);
|
//populateWildMonTabWidget(ui->tabWidget_WildMons, editor->project->wildMonFields);
|
||||||
success = setMap(getDefaultMap(), true);
|
success = setMap(getDefaultMap(), true);
|
||||||
} else {
|
} else {
|
||||||
setWindowTitle(editor->project->getProjectTitle());
|
setWindowTitle(editor->project->getProjectTitle());
|
||||||
loadDataStructures();
|
loadDataStructures();
|
||||||
populateMapList();
|
populateMapList();
|
||||||
populateWildMonTabWidget(ui->tabWidget_WildMons, editor->project->wildMonFields);
|
//populateWildMonTabWidget(ui->tabWidget_WildMons, editor->project->wildMonFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
|
@ -1967,6 +1967,16 @@ void MainWindow::on_pushButton_RemoveConnection_clicked()
|
||||||
editor->removeCurrentConnection();
|
editor->removeCurrentConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_pushButton_NewWildMonGroup_clicked() {
|
||||||
|
//
|
||||||
|
editor->addNewWildMonGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_pushButton_ConfigureEncountersJSON_clicked() {
|
||||||
|
//
|
||||||
|
editor->configureEncounterJSON();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_comboBox_DiveMap_activated(const QString &mapName)
|
void MainWindow::on_comboBox_DiveMap_activated(const QString &mapName)
|
||||||
{
|
{
|
||||||
editor->updateDiveMap(mapName);
|
editor->updateDiveMap(mapName);
|
||||||
|
|
|
@ -522,8 +522,8 @@ void Project::saveMapGroups() {
|
||||||
|
|
||||||
void Project::saveWildMonData() {
|
void Project::saveWildMonData() {
|
||||||
//
|
//
|
||||||
//QString wildEncountersJsonFilepath = QString("%1/src/data/wild_encounters.json").arg(root);
|
QString wildEncountersJsonFilepath = QString("%1/src/data/wild_encounters.json").arg(root);
|
||||||
QString wildEncountersJsonFilepath = QString("%1/src/data/wild_encounters_test.json").arg(root);
|
//QString wildEncountersJsonFilepath = QString("%1/src/data/wild_encounters_test.json").arg(root);
|
||||||
QFile wildEncountersFile(wildEncountersJsonFilepath);
|
QFile wildEncountersFile(wildEncountersJsonFilepath);
|
||||||
if (!wildEncountersFile.open(QIODevice::WriteOnly)) {
|
if (!wildEncountersFile.open(QIODevice::WriteOnly)) {
|
||||||
logError(QString("Error: Could not open %1 for writing").arg(wildEncountersJsonFilepath));
|
logError(QString("Error: Could not open %1 for writing").arg(wildEncountersJsonFilepath));
|
||||||
|
@ -537,15 +537,60 @@ void Project::saveWildMonData() {
|
||||||
QJsonObject monHeadersObject;
|
QJsonObject monHeadersObject;
|
||||||
monHeadersObject["label"] = "gWildMonHeaders";
|
monHeadersObject["label"] = "gWildMonHeaders";
|
||||||
monHeadersObject["for_maps"] = true;
|
monHeadersObject["for_maps"] = true;
|
||||||
|
|
||||||
|
QJsonArray fieldsInfoArray;
|
||||||
|
for (QPair<QString, QVector<int>> fieldInfo : wildMonFields) {
|
||||||
|
QJsonObject fieldObject;
|
||||||
|
QJsonArray rateArray;
|
||||||
|
|
||||||
|
for (int rate : fieldInfo.second)
|
||||||
|
rateArray.append(rate);
|
||||||
|
|
||||||
|
fieldObject["type"] = fieldInfo.first;
|
||||||
|
fieldObject["encounter_rates"] = rateArray;
|
||||||
|
|
||||||
|
fieldsInfoArray.append(fieldObject);
|
||||||
|
}
|
||||||
|
monHeadersObject["fields"] = fieldsInfoArray;
|
||||||
|
|
||||||
QJsonArray encountersArray = QJsonArray();
|
QJsonArray encountersArray = QJsonArray();
|
||||||
for (QString key : wildMonData.keys()) {
|
for (QString key : wildMonData.keys()) {
|
||||||
QJsonObject encounterObject;
|
for (QString groupLabel : wildMonData.value(key).keys()) {
|
||||||
encounterObject["map"] = key;
|
QJsonObject encounterObject;
|
||||||
encounterObject["base_label"] = encounterMapToBaseLabel[key];
|
encounterObject["map"] = key;
|
||||||
//
|
encounterObject["base_label"] = groupLabel;//encounterMapToBaseLabel[key];
|
||||||
//text += key + "\n";
|
//
|
||||||
// ["base_label"] = encounterMapToBaseLabel[mapConstant]
|
|
||||||
encountersArray.append(encounterObject);
|
WildPokemonHeader encounterHeader = wildMonData.value(key).value(groupLabel);
|
||||||
|
for (QString fieldName : encounterHeader.wildMons.keys()) {
|
||||||
|
//
|
||||||
|
QJsonObject fieldObject;
|
||||||
|
WildMonInfo monInfo = encounterHeader.wildMons.value(fieldName);
|
||||||
|
fieldObject["encounter_rate"] = monInfo.encounterRate;
|
||||||
|
QJsonArray monArray;
|
||||||
|
for (WildPokemon wildMon : monInfo.wildPokemon) {
|
||||||
|
//
|
||||||
|
QJsonObject monEntry;
|
||||||
|
monEntry["min_level"] = wildMon.minLevel;
|
||||||
|
monEntry["max_level"] = wildMon.maxLevel;
|
||||||
|
monEntry["species"] = wildMon.species;
|
||||||
|
monArray.append(monEntry);
|
||||||
|
}
|
||||||
|
fieldObject["mons"] = monArray;//fieldObject;
|
||||||
|
encounterObject[fieldName] = fieldObject;
|
||||||
|
}
|
||||||
|
//encounterObject[];
|
||||||
|
// QMap<QString, WildMonInfo> wildMons;
|
||||||
|
|
||||||
|
//QJsonArray
|
||||||
|
//for (auto fieldItem : wildMonFields) {
|
||||||
|
// QString fieldLabel = fieldItem.first;
|
||||||
|
// encounterObject[fieldLabel] = ;
|
||||||
|
//}
|
||||||
|
|
||||||
|
encountersArray.append(encounterObject);
|
||||||
|
}
|
||||||
|
// TODO: save fields json data
|
||||||
}
|
}
|
||||||
monHeadersObject["encounters"] = encountersArray;
|
monHeadersObject["encounters"] = encountersArray;
|
||||||
wildEncounterGroups.append(monHeadersObject);
|
wildEncounterGroups.append(monHeadersObject);
|
||||||
|
@ -1397,7 +1442,10 @@ void Project::readWildMonData() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wildMonData.insert(mapConstant, header);
|
//if (!wildMonData.contains(mapConstant))
|
||||||
|
// wildMonData.insert(mapConstant, header);
|
||||||
|
//else
|
||||||
|
wildMonData[mapConstant].insert(encounter["base_label"].toString(), header);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue