From d58d963874e4a10112d62dbb512f10a504c3c7ca Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Tue, 9 Sep 2025 01:00:38 +0200 Subject: [PATCH 1/3] shortcut market + boat --- client/adventureMap/AdventureMapShortcuts.cpp | 27 +++++++++++++++++-- client/adventureMap/AdventureMapShortcuts.h | 5 ++++ client/adventureMap/AdventureMapWidget.cpp | 15 ++++++++--- client/adventureMap/AdventureMapWidget.h | 2 +- 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/client/adventureMap/AdventureMapShortcuts.cpp b/client/adventureMap/AdventureMapShortcuts.cpp index f1b8b11f5..e9b48e079 100644 --- a/client/adventureMap/AdventureMapShortcuts.cpp +++ b/client/adventureMap/AdventureMapShortcuts.cpp @@ -36,6 +36,7 @@ #include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/mapObjects/CGTownInstance.h" +#include "../../lib/mapObjects/MiscObjects.h" #include "../../lib/mapping/CMap.h" #include "../../lib/pathfinder/CGPathNode.h" #include "../../lib/mapObjectConstructors/CObjectClassesHandler.h" @@ -100,7 +101,7 @@ std::vector AdventureMapShortcuts::getShortcuts() { EShortcut::ADVENTURE_VIEW_PUZZLE, optionSidePanelActive(),[this]() { this->viewPuzzleMap(); } }, { EShortcut::ADVENTURE_VISIT_OBJECT, optionCanVisitObject(), [this]() { this->visitObject(); } }, { EShortcut::ADVENTURE_VIEW_SELECTED, optionInMapView(), [this]() { this->openObject(); } }, - { EShortcut::ADVENTURE_MARKETPLACE, optionInMapView(), [this]() { this->showMarketplace(); } }, + { EShortcut::ADVENTURE_MARKETPLACE, optionMarketplace(), [this]() { this->showMarketplace(); } }, { EShortcut::ADVENTURE_ZOOM_IN, optionSidePanelActive(),[this]() { this->zoom(+10); } }, { EShortcut::ADVENTURE_ZOOM_OUT, optionSidePanelActive(),[this]() { this->zoom(-10); } }, { EShortcut::ADVENTURE_ZOOM_RESET, optionSidePanelActive(),[this]() { this->zoom( 0); } }, @@ -641,7 +642,7 @@ bool AdventureMapShortcuts::optionInWorldView() bool AdventureMapShortcuts::optionSidePanelActive() { -return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW; + return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW; } bool AdventureMapShortcuts::optionMapScrollingActive() @@ -653,3 +654,25 @@ bool AdventureMapShortcuts::optionMapViewActive() { return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW || state == EAdventureState::CASTING_SPELL; } + +bool AdventureMapShortcuts::optionMarketplace() +{ + if(state != EAdventureState::MAKING_TURN) + return false; + for(const CGTownInstance *t : GAME->interface()->cb->getTownsInfo()) + if(t->hasBuilt(BuildingID::MARKETPLACE)) + return true; + return false; +} + +bool AdventureMapShortcuts::optionHeroGround() +{ + const CGHeroInstance *hero = GAME->interface()->localState->getCurrentHero(); + return optionInMapView() && hero && !hero->inBoat(); +} + +bool AdventureMapShortcuts::optionHeroBoat(EPathfindingLayer layer) +{ + const CGHeroInstance *hero = GAME->interface()->localState->getCurrentHero(); + return optionInMapView() && hero && hero->inBoat() && hero->getBoat()->layer == layer; +} diff --git a/client/adventureMap/AdventureMapShortcuts.h b/client/adventureMap/AdventureMapShortcuts.h index 4268fbfd2..2d945e476 100644 --- a/client/adventureMap/AdventureMapShortcuts.h +++ b/client/adventureMap/AdventureMapShortcuts.h @@ -10,6 +10,8 @@ #pragma once +#include "../lib/constants/EntityIdentifiers.h" + VCMI_LIB_NAMESPACE_BEGIN class Point; class Rect; @@ -98,6 +100,9 @@ public: bool optionSidePanelActive(); bool optionMapScrollingActive(); bool optionMapViewActive(); + bool optionMarketplace(); + bool optionHeroGround(); + bool optionHeroBoat(EPathfindingLayer layer); void setState(EAdventureState newState); EAdventureState getState() const; diff --git a/client/adventureMap/AdventureMapWidget.cpp b/client/adventureMap/AdventureMapWidget.cpp index 65c0828a0..bf25624d5 100644 --- a/client/adventureMap/AdventureMapWidget.cpp +++ b/client/adventureMap/AdventureMapWidget.cpp @@ -398,7 +398,7 @@ void CAdventureMapOverlayWidget::show(Canvas & to) CIntObject::showAll(to); } -void AdventureMapWidget::updateActiveStateChildden(CIntObject * widget) +void AdventureMapWidget::updateActiveStateChildren(CIntObject * widget) { for(auto & entry : widget->children) { @@ -414,6 +414,15 @@ void AdventureMapWidget::updateActiveStateChildden(CIntObject * widget) if (container->disableCondition == "heroSleeping") container->setEnabled(shortcuts->optionHeroSleeping()); + if (container->disableCondition == "heroGround") + container->setEnabled(shortcuts->optionHeroGround()); + + if (container->disableCondition == "heroBoat") + container->setEnabled(shortcuts->optionHeroBoat(EPathfindingLayer::SAIL)); + + if (container->disableCondition == "heroAirship") + container->setEnabled(shortcuts->optionHeroBoat(EPathfindingLayer::AIR)); + if (container->disableCondition == "mapLayerSurface") container->setEnabled(shortcuts->optionMapLevel() == 0); @@ -429,14 +438,14 @@ void AdventureMapWidget::updateActiveStateChildden(CIntObject * widget) if (container->disableCondition == "worldViewMode") container->setEnabled(!shortcuts->optionInWorldView()); - updateActiveStateChildden(container); + updateActiveStateChildren(container); } } } void AdventureMapWidget::updateActiveState() { - updateActiveStateChildden(this); + updateActiveStateChildren(this); for (auto entry: shortcuts->getShortcuts()) setShortcutBlocked(entry.shortcut, !entry.isEnabled); diff --git a/client/adventureMap/AdventureMapWidget.h b/client/adventureMap/AdventureMapWidget.h index 742e7d683..85111be88 100644 --- a/client/adventureMap/AdventureMapWidget.h +++ b/client/adventureMap/AdventureMapWidget.h @@ -57,7 +57,7 @@ class AdventureMapWidget : public InterfaceObjectConfigurable std::shared_ptr buildTexturePlayerColored(const JsonNode &); void setPlayerChildren(CIntObject * widget, const PlayerColor & player); - void updateActiveStateChildden(CIntObject * widget); + void updateActiveStateChildren(CIntObject * widget); public: explicit AdventureMapWidget( std::shared_ptr shortcuts ); From a303c01ea291d48ca6f984ff8325f6c556c597cd Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Tue, 9 Sep 2025 01:48:28 +0200 Subject: [PATCH 2/3] digging enable state --- client/adventureMap/AdventureMapShortcuts.cpp | 7 ++++++- client/adventureMap/AdventureMapShortcuts.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/client/adventureMap/AdventureMapShortcuts.cpp b/client/adventureMap/AdventureMapShortcuts.cpp index e9b48e079..f78297689 100644 --- a/client/adventureMap/AdventureMapShortcuts.cpp +++ b/client/adventureMap/AdventureMapShortcuts.cpp @@ -97,7 +97,7 @@ std::vector AdventureMapShortcuts::getShortcuts() { EShortcut::ADVENTURE_NEW_GAME, optionInMapView(), [this]() { this->newGame(); } }, { EShortcut::ADVENTURE_LOAD_GAME, optionInMapView(), [this]() { this->loadGame(); } }, { EShortcut::ADVENTURE_RESTART_GAME, optionInMapView(), [this]() { this->restartGame(); } }, - { EShortcut::ADVENTURE_DIG_GRAIL, optionHeroSelected(), [this]() { this->digGrail(); } }, + { EShortcut::ADVENTURE_DIG_GRAIL, optionHeroDig(), [this]() { this->digGrail(); } }, { EShortcut::ADVENTURE_VIEW_PUZZLE, optionSidePanelActive(),[this]() { this->viewPuzzleMap(); } }, { EShortcut::ADVENTURE_VISIT_OBJECT, optionCanVisitObject(), [this]() { this->visitObject(); } }, { EShortcut::ADVENTURE_VIEW_SELECTED, optionInMapView(), [this]() { this->openObject(); } }, @@ -676,3 +676,8 @@ bool AdventureMapShortcuts::optionHeroBoat(EPathfindingLayer layer) const CGHeroInstance *hero = GAME->interface()->localState->getCurrentHero(); return optionInMapView() && hero && hero->inBoat() && hero->getBoat()->layer == layer; } + +bool AdventureMapShortcuts::optionHeroDig() +{ + return optionInMapView() && GAME->interface()->localState->getCurrentHero() != nullptr && GAME->interface()->localState->getCurrentHero()->diggingStatus() == EDiggingStatus::CAN_DIG; +} diff --git a/client/adventureMap/AdventureMapShortcuts.h b/client/adventureMap/AdventureMapShortcuts.h index 2d945e476..10627be42 100644 --- a/client/adventureMap/AdventureMapShortcuts.h +++ b/client/adventureMap/AdventureMapShortcuts.h @@ -103,6 +103,7 @@ public: bool optionMarketplace(); bool optionHeroGround(); bool optionHeroBoat(EPathfindingLayer layer); + bool optionHeroDig(); void setState(EAdventureState newState); EAdventureState getState() const; From 87d0c9a3cf1db0d44f77c49490eb5ff255d71999 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Mon, 15 Sep 2025 01:02:59 +0200 Subject: [PATCH 3/3] code review --- client/adventureMap/AdventureMapShortcuts.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/adventureMap/AdventureMapShortcuts.cpp b/client/adventureMap/AdventureMapShortcuts.cpp index f78297689..28312904f 100644 --- a/client/adventureMap/AdventureMapShortcuts.cpp +++ b/client/adventureMap/AdventureMapShortcuts.cpp @@ -679,5 +679,6 @@ bool AdventureMapShortcuts::optionHeroBoat(EPathfindingLayer layer) bool AdventureMapShortcuts::optionHeroDig() { - return optionInMapView() && GAME->interface()->localState->getCurrentHero() != nullptr && GAME->interface()->localState->getCurrentHero()->diggingStatus() == EDiggingStatus::CAN_DIG; + auto hero = GAME->interface()->localState->getCurrentHero(); + return optionInMapView() && hero && hero->diggingStatus() == EDiggingStatus::CAN_DIG; }