add distinct icon-only buffer for internal use (#208)

This commit is contained in:
gulrak 2022-05-29 17:26:08 +02:00 committed by GitHub
parent f534a9a265
commit 013f1a2772
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View File

@ -219,7 +219,7 @@ int main()
if (showTextInputBox)
{
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(RAYWHITE, 0.8f));
int result = GuiTextInputBox((Rectangle){ GetScreenWidth()/2 - 120, GetScreenHeight()/2 - 60, 240, 140 }, "Save", GuiIconText(ICON_FILE_SAVE, "Save file as..."), "Introduce a save file name", "Ok;Cancel", textInput, NULL);
int result = GuiTextInputBox((Rectangle){ GetScreenWidth()/2 - 120, GetScreenHeight()/2 - 60, 240, 140 }, "Save", GuiIconText(ICON_FILE_SAVE, "Save file as..."), "Ok;Cancel", textInput, 255, NULL);
if (result == 1)
{

View File

@ -3546,20 +3546,23 @@ const char *GuiIconText(int iconId, const char *text)
return NULL;
#else
static char buffer[1024] = { 0 };
memset(buffer, 0, 1024);
sprintf(buffer, "#%03i#", iconId);
static char iconBuffer[6] = {0};
if (text != NULL)
{
memset(buffer, 0, 1024);
sprintf(buffer, "#%03i#", iconId);
for (int i = 5; i < 1024; i++)
{
buffer[i] = text[i - 5];
if (text[i - 5] == '\0') break;
}
}
return buffer;
}
else {
sprintf(iconBuffer, "#%03i#", iconId&0x1ff);
return iconBuffer;
}
#endif
}