-
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
Bodypart status widget: Symbols + Legend #54531
Merged
kevingranade
merged 7 commits into
CleverRaven:master
from
dseguin:widget_bp_status_syms
Jan 21, 2022
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a8b987b
BP Status Widget: Add symbols and legend widgets
dseguin 4647af1
BP Status Widget: Restore bool defs for status conditions
dseguin 427a23e
BP Status Widget: Use phrases to define text, symbols and color
dseguin 0673d44
BP Status Widget: Dynamically adjust height of status legend
dseguin e6bf520
BP Status Widget: Extract "text" strings for translation
dseguin 98c4da3
BP Status Widget: Update tests to use new data format
dseguin 2f5ece6
BP Status Widget: Add unit tests for compact status widget
dseguin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Although the base style is "phrase", the copy has style "text", and it still works OK right?
If so, there may be no need for a separate "phrase" style; we should just use "text" for all of them.
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.
Yeah,
copy-from
will overwrite the style with whatever you give it. You can put anything in thestyle
field, really. And thedisplay
function can decide how to interpret it if it detects that the widget has aphrases
array.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.
Hangon, I think I know why I got confused, and I hope you'll indulge me a lengthy explanation because I just realized it's an important oversight in the widget implementation.
There's something in the widget class that I stuck there as part of my original idea for phrase widgets, but which is basically dead code. It's this
widget::text
function, invoked bywidget::value_string
for "text" style widgets.Cataclysm-DDA/src/widget.cpp
Lines 765 to 768 in 62a046c
My thinking back then was to define a field something like
"strings": [ "Peckish", "Hungry", "Ravenous" ]
, and these strings would be mapped to 0, 1, 2 - as returned by some (still mythical) function that yielded a simple numerical progression. It's even defined in the header, and the first thing read in at the top ofwidget::load
:Cataclysm-DDA/src/widget.h
Lines 159 to 160 in 62a046c
Cataclysm-DDA/src/widget.cpp
Lines 223 to 225 in 62a046c
But
widget::text
is never invoked, becausewidget::show
circumventscolor_value_string
for any widget that matchesuses_text_function
- in other words all the*_text
widgets I've defined since then, because it was just easier that way.Cataclysm-DDA/src/widget.cpp
Lines 409 to 411 in 62a046c
Now, I like the
"phrases"
data structure a lot better than a naked list of"strings"
, but this may be the opportunity to hook up thatwidget::text
function for the dynamic rendering it was always destined for. All the dirty work is already done by yourwidget_phrase
class. Would it be feasible to hook into place, you think?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.
Absolutely. I can connect the dots in a follow-up PR. It will probably pave the way for #54585.
That's a great idea, and along the lines of what I'd like to do as well. It could work like a convenience function to wrap around the phrase functions.
My thought for
widget_phrase
was a simple container for fields, which are accessed via static methods:The widget functions could wrap these for convenience. The main reason I'm using static accessors for
widget_phrase
is because I wanted to avoid passing the widget itself to thedisplay
functions.