1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-15 13:33:36 +02:00

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

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

View File

@ -219,7 +219,12 @@ void PlayerLocalState::removeWanderingHero(const CGHeroInstance * hero)
if (hero == currentSelection)
{
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);
@ -334,7 +339,8 @@ void PlayerLocalState::serialize(JsonNode & dest) const
dest["spellbook"]["tabBattle"].Integer() = spellbookSettings.spellbookLastTabBattle;
dest["spellbook"]["tabAdvmap"].Integer() = spellbookSettings.spellbookLastTabAdvmap;
dest["currentSelection"].Integer() = currentSelection->id;
if (currentSelection)
dest["currentSelection"].Integer() = currentSelection->id;
}
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)
{
auto info = std::make_shared<ElementInfo>();
//allItems[i].date = std::asctime(std::localtime(&files[i].date));
info->fileURI = file.getOriginalName();
info->name = info->getNameForList();
info->campaignInit();
info->name = info->getNameForList();
if(info->campaign)
allItems.push_back(info);
}

View File

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

View File

@ -47,7 +47,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-126</y>
<y>-797</y>
<width>729</width>
<height>1503</height>
</rect>
@ -261,31 +261,6 @@
</property>
</widget>
</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">
<widget class="QLabel" name="labelSoundVolume">
<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">
<widget class="QComboBox" name="comboBoxResolution"/>
</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>
</widget>
</widget>

View File

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

View File

@ -309,7 +309,11 @@ const CHeroClass * CGHeroInstance::getHeroClass() 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

View File

@ -208,7 +208,7 @@ int CGObjectInstance::getSightRadius() const
int3 CGObjectInstance::getVisitableOffset() const
{
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();
}
@ -308,7 +308,7 @@ void CGObjectInstance::onHeroVisit( const CGHeroInstance * h ) const
int3 CGObjectInstance::visitablePos() const
{
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();
}

View File

@ -95,19 +95,7 @@ void CRewardableObject::blockingDialogAnswered(const CGHeroInstance * hero, int3
}
else
{
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");
}
onBlockingDialogAnswered(hero, answer);
}
}

View File

@ -131,21 +131,7 @@ void TownRewardableBuildingInstance::heroLevelUpDone(const CGHeroInstance *hero)
void TownRewardableBuildingInstance::blockingDialogAnswered(const CGHeroInstance *hero, int32_t answer) const
{
if(answer == 0)
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");
}
onBlockingDialogAnswered(hero, answer);
}
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

View File

@ -48,6 +48,8 @@ protected:
virtual void markAsVisited(const CGHeroInstance * hero) const = 0;
virtual void markAsScouted(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:
/// 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;
}
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())
{
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));
}
}
gameHandler->sendAndApply(sac); //show dialog
}
gameHandler->sendAndApply(iw); //show dialog
}