1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Fix 2014 cursor must disappear during movement and Magi's Eye

This commit is contained in:
Vadim Markovtsev 2016-01-23 00:35:41 +03:00
parent b02bd61c83
commit a266154b26
3 changed files with 41 additions and 26 deletions

View File

@ -119,7 +119,7 @@ CPlayerInterface::CPlayerInterface(PlayerColor Player)
isAutoFightOn = false; isAutoFightOn = false;
duringMovement = false; duringMovement = false;
ignoreEvents = false; ignoreEvents = false;
} }
CPlayerInterface::~CPlayerInterface() CPlayerInterface::~CPlayerInterface()
@ -824,16 +824,16 @@ BattleAction CPlayerInterface::activeStack(const CStack * stack) //called when i
//tidy up //tidy up
BattleAction ret = *(b->givenCommand->data); BattleAction ret = *(b->givenCommand->data);
vstd::clear_pointer(b->givenCommand->data); vstd::clear_pointer(b->givenCommand->data);
if(ret.actionType == Battle::CANCEL) if(ret.actionType == Battle::CANCEL)
{ {
if(stackId != ret.stackNumber) if(stackId != ret.stackNumber)
logGlobal->error("Not current active stack action canceled"); logGlobal->error("Not current active stack action canceled");
logGlobal->traceStream() << "Canceled command for " << stackName; logGlobal->traceStream() << "Canceled command for " << stackName;
} }
else else
logGlobal->traceStream() << "Giving command for " << stackName; logGlobal->traceStream() << "Giving command for " << stackName;
return ret; return ret;
} }
@ -1335,7 +1335,7 @@ void CPlayerInterface::moveHero( const CGHeroInstance *h, CGPath path )
if(showingDialog->get() || !dialogs.empty()) if(showingDialog->get() || !dialogs.empty())
return; return;
duringMovement = true; setMovementStatus(true);
if (adventureInt && adventureInt->isHeroSleeping(h)) if (adventureInt && adventureInt->isHeroSleeping(h))
{ {
@ -1347,8 +1347,6 @@ void CPlayerInterface::moveHero( const CGHeroInstance *h, CGPath path )
} }
boost::thread moveHeroTask(std::bind(&CPlayerInterface::doMoveHero,this,h,path)); boost::thread moveHeroTask(std::bind(&CPlayerInterface::doMoveHero,this,h,path));
} }
bool CPlayerInterface::shiftPressed() const bool CPlayerInterface::shiftPressed() const
@ -1559,6 +1557,7 @@ void CPlayerInterface::centerView (int3 pos, int focusTime)
{ {
EVENT_HANDLER_CALLED_BY_CLIENT; EVENT_HANDLER_CALLED_BY_CLIENT;
waitWhileDialog(); waitWhileDialog();
CCS->curh->hide();
adventureInt->centerOn (pos); adventureInt->centerOn (pos);
if(focusTime) if(focusTime)
{ {
@ -1569,6 +1568,7 @@ void CPlayerInterface::centerView (int3 pos, int focusTime)
SDL_Delay(focusTime); SDL_Delay(focusTime);
} }
} }
CCS->curh->show();
} }
void CPlayerInterface::objectRemoved( const CGObjectInstance *obj ) void CPlayerInterface::objectRemoved( const CGObjectInstance *obj )
@ -1610,11 +1610,11 @@ void CPlayerInterface::update()
{ {
// Make sure that gamestate won't change when GUI objects may obtain its parts on event processing or drawing request // Make sure that gamestate won't change when GUI objects may obtain its parts on event processing or drawing request
boost::shared_lock<boost::shared_mutex> gsLock(cb->getGsMutex()); boost::shared_lock<boost::shared_mutex> gsLock(cb->getGsMutex());
// While mutexes were locked away we may be have stopped being the active interface // While mutexes were locked away we may be have stopped being the active interface
if(LOCPLINT != this) if(LOCPLINT != this)
return; return;
//if there are any waiting dialogs, show them //if there are any waiting dialogs, show them
if((howManyPeople <= 1 || makingTurn) && !dialogs.empty() && !showingDialog->get()) if((howManyPeople <= 1 || makingTurn) && !dialogs.empty() && !showingDialog->get())
{ {
@ -2195,7 +2195,7 @@ void CPlayerInterface::advmapSpellCast(const CGHeroInstance * caster, int spellI
int level = caster->getSpellSchoolLevel(spell); int level = caster->getSpellSchoolLevel(spell);
adventureInt->worldViewOptions.showAllTerrain = (level>2); adventureInt->worldViewOptions.showAllTerrain = (level>2);
} }
auto castSoundPath = spell->getCastSound(); auto castSoundPath = spell->getCastSound();
if (!castSoundPath.empty()) if (!castSoundPath.empty())
CCS->soundh->playSound(castSoundPath); CCS->soundh->playSound(castSoundPath);
@ -2632,6 +2632,19 @@ bool CPlayerInterface::capturedAllEvents()
return false; return false;
} }
void CPlayerInterface::setMovementStatus(bool value)
{
duringMovement = value;
if(value)
{
CCS->curh->hide();
}
else
{
CCS->curh->show();
}
}
void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path) void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path)
{ {
int i = 1; int i = 1;
@ -2776,15 +2789,15 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path)
adventureInt->updateNextHero(h); adventureInt->updateNextHero(h);
} }
duringMovement = false; setMovementStatus(false);
} }
void CPlayerInterface::showWorldViewEx(const std::vector<ObjectPosInfo>& objectPositions) void CPlayerInterface::showWorldViewEx(const std::vector<ObjectPosInfo>& objectPositions)
{ {
EVENT_HANDLER_CALLED_BY_CLIENT; EVENT_HANDLER_CALLED_BY_CLIENT;
//TODO: showWorldViewEx //TODO: showWorldViewEx
std::copy(objectPositions.begin(), objectPositions.end(), std::back_inserter(adventureInt->worldViewOptions.iconPositions)); std::copy(objectPositions.begin(), objectPositions.end(), std::back_inserter(adventureInt->worldViewOptions.iconPositions));
viewWorldMap(); viewWorldMap();
} }

View File

@ -197,7 +197,7 @@ public:
void showComp(const Component &comp, std::string message) override; //display component in the advmapint infobox void showComp(const Component &comp, std::string message) override; //display component in the advmapint infobox
void saveGame(COSer & h, const int version) override; //saving void saveGame(COSer & h, const int version) override; //saving
void loadGame(CISer & h, const int version) override; //loading void loadGame(CISer & h, const int version) override; //loading
void showWorldViewEx(const std::vector<ObjectPosInfo> & objectPositions) override; void showWorldViewEx(const std::vector<ObjectPosInfo> & objectPositions) override;
//for battles //for battles
void actionFinished(const BattleAction& action) override;//occurs AFTER action taken by active stack or by the hero void actionFinished(const BattleAction& action) override;//occurs AFTER action taken by active stack or by the hero
@ -295,6 +295,7 @@ private:
bool ignoreEvents; bool ignoreEvents;
void doMoveHero(const CGHeroInstance *h, CGPath path); void doMoveHero(const CGHeroInstance *h, CGPath path);
void setMovementStatus(bool value);
}; };
extern CPlayerInterface * LOCPLINT; extern CPlayerInterface * LOCPLINT;

View File

@ -103,16 +103,16 @@ std::string CGCreature::getHoverText(const CGHeroInstance * hero) const
{ {
std::string hoverName; std::string hoverName;
if(hero->hasVisions(this, 0)) if(hero->hasVisions(this, 0))
{ {
MetaString ms; MetaString ms;
ms << stacks.begin()->second->count; ms << stacks.begin()->second->count;
ms << " " ; ms << " " ;
ms.addTxt(MetaString::CRE_PL_NAMES,subID); ms.addTxt(MetaString::CRE_PL_NAMES,subID);
ms << "\n"; ms << "\n";
int decision = takenAction(hero, true); int decision = takenAction(hero, true);
switch (decision) switch (decision)
{ {
case FIGHT: case FIGHT:
@ -123,19 +123,19 @@ std::string CGCreature::getHoverText(const CGHeroInstance * hero) const
break; break;
case JOIN_FOR_FREE: case JOIN_FOR_FREE:
ms.addTxt(MetaString::GENERAL_TXT,243); ms.addTxt(MetaString::GENERAL_TXT,243);
break; break;
default: //decision = cost in gold default: //decision = cost in gold
VLC->generaltexth->allTexts[244]; VLC->generaltexth->allTexts[244];
ms << boost::to_string(boost::format(VLC->generaltexth->allTexts[244]) % decision); ms << boost::to_string(boost::format(VLC->generaltexth->allTexts[244]) % decision);
break; break;
} }
ms.toString(hoverName); ms.toString(hoverName);
} }
else else
{ {
hoverName = getHoverText(hero->tempOwner); hoverName = getHoverText(hero->tempOwner);
} }
const JsonNode & texts = VLC->generaltexth->localizedTexts["adventureMap"]["monsterThreat"]; const JsonNode & texts = VLC->generaltexth->localizedTexts["adventureMap"]["monsterThreat"];
@ -1667,6 +1667,7 @@ void CGMagi::onHeroVisit(const CGHeroInstance * h) const
cb->sendAndApply(&cv); cb->sendAndApply(&cv);
} }
cv.pos = h->getPosition(false); cv.pos = h->getPosition(false);
cv.focusTime = 0;
cb->sendAndApply(&cv); cb->sendAndApply(&cv);
} }
} }
@ -1745,7 +1746,7 @@ void CGShipyard::getOutOffsets( std::vector<int3> &offsets ) const
int3(-3,0,0), int3(1,0,0), //AB int3(-3,0,0), int3(1,0,0), //AB
int3(-3,1,0), int3(1,1,0), int3(-2,1,0), int3(0,1,0), int3(-1,1,0), //CDEFG int3(-3,1,0), int3(1,1,0), int3(-2,1,0), int3(0,1,0), int3(-1,1,0), //CDEFG
int3(-3,-1,0), int3(1,-1,0), int3(-2,-1,0), int3(0,-1,0), int3(-1,-1,0) //HIJKL int3(-3,-1,0), int3(1,-1,0), int3(-2,-1,0), int3(0,-1,0), int3(-1,-1,0) //HIJKL
}; };
} }
void CGShipyard::onHeroVisit( const CGHeroInstance * h ) const void CGShipyard::onHeroVisit( const CGHeroInstance * h ) const