1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

cleaned up spell window creation

This commit is contained in:
AlexVinS 2016-10-16 09:27:22 +03:00
parent 415bd8247a
commit 63cbf960df
8 changed files with 10 additions and 18 deletions

View File

@ -898,8 +898,7 @@ void CBattleInterface::bSpellf()
ESpellCastProblem::ESpellCastProblem spellCastProblem; ESpellCastProblem::ESpellCastProblem spellCastProblem;
if (curInt->cb->battleCanCastSpell(&spellCastProblem)) if (curInt->cb->battleCanCastSpell(&spellCastProblem))
{ {
auto spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), myHero, curInt.get()); GH.pushInt(new CSpellWindow(myHero, curInt.get()));
GH.pushInt(spellWindow);
} }
else if(spellCastProblem == ESpellCastProblem::MAGIC_IS_BLOCKED) else if(spellCastProblem == ESpellCastProblem::MAGIC_IS_BLOCKED)
{ {

View File

@ -200,8 +200,7 @@ void CBattleHero::clickLeft(tribool down, bool previousState)
} }
CCS->curh->changeGraphic(ECursor::ADVENTURE, 0); CCS->curh->changeGraphic(ECursor::ADVENTURE, 0);
auto spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), myHero, myOwner->getCurrentPlayerInterface()); GH.pushInt(new CSpellWindow(myHero, myOwner->getCurrentPlayerInterface()));
GH.pushInt(spellWindow);
} }
} }
@ -380,7 +379,7 @@ CBattleResultWindow::CBattleResultWindow(const BattleResult &br, const SDL_Rect
auto heroInfo = owner.cb->battleGetHeroInfo(i); auto heroInfo = owner.cb->battleGetHeroInfo(i);
const int xs[] = {21, 392}; const int xs[] = {21, 392};
if(heroInfo.portrait >= 0) //attacking hero if(heroInfo.portrait >= 0) //attacking hero
{ {
new CAnimImage("PortraitsLarge", heroInfo.portrait, 0, xs[i], 38); new CAnimImage("PortraitsLarge", heroInfo.portrait, 0, xs[i], 38);
sideNames[i] = heroInfo.name; sideNames[i] = heroInfo.name;
@ -448,7 +447,7 @@ CBattleResultWindow::CBattleResultWindow(const BattleResult &br, const SDL_Rect
boost::algorithm::replace_first(str,"%s",ourHero->name); boost::algorithm::replace_first(str,"%s",ourHero->name);
boost::algorithm::replace_first(str,"%d",boost::lexical_cast<std::string>(br.exp[weAreAttacker?0:1])); boost::algorithm::replace_first(str,"%d",boost::lexical_cast<std::string>(br.exp[weAreAttacker?0:1]));
} }
new CTextBox(str, Rect(69, 203, 330, 68), 0, FONT_SMALL, CENTER, Colors::WHITE); new CTextBox(str, Rect(69, 203, 330, 68), 0, FONT_SMALL, CENTER, Colors::WHITE);
} }
else // we lose else // we lose
@ -509,7 +508,7 @@ void CBattleResultWindow::bExitf()
if(dynamic_cast<CBattleInterface*>(GH.topInt())) if(dynamic_cast<CBattleInterface*>(GH.topInt()))
GH.popInts(1); //pop battle interface if present GH.popInts(1); //pop battle interface if present
//Result window and battle interface are gone. We requested all dialogs to be closed before opening the battle, //Result window and battle interface are gone. We requested all dialogs to be closed before opening the battle,
//so we can be sure that there is no dialogs left on GUI stack. //so we can be sure that there is no dialogs left on GUI stack.
intTmp.showingDialog->setn(false); intTmp.showingDialog->setn(false);
CCS->videoh->close(); CCS->videoh->close();
@ -532,7 +531,7 @@ Point CClickableHex::getXYUnitAnim(BattleHex hexNum, const CStack * stack, CBatt
break; break;
case -4: //upper turret case -4: //upper turret
ret = cbi->siegeH->town->town->clientInfo.siegePositions[20]; ret = cbi->siegeH->town->town->clientInfo.siegePositions[20];
break; break;
} }
} }
else else

View File

@ -123,10 +123,7 @@ void CArtPlace::clickLeft(tribool down, bool previousState)
if(ourArt && !down && previousState && !ourOwner->commonInfo->src.AOH) if(ourArt && !down && previousState && !ourOwner->commonInfo->src.AOH)
{ {
if(ourArt->artType->id == ArtifactID::SPELLBOOK) if(ourArt->artType->id == ArtifactID::SPELLBOOK)
{ GH.pushInt(new CSpellWindow(ourOwner->curHero, LOCPLINT, LOCPLINT->battleInt));
auto spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), ourOwner->curHero, LOCPLINT, LOCPLINT->battleInt);
GH.pushInt(spellWindow);
}
} }
if (!down && previousState) if (!down && previousState)

View File

@ -714,8 +714,7 @@ void CAdvMapInt::fshowSpellbok()
centerOn(selection); centerOn(selection);
auto spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), curHero(), LOCPLINT, false); GH.pushInt(new CSpellWindow(curHero(), LOCPLINT, false));
GH.pushInt(spellWindow);
} }
void CAdvMapInt::fadventureOPtions() void CAdvMapInt::fadventureOPtions()

View File

@ -4,7 +4,6 @@
#include "CAdvmapInterface.h" #include "CAdvmapInterface.h"
#include "CCreatureWindow.h" #include "CCreatureWindow.h"
#include "CKingdomInterface.h" #include "CKingdomInterface.h"
#include "CSpellWindow.h"
#include "GUIClasses.h" #include "GUIClasses.h"
#include "../CBitmapHandler.h" #include "../CBitmapHandler.h"

View File

@ -74,7 +74,7 @@ void CSpellWindow::InteractiveArea::hover(bool on)
owner->statusBar->clear(); owner->statusBar->clear();
} }
CSpellWindow::CSpellWindow(const SDL_Rect &, const CGHeroInstance * _myHero, CPlayerInterface * _myInt, bool openOnBattleSpells): CSpellWindow::CSpellWindow(const CGHeroInstance * _myHero, CPlayerInterface * _myInt, bool openOnBattleSpells):
CWindowObject(PLAYER_COLORED, "SpelBack"), CWindowObject(PLAYER_COLORED, "SpelBack"),
battleSpellsOnly(openOnBattleSpells), battleSpellsOnly(openOnBattleSpells),
selectedTab(4), selectedTab(4),

View File

@ -92,7 +92,7 @@ private:
public: public:
CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * _myHero, CPlayerInterface * _myInt, bool openOnBattleSpells = true); //c-tor CSpellWindow(const CGHeroInstance * _myHero, CPlayerInterface * _myInt, bool openOnBattleSpells = true); //c-tor
~CSpellWindow(); //d-tor ~CSpellWindow(); //d-tor
void fexitb(); void fexitb();

View File

@ -5,7 +5,6 @@
#include "CCastleInterface.h" #include "CCastleInterface.h"
#include "CCreatureWindow.h" #include "CCreatureWindow.h"
#include "CHeroWindow.h" #include "CHeroWindow.h"
#include "CSpellWindow.h"
#include "../CBitmapHandler.h" #include "../CBitmapHandler.h"
#include "../CGameInfo.h" #include "../CGameInfo.h"