Simple mod to change item name display

This mod adds two optional features: simplified item name display, and postfix container names.
Simplified item name display does a few things: converts damage tags to an easier to read format, makes the ‘reinforced’ tag shorter and moves it to the end of the item name, and makes the ‘fits’ tag shorter. It’s easier to show what it does:

Normal Cataclysm:

Simplified item tags:

Postfix container names simply places container names after the item they contain.
Example:

You can toggle them on or off in the options menu, under interface. Simplified item tags has four options: off, items only, corpses only, or both. They do not require a restart, and both work with each other.

Why?

  1. Advanced inventory window no longer separates similar items by damage (or container type)
  2. More compact display
  3. Easier to filter out damaged items (eg zombie clothes drops); instead of filtering out all damage strings, you can just filter *
  4. You can tell at a glance how damaged something is, without remembering damage strings for each material
  5. It just reads easier, IMHO.

To use it, just save the following text as a .diff file, and apply it.

diff --git a/src/item.cpp b/src/item.cpp
index 61f98ee..0791083 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -801,20 +801,42 @@ nc_color item::color_in_inventory()
 std::string item::tname(game *g)
 {
     std::stringstream ret;
+    std::stringstream simple_ret;
+    bool simple_corpses = ( OPTIONS["SIMPLE_ITEM_NAMES"] == "corpses" || OPTIONS["SIMPLE_ITEM_NAMES"] == "both");
+    bool simple_items   = ( OPTIONS["SIMPLE_ITEM_NAMES"] == "items"   || OPTIONS["SIMPLE_ITEM_NAMES"] == "both");
+    bool postfix_containers = OPTIONS["POSTFIX_CONTAINERS"];
 
 // MATERIALS-TODO: put this in json
     std::string damtext = "";
+    std::string simple_damtext = "";
+    std::string reinforced_text = "";
+
     if (damage != 0 && !is_null()) {
         if (damage == -1) {
-            damtext = rm_prefix(_("<dam_adj>reinforced "));
+            simple_items ?
+                reinforced_text = rm_prefix(_("<dam_adj>R")) :
+                damtext = rm_prefix(_("<dam_adj>reinforced "));
         } else {
             if (type->id == "corpse") {
-                if (damage == 1) damtext = rm_prefix(_("<dam_adj>bruised "));
-                if (damage == 2) damtext = rm_prefix(_("<dam_adj>damaged "));
-                if (damage == 3) damtext = rm_prefix(_("<dam_adj>mangled "));
-                if (damage == 4) damtext = rm_prefix(_("<dam_adj>pulped "));
-            } else {
+                if (damage == 1) !simple_corpses ?
+                    damtext = rm_prefix(_("<dam_adj>bruised ")) :
+                    simple_damtext = rm_prefix(_(" *"));
+                if (damage == 2) !simple_corpses ?
+                    damtext = rm_prefix(_("<dam_adj>damaged ")) :
+                    simple_damtext = rm_prefix(_(" **"));
+                if (damage == 3) !simple_corpses ?
+                    damtext = rm_prefix(_("<dam_adj>mangled ")) :
+                    simple_damtext = rm_prefix(_(" ***"));
+                if (damage == 4) !simple_corpses ?
+                    damtext = rm_prefix(_("<dam_adj>pulped ")) :
+                    simple_damtext = rm_prefix(_(" ****"));
+            } else if (!simple_items) {
                 damtext = rmp_format("%s ", type->dmg_adj(damage).c_str());
+            } else {
+                if (damage == 1) simple_damtext = rm_prefix(_("<dam_adj> *"));
+                if (damage == 2) simple_damtext = rm_prefix(_("<dam_adj> **"));
+                if (damage == 3) simple_damtext = rm_prefix(_("<dam_adj> ***"));
+                if (damage == 4) simple_damtext = rm_prefix(_("<dam_adj> ****"));
             }
         }
     }
@@ -858,13 +880,23 @@ std::string item::tname(game *g)
             ret << "+";
         maintext = ret.str();
     } else if (contents.size() == 1) {
-        maintext = rmp_format(
-                       contents[0].made_of(LIQUID)?
-                       _("<item_name>%s of %s"):
-                       _("<item_name>%s with %s"),
-                       type->name.c_str(), contents[0].tname().c_str()
-                   );
-    }
+			if (!postfix_containers) {
+				maintext = rmp_format(
+						contents[0].made_of(LIQUID)?
+						_("<item_name>%s of %s"):
+						_("<item_name>%s with %s"),
+						type->name.c_str(), contents[0].tname().c_str()
+						);
+			} else {
+				maintext = rmp_format(
+						contents[0].made_of(LIQUID)?
+						_("<item_name>%s [%s]"):
+						_("<item_name>%s [%s]"),
+						contents[0].tname().c_str(),
+						type->name.c_str()
+						);
+			}
+		}
     else if (contents.size() > 0) {
         maintext = rmp_format(_("<item_name>%s, full"), type->name.c_str());
     } else {
@@ -894,9 +926,21 @@ std::string item::tname(game *g)
         food->rotten(g))
         ret << _(" (rotten)");
 
+    std::string fittext = "";
     if (has_flag("FIT")) {
-        ret << _(" (fits)");
+        if (!simple_items) {
+            ret << _(" (fits)");
+        } else {
+            fittext = _("f");
+        }
+    }
+
+    std::stringstream rfstream;
+    rfstream.str("");
+    if ((fittext != "" || reinforced_text != "") && simple_items) {
+        rfstream << " <" << reinforced_text << fittext << ">";
     }
+    std::string rftext = rfstream.str();
 
     if (owned > 0)
         ret << _(" (owned)");
@@ -905,7 +949,7 @@ std::string item::tname(game *g)
 
     ret.str("");
 
-    ret << damtext << vehtext << burntext << maintext << tagtext;
+    ret << damtext << vehtext << burntext << maintext << simple_damtext << rftext << tagtext;
 
     if (!item_vars.empty()) {
         return "*" + ret.str() + "*";

The code could most definitely use improvements; I’m still a novice at programming, and I threw this together from a non-optional version I had done a while ago. So bug reports/suggestions are much appreciated. Hope this is helpful to someone!

EDIT: Fixed a dumb conditional that made containers holding non-liquids invisible.

Great idea! Unfortunately I can’t test it at the moment - will hopefully get around to it later.

Nice mod, hope someone can make a PR out of this.

i dislike the ** for damage levels, but like the changed reinforced and fits tags.