mirror of
https://github.com/raysan5/raygui.git
synced 2026-02-02 04:09:18 -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())
|
if (IsFileDropped())
|
||||||
{
|
{
|
||||||
int fileCount = 0;
|
FilePathList droppedFiles = LoadDroppedFiles();
|
||||||
char **droppedFiles = LoadDroppedFiles(&fileCount);
|
|
||||||
|
|
||||||
if (fileCount == 1)
|
if (droppedFiles.count == 1)
|
||||||
{
|
{
|
||||||
Image imTemp = LoadImage(droppedFiles[0]);
|
Image imTemp = LoadImage(droppedFiles.paths[0]);
|
||||||
|
|
||||||
if (imTemp.data != NULL)
|
if (imTemp.data != NULL)
|
||||||
{
|
{
|
||||||
@ -89,7 +88,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UnloadDroppedFiles();
|
UnloadDroppedFiles(droppedFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btnExport)
|
if (btnExport)
|
||||||
|
|||||||
@ -82,21 +82,20 @@ int main()
|
|||||||
// Check if a file is dropped
|
// Check if a file is dropped
|
||||||
if (IsFileDropped())
|
if (IsFileDropped())
|
||||||
{
|
{
|
||||||
int fileCount = 0;
|
FilePathList droppedFiles = LoadDroppedFiles();
|
||||||
char **droppedFiles = LoadDroppedFiles(&fileCount);
|
|
||||||
|
|
||||||
// Check file extensions for drag-and-drop
|
// 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);
|
fseek(imageFile, 0L, SEEK_END);
|
||||||
dataSize = ftell(imageFile);
|
dataSize = ftell(imageFile);
|
||||||
fclose(imageFile);
|
fclose(imageFile);
|
||||||
|
|
||||||
// NOTE: Returned string is just a pointer to droppedFiles[0],
|
// NOTE: Returned string is just a pointer to droppedFiles[0],
|
||||||
// we need to make a copy of that data somewhere else: fileName
|
// we need to make a copy of that data somewhere else: fileName
|
||||||
strcpy(fileNamePath, droppedFiles[0]);
|
strcpy(fileNamePath, droppedFiles.paths[0]);
|
||||||
strcpy(fileName, GetFileName(droppedFiles[0]));
|
strcpy(fileName, GetFileName(droppedFiles.paths[0]));
|
||||||
|
|
||||||
// Try to guess possible raw values
|
// Try to guess possible raw values
|
||||||
// Let's assume image is square, RGBA, 8 bit per channel
|
// Let's assume image is square, RGBA, 8 bit per channel
|
||||||
@ -108,7 +107,7 @@ int main()
|
|||||||
importWindowActive = true;
|
importWindowActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
UnloadDroppedFiles();
|
UnloadDroppedFiles(droppedFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if load button has been pressed
|
// Check if load button has been pressed
|
||||||
|
|||||||
@ -140,12 +140,11 @@ int main()
|
|||||||
|
|
||||||
if (IsFileDropped())
|
if (IsFileDropped())
|
||||||
{
|
{
|
||||||
int dropFileCount = 0;
|
FilePathList droppedFiles = LoadDroppedFiles();
|
||||||
char **droppedFiles = LoadDroppedFiles(&dropFileCount);
|
|
||||||
|
|
||||||
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)
|
if (visualStyleActive != prevVisualStyleActive)
|
||||||
|
|||||||
@ -141,14 +141,13 @@ int main(int argc, char **argv)
|
|||||||
// Fonts drag & drop logic
|
// Fonts drag & drop logic
|
||||||
if (IsFileDropped())
|
if (IsFileDropped())
|
||||||
{
|
{
|
||||||
int count = 0;
|
FilePathList droppedFiles = LoadDroppedFiles();
|
||||||
char **files = LoadDroppedFiles(&count);
|
|
||||||
|
|
||||||
if (IsFileExtension(files[0], ".ttf") ||
|
if (IsFileExtension(droppedFiles.paths[0], ".ttf") ||
|
||||||
IsFileExtension(files[0], ".otf") ||
|
IsFileExtension(droppedFiles.paths[0], ".otf") ||
|
||||||
IsFileExtension(files[0], ".fnt"))
|
IsFileExtension(droppedFiles.paths[0], ".fnt"))
|
||||||
{
|
{
|
||||||
Font fnt = LoadFont(files[0]);
|
Font fnt = LoadFont(droppedFiles.paths[0]);
|
||||||
|
|
||||||
if (fnt.texture.id != 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
|
// 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
|
r Rect 0 0 0 100 200
|
||||||
v2 Vec2 0 20.000000 20.000000
|
v2 Vec2 0 20.000000 20.000000
|
||||||
v3 Vec3 0 12.000000 13.000000 14.000000
|
v3 Vec3 0 12.000000 13.000000 14.000000
|
||||||
v4 Vec4 1 12.000000 13.000000 14.000000 15.000000
|
v4 Vec4 0 12.000000 13.000000 14.000000 15.000000
|
||||||
c Color 1 0 255 0 255
|
c Color 0 0 255 0 255
|
||||||
|
|||||||
Reference in New Issue
Block a user