This is a simple fix is for #5385.
Details
- Reviewers
bb - Group Reviewers
Restricted Owners Package (Owns No Changed Paths) - Commits
- rP24076: Redo the previous commit by actually parsing the comments in the revision: use…
rP24075: Let the Overlay width depend on the longest string in it - Trac Tickets
- #5385
Switch to the Bulgarian language and confirm the fps counter is fully shown
Diff Detail
- Repository
- rP 0 A.D. Public Repository
- Branch
- /ps/trunk
- Lint
Lint OK - Unit
No Unit Test Coverage - Build Status
Buildable 6848 Build 11253: arc lint + arc unit
Event Timeline
This is a code problem, not a string problem. It can happen with other languages too. I think the same problem exists with some playernames in the lag-warnings area too.
The *.po files are downloaded from transifex, so they would be edited there ifanything. But I would recommend to not change it that way.
Removing one arbitrary number with another arbitrary number can fix this.
Index: binaries/data/mods/public/gui/common/functions_global_object.js =================================================================== --- binaries/data/mods/public/gui/common/functions_global_object.js (revision 21929) +++ binaries/data/mods/public/gui/common/functions_global_object.js (working copy) @@ -17,9 +17,9 @@ dataCounter.caption = counters.join("\n") + "\n"; dataCounter.hidden = !counters.length; dataCounter.size = sprintf("%(left)s %(top)s %(right)s %(bottom)s", { - "left": "100%%-100", + "left": "100%-110", "top": "40", - "right": "100%%-5", + "right": "100%-5", "bottom": 40 + 14 * counters.length }); }
However, this would also break given a lengthy enough string. The correct solution would be to adapt the sizes based on the width of the longest string just as how it's done for the network warning thingy. Engine.GetTextWidth(font, string) IIRC.
Do you have any reference to the playernames problem so I can try to understand the linking between them?
I think the same problem exists with some playernames in the lag-warnings area too.
It won't exist there as the width check is done in that specific case.
I found the script "functions_global_object.js" interesting.
The function updateCounters updates the overlay, I think we need to make an if-statement ask if the text overflows the overlay width then subtract X to "left" field but I can't find a way to do so.
For example, in Bulgarian if I subtract to the "left" field 5, it fixes the problem.
dataCounter.size = sprintf("%(left)s %(top)s %(right)s %(bottom)s", { "left": "100%%-105", // Was 100 "top": "40", "right": "100%%-5", "bottom": 40 + 14 * counters.length });
So the updateCounters function that smiley mentioned uses a fixed width, but the width should change dynamically. I thought this was already the case. Also as he correctly pointed out, Engine.GetTextWidth can be used for that, like getNetworkWarnings() in binaries/data/mods/public/gui/common/network.js does. If you want you can try to download the code and try to implement that (JavaScript changes only, no need to compile). BuildInstructions.
Add yourself to gui/credits/text/programming.json (path might be wrong).
And also remove the unnecessary three files from the diff. Only needs the changed JS file.
binaries/data/mods/public/gui/common/functions_global_object.js | ||
---|---|---|
18 | The width of the longest counter. The second one might be longer. Also, that negative sign seems useless. |
binaries/data/mods/public/gui/common/functions_global_object.js | ||
---|---|---|
18 | Also, are those %% typos?. I could not find any evidence to suggest otherwise. (Not that I looked). |
binaries/data/mods/public/gui/common/functions_global_object.js | ||
---|---|---|
18 |
number of characters != text width.
(I was wondering too and not looking either. I only know them from a translated sprintf string where %% encoded %, but not from a sprintf argument.) |
binaries/data/mods/public/gui/common/functions_global_object.js | ||
---|---|---|
18 | Replace with GetTextWidth thingy then. With very wide strings, that 1.2 would cause issues. I assume its a buffer area, So just add a constant number of pixels. |
Will do, I'm pretty new to that kind of source control, sorry for my nooby understanding.
Getting the width of the longest text and then adding a constant to make the text fit to the overlay
Sorry for the dumb question but how do I remove these files? I don't understand how to remove these 3 files.
binaries/data/mods/public/gui/common/functions_global_object.js | ||
---|---|---|
18 | I made that it gets the width of the longest string and then adding a constant number which is 15 (For some reason it works no matter how long the string is, it fits perfectly with the overlay). |
(I guess *.exe and *.dll files changed because you compiled. Notice that you don't need to do this as long as you only change .xml / .js)
binaries/data/mods/public/gui/common/functions_global_object.js | ||
---|---|---|
18 | Perhaps rename a, b to max and current, so that the reader doesn't have to infer. I think it should be possible to only store the maxWidth instead of maxText, removing two GetTextWidth calls? reduce consumes two arguments, might be nicer to not rely on the default value (which is the first element of the array) and pass that explicitly (0 in case of computing the width instead of the text). (I guess that function should also account for different fonts in theory (that would be my mistake when introducing the function). I recall s0600204 has worked on a patch to get the text size of mixed contents: D844. Perhaps the GetTextWidth function can be superseded then.) Otherwise patch loooks good, thanks! |