Просмотр исходного кода

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

gulrak 3 лет назад
Родитель
Сommit
013f1a2772
2 измененных файлов с 9 добавлено и 6 удалено
  1. 1 1
      examples/controls_test_suite/controls_test_suite.c
  2. 8 5
      src/raygui.h

+ 1 - 1
examples/controls_test_suite/controls_test_suite.c

@@ -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)
                 {

+ 8 - 5
src/raygui.h

@@ -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
 }