diff options
author | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-02-21 03:18:32 +0000 |
---|---|---|
committer | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-02-21 03:18:32 +0000 |
commit | 8ff25c1e8951304ff5c125e05a8fa044a198ef72 (patch) | |
tree | ae902e210d2f1f8a556ad7d1a7f885e393d9afe1 /src/ui.c | |
parent | 6c63c3d327cf3b494309db82bdd4489b59d3d247 (diff) | |
download | PenguinYippies-8ff25c1e8951304ff5c125e05a8fa044a198ef72.tar.gz PenguinYippies-8ff25c1e8951304ff5c125e05a8fa044a198ef72.tar.bz2 PenguinYippies-8ff25c1e8951304ff5c125e05a8fa044a198ef72.zip |
More buttons
Diffstat (limited to 'src/ui.c')
-rw-r--r-- | src/ui.c | 35 |
1 files changed, 19 insertions, 16 deletions
@@ -31,28 +31,31 @@ bool updateTexturedButton(TexturedButton* button) button->backgroundColor ); - - // Draw outline thingy. - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) + // Draw text centered in button if we have a message. + if (button->message[0] != '\0') { - DrawRectangleLinesEx(button->rect, 2, button->foregroundColor); + DrawText( + button->message, + button->rect.x + (button->rect.width / 2.0 - (button->messageLength * button->fontSize / 4.0)), + button->rect.y + (button->rect.height / 2.0 - button->fontSize / 2.0), + button->fontSize, + button->foregroundColor + ); } - // Draw text centered in button. - DrawText( - button->message, - button->rect.x + (button->rect.width / 2.0 - (button->messageLength * button->fontSize / 4.0)), - button->rect.y + (button->rect.height / 2.0 - button->fontSize / 2.0), - button->fontSize, - button->foregroundColor - ); - button->isPressed = false; - // Check if the button is clicked. - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) + // Outline and detect click stuff. + if (CheckCollisionPointRec(GetMousePosition(), button->rect)) { - if (CheckCollisionPointRec(GetMousePosition(), button->rect)) + // Draw outline thingy. + if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) + { + DrawRectangleLinesEx(button->rect, 2, button->foregroundColor); + } + + // Is clicked. + if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) { button->isPressed = true; } |