From dbf3cad796042bd50e8b0b2edd55a8b2fb25dad7 Mon Sep 17 00:00:00 2001 From: nordsoft Date: Thu, 28 Sep 2023 14:49:47 +0200 Subject: [PATCH] Register all text IDs in map editor --- mapeditor/mapsettings/eventsettings.cpp | 6 +++--- mapeditor/mapsettings/generalsettings.cpp | 4 ++-- mapeditor/mapsettings/loseconditions.cpp | 4 ++-- mapeditor/mapsettings/rumorsettings.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mapeditor/mapsettings/eventsettings.cpp b/mapeditor/mapsettings/eventsettings.cpp index 047c9e1ae..60cd97982 100644 --- a/mapeditor/mapsettings/eventsettings.cpp +++ b/mapeditor/mapsettings/eventsettings.cpp @@ -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))); } } diff --git a/mapeditor/mapsettings/generalsettings.cpp b/mapeditor/mapsettings/generalsettings.cpp index 12322f73b..8f74867dc 100644 --- a/mapeditor/mapsettings/generalsettings.cpp +++ b/mapeditor/mapsettings/generalsettings.cpp @@ -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 diff --git a/mapeditor/mapsettings/loseconditions.cpp b/mapeditor/mapsettings/loseconditions.cpp index 017ad9e78..c66c0f936 100644 --- a/mapeditor/mapsettings/loseconditions.cpp +++ b/mapeditor/mapsettings/loseconditions.cpp @@ -243,7 +243,7 @@ void LoseConditions::on_loseComboBox_currentIndexChanged(int index) loseTypeWidget = new QComboBox; ui->loseParamsLayout->addWidget(loseTypeWidget); for(int i : getObjectIndexes(*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(*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); diff --git a/mapeditor/mapsettings/rumorsettings.cpp b/mapeditor/mapsettings/rumorsettings.cpp index da122be93..6527c67f1 100644 --- a/mapeditor/mapsettings/rumorsettings.cpp +++ b/mapeditor/mapsettings/rumorsettings.cpp @@ -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); } }