Update drawString (rosalina)

This commit is contained in:
TuxSH 2019-03-31 17:04:07 +02:00
parent c688600d33
commit 219f38169f

View File

@ -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) 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')
{ {
case '\n':
posY += SPACING_Y; posY += SPACING_Y;
line_i = 0; line_i = 0;
continue; break;
}
else if(line_i >= (SCREEN_BOT_WIDTH - posX) / SPACING_X) 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; posY += SPACING_Y;
line_i = 0; line_i = 1; //Little offset so we know the same string continues
if(string[i] == ' ') if(string[i] == ' ') break; //Spaces at the start look weird
continue; // Spaces at the start look weird
} }
Draw_DrawCharacter(posX + line_i * SPACING_X, posY, color, string[i]); Draw_DrawCharacter(posX + line_i * SPACING_X, posY, color, string[i]);
line_i++; line_i++;
break;
} }
return posY; return posY;