mirror of
https://github.com/vcmi/vcmi.git
synced 2025-10-08 23:22:25 +02:00
Merge pull request #6116 from Laserlicht/shortcuts
shortcut market + boat
This commit is contained in:
@@ -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"
|
||||
@@ -96,11 +97,11 @@ std::vector<AdventureMapShortcutState> 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(); } },
|
||||
{ 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,31 @@ 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;
|
||||
}
|
||||
|
||||
bool AdventureMapShortcuts::optionHeroDig()
|
||||
{
|
||||
auto hero = GAME->interface()->localState->getCurrentHero();
|
||||
return optionInMapView() && hero && hero->diggingStatus() == EDiggingStatus::CAN_DIG;
|
||||
}
|
||||
|
@@ -10,6 +10,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../lib/constants/EntityIdentifiers.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
class Point;
|
||||
class Rect;
|
||||
@@ -98,6 +100,10 @@ public:
|
||||
bool optionSidePanelActive();
|
||||
bool optionMapScrollingActive();
|
||||
bool optionMapViewActive();
|
||||
bool optionMarketplace();
|
||||
bool optionHeroGround();
|
||||
bool optionHeroBoat(EPathfindingLayer layer);
|
||||
bool optionHeroDig();
|
||||
|
||||
void setState(EAdventureState newState);
|
||||
EAdventureState getState() const;
|
||||
|
@@ -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);
|
||||
|
@@ -57,7 +57,7 @@ class AdventureMapWidget : public InterfaceObjectConfigurable
|
||||
std::shared_ptr<CIntObject> buildTexturePlayerColored(const JsonNode &);
|
||||
|
||||
void setPlayerChildren(CIntObject * widget, const PlayerColor & player);
|
||||
void updateActiveStateChildden(CIntObject * widget);
|
||||
void updateActiveStateChildren(CIntObject * widget);
|
||||
public:
|
||||
explicit AdventureMapWidget( std::shared_ptr<AdventureMapShortcuts> shortcuts );
|
||||
|
||||
|
Reference in New Issue
Block a user