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

Make constructions in progress display the progress percentage. #36020

Merged
merged 3 commits into from
Dec 15, 2019

Conversation

ishtatann
Copy link
Contributor

@ishtatann ishtatann commented Dec 11, 2019

Summary

SUMMARY: Interface "Make constructions in progress display the progress percentage."

Purpose of change

Small display change to show percentage of completion for construction tasks.

Describe the solution

Updated player_activity::get_progress_message to get the counter from the partial construction being worked on.

Testing

Loaded up a game and made a charcoal kiln - verified the progress display includes the percentage now.

@AMurkin
Copy link
Contributor

AMurkin commented Dec 11, 2019

This project has a specific code style. See doc/CODE_STYLE.md.

@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` Crafting / Construction / Recipes Includes: Uncrafting / Disassembling Info / User Interface Game - player communication, menus, etc. labels Dec 11, 2019
@ishtatann ishtatann force-pushed the construction-progress branch from a31ca01 to 3cb822b Compare December 11, 2019 13:13
@@ -104,8 +105,20 @@ cata::optional<std::string> player_activity::get_progress_message( const avatar
type == activity_id( "ACT_CHOP_LOGS" ) ||
type == activity_id( "ACT_CHOP_PLANKS" )
) {
const int percentage = ( ( moves_total - moves_left ) * 100 ) / moves_total;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const int percentage = ( ( moves_total - moves_left ) * 100 ) / moves_total;
const int percentage = ( moves_total - moves_left ) * 100 / moves_total;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just moved this line I didn't add any additional parens.
Also, I prefer the explicit parens to the implicit depending on the order of operations.

if( type == activity_id( "ACT_BUILD" ) ) {
partial_con *pc = g->m.partial_con_at( g->m.getlocal( u.activity.placement ) );
if( pc ) {
int counter = std::min( pc->counter, 10000000 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why the next variable is const, bu this one isn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original percentage line above was const. I just copied that line and modified it.

I'm not a huge fan of const'ing everything under the sun so don't typically add it to variables I declare.

@kevingranade kevingranade merged commit 4f96665 into CleverRaven:master Dec 15, 2019
@ishtatann ishtatann deleted the construction-progress branch December 15, 2019 03:25
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` Crafting / Construction / Recipes Includes: Uncrafting / Disassembling Info / User Interface Game - player communication, menus, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants