mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-28 04:51:42 +00:00
Fix character description text rendering.
This commit is contained in:
parent
42590d5aff
commit
a37caff23e
1 changed files with 76 additions and 6 deletions
82
src/m_menu.c
82
src/m_menu.c
|
|
@ -7972,14 +7972,84 @@ static void M_DrawSetupChoosePlayerMenu(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Character select pictures
|
// Character select pictures
|
||||||
V_DrawScaledPatch(8-xsh, (my+16) - FixedInt(char_scroll), 0, description[char_on].charpic);
|
{
|
||||||
if (prev != -1)
|
INT32 x = 8 - xsh;
|
||||||
V_DrawScaledPatch(8-xsh, (my+16) - FixedInt(char_scroll) - 144, 0, description[prev].charpic);
|
INT32 y = (my+16) - FixedInt(char_scroll);
|
||||||
if (next != -1)
|
V_DrawScaledPatch(x, y, 0, description[char_on].charpic);
|
||||||
V_DrawScaledPatch(8-xsh, (my+16) - FixedInt(char_scroll) + 144, 0, description[next].charpic);
|
if (prev != -1)
|
||||||
|
V_DrawScaledPatch(x, y - 144, 0, description[prev].charpic);
|
||||||
|
if (next != -1)
|
||||||
|
V_DrawScaledPatch(x, y + 144, 0, description[next].charpic);
|
||||||
|
}
|
||||||
|
|
||||||
// Character description
|
// Character description
|
||||||
V_DrawString(146+xsh, my + 9, V_RETURN8|V_ALLOWLOWERCASE, char_notes);
|
// No, I can't use strtok.
|
||||||
|
// Put two line break characters next to each other to see why.
|
||||||
|
{
|
||||||
|
char *text = char_notes;
|
||||||
|
char *first_token = text;
|
||||||
|
char *last_token = strchr(text, '\n');
|
||||||
|
INT32 x = 146 + xsh;
|
||||||
|
INT32 y = my + 9;
|
||||||
|
INT32 flags = V_ALLOWLOWERCASE;
|
||||||
|
|
||||||
|
// No line breaks?
|
||||||
|
// Draw entire string
|
||||||
|
if (!last_token)
|
||||||
|
V_DrawString(x, y, flags, char_notes);
|
||||||
|
// Split string by the line break character
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char *string = NULL;
|
||||||
|
INT32 len;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
// There are still lines left do draw
|
||||||
|
if (last_token)
|
||||||
|
{
|
||||||
|
size_t shift = 0;
|
||||||
|
// Free this line
|
||||||
|
if (string)
|
||||||
|
Z_Free(string);
|
||||||
|
// Find string length, do a malloc...
|
||||||
|
len = (last_token-first_token)+1;
|
||||||
|
string = ZZ_Alloc(len);
|
||||||
|
// Copy the line
|
||||||
|
strncpy(string, first_token, len-1);
|
||||||
|
string[len-1] = '\0';
|
||||||
|
// Don't leave a line break character
|
||||||
|
// at the start of the string!
|
||||||
|
if ((strlen(string) >= 2) && (string[0] == '\n') && (string[1] != '\n'))
|
||||||
|
shift++;
|
||||||
|
// Then draw it
|
||||||
|
V_DrawString(x, y, flags, string+shift);
|
||||||
|
}
|
||||||
|
// No line break character was found
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Don't leave a line break character
|
||||||
|
// at the start of the string!
|
||||||
|
if ((strlen(first_token) >= 2) && (first_token[0] == '\n') && (first_token[1] != '\n'))
|
||||||
|
first_token++;
|
||||||
|
V_DrawString(x, y, flags, first_token);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next line
|
||||||
|
y += 8; // V_RETURN8
|
||||||
|
if ((last_token-text)+1 >= strlen(text))
|
||||||
|
last_token = NULL;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
first_token = last_token;
|
||||||
|
last_token = strchr(first_token+1, '\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Free this line
|
||||||
|
if (string)
|
||||||
|
Z_Free(string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Name tags!
|
// Name tags!
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue