-
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
Add data-driven moddable sidebar widgets #44683
Conversation
Related issue: #23079. |
Food for thought while you're digging around in here, I would love to be able to define tiles instead of ascii characters for the sidebar. I can tell you more about my ideas if you like |
863b9dd
to
a810a5e
Compare
This will remain in WIP, probably until after 0.F, since it is a significant new feature. But I have taken off the "Draft" status - this is essentially complete and working now (with tests and documentation), well enough for others to test and review it (please do!) |
e6e23cb
to
87d07dc
Compare
You have some clang-tidy issues to deal with. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not 'bump' or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered. |
There's unreasonable amount of wasted space there, especially on small phone screens. I really hope that with this we could make an essentials-only version for compact view. |
87d07dc
to
521b667
Compare
521b667
to
7108dba
Compare
This PR is functionally complete and playable as-is; aside from some clang-tidy cleanup and occasional rebasing to keep it in sync until after 0.F, I don't plan to expand it further here. In short, I am tying a knot on this PR and have opened #47620 for further enhancements. |
d297625
to
bc57a71
Compare
Reconsidering the large size of this PR, I am thinking of breaking it up somewhat:
The initial version of the sidebar remains rudimentary (see screenshots) but the commits are fairly clean (rebased many times) so I think this is finally good to go. |
bc57a71
to
050468b
Compare
050468b
to
5cfd30d
Compare
This commit adds a `widget` class for rendering a UI view of some internal value or status variable of an `avatar` (player character). It includes a generic factory wrapper to load widgets from JSON. widget_var for linking avatar attributes to widgets: - focus, move, pain, speed, stamina, stats, HP per bodypart and more widget class to render avatar variables in UI with labels and layout: - uses generic_factory to load JSON from widget types - JSON: id, label, style, var, colors, symbols, width, fill, etc. - show() to render widget value from avatar instance - layout() to arrange widgets and do max width padding/alignment - get_var_value() to return avatar's current "var" value - color_value_string() to render value with colors - supporting: value_color(), value_string(), graph(), num()
Build on the data-driven sidebar `widget` class, defining a collection of numeric and graph display elements, including familiar as well as new informational displays: - HP bar graphs for each body part, in familiar `|||||` form - Classic and extended (10-character) stamina graph - Numeric indicators for sound, focus, pain, moves, str, dex, int, per - Encumbrance bar graphs for each body part - Warmth numbers for each body part - Wide and Narrow root layouts with basic info
Add a "Custom" sidebar section that can be toggled on for each sidebar layout (classic/labels and narrow/compact), loading from the "root_layout_wide" or "root_layout_narrow" widget.
Overview and technical docs on using the custom sidebar widgets
5cfd30d
to
37425f7
Compare
Works fine for me. I think it would make sense to move |
Summary
Features "Add data-driven moddable sidebar widgets"
Purpose of change
The right sidebar has a number of usability problems. Customizing it requires editing some rather convoluted and finicky
panel.cpp
code, which makes people (at least me) disinclined to try and improve them.But possibly the biggest problem with the right sidebar panels is how hard-coded they often are. Making the description and layout of the sidebar more data-driven will:
Describe the solution
Define a new
widget
class implementing JSON objects of type "widget", that can display:||...
,||\..
and so on)Connect these widgets to avatar attributes (HP, pain, thirst etc.) to allow generalized sidebar customization with JSON, and recreation of the existing sidebar info in data-driven form.
widget
class usinggeneric_factory
show
andlayout
with anavatar
The
}
sidebar configuration menu now includes a "Custom" section that may be added to any of the four layouts (both wide and narrow). For now, this section displays only basic info, similar to the existing builtin sidebars - HP for each body part, stamina, speed, focus, movement, sound, fatigue, STR, DEX, INT, and PER.Describe alternatives you've considered
This is pull request 1 of 2 or more. Here is the initial implementation and demonstration of concepts; it is entirely playable, though not intended as a final "production" draft.
Future PRs will build on this foundation to make it a more complete solution for information display to the player. I hope it can eventually be used to phase out the hard-coded sidebar.
Continued in #47620
Testing
Unit tests can be run with
tests/cata_test '[sidebar],[widget]'
In-game, use the
}
sidebar configurator to enable theCustom
section.Edit
data/json/sidebar.json
to customize it however you like.Additional context
Example of default "Custom" sidebar in "labels" layout mode:
And in "labels-narrow" layout mode: