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

Some minor fixes

This commit is contained in:
nordsoft 2023-09-17 13:03:42 +02:00
parent a3b60bf829
commit 7b22aefb12
3 changed files with 27 additions and 28 deletions

View File

@ -171,60 +171,58 @@ void CGPandoraBox::serializeJsonOptions(JsonSerializeFormat & handler)
{
//backward compatibility
CCreatureSet::serializeJson(handler, "guards", 7);
Rewardable::Reward reward;
Rewardable::VisitInfo vinfo;
vinfo.visitType = Rewardable::EEventType::EVENT_FIRST_VISIT;
auto addReward = [this, &reward](bool condition)
auto addReward = [this, &vinfo](bool condition)
{
if(condition)
{
configuration.info.emplace_back();
configuration.info.back().visitType = Rewardable::EEventType::EVENT_FIRST_VISIT;
configuration.info.back().reward = reward;
reward = Rewardable::Reward{};
configuration.info.push_back(vinfo);
vinfo = Rewardable::VisitInfo{};
vinfo.visitType = Rewardable::EEventType::EVENT_FIRST_VISIT;
}
};
addReward(true);
int val;
handler.serializeInt("experience", reward.heroExperience, 0);
addReward(reward.heroExperience);
handler.serializeInt("experience", vinfo.reward.heroExperience, 0);
addReward(vinfo.reward.heroExperience);
handler.serializeInt("mana", reward.manaDiff, 0);
addReward(reward.manaDiff);
handler.serializeInt("mana", vinfo.reward.manaDiff, 0);
addReward(vinfo.reward.manaDiff);
handler.serializeInt("morale", val, 0);
if(val)
reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::MORALE, BonusSource::OBJECT, val, id);
vinfo.reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::MORALE, BonusSource::OBJECT, val, id);
addReward(val);
handler.serializeInt("luck", val, 0);
if(val)
reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::LUCK, BonusSource::OBJECT, val, id);
vinfo.reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::LUCK, BonusSource::OBJECT, val, id);
addReward(val);
reward.resources.serializeJson(handler, "resources");
addReward(reward.resources.nonZero());
vinfo.reward.resources.serializeJson(handler, "resources");
addReward(vinfo.reward.resources.nonZero());
{
bool updateReward = false;
auto s = handler.enterStruct("primarySkills");
for(int idx = 0; idx < reward.primary.size(); idx ++)
for(int idx = 0; idx < vinfo.reward.primary.size(); idx ++)
{
handler.serializeInt(NPrimarySkill::names[idx], reward.primary[idx], 0);
updateReward |= bool(reward.primary[idx]);
handler.serializeInt(NPrimarySkill::names[idx], vinfo.reward.primary[idx], 0);
updateReward |= bool(vinfo.reward.primary[idx]);
}
addReward(updateReward);
}
handler.serializeIdArray("artifacts", reward.artifacts);
addReward(!reward.artifacts.empty());
handler.serializeIdArray("artifacts", vinfo.reward.artifacts);
addReward(!vinfo.reward.artifacts.empty());
handler.serializeIdArray("spells", reward.spells);
addReward(!reward.spells.empty());
handler.serializeIdArray("spells", vinfo.reward.spells);
addReward(!vinfo.reward.spells.empty());
handler.enterArray("creatures").serializeStruct(reward.creatures);
addReward(!reward.creatures.empty());
handler.enterArray("creatures").serializeStruct(vinfo.reward.creatures);
addReward(!vinfo.reward.creatures.empty());
{
bool updateReward = false;
@ -248,7 +246,7 @@ void CGPandoraBox::serializeJsonOptions(JsonSerializeFormat & handler)
continue;
}
reward.secondary[rawId] = level;
vinfo.reward.secondary[rawId] = level;
updateReward = true;
}
addReward(updateReward);

View File

@ -218,6 +218,7 @@ bool RewardsWidget::commitChanges()
void RewardsWidget::saveCurrentVisitInfo(int index)
{
auto & vinfo = object.configuration.info.at(index);
vinfo.visitType = Rewardable::EEventType::EVENT_FIRST_VISIT;
vinfo.message = MetaString::createFromRawString(ui->rewardMessage->text().toStdString());
vinfo.reward.heroLevel = ui->rHeroLevel->value();

View File

@ -49,7 +49,7 @@
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="spacing">
<number>-3</number>
<number>0</number>
</property>
</widget>
</item>