Skip to content

Commit

Permalink
wrap the text in the martial arts selection window
Browse files Browse the repository at this point in the history
Some of those descriptions are long enough to make the window huge.

Fixes #75674
  • Loading branch information
Daniel Brooks committed Aug 16, 2024
1 parent 0b8d7ba commit 6a74ebd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
15 changes: 10 additions & 5 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13349,6 +13349,11 @@ bool Character::can_lift( const T &obj ) const
template bool Character::can_lift<item>( const item &obj ) const;
template bool Character::can_lift<vehicle>( const vehicle &obj ) const;

static std::string wrap60( const std::string &text )
{
return string_join( foldstring( text, 60 ), "\n" );
}

bool character_martial_arts::pick_style( const Character &you ) // Style selection menu
{
enum style_selection {
Expand Down Expand Up @@ -13379,9 +13384,8 @@ bool character_martial_arts::pick_style( const Character &you ) // Style selecti
ctxt.register_action( "SHOW_DESCRIPTION" );

uilist kmenu;
kmenu.text = string_format( _( "Select a style.\n"
"\n"
"STR: <color_white>%d</color>, DEX: <color_white>%d</color>, "
kmenu.title = _( "Select a style.\n" );
kmenu.text = string_format( _( "STR: <color_white>%d</color>, DEX: <color_white>%d</color>, "
"PER: <color_white>%d</color>, INT: <color_white>%d</color>\n"
"Press [<color_yellow>%s</color>] for technique details and compatible weapons.\n" ),
you.get_str(), you.get_dex(), you.get_per(), you.get_int(),
Expand All @@ -13393,7 +13397,7 @@ bool character_martial_arts::pick_style( const Character &you ) // Style selecti
kmenu.desc_enabled = true;
kmenu.addentry_desc( KEEP_HANDS_FREE, true, 'h',
keep_hands_free ? _( "Keep hands free (on)" ) : _( "Keep hands free (off)" ),
_( "When this is enabled, player won't wield things unless explicitly told to." ) );
wrap60( _( "When this is enabled, player won't wield things unless explicitly told to." ) ) );

kmenu.selected = STYLE_OFFSET;

Expand All @@ -13412,7 +13416,8 @@ bool character_martial_arts::pick_style( const Character &you ) // Style selecti
kmenu.selected = i + STYLE_OFFSET;
entry_text = colorize( entry_text, c_pink );
}
kmenu.addentry_desc( i + STYLE_OFFSET, true, -1, entry_text, style.description.translated() );
kmenu.addentry_desc( i + STYLE_OFFSET, true, -1, entry_text,
wrap60( style.description.translated() ) );
}

kmenu.query();
Expand Down
12 changes: 8 additions & 4 deletions src/newcharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,11 @@ void Character::pick_name( bool bUseDefault )
}
}

static std::string wrap60( const std::string &text )
{
return string_join( foldstring( text, 60 ), "\n" );
}

static matype_id choose_ma_style( const character_type type, const std::vector<matype_id> &styles,
const avatar &u )
{
Expand All @@ -393,9 +398,8 @@ static matype_id choose_ma_style( const character_type type, const std::vector<m

uilist menu;
menu.allow_cancel = false;
menu.text = string_format( _( "Select a style.\n"
"\n"
"STR: <color_white>%d</color>, DEX: <color_white>%d</color>, "
menu.title = _( "Select a style.\n" );
menu.text = string_format( _( "STR: <color_white>%d</color>, DEX: <color_white>%d</color>, "
"PER: <color_white>%d</color>, INT: <color_white>%d</color>\n"
"Press [<color_yellow>%s</color>] for technique details and compatible weapons.\n" ),
u.get_str(), u.get_dex(), u.get_per(), u.get_int(),
Expand All @@ -408,7 +412,7 @@ static matype_id choose_ma_style( const character_type type, const std::vector<m

for( const matype_id &s : styles ) {
const martialart &style = s.obj();
menu.addentry_desc( style.name.translated(), style.description.translated() );
menu.addentry_desc( style.name.translated(), wrap60( style.description.translated() ) );
}
while( true ) {
menu.query( true );
Expand Down

0 comments on commit 6a74ebd

Please sign in to comment.