mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Use CAnimImage for SpellArea
This commit is contained in:
parent
3a52a3c663
commit
2a6bab119b
@ -519,13 +519,15 @@ CSpellWindow::SpellArea::SpellArea(SDL_Rect pos, CSpellWindow * owner)
|
|||||||
|
|
||||||
spellCost = whichSchool = schoolLevel = -1;
|
spellCost = whichSchool = schoolLevel = -1;
|
||||||
mySpell = nullptr;
|
mySpell = nullptr;
|
||||||
icon = nullptr;
|
|
||||||
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||||
|
image = new CAnimImage(owner->spells, 0, 0);
|
||||||
|
image->visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSpellWindow::SpellArea::~SpellArea()
|
CSpellWindow::SpellArea::~SpellArea()
|
||||||
{
|
{
|
||||||
if(icon)
|
|
||||||
icon->decreaseRef();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
|
void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
|
||||||
@ -785,9 +787,7 @@ void CSpellWindow::SpellArea::showAll(SDL_Surface * to)
|
|||||||
{
|
{
|
||||||
if(!mySpell)
|
if(!mySpell)
|
||||||
return;
|
return;
|
||||||
|
CIntObject::showAll(to);
|
||||||
if(icon != nullptr)
|
|
||||||
icon->draw(to, pos.x, pos.y);
|
|
||||||
|
|
||||||
blitAt(owner->schoolBorders[owner->selectedTab >= 4 ? whichSchool : owner->selectedTab]->ourImages[schoolLevel].bitmap, pos.x, pos.y, to); //printing border (indicates level of magic school)
|
blitAt(owner->schoolBorders[owner->selectedTab >= 4 ? whichSchool : owner->selectedTab]->ourImages[schoolLevel].bitmap, pos.x, pos.y, to); //printing border (indicates level of magic school)
|
||||||
|
|
||||||
@ -823,19 +823,14 @@ void CSpellWindow::SpellArea::showAll(SDL_Surface * to)
|
|||||||
|
|
||||||
void CSpellWindow::SpellArea::setSpell(const CSpell * spell)
|
void CSpellWindow::SpellArea::setSpell(const CSpell * spell)
|
||||||
{
|
{
|
||||||
if(icon)
|
image->visible = false;
|
||||||
icon->decreaseRef();
|
|
||||||
icon = nullptr;
|
|
||||||
mySpell = spell;
|
mySpell = spell;
|
||||||
if(mySpell)
|
if(mySpell)
|
||||||
{
|
{
|
||||||
schoolLevel = owner->myHero->getSpellSchoolLevel(mySpell, &whichSchool);
|
schoolLevel = owner->myHero->getSpellSchoolLevel(mySpell, &whichSchool);
|
||||||
spellCost = owner->myInt->cb->getSpellCost(mySpell, owner->myHero);
|
spellCost = owner->myInt->cb->getSpellCost(mySpell, owner->myHero);
|
||||||
|
|
||||||
owner->spells->load(mySpell->id);
|
image->setFrame(mySpell->id);
|
||||||
icon = owner->spells->getImage(mySpell->id, 0, false);
|
image->visible = true;
|
||||||
|
|
||||||
if(icon == nullptr)
|
|
||||||
logGlobal->errorStream() << "Failed to load icon for spell " << mySpell->name;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
struct SDL_Surface;
|
struct SDL_Surface;
|
||||||
class CDefHandler;
|
class CDefHandler;
|
||||||
struct SDL_Rect;
|
struct SDL_Rect;
|
||||||
class IImage;
|
class CAnimImage;
|
||||||
class CGHeroInstance;
|
class CGHeroInstance;
|
||||||
class CGStatusBar;
|
class CGStatusBar;
|
||||||
class CPlayerInterface;
|
class CPlayerInterface;
|
||||||
@ -34,7 +34,7 @@ private:
|
|||||||
int whichSchool; //0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic,
|
int whichSchool; //0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic,
|
||||||
int spellCost;
|
int spellCost;
|
||||||
CSpellWindow * owner;
|
CSpellWindow * owner;
|
||||||
IImage * icon;
|
CAnimImage * image;
|
||||||
|
|
||||||
SpellArea(SDL_Rect pos, CSpellWindow * owner);
|
SpellArea(SDL_Rect pos, CSpellWindow * owner);
|
||||||
~SpellArea();
|
~SpellArea();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user