From 3c51082082397b0564a224214249a096750b56c6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 22 Jun 2017 23:20:05 +0300 Subject: Add chat command for return pet to egg. --- src/actions/pets.cpp | 7 +++++++ src/actions/pets.h | 1 + src/dyetool/actions/pets.cpp | 1 + src/enums/input/inputaction.h | 1 + src/gui/popups/popupmenu.cpp | 13 +++++-------- src/input/inputactionmap.h | 6 ++++++ src/input/pages/other.cpp | 6 ++++++ 7 files changed, 27 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/actions/pets.cpp b/src/actions/pets.cpp index 01542edf4..b989cfc5c 100644 --- a/src/actions/pets.cpp +++ b/src/actions/pets.cpp @@ -231,4 +231,11 @@ impHandler0(petDropLoot) return true; } +impHandler0(petReturnToEgg) +{ + if (petHandler != nullptr) + petHandler->returnToEgg(); + return true; +} + } // namespace Actions diff --git a/src/actions/pets.h b/src/actions/pets.h index a3ac0795f..f607f474c 100644 --- a/src/actions/pets.h +++ b/src/actions/pets.h @@ -43,6 +43,7 @@ namespace Actions decHandler(petMove); decHandler(petFeed); decHandler(petDropLoot); + decHandler(petReturnToEgg); } // namespace Actions #undef decHandler diff --git a/src/dyetool/actions/pets.cpp b/src/dyetool/actions/pets.cpp index 16658ebc7..b52c17020 100644 --- a/src/dyetool/actions/pets.cpp +++ b/src/dyetool/actions/pets.cpp @@ -43,5 +43,6 @@ impHandlerVoid(petDirectRight) impHandlerVoid(petMove) impHandlerVoid(petFeed) impHandlerVoid(petDropLoot) +impHandlerVoid(petReturnToEgg) } // namespace Actions diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h index 3099c89ea..3ec122683 100644 --- a/src/enums/input/inputaction.h +++ b/src/enums/input/inputaction.h @@ -706,6 +706,7 @@ enumStart(InputAction) HOMUNCULUS_FEED, PET_FEED, PET_DROP_LOOT, + PET_RETURN_TO_EGG, TOTAL } enumEnd(InputAction); diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 0503e6e8f..d610182e6 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -396,13 +396,14 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being) msg = info->getString(0); if (!msg.empty()) { - mBrowserBox->addRow("pet to egg", msg.c_str()); + mBrowserBox->addRow("/petreturnegg", msg.c_str()); } else { - // TRANSLATORS: popup menu item - // TRANSLATORS: pet return to egg - mBrowserBox->addRow("pet to egg", _("Return to egg")); + mBrowserBox->addRow("/petreturnegg", + // TRANSLATORS: popup menu item + // TRANSLATORS: pet return to egg + _("Return to egg")); } mBrowserBox->addRow("##3---"); } @@ -1302,10 +1303,6 @@ void PopupMenu::handleLink(const std::string &link, showCraftPopup(); return; } - else if (link == "pet to egg") - { - petHandler->returnToEgg(); - } else if (link == "pet unequip") { petHandler->unequip(); diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index 6007a3007..e30e50ae3 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -5726,6 +5726,12 @@ static const InputActionData inputActionData "petdroploot|petloot", UseArgs_false, Protected_true}, + {"keyPetReturnToEgg", + defaultAction(&Actions::petReturnToEgg), + InputCondition::INGAME, + "pettoegg|petegg|petreturn|returnpet|petreturnegg", + UseArgs_false, + Protected_false}, }; #undef defaultAction diff --git a/src/input/pages/other.cpp b/src/input/pages/other.cpp index c215f2fd0..a33ede552 100644 --- a/src/input/pages/other.cpp +++ b/src/input/pages/other.cpp @@ -445,6 +445,12 @@ SetupActionData setupActionDataOther[] = InputAction::PET_DROP_LOOT, "", }, + { + // TRANSLATORS: input action name + N_("Return pet to egg"), + InputAction::PET_RETURN_TO_EGG, + "", + }, { "", InputAction::NO_VALUE, -- cgit v1.2.3-70-g09d2