浏览代码

Merge pull request #5368 from godric3/map-editor-fix-resources-from-event

map editor: fix resource reward in events
Ivan Savenko 8 月之前
父节点
当前提交
869fe5e606
共有 2 个文件被更改,包括 4 次插入4 次删除
  1. 2 2
      mapeditor/inspector/towneventdialog.cpp
  2. 2 2
      mapeditor/mapsettings/timedevent.cpp

+ 2 - 2
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<QSpinBox *> (ui->resourcesTable->cellWidget(i, 1));
 
-		res[itemType->text()] = QVariant::fromValue(itemQty->value());
+		res[itemType] = QVariant::fromValue(itemQty->value());
 	}
 	return res;
 }

+ 2 - 2
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;