mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-19 12:02:24 +02:00
* general improvements in battles
* calls for spell casting in battles (they usually crash VCMI server)
This commit is contained in:
parent
4af64f1b9f
commit
929ce79ad4
@ -296,6 +296,7 @@ CTerrainRect::CTerrainRect():currentPath(NULL)
|
||||
pos.y=6;
|
||||
pos.w=593;
|
||||
pos.h=547;
|
||||
moveX = moveY = 0;
|
||||
arrows = CDefHandler::giveDef("ADAG.DEF");
|
||||
for(int y=0; y<arrows->ourImages.size(); ++y)
|
||||
{
|
||||
@ -731,7 +732,7 @@ void CTerrainRect::show()
|
||||
(LOCPLINT->adventureInt->position.x,LOCPLINT->adventureInt->position.y,
|
||||
tilesw,tilesh,LOCPLINT->adventureInt->position.z,LOCPLINT->adventureInt->anim,
|
||||
&LOCPLINT->cb->getVisibilityMap(), true, LOCPLINT->adventureInt->heroAnim,
|
||||
screen,&genRect(547,594,7,6)
|
||||
screen, &genRect(547, 594, 7, 6)
|
||||
);
|
||||
//SDL_BlitSurface(teren,&genRect(pos.h,pos.w,0,0),screen,&genRect(547,594,7,6));
|
||||
//SDL_FreeSurface(teren);
|
||||
@ -1093,7 +1094,7 @@ void CAdvMapInt::fsystemOptions()
|
||||
{
|
||||
LOCPLINT->curint->deactivate();
|
||||
|
||||
CSystemOptionsWindow * sysopWindow = new CSystemOptionsWindow(genRect(487, 481, 159, 57));
|
||||
CSystemOptionsWindow * sysopWindow = new CSystemOptionsWindow(genRect(487, 481, 159, 57), LOCPLINT);
|
||||
sysopWindow->activate();
|
||||
LOCPLINT->objsToBlit.push_back(sysopWindow);
|
||||
}
|
||||
|
@ -45,8 +45,9 @@ class CTerrainRect
|
||||
public MotionInterested
|
||||
{
|
||||
public:
|
||||
int tilesw, tilesh;
|
||||
int tilesw, tilesh; //width and height of terrain to blit in tiles
|
||||
int3 curHoveredTile;
|
||||
int moveX, moveY; //shift between actual position of screen and the one we wil blit; ranges from -31 to 31 (in pixels)
|
||||
|
||||
CDefHandler * arrows;
|
||||
CTerrainRect();
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
} cmpst2 ;
|
||||
|
||||
CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2)
|
||||
: printCellBorders(true), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0), activeStack(-1), givenCommand(NULL), attackingInfo(NULL), myTurn(false), resWindow(NULL), showStackQueue(false), animSpeed(2), printStackRange(true), printMouseShadow(true)
|
||||
: printCellBorders(true), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0), activeStack(-1), givenCommand(NULL), attackingInfo(NULL), myTurn(false), resWindow(NULL), showStackQueue(false), animSpeed(2), printStackRange(true), printMouseShadow(true), spellDestSelectMode(false), spellToCast(NULL)
|
||||
{
|
||||
strongInterest = true;
|
||||
givenCommand = new CondSh<BattleAction *>(NULL);
|
||||
@ -104,7 +104,7 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
|
||||
//loading hero animations
|
||||
if(hero1) // attacking hero
|
||||
{
|
||||
attackingHero = new CBattleHero(graphics->battleHeroes[hero1->type->heroType], 0, 0, false, hero1->tempOwner, hero1->tempOwner == LOCPLINT->playerID ? hero1 : NULL);
|
||||
attackingHero = new CBattleHero(graphics->battleHeroes[hero1->type->heroType], 0, 0, false, hero1->tempOwner, hero1->tempOwner == LOCPLINT->playerID ? hero1 : NULL, this);
|
||||
attackingHero->pos = genRect(attackingHero->dh->ourImages[0].bitmap->h, attackingHero->dh->ourImages[0].bitmap->w, -40, 0);
|
||||
}
|
||||
else
|
||||
@ -113,7 +113,7 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
|
||||
}
|
||||
if(hero2) // defending hero
|
||||
{
|
||||
defendingHero = new CBattleHero(graphics->battleHeroes[hero2->type->heroType], 0, 0, true, hero2->tempOwner, hero2->tempOwner == LOCPLINT->playerID ? hero2 : NULL);
|
||||
defendingHero = new CBattleHero(graphics->battleHeroes[hero2->type->heroType], 0, 0, true, hero2->tempOwner, hero2->tempOwner == LOCPLINT->playerID ? hero2 : NULL, this);
|
||||
defendingHero->pos = genRect(defendingHero->dh->ourImages[0].bitmap->h, defendingHero->dh->ourImages[0].bitmap->w, 690, 0);
|
||||
}
|
||||
else
|
||||
@ -466,7 +466,7 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
|
||||
void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent)
|
||||
{
|
||||
if(activeStack>=0)
|
||||
if(activeStack>=0 && !spellDestSelectMode)
|
||||
{
|
||||
int myNumber = -1; //number of hovered tile
|
||||
for(int g=0; g<187; ++g)
|
||||
@ -721,7 +721,6 @@ void CBattleInterface::stackMoved(int number, int destHex, bool endMoving)
|
||||
int hexWbase = 44, hexHbase = 42;
|
||||
bool twoTiles = LOCPLINT->cb->battleGetCreature(number).isDoubleWide();
|
||||
|
||||
deactivate();
|
||||
if(startMoving) //animation of starting move; some units don't have this animation (ie. halberdier)
|
||||
{
|
||||
CGI->curh->hide();
|
||||
@ -814,7 +813,6 @@ void CBattleInterface::stackMoved(int number, int destHex, bool endMoving)
|
||||
creAnims[number]->setType(2); //resetting to default
|
||||
CGI->curh->show();
|
||||
}
|
||||
activate();
|
||||
|
||||
CStack curs = *LOCPLINT->cb->battleGetStackByID(number);
|
||||
if(endMoving) //resetting to default
|
||||
@ -1047,51 +1045,61 @@ void CBattleInterface::hexLclicked(int whichOne)
|
||||
{
|
||||
if(!myTurn)
|
||||
return; //we are not permit to do anything
|
||||
|
||||
CStack* dest = LOCPLINT->cb->battleGetStackByPos(whichOne); //creature at destination tile; -1 if there is no one
|
||||
if(!dest || !dest->alive()) //no creature at that tile
|
||||
if(spellDestSelectMode)
|
||||
{
|
||||
if(std::find(shadedHexes.begin(),shadedHexes.end(),whichOne)!=shadedHexes.end())// and it's in our range
|
||||
giveCommand(2,whichOne,activeStack);
|
||||
spellToCast->destinationTile = whichOne;
|
||||
LOCPLINT->cb->battleMakeAction(spellToCast);
|
||||
spellToCast = NULL;
|
||||
spellDestSelectMode = false;
|
||||
CGI->curh->changeGraphic(1, 6);
|
||||
}
|
||||
else if(dest->owner != attackingHeroInstance->tempOwner
|
||||
&& LOCPLINT->cb->battleCanShoot(activeStack, whichOne)
|
||||
&& BattleInfo::mutualPosition(LOCPLINT->cb->battleGetPos(activeStack),whichOne) < 0 ) //shooting
|
||||
else
|
||||
{
|
||||
giveCommand(7,whichOne,activeStack);
|
||||
}
|
||||
else if(dest->owner != attackingHeroInstance->tempOwner) //attacking
|
||||
{
|
||||
//std::vector<int> n = BattleInfo::neighbouringTiles(whichOne);
|
||||
//for(int i=0;i<n.size();i++)
|
||||
//{
|
||||
// //TODO: now we are using first available tile, but in the future we should add possibility of choosing from which tile we want to attack
|
||||
// if(vstd::contains(shadedHexes,n[i]))
|
||||
// {
|
||||
// giveCommand(6,n[i],activeStack,whichOne);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
switch(CGI->curh->number)
|
||||
CStack* dest = LOCPLINT->cb->battleGetStackByPos(whichOne); //creature at destination tile; -1 if there is no one
|
||||
if(!dest || !dest->alive()) //no creature at that tile
|
||||
{
|
||||
case 12:
|
||||
giveCommand(6,whichOne + ( (whichOne/17)%2 ? 17 : 18 ),activeStack,whichOne);
|
||||
break;
|
||||
case 7:
|
||||
giveCommand(6,whichOne + ( (whichOne/17)%2 ? 16 : 17 ),activeStack,whichOne);
|
||||
break;
|
||||
case 8:
|
||||
giveCommand(6,whichOne - 1,activeStack,whichOne);
|
||||
break;
|
||||
case 9:
|
||||
giveCommand(6,whichOne - ( (whichOne/17)%2 ? 18 : 17 ),activeStack,whichOne);
|
||||
break;
|
||||
case 10:
|
||||
giveCommand(6,whichOne - ( (whichOne/17)%2 ? 17 : 16 ),activeStack,whichOne);
|
||||
break;
|
||||
case 11:
|
||||
giveCommand(6,whichOne + 1,activeStack,whichOne);
|
||||
break;
|
||||
if(std::find(shadedHexes.begin(),shadedHexes.end(),whichOne)!=shadedHexes.end())// and it's in our range
|
||||
giveCommand(2,whichOne,activeStack);
|
||||
}
|
||||
else if(dest->owner != attackingHeroInstance->tempOwner
|
||||
&& LOCPLINT->cb->battleCanShoot(activeStack, whichOne)
|
||||
&& BattleInfo::mutualPosition(LOCPLINT->cb->battleGetPos(activeStack),whichOne) < 0 ) //shooting
|
||||
{
|
||||
giveCommand(7,whichOne,activeStack);
|
||||
}
|
||||
else if(dest->owner != attackingHeroInstance->tempOwner) //attacking
|
||||
{
|
||||
//std::vector<int> n = BattleInfo::neighbouringTiles(whichOne);
|
||||
//for(int i=0;i<n.size();i++)
|
||||
//{
|
||||
// //TODO: now we are using first available tile, but in the future we should add possibility of choosing from which tile we want to attack
|
||||
// if(vstd::contains(shadedHexes,n[i]))
|
||||
// {
|
||||
// giveCommand(6,n[i],activeStack,whichOne);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
switch(CGI->curh->number)
|
||||
{
|
||||
case 12:
|
||||
giveCommand(6,whichOne + ( (whichOne/17)%2 ? 17 : 18 ),activeStack,whichOne);
|
||||
break;
|
||||
case 7:
|
||||
giveCommand(6,whichOne + ( (whichOne/17)%2 ? 16 : 17 ),activeStack,whichOne);
|
||||
break;
|
||||
case 8:
|
||||
giveCommand(6,whichOne - 1,activeStack,whichOne);
|
||||
break;
|
||||
case 9:
|
||||
giveCommand(6,whichOne - ( (whichOne/17)%2 ? 18 : 17 ),activeStack,whichOne);
|
||||
break;
|
||||
case 10:
|
||||
giveCommand(6,whichOne - ( (whichOne/17)%2 ? 17 : 16 ),activeStack,whichOne);
|
||||
break;
|
||||
case 11:
|
||||
giveCommand(6,whichOne + 1,activeStack,whichOne);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1182,6 +1190,18 @@ void CBattleInterface::battleFinished(const BattleResult& br)
|
||||
resWindow->activate();
|
||||
}
|
||||
|
||||
void CBattleInterface::castThisSpell(int spellID)
|
||||
{
|
||||
BattleAction * ba = new BattleAction;
|
||||
ba->actionType = 1;
|
||||
ba->additionalInfo = spellID; //spell number
|
||||
ba->destinationTile = -1;
|
||||
ba->side = defendingHeroInstance ? (LOCPLINT->playerID == defendingHeroInstance->tempOwner) : false;
|
||||
spellToCast = ba;
|
||||
spellDestSelectMode = true;
|
||||
CGI->curh->changeGraphic(3, 0);
|
||||
}
|
||||
|
||||
void CBattleInterface::setAnimSpeed(int set)
|
||||
{
|
||||
animSpeed = set;
|
||||
@ -1521,6 +1541,11 @@ void CBattleHero::clickLeft(boost::logic::tribool down)
|
||||
{
|
||||
if(!down && myHero)
|
||||
{
|
||||
for(int it=0; it<187; ++it) //do nothing when any hex is hovered - hero's animation overlaps battlefield
|
||||
{
|
||||
if(myOwner->bfield[it].hovered && myOwner->bfield[it].strictHovered)
|
||||
return;
|
||||
}
|
||||
CGI->curh->changeGraphic(0,0);
|
||||
LOCPLINT->curint->deactivate();
|
||||
|
||||
@ -1530,7 +1555,7 @@ void CBattleHero::clickLeft(boost::logic::tribool down)
|
||||
}
|
||||
}
|
||||
|
||||
CBattleHero::CBattleHero(const std::string & defName, int phaseG, int imageG, bool flipG, unsigned char player, const CGHeroInstance * hero): phase(phaseG), image(imageG), flip(flipG), flagAnim(0), myHero(hero)
|
||||
CBattleHero::CBattleHero(const std::string & defName, int phaseG, int imageG, bool flipG, unsigned char player, const CGHeroInstance * hero, const CBattleInterface * owner): phase(phaseG), image(imageG), flip(flipG), flagAnim(0), myHero(hero), myOwner(owner)
|
||||
{
|
||||
dh = CDefHandler::giveDef( defName );
|
||||
for(int i=0; i<dh->ourImages.size(); ++i) //transforming images
|
||||
|
@ -14,12 +14,15 @@ class CHighlightableButtonsGroup;
|
||||
struct BattleResult;
|
||||
template <typename T> struct CondSh;
|
||||
|
||||
class CBattleInterface;
|
||||
|
||||
class CBattleHero : public IShowable, public ClickableL
|
||||
{
|
||||
public:
|
||||
bool flip; //false if it's attacking hero, true otherwise
|
||||
CDefHandler * dh, *flag; //animation and flag
|
||||
const CGHeroInstance * myHero; //this animation's hero instance
|
||||
const CBattleInterface * myOwner; //battle interface to which this animation is assigned
|
||||
int phase; //stage of animation
|
||||
int image; //frame of animation
|
||||
unsigned char flagAnim, flagAnimCount; //for flag animation
|
||||
@ -27,12 +30,10 @@ public:
|
||||
void activate();
|
||||
void deactivate();
|
||||
void clickLeft(boost::logic::tribool down);
|
||||
CBattleHero(const std::string & defName, int phaseG, int imageG, bool filpG, unsigned char player, const CGHeroInstance * hero); //c-tor
|
||||
CBattleHero(const std::string & defName, int phaseG, int imageG, bool filpG, unsigned char player, const CGHeroInstance * hero, const CBattleInterface * owner); //c-tor
|
||||
~CBattleHero(); //d-tor
|
||||
};
|
||||
|
||||
class CBattleInterface;
|
||||
|
||||
class CBattleHex : public Hoverable, public MotionInterested, public ClickableL, public ClickableR
|
||||
{
|
||||
private:
|
||||
@ -131,6 +132,9 @@ private:
|
||||
int animSpeed; //speed of animation; 1 - slowest, 2 - medium, 4 - fastest
|
||||
float getAnimSpeedMultiplier() const; //returns multiplier for number of frames in a group
|
||||
|
||||
bool spellDestSelectMode; //if true, player is choosing destination for his spell
|
||||
BattleAction * spellToCast; //spell for which player is choosing destination
|
||||
|
||||
class CAttHelper
|
||||
{
|
||||
public:
|
||||
@ -214,6 +218,7 @@ public:
|
||||
void hexLclicked(int whichOne); //hex only call-in
|
||||
void stackIsShooting(int ID, int dest); //called when stack with id ID is shooting to hex dest
|
||||
void battleFinished(const BattleResult& br); //called when battle is finished - battleresult window should be printed
|
||||
void castThisSpell(int spellID); //called when player has chosen a spell from spellbook
|
||||
|
||||
friend class CBattleHex;
|
||||
friend class CBattleReslutWindow;
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/assign/std/vector.hpp>
|
||||
#include <boost/assign/list_of.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <cmath>
|
||||
#include <queue>
|
||||
@ -959,6 +960,7 @@ CPlayerInterface::CPlayerInterface(int Player, int serial)
|
||||
human=true;
|
||||
pim = new boost::recursive_mutex;
|
||||
showingDialog = new CondSh<bool>(false);
|
||||
heroMoveSpeed = 2;
|
||||
}
|
||||
CPlayerInterface::~CPlayerInterface()
|
||||
{
|
||||
@ -1328,10 +1330,14 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
//first initializing done
|
||||
SDL_framerateDelay(mainFPSmng); // after first move
|
||||
//main moving
|
||||
for(int i=1; i<32; i+=4)
|
||||
for(int i=1; i<32; i+=2*heroMoveSpeed)
|
||||
{
|
||||
if(details.dst.x+1 == details.src.x && details.dst.y+1 == details.src.y) //tl
|
||||
{
|
||||
//seting advmap shift
|
||||
adventureInt->terrain.moveX = i-32;
|
||||
adventureInt->terrain.moveY = i-32;
|
||||
|
||||
subRect(hp.x-3, hp.y-2, hp.z, genRect(32, 32, -31+i, -31+i), ho->id);
|
||||
subRect(hp.x-2, hp.y-2, hp.z, genRect(32, 32, 1+i, -31+i), ho->id);
|
||||
subRect(hp.x-1, hp.y-2, hp.z, genRect(32, 32, 33+i, -31+i), ho->id);
|
||||
@ -1349,6 +1355,9 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
}
|
||||
else if(details.dst.x == details.src.x && details.dst.y+1 == details.src.y) //t
|
||||
{
|
||||
//seting advmap shift
|
||||
adventureInt->terrain.moveY = i-32;
|
||||
|
||||
subRect(hp.x-2, hp.y-2, hp.z, genRect(32, 32, 0, -31+i), ho->id);
|
||||
subRect(hp.x-1, hp.y-2, hp.z, genRect(32, 32, 32, -31+i), ho->id);
|
||||
subRect(hp.x, hp.y-2, hp.z, genRect(32, 32, 64, -31+i), ho->id);
|
||||
@ -1363,6 +1372,10 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
}
|
||||
else if(details.dst.x-1 == details.src.x && details.dst.y+1 == details.src.y) //tr
|
||||
{
|
||||
//seting advmap shift
|
||||
adventureInt->terrain.moveX = -i+32;
|
||||
adventureInt->terrain.moveY = i-32;
|
||||
|
||||
subRect(hp.x-2, hp.y-2, hp.z, genRect(32, 32, -1-i, -31+i), ho->id);
|
||||
subRect(hp.x-1, hp.y-2, hp.z, genRect(32, 32, 31-i, -31+i), ho->id);
|
||||
subRect(hp.x, hp.y-2, hp.z, genRect(32, 32, 63-i, -31+i), ho->id);
|
||||
@ -1380,6 +1393,9 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
}
|
||||
else if(details.dst.x-1 == details.src.x && details.dst.y == details.src.y) //r
|
||||
{
|
||||
//seting advmap shift
|
||||
adventureInt->terrain.moveX = -i+32;
|
||||
|
||||
subRect(hp.x-2, hp.y-1, hp.z, genRect(32, 32, -1-i, 0), ho->id);
|
||||
subRect(hp.x-1, hp.y-1, hp.z, genRect(32, 32, 31-i, 0), ho->id);
|
||||
subRect(hp.x, hp.y-1, hp.z, genRect(32, 32, 63-i, 0), ho->id);
|
||||
@ -1392,6 +1408,11 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
}
|
||||
else if(details.dst.x-1 == details.src.x && details.dst.y-1 == details.src.y) //br
|
||||
{
|
||||
|
||||
//seting advmap shift
|
||||
adventureInt->terrain.moveX = -i+32;
|
||||
adventureInt->terrain.moveY = -i+32;
|
||||
|
||||
subRect(hp.x-2, hp.y-1, hp.z, genRect(32, 32, -1-i, -1-i), ho->id);
|
||||
subRect(hp.x-1, hp.y-1, hp.z, genRect(32, 32, 31-i, -1-i), ho->id);
|
||||
subRect(hp.x, hp.y-1, hp.z, genRect(32, 32, 63-i, -1-i), ho->id);
|
||||
@ -1409,6 +1430,9 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
}
|
||||
else if(details.dst.x == details.src.x && details.dst.y-1 == details.src.y) //b
|
||||
{
|
||||
//seting advmap shift
|
||||
adventureInt->terrain.moveY = -i+32;
|
||||
|
||||
subRect(hp.x-2, hp.y-1, hp.z, genRect(32, 32, 0, -1-i), ho->id);
|
||||
subRect(hp.x-1, hp.y-1, hp.z, genRect(32, 32, 32, -1-i), ho->id);
|
||||
subRect(hp.x, hp.y-1, hp.z, genRect(32, 32, 64, -1-i), ho->id);
|
||||
@ -1423,6 +1447,10 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
}
|
||||
else if(details.dst.x+1 == details.src.x && details.dst.y-1 == details.src.y) //bl
|
||||
{
|
||||
//seting advmap shift
|
||||
adventureInt->terrain.moveX = i-32;
|
||||
adventureInt->terrain.moveY = -i+32;
|
||||
|
||||
subRect(hp.x-3, hp.y-1, hp.z, genRect(32, 32, -31+i, -1-i), ho->id);
|
||||
subRect(hp.x-2, hp.y-1, hp.z, genRect(32, 32, 1+i, -1-i), ho->id);
|
||||
subRect(hp.x-1, hp.y-1, hp.z, genRect(32, 32, 33+i, -1-i), ho->id);
|
||||
@ -1440,6 +1468,9 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
}
|
||||
else if(details.dst.x+1 == details.src.x && details.dst.y == details.src.y) //l
|
||||
{
|
||||
//seting advmap shift
|
||||
adventureInt->terrain.moveX = i-32;
|
||||
|
||||
subRect(hp.x-3, hp.y-1, hp.z, genRect(32, 32, -31+i, 0), ho->id);
|
||||
subRect(hp.x-2, hp.y-1, hp.z, genRect(32, 32, 1+i, 0), ho->id);
|
||||
subRect(hp.x-1, hp.y-1, hp.z, genRect(32, 32, 33+i, 0), ho->id);
|
||||
@ -1469,6 +1500,10 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
} //for(int i=1; i<32; i+=4)
|
||||
//main moving done
|
||||
//finishing move
|
||||
|
||||
//restoring adventureInt->terrain.move*
|
||||
adventureInt->terrain.moveX = adventureInt->terrain.moveY = 0;
|
||||
|
||||
if(details.dst.x+1 == details.src.x && details.dst.y+1 == details.src.y) //tl
|
||||
{
|
||||
delObjRect(hp.x, hp.y-2, hp.z, ho->id);
|
||||
@ -1528,6 +1563,15 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
delObjRect(hp.x, hp.y, hp.z, ho->id);
|
||||
}
|
||||
|
||||
//restoring good rects
|
||||
subRect(details.dst.x-2, details.dst.y-1, details.dst.z, genRect(32, 32, 0, 0), ho->id);
|
||||
subRect(details.dst.x-1, details.dst.y-1, details.dst.z, genRect(32, 32, 32, 0), ho->id);
|
||||
subRect(details.dst.x, details.dst.y-1, details.dst.z, genRect(32, 32, 64, 0), ho->id);
|
||||
|
||||
subRect(details.dst.x-2, details.dst.y, details.dst.z, genRect(32, 32, 0, 32), ho->id);
|
||||
subRect(details.dst.x-1, details.dst.y, details.dst.z, genRect(32, 32, 32, 32), ho->id);
|
||||
subRect(details.dst.x, details.dst.y, details.dst.z, genRect(32, 32, 64, 32), ho->id);
|
||||
|
||||
//restoring good order of objects
|
||||
std::stable_sort(CGI->mh->ttiles[details.dst.x-2][details.dst.y-1][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x-2][details.dst.y-1][details.dst.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[details.dst.x-1][details.dst.y-1][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x-1][details.dst.y-1][details.dst.z].objects.end(), ocmptwo_cgin);
|
||||
@ -2025,12 +2069,20 @@ void CPlayerInterface::actionStarted(const BattleAction* action)
|
||||
)
|
||||
{
|
||||
static_cast<CBattleInterface*>(curint)->creAnims[action->stackNumber]->setType(20);
|
||||
if((action->actionType==2 || (action->actionType==6 && action->destinationTile!=cb->battleGetPos(action->stackNumber)))) //deactivating interface when move is started
|
||||
{
|
||||
static_cast<CBattleInterface*>(curint)->deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPlayerInterface::actionFinished(const BattleAction* action)
|
||||
{
|
||||
curAction = NULL;
|
||||
if((action->actionType==2 || (action->actionType==6 && action->destinationTile!=cb->battleGetPos(action->stackNumber)))) //activating interface when move is finished
|
||||
{
|
||||
static_cast<CBattleInterface*>(curint)->activate();
|
||||
}
|
||||
}
|
||||
|
||||
BattleAction CPlayerInterface::activeStack(int stackID) //called when it's turn of that stack
|
||||
@ -3745,7 +3797,7 @@ void CMarketplaceWindow::selectionChanged(bool side)
|
||||
}
|
||||
}
|
||||
|
||||
CSystemOptionsWindow::CSystemOptionsWindow(const SDL_Rect &pos)
|
||||
CSystemOptionsWindow::CSystemOptionsWindow(const SDL_Rect &pos, CPlayerInterface * owner)
|
||||
{
|
||||
this->pos = pos;
|
||||
background = BitmapHandler::loadBitmap("SysOpbck.bmp", true);
|
||||
@ -3772,6 +3824,14 @@ CSystemOptionsWindow::CSystemOptionsWindow(const SDL_Rect &pos)
|
||||
std::swap(quitGame->imgs[0][0], quitGame->imgs[0][1]);
|
||||
backToMap = new AdventureMapButton (CGI->preth->zelp[325].first, CGI->preth->zelp[325].second, boost::bind(&CSystemOptionsWindow::breturnf, this), 516, 471, "soretrn.def", false, NULL, false);
|
||||
std::swap(backToMap->imgs[0][0], backToMap->imgs[0][1]);
|
||||
|
||||
heroMoveSpeed = new CHighlightableButtonsGroup(0);
|
||||
heroMoveSpeed->addButton(boost::assign::map_list_of(0,CGI->preth->zelp[349].first),CGI->preth->zelp[349].second, "sysopb1.def", 187, 134, 1);
|
||||
heroMoveSpeed->addButton(boost::assign::map_list_of(0,CGI->preth->zelp[350].first),CGI->preth->zelp[350].second, "sysopb2.def", 235, 134, 2);
|
||||
heroMoveSpeed->addButton(boost::assign::map_list_of(0,CGI->preth->zelp[351].first),CGI->preth->zelp[351].second, "sysopb3.def", 283, 134, 4);
|
||||
heroMoveSpeed->addButton(boost::assign::map_list_of(0,CGI->preth->zelp[352].first),CGI->preth->zelp[352].second, "sysopb4.def", 331, 134, 8);
|
||||
heroMoveSpeed->select(owner->heroMoveSpeed, 1);
|
||||
heroMoveSpeed->onChange = boost::bind(&CPlayerInterface::setHeroMoveSpeed, owner, _1);
|
||||
}
|
||||
|
||||
CSystemOptionsWindow::~CSystemOptionsWindow()
|
||||
@ -3780,6 +3840,7 @@ CSystemOptionsWindow::~CSystemOptionsWindow()
|
||||
|
||||
delete quitGame;
|
||||
delete backToMap;
|
||||
delete heroMoveSpeed;
|
||||
}
|
||||
|
||||
void CSystemOptionsWindow::bquitf()
|
||||
@ -3809,12 +3870,14 @@ void CSystemOptionsWindow::activate()
|
||||
{
|
||||
quitGame->activate();
|
||||
backToMap->activate();
|
||||
heroMoveSpeed->activate();
|
||||
}
|
||||
|
||||
void CSystemOptionsWindow::deactivate()
|
||||
{
|
||||
quitGame->deactivate();
|
||||
backToMap->deactivate();
|
||||
heroMoveSpeed->deactivate();
|
||||
}
|
||||
|
||||
void CSystemOptionsWindow::show(SDL_Surface *to)
|
||||
@ -3827,4 +3890,5 @@ void CSystemOptionsWindow::show(SDL_Surface *to)
|
||||
|
||||
quitGame->show(to);
|
||||
backToMap->show(to);
|
||||
heroMoveSpeed->show(to);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
class CDefEssential;
|
||||
class AdventureMapButton;
|
||||
class CHighlightableButtonsGroup;
|
||||
class CDefHandler;
|
||||
struct HeroMoveDetails;
|
||||
class CDefEssential;
|
||||
@ -319,6 +320,8 @@ public:
|
||||
CondSh<bool> *showingDialog;
|
||||
boost::recursive_mutex *pim;
|
||||
bool makingTurn;
|
||||
int heroMoveSpeed;
|
||||
void setHeroMoveSpeed(int newSpeed) {heroMoveSpeed = newSpeed;}; //set for the member above
|
||||
SDL_Event * current;
|
||||
CMainInterface *curint;
|
||||
CAdvMapInt * adventureInt;
|
||||
@ -640,8 +643,9 @@ class CSystemOptionsWindow : public IShowActivable, public CIntObject
|
||||
private:
|
||||
SDL_Surface * background; //background of window
|
||||
AdventureMapButton * quitGame, * backToMap;
|
||||
CHighlightableButtonsGroup * heroMoveSpeed;
|
||||
public:
|
||||
CSystemOptionsWindow(const SDL_Rect & pos); //c-tor
|
||||
CSystemOptionsWindow(const SDL_Rect & pos, CPlayerInterface * owner); //c-tor
|
||||
~CSystemOptionsWindow(); //d-tor
|
||||
|
||||
//functions for butons
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "../hch/CPreGameTextHandler.h"
|
||||
#include "../hch/CGeneralTextHandler.h"
|
||||
#include "../CAdvmapInterface.h"
|
||||
#include "../CBattleInterface.h"
|
||||
#include "../CGameInfo.h"
|
||||
#include "../SDL_Extensions.h"
|
||||
#include "../CMessage.h"
|
||||
@ -615,6 +616,12 @@ CSpellWindow::SpellArea::SpellArea(SDL_Rect pos, CSpellWindow * owner)
|
||||
|
||||
void CSpellWindow::SpellArea::clickLeft(boost::logic::tribool down)
|
||||
{
|
||||
owner->fexitb();
|
||||
//we will cast a spell
|
||||
if(dynamic_cast<CBattleInterface*>(LOCPLINT->curint)) //if battle window is open
|
||||
{
|
||||
dynamic_cast<CBattleInterface*>(LOCPLINT->curint)->castThisSpell(mySpell);
|
||||
}
|
||||
}
|
||||
|
||||
void CSpellWindow::SpellArea::clickRight(boost::logic::tribool down)
|
||||
|
Loading…
x
Reference in New Issue
Block a user