1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Merge pull request #2951 from Laserlicht/spell_icon

specific spell icon (artifacts)
This commit is contained in:
Nordsoft91
2023-09-26 20:13:19 +02:00
committed by GitHub
3 changed files with 34 additions and 1 deletions

View File

@@ -18,6 +18,7 @@
#include "../windows/GUIClasses.h" #include "../windows/GUIClasses.h"
#include "../render/Canvas.h" #include "../render/Canvas.h"
#include "../render/Colors.h" #include "../render/Colors.h"
#include "../render/IRenderHandler.h"
#include "../CPlayerInterface.h" #include "../CPlayerInterface.h"
#include "../CGameInfo.h" #include "../CGameInfo.h"
@@ -25,6 +26,7 @@
#include "../../lib/CGeneralTextHandler.h" #include "../../lib/CGeneralTextHandler.h"
#include "../../lib/ArtifactUtils.h" #include "../../lib/ArtifactUtils.h"
#include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/mapObjects/CGHeroInstance.h"
#include "../../lib/CConfigHandler.h"
void CArtPlace::setInternals(const CArtifactInstance * artInst) void CArtPlace::setInternals(const CArtifactInstance * artInst)
{ {
@@ -33,12 +35,16 @@ void CArtPlace::setInternals(const CArtifactInstance * artInst)
if(!artInst) if(!artInst)
{ {
image->disable(); image->disable();
imageSpell->disable();
text.clear(); text.clear();
hoverText = CGI->generaltexth->allTexts[507]; hoverText = CGI->generaltexth->allTexts[507];
return; return;
} }
image->enable(); image->enable();
imageSpell->disable();
image->setFrame(artInst->artType->getIconIndex()); image->setFrame(artInst->artType->getIconIndex());
if(artInst->getTypeId() == ArtifactID::SPELL_SCROLL) if(artInst->getTypeId() == ArtifactID::SPELL_SCROLL)
{ {
auto spellID = artInst->getScrollSpellID(); auto spellID = artInst->getScrollSpellID();
@@ -48,6 +54,13 @@ void CArtPlace::setInternals(const CArtifactInstance * artInst)
baseType = CComponent::spell; baseType = CComponent::spell;
type = spellID; type = spellID;
bonusValue = 0; bonusValue = 0;
if(settings["general"]["enableUiEnhancements"].Bool())
{
imageSpell->enable();
image->disable();
imageSpell->setFrame(spellID.num);
}
} }
} }
else else
@@ -56,6 +69,7 @@ void CArtPlace::setInternals(const CArtifactInstance * artInst)
type = artInst->getTypeId(); type = artInst->getTypeId();
bonusValue = 0; bonusValue = 0;
} }
text = artInst->getDescription(); text = artInst->getDescription();
} }
@@ -247,9 +261,13 @@ void CHeroArtPlace::createImage()
else if(ourArt) else if(ourArt)
imageIndex = ourArt->artType->getIconIndex(); 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); image = std::make_shared<CAnimImage>(AnimationPath::builtin("artifact"), imageIndex);
if(!ourArt) if(!ourArt)
{
image->disable(); image->disable();
imageSpell->disable();
}
selection = std::make_shared<CAnimImage>(AnimationPath::builtin("artifact"), ArtifactID::ART_SELECTION); selection = std::make_shared<CAnimImage>(AnimationPath::builtin("artifact"), ArtifactID::ART_SELECTION);
selection->disable(); selection->disable();

View File

@@ -34,6 +34,7 @@ class CArtPlace : public LRClickableAreaWTextComp
{ {
protected: protected:
std::shared_ptr<CAnimImage> image; std::shared_ptr<CAnimImage> image;
std::shared_ptr<CAnimImage> imageSpell;
const CArtifactInstance * ourArt; const CArtifactInstance * ourArt;
void setInternals(const CArtifactInstance * artInst); void setInternals(const CArtifactInstance * artInst);

View File

@@ -14,6 +14,10 @@
#include "../gui/CursorHandler.h" #include "../gui/CursorHandler.h"
#include "../gui/WindowHandler.h" #include "../gui/WindowHandler.h"
#include "../render/IRenderHandler.h"
#include "../render/CAnimation.h"
#include "../render/IImage.h"
#include "CComponent.h" #include "CComponent.h"
#include "../windows/CHeroWindow.h" #include "../windows/CHeroWindow.h"
@@ -25,6 +29,7 @@
#include "../../lib/ArtifactUtils.h" #include "../../lib/ArtifactUtils.h"
#include "../../lib/CGeneralTextHandler.h" #include "../../lib/CGeneralTextHandler.h"
#include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/mapObjects/CGHeroInstance.h"
#include "../../lib/CConfigHandler.h"
void CWindowWithArtifacts::addSet(CArtifactsOfHeroPtr artSet) void CWindowWithArtifacts::addSet(CArtifactsOfHeroPtr artSet)
{ {
@@ -270,7 +275,16 @@ void CWindowWithArtifacts::artifactMoved(const ArtifactLocation & srcLoc, const
if(pickedArtInst) if(pickedArtInst)
{ {
markPossibleSlots(); markPossibleSlots();
CCS->curh->dragAndDropCursor(AnimationPath::builtin("artifact"), pickedArtInst->artType->getIconIndex());
if(pickedArtInst->getTypeId() == ArtifactID::SPELL_SCROLL && pickedArtInst->getScrollSpellID().num >= 0 && settings["general"]["enableUiEnhancements"].Bool())
{
auto anim = GH.renderHandler().loadAnimation(AnimationPath::builtin("spellscr"));
anim->load(pickedArtInst->getScrollSpellID().num);
std::shared_ptr<IImage> img = anim->getImage(pickedArtInst->getScrollSpellID().num);
CCS->curh->dragAndDropCursor(img->scaleFast(Point(44, 34)));
}
else
CCS->curh->dragAndDropCursor(AnimationPath::builtin("artifact"), pickedArtInst->artType->getIconIndex());
} }
else else
{ {