From 61e5dbde20a36778887fa1613c6434ccc1705dea Mon Sep 17 00:00:00 2001 From: godric3 Date: Sun, 2 Feb 2025 17:03:58 +0100 Subject: [PATCH] map editor: fix resource reward in events --- mapeditor/inspector/towneventdialog.cpp | 4 ++-- mapeditor/mapsettings/timedevent.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mapeditor/inspector/towneventdialog.cpp b/mapeditor/inspector/towneventdialog.cpp index 7d5ff496d..e2fa1805d 100644 --- a/mapeditor/inspector/towneventdialog.cpp +++ b/mapeditor/inspector/towneventdialog.cpp @@ -230,10 +230,10 @@ QVariantMap TownEventDialog::resourcesToVariant() auto res = params.value("resources").toMap(); for (int i = 0; i < GameConstants::RESOURCE_QUANTITY; ++i) { - auto * itemType = ui->resourcesTable->item(i, 0); + auto itemType = QString::fromStdString(GameConstants::RESOURCE_NAMES[i]); auto * itemQty = static_cast (ui->resourcesTable->cellWidget(i, 1)); - res[itemType->text()] = QVariant::fromValue(itemQty->value()); + res[itemType] = QVariant::fromValue(itemQty->value()); } return res; } diff --git a/mapeditor/mapsettings/timedevent.cpp b/mapeditor/mapsettings/timedevent.cpp index 5cc14afe6..6df7957f1 100644 --- a/mapeditor/mapsettings/timedevent.cpp +++ b/mapeditor/mapsettings/timedevent.cpp @@ -96,9 +96,9 @@ void TimedEvent::on_TimedEvent_finished(int result) auto res = target->data(Qt::UserRole).toMap().value("resources").toMap(); for(int i = 0; i < GameConstants::RESOURCE_QUANTITY; ++i) { - auto * itemType = ui->resources->item(i, 0); + auto itemType = QString::fromStdString(GameConstants::RESOURCE_NAMES[i]); auto * itemQty = ui->resources->item(i, 1); - res[itemType->text()] = QVariant::fromValue(itemQty->text().toInt()); + res[itemType] = QVariant::fromValue(itemQty->text().toInt()); } descriptor["resources"] = res;