diff options
-rw-r--r-- | crawl-ref/source/describe.cc | 29 | ||||
-rw-r--r-- | crawl-ref/source/describe.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/l_dgngrd.cc | 17 |
3 files changed, 49 insertions, 0 deletions
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index 1ccfd0a5d7..c0a8470d77 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -54,6 +54,7 @@ #include "xom.h" #define LONG_DESC_KEY "long_desc_key" +#define QUOTE_KEY "quote_key" // ======================================================================== // Internal Functions @@ -2081,6 +2082,15 @@ void get_feature_desc(const coord_def &pos, describe_info &inf) inf.body << _get_feature_description_wide(grd(pos)); inf.quote = getQuoteString(db_name); + + // Quotes don't care about custom descriptions. + if (props.exists(QUOTE_KEY)) + { + const CrawlHashTable "e_table = props[QUOTE_KEY].get_table(); + + if (quote_table.exists(db_name)) + inf.quote = quote_table[db_name].get_string(); + } } void describe_feature_wide(const coord_def& pos) @@ -2116,6 +2126,25 @@ void set_feature_desc_long(const std::string &raw_name, desc_table[raw_name] = desc; } +void set_feature_quote(const std::string &raw_name, + const std::string "e) +{ + ASSERT(!raw_name.empty()); + + CrawlHashTable &props = env.properties; + + if (!props.exists(QUOTE_KEY)) + props[QUOTE_KEY].new_table(); + + CrawlHashTable "e_table = props[QUOTE_KEY].get_table(); + + if (quote.empty()) + quote_table.erase(raw_name); + else + quote_table[raw_name] = quote; +} + + void get_item_desc(const item_def &item, describe_info &inf, bool terse) { // Don't use verbose descriptions if terse and the item contains spells, diff --git a/crawl-ref/source/describe.h b/crawl-ref/source/describe.h index ab07f30fa6..3b68325015 100644 --- a/crawl-ref/source/describe.h +++ b/crawl-ref/source/describe.h @@ -52,6 +52,9 @@ void get_feature_desc(const coord_def &gc, describe_info &inf); void set_feature_desc_long(const std::string &raw_name, const std::string &desc); +void set_feature_quote(const std::string &raw_name, + const std::string "e); + void describe_item(item_def &item, bool allow_inscribe = false, bool shopping = false); void get_item_desc(const item_def &item, describe_info &inf, diff --git a/crawl-ref/source/l_dgngrd.cc b/crawl-ref/source/l_dgngrd.cc index 84d2d00cfc..d72dab589c 100644 --- a/crawl-ref/source/l_dgngrd.cc +++ b/crawl-ref/source/l_dgngrd.cc @@ -115,6 +115,22 @@ static int dgn_set_feature_desc_long(lua_State *ls) return (0); } +static int dgn_set_feature_quote(lua_State *ls) +{ + const std::string raw_name = luaL_checkstring(ls, 1); + const std::string quote = luaL_checkstring(ls, 2); + + if (raw_name.empty()) + { + luaL_argerror(ls, 1, "Raw name can't be empty"); + return (0); + } + + set_feature_quote(raw_name, quote); + + return (0); +} + static int dgn_max_bounds(lua_State *ls) { lua_pushnumber(ls, GXM); @@ -180,6 +196,7 @@ const struct luaL_reg dgn_grid_dlib[] = { "feature_desc_at", dgn_feature_desc_at }, { "set_feature_desc_short", dgn_set_feature_desc_short }, { "set_feature_desc_long", dgn_set_feature_desc_long }, +{ "set_feature_quote", dgn_set_feature_quote }, { "seen_replace_feat", dgn_seen_replace_feat }, { "grid", dgn_grid }, |