mirror of
https://github.com/raysan5/raygui.git
synced 2025-12-25 10:22:33 -05:00
Updated examples to new raylib 4.2 files API
This commit is contained in:
@ -66,12 +66,11 @@ int main(int argc, char *argv[])
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsFileDropped())
|
||||
{
|
||||
int fileCount = 0;
|
||||
char **droppedFiles = LoadDroppedFiles(&fileCount);
|
||||
FilePathList droppedFiles = LoadDroppedFiles();
|
||||
|
||||
if (fileCount == 1)
|
||||
if (droppedFiles.count == 1)
|
||||
{
|
||||
Image imTemp = LoadImage(droppedFiles[0]);
|
||||
Image imTemp = LoadImage(droppedFiles.paths[0]);
|
||||
|
||||
if (imTemp.data != NULL)
|
||||
{
|
||||
@ -89,7 +88,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
UnloadDroppedFiles();
|
||||
UnloadDroppedFiles(droppedFiles);
|
||||
}
|
||||
|
||||
if (btnExport)
|
||||
|
||||
@ -82,21 +82,20 @@ int main()
|
||||
// Check if a file is dropped
|
||||
if (IsFileDropped())
|
||||
{
|
||||
int fileCount = 0;
|
||||
char **droppedFiles = LoadDroppedFiles(&fileCount);
|
||||
FilePathList droppedFiles = LoadDroppedFiles();
|
||||
|
||||
// Check file extensions for drag-and-drop
|
||||
if ((fileCount == 1) && IsFileExtension(droppedFiles[0], ".raw"))
|
||||
if ((droppedFiles.count == 1) && IsFileExtension(droppedFiles.paths[0], ".raw"))
|
||||
{
|
||||
FILE *imageFile = fopen(droppedFiles[0], "rb");
|
||||
FILE *imageFile = fopen(droppedFiles.paths[0], "rb");
|
||||
fseek(imageFile, 0L, SEEK_END);
|
||||
dataSize = ftell(imageFile);
|
||||
fclose(imageFile);
|
||||
|
||||
// NOTE: Returned string is just a pointer to droppedFiles[0],
|
||||
// we need to make a copy of that data somewhere else: fileName
|
||||
strcpy(fileNamePath, droppedFiles[0]);
|
||||
strcpy(fileName, GetFileName(droppedFiles[0]));
|
||||
strcpy(fileNamePath, droppedFiles.paths[0]);
|
||||
strcpy(fileName, GetFileName(droppedFiles.paths[0]));
|
||||
|
||||
// Try to guess possible raw values
|
||||
// Let's assume image is square, RGBA, 8 bit per channel
|
||||
@ -108,7 +107,7 @@ int main()
|
||||
importWindowActive = true;
|
||||
}
|
||||
|
||||
UnloadDroppedFiles();
|
||||
UnloadDroppedFiles(droppedFiles);
|
||||
}
|
||||
|
||||
// Check if load button has been pressed
|
||||
|
||||
@ -140,12 +140,11 @@ int main()
|
||||
|
||||
if (IsFileDropped())
|
||||
{
|
||||
int dropFileCount = 0;
|
||||
char **droppedFiles = LoadDroppedFiles(&dropFileCount);
|
||||
FilePathList droppedFiles = LoadDroppedFiles();
|
||||
|
||||
if ((dropFileCount > 0) && IsFileExtension(droppedFiles[0], ".rgs")) GuiLoadStyle(droppedFiles[0]);
|
||||
if ((droppedFiles.count > 0) && IsFileExtension(droppedFiles.paths[0], ".rgs")) GuiLoadStyle(droppedFiles.paths[0]);
|
||||
|
||||
UnloadDroppedFiles(); // Clear internal buffers
|
||||
UnloadDroppedFiles(droppedFiles); // Clear internal buffers
|
||||
}
|
||||
|
||||
if (visualStyleActive != prevVisualStyleActive)
|
||||
|
||||
@ -141,14 +141,13 @@ int main(int argc, char **argv)
|
||||
// Fonts drag & drop logic
|
||||
if (IsFileDropped())
|
||||
{
|
||||
int count = 0;
|
||||
char **files = LoadDroppedFiles(&count);
|
||||
FilePathList droppedFiles = LoadDroppedFiles();
|
||||
|
||||
if (IsFileExtension(files[0], ".ttf") ||
|
||||
IsFileExtension(files[0], ".otf") ||
|
||||
IsFileExtension(files[0], ".fnt"))
|
||||
if (IsFileExtension(droppedFiles.paths[0], ".ttf") ||
|
||||
IsFileExtension(droppedFiles.paths[0], ".otf") ||
|
||||
IsFileExtension(droppedFiles.paths[0], ".fnt"))
|
||||
{
|
||||
Font fnt = LoadFont(files[0]);
|
||||
Font fnt = LoadFont(droppedFiles.paths[0]);
|
||||
|
||||
if (fnt.texture.id != 0)
|
||||
{
|
||||
@ -162,7 +161,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
UnloadDroppedFiles();
|
||||
UnloadDroppedFiles(droppedFiles);
|
||||
}
|
||||
|
||||
// Convert text to hex representation and draw it on screen
|
||||
|
||||
@ -23,5 +23,5 @@ i Int Range 0 32 0 100 1
|
||||
r Rect 0 0 0 100 200
|
||||
v2 Vec2 0 20.000000 20.000000
|
||||
v3 Vec3 0 12.000000 13.000000 14.000000
|
||||
v4 Vec4 1 12.000000 13.000000 14.000000 15.000000
|
||||
c Color 1 0 255 0 255
|
||||
v4 Vec4 0 12.000000 13.000000 14.000000 15.000000
|
||||
c Color 0 0 255 0 255
|
||||
|
||||
Reference in New Issue
Block a user