1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-24 03:47:18 +02:00

Register all text IDs in map editor

This commit is contained in:
nordsoft 2023-09-28 14:49:47 +02:00
parent 98fde9ab1d
commit dbf3cad796
4 changed files with 8 additions and 8 deletions

View File

@ -47,12 +47,12 @@ QVariant toVariant(const CMapEvent & event)
return QVariant(result);
}
CMapEvent eventFromVariant(const QVariant & variant)
CMapEvent eventFromVariant(CMapHeader & mapHeader, const QVariant & variant)
{
CMapEvent result;
auto v = variant.toMap();
result.name = v.value("name").toString().toStdString();
result.message.appendRawString(v.value("message").toString().toStdString());
result.message.appendTextID(mapRegisterLocalizedString(mapHeader, TextIdentifier("header", "event", result.name, "message"), v.value("message").toString().toStdString()));
result.players = v.value("players").toInt();
result.humanAffected = v.value("humanAffected").toInt();
result.computerAffected = v.value("computerAffected").toInt();
@ -91,7 +91,7 @@ void EventSettings::update()
for(int i = 0; i < ui->eventsList->count(); ++i)
{
const auto * item = ui->eventsList->item(i);
controller->map()->events.push_back(eventFromVariant(item->data(Qt::UserRole)));
controller->map()->events.push_back(eventFromVariant(*controller->map(), item->data(Qt::UserRole)));
}
}

View File

@ -59,8 +59,8 @@ void GeneralSettings::initialize(MapController & c)
void GeneralSettings::update()
{
controller->map()->name.appendRawString(ui->mapNameEdit->text().toStdString());
controller->map()->description.appendRawString(ui->mapDescriptionEdit->toPlainText().toStdString());
controller->map()->name.appendTextID(mapRegisterLocalizedString(*controller->map(), TextIdentifier("header", "name"), ui->mapNameEdit->text().toStdString()));
controller->map()->description.appendTextID(mapRegisterLocalizedString(*controller->map(), TextIdentifier("header", "description"), ui->mapDescriptionEdit->toPlainText().toStdString()));
if(ui->heroLevelLimitCheck->isChecked())
controller->map()->levelLimit = ui->heroLevelLimit->value();
else

View File

@ -243,7 +243,7 @@ void LoseConditions::on_loseComboBox_currentIndexChanged(int index)
loseTypeWidget = new QComboBox;
ui->loseParamsLayout->addWidget(loseTypeWidget);
for(int i : getObjectIndexes<const CGTownInstance>(*controller->map()))
loseTypeWidget->addItem(tr(getTownName(*controller->map(), i).c_str()), QVariant::fromValue(i));
loseTypeWidget->addItem(QString::fromStdString(getTownName(*controller->map(), i).c_str()), QVariant::fromValue(i));
pickObjectButton = new QToolButton;
connect(pickObjectButton, &QToolButton::clicked, this, &LoseConditions::onObjectSelect);
ui->loseParamsLayout->addWidget(pickObjectButton);
@ -254,7 +254,7 @@ void LoseConditions::on_loseComboBox_currentIndexChanged(int index)
loseTypeWidget = new QComboBox;
ui->loseParamsLayout->addWidget(loseTypeWidget);
for(int i : getObjectIndexes<const CGHeroInstance>(*controller->map()))
loseTypeWidget->addItem(tr(getHeroName(*controller->map(), i).c_str()), QVariant::fromValue(i));
loseTypeWidget->addItem(QString::fromStdString(getHeroName(*controller->map(), i).c_str()), QVariant::fromValue(i));
pickObjectButton = new QToolButton;
connect(pickObjectButton, &QToolButton::clicked, this, &LoseConditions::onObjectSelect);
ui->loseParamsLayout->addWidget(pickObjectButton);

View File

@ -43,7 +43,7 @@ void RumorSettings::update()
{
Rumor rumor;
rumor.name = ui->rumors->item(i)->text().toStdString();
rumor.text.appendRawString(ui->rumors->item(i)->data(Qt::UserRole).toString().toStdString());
rumor.text.appendTextID(mapRegisterLocalizedString(*controller->map(), TextIdentifier("header", "rumor", i, "text"), ui->rumors->item(i)->data(Qt::UserRole).toString().toStdString()));
controller->map()->rumors.push_back(rumor);
}
}