mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Inspector widgets set string ID
This commit is contained in:
@@ -301,26 +301,17 @@ void TextLocalizationContainer::registerString(const std::string & modContext, c
|
|||||||
if(stringsLocalizations.count(UID.get()) > 0)
|
if(stringsLocalizations.count(UID.get()) > 0)
|
||||||
{
|
{
|
||||||
auto & value = stringsLocalizations[UID.get()];
|
auto & value = stringsLocalizations[UID.get()];
|
||||||
|
value.baseLanguage = language;
|
||||||
if(value.baseLanguage.empty())
|
value.baseValue = localized;
|
||||||
{
|
|
||||||
value.baseLanguage = language;
|
|
||||||
value.baseValue = localized;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(value.baseValue != localized)
|
|
||||||
logMod->warn("Duplicate registered string '%s' found! Old value: '%s', new value: '%s'", UID.get(), value.baseValue, localized);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringState result;
|
StringState value;
|
||||||
result.baseLanguage = language;
|
value.baseLanguage = language;
|
||||||
result.baseValue = localized;
|
value.baseValue = localized;
|
||||||
result.modContext = modContext;
|
value.modContext = modContext;
|
||||||
|
|
||||||
stringsLocalizations[UID.get()] = result;
|
stringsLocalizations[UID.get()] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -277,8 +277,8 @@ void Inspector::updateProperties(CGHeroInstance * o)
|
|||||||
delegate->options = {{"MALE", QVariant::fromValue(int(EHeroGender::MALE))}, {"FEMALE", QVariant::fromValue(int(EHeroGender::FEMALE))}};
|
delegate->options = {{"MALE", QVariant::fromValue(int(EHeroGender::MALE))}, {"FEMALE", QVariant::fromValue(int(EHeroGender::FEMALE))}};
|
||||||
addProperty<std::string>("Gender", (o->gender == EHeroGender::FEMALE ? "FEMALE" : "MALE"), delegate , false);
|
addProperty<std::string>("Gender", (o->gender == EHeroGender::FEMALE ? "FEMALE" : "MALE"), delegate , false);
|
||||||
}
|
}
|
||||||
addProperty("Name", o->nameCustomTextId, false);
|
addProperty("Name", o->getNameTranslated(), false);
|
||||||
addProperty("Biography", o->biographyCustomTextId, new MessageDelegate, false);
|
addProperty("Biography", o->getBiographyTranslated(), new MessageDelegate, false);
|
||||||
addProperty("Portrait", o->portrait, false);
|
addProperty("Portrait", o->portrait, false);
|
||||||
|
|
||||||
auto * delegate = new HeroSkillsDelegate(*o);
|
auto * delegate = new HeroSkillsDelegate(*o);
|
||||||
@@ -531,7 +531,7 @@ void Inspector::setProperty(CGPandoraBox * o, const QString & key, const QVarian
|
|||||||
if(!o) return;
|
if(!o) return;
|
||||||
|
|
||||||
if(key == "Message")
|
if(key == "Message")
|
||||||
o->message.appendRawString(value.toString().toStdString());
|
o->message.appendTextID(mapWriteStringId(TextIdentifier("guards", o->instanceName, "message"), value.toString().toStdString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inspector::setProperty(CGEvent * o, const QString & key, const QVariant & value)
|
void Inspector::setProperty(CGEvent * o, const QString & key, const QVariant & value)
|
||||||
@@ -553,7 +553,7 @@ void Inspector::setProperty(CGTownInstance * o, const QString & key, const QVari
|
|||||||
if(!o) return;
|
if(!o) return;
|
||||||
|
|
||||||
if(key == "Town name")
|
if(key == "Town name")
|
||||||
o->setNameTextId(value.toString().toStdString());
|
o->setNameTextId(mapWriteStringId(TextIdentifier("town", o->instanceName, "name"), value.toString().toStdString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inspector::setProperty(CGSignBottle * o, const QString & key, const QVariant & value)
|
void Inspector::setProperty(CGSignBottle * o, const QString & key, const QVariant & value)
|
||||||
@@ -561,7 +561,7 @@ void Inspector::setProperty(CGSignBottle * o, const QString & key, const QVarian
|
|||||||
if(!o) return;
|
if(!o) return;
|
||||||
|
|
||||||
if(key == "Message")
|
if(key == "Message")
|
||||||
o->message.appendRawString(value.toString().toStdString());
|
o->message.appendTextID(mapWriteStringId(TextIdentifier("sign", o->instanceName, "message"), value.toString().toStdString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inspector::setProperty(CGMine * o, const QString & key, const QVariant & value)
|
void Inspector::setProperty(CGMine * o, const QString & key, const QVariant & value)
|
||||||
@@ -577,7 +577,7 @@ void Inspector::setProperty(CGArtifact * o, const QString & key, const QVariant
|
|||||||
if(!o) return;
|
if(!o) return;
|
||||||
|
|
||||||
if(key == "Message")
|
if(key == "Message")
|
||||||
o->message.appendRawString(value.toString().toStdString());
|
o->message.appendTextID(mapWriteStringId(TextIdentifier("guards", o->instanceName, "message"), value.toString().toStdString()));
|
||||||
|
|
||||||
if(o->storedArtifact && key == "Spell")
|
if(o->storedArtifact && key == "Spell")
|
||||||
{
|
{
|
||||||
@@ -606,7 +606,10 @@ void Inspector::setProperty(CGHeroInstance * o, const QString & key, const QVari
|
|||||||
o->gender = EHeroGender(value.toInt());
|
o->gender = EHeroGender(value.toInt());
|
||||||
|
|
||||||
if(key == "Name")
|
if(key == "Name")
|
||||||
o->nameCustomTextId = value.toString().toStdString();
|
o->nameCustomTextId = mapWriteStringId(TextIdentifier("hero", o->instanceName, "name"), value.toString().toStdString());
|
||||||
|
|
||||||
|
if(key == "Biography")
|
||||||
|
o->biographyCustomTextId = mapWriteStringId(TextIdentifier("hero", o->instanceName, "biography"), value.toString().toStdString());
|
||||||
|
|
||||||
if(key == "Experience")
|
if(key == "Experience")
|
||||||
o->exp = value.toString().toInt();
|
o->exp = value.toString().toInt();
|
||||||
@@ -643,7 +646,7 @@ void Inspector::setProperty(CGCreature * o, const QString & key, const QVariant
|
|||||||
if(!o) return;
|
if(!o) return;
|
||||||
|
|
||||||
if(key == "Message")
|
if(key == "Message")
|
||||||
o->message.appendRawString(value.toString().toStdString());
|
o->message.appendTextID(mapWriteStringId(TextIdentifier("monster", o->instanceName, "message"), value.toString().toStdString()));
|
||||||
if(key == "Character")
|
if(key == "Character")
|
||||||
o->character = CGCreature::Character(value.toInt());
|
o->character = CGCreature::Character(value.toInt());
|
||||||
if(key == "Never flees")
|
if(key == "Never flees")
|
||||||
@@ -661,11 +664,11 @@ void Inspector::setProperty(CGSeerHut * o, const QString & key, const QVariant &
|
|||||||
if(key == "Mission type")
|
if(key == "Mission type")
|
||||||
o->quest->missionType = CQuest::Emission(value.toInt());
|
o->quest->missionType = CQuest::Emission(value.toInt());
|
||||||
if(key == "First visit text")
|
if(key == "First visit text")
|
||||||
o->quest->firstVisitText.appendRawString(value.toString().toStdString());
|
o->quest->firstVisitText.appendTextID(mapWriteStringId(TextIdentifier("quest", o->instanceName, "firstVisit"), value.toString().toStdString()));
|
||||||
if(key == "Next visit text")
|
if(key == "Next visit text")
|
||||||
o->quest->nextVisitText.appendRawString(value.toString().toStdString());
|
o->quest->nextVisitText.appendTextID(mapWriteStringId(TextIdentifier("quest", o->instanceName, "nextVisit"), value.toString().toStdString()));
|
||||||
if(key == "Completed text")
|
if(key == "Completed text")
|
||||||
o->quest->completedText.appendRawString(value.toString().toStdString());
|
o->quest->completedText.appendTextID(mapWriteStringId(TextIdentifier("quest", o->instanceName, "completed"), value.toString().toStdString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -713,6 +716,11 @@ QTableWidgetItem * Inspector::addProperty(const std::string & value)
|
|||||||
return addProperty(QString::fromStdString(value));
|
return addProperty(QString::fromStdString(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTableWidgetItem * Inspector::addProperty(const TextIdentifier & value)
|
||||||
|
{
|
||||||
|
return addProperty(VLC->generaltexth->translate(value.get()));
|
||||||
|
}
|
||||||
|
|
||||||
QTableWidgetItem * Inspector::addProperty(const MetaString & value)
|
QTableWidgetItem * Inspector::addProperty(const MetaString & value)
|
||||||
{
|
{
|
||||||
return addProperty(value.toString());
|
return addProperty(value.toString());
|
||||||
@@ -797,6 +805,12 @@ Inspector::Inspector(CMap * m, CGObjectInstance * o, QTableWidget * t): obj(o),
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Inspector::mapWriteStringId(const TextIdentifier & stringIdentifier, const std::string & localized)
|
||||||
|
{
|
||||||
|
map->registerString("map", stringIdentifier, localized);
|
||||||
|
return stringIdentifier.get();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delegates
|
* Delegates
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "../lib/mapObjects/CGCreature.h"
|
#include "../lib/mapObjects/CGCreature.h"
|
||||||
#include "../lib/mapObjects/MapObjects.h"
|
#include "../lib/mapObjects/MapObjects.h"
|
||||||
#include "../lib/mapObjects/CRewardableObject.h"
|
#include "../lib/mapObjects/CRewardableObject.h"
|
||||||
|
#include "../lib/CGeneralTextHandler.h"
|
||||||
#include "../lib/ResourceSet.h"
|
#include "../lib/ResourceSet.h"
|
||||||
#include "../lib/MetaString.h"
|
#include "../lib/MetaString.h"
|
||||||
|
|
||||||
@@ -85,6 +86,7 @@ protected:
|
|||||||
QTableWidgetItem * addProperty(unsigned int value);
|
QTableWidgetItem * addProperty(unsigned int value);
|
||||||
QTableWidgetItem * addProperty(int value);
|
QTableWidgetItem * addProperty(int value);
|
||||||
QTableWidgetItem * addProperty(const MetaString & value);
|
QTableWidgetItem * addProperty(const MetaString & value);
|
||||||
|
QTableWidgetItem * addProperty(const TextIdentifier & value);
|
||||||
QTableWidgetItem * addProperty(const std::string & value);
|
QTableWidgetItem * addProperty(const std::string & value);
|
||||||
QTableWidgetItem * addProperty(const QString & value);
|
QTableWidgetItem * addProperty(const QString & value);
|
||||||
QTableWidgetItem * addProperty(const int3 & value);
|
QTableWidgetItem * addProperty(const int3 & value);
|
||||||
@@ -147,6 +149,8 @@ protected:
|
|||||||
addProperty<T>(key, value, nullptr, restricted);
|
addProperty<T>(key, value, nullptr, restricted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string mapWriteStringId(const TextIdentifier & stringIdentifier, const std::string & localized);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int row = 0;
|
int row = 0;
|
||||||
QTableWidget * table;
|
QTableWidget * table;
|
||||||
|
|||||||
Reference in New Issue
Block a user