1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 01:29:43 +01:00

Right-align textboxes in RTL languages

Most of this diff is just moving some existing code around, and
changing inline things to variables that could be changed more easily.
This commit is contained in:
Dav999 2024-01-03 20:36:19 +01:00 committed by Misa Elizabeth Kai
parent 27e83b6008
commit 3588168c4d

View file

@ -871,6 +871,36 @@ void Graphics::drawgui(void)
char buffer[SCREEN_WIDTH_CHARS + 1];
int w = textboxes[i].w;
if (textboxes[i].fill_buttons)
{
/* If we can fill in buttons, the width of the box may change...
* This is Violet's fault. She decided to say a button name out loud. */
int max = 0;
for (size_t j = 0; j < textboxes[i].lines.size(); j++)
{
int len = font::len(textboxes[i].print_flags, textbox_line(buffer, sizeof(buffer), i, j));
if (len > max)
{
max = len;
}
}
w = max + 16;
}
uint32_t print_flags = textboxes[i].print_flags | PR_CJK_LOW;
int text_xp;
if (font::is_rtl(print_flags))
{
print_flags |= PR_RIGHT;
text_xp = textboxes[i].xp + w - 8;
}
else
{
text_xp = textboxes[i].xp + 8;
}
const bool transparent = (textboxes[i].r | textboxes[i].g | textboxes[i].b) == 0;
if (transparent)
@ -881,8 +911,8 @@ void Graphics::drawgui(void)
for (j = 0; j < textboxes[i].lines.size(); j++)
{
font::print(
textboxes[i].print_flags | PR_CJK_LOW | PR_BOR,
textboxes[i].xp + 8,
print_flags | PR_BOR,
text_xp,
yp + text_yoff + text_sign * (j * font_height),
textbox_line(buffer, sizeof(buffer), i, j),
0, 0, 0
@ -891,8 +921,8 @@ void Graphics::drawgui(void)
for (j = 0; j < textboxes[i].lines.size(); j++)
{
font::print(
textboxes[i].print_flags | PR_CJK_LOW,
textboxes[i].xp + 8,
print_flags,
text_xp,
yp + text_yoff + text_sign * (j * font_height),
textbox_line(buffer, sizeof(buffer), i, j),
196, 196, 255 - help.glow
@ -905,32 +935,14 @@ void Graphics::drawgui(void)
const int r = textboxes[i].r * tl_lerp;
const int g = textboxes[i].g * tl_lerp;
const int b = textboxes[i].b * tl_lerp;
size_t j;
int w = textboxes[i].w;
if (textboxes[i].fill_buttons)
{
/* If we can fill in buttons, the width of the box may change...
* This is Violet's fault. She decided to say a button name out loud. */
int max = 0;
for (j = 0; j < textboxes[i].lines.size(); j++)
{
int len = font::len(textboxes[i].print_flags, textbox_line(buffer, sizeof(buffer), i, j));
if (len > max)
{
max = len;
}
}
w = max + 16;
}
drawpixeltextbox(textboxes[i].xp, yp, w, textboxes[i].h, r, g, b);
for (j = 0; j < textboxes[i].lines.size(); j++)
for (size_t j = 0; j < textboxes[i].lines.size(); j++)
{
font::print(
textboxes[i].print_flags | PR_BRIGHTNESS(tl_lerp*255) | PR_CJK_LOW,
textboxes[i].xp + 8,
print_flags | PR_BRIGHTNESS(tl_lerp*255),
text_xp,
yp + text_yoff + text_sign * (j * font_height),
textbox_line(buffer, sizeof(buffer), i, j),
textboxes[i].r, textboxes[i].g, textboxes[i].b