1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-10 22:31:40 +02:00

Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
Xilmi
2024-10-11 19:07:56 +02:00
13 changed files with 79 additions and 62 deletions

View File

@@ -219,7 +219,12 @@ void PlayerLocalState::removeWanderingHero(const CGHeroInstance * hero)
if (hero == currentSelection) if (hero == currentSelection)
{ {
auto const * nextHero = getNextWanderingHero(hero); auto const * nextHero = getNextWanderingHero(hero);
setSelection(nextHero); if (nextHero)
setSelection(nextHero);
else if (!ownedTowns.empty())
setSelection(ownedTowns.front());
else
setSelection(nullptr);
} }
vstd::erase(wanderingHeroes, hero); vstd::erase(wanderingHeroes, hero);
@@ -334,7 +339,8 @@ void PlayerLocalState::serialize(JsonNode & dest) const
dest["spellbook"]["tabBattle"].Integer() = spellbookSettings.spellbookLastTabBattle; dest["spellbook"]["tabBattle"].Integer() = spellbookSettings.spellbookLastTabBattle;
dest["spellbook"]["tabAdvmap"].Integer() = spellbookSettings.spellbookLastTabAdvmap; dest["spellbook"]["tabAdvmap"].Integer() = spellbookSettings.spellbookLastTabAdvmap;
dest["currentSelection"].Integer() = currentSelection->id; if (currentSelection)
dest["currentSelection"].Integer() = currentSelection->id;
} }
void PlayerLocalState::deserialize(const JsonNode & source) void PlayerLocalState::deserialize(const JsonNode & source)

View File

@@ -874,10 +874,9 @@ void SelectionTab::parseCampaigns(const std::unordered_set<ResourcePath> & files
for(auto & file : files) for(auto & file : files)
{ {
auto info = std::make_shared<ElementInfo>(); auto info = std::make_shared<ElementInfo>();
//allItems[i].date = std::asctime(std::localtime(&files[i].date));
info->fileURI = file.getOriginalName(); info->fileURI = file.getOriginalName();
info->name = info->getNameForList();
info->campaignInit(); info->campaignInit();
info->name = info->getNameForList();
if(info->campaign) if(info->campaign)
allItems.push_back(info); allItems.push_back(info);
} }

View File

@@ -70,7 +70,7 @@
//Playing with Fire //Playing with Fire
"H3ABpf1.smk", //PlayingWithFire_a "H3ABpf1.smk", //PlayingWithFire_a
"H3ABpf2.smk", //PlayingWithFire_b "H3ABpf2.smk", //PlayingWithFire_b
"3ABpf3.smk", //PlayingWithFire_c "H3ABpf3.smk", //PlayingWithFire_c
"H3ABpf4.smk", //PlayingWithFire_end "H3ABpf4.smk", //PlayingWithFire_end
//Shadow of Death Campaigns //Shadow of Death Campaigns
//Birth of a Barbarian //Birth of a Barbarian

View File

@@ -47,7 +47,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>-126</y> <y>-797</y>
<width>729</width> <width>729</width>
<height>1503</height> <height>1503</height>
</rect> </rect>
@@ -261,31 +261,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="60" column="4">
<widget class="QToolButton" name="buttonValidationBasic">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Basic</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupValidation</string>
</attribute>
</widget>
</item>
<item row="31" column="0"> <item row="31" column="0">
<widget class="QLabel" name="labelSoundVolume"> <widget class="QLabel" name="labelSoundVolume">
<property name="text"> <property name="text">
@@ -1449,6 +1424,31 @@ Fullscreen Exclusive Mode - game will cover entirety of your screen and will use
<item row="12" column="1" colspan="5"> <item row="12" column="1" colspan="5">
<widget class="QComboBox" name="comboBoxResolution"/> <widget class="QComboBox" name="comboBoxResolution"/>
</item> </item>
<item row="60" column="3" colspan="2">
<widget class="QToolButton" name="buttonValidationBasic">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Basic</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupValidation</string>
</attribute>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>

View File

@@ -241,6 +241,7 @@ JsonNode JsonUtils::assembleFromFiles(const JsonNode & files, bool & isValid)
} }
else else
{ {
isValid = true;
return files; return files;
} }
} }

View File

@@ -309,7 +309,11 @@ const CHeroClass * CGHeroInstance::getHeroClass() const
HeroClassID CGHeroInstance::getHeroClassID() const HeroClassID CGHeroInstance::getHeroClassID() const
{ {
return getHeroType()->heroClass->getId(); auto heroType = getHeroTypeID();
if (heroType.hasValue())
return getHeroType()->heroClass->getId();
else
return HeroClassID();
} }
const CHero * CGHeroInstance::getHeroType() const const CHero * CGHeroInstance::getHeroType() const

View File

