Update core_clipboard_text.c

This commit is contained in:
Ray
2025-11-05 20:51:18 +01:00
parent 12ce106661
commit 3843f771fb

View File

@@ -53,6 +53,8 @@ int main(void)
float textAlpha = 0.0f; float textAlpha = 0.0f;
// Offset amount for animations // Offset amount for animations
const int offsetAmount = -4; const int offsetAmount = -4;
SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
@@ -70,7 +72,6 @@ int main(void)
if (copyAnim > 0) copyAnim -= GetFrameTime(); if (copyAnim > 0) copyAnim -= GetFrameTime();
if (textAnim > 0) textAnim -= GetFrameTime(); if (textAnim > 0) textAnim -= GetFrameTime();
// React to the user pressing paste
if (pastePressed) if (pastePressed)
{ {
// Most operating systems hide this information until the user presses Ctrl-V on the window. // Most operating systems hide this information until the user presses Ctrl-V on the window.
@@ -81,17 +82,13 @@ int main(void)
if (IsImageValid(image)) if (IsImageValid(image))
{ {
// Unload the image
UnloadImage(image); UnloadImage(image);
// Update visuals
popupText = "clipboard contains image"; popupText = "clipboard contains image";
} }
else else
{ {
// Get text from the user's clipboard
clipboardText = GetClipboardText(); clipboardText = GetClipboardText();
// Update visuals
popupText = "text pasted"; popupText = "text pasted";
pasteAnim = animMaxTime; pasteAnim = animMaxTime;
} }
@@ -114,7 +111,6 @@ int main(void)
copyAnim = animMaxTime; copyAnim = animMaxTime;
copyAnimMult = 1; copyAnimMult = 1;
textAlpha = 1; textAlpha = 1;
// Update the text that pops up at the bottom of the screen
popupText = "text copied"; popupText = "text copied";
} }
@@ -141,15 +137,8 @@ int main(void)
copyAnim = animMaxTime; copyAnim = animMaxTime;
copyAnimMult = -1; copyAnimMult = -1;
if (textIndex == 0) if (textIndex == 0) textIndex = (sizeof(copyableText)/sizeof(const char*)) - 1;
{ else textIndex -= 1;
// Loop back to the other end
textIndex = (sizeof(copyableText) / sizeof(const char*)) - 1; // Length of array minus one
}
else
{
textIndex -= 1;
}
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@@ -189,10 +178,7 @@ int main(void)
DrawText(popupText, 10, 425 + offset, 20, ColorAlpha(DARKGREEN, textAlpha)); DrawText(popupText, 10, 425 + offset, 20, ColorAlpha(DARKGREEN, textAlpha));
// Fade-out animation // Fade-out animation
if (textTimer < 0) if (textTimer < 0) textAlpha -= GetFrameTime();
{
textAlpha -= GetFrameTime();
}
} }
EndDrawing(); EndDrawing();