2011-12-22 16:05:19 +03:00
|
|
|
#include "StdInc.h"
|
|
|
|
#include "CBattleInterfaceClasses.h"
|
|
|
|
|
2013-04-07 14:52:07 +03:00
|
|
|
#include "../gui/SDL_Extensions.h"
|
2011-12-22 16:05:19 +03:00
|
|
|
#include "CBattleInterface.h"
|
|
|
|
#include "../CGameInfo.h"
|
|
|
|
#include "../CDefHandler.h"
|
2013-04-07 14:52:07 +03:00
|
|
|
#include "../gui/CCursorHandler.h"
|
2011-12-22 16:05:19 +03:00
|
|
|
#include "../CPlayerInterface.h"
|
|
|
|
#include "../../CCallback.h"
|
|
|
|
#include "../CSpellWindow.h"
|
|
|
|
#include "../Graphics.h"
|
2012-09-29 13:59:43 +03:00
|
|
|
#include "../../lib/CConfigHandler.h"
|
2013-04-07 14:52:07 +03:00
|
|
|
#include "../gui/CGuiHandler.h"
|
|
|
|
#include "../gui/CIntObjectClasses.h"
|
2011-12-22 16:05:19 +03:00
|
|
|
#include "../../lib/CGeneralTextHandler.h"
|
|
|
|
#include "../../lib/NetPacks.h"
|
|
|
|
#include "../../lib/CCreatureHandler.h"
|
|
|
|
#include "../../lib/BattleState.h"
|
2014-06-25 17:11:07 +03:00
|
|
|
#include "../../lib/StartInfo.h"
|
2011-12-22 16:05:19 +03:00
|
|
|
#include "../CMusicHandler.h"
|
|
|
|
#include "../CVideoHandler.h"
|
|
|
|
#include "../../lib/CTownHandler.h"
|
|
|
|
#include "../CBitmapHandler.h"
|
|
|
|
#include "../CCreatureWindow.h"
|
2012-12-19 20:24:53 +03:00
|
|
|
#include "../CMessage.h"
|
2011-12-22 16:05:19 +03:00
|
|
|
|
2013-07-07 22:44:08 +03:00
|
|
|
/*
|
|
|
|
* CBattleInterfaceClasses.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-09-27 20:16:41 +03:00
|
|
|
void CBattleConsole::showAll(SDL_Surface * to)
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2013-01-21 01:49:34 +03:00
|
|
|
Point textPos(pos.x + pos.w/2, pos.y + 17);
|
2012-12-19 20:24:53 +03:00
|
|
|
|
2011-12-22 16:05:19 +03:00
|
|
|
if(ingcAlter.size())
|
|
|
|
{
|
2012-12-19 20:24:53 +03:00
|
|
|
graphics->fonts[FONT_SMALL]->renderTextLinesCenter(to, CMessage::breakText(ingcAlter, pos.w, FONT_SMALL), Colors::WHITE, textPos);
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
else if(alterTxt.size())
|
|
|
|
{
|
2012-12-19 20:24:53 +03:00
|
|
|
graphics->fonts[FONT_SMALL]->renderTextLinesCenter(to, CMessage::breakText(alterTxt, pos.w, FONT_SMALL), Colors::WHITE, textPos);
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
else if(texts.size())
|
|
|
|
{
|
|
|
|
if(texts.size()==1)
|
|
|
|
{
|
2012-12-19 20:24:53 +03:00
|
|
|
graphics->fonts[FONT_SMALL]->renderTextLinesCenter(to, CMessage::breakText(texts[0], pos.w, FONT_SMALL), Colors::WHITE, textPos);
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-12-19 20:24:53 +03:00
|
|
|
graphics->fonts[FONT_SMALL]->renderTextLinesCenter(to, CMessage::breakText(texts[lastShown - 1], pos.w, FONT_SMALL), Colors::WHITE, textPos);
|
|
|
|
textPos.y += 16;
|
|
|
|
graphics->fonts[FONT_SMALL]->renderTextLinesCenter(to, CMessage::breakText(texts[lastShown], pos.w, FONT_SMALL), Colors::WHITE, textPos);
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CBattleConsole::addText(const std::string & text)
|
|
|
|
{
|
|
|
|
if(text.size()>70)
|
|
|
|
return false; //text too long!
|
|
|
|
int firstInToken = 0;
|
|
|
|
for(size_t i = 0; i < text.size(); ++i) //tokenize
|
|
|
|
{
|
|
|
|
if(text[i] == 10)
|
|
|
|
{
|
|
|
|
texts.push_back( text.substr(firstInToken, i-firstInToken) );
|
|
|
|
firstInToken = i+1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
texts.push_back( text.substr(firstInToken, text.size()) );
|
|
|
|
lastShown = texts.size()-1;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-02-20 11:19:03 +03:00
|
|
|
void CBattleConsole::alterText(const std::string &text)
|
|
|
|
{
|
2012-02-21 17:08:42 +03:00
|
|
|
//char buf[500];
|
|
|
|
//sprintf(buf, text.c_str());
|
|
|
|
//alterTxt = buf;
|
|
|
|
alterTxt = text;
|
2012-02-20 11:19:03 +03:00
|
|
|
}
|
|
|
|
|
2011-12-22 16:05:19 +03:00
|
|
|
void CBattleConsole::eraseText(ui32 pos)
|
|
|
|
{
|
|
|
|
if(pos < texts.size())
|
|
|
|
{
|
|
|
|
texts.erase(texts.begin() + pos);
|
|
|
|
if(lastShown == texts.size())
|
|
|
|
--lastShown;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBattleConsole::changeTextAt(const std::string & text, ui32 pos)
|
|
|
|
{
|
|
|
|
if(pos >= texts.size()) //no such pos
|
|
|
|
return;
|
|
|
|
texts[pos] = text;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBattleConsole::scrollUp(ui32 by)
|
|
|
|
{
|
|
|
|
if(lastShown > static_cast<int>(by))
|
|
|
|
lastShown -= by;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBattleConsole::scrollDown(ui32 by)
|
|
|
|
{
|
|
|
|
if(lastShown + by < texts.size())
|
|
|
|
lastShown += by;
|
|
|
|
}
|
|
|
|
|
2012-09-27 20:16:41 +03:00
|
|
|
CBattleConsole::CBattleConsole() : lastShown(-1), alterTxt(""), whoSetAlter(0)
|
|
|
|
{}
|
|
|
|
|
2011-12-22 16:05:19 +03:00
|
|
|
void CBattleHero::show(SDL_Surface * to)
|
|
|
|
{
|
|
|
|
//animation of flag
|
2012-08-29 17:55:31 +03:00
|
|
|
SDL_Rect temp_rect;
|
2011-12-22 16:05:19 +03:00
|
|
|
if(flip)
|
|
|
|
{
|
2012-08-29 17:55:31 +03:00
|
|
|
temp_rect = genRect(
|
2011-12-22 16:05:19 +03:00
|
|
|
flag->ourImages[flagAnim].bitmap->h,
|
|
|
|
flag->ourImages[flagAnim].bitmap->w,
|
|
|
|
pos.x + 61,
|
|
|
|
pos.y + 39);
|
2012-08-29 17:55:31 +03:00
|
|
|
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-29 17:55:31 +03:00
|
|
|
temp_rect = genRect(
|
2011-12-22 16:05:19 +03:00
|
|
|
flag->ourImages[flagAnim].bitmap->h,
|
|
|
|
flag->ourImages[flagAnim].bitmap->w,
|
|
|
|
pos.x + 72,
|
|
|
|
pos.y + 39);
|
|
|
|
}
|
2012-08-29 17:55:31 +03:00
|
|
|
CSDL_Ext::blit8bppAlphaTo24bpp(
|
|
|
|
flag->ourImages[flagAnim].bitmap,
|
2013-06-26 14:18:27 +03:00
|
|
|
nullptr,
|
2012-08-29 17:55:31 +03:00
|
|
|
screen,
|
|
|
|
&temp_rect);
|
|
|
|
|
2011-12-22 16:05:19 +03:00
|
|
|
//animation of hero
|
2012-08-29 17:55:31 +03:00
|
|
|
SDL_Rect rect = pos;
|
2013-06-26 14:18:27 +03:00
|
|
|
CSDL_Ext::blit8bppAlphaTo24bpp(dh->ourImages[currentFrame].bitmap, nullptr, to, &rect);
|
2012-08-29 17:55:31 +03:00
|
|
|
|
|
|
|
if ( ++animCount == 4 )
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2012-08-29 17:55:31 +03:00
|
|
|
animCount = 0;
|
|
|
|
if ( ++flagAnim >= flag->ourImages.size())
|
|
|
|
flagAnim = 0;
|
|
|
|
|
|
|
|
if ( ++currentFrame >= lastFrame)
|
|
|
|
switchToNextPhase();
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBattleHero::setPhase(int newPhase)
|
|
|
|
{
|
2012-08-29 17:55:31 +03:00
|
|
|
nextPhase = newPhase;
|
|
|
|
switchToNextPhase(); //immediately switch to next phase and then restore idling phase
|
|
|
|
nextPhase = 0;
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBattleHero::clickLeft(tribool down, bool previousState)
|
|
|
|
{
|
|
|
|
if(myOwner->spellDestSelectMode) //we are casting a spell
|
|
|
|
return;
|
|
|
|
|
2013-11-03 19:44:47 +03:00
|
|
|
if(!down && myHero != nullptr && myOwner->myTurn && myOwner->getCurrentPlayerInterface()->cb->battleCanCastSpell()) //check conditions
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
|
|
|
for(int it=0; it<GameConstants::BFIELD_SIZE; ++it) //do nothing when any hex is hovered - hero's animation overlaps battlefield
|
|
|
|
{
|
2012-06-09 19:45:45 +03:00
|
|
|
if(myOwner->bfield[it]->hovered && myOwner->bfield[it]->strictHovered)
|
2011-12-22 16:05:19 +03:00
|
|
|
return;
|
|
|
|
}
|
2012-12-14 18:32:53 +03:00
|
|
|
CCS->curh->changeGraphic(ECursor::ADVENTURE, 0);
|
2011-12-22 16:05:19 +03:00
|
|
|
|
2013-11-03 19:44:47 +03:00
|
|
|
auto spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), myHero, myOwner->getCurrentPlayerInterface());
|
2011-12-22 16:05:19 +03:00
|
|
|
GH.pushInt(spellWindow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-29 17:55:31 +03:00
|
|
|
void CBattleHero::switchToNextPhase()
|
|
|
|
{
|
|
|
|
if (phase != nextPhase)
|
|
|
|
{
|
|
|
|
phase = nextPhase;
|
|
|
|
|
|
|
|
//find first and last frames of our animation
|
|
|
|
for (firstFrame = 0;
|
|
|
|
firstFrame < dh->ourImages.size() && dh->ourImages[firstFrame].groupNumber != phase;
|
|
|
|
firstFrame++);
|
|
|
|
|
|
|
|
for (lastFrame = firstFrame;
|
|
|
|
lastFrame < dh->ourImages.size() && dh->ourImages[lastFrame].groupNumber == phase;
|
|
|
|
lastFrame++);
|
|
|
|
}
|
|
|
|
|
|
|
|
currentFrame = firstFrame;
|
|
|
|
}
|
|
|
|
|
2013-03-03 20:06:03 +03:00
|
|
|
CBattleHero::CBattleHero(const std::string & defName, bool flipG, PlayerColor player, const CGHeroInstance * hero, const CBattleInterface * owner):
|
2012-08-29 17:55:31 +03:00
|
|
|
flip(flipG),
|
|
|
|
myHero(hero),
|
|
|
|
myOwner(owner),
|
|
|
|
phase(1),
|
|
|
|
nextPhase(0),
|
|
|
|
flagAnim(0),
|
|
|
|
animCount(0)
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
|
|
|
dh = CDefHandler::giveDef( defName );
|
2013-06-29 16:05:48 +03:00
|
|
|
for(auto & elem : dh->ourImages) //transforming images
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
|
|
|
if(flip)
|
|
|
|
{
|
2013-11-06 16:42:58 +03:00
|
|
|
SDL_Surface * hlp = CSDL_Ext::verticalFlip(elem.bitmap);
|
2013-06-29 16:05:48 +03:00
|
|
|
SDL_FreeSurface(elem.bitmap);
|
|
|
|
elem.bitmap = hlp;
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
2013-06-29 16:05:48 +03:00
|
|
|
CSDL_Ext::alphaTransform(elem.bitmap);
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if(flip)
|
|
|
|
flag = CDefHandler::giveDef("CMFLAGR.DEF");
|
|
|
|
else
|
|
|
|
flag = CDefHandler::giveDef("CMFLAGL.DEF");
|
|
|
|
|
|
|
|
//coloring flag and adding transparency
|
2013-06-29 16:05:48 +03:00
|
|
|
for(auto & elem : flag->ourImages)
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2013-06-29 16:05:48 +03:00
|
|
|
CSDL_Ext::alphaTransform(elem.bitmap);
|
|
|
|
graphics->blueToPlayersAdv(elem.bitmap, player);
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
2012-06-02 18:16:54 +03:00
|
|
|
addUsedEvents(LCLICK);
|
2012-08-29 17:55:31 +03:00
|
|
|
|
|
|
|
switchToNextPhase();
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
CBattleHero::~CBattleHero()
|
|
|
|
{
|
|
|
|
delete dh;
|
|
|
|
delete flag;
|
|
|
|
}
|
|
|
|
|
2013-01-21 01:49:34 +03:00
|
|
|
CBattleOptionsWindow::CBattleOptionsWindow(const SDL_Rect & position, CBattleInterface *owner)
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
|
|
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
|
|
|
pos = position;
|
|
|
|
background = new CPicture("comopbck.bmp");
|
2013-11-03 19:44:47 +03:00
|
|
|
background->colorize(owner->getCurrentPlayerInterface()->playerID);
|
2011-12-22 16:05:19 +03:00
|
|
|
|
2013-07-02 18:23:32 +03:00
|
|
|
viewGrid = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintCellBorders, owner, true), boost::bind(&CBattleInterface::setPrintCellBorders, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[427].first)(3,CGI->generaltexth->zelp[427].first), CGI->generaltexth->zelp[427].second, false, "sysopchk.def", nullptr, 25, 56, false);
|
2012-01-12 18:23:00 +03:00
|
|
|
viewGrid->select(settings["battle"]["cellBorders"].Bool());
|
2013-07-02 18:23:32 +03:00
|
|
|
movementShadow = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintStackRange, owner, true), boost::bind(&CBattleInterface::setPrintStackRange, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[428].first)(3,CGI->generaltexth->zelp[428].first), CGI->generaltexth->zelp[428].second, false, "sysopchk.def", nullptr, 25, 89, false);
|
2012-01-12 18:23:00 +03:00
|
|
|
movementShadow->select(settings["battle"]["stackRange"].Bool());
|
2013-07-02 18:23:32 +03:00
|
|
|
mouseShadow = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintMouseShadow, owner, true), boost::bind(&CBattleInterface::setPrintMouseShadow, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[429].first)(3,CGI->generaltexth->zelp[429].first), CGI->generaltexth->zelp[429].second, false, "sysopchk.def", nullptr, 25, 122, false);
|
2012-01-12 18:23:00 +03:00
|
|
|
mouseShadow->select(settings["battle"]["mouseShadow"].Bool());
|
2011-12-22 16:05:19 +03:00
|
|
|
|
|
|
|
animSpeeds = new CHighlightableButtonsGroup(0);
|
2013-07-06 19:10:20 +03:00
|
|
|
animSpeeds->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[422].first),CGI->generaltexth->zelp[422].second, "sysopb9.def", 28, 225, 40);
|
|
|
|
animSpeeds->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[423].first),CGI->generaltexth->zelp[423].second, "sysob10.def", 92, 225, 63);
|
|
|
|
animSpeeds->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[424].first),CGI->generaltexth->zelp[424].second, "sysob11.def",156, 225, 100);
|
2011-12-22 16:05:19 +03:00
|
|
|
animSpeeds->select(owner->getAnimSpeed(), 1);
|
2013-07-02 18:23:32 +03:00
|
|
|
animSpeeds->onChange = boost::bind(&CBattleInterface::setAnimSpeed, owner, _1);
|
2011-12-22 16:05:19 +03:00
|
|
|
|
2013-07-02 18:23:32 +03:00
|
|
|
setToDefault = new CAdventureMapButton (CGI->generaltexth->zelp[393], boost::bind(&CBattleOptionsWindow::bDefaultf,this), 246, 359, "codefaul.def");
|
2011-12-22 16:05:19 +03:00
|
|
|
setToDefault->swappedImages = true;
|
|
|
|
setToDefault->update();
|
2013-07-02 18:23:32 +03:00
|
|
|
exit = new CAdventureMapButton (CGI->generaltexth->zelp[392], boost::bind(&CBattleOptionsWindow::bExitf,this), 357, 359, "soretrn.def",SDLK_RETURN);
|
2011-12-22 16:05:19 +03:00
|
|
|
exit->swappedImages = true;
|
|
|
|
exit->update();
|
|
|
|
|
|
|
|
//creating labels
|
2012-11-11 15:23:31 +03:00
|
|
|
labels.push_back(new CLabel(242, 32, FONT_BIG, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[392]));//window title
|
|
|
|
labels.push_back(new CLabel(122, 214, FONT_MEDIUM, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[393]));//animation speed
|
|
|
|
labels.push_back(new CLabel(122, 293, FONT_MEDIUM, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[394]));//music volume
|
|
|
|
labels.push_back(new CLabel(122, 359, FONT_MEDIUM, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[395]));//effects' volume
|
|
|
|
labels.push_back(new CLabel(353, 66, FONT_MEDIUM, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[396]));//auto - combat options
|
|
|
|
labels.push_back(new CLabel(353, 265, FONT_MEDIUM, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[397]));//creature info
|
2011-12-22 16:05:19 +03:00
|
|
|
|
|
|
|
//auto - combat options
|
2012-11-11 15:23:31 +03:00
|
|
|
labels.push_back(new CLabel(283, 86, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[398]));//creatures
|
|
|
|
labels.push_back(new CLabel(283, 116, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[399]));//spells
|
|
|
|
labels.push_back(new CLabel(283, 146, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[400]));//catapult
|
|
|
|
labels.push_back(new CLabel(283, 176, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[151]));//ballista
|
|
|
|
labels.push_back(new CLabel(283, 206, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[401]));//first aid tent
|
2011-12-22 16:05:19 +03:00
|
|
|
|
|
|
|
//creature info
|
2012-11-11 15:23:31 +03:00
|
|
|
labels.push_back(new CLabel(283, 285, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[402]));//all stats
|
|
|
|
labels.push_back(new CLabel(283, 315, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[403]));//spells only
|
2011-12-22 16:05:19 +03:00
|
|
|
|
|
|
|
//general options
|
2012-11-11 15:23:31 +03:00
|
|
|
labels.push_back(new CLabel(61, 57, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[404]));
|
|
|
|
labels.push_back(new CLabel(61, 90, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[405]));
|
|
|
|
labels.push_back(new CLabel(61, 123, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[406]));
|
|
|
|
labels.push_back(new CLabel(61, 156, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[407]));
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBattleOptionsWindow::bDefaultf()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBattleOptionsWindow::bExitf()
|
|
|
|
{
|
|
|
|
GH.popIntTotally(this);
|
|
|
|
}
|
|
|
|
|
2013-06-23 14:25:48 +03:00
|
|
|
CBattleResultWindow::CBattleResultWindow(const BattleResult &br, const SDL_Rect & pos, CPlayerInterface &_owner)
|
2011-12-22 16:05:19 +03:00
|
|
|
: owner(_owner)
|
|
|
|
{
|
2012-05-13 18:04:21 +03:00
|
|
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
2011-12-22 16:05:19 +03:00
|
|
|
this->pos = pos;
|
2012-05-13 18:04:21 +03:00
|
|
|
CPicture * bg = new CPicture("CPRESULT");
|
2013-06-23 14:25:48 +03:00
|
|
|
bg->colorize(owner.playerID);
|
2012-05-13 18:04:21 +03:00
|
|
|
|
2013-07-02 18:23:32 +03:00
|
|
|
exit = new CAdventureMapButton ("", "", boost::bind(&CBattleResultWindow::bExitf,this), 384, 505, "iok6432.def", SDLK_RETURN);
|
2012-11-20 20:53:45 +03:00
|
|
|
exit->borderColor = Colors::METALLIC_GOLD;
|
2011-12-22 16:05:19 +03:00
|
|
|
exit->borderEnabled = true;
|
|
|
|
|
|
|
|
if(br.winner==0) //attacker won
|
|
|
|
{
|
2012-11-11 15:23:31 +03:00
|
|
|
new CLabel( 59, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[410]);
|
|
|
|
new CLabel(408, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[411]);
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
else //if(br.winner==1)
|
|
|
|
{
|
2012-11-11 15:23:31 +03:00
|
|
|
new CLabel( 59, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[411]);
|
|
|
|
new CLabel(412, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[410]);
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
|
2012-11-11 15:23:31 +03:00
|
|
|
new CLabel(232, 302, FONT_BIG, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[407]);
|
|
|
|
new CLabel(232, 332, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[408]);
|
|
|
|
new CLabel(232, 428, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[409]);
|
2011-12-22 16:05:19 +03:00
|
|
|
|
2013-06-23 14:25:48 +03:00
|
|
|
std::string sideNames[2] = {"N/A", "N/A"};
|
2011-12-22 16:05:19 +03:00
|
|
|
|
2013-06-23 14:25:48 +03:00
|
|
|
for(int i = 0; i < 2; i++)
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2013-06-23 14:25:48 +03:00
|
|
|
auto heroInfo = owner.cb->battleGetHeroInfo(i);
|
|
|
|
const int xs[] = {21, 392};
|
|
|
|
|
|
|
|
if(heroInfo.portrait >= 0) //attacking hero
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2013-06-23 14:25:48 +03:00
|
|
|
new CAnimImage("PortraitsLarge", heroInfo.portrait, 0, xs[i], 38);
|
|
|
|
sideNames[i] = heroInfo.name;
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
2013-06-23 14:25:48 +03:00
|
|
|
else
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2013-06-23 14:25:48 +03:00
|
|
|
auto stacks = owner.cb->battleGetAllStacks();
|
|
|
|
vstd::erase_if(stacks, [i](const CStack *stack) //erase stack of other side and not coming from garrison
|
|
|
|
{ return stack->attackerOwned == i || !stack->base; });
|
|
|
|
|
|
|
|
auto best = vstd::maxElementByFun(stacks, [](const CStack *stack){ return stack->type->AIValue; });
|
|
|
|
if(best != stacks.end()) //should be always but to be safe...
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2013-06-23 14:25:48 +03:00
|
|
|
new CAnimImage("TWCRPORT", (*best)->type->idNumber+2, 0, xs[i], 38);
|
|
|
|
sideNames[i] = CGI->creh->creatures[(*best)->type->idNumber]->namePl;
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//printing attacker and defender's names
|
2013-06-23 14:25:48 +03:00
|
|
|
new CLabel( 89, 37, FONT_SMALL, TOPLEFT, Colors::WHITE, sideNames[0]);
|
|
|
|
new CLabel( 381, 53, FONT_SMALL, BOTTOMRIGHT, Colors::WHITE, sideNames[1]);
|
2012-05-13 18:04:21 +03:00
|
|
|
|
2013-06-23 14:25:48 +03:00
|
|
|
//printing casualties
|
2011-12-22 16:05:19 +03:00
|
|
|
for(int step = 0; step < 2; ++step)
|
|
|
|
{
|
|
|
|
if(br.casualties[step].size()==0)
|
|
|
|
{
|
2012-11-11 15:23:31 +03:00
|
|
|
new CLabel( 235, 360 + 97*step, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[523]);
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int xPos = 235 - (br.casualties[step].size()*32 + (br.casualties[step].size() - 1)*10)/2; //increment by 42 with each picture
|
|
|
|
int yPos = 344 + step*97;
|
2013-06-29 16:05:48 +03:00
|
|
|
for(auto & elem : br.casualties[step])
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2013-06-29 16:05:48 +03:00
|
|
|
new CAnimImage("CPRSMALL", CGI->creh->creatures[elem.first]->iconIndex, 0, xPos, yPos);
|
2011-12-22 16:05:19 +03:00
|
|
|
std::ostringstream amount;
|
2013-06-29 16:05:48 +03:00
|
|
|
amount<<elem.second;
|
2012-11-11 15:23:31 +03:00
|
|
|
new CLabel( xPos+16, yPos + 42, FONT_SMALL, CENTER, Colors::WHITE, amount.str());
|
2011-12-22 16:05:19 +03:00
|
|
|
xPos += 42;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//printing result description
|
2013-06-23 14:25:48 +03:00
|
|
|
bool weAreAttacker = !(owner.cb->battleGetMySide());
|
2011-12-22 16:05:19 +03:00
|
|
|
if((br.winner == 0 && weAreAttacker) || (br.winner == 1 && !weAreAttacker)) //we've won
|
|
|
|
{
|
|
|
|
int text=-1;
|
|
|
|
switch(br.result)
|
|
|
|
{
|
2013-02-23 00:03:56 +03:00
|
|
|
case BattleResult::NORMAL: text = 304; break;
|
|
|
|
case BattleResult::ESCAPE: text = 303; break;
|
|
|
|
case BattleResult::SURRENDER: text = 302; break;
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
|
2012-08-06 10:34:37 +03:00
|
|
|
CCS->musich->playMusic("Music/Win Battle", false);
|
2012-08-21 20:37:06 +03:00
|
|
|
CCS->videoh->open("WIN3.BIK");
|
2011-12-22 16:05:19 +03:00
|
|
|
std::string str = CGI->generaltexth->allTexts[text];
|
|
|
|
|
2013-06-23 14:25:48 +03:00
|
|
|
const CGHeroInstance * ourHero = owner.cb->battleGetMyHero();
|
2011-12-22 16:05:19 +03:00
|
|
|
if (ourHero)
|
|
|
|
{
|
|
|
|
str += CGI->generaltexth->allTexts[305];
|
|
|
|
boost::algorithm::replace_first(str,"%s",ourHero->name);
|
|
|
|
boost::algorithm::replace_first(str,"%d",boost::lexical_cast<std::string>(br.exp[weAreAttacker?0:1]));
|
|
|
|
}
|
2012-05-13 18:04:21 +03:00
|
|
|
|
2012-11-11 15:23:31 +03:00
|
|
|
new CTextBox(str, Rect(69, 203, 330, 68), 0, FONT_SMALL, CENTER, Colors::WHITE);
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
else // we lose
|
|
|
|
{
|
|
|
|
switch(br.result)
|
|
|
|
{
|
2013-02-23 00:03:56 +03:00
|
|
|
case BattleResult::NORMAL:
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2012-08-06 10:34:37 +03:00
|
|
|
CCS->musich->playMusic("Music/LoseCombat", false);
|
2012-08-21 20:37:06 +03:00
|
|
|
CCS->videoh->open("LBSTART.BIK");
|
2012-11-11 15:23:31 +03:00
|
|
|
new CLabel(235, 235, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[311]);
|
2011-12-22 16:05:19 +03:00
|
|
|
break;
|
|
|
|
}
|
2013-02-23 00:03:56 +03:00
|
|
|
case BattleResult::ESCAPE: //flee
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2012-08-06 10:34:37 +03:00
|
|
|
CCS->musich->playMusic("Music/Retreat Battle", false);
|
2012-08-21 20:37:06 +03:00
|
|
|
CCS->videoh->open("RTSTART.BIK");
|
2012-11-11 15:23:31 +03:00
|
|
|
new CLabel(235, 235, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[310]);
|
2011-12-22 16:05:19 +03:00
|
|
|
break;
|
|
|
|
}
|
2013-02-23 00:03:56 +03:00
|
|
|
case BattleResult::SURRENDER:
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2012-08-06 10:34:37 +03:00
|
|
|
CCS->musich->playMusic("Music/Surrender Battle", false);
|
2012-08-21 20:37:06 +03:00
|
|
|
CCS->videoh->open("SURRENDER.BIK");
|
2012-11-11 15:23:31 +03:00
|
|
|
new CLabel(235, 235, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[309]);
|
2011-12-22 16:05:19 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CBattleResultWindow::~CBattleResultWindow()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBattleResultWindow::activate()
|
|
|
|
{
|
2013-06-23 14:25:48 +03:00
|
|
|
owner.showingDialog->set(true);
|
2012-05-26 13:02:55 +03:00
|
|
|
CIntObject::activate();
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBattleResultWindow::show(SDL_Surface * to)
|
|
|
|
{
|
2012-05-13 18:04:21 +03:00
|
|
|
CIntObject::show(to);
|
2012-05-26 13:02:55 +03:00
|
|
|
CCS->videoh->update(pos.x + 107, pos.y + 70, screen, true, false);
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBattleResultWindow::bExitf()
|
|
|
|
{
|
|
|
|
if(LOCPLINT->cb->getStartInfo()->mode == StartInfo::DUEL)
|
|
|
|
{
|
2012-09-11 17:25:19 +03:00
|
|
|
CGuiHandler::pushSDLEvent(SDL_QUIT);
|
2012-07-26 03:48:44 +03:00
|
|
|
return;
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
|
2013-06-23 14:25:48 +03:00
|
|
|
CPlayerInterface &intTmp = owner; //copy reference because "this" will be destructed soon
|
|
|
|
GH.popIntTotally(this);
|
|
|
|
if(dynamic_cast<CBattleInterface*>(GH.topInt()))
|
|
|
|
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,
|
|
|
|
//so we can be sure that there is no dialogs left on GUI stack.
|
|
|
|
intTmp.showingDialog->setn(false);
|
2011-12-22 16:05:19 +03:00
|
|
|
CCS->videoh->close();
|
|
|
|
}
|
|
|
|
|
2013-07-07 22:44:08 +03:00
|
|
|
Point CClickableHex::getXYUnitAnim(BattleHex hexNum, const CStack * stack, CBattleInterface * cbi)
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2013-07-17 01:59:39 +03:00
|
|
|
assert(cbi);
|
|
|
|
|
2011-12-22 16:05:19 +03:00
|
|
|
Point ret(-500, -500); //returned value
|
|
|
|
if(stack && stack->position < 0) //creatures in turrets
|
|
|
|
{
|
|
|
|
switch(stack->position)
|
|
|
|
{
|
|
|
|
case -2: //keep
|
2012-10-05 21:03:49 +03:00
|
|
|
ret = cbi->siegeH->town->town->clientInfo.siegePositions[18];
|
2011-12-22 16:05:19 +03:00
|
|
|
break;
|
|
|
|
case -3: //lower turret
|
2012-10-05 21:03:49 +03:00
|
|
|
ret = cbi->siegeH->town->town->clientInfo.siegePositions[19];
|
2011-12-22 16:05:19 +03:00
|
|
|
break;
|
|
|
|
case -4: //upper turret
|
2012-10-05 21:03:49 +03:00
|
|
|
ret = cbi->siegeH->town->town->clientInfo.siegePositions[20];
|
2011-12-22 16:05:19 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-07 22:44:08 +03:00
|
|
|
static const Point basePos(-190, -139); // position of creature in topleft corner
|
|
|
|
static const int imageShiftX = 30; // X offset to base pos for facing right stacks, negative for facing left
|
|
|
|
|
2013-07-17 01:59:39 +03:00
|
|
|
ret.x = basePos.x + 22 * ( (hexNum.getY() + 1)%2 ) + 44 * hexNum.getX();
|
|
|
|
ret.y = basePos.y + 42 * hexNum.getY();
|
|
|
|
|
|
|
|
if (stack)
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2013-07-17 01:59:39 +03:00
|
|
|
if(cbi->creDir[stack->ID])
|
|
|
|
ret.x += imageShiftX;
|
2011-12-22 16:05:19 +03:00
|
|
|
else
|
2013-07-17 01:59:39 +03:00
|
|
|
ret.x -= imageShiftX;
|
|
|
|
|
|
|
|
//shifting position for double - hex creatures
|
|
|
|
if(stack->doubleWide())
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2013-07-17 01:59:39 +03:00
|
|
|
if(stack->attackerOwned)
|
|
|
|
{
|
|
|
|
if(cbi->creDir[stack->ID])
|
|
|
|
ret.x -= 44;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(!cbi->creDir[stack->ID])
|
|
|
|
ret.x += 44;
|
|
|
|
}
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//returning
|
|
|
|
return ret +CPlayerInterface::battleInt->pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CClickableHex::hover(bool on)
|
|
|
|
{
|
|
|
|
hovered = on;
|
|
|
|
//Hoverable::hover(on);
|
|
|
|
if(!on && setAlterText)
|
|
|
|
{
|
|
|
|
myInterface->console->alterTxt = std::string();
|
|
|
|
setAlterText = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-26 14:18:27 +03:00
|
|
|
CClickableHex::CClickableHex() : setAlterText(false), myNumber(-1), accessible(true), hovered(false), strictHovered(false), myInterface(nullptr)
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2012-06-02 18:16:54 +03:00
|
|
|
addUsedEvents(LCLICK | RCLICK | HOVER | MOVE);
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CClickableHex::mouseMoved(const SDL_MouseMotionEvent &sEvent)
|
|
|
|
{
|
|
|
|
if(myInterface->cellShade)
|
|
|
|
{
|
|
|
|
if(CSDL_Ext::SDL_GetPixel(myInterface->cellShade, sEvent.x-pos.x, sEvent.y-pos.y) == 0) //hovered pixel is outside hex
|
|
|
|
{
|
|
|
|
strictHovered = false;
|
|
|
|
}
|
|
|
|
else //hovered pixel is inside hex
|
|
|
|
{
|
|
|
|
strictHovered = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(hovered && strictHovered) //print attacked creature to console
|
|
|
|
{
|
2013-11-03 19:44:47 +03:00
|
|
|
const CStack * attackedStack = myInterface->getCurrentPlayerInterface()->cb->battleGetStackByPos(myNumber);
|
2013-06-26 14:18:27 +03:00
|
|
|
if(myInterface->console->alterTxt.size() == 0 &&attackedStack != nullptr &&
|
2013-11-03 19:44:47 +03:00
|
|
|
attackedStack->owner != myInterface->getCurrentPlayerInterface()->playerID &&
|
2011-12-22 16:05:19 +03:00
|
|
|
attackedStack->alive())
|
|
|
|
{
|
|
|
|
char tabh[160];
|
|
|
|
const std::string & attackedName = attackedStack->count == 1 ? attackedStack->getCreature()->nameSing : attackedStack->getCreature()->namePl;
|
|
|
|
sprintf(tabh, CGI->generaltexth->allTexts[220].c_str(), attackedName.c_str());
|
|
|
|
myInterface->console->alterTxt = std::string(tabh);
|
|
|
|
setAlterText = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(setAlterText)
|
|
|
|
{
|
|
|
|
myInterface->console->alterTxt = std::string();
|
|
|
|
setAlterText = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CClickableHex::clickLeft(tribool down, bool previousState)
|
|
|
|
{
|
|
|
|
if(!down && hovered && strictHovered) //we've been really clicked!
|
|
|
|
{
|
|
|
|
myInterface->hexLclicked(myNumber);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CClickableHex::clickRight(tribool down, bool previousState)
|
|
|
|
{
|
2013-11-03 19:44:47 +03:00
|
|
|
const CStack * myst = myInterface->getCurrentPlayerInterface()->cb->battleGetStackByPos(myNumber); //stack info
|
2013-06-26 14:18:27 +03:00
|
|
|
if(hovered && strictHovered && myst!=nullptr)
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
if(!myst->alive()) return;
|
|
|
|
if(down)
|
|
|
|
{
|
|
|
|
GH.pushInt(createCreWindow(myst));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CStackQueue::update()
|
|
|
|
{
|
|
|
|
stacksSorted.clear();
|
2013-11-03 19:44:47 +03:00
|
|
|
owner->getCurrentPlayerInterface()->cb->battleGetStackQueue(stacksSorted, stackBoxes.size());
|
2012-08-31 19:33:30 +03:00
|
|
|
if(stacksSorted.size())
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2012-08-31 19:33:30 +03:00
|
|
|
for (int i = 0; i < stackBoxes.size() ; i++)
|
|
|
|
{
|
|
|
|
stackBoxes[i]->setStack(stacksSorted[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//no stacks on battlefield... what to do with queue?
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CStackQueue::CStackQueue(bool Embedded, CBattleInterface * _owner)
|
|
|
|
:embedded(Embedded), owner(_owner)
|
|
|
|
{
|
|
|
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
|
|
|
if(embedded)
|
|
|
|
{
|
2013-06-26 14:18:27 +03:00
|
|
|
bg = nullptr;
|
2011-12-22 16:05:19 +03:00
|
|
|
pos.w = QUEUE_SIZE * 37;
|
2012-08-28 19:28:21 +03:00
|
|
|
pos.h = 46;
|
2011-12-22 16:05:19 +03:00
|
|
|
pos.x = screen->w/2 - pos.w/2;
|
|
|
|
pos.y = (screen->h - 600)/2 + 10;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-28 19:28:21 +03:00
|
|
|
bg = BitmapHandler::loadBitmap("DIBOXBCK");
|
|
|
|
pos.w = 800;
|
|
|
|
pos.h = 85;
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
stackBoxes.resize(QUEUE_SIZE);
|
2012-08-28 19:28:21 +03:00
|
|
|
for (int i = 0; i < stackBoxes.size(); i++)
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2012-08-28 19:28:21 +03:00
|
|
|
stackBoxes[i] = new StackBox(embedded);
|
|
|
|
stackBoxes[i]->moveBy(Point(1 + (embedded ? 36 : 80)*i, 0));
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CStackQueue::~CStackQueue()
|
|
|
|
{
|
2012-08-28 19:28:21 +03:00
|
|
|
SDL_FreeSurface(bg);
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CStackQueue::showAll(SDL_Surface * to)
|
|
|
|
{
|
|
|
|
blitBg(to);
|
|
|
|
|
|
|
|
CIntObject::showAll(to);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CStackQueue::blitBg( SDL_Surface * to )
|
|
|
|
{
|
|
|
|
if(bg)
|
|
|
|
{
|
2012-08-28 19:28:21 +03:00
|
|
|
SDL_SetClipRect(to, &pos);
|
|
|
|
CSDL_Ext::fillTexture(to, bg);
|
|
|
|
SDL_SetClipRect(to, nullptr);
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CStackQueue::StackBox::showAll(SDL_Surface * to)
|
|
|
|
{
|
2012-08-28 19:28:21 +03:00
|
|
|
assert(stack);
|
|
|
|
bg->colorize(stack->owner);
|
|
|
|
CIntObject::showAll(to);
|
|
|
|
|
|
|
|
if(small)
|
2012-11-11 15:23:31 +03:00
|
|
|
printAtMiddleLoc(makeNumberShort(stack->count), pos.w/2, pos.h - 7, FONT_SMALL, Colors::WHITE, to);
|
2011-12-22 16:05:19 +03:00
|
|
|
else
|
2012-11-11 15:23:31 +03:00
|
|
|
printAtMiddleLoc(makeNumberShort(stack->count), pos.w/2, pos.h - 8, FONT_MEDIUM, Colors::WHITE, to);
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
|
2012-08-28 19:28:21 +03:00
|
|
|
void CStackQueue::StackBox::setStack( const CStack *stack )
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2012-08-28 19:28:21 +03:00
|
|
|
this->stack = stack;
|
|
|
|
assert(stack);
|
2012-09-22 18:10:15 +03:00
|
|
|
icon->setFrame(stack->getCreature()->iconIndex);
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
|
2012-08-28 19:28:21 +03:00
|
|
|
CStackQueue::StackBox::StackBox(bool small):
|
|
|
|
stack(nullptr),
|
|
|
|
small(small)
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2012-08-28 19:28:21 +03:00
|
|
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
|
|
|
bg = new CPicture(small ? "StackQueueBgSmall" : "StackQueueBgBig" );
|
|
|
|
|
|
|
|
if (small)
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
2012-08-28 19:28:21 +03:00
|
|
|
icon = new CAnimImage("CPRSMALL", 0, 0, 5, 2);
|
2011-12-22 16:05:19 +03:00
|
|
|
}
|
|
|
|
else
|
2012-08-28 19:28:21 +03:00
|
|
|
icon = new CAnimImage("TWCRPORT", 0, 0, 9, 1);
|
2011-12-22 16:05:19 +03:00
|
|
|
|
2012-08-28 19:28:21 +03:00
|
|
|
pos.w = bg->pos.w;
|
|
|
|
pos.h = bg->pos.h;
|
2012-05-13 18:04:21 +03:00
|
|
|
}
|