Sfoglia il codice sorgente

Show content preview only for Witch Huts / Shrines / Tree

Ivan Savenko 2 anni fa
parent
commit
8f4791914e

+ 2 - 0
config/objects/rewardableOncePerHero.json

@@ -242,6 +242,8 @@
 				"visitMode" : "hero",
 				"selectMode" : "selectFirst",
 				"canRefuse" : true,
+				"showScoutedPreview" : true,
+
 				"rewards" : [
 					{
 						"description" : "@core.arraytxt.202",

+ 3 - 0
config/objects/rewardableShrine.json

@@ -21,6 +21,7 @@
 				"visitMode" : "limiter",
 				"visitedTooltip" : 354,
 				"description" : "@core.xtrainfo.19",
+				"showScoutedPreview" : true,
 
 				"variables" : {
 					"spell" : {
@@ -89,6 +90,7 @@
 				"visitMode" : "limiter",
 				"visitedTooltip" : 354,
 				"description" : "@core.xtrainfo.20",
+				"showScoutedPreview" : true,
 
 				"variables" : {
 					"spell" : {
@@ -157,6 +159,7 @@
 				"visitMode" : "limiter",
 				"visitedTooltip" : 354,
 				"description" : "@core.xtrainfo.21",
+				"showScoutedPreview" : true,
 
 				"variables" : {
 					"spell" : {

+ 1 - 0
config/objects/rewardableWitchHut.json

@@ -21,6 +21,7 @@
 				"visitMode" : "limiter",
 				"visitedTooltip" : 354,
 				"description" : "@core.xtrainfo.12",
+				"showScoutedPreview" : true,
 
 				"variables" : {
 					"secondarySkill" : {

+ 8 - 2
lib/mapObjects/CRewardableObject.cpp

@@ -58,6 +58,9 @@ std::vector<Component> CRewardableObject::loadComponents(const CGHeroInstance *
 	if (rewardIndices.empty())
 		return result;
 
+	if (!configuration.showScoutedPreview)
+		return result;
+
 	if (configuration.selectMode != Rewardable::SELECT_FIRST)
 	{
 		for (auto index : rewardIndices)
@@ -300,10 +303,13 @@ std::string CRewardableObject::getDescriptionMessage(PlayerColor player, const C
 		return configuration.description.toString();
 
 	auto rewardIndices = getAvailableRewards(hero, Rewardable::EEventType::EVENT_FIRST_VISIT);
-	if (rewardIndices.empty())
+	if (rewardIndices.empty() && !configuration.info[0].description.empty())
 		return configuration.info[0].description.toString();
 
-	return configuration.info[rewardIndices.front()].description.toString();
+	if (!configuration.info[rewardIndices.front()].description.empty())
+		return configuration.info[rewardIndices.front()].description.toString();
+
+	return configuration.description.toString();
 }
 
 std::vector<Component> CRewardableObject::getPopupComponentsImpl(PlayerColor player, const CGHeroInstance * hero) const

+ 1 - 0
lib/rewardable/Configuration.cpp

@@ -84,6 +84,7 @@ void Rewardable::Configuration::serializeJson(JsonSerializeFormat & handler)
 	handler.serializeEnum("visitMode", visitMode, std::vector<std::string>{VisitModeString.begin(), VisitModeString.end()});
 	handler.serializeStruct("resetParameters", resetParameters);
 	handler.serializeBool("canRefuse", canRefuse);
+	handler.serializeBool("showScoutedPreview", showScoutedPreview);
 	handler.serializeInt("infoWindowType", infoWindowType);
 }
 

+ 4 - 0
lib/rewardable/Configuration.h

@@ -157,6 +157,9 @@ struct DLL_LINKAGE Configuration
 	/// if true - player can refuse visiting an object (e.g. Tomb)
 	bool canRefuse = false;
 
+	/// if true - right-clicking object will show preview of object rewards
+	bool showScoutedPreview = false;
+
 	/// if true - object info will shown in infobox (like resource pickup)
 	EInfoWindowMode infoWindowType = EInfoWindowMode::AUTO;
 	
@@ -183,6 +186,7 @@ struct DLL_LINKAGE Configuration
 		h & variables;
 		h & visitLimiter;
 		h & canRefuse;
+		h & showScoutedPreview;
 		h & infoWindowType;
 	}
 };

+ 1 - 0
lib/rewardable/Info.cpp

@@ -396,6 +396,7 @@ void Rewardable::Info::configureObject(Rewardable::Configuration & object, CRand
 	configureResetInfo(object, rng, object.resetParameters, parameters["resetParameters"]);
 
 	object.canRefuse = parameters["canRefuse"].Bool();
+	object.showScoutedPreview = parameters["showScoutedPreview"].Bool();
 
 	if(parameters["showInInfobox"].isNull())
 		object.infoWindowType = EInfoWindowMode::AUTO;