From 9c826f213f5b287159a0b0e1a0670a27c09dcc7e Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 29 Jun 2022 19:45:47 +0200 Subject: [PATCH] Updated examples to new `raylib 4.2` files API --- examples/image_exporter/image_exporter.c | 9 ++++----- examples/image_importer_raw/image_importer_raw.c | 13 ++++++------- examples/style_selector/style_selector.c | 7 +++---- examples/textbox_selection/textbox_selection.c | 13 ++++++------- projects/VS2022/examples/test.props | 4 ++-- 5 files changed, 21 insertions(+), 25 deletions(-) diff --git a/examples/image_exporter/image_exporter.c b/examples/image_exporter/image_exporter.c index 7abf2b5..4d38e98 100644 --- a/examples/image_exporter/image_exporter.c +++ b/examples/image_exporter/image_exporter.c @@ -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) diff --git a/examples/image_importer_raw/image_importer_raw.c b/examples/image_importer_raw/image_importer_raw.c index 2735097..fd5c6a9 100644 --- a/examples/image_importer_raw/image_importer_raw.c +++ b/examples/image_importer_raw/image_importer_raw.c @@ -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 diff --git a/examples/style_selector/style_selector.c b/examples/style_selector/style_selector.c index e332c99..75db82c 100644 --- a/examples/style_selector/style_selector.c +++ b/examples/style_selector/style_selector.c @@ -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) diff --git a/examples/textbox_selection/textbox_selection.c b/examples/textbox_selection/textbox_selection.c index ecbba2d..e9a5333 100644 --- a/examples/textbox_selection/textbox_selection.c +++ b/examples/textbox_selection/textbox_selection.c @@ -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 diff --git a/projects/VS2022/examples/test.props b/projects/VS2022/examples/test.props index aeaaab6..e3a6e09 100644 --- a/projects/VS2022/examples/test.props +++ b/projects/VS2022/examples/test.props @@ -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