Update drawString (rosalina)
This commit is contained in:
parent
c688600d33
commit
219f38169f
@ -75,27 +75,34 @@ void Draw_DrawCharacter(u32 posX, u32 posY, u32 color, char character)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
u32 Draw_DrawString(u32 posX, u32 posY, u32 color, const char *string)
|
||||
{
|
||||
for(u32 i = 0, line_i = 0; i < ((u32) strlen(string)); i++)
|
||||
{
|
||||
if(string[i] == '\n')
|
||||
for(u32 i = 0, line_i = 0; i < strlen(string); i++)
|
||||
switch(string[i])
|
||||
{
|
||||
case '\n':
|
||||
posY += SPACING_Y;
|
||||
line_i = 0;
|
||||
continue;
|
||||
}
|
||||
else if(line_i >= (SCREEN_BOT_WIDTH - posX) / SPACING_X)
|
||||
break;
|
||||
|
||||
case '\t':
|
||||
line_i += 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
//Make sure we never get out of the screen
|
||||
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
|
||||
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;
|
||||
|
Reference in New Issue
Block a user