From bdf778a80a48a1e1e157d9df204fb989f3f34014 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Thu, 2 Jan 2025 23:05:40 +0100 Subject: [PATCH] mapeditor new translatable strings --- mapeditor/inspector/inspector.cpp | 229 +++++++++++++++++------------- mapeditor/mainwindow.cpp | 15 +- 2 files changed, 142 insertions(+), 102 deletions(-) diff --git a/mapeditor/inspector/inspector.cpp b/mapeditor/inspector/inspector.cpp index 3201e46d8..d6618f711 100644 --- a/mapeditor/inspector/inspector.cpp +++ b/mapeditor/inspector/inspector.cpp @@ -44,6 +44,45 @@ static QList> CharacterIdentifiers {QObject::tr("Savage"), QVariant::fromValue(int(CGCreature::Character::SAVAGE))}, }; +// multiple times used translation strings +enum ReusedKey { ARMY, OWNER, SAME_AS_TOWN, REMOVABLE_UNITS, PLACEHOLDER_TYPE, POWER_RANK, HERO_TYPE, EXPERIENCE, MALE, FEMALE, GENDER, NAME, BIOGRAPHY, SPELLS, NO_PATROL, PATROL_RADIUS, TOWN_NAME, MESSAGE, SPELL, PRODUCTIVITY, AMOUNT, CHARACTER, NEVER_FLEES, NOT_GROWING, REWARD, REMOVE_AFTER, HUMAN_TRIGGER, CPU_TRIGGER, FIRST_VISIT_TEXT, NEXT_VISIT_TEXT, COMPLETED_TEXT, REPEAT_QUEST, TIME_LIMIT }; +static const QHash trReused = +{ + { ARMY, QObject::tr("Army") }, + { OWNER, QObject::tr("Owner") }, + { SAME_AS_TOWN, QObject::tr("Same as town") }, + { REMOVABLE_UNITS, QObject::tr("Removable units") }, + { PLACEHOLDER_TYPE, QObject::tr("Placeholder type") }, + { POWER_RANK, QObject::tr("Power rank") }, + { HERO_TYPE, QObject::tr("Hero type") }, + { EXPERIENCE, QObject::tr("Experience") }, + { MALE, QObject::tr("MALE") }, + { FEMALE, QObject::tr("FEMALE") }, + { GENDER, QObject::tr("Gender") }, + { NAME, QObject::tr("Name") }, + { BIOGRAPHY, QObject::tr("Biography") }, + { SPELLS, QObject::tr("Spells") }, + { NO_PATROL, QObject::tr("No patrol") }, + { PATROL_RADIUS, QObject::tr("Patrol radius") }, + { TOWN_NAME, QObject::tr("Town name") }, + { MESSAGE, QObject::tr("Message") }, + { SPELL, QObject::tr("Spell") }, + { PRODUCTIVITY, QObject::tr("Productivity") }, + { AMOUNT, QObject::tr("Amount") }, + { CHARACTER, QObject::tr("Character") }, + { NEVER_FLEES, QObject::tr("Never flees") }, + { NOT_GROWING, QObject::tr("Not growing") }, + { REWARD, QObject::tr("Reward") }, + { REMOVE_AFTER, QObject::tr("Remove after") }, + { HUMAN_TRIGGER, QObject::tr("Human trigger") }, + { CPU_TRIGGER, QObject::tr("Cpu trigger") }, + { FIRST_VISIT_TEXT, QObject::tr("First visit text") }, + { NEXT_VISIT_TEXT, QObject::tr("Next visit text") }, + { COMPLETED_TEXT, QObject::tr("Completed text") }, + { REPEAT_QUEST, QObject::tr("Repeat quest") }, + { TIME_LIMIT, QObject::tr("Time limit") }, +}; + //===============IMPLEMENT OBJECT INITIALIZATION FUNCTIONS================ Initializer::Initializer(CGObjectInstance * o, const PlayerColor & pl) : defaultPlayer(pl) { @@ -245,19 +284,19 @@ void Inspector::updateProperties(CArmedInstance * o) if(!o) return; auto * delegate = new ArmyDelegate(*o); - addProperty("Army", PropertyEditorPlaceholder(), delegate, false); + addProperty(trReused[ARMY], PropertyEditorPlaceholder(), delegate, false); } void Inspector::updateProperties(CGDwelling * o) { if(!o) return; - addProperty("Owner", o->tempOwner, new OwnerDelegate(controller), false); + addProperty(trReused[OWNER], o->tempOwner, new OwnerDelegate(controller), false); if (o->ID == Obj::RANDOM_DWELLING || o->ID == Obj::RANDOM_DWELLING_LVL) { auto * delegate = new PickObjectDelegate(controller, PickObjectDelegate::typedFilter); - addProperty("Same as town", PropertyEditorPlaceholder(), delegate, false); + addProperty(trReused[SAME_AS_TOWN], PropertyEditorPlaceholder(), delegate, false); } } @@ -265,29 +304,29 @@ void Inspector::updateProperties(FlaggableMapObject * o) { if(!o) return; - addProperty("Owner", o->tempOwner, new OwnerDelegate(controller), false); + addProperty(trReused[OWNER], o->tempOwner, new OwnerDelegate(controller), false); } void Inspector::updateProperties(CGGarrison * o) { if(!o) return; - addProperty("Owner", o->tempOwner, new OwnerDelegate(controller), false); - addProperty("Removable units", o->removableUnits, false); + addProperty(trReused[OWNER], o->tempOwner, new OwnerDelegate(controller), false); + addProperty(trReused[REMOVABLE_UNITS], o->removableUnits, false); } void Inspector::updateProperties(CGShipyard * o) { if(!o) return; - addProperty("Owner", o->tempOwner, new OwnerDelegate(controller), false); + addProperty(trReused[OWNER], o->tempOwner, new OwnerDelegate(controller), false); } void Inspector::updateProperties(CGHeroPlaceholder * o) { if(!o) return; - addProperty("Owner", o->tempOwner, new OwnerDelegate(controller), false); + addProperty(trReused[OWNER], o->tempOwner, new OwnerDelegate(controller), false); bool type = false; if(o->heroType.has_value()) @@ -297,11 +336,11 @@ void Inspector::updateProperties(CGHeroPlaceholder * o) { auto * delegate = new InspectorDelegate; - delegate->options = {{"POWER RANK", QVariant::fromValue(false)}, {"HERO TYPE", QVariant::fromValue(true)}}; - addProperty("Placeholder type", delegate->options[type].first, delegate, false); + delegate->options = {{QObject::tr("POWER RANK"), QVariant::fromValue(false)}, {QObject::tr("HERO TYPE"), QVariant::fromValue(true)}}; + addProperty(trReused[PLACEHOLDER_TYPE], delegate->options[type].first, delegate, false); } - addProperty("Power rank", o->powerRank.has_value() ? o->powerRank.value() : 0, type); + addProperty(trReused[POWER_RANK], o->powerRank.has_value() ? o->powerRank.value() : 0, type); { auto * delegate = new InspectorDelegate; @@ -309,7 +348,7 @@ void Inspector::updateProperties(CGHeroPlaceholder * o) { delegate->options.push_back({QObject::tr(VLC->heroh->objects[i]->getNameTranslated().c_str()), QVariant::fromValue(VLC->heroh->objects[i]->getId().getNum())}); } - addProperty("Hero type", o->heroType.has_value() ? VLC->heroh->getById(o->heroType.value())->getNameTranslated() : "", delegate, !type); + addProperty(trReused[HERO_TYPE], o->heroType.has_value() ? VLC->heroh->getById(o->heroType.value())->getNameTranslated() : "", delegate, !type); } } @@ -318,23 +357,23 @@ void Inspector::updateProperties(CGHeroInstance * o) if(!o) return; auto isPrison = o->ID == Obj::PRISON; - addProperty("Owner", o->tempOwner, new OwnerDelegate(controller, isPrison), isPrison); //field is not editable for prison - addProperty("Experience", o->exp, false); - addProperty("Hero class", o->getHeroClassID().hasValue() ? o->getHeroClass()->getNameTranslated() : "", true); + addProperty(trReused[OWNER], o->tempOwner, new OwnerDelegate(controller, isPrison), isPrison); //field is not editable for prison + addProperty(trReused[EXPERIENCE], o->exp, false); + addProperty(QObject::tr("Hero class"), o->getHeroClassID().hasValue() ? o->getHeroClass()->getNameTranslated() : "", true); { //Gender auto * delegate = new InspectorDelegate; - delegate->options = {{"MALE", QVariant::fromValue(int(EHeroGender::MALE))}, {"FEMALE", QVariant::fromValue(int(EHeroGender::FEMALE))}}; - addProperty("Gender", (o->gender == EHeroGender::FEMALE ? "FEMALE" : "MALE"), delegate , false); + delegate->options = {{trReused[MALE], QVariant::fromValue(int(EHeroGender::MALE))}, {trReused[FEMALE], QVariant::fromValue(int(EHeroGender::FEMALE))}}; + addProperty(trReused[GENDER], (o->gender == EHeroGender::FEMALE ? trReused[FEMALE] : trReused[MALE]).toStdString(), delegate , false); } - addProperty("Name", o->getNameTranslated(), false); - addProperty("Biography", o->getBiographyTranslated(), new MessageDelegate, false); - addProperty("Portrait", PropertyEditorPlaceholder(), new PortraitDelegate(*o), false); + addProperty(trReused[NAME], o->getNameTranslated(), false); + addProperty(trReused[BIOGRAPHY], o->getBiographyTranslated(), new MessageDelegate, false); + addProperty(QObject::tr("Portrait"), PropertyEditorPlaceholder(), new PortraitDelegate(*o), false); auto * delegate = new HeroSkillsDelegate(*o); - addProperty("Skills", PropertyEditorPlaceholder(), delegate, false); - addProperty("Spells", PropertyEditorPlaceholder(), new HeroSpellDelegate(*o), false); - addProperty("Artifacts", PropertyEditorPlaceholder(), new HeroArtifactsDelegate(*o), false); + addProperty(QObject::tr("Skills"), PropertyEditorPlaceholder(), delegate, false); + addProperty(trReused[SPELLS], PropertyEditorPlaceholder(), new HeroSpellDelegate(*o), false); + addProperty(QObject::tr("Artifacts"), PropertyEditorPlaceholder(), new HeroArtifactsDelegate(*o), false); if(o->getHeroTypeID().hasValue() || o->ID == Obj::PRISON) { //Hero type @@ -349,7 +388,7 @@ void Inspector::updateProperties(CGHeroInstance * o) } } } - addProperty("Hero type", o->getHeroTypeID().hasValue() ? o->getHeroType()->getNameTranslated() : "", delegate, false); + addProperty(trReused[HERO_TYPE], o->getHeroTypeID().hasValue() ? o->getHeroType()->getNameTranslated() : "", delegate, false); } { const int maxRadius = 60; @@ -358,7 +397,7 @@ void Inspector::updateProperties(CGHeroInstance * o) for(int i = 0; i <= maxRadius; ++i) patrolDelegate->options.push_back({ QObject::tr("%n tile(s)", "", i), QVariant::fromValue(i)}); auto patrolRadiusText = o->patrol.patrolling ? QObject::tr("%n tile(s)", "", o->patrol.patrolRadius) : QObject::tr("No patrol"); - addProperty("Patrol radius", patrolRadiusText, patrolDelegate, false); + addProperty(trReused[PATROL_RADIUS], patrolRadiusText, patrolDelegate, false); } } @@ -366,19 +405,19 @@ void Inspector::updateProperties(CGTownInstance * o) { if(!o) return; - addProperty("Town name", o->getNameTranslated(), false); + addProperty(trReused[TOWN_NAME], o->getNameTranslated(), false); auto * delegate = new TownBuildingsDelegate(*o); - addProperty("Buildings", PropertyEditorPlaceholder(), delegate, false); - addProperty("Spells", PropertyEditorPlaceholder(), new TownSpellsDelegate(*o), false); - addProperty("Events", PropertyEditorPlaceholder(), new TownEventsDelegate(*o, controller), false); + addProperty(QObject::tr("Buildings"), PropertyEditorPlaceholder(), delegate, false); + addProperty(trReused[SPELLS], PropertyEditorPlaceholder(), new TownSpellsDelegate(*o), false); + addProperty(QObject::tr("Events"), PropertyEditorPlaceholder(), new TownEventsDelegate(*o, controller), false); } void Inspector::updateProperties(CGArtifact * o) { if(!o) return; - addProperty("Message", o->message, false); + addProperty(trReused[MESSAGE], o->message, false); CArtifactInstance * instance = o->storedArtifact; if(instance) @@ -392,7 +431,7 @@ void Inspector::updateProperties(CGArtifact * o) if(controller.map()->allowedSpells.count(spell->id) != 0) delegate->options.push_back({QObject::tr(spell->getNameTranslated().c_str()), QVariant::fromValue(int(spell->getId()))}); } - addProperty("Spell", VLC->spellh->getById(spellId)->getNameTranslated(), delegate, false); + addProperty(trReused[SPELL], VLC->spellh->getById(spellId)->getNameTranslated(), delegate, false); } } } @@ -401,42 +440,42 @@ void Inspector::updateProperties(CGMine * o) { if(!o) return; - addProperty("Owner", o->tempOwner, new OwnerDelegate(controller), false); - addProperty("Resource", o->producedResource); - addProperty("Productivity", o->producedQuantity); + addProperty(trReused[OWNER], o->tempOwner, new OwnerDelegate(controller), false); + addProperty(QObject::tr("Resource"), o->producedResource); + addProperty(trReused[PRODUCTIVITY], o->producedQuantity); } void Inspector::updateProperties(CGResource * o) { if(!o) return; - addProperty("Amount", o->amount, false); - addProperty("Message", o->message, false); + addProperty(trReused[AMOUNT], o->amount, false); + addProperty(trReused[MESSAGE], o->message, false); } void Inspector::updateProperties(CGSignBottle * o) { if(!o) return; - addProperty("Message", o->message, new MessageDelegate, false); + addProperty(trReused[MESSAGE], o->message, new MessageDelegate, false); } void Inspector::updateProperties(CGCreature * o) { if(!o) return; - addProperty("Message", o->message, false); + addProperty(trReused[MESSAGE], o->message, false); { //Character auto * delegate = new InspectorDelegate; delegate->options = CharacterIdentifiers; addProperty("Character", (CGCreature::Character)o->character, delegate, false); } - addProperty("Never flees", o->neverFlees, false); - addProperty("Not growing", o->notGrowingTeam, false); - addProperty("Artifact reward", o->gainedArtifact); //TODO: implement in setProperty - addProperty("Army", PropertyEditorPlaceholder(), true); - addProperty("Amount", o->stacks[SlotID(0)]->count, false); - //addProperty("Resources reward", o->resources); //TODO: implement in setProperty + addProperty(trReused[NEVER_FLEES], o->neverFlees, false); + addProperty(trReused[NOT_GROWING], o->notGrowingTeam, false); + addProperty(QObject::tr("Artifact reward"), o->gainedArtifact); //TODO: implement in setProperty + addProperty(trReused[ARMY], PropertyEditorPlaceholder(), true); + addProperty(trReused[AMOUNT], o->stacks[SlotID(0)]->count, false); + //addProperty(QObject::tr("Resources reward"), o->resources); //TODO: implement in setProperty } void Inspector::updateProperties(CRewardableObject * o) @@ -444,23 +483,23 @@ void Inspector::updateProperties(CRewardableObject * o) if(!o) return; auto * delegate = new RewardsDelegate(*controller.map(), *o); - addProperty("Reward", PropertyEditorPlaceholder(), delegate, false); + addProperty(trReused[REWARD], PropertyEditorPlaceholder(), delegate, false); } void Inspector::updateProperties(CGPandoraBox * o) { if(!o) return; - addProperty("Message", o->message, new MessageDelegate, false); + addProperty(trReused[MESSAGE], o->message, new MessageDelegate, false); } void Inspector::updateProperties(CGEvent * o) { if(!o) return; - addProperty("Remove after", o->removeAfterVisit, false); - addProperty("Human trigger", o->humanActivate, false); - addProperty("Cpu trigger", o->computerActivate, false); + addProperty(trReused[REMOVE_AFTER], o->removeAfterVisit, false); + addProperty(trReused[HUMAN_TRIGGER], o->humanActivate, false); + addProperty(trReused[CPU_TRIGGER], o->computerActivate, false); //ui8 availableFor; //players whom this event is available for } @@ -468,15 +507,15 @@ void Inspector::updateProperties(CGSeerHut * o) { if(!o || !o->quest) return; - addProperty("First visit text", o->quest->firstVisitText, new MessageDelegate, false); - addProperty("Next visit text", o->quest->nextVisitText, new MessageDelegate, false); - addProperty("Completed text", o->quest->completedText, new MessageDelegate, false); - addProperty("Repeat quest", o->quest->repeatedQuest, false); - addProperty("Time limit", o->quest->lastDay, false); + addProperty(trReused[FIRST_VISIT_TEXT], o->quest->firstVisitText, new MessageDelegate, false); + addProperty(trReused[NEXT_VISIT_TEXT], o->quest->nextVisitText, new MessageDelegate, false); + addProperty(trReused[COMPLETED_TEXT], o->quest->completedText, new MessageDelegate, false); + addProperty(trReused[REPEAT_QUEST], o->quest->repeatedQuest, false); + addProperty(trReused[TIME_LIMIT], o->quest->lastDay, false); { //Quest auto * delegate = new QuestDelegate(controller, *o->quest); - addProperty("Quest", PropertyEditorPlaceholder(), delegate, false); + addProperty(QObject::tr("Quest"), PropertyEditorPlaceholder(), delegate, false); } } @@ -484,8 +523,8 @@ void Inspector::updateProperties(CGQuestGuard * o) { if(!o || !o->quest) return; - addProperty("Reward", PropertyEditorPlaceholder(), nullptr, true); - addProperty("Repeat quest", o->quest->repeatedQuest, true); + addProperty(trReused[REWARD], PropertyEditorPlaceholder(), nullptr, true); + addProperty(trReused[REPEAT_QUEST], o->quest->repeatedQuest, true); } void Inspector::updateProperties() @@ -494,18 +533,18 @@ void Inspector::updateProperties() return; table->setRowCount(0); //cleanup table - addProperty("Identifier", obj); - addProperty("ID", obj->ID.getNum()); - addProperty("SubID", obj->subID); - addProperty("InstanceName", obj->instanceName); + addProperty(QObject::tr("Identifier"), obj); + addProperty(QObject::tr("ID"), obj->ID.getNum()); + addProperty(QObject::tr("SubID"), obj->subID); + addProperty(QObject::tr("InstanceName"), obj->instanceName); if(obj->ID != Obj::HERO_PLACEHOLDER && !dynamic_cast(obj)) { auto factory = VLC->objtypeh->getHandlerFor(obj->ID, obj->subID); - addProperty("IsStatic", factory->isStaticObject()); + addProperty(QObject::tr("IsStatic"), factory->isStaticObject()); } - addProperty("Owner", obj->tempOwner, new OwnerDelegate(controller), true); + addProperty(trReused[OWNER], obj->tempOwner, new OwnerDelegate(controller), true); UPDATE_OBJ_PROPERTIES(CArmedInstance); UPDATE_OBJ_PROPERTIES(CGResource); @@ -552,7 +591,7 @@ void Inspector::setProperty(const QString & key, const QVariant & value) if(!obj) return; - if(key == "Owner") + if(key == trReused[OWNER]) obj->tempOwner = PlayerColor(value.toInt()); SET_PROPERTIES(CArmedInstance); @@ -594,7 +633,7 @@ void Inspector::setProperty(CGPandoraBox * o, const QString & key, const QVarian { if(!o) return; - if(key == "Message") + if(key == trReused[MESSAGE]) o->message = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller.map(), TextIdentifier("guards", o->instanceName, "message"), value.toString().toStdString())); } @@ -603,13 +642,13 @@ void Inspector::setProperty(CGEvent * o, const QString & key, const QVariant & v { if(!o) return; - if(key == "Remove after") + if(key == trReused[REMOVE_AFTER]) o->removeAfterVisit = value.toBool(); - if(key == "Human trigger") + if(key == trReused[HUMAN_TRIGGER]) o->humanActivate = value.toBool(); - if(key == "Cpu trigger") + if(key == trReused[CPU_TRIGGER]) o->computerActivate = value.toBool(); } @@ -617,7 +656,7 @@ void Inspector::setProperty(CGTownInstance * o, const QString & key, const QVari { if(!o) return; - if(key == "Town name") + if(key == trReused[TOWN_NAME]) o->setNameTextId(mapRegisterLocalizedString("map", *controller.map(), TextIdentifier("town", o->instanceName, "name"), value.toString().toStdString())); } @@ -626,7 +665,7 @@ void Inspector::setProperty(CGSignBottle * o, const QString & key, const QVarian { if(!o) return; - if(key == "Message") + if(key == trReused[MESSAGE]) o->message = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller.map(), TextIdentifier("sign", o->instanceName, "message"), value.toString().toStdString())); } @@ -635,7 +674,7 @@ void Inspector::setProperty(CGMine * o, const QString & key, const QVariant & va { if(!o) return; - if(key == "Productivity") + if(key == trReused[PRODUCTIVITY]) o->producedQuantity = value.toString().toInt(); } @@ -643,11 +682,11 @@ void Inspector::setProperty(CGArtifact * o, const QString & key, const QVariant { if(!o) return; - if(key == "Message") + if(key == trReused[MESSAGE]) o->message = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller.map(), TextIdentifier("guards", o->instanceName, "message"), value.toString().toStdString())); - if(o->storedArtifact && key == "Spell") + if(o->storedArtifact && key == trReused[SPELL]) { o->storedArtifact = ArtifactUtils::createScroll(SpellID(value.toInt())); } @@ -657,7 +696,7 @@ void Inspector::setProperty(CGDwelling * o, const QString & key, const QVariant { if(!o) return; - if(key == "Same as town") + if(key == trReused[SAME_AS_TOWN]) { if (!o->randomizationInfo.has_value()) o->randomizationInfo = CGDwellingRandomizationInfo(); @@ -672,7 +711,7 @@ void Inspector::setProperty(CGGarrison * o, const QString & key, const QVariant { if(!o) return; - if(key == "Removable units") + if(key == trReused[REMOVABLE_UNITS]) o->removableUnits = value.toBool(); } @@ -680,7 +719,7 @@ void Inspector::setProperty(CGHeroPlaceholder * o, const QString & key, const QV { if(!o) return; - if(key == "Placeholder type") + if(key == trReused[PLACEHOLDER_TYPE]) { if(value.toBool()) { @@ -698,10 +737,10 @@ void Inspector::setProperty(CGHeroPlaceholder * o, const QString & key, const QV updateProperties(); } - if(key == "Power rank") + if(key == trReused[POWER_RANK]) o->powerRank = value.toInt(); - if(key == "Hero type") + if(key == trReused[HERO_TYPE]) { o->heroType = HeroTypeID(value.toInt()); } @@ -711,21 +750,21 @@ void Inspector::setProperty(CGHeroInstance * o, const QString & key, const QVari { if(!o) return; - if(key == "Gender") + if(key == trReused[GENDER]) o->gender = EHeroGender(value.toInt()); - if(key == "Name") + if(key == trReused[NAME]) o->nameCustomTextId = mapRegisterLocalizedString("map", *controller.map(), TextIdentifier("hero", o->instanceName, "name"), value.toString().toStdString()); - if(key == "Biography") + if(key == trReused[BIOGRAPHY]) o->biographyCustomTextId = mapRegisterLocalizedString("map", *controller.map(), TextIdentifier("hero", o->instanceName, "biography"), value.toString().toStdString()); - if(key == "Experience") + if(key == trReused[EXPERIENCE]) o->exp = value.toString().toInt(); - if(key == "Hero type") + if(key == trReused[HERO_TYPE]) { for(auto const & t : VLC->heroh->objects) { @@ -737,7 +776,7 @@ void Inspector::setProperty(CGHeroInstance * o, const QString & key, const QVari updateProperties(); //updating other properties after change } - if(key == "Patrol radius") + if(key == trReused[PATROL_RADIUS]) { auto radius = value.toInt(); o->patrol.patrolRadius = radius; @@ -754,7 +793,7 @@ void Inspector::setProperty(CGResource * o, const QString & key, const QVariant { if(!o) return; - if(key == "Amount") + if(key == trReused[AMOUNT]) o->amount = value.toString().toInt(); } @@ -762,16 +801,16 @@ void Inspector::setProperty(CGCreature * o, const QString & key, const QVariant { if(!o) return; - if(key == "Message") + if(key == trReused[MESSAGE]) o->message = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller.map(), TextIdentifier("monster", o->instanceName, "message"), value.toString().toStdString())); - if(key == "Character") + if(key == trReused[CHARACTER]) o->character = CGCreature::Character(value.toInt()); - if(key == "Never flees") + if(key == trReused[NEVER_FLEES]) o->neverFlees = value.toBool(); - if(key == "Not growing") + if(key == trReused[NOT_GROWING]) o->notGrowingTeam = value.toBool(); - if(key == "Amount") + if(key == trReused[AMOUNT]) o->stacks[SlotID(0)]->count = value.toString().toInt(); } @@ -779,18 +818,18 @@ void Inspector::setProperty(CGSeerHut * o, const QString & key, const QVariant & { if(!o) return; - if(key == "First visit text") + if(key == trReused[FIRST_VISIT_TEXT]) o->quest->firstVisitText = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller.map(), TextIdentifier("quest", o->instanceName, "firstVisit"), value.toString().toStdString())); - if(key == "Next visit text") + if(key == trReused[NEXT_VISIT_TEXT]) o->quest->nextVisitText = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller.map(), TextIdentifier("quest", o->instanceName, "nextVisit"), value.toString().toStdString())); - if(key == "Completed text") + if(key == trReused[COMPLETED_TEXT]) o->quest->completedText = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller.map(), TextIdentifier("quest", o->instanceName, "completed"), value.toString().toStdString())); - if(key == "Repeat quest") + if(key == trReused[REPEAT_QUEST]) o->quest->repeatedQuest = value.toBool(); - if(key == "Time limit") + if(key == trReused[TIME_LIMIT]) o->quest->lastDay = value.toString().toInt(); } diff --git a/mapeditor/mainwindow.cpp b/mapeditor/mainwindow.cpp index 345f645dc..c2cc39959 100644 --- a/mapeditor/mainwindow.cpp +++ b/mapeditor/mainwindow.cpp @@ -407,12 +407,12 @@ bool MainWindow::openMap(const QString & filenameSelect) catch(const ModIncompatibility & e) { assert(e.whatExcessive().empty()); - QMessageBox::warning(this, "Mods are required", QString::fromStdString(e.whatMissing())); + QMessageBox::warning(this, tr("Mods are required"), QString::fromStdString(e.whatMissing())); return false; } catch(const std::exception & e) { - QMessageBox::critical(this, "Failed to open map", tr(e.what())); + QMessageBox::critical(this, tr("Failed to open map"), tr(e.what())); return false; } @@ -460,7 +460,7 @@ void MainWindow::on_actionOpenRecent_triggered() : QDialog(parent), layout(new QVBoxLayout(this)), listWidget(new QListWidget(this)) { - setWindowTitle(tr("Recently Opened Files")); + parent->setWindowTitle(tr("Recently Opened Files")); setMinimumWidth(600); connect(listWidget, &QListWidget::itemActivated, this, [this](QListWidgetItem *item) @@ -548,10 +548,11 @@ void MainWindow::saveMap() if(!issues.empty()) { + auto mapValidationTitle = tr("Map validation"); if(critical) - QMessageBox::warning(this, "Map validation", "Map has critical problems and most probably will not be playable. Open Validator from the Map menu to see issues found"); + QMessageBox::warning(this, mapValidationTitle, tr("Map has critical problems and most probably will not be playable. Open Validator from the Map menu to see issues found")); else - QMessageBox::information(this, "Map validation", "Map has some errors. Open Validator from the Map menu to see issues found"); + QMessageBox::information(this, mapValidationTitle, tr("Map has some errors. Open Validator from the Map menu to see issues found")); } Translations::cleanupRemovedItems(*controller.map()); @@ -575,7 +576,7 @@ void MainWindow::saveMap() } catch(const std::exception & e) { - QMessageBox::critical(this, "Failed to save map", e.what()); + QMessageBox::critical(this, tr("Failed to save map"), e.what()); return; } @@ -942,7 +943,7 @@ void MainWindow::loadObjectsTree() } catch(const std::exception &) { - QMessageBox::critical(this, "Mods loading problem", "Critical error during Mods loading. Disable invalid mods and restart."); + QMessageBox::critical(this, tr("Mods loading problem"), tr("Critical error during Mods loading. Disable invalid mods and restart.")); } }