2
0
Эх сурвалжийг харах

Add description for University using H3 string

Ivan Savenko 3 сар өмнө
parent
commit
283230eb4e

+ 2 - 1
config/objects/markets.json

@@ -124,6 +124,7 @@
 					"rarity"	: 20
 				},
 				"modes" : ["resource-skill"],
+				"description" : "@core.xtrainfo.24",
 				"speech" : "@core.genrltxt.603",
 				"offer": 
 				[
@@ -135,4 +136,4 @@
 			}
 		}
 	}
-}
+}

+ 18 - 2
lib/mapObjectConstructors/MarketInstanceConstructor.cpp

@@ -18,6 +18,8 @@
 #include "../texts/CGeneralTextHandler.h"
 #include "../texts/TextIdentifier.h"
 
+VCMI_LIB_NAMESPACE_BEGIN
+
 void MarketInstanceConstructor::initTypeData(const JsonNode & input)
 {
 	if (settings["mods"]["validation"].String() != "off")
@@ -26,8 +28,15 @@ void MarketInstanceConstructor::initTypeData(const JsonNode & input)
 	if (!input["description"].isNull())
 	{
 		std::string description = input["description"].String();
-		descriptionTextID = TextIdentifier(getBaseTextID(), "description").get();
-		LIBRARY->generaltexth->registerString( input.getModScope(), descriptionTextID, input["description"]);
+		if (!description.empty() && description.at(0) == '@')
+		{
+			descriptionTextID = description.substr(1);
+		}
+		else
+		{
+			descriptionTextID = TextIdentifier(getBaseTextID(), "description").get();
+			LIBRARY->generaltexth->registerString( input.getModScope(), descriptionTextID, input["description"]);
+		}
 	}
 
 	if (!input["speech"].isNull())
@@ -59,6 +68,11 @@ bool MarketInstanceConstructor::hasDescription() const
 	return !descriptionTextID.empty();
 }
 
+std::string MarketInstanceConstructor::getDescriptionTextID() const
+{
+	return descriptionTextID;
+}
+
 std::shared_ptr<CGMarket> MarketInstanceConstructor::createObject(IGameInfoCallback * cb) const
 {
 	if(marketModes.size() == 1)
@@ -103,3 +117,5 @@ int MarketInstanceConstructor::getMarketEfficiency() const
 {
 	return marketEfficiency;
 }
+
+VCMI_LIB_NAMESPACE_END

+ 1 - 0
lib/mapObjectConstructors/MarketInstanceConstructor.h

@@ -31,6 +31,7 @@ public:
 
 	const std::set<EMarketMode> & availableModes() const;
 	bool hasDescription() const;
+	std::string getDescriptionTextID() const;
 
 	std::string getSpeechTranslated() const;
 	int getMarketEfficiency() const;

+ 1 - 1
lib/mapObjects/CGMarket.cpp

@@ -51,7 +51,7 @@ std::string CGMarket::getPopupText(PlayerColor player) const
 
 	MetaString message = MetaString::createFromRawString("{%s}\r\n\r\n%s");
 	message.replaceName(ID, subID);
-	message.replaceTextID(TextIdentifier(getObjectHandler()->getBaseTextID(), "description").get());
+	message.replaceTextID(getMarketHandler()->getDescriptionTextID());
 	return message.toString();
 }