mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	SpellArea tweak
This commit is contained in:
		| @@ -595,6 +595,7 @@ CSpellWindow::SpellArea::SpellArea(SDL_Rect pos, CSpellWindow * owner) | ||||
|  | ||||
| 	spellCost = whichSchool = schoolLevel = -1; | ||||
| 	mySpell = nullptr; | ||||
| 	icon = nullptr; | ||||
| } | ||||
|  | ||||
| void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState) | ||||
| @@ -855,14 +856,8 @@ void CSpellWindow::SpellArea::showAll(SDL_Surface * to) | ||||
| 	if(!mySpell) | ||||
| 		return; | ||||
|  | ||||
| 	owner->spells->load(mySpell->id); | ||||
|  | ||||
| 	IImage * icon = owner->spells->getImage(mySpell->id,0,false); | ||||
|  | ||||
| 	if(icon != nullptr) | ||||
| 		icon->draw(to, pos.x, pos.y); | ||||
| 	else | ||||
| 		logGlobal->errorStream() << __FUNCTION__ << ": failed to load icon for spell " << mySpell->name; | ||||
|  | ||||
| 	blitAt(owner->schoolBorders[owner->selectedTab >= 4 ? whichSchool : owner->selectedTab]->ourImages[schoolLevel].bitmap, pos.x, pos.y, to); //printing border (indicates level of magic school) | ||||
|  | ||||
| @@ -898,10 +893,17 @@ void CSpellWindow::SpellArea::showAll(SDL_Surface * to) | ||||
|  | ||||
| void CSpellWindow::SpellArea::setSpell(const CSpell * spell) | ||||
| { | ||||
| 	icon = nullptr; | ||||
| 	mySpell = spell; | ||||
| 	if(mySpell) | ||||
| 	{ | ||||
| 		schoolLevel = owner->myHero->getSpellSchoolLevel(mySpell, &whichSchool); | ||||
| 		spellCost = owner->myInt->cb->getSpellCost(mySpell, owner->myHero); | ||||
|  | ||||
| 		owner->spells->load(mySpell->id); | ||||
| 		icon = owner->spells->getImage(mySpell->id, 0, false); | ||||
|  | ||||
| 		if(icon == nullptr) | ||||
| 			logGlobal->errorStream() << "Failed to load icon for spell " << mySpell->name; | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -15,6 +15,7 @@ | ||||
| struct SDL_Surface; | ||||
| class CDefHandler; | ||||
| struct SDL_Rect; | ||||
| class IImage; | ||||
| class CGHeroInstance; | ||||
| class CGStatusBar; | ||||
| class CPlayerInterface; | ||||
| @@ -33,6 +34,7 @@ private: | ||||
| 		int whichSchool; //0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic, | ||||
| 		int spellCost; | ||||
| 		CSpellWindow * owner; | ||||
| 		IImage * icon; | ||||
|  | ||||
| 		SpellArea(SDL_Rect pos, CSpellWindow * owner); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user