mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
Merge pull request #3057 from Laserlicht/rw_hero
This commit is contained in:
BIN
Mods/vcmi/Data/radialMenu/dismissHero.png
Normal file
BIN
Mods/vcmi/Data/radialMenu/dismissHero.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 352 B |
BIN
Mods/vcmi/Data/radialMenu/moveArtifacts.png
Normal file
BIN
Mods/vcmi/Data/radialMenu/moveArtifacts.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
Mods/vcmi/Data/radialMenu/moveTroops.png
Normal file
BIN
Mods/vcmi/Data/radialMenu/moveTroops.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 518 B |
BIN
Mods/vcmi/Data/radialMenu/swapArtifacts.png
Normal file
BIN
Mods/vcmi/Data/radialMenu/swapArtifacts.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
Mods/vcmi/Data/radialMenu/tradeHeroes.png
Normal file
BIN
Mods/vcmi/Data/radialMenu/tradeHeroes.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 378 B |
@@ -42,6 +42,13 @@
|
||||
"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:",
|
||||
"vcmi.mainMenu.serverConnectionFailed" : "Failed to connect",
|
||||
|
@@ -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)
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user