-
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
Eat menu #33304
Eat menu #33304
Conversation
WIP for 'E'ating menu # Explain why this change is being made current one is clunky
fix tests/ errors
Can we get some screenshots? |
You need to astyle, and fix the build errors. |
I can see that a lot of code is simply a copy of advanced inventory code. Maybe you can use some shared functions to reduce code duplication? |
You mean by copying most of the content of "advanced_inv.cpp" and "advanced_inv.h". Any change to those files will not appear in the new menu and vice versa. This will lead to inconsistencies. It's generally not a good idea to copy that much code with little changes. |
settings are saved within a session can actually eat now
bionics have special eating menu when activated can summon crafting menu from eating menu refactoring to make it more modular, future support
fixing CBM menu showing wrong items fixing heat_up not having shortcuts
reorganizing things a little
src/comestible_inv_listitem.cpp
Outdated
menu_color = it.color_in_inventory(); | ||
|
||
// statuses | ||
const auto &comest = it.get_comestible(); |
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 assume you meant to get the edible
instead of querying it
directly here (get_edible_comestible
queries it anyway).
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 don't know what the difference is between get_edible_comestible( p, it );
and it.get_comestible();
Edible and comestible are synonyms and it's not documented which function I should use when.
This code is copied from different places, so not sure what it actually needs to be. The functions seem different on the inside, so I don't know the consequences if we just replace comest
with edible
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 don't know what the difference is between
Than look at the source of their implementation.
This code is copied from different places,
Copying code without understanding what it does (or even why it does it) is dangerous.
get_comestible
returns an optional value, dereferencing the optional (as you do below viacomest->
) will cause UB when it does not actually contain a value. Your code does not check this, it just dereferences in the assumption that it will always contain a value. That leads to a crash when encountering non-food items (wherecomest
is empty).
get_edible_comestible
(which looks like a straight copy from "game_inventory.cpp", which is bad on its own) checks for the optional value being empty and returns a dummy value in that case.
Btw. this has nothing to do with edible vs comestible.
3500+ lines of mostly copy-pasted code for a new non-generic menu (in addition to the existing ones) shoved into a single PR? I'd say it's a no-go. |
Ok, let's start with the problem - inventory-type menus are bad (no sorting, grouping by location is generally useless, no QOL features) |
That is not how that works, writing all-new code is easier, but it's also massively riskier. You've identified issues you have with the existing code, but I guarantee that the new code has it's own issues, if nothing else missing features compared to the old code. The only sure way to prevent this is to incrementally adjust the existing code over time so that bugs and feature omissions are easier to spot and correct. Cleaning up the advanced inventory code is something we would love soneone to tackle. |
True |
@@ -0,0 +1,104 @@ | |||
#pragma once | |||
#ifndef comestible_inv_H |
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.
#ifndef comestible_inv_H | |
#ifndef COMESTIBLE_INV_H |
@@ -0,0 +1,104 @@ | |||
#pragma once | |||
#ifndef comestible_inv_H | |||
#define comestible_inv_H |
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.
#define comestible_inv_H | |
#define COMESTIBLE_INV_H |
@@ -14,6 +15,6 @@ void remove_ammo( item &dis_item, player &p ); | |||
// same as above but for each item in the list | |||
void remove_ammo( std::list<item> &dis_items, player &p ); | |||
|
|||
const recipe *select_crafting_recipe( int &batch_size ); | |||
const recipe *select_crafting_recipe( int &batch_size, const std::string &filter = "" ); |
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.
const recipe *select_crafting_recipe( int &batch_size, const std::string &filter = "" ); | |
const recipe *select_crafting_recipe( int &batch_size, const std::string &filter ); |
@@ -1424,7 +1424,7 @@ class player : public Character | |||
* Start various types of crafts | |||
* @param loc the location of the workbench. tripoint_zero indicates crafting from inventory. | |||
*/ | |||
void craft( const tripoint &loc = tripoint_zero ); | |||
void craft( const tripoint &loc = tripoint_zero, const std::string &filter = "" ); |
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.
void craft( const tripoint &loc = tripoint_zero, const std::string &filter = "" ); | |
void craft( const tripoint &loc = tripoint_zero, const std::string &filter ); |
|
||
eat_error = p.can_eat( it ); | ||
|
||
exipres_in = ""; |
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.
exipres_in = ""; | |
exipres_in.clear(); |
eat_error = p.can_eat( it ); | ||
|
||
exipres_in = ""; | ||
shelf_life = ""; |
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.
shelf_life = ""; | |
shelf_life.clear(); |
{ | ||
//Function is overriden in children. Code is to supress warnings/errors. | ||
if( col == 0 ) { | ||
print_str = ""; |
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.
print_str = ""; | |
print_str.clear(); |
{ | ||
//Function is overriden in children. Code is to supress warnings/errors. | ||
if( col == 0 ) { | ||
print_str = ""; |
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.
print_str = ""; | |
print_str.clear(); |
} | ||
print_str = string_format( "%4d", stacks ); | ||
} else { | ||
print_str = ""; |
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.
print_str = ""; | |
print_str.clear(); |
string_format = "%d"; | ||
} else { | ||
print_color = need_highlight ? c_yellow : c_dark_gray; | ||
string_format = ""; |
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.
string_format = ""; | |
string_format.clear(); |
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. |
This large scale overhaul isn't going to happen in one shot, the options are incremental change or stick with the status quo. |
Summary
SUMMARY: Interface "Replacing 'E'ating menu with a better one"
Purpose of change
Current menu is clunky and lacks QOL features
Describe the solution
Base the menu off of advancved inventory, so we get targeting, sorting and filtering for free
Ability to toggle between Food, Drugs - technically can filter with 'c:' but it's too many button presses
CBM opens eating menu when turned on
Add ability to warm up food from the menu
Add ability to cook using current ingredient from the menu
Describe alternatives you've considered
I think creating new menu is easier than adding all these features to current one, because current is generic code, shared between multiple menus.
Additional context
Large + help page
Small + mutation error
Furance menu + sorting