mirror of
https://github.com/vcmi/vcmi.git
synced 2025-05-15 22:16:37 +02:00
Merge pull request #2876 from IvanSavenko/revisit_object_button_block
Block revisit object shortcut if no visit is possible
This commit is contained in:
commit
a9abd294da
@ -79,7 +79,7 @@ std::vector<AdventureMapShortcutState> AdventureMapShortcuts::getShortcuts()
|
|||||||
{ EShortcut::ADVENTURE_DIG_GRAIL, optionHeroSelected(), [this]() { this->digGrail(); } },
|
{ EShortcut::ADVENTURE_DIG_GRAIL, optionHeroSelected(), [this]() { this->digGrail(); } },
|
||||||
{ EShortcut::ADVENTURE_VIEW_PUZZLE, optionSidePanelActive(),[this]() { this->viewPuzzleMap(); } },
|
{ EShortcut::ADVENTURE_VIEW_PUZZLE, optionSidePanelActive(),[this]() { this->viewPuzzleMap(); } },
|
||||||
{ EShortcut::GAME_RESTART_GAME, optionInMapView(), [this]() { this->restartGame(); } },
|
{ EShortcut::GAME_RESTART_GAME, optionInMapView(), [this]() { this->restartGame(); } },
|
||||||
{ EShortcut::ADVENTURE_VISIT_OBJECT, optionHeroSelected(), [this]() { this->visitObject(); } },
|
{ EShortcut::ADVENTURE_VISIT_OBJECT, optionCanVisitObject(), [this]() { this->visitObject(); } },
|
||||||
{ EShortcut::ADVENTURE_VIEW_SELECTED, optionInMapView(), [this]() { this->openObject(); } },
|
{ EShortcut::ADVENTURE_VIEW_SELECTED, optionInMapView(), [this]() { this->openObject(); } },
|
||||||
{ EShortcut::GAME_OPEN_MARKETPLACE, optionInMapView(), [this]() { this->showMarketplace(); } },
|
{ EShortcut::GAME_OPEN_MARKETPLACE, optionInMapView(), [this]() { this->showMarketplace(); } },
|
||||||
{ EShortcut::ADVENTURE_ZOOM_IN, optionSidePanelActive(),[this]() { this->zoom(+1); } },
|
{ EShortcut::ADVENTURE_ZOOM_IN, optionSidePanelActive(),[this]() { this->zoom(+1); } },
|
||||||
@ -422,6 +422,18 @@ bool AdventureMapShortcuts::optionHeroAwake()
|
|||||||
return optionInMapView() && hero && !LOCPLINT->localState->isHeroSleeping(hero);
|
return optionInMapView() && hero && !LOCPLINT->localState->isHeroSleeping(hero);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AdventureMapShortcuts::optionCanVisitObject()
|
||||||
|
{
|
||||||
|
if (!optionHeroSelected())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
auto * hero = LOCPLINT->localState->getCurrentHero();
|
||||||
|
auto objects = LOCPLINT->cb->getVisitableObjs(hero->visitablePos());
|
||||||
|
|
||||||
|
assert(vstd::contains(objects,hero));
|
||||||
|
return objects.size() > 1; // there is object other than our hero
|
||||||
|
}
|
||||||
|
|
||||||
bool AdventureMapShortcuts::optionHeroSelected()
|
bool AdventureMapShortcuts::optionHeroSelected()
|
||||||
{
|
{
|
||||||
return optionInMapView() && LOCPLINT->localState->getCurrentHero() != nullptr;
|
return optionInMapView() && LOCPLINT->localState->getCurrentHero() != nullptr;
|
||||||
|
@ -77,6 +77,7 @@ public:
|
|||||||
bool optionHeroSelected();
|
bool optionHeroSelected();
|
||||||
bool optionHeroCanMove();
|
bool optionHeroCanMove();
|
||||||
bool optionHasNextHero();
|
bool optionHasNextHero();
|
||||||
|
bool optionCanVisitObject();
|
||||||
bool optionSpellcasting();
|
bool optionSpellcasting();
|
||||||
bool optionInMapView();
|
bool optionInMapView();
|
||||||
bool optionInWorldView();
|
bool optionInWorldView();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user