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 option to toggle display of trait/mutation on player sprite #52058

Merged
merged 1 commit into from
Oct 4, 2021
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 @@ -2737,6 +2737,13 @@
"name": "Reassign invlet",
"bindings": [ { "input_method": "keyboard_any", "key": "=" } ]
},
{
"type": "keybinding",
"id": "TOGGLE_SPRITE",
"category": "MUTATIONS",
"name": "Toggle sprite",
"bindings": [ { "input_method": "keyboard_any", "key": "," } ]
},
{
"type": "keybinding",
"id": "UP",
Expand Down
3 changes: 3 additions & 0 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2705,6 +2705,9 @@ std::vector<std::pair<std::string, std::string>> Character::get_overlay_ids() co

// then get mutations
for( const std::pair<const trait_id, trait_data> &mut : my_mutations ) {
if( !mut.second.show_sprite ) {
continue;
}
overlay_id = ( mut.second.powered ? "active_" : "" ) + mut.first.str();
order = get_overlay_order_of_mutation( overlay_id );
mutation_sorting.insert( std::pair<int, std::string>( order, overlay_id ) );
Expand Down
3 changes: 3 additions & 0 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -3127,6 +3127,9 @@ class Character : public Creature, public visitable
* is reset to @ref mutation_branch::cooldown.
*/
int charge = 0;

bool show_sprite = true;

void serialize( JsonOut &json ) const;
void deserialize( const JsonObject &data );
};
Expand Down
17 changes: 17 additions & 0 deletions src/mutation_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ enum class mutation_menu_mode : int {
activating,
examining,
reassigning,
hidding,
};

static void show_mutations_titlebar( const catacurses::window &window,
Expand All @@ -62,9 +63,14 @@ static void show_mutations_titlebar( const catacurses::window &window,
c_light_blue ) + " " + shortcut_desc( _( "%s to activate mutation, " ),
ctxt.get_desc( "TOGGLE_EXAMINE" ) );
}
if( menu_mode == mutation_menu_mode::hidding ) {
desc += colorize( _( "Hidding" ), c_cyan ) + " " + shortcut_desc( _( "%s to activate mutation, " ),
ctxt.get_desc( "TOGGLE_EXAMINE" ) );
}
if( menu_mode != mutation_menu_mode::reassigning ) {
desc += shortcut_desc( _( "%s to reassign invlet, " ), ctxt.get_desc( "REASSIGN" ) );
}
desc += shortcut_desc( _( "%s to toggle sprite visibility, " ), ctxt.get_desc( "TOGGLE_SPRITE" ) );
desc += shortcut_desc( _( "%s to change keybindings." ), ctxt.get_desc( "HELP_KEYBINDINGS" ) );
// NOLINTNEXTLINE(cata-use-named-point-constants)
fold_and_print( window, point( 1, 0 ), getmaxx( window ) - 1, c_white, desc );
Expand Down Expand Up @@ -172,6 +178,7 @@ void avatar::power_mutations()
ctxt.register_updown();
ctxt.register_action( "ANY_INPUT" );
ctxt.register_action( "TOGGLE_EXAMINE" );
ctxt.register_action( "TOGGLE_SPRITE" );
ctxt.register_action( "REASSIGN" );
ctxt.register_action( "HELP_KEYBINDINGS" );
ctxt.register_action( "QUIT" );
Expand Down Expand Up @@ -215,6 +222,10 @@ void avatar::power_mutations()
type = has_base_trait( passive[i] ) ? c_cyan : c_light_cyan;
mvwprintz( wBio, point( 2, list_start_y + i - scroll_position ),
type, "%c %s", td.key, md.name() );
if( !td.show_sprite ) {
//~ Hint: Letter to show which mutation is Hidden in the mutation menu
wprintz( wBio, c_cyan, _( " H" ) );
}
}
}

Expand Down Expand Up @@ -352,6 +363,9 @@ void avatar::power_mutations()
// Describing mutations, not activating them!
examine_id = mut_id;
break;
case mutation_menu_mode::hidding:
my_mutations[mut_id].show_sprite = !my_mutations[mut_id].show_sprite;
break;
}
handled = true;
} else if( mutation_chars.valid( ch ) ) {
Expand All @@ -375,6 +389,9 @@ void avatar::power_mutations()
menu_mode = menu_mode == mutation_menu_mode::activating ?
mutation_menu_mode::examining : mutation_menu_mode::activating;
examine_id = cata::nullopt;
} else if( action == "TOGGLE_SPRITE" ) {
menu_mode = mutation_menu_mode::hidding;
examine_id = cata::nullopt;
} else if( action == "QUIT" ) {
exit = true;
}
Expand Down
2 changes: 2 additions & 0 deletions src/savegame_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ void Character::trait_data::serialize( JsonOut &json ) const
json.member( "key", key );
json.member( "charge", charge );
json.member( "powered", powered );
json.member( "show_sprite", show_sprite );
json.end_object();
}

Expand All @@ -494,6 +495,7 @@ void Character::trait_data::deserialize( const JsonObject &data )
data.read( "key", key );
data.read( "charge", charge );
data.read( "powered", powered );
data.read( "show_sprite", show_sprite );
}

void consumption_event::serialize( JsonOut &json ) const
Expand Down