From 8f4791914ed567717a14ce0a32104fcefe8a935b Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Thu, 19 Oct 2023 15:17:58 +0300 Subject: [PATCH] Show content preview only for Witch Huts / Shrines / Tree --- config/objects/rewardableOncePerHero.json | 2 ++ config/objects/rewardableShrine.json | 3 +++ config/objects/rewardableWitchHut.json | 1 + lib/mapObjects/CRewardableObject.cpp | 10 ++++++++-- lib/rewardable/Configuration.cpp | 1 + lib/rewardable/Configuration.h | 4 ++++ lib/rewardable/Info.cpp | 1 + 7 files changed, 20 insertions(+), 2 deletions(-) diff --git a/config/objects/rewardableOncePerHero.json b/config/objects/rewardableOncePerHero.json index c582b2f0f..43065ed8d 100644 --- a/config/objects/rewardableOncePerHero.json +++ b/config/objects/rewardableOncePerHero.json @@ -242,6 +242,8 @@ "visitMode" : "hero", "selectMode" : "selectFirst", "canRefuse" : true, + "showScoutedPreview" : true, + "rewards" : [ { "description" : "@core.arraytxt.202", diff --git a/config/objects/rewardableShrine.json b/config/objects/rewardableShrine.json index 50a78d5a8..44bd2a952 100644 --- a/config/objects/rewardableShrine.json +++ b/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" : { diff --git a/config/objects/rewardableWitchHut.json b/config/objects/rewardableWitchHut.json index 006aff7dc..ad5d036df 100644 --- a/config/objects/rewardableWitchHut.json +++ b/config/objects/rewardableWitchHut.json @@ -21,6 +21,7 @@ "visitMode" : "limiter", "visitedTooltip" : 354, "description" : "@core.xtrainfo.12", + "showScoutedPreview" : true, "variables" : { "secondarySkill" : { diff --git a/lib/mapObjects/CRewardableObject.cpp b/lib/mapObjects/CRewardableObject.cpp index 0599f689c..75437c925 100644 --- a/lib/mapObjects/CRewardableObject.cpp +++ b/lib/mapObjects/CRewardableObject.cpp @@ -58,6 +58,9 @@ std::vector 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 CRewardableObject::getPopupComponentsImpl(PlayerColor player, const CGHeroInstance * hero) const diff --git a/lib/rewardable/Configuration.cpp b/lib/rewardable/Configuration.cpp index 427c01401..18788473f 100644 --- a/lib/rewardable/Configuration.cpp +++ b/lib/rewardable/Configuration.cpp @@ -84,6 +84,7 @@ void Rewardable::Configuration::serializeJson(JsonSerializeFormat & handler) handler.serializeEnum("visitMode", visitMode, std::vector{VisitModeString.begin(), VisitModeString.end()}); handler.serializeStruct("resetParameters", resetParameters); handler.serializeBool("canRefuse", canRefuse); + handler.serializeBool("showScoutedPreview", showScoutedPreview); handler.serializeInt("infoWindowType", infoWindowType); } diff --git a/lib/rewardable/Configuration.h b/lib/rewardable/Configuration.h index 2fb901651..c31290506 100644 --- a/lib/rewardable/Configuration.h +++ b/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; } }; diff --git a/lib/rewardable/Info.cpp b/lib/rewardable/Info.cpp index 69ed5dadd..61d12282f 100644 --- a/lib/rewardable/Info.cpp +++ b/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;