diff --git a/client/adventureMap/AdventureMapInterface.cpp b/client/adventureMap/AdventureMapInterface.cpp index 4d7f2dc31..c874630a8 100644 --- a/client/adventureMap/AdventureMapInterface.cpp +++ b/client/adventureMap/AdventureMapInterface.cpp @@ -26,6 +26,7 @@ #include "../CGameInfo.h" #include "../gui/CursorHandler.h" #include "../gui/CGuiHandler.h" +#include "../gui/Shortcut.h" #include "../CMT.h" #include "../PlayerLocalState.h" #include "../CPlayerInterface.h" @@ -57,6 +58,8 @@ AdventureMapInterface::AdventureMapInterface(): widget = std::make_shared(shortcuts); shortcuts->setState(EAdventureState::MAKING_TURN); widget->getMapView()->onViewMapActivated(); + + addUsedEvents(KEYBOARD); } void AdventureMapInterface::onMapViewMoved(const Rect & visibleArea, int mapLevel) @@ -234,6 +237,9 @@ void AdventureMapInterface::centerOnObject(const CGObjectInstance * obj) void AdventureMapInterface::keyPressed(EShortcut key) { + if (key == EShortcut::GLOBAL_CANCEL && spellBeingCasted) + hotkeyAbortCastingMode(); + //fake mouse use to trigger onTileHovered() GH.fakeMouseMove(); } diff --git a/client/adventureMap/AdventureMapShortcuts.cpp b/client/adventureMap/AdventureMapShortcuts.cpp index 79fcba2e9..93d5d24e1 100644 --- a/client/adventureMap/AdventureMapShortcuts.cpp +++ b/client/adventureMap/AdventureMapShortcuts.cpp @@ -47,9 +47,6 @@ void AdventureMapShortcuts::setState(EAdventureState newState) void AdventureMapShortcuts::onMapViewMoved(const Rect & visibleArea, int newMapLevel) { - if(mapLevel == newMapLevel) - return; - mapLevel = newMapLevel; } @@ -82,7 +79,6 @@ std::vector AdventureMapShortcuts::getShortcuts() { EShortcut::GAME_RESTART_GAME, optionInMapView(), [this]() { this->restartGame(); } }, { EShortcut::ADVENTURE_VISIT_OBJECT, optionHeroSelected(), [this]() { this->visitObject(); } }, { EShortcut::ADVENTURE_VIEW_SELECTED, optionInMapView(), [this]() { this->openObject(); } }, - { EShortcut::GLOBAL_CANCEL, optionSpellcasting(), [this]() { this->abortSpellcasting(); } }, { EShortcut::GAME_OPEN_MARKETPLACE, optionInMapView(), [this]() { this->showMarketplace(); } }, { EShortcut::ADVENTURE_NEXT_TOWN, optionInMapView(), [this]() { this->nextTown(); } }, { EShortcut::ADVENTURE_NEXT_OBJECT, optionInMapView(), [this]() { this->nextObject(); } }, @@ -130,7 +126,6 @@ void AdventureMapShortcuts::worldViewScale4x() void AdventureMapShortcuts::switchMapLevel() { - // with support for future multi-level maps :) int maxLevels = LOCPLINT->cb->getMapSize().z; if (maxLevels < 2) return; @@ -145,20 +140,13 @@ void AdventureMapShortcuts::showQuestlog() void AdventureMapShortcuts::toggleSleepWake() { - const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero(); - if (!h) + if (!optionHeroSelected()) return; - bool newSleep = !LOCPLINT->localState->isHeroSleeping(h); - if (newSleep) - LOCPLINT->localState->setHeroAsleep(h); + if (optionHeroAwake()) + setHeroSleeping(); else - LOCPLINT->localState->setHeroAwaken(h); - - owner.onHeroChanged(h); - - if (newSleep) - nextHero(); + setHeroAwake(); } void AdventureMapShortcuts::setHeroSleeping() @@ -193,7 +181,7 @@ void AdventureMapShortcuts::moveHeroAlongPath() void AdventureMapShortcuts::showSpellbook() { - if (!LOCPLINT->localState->getCurrentHero()) //checking necessary values + if (!LOCPLINT->localState->getCurrentHero()) return; owner.centerOnObject(LOCPLINT->localState->getCurrentHero()); @@ -324,11 +312,6 @@ void AdventureMapShortcuts::openObject() LOCPLINT->openTownWindow(t); } -void AdventureMapShortcuts::abortSpellcasting() -{ - owner.hotkeyAbortCastingMode(); -} - void AdventureMapShortcuts::showMarketplace() { //check if we have any marketplace diff --git a/client/adventureMap/AdventureMapShortcuts.h b/client/adventureMap/AdventureMapShortcuts.h index e54636a1a..ad7b8751c 100644 --- a/client/adventureMap/AdventureMapShortcuts.h +++ b/client/adventureMap/AdventureMapShortcuts.h @@ -58,7 +58,6 @@ class AdventureMapShortcuts void restartGame(); void visitObject(); void openObject(); - void abortSpellcasting(); void showMarketplace(); void nextTown(); void nextObject(); diff --git a/client/adventureMap/AdventureMapWidget.cpp b/client/adventureMap/AdventureMapWidget.cpp index 163c841b2..36d46e37d 100644 --- a/client/adventureMap/AdventureMapWidget.cpp +++ b/client/adventureMap/AdventureMapWidget.cpp @@ -133,7 +133,6 @@ std::shared_ptr AdventureMapWidget::loadImage(const std::string & name) if(images.count(resource.getName()) == 0) images[resource.getName()] = IImage::createFromFile(resource.getName()); - ; return images[resource.getName()]; } @@ -212,6 +211,7 @@ std::shared_ptr AdventureMapWidget::buildMapContainer(const JsonNode addWidget(entry["name"].String(), widget); result->ownedChildren.push_back(widget); + // FIXME: remove cast and replace it with better check if (std::dynamic_pointer_cast(widget) || std::dynamic_pointer_cast(widget)) result->addChild(widget.get(), true); else diff --git a/client/renderSDL/ScreenHandler.cpp b/client/renderSDL/ScreenHandler.cpp index 1ee0ed5d8..4acb9089e 100644 --- a/client/renderSDL/ScreenHandler.cpp +++ b/client/renderSDL/ScreenHandler.cpp @@ -168,7 +168,7 @@ void ScreenHandler::recreateWindowAndScreenBuffers() void ScreenHandler::updateWindowState() { -#if !defined(VCMI_MOBILE) +#ifdef VCMI_MOBILE int displayIndex = getPreferredDisplayIndex(); switch(getPreferredWindowMode()) @@ -332,7 +332,7 @@ void ScreenHandler::onScreenResize() void ScreenHandler::validateSettings() { -#if !defined(VCMI_MOBILE) +#ifdef VCMI_MOBILE { int displayIndex = settings["video"]["displayIndex"].Integer(); int displaysCount = SDL_GetNumVideoDisplays();