Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

[patch] Ellipsis & Button Text Offset

Started by An_dz, April 11, 2014, 12:49:23 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


Two patches, one complements the other.

The ellipsis_fix patch will check if the last character is smaller than the ellipsis and if true will remove another one so the ellipsis will fit inside the area. It may still fail if the ellipsis is still bigger than three "i" for example, but still is the best and fastest option without using temp array to store the last 3~4 characters width and do the checking.

The button_text_offset patch will apply the gui_button_text_offset you define in your file to roundbox and box buttons by using the x value in both left and right borders and y only in top. This way the text is always centralized at horizontal.

This picture shows how both patches work, the first image is unpatched (how it's now), the second with the ellipsis_fix, and the third with button_text_offset and gui_button_text_offset=5,0 set in


I remember that I had fixed this in one of my original patches. To bad it never got implemented the way I wrote it. It would have saved us all the extra work.

Maybe I should have been harder when I noticed differences from my patches and Prissi's implementation of it, but I just didn't had the strength to bother anymore...
- My code doesn't have bugs. It develops random features...


The patch is not very unicode like. Since we have anyway calculated the last matching character above, one should use it anyway, and even use the remaining space to center the text within the button. But thanks for pointing this out.

There are two kinds of different buttons offsets needed, so the existing one I renamed to gui_color_button_text_offset

Check -7192


It doesn't compile. Error in, must remove (scr_coord) in both area_text.set_pos. And you are using gui_button_text_offset in both, while it should use gui_color_button_text_offset in the box button.

After testing I found the ellipses sometimes is over the last character, and so one of the dots sometimes disappear over the text.

And I think we need an offset in the right as well to prevent the last character from being over the border, like the second screen in the first post. And because you may create a theme where the right side of the button has some kind of graphic which should not be overlapped.

Edit 2:
Attached is a patch with a triple value offset. Just set the offsets as "left, top, right", parameter names were not changed.


Here's the patch that fixes the ellipsis again. I also added a check if we really want it to center align.


Let me be boring here, anything against these patches?


Sorry, was on holiday. Will check tomorrow.


Enjoy your holidays, I was looking for anyone that tested and found something wrong at first place.



BTW, what about the triple offset?


I though that was all included. I have to check again.


Ok, now also added then right bottom offsets in r7328. Back to other backlogs ...