1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Show content preview only for Witch Huts / Shrines / Tree

This commit is contained in:
Ivan Savenko 2023-10-19 15:17:58 +03:00
parent e0f6b582f5
commit 8f4791914e
7 changed files with 20 additions and 2 deletions

View File

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

View File

@ -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" : {

View File

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

View File

@ -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

View File

@ -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);
}

View File

@ -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;
}
};

View File

@ -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;