diff --git a/client/CAdvmapInterface.cpp b/client/CAdvmapInterface.cpp index d7b772319..cf50e7279 100644 --- a/client/CAdvmapInterface.cpp +++ b/client/CAdvmapInterface.cpp @@ -434,7 +434,7 @@ void CMinimap::show( SDL_Surface * to ) } CTerrainRect::CTerrainRect() - :currentPath(NULL) + :currentPath(NULL), curHoveredTile(-1,-1,-1) { tilesw=(ADVOPT.advmapW+31)/32; tilesh=(ADVOPT.advmapH+31)/32; @@ -466,6 +466,7 @@ void CTerrainRect::deactivate() deactivateRClick(); deactivateHover(); deactivateMouseMove(); + curHoveredTile = int3(-1,-1,-1); //we lost info about hovered tile when disabling }; void CTerrainRect::clickLeft(tribool down, bool previousState) { @@ -564,10 +565,12 @@ void CTerrainRect::clickRight(tribool down, bool previousState) return; std::vector < const CGObjectInstance * > objs = LOCPLINT->cb->getBlockingObjs(mp); - if(!objs.size()) { + if(!objs.size()) + { // Bare or undiscovered terrain const TerrainTile * tile = LOCPLINT->cb->getTileInfo(mp); - if (tile) { + if (tile) + { CSimpleWindow * temp = CMessage::genWindow(VLC->generaltexth->terrainNames[tile->tertype],LOCPLINT->playerID,true); CRClickPopupInt *rcpi = new CRClickPopupInt(temp,true); GH.pushInt(rcpi); @@ -1410,7 +1413,9 @@ void CInfoBar::newDay(int Day) } } pom = 0; - activateTimer(); + if(!(active & TIME)) + activateTimer(); + toNextTick = 500; blitAnim(mode); } @@ -1459,6 +1464,18 @@ void CInfoBar::show( SDL_Surface * to ) } +void CInfoBar::activate() +{ + //CIntObject::activate(); +} + +void CInfoBar::deactivate() +{ + //CIntObject::deactivate(); + if(active & TIME) + deactivateTimer(); +} + CAdvMapInt::CAdvMapInt(int Player) :player(Player), statusbar(ADVOPT.statusbarX,ADVOPT.statusbarY,ADVOPT.statusbarG), @@ -1643,8 +1660,10 @@ void CAdvMapInt::activate() heroList.activate(); townList.activate(); terrain.activate(); + infoBar.activate(); LOCPLINT->cingconsole->activate(); + GH.fakeMouseMove(); //to restore the cursor } void CAdvMapInt::deactivate() { @@ -1666,8 +1685,7 @@ void CAdvMapInt::deactivate() heroList.deactivate(); townList.deactivate(); terrain.deactivate(); - if(std::find(GH.timeinterested.begin(),GH.timeinterested.end(),&infoBar)!=GH.timeinterested.end()) - infoBar.deactivate(); + infoBar.deactivate(); infoBar.mode=-1; LOCPLINT->cingconsole->deactivate(); diff --git a/client/CAdvmapInterface.h b/client/CAdvmapInterface.h index a54beb48a..dd28bbc50 100644 --- a/client/CAdvmapInterface.h +++ b/client/CAdvmapInterface.h @@ -127,6 +127,8 @@ public: void blitAnim(int mode);//0 - day, 1 - week CDefHandler * getAnim(int mode); void show(SDL_Surface * to); + void activate(); + void deactivate(); }; /*****************************/ class CAdvMapInt : public CIntObject //adventure map interface diff --git a/client/CBattleInterface.cpp b/client/CBattleInterface.cpp index edf04e8c1..4e59fda77 100644 --- a/client/CBattleInterface.cpp +++ b/client/CBattleInterface.cpp @@ -1522,6 +1522,10 @@ void CBattleInterface::show(SDL_Surface * to) if(preSize > 0 && pendingAnims.size() == 0) { + //action finished, restore the interface + if(!active) + activate(); + //restoring good directions of stacks for(std::map::const_iterator it = stacks.begin(); it != stacks.end(); ++it) { @@ -1704,7 +1708,7 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent) CGI->curh->changeGraphic(1,3); //setting console text char buf[500]; - //calculating esimated dmg + //calculating estimated dmg std::pair estimatedDmg = LOCPLINT->cb->battleEstimateDamage(sactive->ID, shere->ID); std::ostringstream estDmg; estDmg << estimatedDmg.first << " - " << estimatedDmg.second; @@ -1738,16 +1742,21 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent) // Exclude directions which cannot be attacked from. // Check to the left. - if (myNumber%BFIELD_WIDTH <= 1 || !vstd::contains(shadedHexes, myNumber - 1)) { + if (myNumber%BFIELD_WIDTH <= 1 || !vstd::contains(shadedHexes, myNumber - 1)) + { sectorCursor[0] = -1; } // Check top left, top right as well as above for 2-hex creatures. - if (myNumber/BFIELD_WIDTH == 0) { + if (myNumber/BFIELD_WIDTH == 0) + { sectorCursor[1] = -1; sectorCursor[2] = -1; aboveAttackable = false; - } else { - if (doubleWide) { + } + else + { + if (doubleWide) + { bool attackRow[4] = {true, true, true, true}; if (myNumber%BFIELD_WIDTH <= 1 || !vstd::contains(shadedHexes, myNumber - BFIELD_WIDTH - 2 + zigzagCorrection)) @@ -1765,7 +1774,9 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent) aboveAttackable = false; if (!(attackRow[2] && attackRow[3])) sectorCursor[2] = -1; - } else { + } + else + { if (!vstd::contains(shadedHexes, myNumber - BFIELD_WIDTH - 1 + zigzagCorrection)) sectorCursor[1] = -1; if (!vstd::contains(shadedHexes, myNumber - BFIELD_WIDTH + zigzagCorrection)) @@ -1773,16 +1784,21 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent) } } // Check to the right. - if (myNumber%BFIELD_WIDTH >= BFIELD_WIDTH - 2 || !vstd::contains(shadedHexes, myNumber + 1)) { + if (myNumber%BFIELD_WIDTH >= BFIELD_WIDTH - 2 || !vstd::contains(shadedHexes, myNumber + 1)) + { sectorCursor[3] = -1; } // Check bottom right, bottom left as well as below for 2-hex creatures. - if (myNumber/BFIELD_WIDTH == BFIELD_HEIGHT - 1) { + if (myNumber/BFIELD_WIDTH == BFIELD_HEIGHT - 1) + { sectorCursor[4] = -1; sectorCursor[5] = -1; belowAttackable = false; - } else { - if (doubleWide) { + } + else + { + if (doubleWide) + { bool attackRow[4] = {true, true, true, true}; if (myNumber%BFIELD_WIDTH <= 1 || !vstd::contains(shadedHexes, myNumber + BFIELD_WIDTH - 2 + zigzagCorrection)) @@ -1800,7 +1816,9 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent) belowAttackable = false; if (!(attackRow[2] && attackRow[3])) sectorCursor[4] = -1; - } else { + } + else + { if (!vstd::contains(shadedHexes, myNumber + BFIELD_WIDTH + zigzagCorrection)) sectorCursor[4] = -1; if (!vstd::contains(shadedHexes, myNumber + BFIELD_WIDTH - 1 + zigzagCorrection)) @@ -1810,7 +1828,8 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent) // Determine index from sector. int cursorIndex; - if (doubleWide) { + if (doubleWide) + { sectorCursor.insert(sectorCursor.begin() + 5, belowAttackable ? 13 : -1); sectorCursor.insert(sectorCursor.begin() + 2, aboveAttackable ? 14 : -1); @@ -1824,7 +1843,9 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent) cursorIndex = 6; else cursorIndex = (int) sector + 2; - } else { + } + else + { cursorIndex = sector; } @@ -1837,7 +1858,7 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent) //setting console info char buf[500]; - //calculating esimated dmg + //calculating estimated dmg std::pair estimatedDmg = LOCPLINT->cb->battleEstimateDamage(sactive->ID, shere->ID); std::ostringstream estDmg; estDmg << estimatedDmg.first << " - " << estimatedDmg.second; @@ -1985,9 +2006,6 @@ void CBattleInterface::clickRight(tribool down, bool previousState) void CBattleInterface::bOptionsf() { - if(activeStack < 0) //workaround to prevent crashing calls in the middle of movement (action) - return; //TODO: disable options button during action (other buttons should be disabled as well) - if(spellDestSelectMode) //we are casting a spell return; @@ -2726,6 +2744,9 @@ void CBattleInterface::activateStack() bSpell->block(!defendingHeroInstance->getArt(17)); } GH.fakeMouseMove(); + + if(!pendingAnims.size() && !active) + activate(); } float CBattleInterface::getAnimSpeedMultiplier() const @@ -3008,9 +3029,9 @@ void CBattleInterface::projectileShowHelper(SDL_Surface * to) void CBattleInterface::endAction(const BattleAction* action) { //if((action->actionType==2 || (action->actionType==6 && action->destinationTile!=cb->battleGetPos(action->stackNumber)))) //activating interface when move is finished - { - activate(); - } +// { +// activate(); +// } if(action->actionType == 1) { if(action->side) @@ -3076,8 +3097,8 @@ void CBattleInterface::startAction(const BattleAction* action) } } - - deactivate(); + if(active) + deactivate(); char txt[400];