diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-12-27 10:30:31 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-12-27 10:30:31 +0000 |
commit | 973a85d8d2980c5572da3d4f4839110647864873 (patch) | |
tree | 552cd198c83f9684b4eba7845a1366821accf38d /crawl-ref/source/describe.cc | |
parent | 2b793343f9c43103ee152886353c2988e4434def (diff) | |
download | crawl-ref-973a85d8d2980c5572da3d4f4839110647864873.tar.gz crawl-ref-973a85d8d2980c5572da3d4f4839110647864873.zip |
Let portal vaults (and places like Vault:8 and Slime:6) change the short and
long descriptions of features. For example, "An ice covered rock wall" instead
of "A rock wall". See dat/icecave.des function ice_cave_feat_descs() for
examples.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7992 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/describe.cc')
-rw-r--r-- | crawl-ref/source/describe.cc | 69 |
1 files changed, 62 insertions, 7 deletions
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index 477f9bddbe..3d7e0720fd 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -50,6 +50,8 @@ #include "tutorial.h" #include "xom.h" +#define LONG_DESC_KEY "long_desc_key" + // ======================================================================== // Internal Functions // ======================================================================== @@ -1995,17 +1997,52 @@ static std::string _get_feature_description_wide(int feat) void describe_feature_wide(int x, int y) { - std::string desc = feature_description(coord_def(x, y)); - desc += "$$"; + const coord_def pos(x, y); + const dungeon_feature_type feat = grd(pos); - // Get rid of trailing .$$ before lookup + std::string desc = feature_description(pos, false, DESC_CAP_A, false); std::string db_name = - grd[x][y] == DNGN_ENTER_SHOP ? "A shop" - : desc.substr(0, desc.length() - 3); + grd[x][y] == DNGN_ENTER_SHOP ? "A shop" : desc; + std::string long_desc = getLongDescription(db_name); + + desc += ".$$"; + + // If we couldn't find a description in the database then see if + // the feature's base name is different. + if (long_desc.empty()) + { + db_name = feature_description(pos, false, DESC_CAP_A, false, true); + long_desc = getLongDescription(db_name); + } + + bool custom_desc = false; + + const CrawlHashTable &props = env.properties; + if (props.exists(LONG_DESC_KEY)) + { + const CrawlHashTable &desc_table = props[LONG_DESC_KEY].get_table(); + + // First try the modified name, then the base name. + std::string key = raw_feature_description(feat); + if (!desc_table.exists(key)) + key = raw_feature_description(feat, NUM_TRAPS, true); + + if (desc_table.exists(key)) + { + long_desc = desc_table[key].get_string(); + custom_desc = true; + } + + std::string quote = getQuoteString(key); + if (!quote.empty()) + db_name = key; + } + + desc += long_desc; - desc += getLongDescription(db_name); // For things which require logic - desc += _get_feature_description_wide(grd[x][y]); + if (!custom_desc) + desc += _get_feature_description_wide(grd[x][y]); std::string quote = getQuoteString(db_name); @@ -2020,6 +2057,24 @@ void describe_feature_wide(int x, int y) getch(); } +void set_feature_desc_long(const std::string &raw_name, + const std::string &desc) +{ + ASSERT(!raw_name.empty()); + + CrawlHashTable &props = env.properties; + + if (!props.exists(LONG_DESC_KEY)) + props[LONG_DESC_KEY].new_table(SV_STR); + + CrawlHashTable &desc_table = props[LONG_DESC_KEY]; + + if (desc.empty()) + desc_table.erase(raw_name); + else + desc_table[raw_name] = desc; +} + // Returns true if spells can be shown to player. static bool _show_item_description(const item_def &item) { |