mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Merge pull request #3809 from dydzio0614/shortcut-enhancements
Artifact management shortcuts + game begin default keybind fix
This commit is contained in:
commit
50dc6f67c6
@ -59,7 +59,8 @@ enum class EShortcut
|
||||
MAIN_MENU_CAMPAIGN_CUSTOM,
|
||||
|
||||
// Game lobby / scenario selection
|
||||
LOBBY_BEGIN_GAME, // b, Return
|
||||
LOBBY_BEGIN_STANDARD_GAME, // b
|
||||
LOBBY_BEGIN_CAMPAIGN, // Return
|
||||
LOBBY_LOAD_GAME, // l, Return
|
||||
LOBBY_SAVE_GAME, // s, Return
|
||||
LOBBY_RANDOM_MAP, // Open random map tab
|
||||
|
@ -99,7 +99,8 @@ EShortcut ShortcutHandler::findShortcut(const std::string & identifier ) const
|
||||
{"mainMenuCampaignRoe", EShortcut::MAIN_MENU_CAMPAIGN_ROE },
|
||||
{"mainMenuCampaignAb", EShortcut::MAIN_MENU_CAMPAIGN_AB },
|
||||
{"mainMenuCampaignCustom", EShortcut::MAIN_MENU_CAMPAIGN_CUSTOM },
|
||||
{"lobbyBeginGame", EShortcut::LOBBY_BEGIN_GAME },
|
||||
{"lobbyBeginStandardGame", EShortcut::LOBBY_BEGIN_STANDARD_GAME },
|
||||
{"lobbyBeginCampaign", EShortcut::LOBBY_BEGIN_CAMPAIGN },
|
||||
{"lobbyLoadGame", EShortcut::LOBBY_LOAD_GAME },
|
||||
{"lobbySaveGame", EShortcut::LOBBY_SAVE_GAME },
|
||||
{"lobbyRandomMap", EShortcut::LOBBY_RANDOM_MAP },
|
||||
|
@ -82,7 +82,7 @@ CLobbyScreen::CLobbyScreen(ESelectionScreen screenType)
|
||||
|
||||
card->iconDifficulty->addCallback(std::bind(&IServerAPI::setDifficulty, CSH, _1));
|
||||
|
||||
buttonStart = std::make_shared<CButton>(Point(411, 535), AnimationPath::builtin("SCNRBEG.DEF"), CGI->generaltexth->zelp[103], std::bind(&CLobbyScreen::startScenario, this, false), EShortcut::LOBBY_BEGIN_GAME);
|
||||
buttonStart = std::make_shared<CButton>(Point(411, 535), AnimationPath::builtin("SCNRBEG.DEF"), CGI->generaltexth->zelp[103], std::bind(&CLobbyScreen::startScenario, this, false), EShortcut::LOBBY_BEGIN_STANDARD_GAME);
|
||||
initLobby();
|
||||
break;
|
||||
}
|
||||
@ -97,7 +97,7 @@ CLobbyScreen::CLobbyScreen(ESelectionScreen screenType)
|
||||
}
|
||||
case ESelectionScreen::campaignList:
|
||||
tabSel->callOnSelect = std::bind(&IServerAPI::setMapInfo, CSH, _1, nullptr);
|
||||
buttonStart = std::make_shared<CButton>(Point(411, 535), AnimationPath::builtin("SCNRLOD.DEF"), CButton::tooltip(), std::bind(&CLobbyScreen::startCampaign, this), EShortcut::LOBBY_BEGIN_GAME);
|
||||
buttonStart = std::make_shared<CButton>(Point(411, 535), AnimationPath::builtin("SCNRLOD.DEF"), CButton::tooltip(), std::bind(&CLobbyScreen::startCampaign, this), EShortcut::LOBBY_BEGIN_CAMPAIGN);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -147,8 +147,66 @@ void CWindowWithArtifacts::clickPressedArtPlaceHero(CArtifactsOfHeroBase & artsI
|
||||
if(checkSpecialArts(*art, hero, std::is_same_v<decltype(artSetWeak), std::weak_ptr<CArtifactsOfHeroAltar>> ? true : false))
|
||||
{
|
||||
assert(artSetPtr->getHero()->getSlotByInstance(art) != ArtifactPosition::PRE_FIRST);
|
||||
LOCPLINT->cb->swapArtifacts(ArtifactLocation(artSetPtr->getHero()->id, artSetPtr->getHero()->getSlotByInstance(art)),
|
||||
ArtifactLocation(artSetPtr->getHero()->id, ArtifactPosition::TRANSITION_POS));
|
||||
|
||||
if(GH.isKeyboardCtrlDown())
|
||||
{
|
||||
std::shared_ptr<CArtifactsOfHeroMain> anotherHeroEquipmentPointer = nullptr;
|
||||
|
||||
for(auto set : artSets)
|
||||
{
|
||||
if(std::holds_alternative<std::weak_ptr<CArtifactsOfHeroMain>>(set))
|
||||
{
|
||||
std::shared_ptr<CArtifactsOfHeroMain> heroEquipmentPointer = std::get<std::weak_ptr<CArtifactsOfHeroMain>>(set).lock();
|
||||
if(heroEquipmentPointer->getHero()->id != artSetPtr->getHero()->id)
|
||||
{
|
||||
anotherHeroEquipmentPointer = heroEquipmentPointer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(anotherHeroEquipmentPointer != nullptr)
|
||||
{
|
||||
ArtifactPosition availablePosition = ArtifactUtils::getArtAnyPosition(anotherHeroEquipmentPointer->getHero(), art->getTypeId());
|
||||
if(availablePosition != ArtifactPosition::PRE_FIRST)
|
||||
{
|
||||
LOCPLINT->cb->swapArtifacts(ArtifactLocation(artSetPtr->getHero()->id, artSetPtr->getHero()->getSlotByInstance(art)),
|
||||
ArtifactLocation(anotherHeroEquipmentPointer->getHero()->id, availablePosition));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(GH.isKeyboardAltDown())
|
||||
{
|
||||
ArtifactPosition destinationPosition = ArtifactPosition::PRE_FIRST;
|
||||
|
||||
if(ArtifactUtils::isSlotEquipment(artPlace.slot))
|
||||
{
|
||||
ArtifactPosition availablePosition = ArtifactUtils::getArtBackpackPosition(artSetPtr->getHero(), art->getTypeId());
|
||||
if(availablePosition != ArtifactPosition::PRE_FIRST)
|
||||
{
|
||||
destinationPosition = availablePosition;
|
||||
}
|
||||
}
|
||||
else if(ArtifactUtils::isSlotBackpack(artPlace.slot))
|
||||
{
|
||||
ArtifactPosition availablePosition = ArtifactUtils::getArtAnyPosition(artSetPtr->getHero(), art->getTypeId());
|
||||
if(availablePosition != ArtifactPosition::PRE_FIRST && availablePosition != ArtifactPosition::BACKPACK_START)
|
||||
{
|
||||
destinationPosition = availablePosition;
|
||||
}
|
||||
}
|
||||
|
||||
if(destinationPosition != ArtifactPosition::PRE_FIRST)
|
||||
{
|
||||
LOCPLINT->cb->swapArtifacts(ArtifactLocation(artSetPtr->getHero()->id, artPlace.slot),
|
||||
ArtifactLocation(artSetPtr->getHero()->id, destinationPosition));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOCPLINT->cb->swapArtifacts(ArtifactLocation(artSetPtr->getHero()->id, artPlace.slot),
|
||||
ArtifactLocation(artSetPtr->getHero()->id, ArtifactPosition::TRANSITION_POS));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -43,7 +43,8 @@
|
||||
"mainMenuCampaignRoe": "R",
|
||||
"mainMenuCampaignAb": "A",
|
||||
"mainMenuCampaignCustom": "C",
|
||||
"lobbyBeginGame": [ "B", "Return", "Keypad Enter"],
|
||||
"lobbyBeginStandardGame": "B",
|
||||
"lobbyBeginCampaign": [ "Return", "Keypad Enter"],
|
||||
"lobbyLoadGame": [ "L", "Return", "Keypad Enter"],
|
||||
"lobbySaveGame": [ "S", "Return", "Keypad Enter"],
|
||||
"lobbyRandomMap": "R",
|
||||
|
Loading…
Reference in New Issue
Block a user