fheroes2 icon indicating copy to clipboard operation
fheroes2 copied to clipboard

Make battle buttons translatable

Open zenseii opened this issue 2 years ago • 2 comments

Relates to and final part of #6105

This has been implemented:

  1. Variable width for the SKIP and AUTO buttons according to their texts.
  2. Variable width of the Status Bar according to the widths of the buttons.

For the Cyrillic font it looks quite good even though the buttons are slightly wider than the originals which means we have 15 pixels less for text:

image

Meanwhile, for the Latin font it is obvious that we have to cram the letters closer together. I found the sweet spot to be 2 pixels closer in the x-direction.

This is what it looks like for the Latin font without cramming:

image

Implementing a feature to cram letters would need a new function for calculating text width because it needs to take into account that the letters are rendered on top of each other, and we need a new function for actually rendering the text with letters on top of each other.

This change would give us 12 pixels more in width in the case when we have two words of 4 letters (ex. AUTO + SKIP), ( 2 pixels * ( 2 words * ( 4 letters - 1 first letter ) ) ). We would then only lose 3 pixels for text.

Such big changes might be better to do in a separate PR.

This change could be used to solve button problems like those described here https://github.com/ihhub/fheroes2/issues/7548

This is what the SKIP button would look like with 2 pixels closer for letters. image

Related to #9261

zenseii avatar Sep 05 '23 17:09 zenseii

Hi @zenseii , can you please explain what is missing to be implemented in this pull request? Can we help to move forward with the changes or the idea?

ihhub avatar Mar 21 '25 15:03 ihhub

@ihhub. There are 2 things necessary for this implementation to be ready:

  1. Implement a text method that makes the letter images move 1px closer to each other if the text exceeds a specified width. This width should be passed as an argument and not be a fixed value. Ex. if a max text width is specified as 86 (:standard button text width), then a text width that is wider will have its letters placed 1 px closer to each other. It should also be taken into consideration that if a text consists of several lines, then only the lines which exceed this width should have letters moved closer, e.g. Multiplayer\nGame where only Multiplayer should be made smaller by 1 px.
  2. Tidying and improvement of the PR's code.

Help with the first step would be appreciated and should be made in a different PR.

zenseii avatar Mar 21 '25 15:03 zenseii