Skip to content

Commit

Permalink
switch to ">" symbol for nesting indication
Browse files Browse the repository at this point in the history
  • Loading branch information
Aivean committed Dec 3, 2020
1 parent d81ec6c commit d7f6b57
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4610,14 +4610,14 @@ std::string item::tname( unsigned int quantity, bool with_prefix, unsigned int t
? contents_item.charges
: 1;
contents_suffix_text = string_format( pgettext( "item name",
//~ [container item name] "with [inner item name]"
" with %1$s" ),
//~ [container item name] " > [inner item name]"
" > %1$s" ),
/* with_contents=false for nested items to prevent excessively long names */
contents_item.tname( contents_count, true, 0, false ) );
} else if( !contents.empty() ) {
contents_suffix_text = string_format( npgettext( "item name",
//~ [container item name] "with [count] item"
" with %1$zd item", " with %1$zd items",
//~ [container item name] " > [count] item"
" > %1$zd item", " > %1$zd items",
contents.num_item_stacks() ), contents.num_item_stacks() );
}
}
Expand Down Expand Up @@ -4751,7 +4751,7 @@ std::string item::tname( unsigned int quantity, bool with_prefix, unsigned int t
modtext += std::string( pgettext( "Adjective, as in diamond katana", "diamond" ) ) + " ";
}

//~ This is a string to construct the item name as it is displayed. This format string has been added for maximum flexibility. The strings are: %1$s: Damage text (e.g. "bruised"). %2$s: burn adjectives (e.g. "burnt"). %3$s: tool modifier text (e.g. "atomic"). %4$s: vehicle part text (e.g. "3.8-Liter"). $5$s: main item text (e.g. "apple"). %6s: tags (e.g. "(wet) (poor fit)").%7s: contents suffix (e.g. "with rock" or "with 5 items").
//~ This is a string to construct the item name as it is displayed. This format string has been added for maximum flexibility. The strings are: %1$s: Damage text (e.g. "bruised"). %2$s: burn adjectives (e.g. "burnt"). %3$s: tool modifier text (e.g. "atomic"). %4$s: vehicle part text (e.g. "3.8-Liter"). $5$s: main item text (e.g. "apple"). %6s: tags (e.g. "(wet) (poor fit)").%7s: inner contents suffix (e.g. " > rock" or " > 5 items").
std::string ret = string_format( _( "%1$s%2$s%3$s%4$s%5$s%6$s%7$s" ), damtext, burntext, modtext,
vehtext, maintext, tagtext, contents_suffix_text );

Expand Down
18 changes: 11 additions & 7 deletions tests/item_tname_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,24 +438,26 @@ TEST_CASE( "nested_items_tname", "[item][tname]" )
item purse( itype_id( "purse" ) );
item rock( itype_id( "test_rock" ) );
item rock2( itype_id( "rock" ) );

const std::string color_pref = "<color_c_light_green>||\u00A0</color>";

const std::string nesting_sym = ">";

SECTION( "single stack inside" ) {

backpack_hiking.put_in( rock, item_pocket::pocket_type::CONTAINER );

SECTION( "single rock" ) {
CHECK( backpack_hiking.tname( 1 ) == color_pref + "hiking backpack with TEST rock" );
CHECK( backpack_hiking.tname( 1 ) == color_pref + "hiking backpack " + nesting_sym + " TEST rock" );
}
SECTION( "several rocks" ) {
backpack_hiking.put_in( rock, item_pocket::pocket_type::CONTAINER );
CHECK( backpack_hiking.tname( 1 ) == color_pref + "hiking backpack with TEST rocks" );
CHECK( backpack_hiking.tname( 1 ) == color_pref + "hiking backpack " + nesting_sym +
" TEST rocks" );
}
SECTION( "several stacks" ) {
backpack_hiking.put_in( rock, item_pocket::pocket_type::CONTAINER );
backpack_hiking.put_in( rock2, item_pocket::pocket_type::CONTAINER );
CHECK( backpack_hiking.tname( 1 ) == color_pref + "hiking backpack with 2 items" );
CHECK( backpack_hiking.tname( 1 ) == color_pref + "hiking backpack " + nesting_sym + " 2 items" );
}
}

Expand All @@ -465,7 +467,8 @@ TEST_CASE( "nested_items_tname", "[item][tname]" )
SECTION( "single rock" ) {
backpack_hiking.put_in( purse, item_pocket::pocket_type::CONTAINER );
CHECK( backpack_hiking.tname( 1 ) ==
color_pref + "hiking backpack with " + color_pref + "purse with 1 item" );
color_pref + "hiking backpack " + nesting_sym + " " + color_pref + "purse " + nesting_sym +
" 1 item" );
}

SECTION( "several rocks" ) {
Expand All @@ -474,14 +477,15 @@ TEST_CASE( "nested_items_tname", "[item][tname]" )
backpack_hiking.put_in( purse, item_pocket::pocket_type::CONTAINER );

CHECK( backpack_hiking.tname( 1 ) ==
color_pref + "hiking backpack with " + color_pref + "purse with 2 items" );
color_pref + "hiking backpack " + nesting_sym + " " + color_pref + "purse " + nesting_sym +
" 2 items" );
}

SECTION( "several purses" ) {
backpack_hiking.put_in( purse, item_pocket::pocket_type::CONTAINER );
backpack_hiking.put_in( purse, item_pocket::pocket_type::CONTAINER );

CHECK( backpack_hiking.tname( 1 ) == color_pref + "hiking backpack with 2 items" );
CHECK( backpack_hiking.tname( 1 ) == color_pref + "hiking backpack " + nesting_sym + " 2 items" );
}
}
}
2 changes: 1 addition & 1 deletion tests/itemname_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,6 @@ TEST_CASE( "display name includes item contents", "[item][display_name][contents
CHECK( quiver.ammo_remaining() == 10 );
CHECK( quiver.display_name() ==
"<color_c_light_green>||\u00A0</color>"
"test quiver with test wooden broadhead arrows (10)" );
"test quiver > test wooden broadhead arrows (10)" );
}

0 comments on commit d7f6b57

Please sign in to comment.