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

Interface: Newcharacter - show proficiencies and other changes (UPDATED) #44532

Merged
merged 7 commits into from
Oct 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions data/raw/keybindings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,13 @@
"name": "Reroll Random Character With Scenario",
"bindings": [ { "input_method": "keyboard_char", "key": "^" }, { "input_method": "keyboard_code", "key": "6", "mod": [ "shift" ] } ]
},
{
"type": "keybinding",
"id": "RANDOMIZE_CHAR_NAME",
"category": "NEW_CHAR_DESCRIPTION",
"name": "Pick random character name",
"bindings": [ { "input_method": "keyboard_any", "key": "n" } ]
},
{
"type": "keybinding",
"id": "RANDOMIZE_CHAR_DESCRIPTION",
Expand Down
81 changes: 64 additions & 17 deletions src/newcharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1485,8 +1485,10 @@ tab_direction set_profession( avatar &u, points_left &points,
std::string buffer;
// Profession addictions
const auto prof_addictions = sorted_profs[cur_id]->addictions();
if( !prof_addictions.empty() ) {
buffer += colorize( _( "Addictions:" ), c_light_blue ) + "\n";
buffer += colorize( _( "Addictions:" ), c_light_blue ) + "\n";
if( prof_addictions.empty() ) {
buffer += pgettext( "set_profession_addictions", "None" ) + std::string( "\n" );
} else {
for( const addiction &a : prof_addictions ) {
const char *format = pgettext( "set_profession_addictions", "%1$s (%2$d)" );
buffer += string_format( format, addiction_name( a ), a.intensity ) + "\n";
Expand All @@ -1495,17 +1497,21 @@ tab_direction set_profession( avatar &u, points_left &points,

// Profession traits
const auto prof_traits = sorted_profs[cur_id]->get_locked_traits();
if( !prof_traits.empty() ) {
buffer += colorize( _( "Profession traits:" ), c_light_blue ) + "\n";
buffer += colorize( _( "Profession traits:" ), c_light_blue ) + "\n";
if( prof_traits.empty() ) {
buffer += pgettext( "set_profession_trait", "None" ) + std::string( "\n" );
} else {
for( const auto &t : prof_traits ) {
buffer += mutation_branch::get_name( t ) + "\n";
}
}

// Profession skills
const auto prof_skills = sorted_profs[cur_id]->skills();
if( !prof_skills.empty() ) {
buffer += colorize( _( "Profession skills:" ), c_light_blue ) + "\n";
buffer += colorize( _( "Profession skills:" ), c_light_blue ) + "\n";
if( prof_skills.empty() ) {
buffer += pgettext( "set_profession_skill", "None" ) + std::string( "\n" );
} else {
for( const auto &sl : prof_skills ) {
const char *format = pgettext( "set_profession_skill", "%1$s (%2$d)" );
buffer += string_format( format, sl.first.obj().name(), sl.second ) + "\n";
Expand Down Expand Up @@ -1551,11 +1557,12 @@ tab_direction set_profession( avatar &u, points_left &points,
std::sort( begin( prof_CBMs ), end( prof_CBMs ), []( const bionic_id & a, const bionic_id & b ) {
return a->activated && !b->activated;
} );
if( !prof_CBMs.empty() ) {
buffer += colorize( _( "Profession bionics:" ), c_light_blue ) + "\n";
buffer += colorize( _( "Profession bionics:" ), c_light_blue ) + "\n";
if( prof_CBMs.empty() ) {
buffer += pgettext( "set_profession_bionic", "None" ) + std::string( "\n" );
} else {
for( const auto &b : prof_CBMs ) {
const auto &cbm = b.obj();

if( cbm.activated && cbm.has_flag( "BIONIC_TOGGLED" ) ) {
buffer += string_format( _( "%s (toggled)" ), cbm.name ) + "\n";
} else if( cbm.activated ) {
Expand All @@ -1568,25 +1575,31 @@ tab_direction set_profession( avatar &u, points_left &points,
// Proficiencies
const std::string newline = "\n";
std::vector<proficiency_id> prof_proficiencies = sorted_profs[cur_id]->proficiencies();
if( !prof_proficiencies.empty() ) {
buffer += colorize( _( "Profession proficiencies:" ), c_light_blue ) + newline;
buffer += colorize( _( "Profession proficiencies:" ), c_light_blue ) + newline;
if( prof_proficiencies.empty() ) {
buffer += pgettext( "Profession has no proficiencies", "None" ) + newline;
} else {
for( const proficiency_id &prof : prof_proficiencies ) {
buffer += prof->name() + newline;
}
}
// Profession pet
if( !sorted_profs[cur_id]->pets().empty() ) {
buffer += colorize( _( "Pets:" ), c_light_blue ) + "\n";
buffer += colorize( _( "Pets:" ), c_light_blue ) + "\n";
if( sorted_profs[cur_id]->pets().empty() ) {
buffer += pgettext( "set_profession_pets", "None" ) + std::string( "\n" );
} else {
for( const auto &elem : sorted_profs[cur_id]->pets() ) {
monster mon( elem );
buffer += mon.get_name() + "\n";
}
}
// Profession vehicle
buffer += colorize( _( "Vehicle:" ), c_light_blue ) + "\n";
if( sorted_profs[cur_id]->vehicle() ) {
buffer += colorize( _( "Vehicle:" ), c_light_blue ) + "\n";
vproto_id veh_id = sorted_profs[cur_id]->vehicle();
buffer += veh_id->name.translated();
} else {
buffer += pgettext( "set_profession_vehicle", "None" ) + std::string( "\n" );
}
// Profession spells
if( !sorted_profs[cur_id]->spells().empty() ) {
Expand All @@ -1595,6 +1608,7 @@ tab_direction set_profession( avatar &u, points_left &points,
buffer += string_format( _( "%s level %d" ), spell_pair.first->name, spell_pair.second ) + "\n";
}
}

const auto scroll_msg = string_format(
_( "Press <color_light_green>%1$s</color> or <color_light_green>%2$s</color> to scroll." ),
ctxt.get_desc( "LEFT" ),
Expand Down Expand Up @@ -2420,6 +2434,7 @@ tab_direction set_description( avatar &you, const bool allow_reroll,
catacurses::window w_stats;
catacurses::window w_traits;
catacurses::window w_bionics;
catacurses::window w_proficiencies;
catacurses::window w_addictions;
catacurses::window w_scenario;
catacurses::window w_profession;
Expand All @@ -2438,6 +2453,7 @@ tab_direction set_description( avatar &you, const bool allow_reroll,
w_stats = catacurses::newwin( 6, 20, point( 2, 9 ) );
w_traits = catacurses::newwin( TERMY - 10, 24, point( 22, 9 ) );
w_bionics = catacurses::newwin( TERMY - 10, TERMX - 92, point( 90, 9 ) );
w_proficiencies = catacurses::newwin( TERMY - 20, 20, point( 2, 15 ) );
w_scenario = catacurses::newwin( 1, 40, point( 46, 9 ) );
w_profession = catacurses::newwin( 1, 40, point( 46, 10 ) );
w_skills = catacurses::newwin( TERMY - 12, 40, point( 46, 11 ) );
Expand All @@ -2455,6 +2471,7 @@ tab_direction set_description( avatar &you, const bool allow_reroll,
input_context ctxt( "NEW_CHAR_DESCRIPTION" );
ctxt.register_cardinal();
ctxt.register_action( "SAVE_TEMPLATE" );
ctxt.register_action( "RANDOMIZE_CHAR_NAME" );
ctxt.register_action( "RANDOMIZE_CHAR_DESCRIPTION" );
ctxt.register_action( "CHANGE_GENDER" );
ctxt.register_action( "PREV_TAB" );
Expand Down Expand Up @@ -2626,6 +2643,19 @@ tab_direction set_description( avatar &you, const bool allow_reroll,
}
wnoutrefresh( w_bionics );

werase( w_proficiencies );
// Proficiencies description tab
std::vector<proficiency_id> prof_proficiencies = you.prof->proficiencies();
mvwprintz( w_proficiencies, point_zero, COL_HEADER, _( "Proficiencies:" ) );
if( prof_proficiencies.empty() ) {
wprintz( w_proficiencies, c_light_red, _( "\nNone!" ) );
} else {
for( const proficiency_id &prof : prof_proficiencies ) {
wprintz( w_proficiencies, c_light_gray, "\n" + prof->name() );
}
}
wnoutrefresh( w_proficiencies );

// Helptext description window
fold_and_print( w_guide, point( 0, getmaxy( w_guide ) - 9 ), ( TERMX ), c_light_gray,
_( "Press <color_light_green>%s</color> to view and alter keybindings." ),
Expand All @@ -2637,15 +2667,19 @@ tab_direction set_description( avatar &you, const bool allow_reroll,

if( !MAP_SHARING::isSharing() && allow_reroll ) { // no random names when sharing maps
fold_and_print( w_guide, point( 0, getmaxy( w_guide ) - 7 ), ( TERMX ), c_light_gray,
_( "Press <color_light_green>%s</color> to randomize description values, "
_( "Press <color_light_green>%s</color> to pick a random name, "
"<color_light_green>%s</color> to randomize all description values, "
"<color_light_green>%s</color> to randomize all but scenario or "
"<color_light_green>%s</color> to randomize everything." ),
ctxt.get_desc( "RANDOMIZE_CHAR_NAME" ),
ctxt.get_desc( "RANDOMIZE_CHAR_DESCRIPTION" ),
ctxt.get_desc( "REROLL_CHARACTER" ),
ctxt.get_desc( "REROLL_CHARACTER_WITH_SCENARIO" ) );
} else {
fold_and_print( w_guide, point( 0, getmaxy( w_guide ) - 7 ), ( TERMX ), c_light_gray,
_( "Press <color_light_green>%s</color> to randomize description values." ),
_( "Press <color_light_green>%s</color> to pick a random name, "
"<color_light_green>%s</color> to randomize all description values." ),
ctxt.get_desc( "RANDOMIZE_CHAR_NAME" ),
ctxt.get_desc( "RANDOMIZE_CHAR_DESCRIPTION" ) );
}

Expand Down Expand Up @@ -2703,16 +2737,24 @@ tab_direction set_description( avatar &you, const bool allow_reroll,
const vproto_id scen_veh = get_scenario()->vehicle();
const vproto_id prof_veh = you.prof->vehicle();
if( scen_veh ) {
mvwprintz( w_vehicle, point_zero, c_light_gray, _( "Starting vehicle (scenario): " ) );
wprintz( w_vehicle, c_white, "%s", scen_veh->name );
} else if( prof_veh ) {
mvwprintz( w_vehicle, point_zero, c_light_gray, _( "Starting vehicle (profession): " ) );
wprintz( w_vehicle, c_white, "%s", prof_veh->name );
} else {
mvwprintz( w_vehicle, point_zero, c_light_gray, _( "Starting vehicle: " ) );
wprintz( w_vehicle, c_light_red, _( "None!" ) );
}
wnoutrefresh( w_vehicle );

werase( w_addictions );
// Profession addictions description tab
const auto prof_addictions = you.prof->addictions();
if( !prof_addictions.empty() ) {
if( prof_addictions.empty() ) {
mvwprintz( w_addictions, point_zero, c_light_gray, _( "Starting addictions: " ) );
wprintz( w_addictions, c_light_red, _( "None!" ) );
} else {
mvwprintz( w_addictions, point_zero, c_light_gray, _( "Starting addictions: " ) );
for( const addiction &a : prof_addictions ) {
const char *format = "%1$s (%2$d) ";
Expand Down Expand Up @@ -2890,6 +2932,11 @@ tab_direction set_description( avatar &you, const bool allow_reroll,
if( const auto name = query_for_template_name() ) {
you.save_template( *name, points );
}
} else if( action == "RANDOMIZE_CHAR_NAME" ) {
if( !MAP_SHARING::isSharing() ) { // Don't allow random names when sharing maps. We don't need to check at the top as you won't be able to edit the name
you.pick_name();
no_name_entered = you.name.empty();
}
} else if( action == "RANDOMIZE_CHAR_DESCRIPTION" ) {
you.male = one_in( 2 );
if( !MAP_SHARING::isSharing() ) { // Don't allow random names when sharing maps. We don't need to check at the top as you won't be able to edit the name
Expand Down