diff --git a/Mods/vcmi/config/vcmi/english.json b/Mods/vcmi/config/vcmi/english.json index 18e6641f1..b62ee25d2 100644 --- a/Mods/vcmi/config/vcmi/english.json +++ b/Mods/vcmi/config/vcmi/english.json @@ -21,6 +21,7 @@ "vcmi.adventureMap.playerAttacked" : "Player has been attacked: %s", "vcmi.adventureMap.moveCostDetails" : "Movement points - Cost: %TURNS turns + %POINTS points, Remaining points: %REMAINING", "vcmi.adventureMap.moveCostDetailsNoTurns" : "Movement points - Cost: %POINTS points, Remaining points: %REMAINING", + "vcmi.adventureMap.movementPointsHeroInfo" : "(Movement points: %REMAINING / %POINTS)", "vcmi.adventureMap.replayOpponentTurnNotImplemented" : "Sorry, replay opponent turn is not implemented yet!", "vcmi.capitalColors.0" : "Red", diff --git a/Mods/vcmi/config/vcmi/polish.json b/Mods/vcmi/config/vcmi/polish.json index 1ab65c8e3..2f8d0ce87 100644 --- a/Mods/vcmi/config/vcmi/polish.json +++ b/Mods/vcmi/config/vcmi/polish.json @@ -20,6 +20,7 @@ "vcmi.adventureMap.playerAttacked" : "Gracz został zaatakowany: %s", "vcmi.adventureMap.moveCostDetails" : "Punkty ruchu - Koszt: %TURNS tury + %POINTS punktów, Pozostanie: %REMAINING punktów", "vcmi.adventureMap.moveCostDetailsNoTurns" : "Punkty ruchu - Koszt: %POINTS punktów, Pozostanie: %REMAINING punktów", + "vcmi.adventureMap.movementPointsHeroInfo" : "(Punkty ruchu: %REMAINING / %POINTS)", "vcmi.adventureMap.replayOpponentTurnNotImplemented" : "Wybacz, powtórka ruchu wroga nie została jeszcze zaimplementowana!", "vcmi.capitalColors.0" : "Czerwony", diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 162aada4c..1100b26c8 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -171,10 +171,11 @@ void CPlayerInterface::initGameInterface(std::shared_ptr ENV, std:: void CPlayerInterface::closeAllDialogs() { // remove all active dialogs that do not expect query answer - for (;;) + while(true) { auto adventureWindow = GH.windows().topWindow(); auto infoWindow = GH.windows().topWindow(); + auto topWindow = GH.windows().topWindow(); if(adventureWindow != nullptr) break; @@ -182,16 +183,8 @@ void CPlayerInterface::closeAllDialogs() if(infoWindow && infoWindow->ID != QueryID::NONE) break; - if (infoWindow) - infoWindow->close(); - else - GH.windows().popWindows(1); + topWindow->close(); } - - if(castleInt) - castleInt->close(); - - castleInt = nullptr; } void CPlayerInterface::playerEndsTurn(PlayerColor player) @@ -1460,6 +1453,7 @@ void CPlayerInterface::playerBlocked(int reason, bool start) cmp.push_back(std::make_shared(ComponentType::FLAG, playerID)); makingTurn = true; //workaround for stiff showInfoDialog implementation showInfoDialog(msg, cmp); + waitWhileDialog(); makingTurn = false; } } diff --git a/client/adventureMap/AdventureMapInterface.cpp b/client/adventureMap/AdventureMapInterface.cpp index b8c71884e..020f4a323 100644 --- a/client/adventureMap/AdventureMapInterface.cpp +++ b/client/adventureMap/AdventureMapInterface.cpp @@ -557,7 +557,8 @@ void AdventureMapInterface::onTileLeftClicked(const int3 &targetPosition) else //still here? we need to move hero if we clicked end of already selected path or calculate a new path otherwise { if(LOCPLINT->localState->hasPath(currentHero) && - LOCPLINT->localState->getPath(currentHero).endPos() == targetPosition)//we'll be moving + LOCPLINT->localState->getPath(currentHero).endPos() == targetPosition && + !GH.isKeyboardShiftDown())//we'll be moving { assert(!CGI->mh->hasOngoingAnimations()); if(!CGI->mh->hasOngoingAnimations() && LOCPLINT->localState->getPath(currentHero).nextNode().turns == 0) diff --git a/client/adventureMap/CList.cpp b/client/adventureMap/CList.cpp index a563f34f4..5c46a510a 100644 --- a/client/adventureMap/CList.cpp +++ b/client/adventureMap/CList.cpp @@ -266,7 +266,7 @@ void CHeroList::CHeroItem::showTooltip() std::string CHeroList::CHeroItem::getHoverText() { - return boost::str(boost::format(CGI->generaltexth->allTexts[15]) % hero->getNameTranslated() % hero->getClassNameTranslated()); + return boost::str(boost::format(CGI->generaltexth->allTexts[15]) % hero->getNameTranslated() % hero->getClassNameTranslated()) + hero->getMovementPointsTextIfOwner(hero->getOwner()); } void CHeroList::CHeroItem::gesture(bool on, const Point & initialPosition, const Point & finalPosition) diff --git a/client/gui/CIntObject.cpp b/client/gui/CIntObject.cpp index 7dc4dff85..3535985f1 100644 --- a/client/gui/CIntObject.cpp +++ b/client/gui/CIntObject.cpp @@ -343,6 +343,6 @@ WindowBase::WindowBase(int used_, Point pos_) void WindowBase::close() { if(!GH.windows().isTopWindow(this)) - logGlobal->error("Only top interface must be closed"); + throw std::runtime_error("Only top interface can be closed"); GH.windows().popWindows(1); } diff --git a/client/gui/CIntObject.h b/client/gui/CIntObject.h index da3ebcdc8..700b7d990 100644 --- a/client/gui/CIntObject.h +++ b/client/gui/CIntObject.h @@ -148,7 +148,6 @@ class WindowBase : public CIntObject { public: WindowBase(int used_ = 0, Point pos_ = Point()); -protected: virtual void close(); }; diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index 35782bfdb..8cf3871b0 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -567,6 +567,25 @@ std::string CGHeroInstance::getObjectName() const return VLC->objtypeh->getObjectName(ID, 0); } +std::string CGHeroInstance::getHoverText(PlayerColor player) const +{ + std::string hoverText = CArmedInstance::getHoverText(player) + getMovementPointsTextIfOwner(player); + return hoverText; +} + +std::string CGHeroInstance::getMovementPointsTextIfOwner(PlayerColor player) const +{ + std::string output = ""; + if(player == getOwner()) + { + output += " " + VLC->generaltexth->translate("vcmi.adventureMap.movementPointsHeroInfo"); + boost::replace_first(output, "%POINTS", std::to_string(movementPointsLimit(!boat))); + boost::replace_first(output, "%REMAINING", std::to_string(movementPointsRemaining())); + } + + return output; +} + ui8 CGHeroInstance::maxlevelsToMagicSchool() const { return type->heroClass->isMagicHero() ? 3 : 4; diff --git a/lib/mapObjects/CGHeroInstance.h b/lib/mapObjects/CGHeroInstance.h index 2ad2811a9..a4dffa8af 100644 --- a/lib/mapObjects/CGHeroInstance.h +++ b/lib/mapObjects/CGHeroInstance.h @@ -301,6 +301,8 @@ public: void pickRandomObject(vstd::RNG & rand) override; void onHeroVisit(const CGHeroInstance * h) const override; std::string getObjectName() const override; + std::string getHoverText(PlayerColor player) const override; + std::string getMovementPointsTextIfOwner(PlayerColor player) const; void afterAddToMap(CMap * map) override; void afterRemoveFromMap(CMap * map) override;