@@ -208,7 +208,7 @@ int CGObjectInstance::getSightRadius() const
int3 CGObjectInstance::getVisitableOffset() const int3 CGObjectInstance::getVisitableOffset() const
{ {
if (!isVisitable()) if (!isVisitable())
throw std::runtime_error("Attempt to access visitable offset of a non-visitable object!"); logGlobal->debug("Attempt to access visitable offset on a non-visitable object!");
return appearance->getVisitableOffset(); return appearance->getVisitableOffset();
} }
@@ -308,7 +308,7 @@ void CGObjectInstance::onHeroVisit( const CGHeroInstance * h ) const
int3 CGObjectInstance::visitablePos() const int3 CGObjectInstance::visitablePos() const
{ {
if (!isVisitable()) if (!isVisitable())
throw std::runtime_error("Attempt to access visitable position on a non-visitable object!"); logGlobal->debug("Attempt to access visitable position on a non-visitable object!");
return pos - getVisitableOffset(); return pos - getVisitableOffset();
} }

View File

@@ -95,19 +95,7 @@ void CRewardableObject::blockingDialogAnswered(const CGHeroInstance * hero, int3
} }
else else
{ {
if (answer == 0) onBlockingDialogAnswered(hero, answer);
return; //Player refused
if(answer > 0 && answer - 1 < configuration.info.size())
{
auto list = getAvailableRewards(hero, Rewardable::EEventType::EVENT_FIRST_VISIT);
markAsVisited(hero);
grantReward(list[answer - 1], hero);
}
else
{
throw std::runtime_error("Unhandled choice");
}
} }
} }

View File

@@ -131,21 +131,7 @@ void TownRewardableBuildingInstance::heroLevelUpDone(const CGHeroInstance *hero)
void TownRewardableBuildingInstance::blockingDialogAnswered(const CGHeroInstance *hero, int32_t answer) const void TownRewardableBuildingInstance::blockingDialogAnswered(const CGHeroInstance *hero, int32_t answer) const
{ {
if(answer == 0) onBlockingDialogAnswered(hero, answer);
return; // player refused
if(visitors.find(hero->id) != visitors.end())
return; // query not for this building
if(answer > 0 && answer-1 < configuration.info.size())
{
auto list = getAvailableRewards(hero, Rewardable::EEventType::EVENT_FIRST_VISIT);
grantReward(list[answer - 1], hero);
}
else
{
throw std::runtime_error("Unhandled choice");
}
} }
void TownRewardableBuildingInstance::grantReward(ui32 rewardID, const CGHeroInstance * hero) const void TownRewardableBuildingInstance::grantReward(ui32 rewardID, const CGHeroInstance * hero) const

View File

@@ -366,4 +366,21 @@ void Rewardable::Interface::doHeroVisit(const CGHeroInstance *h) const
} }
} }
void Rewardable::Interface::onBlockingDialogAnswered(const CGHeroInstance * hero, int32_t answer) const
{
if (answer == 0)
return; //Player refused
if(answer > 0 && answer - 1 < configuration.info.size())
{
auto list = getAvailableRewards(hero, Rewardable::EEventType::EVENT_FIRST_VISIT);
markAsVisited(hero);
grantReward(list[answer - 1], hero);
}
else
{
throw std::runtime_error("Unhandled choice");
}
}
VCMI_LIB_NAMESPACE_END VCMI_LIB_NAMESPACE_END

View File

@@ -48,6 +48,8 @@ protected:
virtual void markAsVisited(const CGHeroInstance * hero) const = 0; virtual void markAsVisited(const CGHeroInstance * hero) const = 0;
virtual void markAsScouted(const CGHeroInstance * hero) const = 0; virtual void markAsScouted(const CGHeroInstance * hero) const = 0;
virtual void grantReward(ui32 rewardID, const CGHeroInstance * hero) const = 0; virtual void grantReward(ui32 rewardID, const CGHeroInstance * hero) const = 0;
void onBlockingDialogAnswered(const CGHeroInstance * hero, int32_t answer) const;
public: public:
/// filters list of visit info and returns rewards that can be granted to current hero /// filters list of visit info and returns rewards that can be granted to current hero

View File

@@ -139,6 +139,18 @@ void Initializer::initialize(CGHeroInstance * o)
o->tempOwner = PlayerColor::NEUTRAL; o->tempOwner = PlayerColor::NEUTRAL;
} }
if(o->ID == Obj::HERO)
{
for(auto const & t : VLC->heroh->objects)
{
if(t->heroClass->getId() == HeroClassID(o->subID))
{
o->subID = t->getId();
break;
}
}
}
if(o->getHeroTypeID().hasValue()) if(o->getHeroTypeID().hasValue())
{ {
o->gender = o->getHeroType()->gender; o->gender = o->getHeroType()->gender;

View File

@@ -116,6 +116,8 @@ void NewTurnProcessor::handleTownEvents(const CGTownInstance * town)
iw.components.emplace_back(ComponentType::CREATURE, town->creatures.at(i).second.back(), event.creatures.at(i)); iw.components.emplace_back(ComponentType::CREATURE, town->creatures.at(i).second.back(), event.creatures.at(i));
} }
} }
gameHandler->sendAndApply(sac); //show dialog
} }
gameHandler->sendAndApply(iw); //show dialog gameHandler->sendAndApply(iw); //show dialog
} }