From 70f7db29f291ea22e6dca7c03540beded7ec7bf8 Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Thu, 22 Jun 2017 21:26:32 +0300
Subject: Add chat command for feed homunculus.

---
 src/actions/actions.cpp         | 7 +++++++
 src/actions/actions.h           | 1 +
 src/dyetool/actions/actions.cpp | 1 +
 src/enums/input/inputaction.h   | 1 +
 src/gui/popups/popupmenu.cpp    | 6 +-----
 src/input/inputactionmap.h      | 6 ++++++
 src/input/pages/other.cpp       | 6 ++++++
 7 files changed, 23 insertions(+), 5 deletions(-)

(limited to 'src')

diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index 65de77689..afd774b79 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -1609,6 +1609,13 @@ impHandler0(homunculusToMaster)
     return true;
 }
 
+impHandler0(homunculusFeed)
+{
+    if (homunculusHandler != nullptr)
+        homunculusHandler->feed();
+    return true;
+}
+
 impHandler(useItem)
 {
     const int itemId = atoi(event.args.c_str());
diff --git a/src/actions/actions.h b/src/actions/actions.h
index 107f978aa..83072680c 100644
--- a/src/actions/actions.h
+++ b/src/actions/actions.h
@@ -103,6 +103,7 @@ namespace Actions
     decHandler(mercenaryFire);
     decHandler(mercenaryToMaster);
     decHandler(homunculusToMaster);
+    decHandler(homunculusFeed);
     decHandler(useItem);
     decHandler(useItemInv);
     decHandler(invToStorage);
diff --git a/src/dyetool/actions/actions.cpp b/src/dyetool/actions/actions.cpp
index 7dc23fe38..58353b699 100644
--- a/src/dyetool/actions/actions.cpp
+++ b/src/dyetool/actions/actions.cpp
@@ -99,6 +99,7 @@ impHandlerVoid(uploadLog)
 impHandlerVoid(mercenaryFire)
 impHandlerVoid(mercenaryToMaster)
 impHandlerVoid(homunculusToMaster)
+impHandlerVoid(homunculusFeed)
 impHandlerVoid(useItem)
 impHandlerVoid(useItemInv)
 impHandlerVoid(invToStorage)
diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h
index 6f423207e..0962bf34f 100644
--- a/src/enums/input/inputaction.h
+++ b/src/enums/input/inputaction.h
@@ -703,6 +703,7 @@ enumStart(InputAction)
     WINDOW_SERVER_INFO,
     MERCENARY_TO_MASTER,
     HOMUNCULUS_TO_MASTER,
+    HOMUNCULUS_FEED,
     TOTAL
 }
 enumEnd(InputAction);
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 15fcc34cb..b13a2c374 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -358,7 +358,7 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
                     _("Move to master"));
                 // TRANSLATORS: popup menu item
                 // TRANSLATORS: feed homunculus
-                mBrowserBox->addRow("homunculus feed", _("Feed"));
+                mBrowserBox->addRow("/homunculusfeed", _("Feed"));
                 mBrowserBox->addRow("##3---");
                 // TRANSLATORS: popup menu item
                 // TRANSLATORS: pet rename item
@@ -1297,10 +1297,6 @@ void PopupMenu::handleLink(const std::string &link,
         if (chat != nullptr)
             chatHandler->joinChat(chat, "");
     }
-    else if (link == "homunculus feed")
-    {
-        homunculusHandler->feed();
-    }
     else if (link == "homunculus delete")
     {
         homunculusHandler->fire();
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index dc2a38e7d..95a3b8d3e 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -5708,6 +5708,12 @@ static const InputActionData inputActionData
         "homunculustomaster|homunmaster",
         UseArgs_false,
         Protected_false},
+    {"keyHomunculusFeed",
+        defaultAction(&Actions::homunculusFeed),
+        InputCondition::INGAME,
+        "homunculusfeed|homunfeed|feedhomun|feedhomunculus",
+        UseArgs_false,
+        Protected_false},
 };
 
 #undef defaultAction
diff --git a/src/input/pages/other.cpp b/src/input/pages/other.cpp
index 47312c3c5..3d37bd982 100644
--- a/src/input/pages/other.cpp
+++ b/src/input/pages/other.cpp
@@ -427,6 +427,12 @@ SetupActionData setupActionDataOther[] =
         InputAction::PET_AI_STOP,
         "",
     },
+    {
+        // TRANSLATORS: input action name
+        N_("Feed homunculus"),
+        InputAction::HOMUNCULUS_FEED,
+        "",
+    },
     {
         "",
         InputAction::NO_VALUE,
-- 
cgit v1.2.3-70-g09d2