Update drawString (rosalina)
This commit is contained in:
parent
c688600d33
commit
219f38169f
@ -75,28 +75,35 @@ void Draw_DrawCharacter(u32 posX, u32 posY, u32 color, char character)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
u32 Draw_DrawString(u32 posX, u32 posY, u32 color, const char *string)
|
u32 Draw_DrawString(u32 posX, u32 posY, u32 color, const char *string)
|
||||||
{
|
{
|
||||||
for(u32 i = 0, line_i = 0; i < ((u32) strlen(string)); i++)
|
for(u32 i = 0, line_i = 0; i < strlen(string); i++)
|
||||||
{
|
switch(string[i])
|
||||||
if(string[i] == '\n')
|
|
||||||
{
|
{
|
||||||
posY += SPACING_Y;
|
case '\n':
|
||||||
line_i = 0;
|
posY += SPACING_Y;
|
||||||
continue;
|
line_i = 0;
|
||||||
}
|
break;
|
||||||
else if(line_i >= (SCREEN_BOT_WIDTH - posX) / SPACING_X)
|
|
||||||
{
|
|
||||||
// Make sure we never get out of the screen.
|
|
||||||
posY += SPACING_Y;
|
|
||||||
line_i = 0;
|
|
||||||
if(string[i] == ' ')
|
|
||||||
continue; // Spaces at the start look weird
|
|
||||||
}
|
|
||||||
|
|
||||||
Draw_DrawCharacter(posX + line_i * SPACING_X, posY, color, string[i]);
|
case '\t':
|
||||||
line_i++;
|
line_i += 2;
|
||||||
}
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
//Make sure we never get out of the screen
|
||||||
|
if(line_i >= ((SCREEN_BOT_WIDTH) - posX) / SPACING_X)
|
||||||
|
{
|
||||||
|
posY += SPACING_Y;
|
||||||
|
line_i = 1; //Little offset so we know the same string continues
|
||||||
|
if(string[i] == ' ') break; //Spaces at the start look weird
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw_DrawCharacter(posX + line_i * SPACING_X, posY, color, string[i]);
|
||||||
|
|
||||||
|
line_i++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return posY;
|
return posY;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user