Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign up[RDY] Customize Consume Item menu #20676
Conversation
codemime
added some commits
Mar 10, 2017
codemime
changed the title
[CR] Customize Consume menu
[CR] Customize Consume Item menu
Mar 26, 2017
Coolthulhu
reviewed
Mar 26, 2017
| @@ -215,191 +227,157 @@ morale_type player::allergy_type( const item &food ) const | |||
| return MORALE_NULL; | |||
| } | |||
|
|
|||
| bool player::is_allergic( const item &food ) const | |||
| edible_rating player::can_eat( const item &food, std::string *err ) const | |||
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Mar 26, 2017
Contributor
The interface would be cleaner if the return value included the error - return by parameter is C-ish.
For example, if you returned it as a const std::pair<edible_rating, std::string> &.
This comment has been minimized.
This comment has been minimized.
codemime
Mar 26, 2017
•
Author
Member
The interface would be cleaner if the return value included the error - return by parameter is C-ish.
Agreed. For now, I've simply repeated the signature of player::can_eat
For example, if you returned it as a const std::pair<edible_rating, std::string> &
I was thinking about that too and came up with a template class. Something like this:
template<typename T = bool, T no_error = true, T default_error = false>
class ret_val
{
public:
static_assert( no_error != default_error, "Error codes must differ." );
ret_val() = delete;
static ret_val success( const std::string &msg = std::string() ) {
return ret_val( no_error, msg );
}
static ret_val failure( T code = default_error, const std::string &msg = std::string() ) {
return ret_val( default_error, msg );
}
operator bool() const {
return code == no_error;
}
T operator *() const {
return code;
}
const std::string &str() const {
return msg;
}
const char *c_str() const {
return msg.c_str();
}
protected:
ret_val( T code, const std::string &msg ) : code( code ), msg( msg ) {}
private:
std::string msg;
T code;
};
I think this should be done in a separate PR for all related cases.
This comment has been minimized.
This comment has been minimized.
|
I'm not sure if that sorting is a good idea, at least not without a way to turn it off. Is there a different item menu that is sorted by default? If not, this one should only be sorted once the player presses some sort/filter button. |
This comment has been minimized.
This comment has been minimized.
Neither am I. That's mostly why I put the CR tag.
They'd be more stable if sorted by NUTRITION only. Or even solely by freshness/spoilage (as an extreme). I do think that the latter is a good idea.
Gunmod menu is sorted using the installation odds.
As for now, there's no way we can toggle sorting. This probably needs to be implemented. |
Coolthulhu
self-assigned this
Mar 27, 2017
This comment has been minimized.
This comment has been minimized.
|
The display is generally fine on a sane setting, but our defaults are not sane: at 80 screen width, the new display columns force inventory columns (from map, from vehicle etc.) below the inventory ones, halving the number of items displayed. If not, I'll wait for others to approve. It's fine by me, but not necessarily for everyone else. As for the smart sorting: One thing could really help with everything here: |
Coolthulhu
removed their assignment
Mar 27, 2017
This comment has been minimized.
This comment has been minimized.
Doable, but I doubt that makes sense. Long rows would either overlap each other or simply won't fit. BTW I didn't change column management in this PR.
That would be equally painful with lists sorted alphabetically, but the option is an option.
I thought about that too and I'm going to implement that. |
Leland
referenced this pull request
May 9, 2017
Closed
Add item description in consume (shift+e) menu #20617
codemime
added some commits
Jul 23, 2017
This comment has been minimized.
This comment has been minimized.
|
I have resolved the merge conflict and removed all additional sorting except by freshness. |
codemime
requested a review
from
Coolthulhu
Jul 23, 2017
Coolthulhu
reviewed
Jul 27, 2017
| if( food.rotten() ) { | ||
| const bool saprovore = has_trait( trait_id( "SAPROVORE" ) ); | ||
| if( !saprophage && !saprovore ) { | ||
| consequences.emplace_back( ROTTEN, _( "This is rotten an smells awful!" ) ); |
This comment has been minimized.
This comment has been minimized.
Coolthulhu
reviewed
Jul 27, 2017
| if( has_active_mutation( trait_id( "HIBERNATE" ) ) ) { | ||
| if( ( get_hunger() >= -60 && get_thirst() >= -60 ) && | ||
| ( temp_hunger < -60 || temp_thirst < -60 ) ) { | ||
| consequences.emplace_back( TOO_FULL, _( "You're adequately fueled. Prepare for hibernation?" ) ); |
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Jul 27, 2017
Contributor
What will be the context of this message?
You removed questions from other messages, why not this one?
This comment has been minimized.
This comment has been minimized.
Coolthulhu
reviewed
Jul 27, 2017
| req << _( "Consume anyway?" ); | ||
|
|
||
| if( !query_yn( "%s", req.str().c_str() ) ) { | ||
| return res; |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
codemime
Jul 29, 2017
•
Author
Member
It does matter mostly for the colors in the inventory menu. Another option is choosing the most severe out of multiple choices.
This comment has been minimized.
This comment has been minimized.
codemime
Jul 29, 2017
•
Author
Member
I have reordered the consequences by severity (the order is arguable):
| Type | Consequences |
|---|---|
| Rotten | Food poisoning, health damage |
| Cannibalism | Long lasting morale penalty |
| Nausea | Losing eaten food, hunger, thirst, morale penalty |
| Allergy | Morale penalty that lasts half as long as for cannibalism |
| Too full | Risk of sudden vomiting |
| Won't eat | No ill effects |
Coolthulhu
reviewed
Jul 27, 2017
| edible_rating can_eat( const item &food, bool interactive = false, | ||
| bool force = false ) const; | ||
|
|
||
| /** The food can be (theoretically) eaten. No matter the consquences. */ |
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Jul 27, 2017
Contributor
Is this regarding the return value?
Would be cleaner with "Can" in front.
Coolthulhu
referenced this pull request
Jul 29, 2017
Merged
[QOL] Add dynamic hint to inventory selector #21508
codemime
added some commits
Jul 29, 2017
Coolthulhu
self-assigned this
Jul 30, 2017
This comment has been minimized.
This comment has been minimized.
|
That prompt for "really burn x for energy" is really annoying. I assume it is to prevent burning weapons and such, but this needs to be special cased for "quality" items, otherwise it will lead to common annoyance to prevent a rare edge case. Also double prompt when eating something burnable for fuel that is edible. Double Y/N queries (other than "are you really, really sure? this will probably have horrible results") are pretty much always wrong and can only ever be lesser evil, not the proper solution. When the furnace is turned on, burnable food containers are colored as if inedible. |
Coolthulhu
removed their assignment
Jul 30, 2017
This comment has been minimized.
This comment has been minimized.
|
Also a bug, but I'm not sure if it's introduced here:
This will result in "Too big to pick up", even though you are trying to eat them, not hold them in the inventory. |
codemime
added some commits
Jul 30, 2017
This comment has been minimized.
This comment has been minimized.
|
Fails bionic test:
|
This comment has been minimized.
This comment has been minimized.
|
The test was failing because it's assumed that discharged batteries can still be used to recharge the power storage. Seems quite impossible to reproduce with the |
codemime
changed the title
[CR] Customize Consume Item menu
[RDY] Customize Consume Item menu
Aug 2, 2017
This comment has been minimized.
This comment has been minimized.
|
All set. |
codemime commentedMar 26, 2017
•
edited
Follows #19952 and #18681.
Overview
The usable information and various reasons why you can't consume stuff are shown.

CBMs that turn items into energy became more UI friendly:


All the "queries" are now asked at once. No more annoying repetition of "Really eat that?":

"Smart" sorting order:

If you're thirsty, food gets sorted by QUENCH, otherwise by NUTRITION.Then by what remains (either NUTRITION or QUENCH).Then by JOY.Then by ENERGY (in case of active CBMs).