1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Merge pull request #3057 from Laserlicht/rw_hero

This commit is contained in:
Nordsoft91
2023-10-20 01:42:06 +02:00
committed by GitHub
8 changed files with 46 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

View File

@@ -41,6 +41,13 @@
"vcmi.radialWheel.splitUnitEqually" : "Split creatures equally",
"vcmi.radialWheel.moveUnit" : "Move creatures to another army",
"vcmi.radialWheel.splitUnit" : "Split creature to another slot",
"vcmi.radialWheel.heroGetArmy" : "Get army from other hero",
"vcmi.radialWheel.heroSwapArmy" : "Swap army with other hero",
"vcmi.radialWheel.heroExchange" : "Open hero exchange",
"vcmi.radialWheel.heroGetArtifacts" : "Get artifacts from other hero",
"vcmi.radialWheel.heroSwapArtifacts" : "Swap artifacts with other hero",
"vcmi.radialWheel.heroDismiss" : "Dismiss hero",
"vcmi.mainMenu.serverConnecting" : "Connecting...",
"vcmi.mainMenu.serverAddressEnter" : "Enter address:",

View File

@@ -29,6 +29,8 @@
#include "../widgets/CGarrisonInt.h"
#include "../widgets/Buttons.h"
#include "../widgets/TextControls.h"
#include "../widgets/RadialMenu.h"
#include "../widgets/CExchangeController.h"
#include "../render/Canvas.h"
#include "../render/IImage.h"
#include "../render/IRenderHandler.h"
@@ -322,11 +324,46 @@ CHeroGSlot::CHeroGSlot(int x, int y, int updown, const CGHeroInstance * h, HeroS
set(h);
addUsedEvents(LCLICK | SHOW_POPUP | HOVER);
addUsedEvents(LCLICK | SHOW_POPUP | GESTURE | HOVER);
}
CHeroGSlot::~CHeroGSlot() = default;
void CHeroGSlot::gesture(bool on, const Point & initialPosition, const Point & finalPosition)
{
if(!on)
return;
if(!hero)
return;
if (!settings["input"]["radialWheelGarrisonSwipe"].Bool())
return;
std::shared_ptr<CHeroGSlot> other = upg ? owner->garrisonedHero : owner->visitingHero;
bool twoHeroes = hero && other->hero;
ObjectInstanceID heroId = hero->id;
ObjectInstanceID heroOtherId = twoHeroes ? other->hero->id : ObjectInstanceID::NONE;
std::vector<RadialMenuConfig> menuElements = {
{ RadialMenuConfig::ITEM_NW, twoHeroes, "moveTroops", "vcmi.radialWheel.heroGetArmy", [heroId, heroOtherId](){CExchangeController(heroId, heroOtherId).moveArmy(false, std::nullopt);} },
{ RadialMenuConfig::ITEM_NE, twoHeroes, "stackSplitDialog", "vcmi.radialWheel.heroSwapArmy", [heroId, heroOtherId](){CExchangeController(heroId, heroOtherId).swapArmy();} },
{ RadialMenuConfig::ITEM_EE, twoHeroes, "tradeHeroes", "vcmi.radialWheel.heroExchange", [heroId, heroOtherId](){LOCPLINT->showHeroExchange(heroId, heroOtherId);} },
{ RadialMenuConfig::ITEM_SW, twoHeroes, "moveArtifacts", "vcmi.radialWheel.heroGetArtifacts", [heroId, heroOtherId](){CExchangeController(heroId, heroOtherId).moveArtifacts(false, true, true);} },
{ RadialMenuConfig::ITEM_SE, twoHeroes, "swapArtifacts", "vcmi.radialWheel.heroSwapArtifacts", [heroId, heroOtherId](){CExchangeController(heroId, heroOtherId).swapArtifacts(true, true);} },
{ RadialMenuConfig::ITEM_WW, true, "dismissHero", "vcmi.radialWheel.heroDismiss", [this]()
{
CFunctionList<void()> ony = [=](){ };
ony += [=](){ LOCPLINT->cb->dismissHero(hero); };
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[22], ony, nullptr);
} },
};
GH.windows().createAndPushWindow<RadialMenu>(pos.center(), menuElements);
}
void CHeroGSlot::hover(bool on)
{
if(!on)

View File

@@ -113,6 +113,7 @@ public:
void set(const CGHeroInstance * newHero);
void hover (bool on) override;
void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override;
void clickPressed(const Point & cursorPosition) override;
void showPopupWindow(const Point & cursorPosition) override;
void deactivate() override;