mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
crash fixed
This commit is contained in:
@@ -30,46 +30,48 @@
|
||||
|
||||
void CArtPlace::setInternals(const CArtifactInstance * artInst)
|
||||
{
|
||||
baseType = -1; // By default we don't store any component
|
||||
ourArt = artInst;
|
||||
if(!artInst)
|
||||
{
|
||||
image->disable();
|
||||
imageSpell->disable();
|
||||
text.clear();
|
||||
hoverText = CGI->generaltexth->allTexts[507];
|
||||
return;
|
||||
}
|
||||
|
||||
image->enable();
|
||||
imageSpell->disable();
|
||||
image->setFrame(artInst->artType->getIconIndex());
|
||||
|
||||
imageIndex = artInst->artType->getIconIndex();
|
||||
if(artInst->getTypeId() == ArtifactID::SPELL_SCROLL)
|
||||
{
|
||||
auto spellID = artInst->getScrollSpellID();
|
||||
if(spellID.num >= 0)
|
||||
{
|
||||
// Add spell component info (used to provide a pic in r-click popup)
|
||||
baseType = CComponent::spell;
|
||||
type = spellID;
|
||||
bonusValue = 0;
|
||||
assert(spellID.num >= 0);
|
||||
|
||||
if(settings["general"]["enableUiEnhancements"].Bool())
|
||||
if(settings["general"]["enableUiEnhancements"].Bool())
|
||||
{
|
||||
imageIndex = spellID.num;
|
||||
if(baseType != CComponent::spell)
|
||||
{
|
||||
imageSpell->enable();
|
||||
image->disable();
|
||||
imageSpell->setFrame(spellID.num);
|
||||
image->setScale(Point(pos.w, 34));
|
||||
image->setAnimationPath(AnimationPath::builtin("spellscr"), imageIndex);
|
||||
image->moveTo(Point(pos.x, pos.y + 4));
|
||||
}
|
||||
}
|
||||
// Add spell component info (used to provide a pic in r-click popup)
|
||||
baseType = CComponent::spell;
|
||||
type = spellID;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(settings["general"]["enableUiEnhancements"].Bool() && baseType != CComponent::artifact)
|
||||
{
|
||||
image->setScale(Point());
|
||||
image->setAnimationPath(AnimationPath::builtin("artifact"), imageIndex);
|
||||
image->moveTo(Point(pos.x, pos.y));
|
||||
}
|
||||
baseType = CComponent::artifact;
|
||||
type = artInst->getTypeId();
|
||||
bonusValue = 0;
|
||||
}
|
||||
|
||||
bonusValue = 0;
|
||||
image->enable();
|
||||
text = artInst->getDescription();
|
||||
}
|
||||
|
||||
@@ -99,7 +101,7 @@ void CCommanderArtPlace::createImage()
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE);
|
||||
|
||||
int imageIndex = 0;
|
||||
imageIndex = 0;
|
||||
if(ourArt)
|
||||
imageIndex = ourArt->artType->getIconIndex();
|
||||
|
||||
@@ -165,7 +167,7 @@ void CHeroArtPlace::lockSlot(bool on)
|
||||
if(on)
|
||||
image->setFrame(ArtifactID::ART_LOCK);
|
||||
else if(ourArt)
|
||||
image->setFrame(ourArt->artType->getIconIndex());
|
||||
image->setFrame(imageIndex);
|
||||
else
|
||||
image->setFrame(0);
|
||||
}
|
||||
@@ -220,7 +222,7 @@ void CHeroArtPlace::setArtifact(const CArtifactInstance * art)
|
||||
setInternals(art);
|
||||
if(art)
|
||||
{
|
||||
image->setFrame(locked ? ArtifactID::ART_LOCK : art->artType->getIconIndex());
|
||||
image->setFrame(locked ? static_cast<int>(ArtifactID::ART_LOCK) : imageIndex);
|
||||
|
||||
if(locked) // Locks should appear as empty.
|
||||
hoverText = CGI->generaltexth->allTexts[507];
|
||||
@@ -261,13 +263,8 @@ void CHeroArtPlace::createImage()
|
||||
else if(ourArt)
|
||||
imageIndex = ourArt->artType->getIconIndex();
|
||||
|
||||
imageSpell = std::make_shared<CAnimImage>(GH.renderHandler().loadAnimation(AnimationPath::builtin("spellscr")), 0, Rect(0, 5, 44, 34));
|
||||
image = std::make_shared<CAnimImage>(AnimationPath::builtin("artifact"), imageIndex);
|
||||
if(!ourArt)
|
||||
{
|
||||
image->disable();
|
||||
imageSpell->disable();
|
||||
}
|
||||
image->disable();
|
||||
|
||||
selection = std::make_shared<CAnimImage>(AnimationPath::builtin("artifact"), ArtifactID::ART_SELECTION);
|
||||
selection->disable();
|
||||
|
@@ -34,8 +34,8 @@ class CArtPlace : public LRClickableAreaWTextComp
|
||||
{
|
||||
protected:
|
||||
std::shared_ptr<CAnimImage> image;
|
||||
std::shared_ptr<CAnimImage> imageSpell;
|
||||
const CArtifactInstance * ourArt;
|
||||
int imageIndex;
|
||||
|
||||
void setInternals(const CArtifactInstance * artInst);
|
||||
virtual void createImage()=0;
|
||||
|
@@ -275,6 +275,18 @@ void CAnimImage::showAll(Canvas & to)
|
||||
}
|
||||
}
|
||||
|
||||
void CAnimImage::setAnimationPath(const AnimationPath & name, size_t frame)
|
||||
{
|
||||
this->frame = frame;
|
||||
anim = GH.renderHandler().loadAnimation(name);
|
||||
init();
|
||||
}
|
||||
|
||||
void CAnimImage::setScale(Point scale)
|
||||
{
|
||||
scaledSize = scale;
|
||||
}
|
||||
|
||||
void CAnimImage::setFrame(size_t Frame, size_t Group)
|
||||
{
|
||||
if (frame == Frame && group==Group)
|
||||
|
@@ -95,7 +95,7 @@ private:
|
||||
size_t frame;
|
||||
size_t group;
|
||||
ui8 flags;
|
||||
const Point scaledSize;
|
||||
Point scaledSize;
|
||||
|
||||
/// If set, then image is colored using player-specific palette
|
||||
std::optional<PlayerColor> player;
|
||||
@@ -124,6 +124,10 @@ public:
|
||||
bool isPlayerColored() const;
|
||||
|
||||
void showAll(Canvas & to) override;
|
||||
|
||||
void setAnimationPath(const AnimationPath & name, size_t frame);
|
||||
|
||||
void setScale(Point scale);
|
||||
};
|
||||
|
||||
/// Base class for displaying animation, used as superclass for different animations
|
||||
|
Reference in New Issue
Block a user