Skip to content

Commit

Permalink
Updated examples to new raylib 4.2 files API
Browse files Browse the repository at this point in the history
  • Loading branch information
raysan5 committed Jun 29, 2022
1 parent 7ef0ae7 commit 9c826f2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 25 deletions.
9 changes: 4 additions & 5 deletions examples/image_exporter/image_exporter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -89,7 +88,7 @@ int main(int argc, char *argv[])
}
}

UnloadDroppedFiles();
UnloadDroppedFiles(droppedFiles);
}

if (btnExport)
Expand Down
13 changes: 6 additions & 7 deletions examples/image_importer_raw/image_importer_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -108,7 +107,7 @@ int main()
importWindowActive = true;
}

UnloadDroppedFiles();
UnloadDroppedFiles(droppedFiles);
}

// Check if load button has been pressed
Expand Down
7 changes: 3 additions & 4 deletions examples/style_selector/style_selector.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 6 additions & 7 deletions examples/textbox_selection/textbox_selection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -162,7 +161,7 @@ int main(int argc, char **argv)
}
}

UnloadDroppedFiles();
UnloadDroppedFiles(droppedFiles);
}

// Convert text to hex representation and draw it on screen
Expand Down
4 changes: 2 additions & 2 deletions projects/VS2022/examples/test.props
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9c826f2

Please sign in to comment.