-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Improve display of the crafting screen header on narrow windows #56822
Improve display of the crafting screen header on narrow windows #56822
Conversation
On narrow screens (80-~120 characters wide, depending on language), the the crafting screen (&) encounters several rendering issues: 1. The information on hidden recipes will start to print over the recipe category tabs in the header. 2. On particularly narrow screens, the recipe tabs will occasionally wrap around, partially printing over the header border 3. Subcategory tabs will print over the border of the crafting screen, and on particularly narrow screens, wrap around to the next line 4. Subcategory tabs that would be printed to the right of a tab that has wrapped are not printed at all, with no indication that there are additional subcategories for the player to look at.
Yeah, I definitely should have prioritized keeping craft speed % visible on minimum window width. It should be pretty easy to do that, though it will depend on what the longest translation of "crafting is slow" is. For the disappearing crafting speed, I'm pretty sure that's an artifact of how I produced the animation, not a problem in the code. Rather than finding a way to directly record cataclysm like a sensible person, I took a screenshot at each width/position, then assembled it into an animation. Since the crafting speed indicator blinks on and off, some of my screenshots were captured while it blinked off. For the clang-tidy errors, I'll also be fixing the point_zero error once I get a chance. The select_crafting_recipe length error is a thornier issue, though Qrox's #56812 should alleviate some of the pressure there |
The crafting info panel, at minimum window size, was not wide enough for the display of crafting speed. This adds a check to ensure that the minimum width of this panel is enough to display any of the current language's crafting speed descriptions. In addition, the crafting info panel was not being properly cleared when changing recipes, meaning that, .e.g. moving from an item that can be crafted in the dark to one that cannot would result in the old "crafting is slow" message being partially visible.
@Qrox I've implemented the changes you've recommended and everything seems to be working. The only reservation I have is the refactor of draw_can_craft_indicator with a loop. I'm not sure what I've done is exactly what you had in mind, but I find the new version to be a much more daunting block of code than the original version. Also of note is that as far as I can tell, crafting_speed_multiplier(rec) will not, under any reasonable conditions, produce a value <=0.0f (too slow to craft) or >1.0f (crafting is fast), so those messages will not come up in-game (either under the original draw_can_craft_indicator or the new implementation). That's probably something that will need a separate PR, perhaps also addressing #49274. And clang-tidy has already failed with a complaint about FLT_MAX and FLT_EPSILON. Is there a preferred method for that? |
Yeah, I was mainly thinking of getting rid of the string literal keys, in hindsight it's better to just convert the keys to enums like you did.
You can use numeric_limits. |
With this last commit I've moved draw_can_craft_indicator back to a batch of if/else checks rather than the array and loop, since my loop implementation ended up being harder to read. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merged & tested locally, looks good. The only issue is the complexity limit from clang-tidy for select_crafting_recipe
, but as mentioned before that's being fixed separately.
mvwprintz( w, point( pos_x - 2, 1 ), c_light_green, "⁺" ); | ||
auto it = flagged_names.find( cat ); | ||
cata_assert( it != flagged_names.end() ); | ||
( *it ).second += "<color_green>*</color>"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason ⁺
is changed to *
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...huh.
The new version is a * because I always read the previous version as a *.
If you want a quick PR to change it back to a ⁺, let me know. I have no particular attachment to the *.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change it back to a ⁺
for consistency with the subtabs then.
Summary
Interface "Improve display of the crafting screen header on narrow windows"
Purpose of change
On narrow screens (80-~120 characters wide, depending on language), the the crafting screen (&) encounters several rendering issues:
Observe that the "Practice", "Animals", "Other", "Appliance", "Armor", and even "Electronic" tabs are progressively obscured by the discussion of hidden recipes. The "Other" subcategory also disappears as the window gets smaller.
Describe the solution
Move the recipe category tabs and the general information to separate windows to prevent overlapping.
Prior to drawing the recipe category tabs (and the subcategory subtabs), the available width is checked and the required width to display all tabs is calculated. If the full list of tabs won't fit, then the largest collection of them that a) fits, and b) contains the currently selected tab is generated. This is then drawn, complete with "<" and ">" placeholder tabs indicating if there are additional tabs to the left and right, respectively.
Describe alternatives you've considered
Ignore it:
Abbreviate crafting categories when there's insufficient space, as done in the vehicle part installation menu:
Hiding empty subcategories rather than merely using a different colour:
Move the display of hidden/new/crafting status information to a subheader
Raise the minimum screen width:
Testing
Tested in the full range of widths:
Tested scrolling through tabs in a small window:
Tested scrolling through subcategories in a small window:
Tested in several other languages. I cannot read Portuguese or Ukrainian, but it doesn't look like the changes broke anything:
Additional context