Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deduplicate item name in info window #38610

Merged
merged 2 commits into from
Mar 8, 2020

Conversation

wapcaplet
Copy link
Contributor

@wapcaplet wapcaplet commented Mar 7, 2020

Summary

SUMMARY: Interface "Remove duplicate item name in item info panel"

Purpose of change

Many items (clothing, stuff in containers, fresh food, tools marked as favorite) display a duplicate name in the item description panel. The duplicate item name adds no information (since the first line always includes the text of the second) and it takes up a potentially quite valuable line of screen space.

Describe the solution

Slightly changes the conditional in src/output.cpp in the draw_item_info function, so that type_name is only output if tname does not already include it. Normally, tname includes type_name anyway, thanks to this bit inside the tname function:

Cataclysm-DDA/src/item.cpp

Lines 3883 to 3884 in 6bb5b9d

if( is_corpse() || typeId() == "blood" || item_vars.find( "name" ) != item_vars.end() ) {
maintext = type_name( quantity );

In the few cases where it does not, both lines will be shown - such as when an item has a custom label.

Describe alternatives you've considered

Considered leaving as-is, and also considered fixing as part of #38030 , but seems worth doing on its own.

Testing

Checked descriptions of various items and saw the duplicate line removed. Checked items that had no duplicate before (guns, regular tools and weapons) and saw they still have the name intact.

Additional context

Any item that previously duplicated the exact same text in both lines, now has the duplicate second line removed. This includes:

  • Wearable items (with/without health bar)
  • Food with (fresh), (hot), (rotten) modifier
  • Favorite items with * next to them

image

Since type_name is responsible for adding the descriptive modifiers (when a food has human or mutant meat as an ingredient, for example), I tested a few of those as well:

image

Any item whose first line does not include the exact text of the second line, has both lines displayed. This includes items that have been re-labeled using a marker or knife. The display of such items remains unchanged:

image

Instead of often outputting both tname and type_name (for example
clothing, bottle of water, fresh food), only output type_name if tname
is empty.
@Night-Pryanik
Copy link
Contributor

Could you please inscribe some text (to give it a custom name) on some item and check if everything is working as it should?

@wapcaplet
Copy link
Contributor Author

wapcaplet commented Mar 7, 2020

Could you please inscribe some text (to give it a custom name) on some item and check if everything is working as it should?

@Night-Pryanik Ah, this is an edge case I didn't think about. With a new label, the original item name would no longer be shown:

image

With my change, there is only "knifey", which is no good. I find a way to merge in the original name in that situation.

@wapcaplet wapcaplet changed the title Deduplicate item name in info window [WIP] Deduplicate item name in info window Mar 7, 2020
When an item has its name changed by writing/inscribing on it with a
knife or marker, the `tname` (from `get_item_name`) returns only
the customized name, while `type_name` (from `get_type_name`) returns
the original item name.

Because the custom name could be anything, this commit restores the
display of `type_name` when the `tname` does not already include it.
@wapcaplet
Copy link
Contributor Author

wapcaplet commented Mar 7, 2020

My solution for items with custom labels is to output the type_name line only if the item_name does not already include the same text.

Now, if you write a custom label on an item, the original item name is shown after it, unless your custom label also includes the original item name, for example here I have two pocket knife items, one labeled knifey --pocket knife-- and the other labeled Stabby McStabber. The first has the duplicate type name removed; the second preserves it:

image

@wapcaplet wapcaplet changed the title [WIP] Deduplicate item name in info window Deduplicate item name in info window Mar 7, 2020
@kevingranade
Copy link
Member

I just want to say, this is an elegant and well thought out change, thanks.

@kevingranade kevingranade merged commit 2b0df8e into CleverRaven:master Mar 8, 2020
@wapcaplet wapcaplet deleted the dedup-item-name branch March 8, 2020 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants