Make battle buttons translatable
Relates to and final part of #6105
This has been implemented:
- Variable width for the SKIP and AUTO buttons according to their texts.
- 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:
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:
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.
Related to #9261
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. There are 2 things necessary for this implementation to be ready:
- 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\nGamewhere onlyMultiplayershould be made smaller by 1 px. - Tidying and improvement of the PR's code.
Help with the first step would be appreciated and should be made in a different PR.