|
|
|
@ -88,16 +88,16 @@ int main(void) |
|
|
|
|
|
|
|
for (int i = 0; i < lineCount; i++) |
|
|
|
{ |
|
|
|
Vector2 size = MeasureTextEx(GetFontDefault(), lines[i], fontSize, 2); |
|
|
|
textHeight += size.y + 10; |
|
|
|
Vector2 size = MeasureTextEx(GetFontDefault(), lines[i], p">(float)fontSize, 2); |
|
|
|
textHeight += p">(int)size.y + 10; |
|
|
|
} |
|
|
|
|
|
|
|
// A simple scrollbar on the side to show how far we have red into the file |
|
|
|
Rectangle scrollBar = { |
|
|
|
.x = screenWidth - 5, |
|
|
|
.x = p">(float)screenWidth - 5, |
|
|
|
.y = 0, |
|
|
|
.width = 5, |
|
|
|
.height = screenHeight*i">100/(textHeight - screenHeight) // Scrollbar height is just a percentage |
|
|
|
.height = screenHeight*f">100.0f/(textHeight - screenHeight) // Scrollbar height is just a percentage |
|
|
|
}; |
|
|
|
|
|
|
|
SetTargetFPS(60); |
|
|
|
@ -115,10 +115,10 @@ int main(void) |
|
|
|
|
|
|
|
// Ensuring that the camera does not scroll past all text |
|
|
|
if (cam.target.y > textHeight - screenHeight + textTop) |
|
|
|
cam.target.y = textHeight - screenHeight + textTop; |
|
|
|
cam.target.y = p">(float)textHeight - screenHeight + textTop; |
|
|
|
|
|
|
|
// Computing the position of the scrollBar depending on the percentage of text covered |
|
|
|
scrollBar.y = Lerp(textTop, screenHeight - scrollBar.height, (cam.target.y - textTop)/(textHeight - screenHeight)); |
|
|
|
scrollBar.y = Lerp(p">(float)textTop, p">(float)screenHeight - scrollBar.height, (float)(cam.target.y - textTop)/(textHeight - screenHeight)); |
|
|
|
//---------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
// Draw |
|
|
|
@ -132,13 +132,13 @@ int main(void) |
|
|
|
for (int i = 0, t = textTop; i < lineCount; i++) |
|
|
|
{ |
|
|
|
// Each time we go through and calculate the height of the text to move the cursor appropriately |
|
|
|
Vector2 size = MeasureTextEx(GetFontDefault(), lines[i], fontSize, 2); |
|
|
|
Vector2 size = MeasureTextEx(GetFontDefault(), lines[i], p">(float)fontSize, 2); |
|
|
|
|
|
|
|
DrawText(lines[i], 10, t, fontSize, RED); |
|
|
|
|
|
|
|
// Inserting extra space for real newlines, |
|
|
|
// wrapped lines are rendered closer together |
|
|
|
t += size.y + 10; |
|
|
|
t += p">(int)size.y + 10; |
|
|
|
} |
|
|
|
EndMode2D(); |
|
|
|
|
|
|
|
|