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

Added unified_inventory_enable_item_names option #235

Merged
merged 7 commits into from
Oct 15, 2023

Conversation

fmmaks666
Copy link

Added option to disable Item Names.

Purpose of change

This change allows players to disable item names, addressing the issue of long item descriptions taking up too much screen space in certain mods (e.g., ranged weapons).

Alternative solution

Show only first line of Item's description

init.lua Outdated Show resolved Hide resolved
Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
@SmallJoker
Copy link
Member

SmallJoker commented Oct 1, 2023

For clarification: is this fix only to work around long descriptions? If so, you could still preserve the name HUD but perform a string length check to then shorten the description to the first line and first (e.g.) 50 characters.

EDIT: In case overlaps with other HUD elements are an issue, it might make sense (in regard to #135) to take other mods into account to place the item name element in a better position.

@fmmaks666
Copy link
Author

This change is a small addition to the customization. Well, item names are sometimes useful, so I'll try to implement a fix for them as soon as possible.

// It's not related to #135.

Added:
- Show only names settings: in case of multi-line descriptions, only the first line is shown
- Shorten long descriptions: Removes all characters after x index, and add `[...]`
- Max length before truncation: x for Shorten long descriptions
Notes:
- If Max length == 0, then item names won't be displayed
@fmmaks666
Copy link
Author

Added option to show only first line of item's description, option to truncate item's description if its too long.
Before:
screenshot_20231001_173829
After:
screenshot_20231001_173905
Before:
screenshot_20231001_174034
After (Max length can be changed):
screenshot_20231001_174053
Also:
screenshot_20231001_174410
Before on Mobile:
Screenshot_20231001-174829
After on Mobile:
Screenshot_20231001-174858
Sorry for Image spam...

item_names.lua Outdated Show resolved Hide resolved
item_names.lua Outdated Show resolved Hide resolved
Contains bug:
- minetest.strip_colors() does not removes `@default)`
@SmallJoker
Copy link
Member

FYI: \x1B(T@default) indicates a translation, where default is the textdomain. If you want to it 100% properly, you could use minetest.get_translated_string on the item description before cropping it (using a cached per-player language value from minetest.get_player_information().

Unfortunately I cannot find any helper function to strip translation marks. Not handling them might however cause visual errors or warnings on the client.

item_names.lua Outdated Show resolved Hide resolved
Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
@SmallJoker
Copy link
Member

Thanks. Works. Will merge in a few days unless there are objections.

@SmallJoker SmallJoker merged commit 43c9b50 into minetest-mods:master Oct 15, 2023
1 check passed
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.

None yet

2 participants