2023-05-02 15:09:36 +02:00
|
|
|
/*
|
|
|
|
* AdventureMapShortcuts.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "StdInc.h"
|
|
|
|
#include "AdventureMapShortcuts.h"
|
|
|
|
|
2023-05-04 18:04:36 +02:00
|
|
|
#include "../CGameInfo.h"
|
|
|
|
#include "../CPlayerInterface.h"
|
|
|
|
#include "../PlayerLocalState.h"
|
|
|
|
#include "../gui/CGuiHandler.h"
|
|
|
|
#include "../gui/Shortcut.h"
|
|
|
|
#include "../lobby/CSavingScreen.h"
|
|
|
|
#include "../mapView/mapHandler.h"
|
2023-05-02 15:09:36 +02:00
|
|
|
#include "../windows/CKingdomInterface.h"
|
|
|
|
#include "../windows/CSpellWindow.h"
|
|
|
|
#include "../windows/CTradeWindow.h"
|
2023-05-04 18:04:36 +02:00
|
|
|
#include "../windows/settings/SettingsMainWindow.h"
|
2023-05-08 14:18:34 +02:00
|
|
|
#include "AdventureMapInterface.h"
|
|
|
|
#include "AdventureOptions.h"
|
2023-05-05 14:48:43 +02:00
|
|
|
#include "AdventureState.h"
|
2023-05-02 15:09:36 +02:00
|
|
|
|
|
|
|
#include "../../CCallback.h"
|
|
|
|
#include "../../lib/CConfigHandler.h"
|
|
|
|
#include "../../lib/CGeneralTextHandler.h"
|
2023-05-04 18:04:36 +02:00
|
|
|
#include "../../lib/CPathfinder.h"
|
2023-05-02 15:09:36 +02:00
|
|
|
#include "../../lib/mapObjects/CGHeroInstance.h"
|
|
|
|
#include "../../lib/mapObjects/CGTownInstance.h"
|
2023-05-04 18:04:36 +02:00
|
|
|
#include "../../lib/mapping/CMap.h"
|
2023-05-02 15:09:36 +02:00
|
|
|
|
2023-05-08 14:18:34 +02:00
|
|
|
AdventureMapShortcuts::AdventureMapShortcuts(AdventureMapInterface & owner)
|
2023-05-05 14:48:43 +02:00
|
|
|
: owner(owner)
|
|
|
|
, state(EAdventureState::NOT_INITIALIZED)
|
|
|
|
, mapLevel(0)
|
2023-05-02 15:09:36 +02:00
|
|
|
{}
|
|
|
|
|
2023-05-05 14:48:43 +02:00
|
|
|
void AdventureMapShortcuts::setState(EAdventureState newState)
|
|
|
|
{
|
|
|
|
state = newState;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::onMapViewMoved(const Rect & visibleArea, int newMapLevel)
|
|
|
|
{
|
|
|
|
if(mapLevel == newMapLevel)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mapLevel = newMapLevel;
|
|
|
|
}
|
|
|
|
|
2023-05-04 18:04:36 +02:00
|
|
|
std::vector<AdventureMapShortcutState> AdventureMapShortcuts::getShortcuts()
|
|
|
|
{
|
|
|
|
std::vector<AdventureMapShortcutState> result = {
|
2023-05-05 14:48:43 +02:00
|
|
|
{ EShortcut::ADVENTURE_KINGDOM_OVERVIEW, optionInMapView(), [this]() { this->showOverview(); } },
|
|
|
|
{ EShortcut::ADVENTURE_EXIT_WORLD_VIEW, optionInWorldView(), [this]() { this->worldViewBack(); } },
|
|
|
|
{ EShortcut::ADVENTURE_VIEW_WORLD, optionInMapView(), [this]() { this->worldViewScale1x(); } },
|
|
|
|
{ EShortcut::ADVENTURE_VIEW_WORLD_X1, optionInWorldView(), [this]() { this->worldViewScale1x(); } },
|
|
|
|
{ EShortcut::ADVENTURE_VIEW_WORLD_X2, optionInWorldView(), [this]() { this->worldViewScale2x(); } },
|
|
|
|
{ EShortcut::ADVENTURE_VIEW_WORLD_X4, optionInWorldView(), [this]() { this->worldViewScale4x(); } },
|
2023-05-07 00:34:11 +02:00
|
|
|
{ EShortcut::ADVENTURE_TOGGLE_MAP_LEVEL, optionCanToggleLevel(), [this]() { this->switchMapLevel(); } },
|
|
|
|
{ EShortcut::ADVENTURE_QUEST_LOG, optionCanViewQuests(), [this]() { this->showQuestlog(); } },
|
2023-05-04 18:04:36 +02:00
|
|
|
{ EShortcut::ADVENTURE_TOGGLE_SLEEP, optionHeroSelected(), [this]() { this->toggleSleepWake(); } },
|
2023-05-05 14:48:43 +02:00
|
|
|
{ EShortcut::ADVENTURE_SET_HERO_ASLEEP, optionHeroAwake(), [this]() { this->setHeroSleeping(); } },
|
2023-05-04 18:04:36 +02:00
|
|
|
{ EShortcut::ADVENTURE_SET_HERO_AWAKE, optionHeroSleeping(), [this]() { this->setHeroAwake(); } },
|
|
|
|
{ EShortcut::ADVENTURE_MOVE_HERO, optionHeroCanMove(), [this]() { this->moveHeroAlongPath(); } },
|
|
|
|
{ EShortcut::ADVENTURE_CAST_SPELL, optionHeroSelected(), [this]() { this->showSpellbook(); } },
|
2023-05-05 14:48:43 +02:00
|
|
|
{ EShortcut::ADVENTURE_GAME_OPTIONS, optionInMapView(), [this]() { this->adventureOptions(); } },
|
|
|
|
{ EShortcut::GLOBAL_OPTIONS, optionInMapView(), [this]() { this->systemOptions(); } },
|
2023-05-04 18:04:36 +02:00
|
|
|
{ EShortcut::ADVENTURE_NEXT_HERO, optionHasNextHero(), [this]() { this->nextHero(); } },
|
2023-05-05 14:48:43 +02:00
|
|
|
{ EShortcut::GAME_END_TURN, optionInMapView(), [this]() { this->endTurn(); } },
|
|
|
|
{ EShortcut::ADVENTURE_THIEVES_GUILD, optionInMapView(), [this]() { this->showThievesGuild(); } },
|
|
|
|
{ EShortcut::ADVENTURE_VIEW_SCENARIO, optionInMapView(), [this]() { this->showScenarioInfo(); } },
|
|
|
|
{ EShortcut::GAME_SAVE_GAME, optionInMapView(), [this]() { this->saveGame(); } },
|
|
|
|
{ EShortcut::GAME_LOAD_GAME, optionInMapView(), [this]() { this->loadGame(); } },
|
2023-05-04 18:04:36 +02:00
|
|
|
{ EShortcut::ADVENTURE_DIG_GRAIL, optionHeroSelected(), [this]() { this->digGrail(); } },
|
2023-05-07 00:34:11 +02:00
|
|
|
{ EShortcut::ADVENTURE_VIEW_PUZZLE, optionSidePanelActive(),[this]() { this->viewPuzzleMap(); } },
|
2023-05-05 14:48:43 +02:00
|
|
|
{ EShortcut::GAME_RESTART_GAME, optionInMapView(), [this]() { this->restartGame(); } },
|
2023-05-04 18:04:36 +02:00
|
|
|
{ EShortcut::ADVENTURE_VISIT_OBJECT, optionHeroSelected(), [this]() { this->visitObject(); } },
|
2023-05-05 14:48:43 +02:00
|
|
|
{ EShortcut::ADVENTURE_VIEW_SELECTED, optionInMapView(), [this]() { this->openObject(); } },
|
2023-05-04 18:04:36 +02:00
|
|
|
{ EShortcut::GLOBAL_CANCEL, optionSpellcasting(), [this]() { this->abortSpellcasting(); } },
|
2023-05-05 14:48:43 +02:00
|
|
|
{ EShortcut::GAME_OPEN_MARKETPLACE, optionInMapView(), [this]() { this->showMarketplace(); } },
|
|
|
|
{ EShortcut::ADVENTURE_NEXT_TOWN, optionInMapView(), [this]() { this->nextTown(); } },
|
|
|
|
{ EShortcut::ADVENTURE_NEXT_OBJECT, optionInMapView(), [this]() { this->nextObject(); } },
|
2023-05-04 18:04:36 +02:00
|
|
|
{ EShortcut::ADVENTURE_MOVE_HERO_SW, optionHeroSelected(), [this]() { this->moveHeroDirectional({-1, +1}); } },
|
|
|
|
{ EShortcut::ADVENTURE_MOVE_HERO_SS, optionHeroSelected(), [this]() { this->moveHeroDirectional({ 0, +1}); } },
|
|
|
|
{ EShortcut::ADVENTURE_MOVE_HERO_SE, optionHeroSelected(), [this]() { this->moveHeroDirectional({+1, +1}); } },
|
|
|
|
{ EShortcut::ADVENTURE_MOVE_HERO_WW, optionHeroSelected(), [this]() { this->moveHeroDirectional({-1, 0}); } },
|
|
|
|
{ EShortcut::ADVENTURE_MOVE_HERO_EE, optionHeroSelected(), [this]() { this->moveHeroDirectional({+1, 0}); } },
|
|
|
|
{ EShortcut::ADVENTURE_MOVE_HERO_NW, optionHeroSelected(), [this]() { this->moveHeroDirectional({-1, -1}); } },
|
|
|
|
{ EShortcut::ADVENTURE_MOVE_HERO_NN, optionHeroSelected(), [this]() { this->moveHeroDirectional({ 0, -1}); } },
|
|
|
|
{ EShortcut::ADVENTURE_MOVE_HERO_NE, optionHeroSelected(), [this]() { this->moveHeroDirectional({+1, -1}); } }
|
2023-05-02 15:09:36 +02:00
|
|
|
};
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::showOverview()
|
|
|
|
{
|
|
|
|
GH.pushIntT<CKingdomInterface>();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::worldViewBack()
|
|
|
|
{
|
|
|
|
owner.hotkeyExitWorldView();
|
|
|
|
|
|
|
|
auto hero = LOCPLINT->localState->getCurrentHero();
|
|
|
|
if (hero)
|
|
|
|
owner.centerOnObject(hero);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::worldViewScale1x()
|
|
|
|
{
|
|
|
|
// TODO set corresponding scale button to "selected" mode
|
|
|
|
owner.openWorldView(7);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::worldViewScale2x()
|
|
|
|
{
|
|
|
|
owner.openWorldView(11);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::worldViewScale4x()
|
|
|
|
{
|
|
|
|
owner.openWorldView(16);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::switchMapLevel()
|
|
|
|
{
|
|
|
|
// with support for future multi-level maps :)
|
|
|
|
int maxLevels = LOCPLINT->cb->getMapSize().z;
|
|
|
|
if (maxLevels < 2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
owner.hotkeySwitchMapLevel();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::showQuestlog()
|
|
|
|
{
|
|
|
|
LOCPLINT->showQuestLog();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::toggleSleepWake()
|
|
|
|
{
|
|
|
|
const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero();
|
|
|
|
if (!h)
|
|
|
|
return;
|
|
|
|
bool newSleep = !LOCPLINT->localState->isHeroSleeping(h);
|
|
|
|
|
|
|
|
if (newSleep)
|
|
|
|
LOCPLINT->localState->setHeroAsleep(h);
|
|
|
|
else
|
|
|
|
LOCPLINT->localState->setHeroAwaken(h);
|
|
|
|
|
|
|
|
owner.onHeroChanged(h);
|
|
|
|
|
|
|
|
if (newSleep)
|
|
|
|
nextHero();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::setHeroSleeping()
|
|
|
|
{
|
|
|
|
const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero();
|
|
|
|
if (h)
|
|
|
|
{
|
|
|
|
LOCPLINT->localState->setHeroAsleep(h);
|
|
|
|
owner.onHeroChanged(h);
|
|
|
|
nextHero();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::setHeroAwake()
|
|
|
|
{
|
|
|
|
const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero();
|
|
|
|
if (h)
|
|
|
|
{
|
2023-05-05 14:48:43 +02:00
|
|
|
LOCPLINT->localState->setHeroAwaken(h);
|
2023-05-02 15:09:36 +02:00
|
|
|
owner.onHeroChanged(h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::moveHeroAlongPath()
|
|
|
|
{
|
|
|
|
const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero();
|
|
|
|
if (!h || !LOCPLINT->localState->hasPath(h))
|
|
|
|
return;
|
|
|
|
|
|
|
|
LOCPLINT->moveHero(h, LOCPLINT->localState->getPath(h));
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::showSpellbook()
|
|
|
|
{
|
|
|
|
if (!LOCPLINT->localState->getCurrentHero()) //checking necessary values
|
|
|
|
return;
|
|
|
|
|
|
|
|
owner.centerOnObject(LOCPLINT->localState->getCurrentHero());
|
|
|
|
|
|
|
|
GH.pushIntT<CSpellWindow>(LOCPLINT->localState->getCurrentHero(), LOCPLINT, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::adventureOptions()
|
|
|
|
{
|
2023-05-08 14:18:34 +02:00
|
|
|
GH.pushIntT<AdventureOptions>();
|
2023-05-02 15:09:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::systemOptions()
|
|
|
|
{
|
|
|
|
GH.pushIntT<SettingsMainWindow>();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::nextHero()
|
|
|
|
{
|
|
|
|
const auto * currHero = LOCPLINT->localState->getCurrentHero();
|
|
|
|
const auto * nextHero = LOCPLINT->localState->getNextWanderingHero(currHero);
|
|
|
|
|
|
|
|
if (nextHero)
|
|
|
|
{
|
|
|
|
LOCPLINT->localState->setSelection(nextHero);
|
|
|
|
owner.centerOnObject(nextHero);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::endTurn()
|
|
|
|
{
|
|
|
|
if(!LOCPLINT->makingTurn)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if(settings["adventure"]["heroReminder"].Bool())
|
|
|
|
{
|
|
|
|
for(auto hero : LOCPLINT->localState->getWanderingHeroes())
|
|
|
|
{
|
|
|
|
if(!LOCPLINT->localState->isHeroSleeping(hero) && hero->movement > 0)
|
|
|
|
{
|
|
|
|
// Only show hero reminder if conditions met:
|
|
|
|
// - There still movement points
|
|
|
|
// - Hero don't have a path or there not points for first step on path
|
|
|
|
LOCPLINT->localState->verifyPath(hero);
|
|
|
|
|
|
|
|
if(!LOCPLINT->localState->hasPath(hero))
|
|
|
|
{
|
|
|
|
LOCPLINT->showYesNoDialog( CGI->generaltexth->allTexts[55], [this](){ owner.hotkeyEndingTurn(); }, nullptr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto path = LOCPLINT->localState->getPath(hero);
|
|
|
|
if (path.nodes.size() < 2 || path.nodes[path.nodes.size() - 2].turns)
|
|
|
|
{
|
|
|
|
LOCPLINT->showYesNoDialog( CGI->generaltexth->allTexts[55], [this](){ owner.hotkeyEndingTurn(); }, nullptr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
owner.hotkeyEndingTurn();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::showThievesGuild()
|
|
|
|
{
|
|
|
|
//find first town with tavern
|
|
|
|
auto itr = range::find_if(LOCPLINT->localState->getOwnedTowns(), [](const CGTownInstance * town)
|
|
|
|
{
|
|
|
|
return town->hasBuilt(BuildingID::TAVERN);
|
|
|
|
});
|
|
|
|
|
|
|
|
if(itr != LOCPLINT->localState->getOwnedTowns().end())
|
|
|
|
LOCPLINT->showThievesGuildWindow(*itr);
|
|
|
|
else
|
|
|
|
LOCPLINT->showInfoDialog(CGI->generaltexth->translate("vcmi.adventureMap.noTownWithTavern"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::showScenarioInfo()
|
|
|
|
{
|
2023-05-08 14:18:34 +02:00
|
|
|
AdventureOptions::showScenarioInfo();
|
2023-05-02 15:09:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::saveGame()
|
|
|
|
{
|
|
|
|
GH.pushIntT<CSavingScreen>();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::loadGame()
|
|
|
|
{
|
|
|
|
LOCPLINT->proposeLoadingGame();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::digGrail()
|
|
|
|
{
|
|
|
|
const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero();
|
|
|
|
|
|
|
|
if(h && LOCPLINT->makingTurn)
|
|
|
|
LOCPLINT->tryDiggging(h);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::viewPuzzleMap()
|
|
|
|
{
|
|
|
|
LOCPLINT->showPuzzleMap();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::restartGame()
|
|
|
|
{
|
|
|
|
LOCPLINT->showYesNoDialog(CGI->generaltexth->translate("vcmi.adventureMap.confirmRestartGame"),
|
|
|
|
[](){ GH.pushUserEvent(EUserEvent::RESTART_GAME); }, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::visitObject()
|
|
|
|
{
|
|
|
|
const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero();
|
|
|
|
|
|
|
|
if(h)
|
|
|
|
LOCPLINT->cb->moveHero(h,h->pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::openObject()
|
|
|
|
{
|
|
|
|
const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero();
|
|
|
|
const CGTownInstance *t = LOCPLINT->localState->getCurrentTown();
|
|
|
|
if(h)
|
|
|
|
LOCPLINT->openHeroWindow(h);
|
|
|
|
|
|
|
|
if(t)
|
|
|
|
LOCPLINT->openTownWindow(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::abortSpellcasting()
|
|
|
|
{
|
|
|
|
owner.hotkeyAbortCastingMode();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::showMarketplace()
|
|
|
|
{
|
|
|
|
//check if we have any marketplace
|
|
|
|
const CGTownInstance *townWithMarket = nullptr;
|
|
|
|
for(const CGTownInstance *t : LOCPLINT->cb->getTownsInfo())
|
|
|
|
{
|
|
|
|
if(t->hasBuilt(BuildingID::MARKETPLACE))
|
|
|
|
{
|
|
|
|
townWithMarket = t;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(townWithMarket) //if any town has marketplace, open window
|
|
|
|
GH.pushIntT<CMarketplaceWindow>(townWithMarket);
|
|
|
|
else //if not - complain
|
|
|
|
LOCPLINT->showInfoDialog(CGI->generaltexth->translate("vcmi.adventureMap.noTownWithMarket"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::nextTown()
|
|
|
|
{
|
2023-05-05 14:48:43 +02:00
|
|
|
owner.hotkeyNextTown();
|
2023-05-04 18:04:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::nextObject()
|
|
|
|
{
|
2023-05-05 14:48:43 +02:00
|
|
|
const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero();
|
|
|
|
const CGTownInstance *t = LOCPLINT->localState->getCurrentTown();
|
|
|
|
if(h)
|
|
|
|
nextHero();
|
|
|
|
|
|
|
|
if(t)
|
|
|
|
nextTown();
|
2023-05-02 15:09:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void AdventureMapShortcuts::moveHeroDirectional(const Point & direction)
|
|
|
|
{
|
2023-05-05 14:48:43 +02:00
|
|
|
const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero(); //selected hero
|
|
|
|
|
|
|
|
if(!h)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (CGI->mh->hasOngoingAnimations())
|
|
|
|
return;
|
|
|
|
|
|
|
|
int3 dst = h->visitablePos() + int3(direction.x, direction.y, 0);
|
|
|
|
|
|
|
|
if (!CGI->mh->isInMap((dst)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( !LOCPLINT->localState->setPath(h, dst))
|
|
|
|
return;
|
|
|
|
|
|
|
|
const CGPath & path = LOCPLINT->localState->getPath(h);
|
|
|
|
|
|
|
|
if (path.nodes.size() > 2)
|
|
|
|
owner.onHeroChanged(h);
|
|
|
|
else
|
|
|
|
if(path.nodes[0].turns == 0)
|
|
|
|
LOCPLINT->moveHero(h, path);
|
2023-05-02 15:09:36 +02:00
|
|
|
}
|
2023-05-04 18:04:36 +02:00
|
|
|
|
2023-05-07 00:34:11 +02:00
|
|
|
bool AdventureMapShortcuts::optionCanViewQuests()
|
2023-05-04 18:04:36 +02:00
|
|
|
{
|
2023-05-07 00:34:11 +02:00
|
|
|
return optionInMapView() && CGI->mh->getMap()->quests.empty();
|
2023-05-04 18:04:36 +02:00
|
|
|
}
|
|
|
|
|
2023-05-07 00:34:11 +02:00
|
|
|
bool AdventureMapShortcuts::optionCanToggleLevel()
|
2023-05-04 18:04:36 +02:00
|
|
|
{
|
2023-05-07 00:34:11 +02:00
|
|
|
return optionInMapView() && LOCPLINT->cb->getMapSize().z > 0;
|
2023-05-04 18:04:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AdventureMapShortcuts::optionMapLevelSurface()
|
|
|
|
{
|
2023-05-05 14:48:43 +02:00
|
|
|
return mapLevel == 0;
|
2023-05-04 18:04:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AdventureMapShortcuts::optionHeroSleeping()
|
|
|
|
{
|
|
|
|
const CGHeroInstance *hero = LOCPLINT->localState->getCurrentHero();
|
2023-05-07 00:34:11 +02:00
|
|
|
return optionInMapView() && hero && LOCPLINT->localState->isHeroSleeping(hero);
|
2023-05-04 18:04:36 +02:00
|
|
|
}
|
|
|
|
|
2023-05-05 14:48:43 +02:00
|
|
|
bool AdventureMapShortcuts::optionHeroAwake()
|
|
|
|
{
|
|
|
|
const CGHeroInstance *hero = LOCPLINT->localState->getCurrentHero();
|
2023-05-07 00:34:11 +02:00
|
|
|
return optionInMapView() && hero && !LOCPLINT->localState->isHeroSleeping(hero);
|
2023-05-05 14:48:43 +02:00
|
|
|
}
|
|
|
|
|
2023-05-04 18:04:36 +02:00
|
|
|
bool AdventureMapShortcuts::optionHeroSelected()
|
|
|
|
{
|
2023-05-07 00:34:11 +02:00
|
|
|
return optionInMapView() && LOCPLINT->localState->getCurrentHero() != nullptr;
|
2023-05-04 18:04:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AdventureMapShortcuts::optionHeroCanMove()
|
|
|
|
{
|
|
|
|
const auto * hero = LOCPLINT->localState->getCurrentHero();
|
2023-05-07 00:34:11 +02:00
|
|
|
return optionInMapView() && hero && hero->movement != 0 && LOCPLINT->localState->hasPath(hero);
|
2023-05-04 18:04:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AdventureMapShortcuts::optionHasNextHero()
|
|
|
|
{
|
|
|
|
const auto * hero = LOCPLINT->localState->getCurrentHero();
|
|
|
|
const auto * nextSuitableHero = LOCPLINT->localState->getNextWanderingHero(hero);
|
|
|
|
|
2023-05-07 00:34:11 +02:00
|
|
|
return optionInMapView() && nextSuitableHero != nullptr;
|
2023-05-04 18:04:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AdventureMapShortcuts::optionSpellcasting()
|
|
|
|
{
|
2023-05-05 14:48:43 +02:00
|
|
|
return state == EAdventureState::CASTING_SPELL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AdventureMapShortcuts::optionInMapView()
|
|
|
|
{
|
|
|
|
return state == EAdventureState::MAKING_TURN;
|
2023-05-04 18:04:36 +02:00
|
|
|
}
|
|
|
|
|
2023-05-05 14:48:43 +02:00
|
|
|
bool AdventureMapShortcuts::optionInWorldView()
|
2023-05-04 18:04:36 +02:00
|
|
|
{
|
2023-05-05 14:48:43 +02:00
|
|
|
return state == EAdventureState::WORLD_VIEW;
|
2023-05-04 18:04:36 +02:00
|
|
|
}
|
2023-05-07 00:34:11 +02:00
|
|
|
|
|
|
|
bool AdventureMapShortcuts::optionSidePanelActive()
|
|
|
|
{
|
|
|
|
return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AdventureMapShortcuts::optionMapViewActive()
|
|
|
|
{
|
|
|
|
return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW || state == EAdventureState::CASTING_SPELL;
|
|
|
|
}
|