From b4de7c68b240dd1b63ac1b78feb0721977cdb171 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 10 Dec 2014 12:43:12 +0300 Subject: Add default npc menu items if missing in configuration. --- src/resources/beinginfo.cpp | 5 +++++ src/resources/beinginfo.h | 2 ++ src/resources/db/npcdb.cpp | 9 ++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src/resources') diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index 8b9d72376..ad10f5628 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -219,3 +219,8 @@ void BeingInfo::addMenu(const std::string &name, const std::string &command) { mMenu.push_back(BeingMenuItem(name, command)); } + +const std::vector &BeingInfo::getMenu() const +{ + return mMenu; +} diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index aefd7a5ca..4dfea8bac 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -318,6 +318,8 @@ class BeingInfo final void addMenu(const std::string &name, const std::string &command); + const std::vector &getMenu() const; + static void init(); static void clear(); diff --git a/src/resources/db/npcdb.cpp b/src/resources/db/npcdb.cpp index 542724e27..5f7c48b0b 100644 --- a/src/resources/db/npcdb.cpp +++ b/src/resources/db/npcdb.cpp @@ -22,6 +22,7 @@ #include "resources/db/npcdb.h" +#include "configuration.h" #include "logger.h" #include "resources/beingcommon.h" @@ -29,7 +30,7 @@ #include "resources/spritereference.h" #include "utils/dtor.h" -#include "configuration.h" +#include "utils/gettext.h" #include "debug.h" @@ -137,6 +138,12 @@ void NPCDB::loadXmlFile(const std::string &fileName) } currentInfo->setDisplay(display); + if (currentInfo->getMenu().empty()) + { + currentInfo->addMenu(_("Talk"), "/talk "); + currentInfo->addMenu(_("Buy"), "/buy "); + currentInfo->addMenu(_("Sell"), "/sell "); + } mNPCInfos[id] = currentInfo; } } -- cgit v1.2.3-60-g2f50