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

feat(UI, port): Port hiding traits/mutations from DDA #5754

Merged
merged 4 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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/keybindings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1883,6 +1883,13 @@
"id": "bionics",
"bindings": [ { "input_method": "keyboard", "key": "p" } ]
},
{
"type": "keybinding",
"id": "TOGGLE_SPRITE",
"category": "MUTATIONS",
"name": "Toggle sprite",
"bindings": [ { "input_method": "keyboard", "key": "," } ]
},
{
"type": "keybinding",
"name": "View/Activate Mutations",
Expand Down
3 changes: 3 additions & 0 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3662,6 +3662,9 @@ std::vector<std::string> Character::get_overlay_ids() const

// then get mutations
for( const std::pair<const trait_id, char_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
1 change: 1 addition & 0 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ struct char_trait_data {
* is reset to @ref mutation_branch::cooldown.
*/
int charge = 0;
bool show_sprite = true;
void serialize( JsonOut &json ) const;
void deserialize( JsonIn &jsin );
};
Expand Down
20 changes: 20 additions & 0 deletions src/mutation_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum class mutation_menu_mode {
activating,
examining,
reassigning,
hidding,
chaosvolt marked this conversation as resolved.
Show resolved Hide resolved
};
enum class mutation_tab_mode {
active,
Expand Down Expand Up @@ -78,9 +79,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, " ),
chaosvolt marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -234,6 +240,7 @@ detail::mutations_ui_result detail::show_mutations_ui_internal( Character &who )
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( "NEXT_TAB" );
ctxt.register_action( "PREV_TAB" );
Expand Down Expand Up @@ -285,6 +292,10 @@ detail::mutations_ui_result detail::show_mutations_ui_internal( Character &who )
}
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 @@ -440,6 +451,9 @@ detail::mutations_ui_result detail::show_mutations_ui_internal( Character &who )
// Describing mutations, not activating them!
examine_id = mut_id;
break;
case mutation_menu_mode::hidding:
chaosvolt marked this conversation as resolved.
Show resolved Hide resolved
who.my_mutations[*mut_id].show_sprite = !who.my_mutations[*mut_id].show_sprite;
break;
}
handled = true;
} else if( mutation_chars.valid( ch ) ) {
Expand Down Expand Up @@ -602,6 +616,9 @@ detail::mutations_ui_result detail::show_mutations_ui_internal( Character &who )
// Describing mutations, not activating them!
examine_id = mut_id;
break;
case mutation_menu_mode::hidding:
chaosvolt marked this conversation as resolved.
Show resolved Hide resolved
who.my_mutations[mut_id].show_sprite = !who.my_mutations[mut_id].show_sprite;
break;
}
}
} else if( action == "REASSIGN" ) {
Expand All @@ -612,6 +629,9 @@ detail::mutations_ui_result detail::show_mutations_ui_internal( Character &who )
menu_mode = menu_mode == mutation_menu_mode::activating ?
mutation_menu_mode::examining : mutation_menu_mode::activating;
examine_id = std::nullopt;
} else if( action == "TOGGLE_SPRITE" ) {
menu_mode = mutation_menu_mode::hidding;
chaosvolt marked this conversation as resolved.
Show resolved Hide resolved
examine_id = std::nullopt;
} else if( action == "QUIT" ) {
ret.cmd = mutations_ui_cmd::exit;
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 @@ -336,6 +336,7 @@ void char_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 @@ -346,6 +347,7 @@ void char_trait_data::deserialize( JsonIn &jsin )
data.read( "key", key );
data.read( "charge", charge );
data.read( "powered", powered );
data.read( "show_sprite", show_sprite );
}

////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Loading