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

Filter wearable items by body part in the armor layers window #45600

Merged
merged 1 commit into from
Nov 25, 2020

Conversation

Nirnael
Copy link
Contributor

@Nirnael Nirnael commented Nov 23, 2020

Summary

SUMMARY: Interface "Filter wearable items by body part in the armor layers window"

Purpose of change

The armor layers window has two buttons for equipping items, "e" and "E" where "E" equips an item at the current position marked by the cursor. It seems logical to me that if you are looking at a specific body part, you should only see clothing that covers that body part. I have modified "E" to do just that. The "e" keybind has been left untouched and shows all available wearables.

Describe the solution

wear() is called when the "E" key is pressed, and the current body part tab is passed so that it can be used to filter clothing to only that which covers that specific body part (a default null body part is used for cases where wear() is called without body parts, which is checked later in order to skip filtering).
This is done through the presets sent to inv_internal() which filter items through their is_shown(). I've modified the wear preset with a body part field which is constant and unique each time wear() is called.
Due to the default null body part and the conditional in is_shown(), this modification should have no side effects when wear() is called without specifying body parts (as it is in 2 other calls), and it is only called with body parts in the "E" key handler.

Describe alternatives you've considered

A function object approach was also possible, which would have allowed somewhat custom filtering, but I deemed it too convoluted for this purpose.
Potentially modifying the "e" key so that it filters by body part as well.
A more robust generic filtering together with sorting would have been better, but is much more complicated and left for the future.

Testing

Spawned a bunch of clothing of each body part coverage and a few with shared coverage. Works as intended and only shows the appropriate ones when in that specific body part's tab, though I did spot a few segfaults when unequipping some items, none of which is related to this.

@anothersimulacrum anothersimulacrum added [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. labels Nov 24, 2020
@kevingranade kevingranade merged commit 303ac98 into CleverRaven:master Nov 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants