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

Add description widgets for pain, thirst, fatigue, weight, hunger and more #50945

Merged
merged 9 commits into from
Aug 28, 2021

Conversation

wapcaplet
Copy link
Contributor

@wapcaplet wapcaplet commented Aug 21, 2021

Summary

Features "Add description widgets for pain, thirst, fatigue, weight, hunger"

Purpose of change

Make the custom sidebar more capable of displaying useful information.

Describe the solution

Build on #44683 adding new "var" (widget_var) values:

  • hunger_text showing display::hunger_text_color
  • thirst_text showing display::thirst_text_color
  • pain_text showing display::pain_text_color
  • fatigue_text showing display::fatigue_text_color
  • weight_text showing display::weight_text_color
  • weariness_text showing display::weariness_text_color
  • wielding_text showing avatar.weapname
  • style_text showing avatar.martial_arts_data->selected_style_name
  • date_text showing calendar::name_season and day_of_season
  • place_text showing avatar location from overmap buffer get_name

Add some notes to doc/SIDEBAR_MOD.md for using "text" style variables, with a few examples.

Depends on #50972

Describe alternatives you've considered

Would still like to add a few test cases and some documentation on these. May also include weariness_description.

Testing

Playing game with widgets added to custom sidebar, values and colors match original sidebar displays.

Additional context

Below is a sample of how the widgets are displayed, if they are simply added to the root layout in data/json/ui/sidebar.json, ex.:

  {
    "id": "root_layout_wide",
    "type": "widget",
    "style": "layout",
    "arrange": "rows",
    "widgets": [
      "hunger_desc",
      "thirst_desc",
      "pain_desc",
      "fatigue_desc",
      "weight_desc",
      "weariness_desc",
      "wielding_desc",
      "style_desc",
      "date_desc",
      "place_desc"
    ]
  },

Wide layout:

image

Narrow layout:

image

@actual-nh actual-nh added <Enhancement / Feature> New features, or enhancements on existing [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Info / User Interface Game - player communication, menus, etc. Mechanics: Character / Player Character / Player mechanics labels Aug 21, 2021
@wapcaplet
Copy link
Contributor Author

I have a somewhat more urgent refactoring to remove about 200 lines of get_*_description functions from character.cpp into panels.cpp - mostly the functions this PR depends on - so I will leave this in draft until that one can be submitted and applied.

@wapcaplet wapcaplet force-pushed the w-desc-widgets branch 2 times, most recently from 0fa18c8 to b350598 Compare August 28, 2021 00:11
@wapcaplet wapcaplet changed the title Add description widgets for pain, thirst, fatigue, weight, hunger Add description widgets for pain, thirst, fatigue, weight, hunger and more Aug 28, 2021
Add several `xx_text` widget variables associated with "text color
functions", which are functions in the panels.h `display` namespace
returning a (text, color) pair for the description strings of the pain,
hunger, thirst, fatigue, and weight attributes.
Add phrase widgets which may be added to custom sidebar layouts or to
the root layout widget.
The word "phrase" is a little awkward; "text" fits better conceptually
with "number" and "graph".

Include comments on the intention of text functions vs normal widgets.
Gives cleaner-looking results, especially when value is empty
Also add a weariness_text_color wrapper accepting a Character reference,
to simplify usage, and provide a pair( std::string, nc_color ) response
like its kin.
For showing wielded weapon and martial arts style
@wapcaplet wapcaplet marked this pull request as ready for review August 28, 2021 19:08
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` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style <Enhancement / Feature> New features, or enhancements on existing Info / User Interface Game - player communication, menus, etc. Mechanics: Character / Player Character / Player mechanics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants