[Examples] Warning fixes (pt 1) (#1668)
* Fix some warnings in examples. * cleanups from review Co-authored-by: Jeffery Myers <JefMyers@blizzard.com>
This commit is contained in:
parent
c6dd41495b
commit
e48b9a6da1
30 changed files with 104 additions and 103 deletions
|
@ -66,12 +66,12 @@ int main(void)
|
|||
|
||||
if (!useTtf)
|
||||
{
|
||||
DrawTextEx(fontBm, msg, (Vector2){ 20.0f, 100.0f }, fontBm.baseSize, 2, MAROON);
|
||||
DrawTextEx(fontBm, msg, (Vector2){ 20.0f, 100.0f }, (float)fontBm.baseSize, 2, MAROON);
|
||||
DrawText("Using BMFont (Angelcode) imported", 20, GetScreenHeight() - 30, 20, GRAY);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawTextEx(fontTtf, msg, (Vector2){ 20.0f, 100.0f }, fontTtf.baseSize, 2, LIME);
|
||||
DrawTextEx(fontTtf, msg, (Vector2){ 20.0f, 100.0f }, (float)fontTtf.baseSize, 2, LIME);
|
||||
DrawText("Using TTF font generated", 20, GetScreenHeight() - 30, 20, GRAY);
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ int main(void)
|
|||
Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/sdf.fs", GLSL_VERSION));
|
||||
SetTextureFilter(fontSDF.texture, FILTER_BILINEAR); // Required for SDF font
|
||||
|
||||
Vector2 fontPosition = { 40, screenHeight/2 - 50 };
|
||||
Vector2 fontPosition = { 40, screenHeight/2.0f - 50 };
|
||||
Vector2 textSize = { 0.0f, 0.0f };
|
||||
float fontSize = 16.0f;
|
||||
int currentFont = 0; // 0 - fontDefault, 1 - fontSDF
|
||||
|
|
|
@ -38,14 +38,14 @@ int main(void)
|
|||
Font font2 = LoadFont("resources/custom_alagard.png"); // Font loading
|
||||
Font font3 = LoadFont("resources/custom_jupiter_crash.png"); // Font loading
|
||||
|
||||
Vector2 fontPosition1 = { screenWidth/2 - MeasureTextEx(font1, msg1, font1.baseSize, -3).x/2,
|
||||
Vector2 fontPosition1 = { screenWidth/2 - MeasureTextEx(font1, msg1, (float)font1.baseSize, -3).x/2,
|
||||
screenHeight/2 - font1.baseSize/2 - 80 };
|
||||
|
||||
Vector2 fontPosition2 = { screenWidth/2 - MeasureTextEx(font2, msg2, font2.baseSize, -2).x/2,
|
||||
Vector2 fontPosition2 = { screenWidth/2 - MeasureTextEx(font2, msg2, (float)font2.baseSize, -2).x/2,
|
||||
screenHeight/2 - font2.baseSize/2 - 10 };
|
||||
|
||||
Vector2 fontPosition3 = { screenWidth/2 - MeasureTextEx(font3, msg3, font3.baseSize, 2).x/2,
|
||||
screenHeight/2 - font3.baseSize/2 + 50 };
|
||||
Vector2 fontPosition3 = { screenWidth/2.0f - MeasureTextEx(font3, msg3, (float)font3.baseSize, 2).x/2,
|
||||
screenHeight/2.0f - font3.baseSize/2 + 50 };
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
@ -64,9 +64,9 @@ int main(void)
|
|||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawTextEx(font1, msg1, fontPosition1, font1.baseSize, -3, WHITE);
|
||||
DrawTextEx(font2, msg2, fontPosition2, font2.baseSize, -2, WHITE);
|
||||
DrawTextEx(font3, msg3, fontPosition3, font3.baseSize, 2, WHITE);
|
||||
DrawTextEx(font1, msg1, fontPosition1, (float)font1.baseSize, -3, WHITE);
|
||||
DrawTextEx(font2, msg2, fontPosition2, (float)font2.baseSize, -2, WHITE);
|
||||
DrawTextEx(font3, msg3, fontPosition3, (float)font3.baseSize, 2, WHITE);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
@ -52,7 +52,7 @@ int main(void)
|
|||
|
||||
for (int i = 0; i < MAX_FONTS; i++)
|
||||
{
|
||||
positions[i].x = screenWidth/2 - MeasureTextEx(fonts[i], messages[i], fonts[i].baseSize*2, spacings[i]).x/2;
|
||||
positions[i].x = screenWidth/2 - MeasureTextEx(fonts[i], messages[i], fonts[i].baseSize*2.0f, spacings[i]).x/2.0f);
|
||||
positions[i].y = 60 + fonts[i].baseSize + 45*i;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ int main(void)
|
|||
|
||||
for (int i = 0; i < MAX_FONTS; i++)
|
||||
{
|
||||
DrawTextEx(fonts[i], messages[i], positions[i], fonts[i].baseSize*2, spacings[i], colors[i]);
|
||||
DrawTextEx(fonts[i], messages[i], positions[i], fonts[i].baseSize*2.0f, (float)spacings[i], colors[i]);
|
||||
}
|
||||
|
||||
EndDrawing();
|
||||
|
|
|
@ -33,10 +33,10 @@ tempor incididunt ut labore et dolore magna aliqua. Nec ullamcorper sit amet ris
|
|||
Rectangle resizer = { container.x + container.width - 17, container.y + container.height - 17, 14, 14 };
|
||||
|
||||
// Minimum width and heigh for the container rectangle
|
||||
const int minWidth = 60;
|
||||
const int minHeight = 60;
|
||||
const int maxWidth = screenWidth - 50;
|
||||
const int maxHeight = screenHeight - 160;
|
||||
const float minWidth = 60;
|
||||
const float minHeight = 60;
|
||||
const float maxWidth = screenWidth - 50;
|
||||
const float maxHeight = screenHeight - 160;
|
||||
|
||||
Vector2 lastMouse = { 0.0f, 0.0f }; // Stores last mouse coordinates
|
||||
Color borderColor = MAROON; // Container border color
|
||||
|
@ -63,10 +63,10 @@ tempor incididunt ut labore et dolore magna aliqua. Nec ullamcorper sit amet ris
|
|||
{
|
||||
if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) resizing = false;
|
||||
|
||||
int width = container.width + (mouse.x - lastMouse.x);
|
||||
float width = container.width + (mouse.x - lastMouse.x);
|
||||
container.width = (width > minWidth)? ((width < maxWidth)? width : maxWidth) : minWidth;
|
||||
|
||||
int height = container.height + (mouse.y - lastMouse.y);
|
||||
float height = container.height + (mouse.y - lastMouse.y);
|
||||
container.height = (height > minHeight)? ((height < maxHeight)? height : maxHeight) : minHeight;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -203,15 +203,15 @@ int main(int argc, char **argv)
|
|||
for (int i = 0; i < SIZEOF(emoji); ++i)
|
||||
{
|
||||
const char *txt = &emojiCodepoints[emoji[i].index];
|
||||
Rectangle emojiRect = { pos.x, pos.y, fontEmoji.baseSize, fontEmoji.baseSize };
|
||||
Rectangle emojiRect = { pos.x, pos.y, (float)fontEmoji.baseSize, (float)fontEmoji.baseSize };
|
||||
|
||||
if (!CheckCollisionPointRec(mouse, emojiRect))
|
||||
{
|
||||
DrawTextEx(fontEmoji, txt, pos, fontEmoji.baseSize, 1.0, selected == i ? emoji[i].color : Fade(LIGHTGRAY, 0.4f));
|
||||
DrawTextEx(fontEmoji, txt, pos, (float)fontEmoji.baseSize, 1.0f, selected == i ? emoji[i].color : Fade(LIGHTGRAY, 0.4f));
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawTextEx(fontEmoji, txt, pos, fontEmoji.baseSize, 1.0, emoji[i].color );
|
||||
DrawTextEx(fontEmoji, txt, pos, (float)fontEmoji.baseSize, 1.0f, emoji[i].color );
|
||||
hovered = i;
|
||||
hoveredPos = pos;
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ int main(int argc, char **argv)
|
|||
TextIsEqual(messages[message].language, "Japanese")) font = &fontAsian;
|
||||
|
||||
// Calculate size for the message box (approximate the height and width)
|
||||
Vector2 sz = MeasureTextEx(*font, messages[message].text, font->baseSize, 1.0f);
|
||||
Vector2 sz = MeasureTextEx(*font, messages[message].text, (float)font->baseSize, 1.0f);
|
||||
if (sz.x > 300) { sz.y *= sz.x/300; sz.x = 300; }
|
||||
else if (sz.x < 160) sz.x = 160;
|
||||
|
||||
|
@ -267,15 +267,15 @@ int main(int argc, char **argv)
|
|||
|
||||
// Draw the main text message
|
||||
Rectangle textRect = { msgRect.x + horizontalPadding/2, msgRect.y + verticalPadding/2, msgRect.width - horizontalPadding, msgRect.height };
|
||||
DrawTextRec(*font, messages[message].text, textRect, font->baseSize, 1.0f, true, WHITE);
|
||||
DrawTextRec(*font, messages[message].text, textRect, (float)font->baseSize, 1.0f, true, WHITE);
|
||||
|
||||
// Draw the info text below the main message
|
||||
int size = strlen(messages[message].text);
|
||||
int size = (int)strlen(messages[message].text);
|
||||
int len = GetCodepointsCount(messages[message].text);
|
||||
const char *info = TextFormat("%s %u characters %i bytes", messages[message].language, len, size);
|
||||
sz = MeasureTextEx(GetFontDefault(), info, 10, 1.0f);
|
||||
Vector2 pos = { textRect.x + textRect.width - sz.x, msgRect.y + msgRect.height - sz.y - 2 };
|
||||
DrawText(info, pos.x, pos.y, 10, RAYWHITE);
|
||||
DrawText(info, (int)pos.x, (int)pos.y, 10, RAYWHITE);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue